[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Quilt-dev] [PATCH 6/7] setup: Check for existing directories before unp
From: |
Jean Delvare |
Subject: |
[Quilt-dev] [PATCH 6/7] setup: Check for existing directories before unpacking |
Date: |
Sun, 21 Oct 2012 14:32:50 +0200 |
Check for existing directories before unpacking.
---
quilt/setup.in | 22 ++++++++++++++++++++++
test/setup.test | 7 ++++++-
2 files changed, 28 insertions(+), 1 deletion(-)
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -22,6 +22,25 @@ then
fi
fi
+check_for_existing_directories() {
+ local tag dir last_dir arg status=0
+
+ while read tag dir arg
+ do
+ [ "$dir" != "." -a "$dir" != "$last_dir" ] || continue
+
+ if [ -e "$prefix$dir" ]
+ then
+ printf $"Directory %s exists\n" \
+ "$prefix$dir" >&2
+ status=1
+ fi
+ last_dir=$dir
+ done < $tmpfile
+
+ return $status
+}
+
check_for_existing_files() {
local tag dir last_dir arg status=0
@@ -196,6 +215,9 @@ case "$1" in
;;
esac
+# Make sure that unpacking will not overwrite anything
+check_for_existing_directories || exit 1
+
while read tag dir arg1 arg2
do
case "$tag" in
--- a/test/setup.test
+++ b/test/setup.test
@@ -64,12 +64,17 @@ $ quilt push -qa
$ cd ../..
$ rm -rf "dir"
-# Now test the case where the tarball contains a patches directory
+# Now test the cases where the directory already exists, or the tarball
+# contains a patches directory
$ cat > series_with_patches
< # Source: dir_with_patches.tar.gz
< # Patchdir: dir
< #
< foo.diff
+$ mkdir dir
+$ quilt setup series_with_patches
+> Directory dir exists
+$ rmdir dir
$ quilt setup series_with_patches
> Unpacking archive dir_with_patches.tar.gz
> Directory dir/patches exists
--
Jean Delvare
Suse L3
- [Quilt-dev] [PATCH 0/7 v2] quilt setup improvements, Jean Delvare, 2012/10/21
- [Quilt-dev] [PATCH 1/7] setup: Check for existing files after unpacking, Jean Delvare, 2012/10/21
- [Quilt-dev] [PATCH 2/7] setup: Try alternative patches/series names, Jean Delvare, 2012/10/21
- [Quilt-dev] [PATCH 3/7] setup: Run create_db, Jean Delvare, 2012/10/21
- [Quilt-dev] [PATCH 4/7 v2] setup/inspect: Handle zip archives, Jean Delvare, 2012/10/21
- [Quilt-dev] [PATCH 5/7] setup: Fix white space handling by check_for_existing_files, Jean Delvare, 2012/10/21
- [Quilt-dev] [PATCH 6/7] setup: Check for existing directories before unpacking,
Jean Delvare <=
- [Quilt-dev] [PATCH 7/7] inspect: Refactor code to pwd_to_dir, Jean Delvare, 2012/10/21