quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [PATCH 4/7 v2] setup/inspect: Handle zip archives


From: Jean Delvare
Subject: [Quilt-dev] [PATCH 4/7 v2] setup/inspect: Handle zip archives
Date: Sun, 21 Oct 2012 14:31:21 +0200

Let quilt setup handle zip archives.
---
Changes since v1:
* Use unzip option -o to make sure it never gets interactive.
* Use unzip option -d so we don't have to change directory.
* Also handle zip files in series files.
 
 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
@@ -251,6 +251,21 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
                esac
        }
 
+       unzip_input_file() {
+               while [ $# -gt 0 ]; do
+                       case "$1" in
+                       -*)
+                               shift
+                               ;;
+                       *)
+                               echo "$1"
+                               return
+                               ;;
+                       esac
+               done
+               return 1
+       }
+
        tar_opt_C() {
                case "$1" in
                *C*f*)
@@ -270,6 +285,9 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
                # For tar, file - means read from stdin
                [ "$inputfile" = "-" ] && inputfile=
                ;;
+       unzip)
+               inputfile=$(unzip_input_file "$@")
+               ;;
        esac
        if [ -z "$inputfile" ]; then
            # put data from stdin into tmpfile
@@ -309,6 +327,14 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
                        dir=${dir// /\\ }
                        echo "${0##*/} ${dir:-.} $unpackfile" >&3
                        ;;
+               unzip)
+                       echo -n Z >&4
+                       dir=$PWD
+                       dir=${dir/$RPM_BUILD_DIR}
+                       dir=${dir##/}
+                       dir=${dir// /\\ }
+                       echo "${0##*/} ${dir:-.} $unpackfile" >&3
+                       ;;
                esac
        fi
 
@@ -333,6 +359,7 @@ fi
 
 ln -s wrapper $tmpdir/bin/patch
 ln -s wrapper $tmpdir/bin/tar
+ln -s wrapper $tmpdir/bin/unzip
 
 # let rpm do all the dirty specfile stuff ...
 echo -n "### rpmbuild: " >&4
@@ -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" \
+        --eval "%define __unzip    $tmpdir/bin/unzip" \
         --eval "$DEFINE_FUZZ" \
         --nodeps \
         -bp "$specdir/$specfile" < /dev/null >&5 2>&5
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -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"
                ;;
+       unzip)
+               tarball=$sourcedir$arg1
+               if [ ! -e "$tarball" ]
+               then
+                       printf $"File %s not found\n" "$tarball" >&2
+                       exit 1
+               fi
+               printf $"Unpacking archive %s\n" "$tarball"
+               mkdir -p "${prefix:-.}" "$prefix$dir"
+               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"

-- 
Jean Delvare
Suse L3




reply via email to

[Prev in Thread] Current Thread [Next in Thread]