Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bugs, incorporated Bombich Software changes #7

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ all:
cd util && make
clean:
cd util && make clean
realclean:
-umount /Volumes/Src
-umount /Volumes/Dst
-rm -f Src.sparseimage Dst.sparseimage
#
# Developer targets. To use this:
# 1. Change ./VERSION to reflect the release version
Expand Down
3 changes: 2 additions & 1 deletion autopilot
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ echo "We're now going to create two disk images, create some files on one,"
echo "copy them to the other, and find out what metadata was preserved."
echo

set -ex
set -x

make
./bbouncer create-vol Src
./bbouncer create-vol Dst
./bbouncer create /Volumes/Src
./bbouncer copy -d /Volumes/Src /Volumes/Dst
#./bbouncer copy -c 16-rsync-fink -t 00-basic-permissions -d /Volumes/Src /Volumes/Dst
15 changes: 8 additions & 7 deletions bbouncer
Original file line number Diff line number Diff line change
Expand Up @@ -110,10 +110,10 @@ read-copiers () {
}

create-vol () {
hdiutil create -size 40m -fs 'Journaled HFS+' \
hdiutil create -size 130m -fs 'Journaled HFS+' \
-volname $1 -type SPARSE ./$1
hdiutil attach -owners on ./$1.sparseimage
/usr/bin/which -s fsaclctl && sudo fsaclctl -p /Volumes/$1 -e
/usr/bin/which fsaclctl > /dev/null && sudo fsaclctl -p /Volumes/$1 -e
touch /Volumes/$1/bbouncer-vol
}

