quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH] setup: Merge inspect into setup


From: Jean Delvare
Subject: [Quilt-dev] [PATCH] setup: Merge inspect into setup
Date: Fri, 16 Jan 2015 11:30:53 +0100

There is no good reason for the setup command to be split into two
scripts, setup and inspect. Merge inspect into setup to save the
extra interfacing overhead. Performance improvement reaches 5% on
simple packages.
---
 Makefile.in              |    6 -
 quilt/scripts/inspect.in |  185 -----------------------------------------------
 quilt/setup.in           |  151 +++++++++++++++++++++++++++++++++++---
 3 files changed, 142 insertions(+), 200 deletions(-)

--- a/Makefile.in
+++ b/Makefile.in
@@ -78,8 +78,8 @@ QUILT :=      $(QUILT_IN)
 SRC +=         $(QUILT_SRC:%=quilt/%)
 DIRT +=                $(QUILT_IN:%=quilt/%)
 
-SCRIPTS_IN :=  patchfns inspect inspect-wrapper dependency-graph       \
-               edmail remove-trailing-ws backup-files
+SCRIPTS_IN :=  patchfns inspect-wrapper dependency-graph edmail        \
+               remove-trailing-ws backup-files
 
 SCRIPTS_SRC := $(SCRIPTS_IN:%=%.in)
 SCRIPTS :=     $(SCRIPTS_IN)
@@ -390,7 +390,7 @@ test/.depend : Makefile $(TESTS)
            -e 's:quilt/graph:quilt/graph quilt/scripts/dependency-graph:' \
            -e 's:quilt/mail:quilt/mail quilt/scripts/edmail:' \
            -e 's:quilt/refresh:quilt/refresh 
quilt/scripts/remove-trailing-ws:' \
-           -e 's:quilt/setup:quilt/setup quilt/scripts/inspect 
quilt/scripts/inspect-wrapper:' \
+           -e 's:quilt/setup:quilt/setup quilt/scripts/inspect-wrapper:' \
          > $@
 
 ifneq ($(shell . $(QUILTRC) ;  echo $$QUILT_PATCHES_PREFIX),)
