From 3f25ce18333a8afe81ce8968f756ba986bd9b4b5 Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Wed, 1 Feb 2012 18:08:48 +0100 Subject: BSD compatibility: rmdir Use rmdir -p instead of open-coding it. The more complex code was maybe needed to properly handle symbolic links, but we know that there won't be symbolic links in the backup directory, so the extra complexity isn't needed. Signed-off-by: Jean Delvare Reviewed-by: Raphael Hertzog --- quilt.changes | 7 +++++++ quilt/scripts/backup-files.in | 27 +++------------------------ 2 files changed, 10 insertions(+), 24 deletions(-) diff --git a/quilt.changes b/quilt.changes index 4cc73cc..0b0b92f 100644 --- a/quilt.changes +++ b/quilt.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Feb 1 17:02:32 CET 2012 - jdelvare@suse.de + +- backup-files: Avoid relying on GNU-specific extensions of stat, + cp and rmdir. Otherwise it fails on BSD systems and probably + others. + ------------------------------------------------------------------- Wed Feb 1 16:58:22 CET 2012 - mquinson@debian.org diff --git a/quilt/scripts/backup-files.in b/quilt/scripts/backup-files.in index 086d178..fcfc995 100644 --- a/quilt/scripts/backup-files.in +++ b/quilt/scripts/backup-files.in @@ -117,14 +117,7 @@ process_file() { $ECHO "Removing $file" if [ -z "$OPT_KEEP_BACKUP" ]; then rm "$backup" - while [ -d "${backup%/*}" ] && ! [ -L "${backup%/*}" ] - do - backup="${backup%/*}" - rmdir --ignore-fail-on-non-empty "$backup" 2>/dev/null - if [ -d "$backup" ]; then - break - fi - done + rmdir -p "${backup%/*}" 2> /dev/null || true fi else $ECHO "Restoring $file" @@ -142,14 +135,7 @@ process_file() { if [ -z "$OPT_KEEP_BACKUP" ]; then rm "$backup" - while [ -d "${backup%/*}" ] && ! [ -L "${backup%/*}" ] - do - backup="${backup%/*}" - rmdir --ignore-fail-on-non-empty "$backup" 2>/dev/null - if [ -d "$backup" ]; then - break - fi - done + rmdir -p "${backup%/*}" 2> /dev/null || true fi if [ -n "$OPT_TOUCH" ]; then touch "$file" @@ -159,14 +145,7 @@ process_file() { if [ -e "$backup" ]; then rm "$backup" fi - while [ -d "${backup%/*}" ] && ! [ -L "${backup%/*}" ] - do - backup="${backup%/*}" - rmdir --ignore-fail-on-non-empty "$backup" 2>/dev/null - if [ -d "$backup" ]; then - break - fi - done + rmdir -p "${backup%/*}" 2> /dev/null || true elif [ -z "$OPT_WHAT" ]; then if [ -e "$file" ] && [ -n "$OPT_NOLINKS" ]; then ensure_nolinks "$file" -- cgit