Expand Down Expand Up @@ -217,6 +217,8 @@ copy () {
echo
for c in $copiers; do
cnice=${c:3}
echo
echo "--------------------------------------------"
printf "Copying with: %${printWidth}s ... " "$cnice"
mkdir $dst/$c
bash util/copy-runner copiers.d/$c.cp $src $dst/$c
Expand All @@ -225,12 +227,11 @@ copy () {
# Make sure the volume can be cleaned
touch $dst/$c/bbouncer-vol
[ "$code" = "0" ] && echo ok \
|| echo FAIL
done
for c2 in $copiers; do
|| echo FAIL/warn\?
# done
# for c2 in $copiers; do
c2=("${c[@]}") # truly, bash has quoting issues
cnice=${c2:3}
echo
echo "------------------ $cnice ------------------"
if [ -e $dst/$c2/skipped ]; then
echo " This copier was skipped"
else
Expand Down
1 change: 1 addition & 0 deletions copiers.d/10-rsync-apple.cp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ flags="-aH -E --rsync-path=$rsync"
# Should exit with code 0 if the necessary programs exist, 1 otherwise
can-copy () {
test -e $rsync
false # hangs on fifo
}

# Should generate some text on stdout identifying which version of the
Expand Down
4 changes: 2 additions & 2 deletions copiers.d/60-pax.cp
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ can-copy () {
version () {
ls -l $pax
echo
echo "command = cd src; sudo $pax -rw $flags . dst"
echo "command = cd src; sudo $pax -rw -pe $flags . dst"
}

backup () {
cd $1
sudo $pax -rw $flags . $2
sudo $pax -rw -pe $flags . $2
}
6 changes: 3 additions & 3 deletions copiers.d/70-xar-apple.cp
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ version () {
cd src
sudo $xar -c -f tmpfile . \
&& cd dst \
&& sudo $xar -x -P -f tmpfile"
&& sudo $xar -x --keep-setuid -P -f tmpfile"
}

backup () {
cd $1
# xar doesn't work with pipes yet, so we use a tmpfile
tmpfile=`mktemp -t bbouncer-xar` || exit 1
tmpfile=`mktemp` || exit 1 # Need to use mktemp correctly!
sudo $xar -c -f $tmpfile . \
&& cd $2 \
&& sudo $xar -x -P -f $tmpfile
&& sudo $xar -x --keep-setuid -P -f $tmpfile
code=$?
rm -f $tmpfile
return $code
Expand Down
6 changes: 3 additions & 3 deletions copiers.d/75-xar-svn.cp
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ version () {
cd src
sudo $xar -c -f tmpfile . \
&& cd dst \
&& sudo $xar -x -P -f tmpfile"
&& sudo $xar -x --keep-setuid -P -f $tmpfile"
}

backup () {
cd $1
# xar doesn't work with pipes yet, so we use a tmpfile
tmpfile=`mktemp -t bbouncer-xar` || exit 1
tmpfile=`mktemp` || exit 1 # Need to use mktemp correctly!
sudo $xar -c -f $tmpfile . \
&& cd $2 \
&& sudo $xar -x -P -f $tmpfile
&& sudo $xar -x --keep-setuid -P -f $tmpfile
code=$?
rm -f $tmpfile
return $code
Expand Down
12 changes: 12 additions & 0 deletions tests.d/00-basic-permissions.test
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,16 @@ create () {

touch owned-by-me
chmod 1777 owned-by-me

touch owned-by-me-suid
chmod u+s owned-by-me-suid

touch owned-by-me-guid
chmod g+s owned-by-me-guid

touch owned-by-me-sticky
chmod o+t owned-by-me-sticky

touch owned-by-root
sudo chown root:wheel owned-by-root

Expand Down Expand Up @@ -51,6 +60,9 @@ verify () {
cd $1

compare ./owned-by-me $2/owned-by-me \
&& compare ./owned-by-me-suid $2/owned-by-me-suid \
&& compare ./owned-by-me-guid $2/owned-by-me-guid \
&& compare ./owned-by-me-sticky $2/owned-by-me-sticky \
&& compare ./owned-by-root $2/owned-by-root \
&& compare ./owned-by-www $2/owned-by-www \
&& compare ./some-dir $2/some-dir
Expand Down
10 changes: 7 additions & 3 deletions tests.d/20-hardlinks.test
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ create () {
ln ./some-file link1
ln ./some-file link2
ln ./link1 link3


touch locked_link_source
ln locked_link_source locked_link_target
chflags uchg locked_link_source
# Leopard allows hard links to directories
# mkdir dir1
# mkdir dir2
Expand All @@ -21,13 +24,14 @@ create () {
verify () {
cd $1
tmpfile=/tmp/hardlinks-test
set +e
#begin-subtests

stat -f "%i" link1 > $tmpfile
stat -f "%i" link2 >> $tmpfile
stat -f "%i" link3 >> $tmpfile
test "`uniq $tmpfile | wc -l | awk '{print $1}'`" = "1"
stat -f "%i%f" locked_link_source >> $tmpfile
stat -f "%i%f" locked_link_target >> $tmpfile
test "`uniq $tmpfile | wc -l | awk '{print $1}'`" = "2"
#x1=$?
#subtest "on files" $x1

Expand Down
34 changes: 23 additions & 11 deletions tests.d/30-resource-forks.test
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,22 @@ max_priority () {
}

create () {
cd $1
set -e
echo "testing 1 2 3" > some-file
echo "Hello world" > some-file/..namedfork/rsrc
echo "testing 1 2 3" > $1/some-file
xattr-util w com.apple.ResourceFork "Hello world" $1/some-file

echo "Apple's rsync had issues with resource forks + hardlinks" > hl-rfork1
ln hl-rfork1 hl-rfork2
echo "Let's see what happens..." > hl-rfork1/..namedfork/rsrc
echo "Apple's rsync had issues with resource forks + hardlinks" > $1/hl-rfork1
ln $1/hl-rfork1 $1/hl-rfork2
xattr-util w com.apple.ResourceFork "Let's see what happens..." $1/hl-rfork1

# Resource forks > 64MB have to be handled specially
echo "big daddy" > $1/large_resource_fork
dd if=/dev/random of="$1/large_resource_fork"/..namedfork/rsrc bs=1000000 count=75
}

compare () {
set -e
# We only test regular files. Should we test others?
if [ -f "$1" ]; then
cmp "$1/..namedfork/rsrc" "$2/..namedfork/rsrc"
cmp "$1"/..namedfork/rsrc "$2"/..namedfork/rsrc
else
true
fi
Expand All @@ -36,7 +37,7 @@ verify () {

test -e ./some-file \
&& grep -q '^testing 1 2 3$' ./some-file \
&& grep -q '^Hello world$' ./some-file/..namedfork/rsrc
&& compare ./some-file $2/some-file
x1=$?
subtest "on files" $x1

Expand All @@ -49,7 +50,18 @@ verify () {
x2=$?
subtest "on hardlinked files" $x2

alltrue $x1 $x2
test_priority=$Important
test -e ./large_resource_fork \
&& compare ./large_resource_fork $2/large_resource_fork
x3=$?
subtest "with forks > 64MB" $x3


# Truncate this file in the interests of space:
rm -f $1/large_resource_fork $1/._large_resource_fork
echo got result $x3 for this > $1/large_resource_fork

alltrue $x1 $x2 $x3
}

clean () {
Expand Down
23 changes: 10 additions & 13 deletions tests.d/40-finder-flags.test
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ max_priority () {

create () {
cd $1
set -e

touch type-and-creator
SetFile -c MSWD -t TEXT type-and-creator
Expand All @@ -67,6 +66,11 @@ create () {
touch mucho-flags-file
SetFile -a ABCDEIMNSTVZ mucho-flags-file

# Use every flag possible (then lock it)
touch mucho-flags-file-locked
SetFile -a ABCDEIMNSTVZ mucho-flags-file-locked
chflags uchg mucho-flags-file-locked

# All possible on a dir
mkdir mucho-flags-dir
SetFile -a CDEIVZ mucho-flags-dir
Expand All @@ -75,18 +79,10 @@ create () {
compare () {
test "`GetFileInfo -P -a $1`" = "`GetFileInfo -P -a $2`" \
&& test "`GetFileInfo -P -m $1`" = "`GetFileInfo -P -m $2`"
x=$?
if [ -f "$1" ]; then
test "`GetFileInfo -P -t $1`" = "`GetFileInfo -P -t $2`" \
&& test "`GetFileInfo -P -c $1`" = "`GetFileInfo -P -c $2`"
x2=$?
elif [ -d "$1" ]; then
x2=0
else
echo "ERROR: Unknown file type in 40-finder-flags compare test"
x2=1
fi
alltrue $x $x2
if [ ! -d $1 ]; then
test "`GetFileInfo -P -t $1`" = "`GetFileInfo -P -t $2`" \
&& test "`GetFileInfo -P -c $1`" = "`GetFileInfo -P -c $2`"
fi
}

verify () {
Expand All @@ -99,6 +95,7 @@ verify () {
&& test "`GetFileInfo -ae hidden-extension.txt`" = "1" \
&& test "`GetFileInfo -as system-file`" = "1" \
&& compare ./mucho-flags-file $2/mucho-flags-file \
&& compare ./mucho-flags-file-locked $2/mucho-flags-file-locked \
&& compare ./mucho-flags-dir $2/mucho-flags-dir
}

Expand Down
1 change: 0 additions & 1 deletion tests.d/45-finder-locks.test
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ max_priority () {

create () {
cd $1
set -e
touch 'locked-file'
SetFile -a L locked-file
}
Expand Down
1 change: 0 additions & 1 deletion tests.d/50-creation-date.test
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ max_priority () {

create () {
cd $1
set -e
touch creation-date-test
# Make sure the creation date isn't the same as the access/modification date
# The modification date from SetFile is the same as the standard mtime.
Expand Down
1 change: 0 additions & 1 deletion tests.d/60-bsd-flags.test
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ max_priority () {

create () {
cd $1
set -e

mkdir dir-with-flags
chflags uappnd,uchg,nodump,opaque dir-with-flags
Expand Down
Loading