summaryrefslogtreecommitdiffstats
path: root/sched
diff options
context:
space:
mode:
authorJean-Philippe Lesot <jplesot@google.com>2015-03-19 22:10:06 +0100
committerJean-Philippe Lesot <jplesot@google.com>2015-03-20 11:12:04 +0100
commit09e3ba8880b4e5c2540651a3c6f166602c469ff5 (patch)
tree45f53f0a7465b217e28df0380ca63a1bc0afc322 /sched
parent9f7aaba834167a3c6636e9a2403bfc9df65b49aa (diff)
downloadtoolchain_jack-09e3ba8880b4e5c2540651a3c6f166602c469ff5.zip
toolchain_jack-09e3ba8880b4e5c2540651a3c6f166602c469ff5.tar.gz
toolchain_jack-09e3ba8880b4e5c2540651a3c6f166602c469ff5.tar.bz2
Make Jack script more robust
- Add small support of interruptions, but no synchronization with the compilation server. - Add support of space in command line, but do not support double quote. - Stale lock support. - More robust server by being over-conservative. Change-Id: Ia5fe022e6b820c9c589a1d524278eed0b8009a48
Diffstat (limited to 'sched')
-rw-r--r--sched/src/com/android/sched/util/file/CannotSetPermissionException.java10
-rw-r--r--sched/src/com/android/sched/util/file/CannotUnsetPermissionException.java70
-rw-r--r--sched/src/com/android/sched/util/file/FileOrDirectory.java8
3 files changed, 79 insertions, 9 deletions
diff --git a/sched/src/com/android/sched/util/file/CannotSetPermissionException.java b/sched/src/com/android/sched/util/file/CannotSetPermissionException.java
index 59c203b..273279f 100644
--- a/sched/src/com/android/sched/util/file/CannotSetPermissionException.java
+++ b/sched/src/com/android/sched/util/file/CannotSetPermissionException.java
@@ -60,10 +60,10 @@ public class CannotSetPermissionException extends WithLocationException {
@Override
protected String createMessage(@Nonnull String description) {
- return description + " can not be set " +
- ((permission == Permission.READ) ? "readable" :
- ((permission == Permission.WRITE) ? "writable" :
- ((permission == Permission.EXECUTE) ? "executable" : "???"))) +
- ((change == ChangePermission.EVERYBODY) ? " for everybody" : "");
+ return description + " cannot have its " +
+ ((permission == Permission.READ) ? "readable " :
+ ((permission == Permission.WRITE) ? "writable " :
+ ((permission == Permission.EXECUTE) ? "executable " : "???"))) + "permission set" +
+ ((change == ChangePermission.EVERYBODY) ? "for everybody" : "");
}
}
diff --git a/sched/src/com/android/sched/util/file/CannotUnsetPermissionException.java b/sched/src/com/android/sched/util/file/CannotUnsetPermissionException.java
new file mode 100644
index 0000000..cb733cc
--- /dev/null
+++ b/sched/src/com/android/sched/util/file/CannotUnsetPermissionException.java
@@ -0,0 +1,70 @@
+/*
+ * Copyright (C) 2015 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.sched.util.file;
+
+import com.android.sched.util.file.FileOrDirectory.ChangePermission;
+import com.android.sched.util.file.FileOrDirectory.Permission;
+import com.android.sched.util.location.HasLocation;
+import com.android.sched.util.location.Location;
+
+import javax.annotation.CheckForNull;
+import javax.annotation.Nonnull;
+
+/**
+ * Exception when a file or directory can not be cleared of the expected permission.
+ */
+public class CannotUnsetPermissionException extends WithLocationException {
+ private static final long serialVersionUID = 1L;
+
+ private final int permission;
+ @Nonnull
+ private final ChangePermission change;
+
+ public CannotUnsetPermissionException(@Nonnull Location location, int permission,
+ @Nonnull ChangePermission change) {
+ this(location, permission, change, null);
+ }
+
+ public CannotUnsetPermissionException(@Nonnull Location location, int permission,
+ @Nonnull ChangePermission change, @CheckForNull Throwable cause) {
+ super(location, cause);
+ this.permission = permission;
+ this.change = change;
+ }
+
+ public CannotUnsetPermissionException(@Nonnull HasLocation locationProvider, int permission,
+ @Nonnull ChangePermission change) {
+ this(locationProvider, permission, change, null);
+ }
+
+ public CannotUnsetPermissionException(@Nonnull HasLocation locationProvider, int permission,
+ @Nonnull ChangePermission change, @CheckForNull Throwable cause) {
+ super(locationProvider, cause);
+ this.permission = permission;
+ this.change = change;
+ }
+
+ @Override
+ @Nonnull
+ protected String createMessage(@Nonnull String description) {
+ return description + " cannot have its " +
+ ((permission == Permission.READ) ? "readable " :
+ ((permission == Permission.WRITE) ? "writable " :
+ ((permission == Permission.EXECUTE) ? "executable " : "???"))) + "permission removed" +
+ ((change == ChangePermission.EVERYBODY) ? " for everybody" : "");
+ }
+}
diff --git a/sched/src/com/android/sched/util/file/FileOrDirectory.java b/sched/src/com/android/sched/util/file/FileOrDirectory.java
index 688e5d2..1065cd0 100644
--- a/sched/src/com/android/sched/util/file/FileOrDirectory.java
+++ b/sched/src/com/android/sched/util/file/FileOrDirectory.java
@@ -128,7 +128,7 @@ public abstract class FileOrDirectory implements HasLocation {
public static void unsetPermissions(@Nonnull File file, @Nonnull Location location,
int permissions, @Nonnull FileOrDirectory.ChangePermission change)
- throws CannotSetPermissionException {
+ throws CannotUnsetPermissionException {
if (change != ChangePermission.NOCHANGE) {
// Set access
if ((permissions & Permission.READ) != 0) {
@@ -136,7 +136,7 @@ public abstract class FileOrDirectory implements HasLocation {
logger.log(Level.FINE, "Clear readable permission to {0} (''{1}'')",
new Object[] {location.getDescription(), file.getAbsoluteFile()});
} else {
- throw new CannotSetPermissionException(location, Permission.READ,
+ throw new CannotUnsetPermissionException(location, Permission.READ,
change);
}
}
@@ -146,7 +146,7 @@ public abstract class FileOrDirectory implements HasLocation {
logger.log(Level.FINE, "Clear writable permission to {0} (''{1}'')",
new Object[] {location.getDescription(), file.getAbsoluteFile()});
} else {
- throw new CannotSetPermissionException(location, Permission.WRITE,
+ throw new CannotUnsetPermissionException(location, Permission.WRITE,
change);
}
}
@@ -156,7 +156,7 @@ public abstract class FileOrDirectory implements HasLocation {
logger.log(Level.FINE, "Clear executable permission to {0} (''{1}'')",
new Object[] {location.getDescription(), file.getAbsoluteFile()});
} else {
- throw new CannotSetPermissionException(location, Permission.EXECUTE,
+ throw new CannotUnsetPermissionException(location, Permission.EXECUTE,
change);
}
}