quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH v2] setup: Add basic support for p7zip (.7z) archives


From: Jean Delvare
Subject: [Quilt-dev] [PATCH v2] setup: Add basic support for p7zip (.7z) archives
Date: Thu, 02 Feb 2017 15:08:10 +0100

This should work in the most basic case (no option used.) This only
covers the case of archives being compressed with 7z, not patches.

This should fix bug #49754:
  http://savannah.nongnu.org/bugs/?49754

Remaining issues:
* 7z could also be used to compress patches, although nobody sane
  would do that.
* 7z is very verbose, and doesn't offer any option to be silent or
  even just quieter.
---
Changes since v1:
 * Handle the different possible names of the 7z extraction tool
   (7zr, 7za, 7z.)

 Makefile.in                      |    1 +
 configure.ac                     |    2 ++
 quilt/scripts/inspect-wrapper.in |   26 ++++++++++++++++++++++++++
 quilt/setup.in                   |   20 ++++++++++++++++++--
 4 files changed, 47 insertions(+), 2 deletions(-)

--- a/Makefile.in
+++ b/Makefile.in
@@ -43,6 +43,7 @@ DIFFSTAT :=   @DIFFSTAT@
 RPMBUILD :=    @RPMBUILD@
 SENDMAIL :=    @SENDMAIL@
 MD5SUM :=      @MD5SUM@
+7Z :=          @P7ZIP@
 
 USE_NLS :=     @USE_NLS@
 STAT_HARDLINK := @STAT_HARDLINK@
--- a/configure.ac
+++ b/configure.ac
@@ -411,6 +411,8 @@ AC_SUBST(docdir)
 dnl Check for rpmbuild (v4) vs. rpm (v3)
 QUILT_COMPAT_PROG_PATH_OPT(RPMBUILD, rpmbuild, [rpmbuild rpm])
 
+QUILT_COMPAT_PROG_PATH_OPT(P7ZIP, 7z, [7zr 7za 7z])
+
 AC_SUBST(COMPAT_SYMLINKS)
 AC_SUBST(COMPAT_PROGRAMS)
 
--- a/quilt/scripts/inspect-wrapper.in
+++ b/quilt/scripts/inspect-wrapper.in
@@ -189,6 +189,23 @@ unzip_input_file()
        return 1
 }
 
+_7z_input_file()
+{
+       while [ $# -gt 0 ]
+       do
+               case "$1" in
+               -*|e|x)
+                       shift
+                       ;;
+               *)
+                       echo "$1"
+                       return
+                       ;;
+               esac
+       done
+       return 1
+}
+
 tar_opt_C()
 {
        case "$1" in
@@ -240,6 +257,11 @@ unzip)
        [ -n "$QUILT_SETUP_FAST" ] && exec unzip "$@"
        inputfile=$(unzip_input_file "$@")
        ;;
+7z)
+       echo -n 7 >&4
+       [ -n "$QUILT_SETUP_FAST" ] && exec 7z "$@"
+       inputfile=$(_7z_input_file "$@")
+       ;;
 esac
 
 # If the file was not passed as a parameter, try to identify stdin
@@ -296,6 +318,10 @@ unzip)
        dir=$(pwd_to_dir)
        echo "unzip ${dir:-.} $unpackfile" >&3
        ;;
+7z)
+       dir=$(pwd_to_dir)
+       echo "7z ${dir:-.} $unpackfile" >&3
+       ;;
 esac
 
 # In fast mode, we don't actually apply patches
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -141,7 +141,7 @@ create_md5sums()
                                ;;
                        # In fast mode, we are only interested in patches, so 
filter out
                        # archives
-                       *.tar|*.tar.Z|*.tar.gz|*.tgz|*.tar.bz2|*.tar.xz|*.zip)
+                       
*.tar|*.tar.Z|*.tar.gz|*.tgz|*.tar.bz2|*.tar.xz|*.zip|*.7z)
                                [ -n "$QUILT_SETUP_FAST" ] && continue
                                ;;
                esac
@@ -220,6 +220,7 @@ inspect()
        ln -s $QUILT_DIR/scripts/inspect-wrapper $tmpdir/bin/patch
        ln -s $QUILT_DIR/scripts/inspect-wrapper $tmpdir/bin/tar
        ln -s $QUILT_DIR/scripts/inspect-wrapper $tmpdir/bin/unzip
+       ln -s $QUILT_DIR/scripts/inspect-wrapper $tmpdir/bin/7z
 
        # Redirect file descriptors
        # 5 is used in verbose mode, 4 in non-verbose mode, and 2 for both 
(real errors)
@@ -253,6 +254,7 @@ inspect()
                 --eval "%define __patch    $tmpdir/bin/patch" \
                 --eval "%define __tar      $tmpdir/bin/tar" \
                 --eval "%define __unzip    $tmpdir/bin/unzip" \
+                --eval "%define __7zip     $tmpdir/bin/7z" \
                 --eval "$DEFINE_FUZZ" \
                 --nodeps \
                 -bp "$specdir/$specfile" < /dev/null >&5 2>&5
@@ -396,6 +398,9 @@ case "$1" in
                        Zip*)
                                echo "unzip ${tar_dir:-.} ${source// /\\ }"
                                ;;
+                       7z*)
+                               echo "7z ${tar_dir:-.} ${source// /\\ }"
+                               ;;
                        *)
                                echo "tar ${tar_dir:-.} ${source// /\\ }"
                                ;;
@@ -448,6 +453,17 @@ then
                        mkdir -p "${prefix:-.}" "$prefix$dir"
                        unzip -qqo "$tarball" -d "$prefix$dir"
                        ;;
+               7z)
+                       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"
+                       7z x -bd "$tarball" -o"$prefix$dir"
+                       ;;
                esac
        done < $tmpfile
 fi
@@ -474,7 +490,7 @@ series_header()
 while read tag dir arg1 arg2
 do
        case "$tag" in
-       tar|unzip)
+       tar|unzip|7z)
                tar_dir=$dir
                [ "$tar_dir" = . ] && tar_dir=
                tar_file=$arg1
-- 
Jean Delvare
SUSE L3 Support



reply via email to

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