factor out schroot
[mirror/dsa-puppet.git] / modules / roles / files / static-mirroring / static-master-update-component
index d9dae27..f2ea116 100755 (executable)
@@ -35,6 +35,10 @@ base=/home/staticsync/static-master/master
 set -e
 set -u
 
+if [ "`id -u`" != "`stat -c %u "$base"`" ]; then
+  echo >&2 "You are probably running this as the wrong user."
+  exit 1
+fi
 
 lock() {
   local fd="$1"; shift
@@ -84,6 +88,10 @@ if [ -z "$srchost" ] || [ -z "$srcdir" ]; then
   exit 1
 fi
 tgt="$base/$component"
+if ! [ -d "$tgt" ]; then
+  echo "$0: Creating $tgt for $component";
+  mkdir "$tgt"
+fi
 
 if [ "$srchost" = "`hostname -f`" ]; then
   src="$srcdir"
@@ -105,7 +113,8 @@ echo "$0: Got them."
 
 echo "$0: Updating master copy of $component..."
 rsync --delete \
-  -tr \
+  -trz \
+  --links --hard-links --safe-links \
   --link-dest="$tgt" \
   "$src/." "$tmpdir_new/."
 echo "$0: Done.  Committing."