diff options
author | Roger Leigh <rleigh@debian.org> | 2008-01-19 18:20:48 +0000 |
---|---|---|
committer | Roger Leigh <rleigh@debian.org> | 2008-01-19 18:20:48 +0000 |
commit | 9cf698ef0bd5c7c117d0fea6ff60eb57823d88db (patch) | |
tree | 9d5558b04002d658293de3dae6649399afb7b9d4 /bin | |
parent | 24280efd624d3a97c8cfa9dfb4190b3c9f9d31ae (diff) | |
download | schroot-9cf698ef0bd5c7c117d0fea6ff60eb57823d88db.tar.gz |
* bin/schroot/setup/20copyfiles
(copy_file): Add checks that source and destination both exist.
* bin/schroot/Makefile.am
(pkgsysconf_DATA): Add copyfiles-defaults.
Diffstat (limited to 'bin')
-rw-r--r-- | bin/schroot/Makefile.am | 6 | ||||
-rwxr-xr-x | bin/schroot/setup/20copyfiles | 32 |
2 files changed, 28 insertions, 10 deletions
diff --git a/bin/schroot/Makefile.am b/bin/schroot/Makefile.am index 2dec9b9f..4567b930 100644 --- a/bin/schroot/Makefile.am +++ b/bin/schroot/Makefile.am @@ -50,7 +50,11 @@ schroot_LDADD = libschroot.la pkgsysconfdir = $(PACKAGE_SYSCONF_DIR) -pkgsysconf_DATA = schroot.conf mount-defaults script-defaults +pkgsysconf_DATA = \ + schroot.conf \ + copyfiles-defaults \ + mount-defaults \ + script-defaults man_MANS = \ schroot.1 \ diff --git a/bin/schroot/setup/20copyfiles b/bin/schroot/setup/20copyfiles index 2ce22042..0103721d 100755 --- a/bin/schroot/setup/20copyfiles +++ b/bin/schroot/setup/20copyfiles @@ -32,20 +32,34 @@ fi # $2: destination file copy_file() { - # Device and inode - da=$(/usr/bin/stat --format="%d %i" "$1") - db=$(/usr/bin/stat --format="%d %i" "$2") + if [ -r "$1" ]; then + if [ -r "$2" ]; then - # Content - ca=$(/usr/bin/md5sum "$1" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/') - cb=$(/usr/bin/md5sum "$2" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/') + # Device and inode + da=$(/usr/bin/stat --format="%d %i" "$1") + db=$(/usr/bin/stat --format="%d %i" "$2") - if [ "$da" != "$db" ]; then - if [ "$ca" != "$cb" ]; then + # Content + ca=$(/usr/bin/md5sum "$1" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/') + cb=$(/usr/bin/md5sum "$2" | sed -e 's/\(^[0-9a-f][0-9a-f]*\).*$/\1/') + + # Copy if files are different + if [ "$da" != "$db" ]; then + if [ "$ca" != "$cb" ]; then + cp $VERBOSE "$1" "$2" + fi + fi + + else + + # Copy if destination file does not exist cp $VERBOSE "$1" "$2" + fi - fi + else + echo "W: Not copying nonexistent file: $file" + fi } if [ $1 = "setup-start" ] || [ $1 = "setup-recover" ]; then |