--- a/quilt/scripts/inspect.in
+++ /dev/null
@@ -1,185 +0,0 @@
-#! @BASH@
-
-#  This script is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU General Public License version 2 as
-#  published by the Free Software Foundation.
-#
-#  See the COPYING and AUTHORS files for more details.
-
-: address@hidden@}
-
-# Version check is irrelevant to this script.
-skip_version_check=1
-
-if ! [ -r $QUILT_DIR/scripts/patchfns ]
-then
-       echo "Cannot read library $QUILT_DIR/scripts/patchfns" >&2
-       exit 1
-fi
-. $QUILT_DIR/scripts/patchfns
-cd ${SUBDIR:-.}
-
-usage()
-{
-       echo "Usage: ${0##*/} [-v] [--sourcedir dir] [--targetdir dir] 
[--fuzz=N] specfile"
-       exit 1
-}
-
-options=$(getopt -o v --long sourcedir:,targetdir:,fuzz: -n "${0##*/}" -- 
"$@") || exit
-
-eval set -- "$options"
-
-sourcedir=
-
-while true
-do
-       case "$1" in
-       -v)
-               verbose=1
-               shift ;;
-       --sourcedir)
-               sourcedir=${2%/}/
-               shift 2 ;;
-       --targetdir)
-               targetdir=$2
-               shift 2 ;;
-       --fuzz)
-               # Only works with rpm 4.6 and later
-               DEFINE_FUZZ="%define _default_patch_fuzz $2"
-               shift 2 ;;
-       --)
-               shift
-               break ;;
-       esac
-done
-
-[ "${sourcedir:0:1}" = / ] || sourcedir=$PWD/$sourcedir
-
-specfile=$1
-if [ $# -ne 1 -o ! -f "$specfile" ]
-then
-       usage
-fi
-if [ "${specfile:0:1}"  = / ]
-then
-       specdir=$(dirname "$specfile")
-       specfile=${specfile##*/}
-else
-       specdir=$PWD
-fi
-
-tmpdir=$(gen_tempfile -d ${VARTMPDIR:-/var/tmp}/${0##*/})
-mkdir -p $tmpdir || exit 1
-add_exit_handler "rm -rf $tmpdir"
-mkdir -p $tmpdir/bin
-if [ -n "$targetdir" ]
-then
-       # Fast mode
-       [ -d "$targetdir" ] || mkdir -p "$targetdir" || exit 1
-       ln -s "$targetdir" $tmpdir/build
-else
-       # Standard mode
-       mkdir -p $tmpdir/build
-fi
-
-# Redirect file descriptors
-# 5 is used in verbose mode, 4 in non-verbose mode, and 2 for both (real 
errors)
-if [ -n "$verbose" ]
-then
-       exec 3>&1 5>&2 4>/dev/null
-else
-       exec 3>&1 4>&2 5>/dev/null
-fi
-
-# create md5 sums, also for uncompressed files
-echo -n "### md5sum: " >&4
-shopt -s nullglob
-for file in $sourcedir/*
-do
-       basename=${file##*/}
-       case "$basename" in
-               
ready|bigpack|_constraints|_service|baselibs.conf|MD5SUMS|MD5SUMS.meta|*.spec|*.changes|*.sig|*.sign|*rpmlintrc)
-                       continue
-                       ;;
-               # In fast mode, we are only interested in patches, so filter out
-               # archives
-               *.tar|*.tar.Z|*.tar.gz|*.tgz|*.tar.bz2|*.tar.xz|*.zip)
-                       [ -n "$targetdir" ] && continue
-                       ;;
-       esac
-       [ -f "$file" ] || continue
-       echo -n "." >&4
-       echo "md5sum < $file" >&5
-       set -- $(md5sum < "$file")
-       echo "$1 $basename"
-
-       case "$file" in
-               *.lzma)
-                       # file doesn't reliably recognize lzma-compressed files
-                       filetype="lzma"
-                       ;;
-               *.xz)
-                       # old versions of file don't know about xz-compressed
-                       # files
-                       filetype="xz"
-                       ;;
-               *)
-                       filetype=$(file -b "$file")
-                       ;;
-       esac
-
-       case "$filetype" in
-               compress*|gzip*)
-                       echo -n "g" >&4
-                       echo "gzip -cd $file | md5sum" >&5
-                       set -- $(gzip -cd "$file" | md5sum)
-                       echo "$1 $basename"
-                       ;;
-               bzip2*)
-                       echo -n "b" >&4
-                       echo "bzip2 -cd $file | md5sum" >&5
-                       set -- $(bzip2 -cd "$file" | md5sum)
-                       echo "$1 $basename"
-                       ;;
-               xz*|XZ*)
-                       echo -n "x" >&4
-                       echo "xz -cd $file | md5sum" >&5
-                       set -- $(xz -cd "$file" | md5sum)
-                       echo "$1 $basename"
-                       ;;
-               lzma*)
-                       echo -n "l" >&4
-                       echo "lzma -cd $file | md5sum" >&5
-                       set -- $(lzma -cd "$file" | md5sum)
-                       echo "$1 $basename"
-                       ;;
-       esac
-done > $tmpdir/md5sums
-echo >&4
-shopt -u nullglob
-
-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
-
-# let rpm do all the dirty specfile stuff ...
-echo -n "### rpmbuild: " >&4
-
-export PATH="$tmpdir/bin:$PATH"
-export QUILT_SETUP_FAST=${targetdir:+1}
-rpmbuild --eval "%define _sourcedir $sourcedir" \
-        --eval "%define _specdir   $specdir" \
-        --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
-status=$?
-echo >&4
-exit $status
-### Local Variables:
-### mode: shell-script
-### End:
-# vim:filetype=sh
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -123,6 +123,141 @@ dir_to_dir()
        echo "$to"
 }
 
