]> git.michaelhowe.org Git - packages/b/bup.git/commitdiff
Don't use "cp -a"
authorRob Browning <rlb@defaultvalue.org>
Sun, 29 Mar 2015 16:47:45 +0000 (11:47 -0500)
committerRob Browning <rlb@defaultvalue.org>
Sun, 29 Mar 2015 16:47:48 +0000 (11:47 -0500)
It's not portable -- use portable cp options, or a new t/sync-tree
instead.  Thanks to Greg Troxel for reporting the problem after testing
on NetBSD 5.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Tested-by: Rob Browning <rlb@defaultvalue.org>
Documentation/bup-damage.md
t/configure-sampledata
t/sync-tree [new file with mode: 0755]
t/test-fsck.sh
t/test-import-duplicity.sh
t/test-meta.sh

index 3d64d2876cd681239b75725a306cc53b731854d7..e5c65c6065534a02dacb963fac1097feee6b1ffe 100644 (file)
@@ -73,7 +73,7 @@ actually work.
     
 # EXAMPLES
     # make a backup in case things go horribly wrong
-    cp -a ~/.bup/objects/pack ~/bup-packs.bak
+    cp -pPR ~/.bup/objects/pack ~/bup-packs.bak
     
     # generate recovery blocks for all packs
     bup fsck -g
index 256d0bf438cd6304b7575caaf6b5d2be148f14de..1603fd8370d1d8f2f3940cfd1fb512d241c14401 100755 (executable)
@@ -42,9 +42,9 @@ case "$1" in
             ln -sf b c || exit $?
             ln -sf "$(pwd)/abs-symlink-target" abs-symlink || exit $?
             mkdir -p cmd doc lib/bup || exit $?
-            cp -a "$top"/cmd/*.py cmd/ || exit $?
-            cp -a "$top"/Documentation/*.md doc/ || exit $?
-            cp -a "$top"/lib/bup/*.py lib/bup || exit $?
+            cp -pP "$top"/cmd/*.py cmd/ || exit $?
+            cp -pP "$top"/Documentation/*.md doc/ || exit $?
+            cp -pP "$top"/lib/bup/*.py lib/bup || exit $?
             # The "v" ensures that if "configure-sampledata
             # --revision" and/or the setup above fails somehow,
             # callers like make will be looking for a file that won't
diff --git a/t/sync-tree b/t/sync-tree
new file mode 100755 (executable)
index 0000000..e2b330e
--- /dev/null
@@ -0,0 +1,54 @@
+#!/usr/bin/env bash
+
+usage() {
+cat <<EOF
+Usage: sync-tree [-h] [-c] [-x] SOURCE/ DEST/
+  Make the DEST tree match SOURCE as closely as possible
+OPTIONS:
+  -h
+    Display help
+EOF
+}
+
+while getopts "h" OPTION
+do
+    case "$OPTION" in
+        h) usage; exit 0;;
+        ?) usage 1>&2; exit 1;;
+    esac
+done
+
+shift $(($OPTIND - 1)) || exit $?
+
+if ! test $# -eq 2
+then
+    usage 1>&2
+    exit 1
+fi
+
+src="$1"
+dest="$2"
+
+rsync_opts="-aH --delete"
+
+rsync_version=$(rsync --version)
+if [[ ! "$rsync_version" =~ "ACLs" ]] || [[ "$rsync_version" =~ "no ACLs" ]]; then
+    echo "Not syncing ACLs (not supported by available rsync)" 1>&2
+else
+    case $OSTYPE in
+        cygwin|darwin|netbsd)
+            echo "Not syncing ACLs (not yet supported on $OSTYPE)" 1>&2
+            ;;
+        *)
+            rsync_opts="$rsync_opts -A"
+            ;;
+    esac
+fi
+
+if [[ ! "$rsync_version" =~ "xattrs" ]] || [[ "$rsync_version" =~ "no xattrs" ]]; then
+    echo "Not syncing xattrs (not supported by available rsync)" 1>&2
+else
+    rsync_opts="$rsync_opts -X"
+fi
+
+exec rsync $rsync_opts "$src" "$dest"
index 22d909cfa9caed994209e699e62f8a0dc651c660..be1c5aac0bd8b7b139b0a6e6f7d86421cb2a56a3 100755 (executable)
@@ -8,7 +8,7 @@ tmpdir="$(WVPASS wvmktempdir)" || exit $?
 
 bup() { "$top/bup" "$@"; }
 
-WVPASS cp -a "$top/t/sampledata" "$tmpdir/src"
+WVPASS "$top/t/sync-tree" "$top/t/sampledata/" "$tmpdir/src/"
 
 export BUP_DIR="$tmpdir/bup"
 export GIT_DIR="$tmpdir/bup"
index 61fb2fff4d0a48b3d357a6823560e475f7b11b23..42e5b8352b1c06ebb77bcd34accea1da29912ab9 100755 (executable)
@@ -16,7 +16,7 @@ bup() { "$top/bup" "$@"; }
 dup() { duplicity --archive-dir "$tmpdir/dup-cache" "$@"; }
 
 WVSTART "import-duplicity"
-WVPASS cp -a "$top/t/sampledata" "$tmpdir/src"
+WVPASS "$top/t/sync-tree" "$top/t/sampledata/" "$tmpdir/src/"
 
 export BUP_DIR="$tmpdir/bup"
 export GIT_DIR="$tmpdir/bup"
index f9fa896283dc42cb58350308e2f33c85705ec662..2c886cce8b356e0963443d2caec753d0c4faa197 100755 (executable)
@@ -100,7 +100,7 @@ test-src-save-restore()
 
 setup-test-tree()
 {
-    WVPASS cp -a "$TOP/t/sampledata" "$tmpdir/src"
+    WVPASS "$TOP/t/sync-tree" "$TOP/t/sampledata/" "$tmpdir/src/"
 
     # Add some hard links for the general tests.
     (
@@ -214,7 +214,7 @@ WVSTART 'metadata save/restore (using index metadata)'
     WVPASS "$TOP/t/compare-trees" -c src/ src-restore-1/src/
 
     WVPASS echo "blarg" > src/volatile/1
-    WVPASS cp -a src/volatile/1 src-restore-1/src/volatile/
+    WVPASS cp -pP src/volatile/1 src-restore-1/src/volatile/
     WVPASS bup index src
 
     # Bup should *not* pick up these metadata changes.