SHA256
1
0
forked from pool/quilt

- quilt-setup-04-handle-zip-files.patch: Refresh from upstream.

- quilt-setup-05-fix-check_for_existing_files.patch: Fix handling
  of directory names including white spaces by
  check_for_existing_files.
- quilt-setup-06-check-for-directories-too.patch: Check for
  existing directories before unpacking.

OBS-URL: https://build.opensuse.org/package/show/devel:tools:scm/quilt?expand=0&rev=63
This commit is contained in:
Jean Delvare 2012-10-19 09:18:16 +00:00 committed by Git OBS Bridge
parent 014ebed9b5
commit 545a92cf89
5 changed files with 152 additions and 24 deletions

View File

@ -1,27 +1,13 @@
References: bnc#768332
Let quilt setup handle zip archives referenced in spec files.
---
quilt/scripts/inspect.in | 33 +++++++++++++++++++++++++++++++++
quilt/setup.in | 11 +++++++++++
2 files changed, 44 insertions(+)
quilt/scripts/inspect.in | 28 ++++++++++++++++++++++++++++
quilt/setup.in | 23 +++++++++++++++++++++--
2 files changed, 49 insertions(+), 2 deletions(-)
--- a/quilt/scripts/inspect.in
+++ b/quilt/scripts/inspect.in
@@ -133,6 +133,11 @@ do
set -- $(lzma -cd "$file" | md5sum)
echo "$1 $basename"
;;
+ Zip*)
+ # There is no uncompressed archive equivalent but
+ # still notify the user we are processing an archive.
+ echo -n "Z" >&4
+ ;;
esac
done > $tmpdir/md5sums
echo >&4
@@ -251,6 +256,21 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
@@ -251,6 +251,21 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
esac
}
@ -43,7 +29,7 @@ Let quilt setup handle zip archives referenced in spec files.
tar_opt_C() {
case "$1" in
*C*f*)
@@ -270,6 +290,9 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
@@ -270,6 +285,9 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
# For tar, file - means read from stdin
[ "$inputfile" = "-" ] && inputfile=
;;
@ -53,7 +39,7 @@ Let quilt setup handle zip archives referenced in spec files.
esac
if [ -z "$inputfile" ]; then
# put data from stdin into tmpfile
@@ -309,6 +332,14 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
@@ -309,6 +327,14 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
dir=${dir// /\\ }
echo "${0##*/} ${dir:-.} $unpackfile" >&3
;;
@ -68,7 +54,7 @@ Let quilt setup handle zip archives referenced in spec files.
esac
fi
@@ -333,6 +364,7 @@ fi
@@ -333,6 +359,7 @@ fi
ln -s wrapper $tmpdir/bin/patch
ln -s wrapper $tmpdir/bin/tar
@ -76,7 +62,7 @@ Let quilt setup handle zip archives referenced in spec files.
# let rpm do all the dirty specfile stuff ...
echo -n "### rpmbuild: " >&4
@@ -343,6 +375,7 @@ rpmbuild --eval "%define _sourcedir $sou
@@ -343,6 +370,7 @@ rpmbuild --eval "%define _sourcedir $sou
--eval "%define _builddir $tmpdir/build" \
--eval "%define __patch $tmpdir/bin/patch" \
--eval "%define __tar $tmpdir/bin/tar" \
@ -86,7 +72,24 @@ Let quilt setup handle zip archives referenced in spec files.
-bp "$specdir/$specfile" < /dev/null >&5 2>&5
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -198,6 +198,17 @@ do
@@ -167,7 +167,15 @@ case "$1" in
"# Source: "*)
shift 2
source="$@"
- echo "tar ${tar_dir:-.} ${source// /\\ }"
+ filetype="$(file -b "$source")"
+ case "$filetype" in
+ Zip*)
+ echo "unzip ${tar_dir:-.} ${source// /\\ }"
+ ;;
+ *)
+ echo "tar ${tar_dir:-.} ${source// /\\ }"
+ ;;
+ esac
;;
"# Patchdir: "*)
shift 2
@@ -198,6 +206,17 @@ do
cat_file "$tarball" \
| tar xf - -C "$prefix$dir"
;;
@ -99,8 +102,17 @@ Let quilt setup handle zip archives referenced in spec files.
+ fi
+ printf $"Unpacking archive %s\n" "$tarball"
+ mkdir -p "${prefix:-.}" "$prefix$dir"
+ (cd "$prefix$dir" && unzip -qq "$tarball")
+ unzip -qqo "$tarball" -d "$prefix$dir"
+ ;;
esac
done < $tmpfile
@@ -212,7 +231,7 @@ fi
while read tag dir arg1 arg2
do
case "$tag" in
- tar)
+ tar|unzip)
tar_dir="$dir"
[ "$tar_dir" = . ] && tar_dir=
tar_file="$arg1"

View File

@ -0,0 +1,37 @@
Fix handling of directory names including white spaces by
check_for_existing_files. awk can't deal with tokens which include
white spaces, so use bash's read function instead.
As a side bonus, we get rid of the undocumented dependency to "uniq".
---
quilt/setup.in | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -23,9 +23,12 @@ then
fi
check_for_existing_files() {
- local dir status=0
- for dir in $(awk ' $1 == "patch" { print $2 }' $tmpfile | uniq)
+ local tag dir last_dir arg status=0
+
+ while read tag dir arg
do
+ [ "$tag" = "patch" -a "$dir" != "$last_dir" ] || continue
+
if [ -e "$prefix$dir/$QUILT_PATCHES" ]
then
printf $"Directory %s exists\n" \
@@ -38,7 +41,9 @@ check_for_existing_files() {
"$prefix$dir/$QUILT_SERIES" >&2
status=1
fi
- done
+ last_dir=$dir
+ done < $tmpfile
+
return $status
}

View File

@ -0,0 +1,65 @@
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

View File

@ -1,3 +1,13 @@
-------------------------------------------------------------------
Fri Oct 19 11:15:16 CEST 2012 - jdelvare@suse.de
- quilt-setup-04-handle-zip-files.patch: Refresh from upstream.
- quilt-setup-05-fix-check_for_existing_files.patch: Fix handling
of directory names including white spaces by
check_for_existing_files.
- quilt-setup-06-check-for-directories-too.patch: Check for
existing directories before unpacking.
-------------------------------------------------------------------
Wed Oct 17 21:42:44 CEST 2012 - jdelvare@suse.de

View File

@ -54,6 +54,8 @@ Patch7: quilt-setup-01-check-existing-files-after-unpack.patch
Patch8: quilt-setup-02-try-alternative-names.patch
Patch9: quilt-setup-03-remember-alternative-names.patch
Patch10: quilt-setup-04-handle-zip-files.patch
Patch11: quilt-setup-05-fix-check_for_existing_files.patch
Patch12: quilt-setup-06-check-for-directories-too.patch
Url: http://savannah.nongnu.org/projects/quilt
BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch
@ -83,6 +85,8 @@ Authors:
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%build
# --with-rpmbuild=/usr/lib/rpm/rpmb: