summaryrefslogtreecommitdiffstats
path: root/tools/build/lock-directory.in
diff options
context:
space:
mode:
Diffstat (limited to 'tools/build/lock-directory.in')
-rw-r--r--tools/build/lock-directory.in43
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/build/lock-directory.in b/tools/build/lock-directory.in
new file mode 100644
index 0000000000..1c205cdec0
--- /dev/null
+++ b/tools/build/lock-directory.in
@@ -0,0 +1,43 @@
+#!@KSH@
+#
+# $Id$
+#
+# Make a directory write protected
+# Used to write protect the install point after a build
+# to prevent inadvertant overwriting.
+#
+
+# is a particular command available on this machine?
+#
+cmd_avail()
+{
+ set -- `type $1 2>&1`
+ if [ "$2" = "not" -a "$3" = "found" ] || [ "$3" = "not" -a "$4" = "found" ]
+ then
+ return 1
+ else
+ return 0
+ fi
+}
+
+lock_directory() {
+ l_dir=$1/. # get any symlink out of the way using '.'
+ if [ -d $l_dir ]
+ then
+ find $l_dir -type d -perm -0200 -print | $XARGS chmod -w
+ fi
+}
+
+# Use gnu xargs if available; faster, more reliable in general
+XARGS=xargs
+cmd_avail gxargs && XARGS=gxargs
+
+for dir
+do
+ lock_directory $dir
+done
+
+# Local Variables: ***
+# mode:ksh ***
+# End: ***
+