+# create md5 sums, also for uncompressed files
+create_md5sums()
+{
+       local sourcedir=$1 output=$2
+       local file basename filetype
+
+       echo -n "### md5sum: " >&4
+       shopt -s nullglob
+       for file in "$sourcedir"*
+       do
+               basename=${file##*/}
+               case "$basename" in
+                       
ready|bigpack|_constraints|_service|baselibs.conf|MD5SUMS|MD5SUMS.meta|*.spec|*.changes|*.sig|*.sign|*rpmlintrc)
+                               continue
+                               ;;
+                       # In fast mode, we are only interested in patches, so 
filter out
+                       # archives
+                       *.tar|*.tar.Z|*.tar.gz|*.tgz|*.tar.bz2|*.tar.xz|*.zip)
+                               [ -n "$targetdir" ] && continue
+                               ;;
+               esac
+               [ -f "$file" ] || continue
+               echo -n "." >&4
+               echo "md5sum < $file" >&5
+               set -- $(md5sum < "$file")
+               echo "$1 $basename"
+
+               case "$file" in
+                       *.lzma)
+                               # file doesn't reliably recognize 
lzma-compressed files
+                               filetype="lzma"
+                               ;;
+                       *.xz)
+                               # old versions of file don't know about 
xz-compressed
+                               # files
+                               filetype="xz"
+                               ;;
+                       *)
+                               filetype=$(file -b "$file")
+                               ;;
+               esac
+
+               case "$filetype" in
+                       compress*|gzip*)
+                               echo -n "g" >&4
+                               echo "gzip -cd $file | md5sum" >&5
+                               set -- $(gzip -cd "$file" | md5sum)
+                               echo "$1 $basename"
+                               ;;
+                       bzip2*)
+                               echo -n "b" >&4
+                               echo "bzip2 -cd $file | md5sum" >&5
+                               set -- $(bzip2 -cd "$file" | md5sum)
+                               echo "$1 $basename"
+                               ;;
+                       xz*|XZ*)
+                               echo -n "x" >&4
+                               echo "xz -cd $file | md5sum" >&5
+                               set -- $(xz -cd "$file" | md5sum)
+                               echo "$1 $basename"
+                               ;;
+                       lzma*)
+                               echo -n "l" >&4
+                               echo "lzma -cd $file | md5sum" >&5
+                               set -- $(lzma -cd "$file" | md5sum)
+                               echo "$1 $basename"
+                               ;;
+               esac
+       done > $output
+       echo >&4
+       shopt -u nullglob
+}
+
+# Uses global variables: verbose, sourcedir, targetdir
+inspect()
+{
+       local specfile=$1 specdir
+       local abs_sourcedir=$sourcedir tmpdir
+
+       [ "${abs_sourcedir:0:1}" = / ] || abs_sourcedir=$PWD/$abs_sourcedir
+
+       if [ "${specfile:0:1}"  = / ]
+       then
+               specdir=$(dirname "$specfile")
+               specfile=${spec_file##*/}
+       else
+               specdir=$PWD
+       fi
+
+       tmpdir=$(gen_tempfile -d ${VARTMPDIR:-/var/tmp}/${0##*/})
+       mkdir -p $tmpdir || exit 1
+       add_exit_handler "rm -rf $tmpdir"
+       mkdir -p $tmpdir/bin
+       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
+       if [ -n "$targetdir" ]
+       then
+               # Fast mode
+               [ -d "$targetdir" ] || mkdir -p "$targetdir" || exit 1
+               ln -s "$targetdir" $tmpdir/build
+       else
+               # Standard mode
+               mkdir -p $tmpdir/build
+       fi
+
+       # Redirect file descriptors
+       # 5 is used in verbose mode, 4 in non-verbose mode, and 2 for both 
(real errors)
+       if [ -n "$verbose" ]
+       then
+               exec 3>&1 5>&2 4>/dev/null
+       else
+               exec 3>&1 4>&2 5>/dev/null
+       fi
+
+       create_md5sums "$sourcedir" $tmpdir/md5sums
+
+       # let rpm do all the dirty specfile stuff ...
+       echo -n "### rpmbuild: " >&4
+
+       PATH="$tmpdir/bin:$PATH" QUILT_SETUP_FAST=${targetdir:+1} \
+       rpmbuild --eval "%define _sourcedir $abs_sourcedir" \
+                --eval "%define _specdir   $specdir" \
+                --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
+       status=$?
+       echo >&4
+       return $status
+}
+
 usage()
 {
        printf $"Usage: quilt setup [-d path-prefix] [-v] [--sourcedir dir] 
[--fuzz=N] [--slow|--fast] {specfile|seriesfile}\n"
@@ -179,13 +314,14 @@ do
        -h)
                usage -h ;;
        -v)
-               verbose=-v
+               verbose=1
                shift ;;
        --sourcedir)
                sourcedir=${2%/}/
                shift 2 ;;
        --fuzz)
-               opt_fuzz="--fuzz $2"
+               # Only works with rpm 4.6 and later
+               DEFINE_FUZZ="%define _default_patch_fuzz $2"
                shift 2 ;;
        --slow)
                opt_fast=
@@ -204,8 +340,6 @@ then
        usage
 fi
 
-[ -n "$sourcedir" ] && opt_sourcedir="--sourcedir $sourcedir"
-
 tmpfile=$(gen_tempfile)
 add_exit_handler "rm -f $tmpfile"
 
@@ -229,16 +363,9 @@ case "$1" in
                else
                        targetdir=$PWD/$prefix
                fi
-
-               $QUILT_DIR/scripts/inspect $verbose $opt_sourcedir $opt_fuzz \
-                                          --targetdir "$targetdir" \
-                                          "$spec_file" 2>&1 > $tmpfile
-       else
-               $QUILT_DIR/scripts/inspect $verbose $opt_sourcedir $opt_fuzz \
-                                          "$spec_file" 2>&1 > $tmpfile
        fi
 
-       if [ $? -ne 0 ]
+       if ! inspect "$spec_file" 2>&1 > $tmpfile
        then
                printf $"The %%prep section of %s failed; results may be 
incomplete\n" "$spec_file"
                if [ -z "$verbose" ]

-- 
Jean Delvare
SUSE L3 Support




reply via email to

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