SHA256
1
0
forked from pool/quilt

Accepting request 264454 from home:jdelvare:branches:devel:tools:scm

- Fix the series file consistency checker
- Many fixes and improvements to the setup command
- New option --fast for quilt setup (hackweek project)

OBS-URL: https://build.opensuse.org/request/show/264454
OBS-URL: https://build.opensuse.org/package/show/devel:tools:scm/quilt?expand=0&rev=92
This commit is contained in:
Takashi Iwai 2014-12-10 16:05:56 +00:00 committed by Git OBS Bridge
parent 7a32629653
commit a5de1023e1
16 changed files with 1401 additions and 2 deletions

View File

@ -0,0 +1,18 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: inspect: Comment update
Upstream: Committed (40f5bfbbd4f0a3f9e74c2129a142aab7f6f8ac14)
---
quilt/scripts/inspect.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/quilt/scripts/inspect.in
+++ b/quilt/scripts/inspect.in
@@ -150,7 +150,7 @@ done > $tmpdir/md5sums
echo >&4
shopt -u nullglob
-# wrapper script for patch and tar
+# wrapper script for patch, tar and unzip
cat <<-'EOF' > $tmpdir/bin/wrapper
#! @BASH@

View File

@ -0,0 +1,98 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: setup/inspect: Cleanups
Upstream: Committed (aa5d1389f7ce7ca2fc51e791ec33b68404fdea6b)
* Drop quotes that aren't needed and break syntax highlighting in some
editors.
* Coding style cleanups.
---
quilt/scripts/inspect.in | 23 +++++++++++++----------
quilt/setup.in | 6 +++---
2 files changed, 16 insertions(+), 13 deletions(-)
--- a/quilt/scripts/inspect.in
+++ b/quilt/scripts/inspect.in
@@ -65,7 +65,7 @@ else
specdir=$PWD
fi
-tmpdir="$(gen_tempfile -d ${VARTMPDIR:-/var/tmp}/${0##*/})"
+tmpdir=$(gen_tempfile -d ${VARTMPDIR:-/var/tmp}/${0##*/})
mkdir -p $tmpdir || exit 1
add_exit_handler "rm -rf $tmpdir"
mkdir -p $tmpdir/build
@@ -116,7 +116,7 @@ do
filetype="xz"
;;
*)
- filetype="$(file -b "$file")"
+ filetype=$(file -b "$file")
;;
esac
@@ -239,7 +239,8 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
while [ $# -gt 0 ]; do
case "$1" in
-i|--input)
- if [ $# -ge 2 ]; then
+ if [ $# -ge 2 ]
+ then
echo "$2"
return
fi
@@ -372,12 +373,13 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
inputfile=$(unzip_input_file "$@")
;;
esac
- if [ -z "$inputfile" ]; then
- # put data from stdin into tmpfile
- cat > $tmpdir/data
+ if [ -z "$inputfile" ]
+ then
+ # put data from stdin into tmpfile
+ cat > $tmpdir/data
fi
- unpackfile="$(original_file ${inputfile:-$tmpdir/data})"
+ unpackfile=$(original_file ${inputfile:-$tmpdir/data})
if [ -n "$unpackfile" ]
then
case "${0##*/}" in
@@ -403,10 +405,11 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
fi
PATH=${PATH#*:}
- if [ -n "$inputfile" ]; then
- ${0##*/} "$@"
+ if [ -n "$inputfile" ]
+ then
+ ${0##*/} "$@"
else
- ${0##*/} "$@" < $tmpdir/data
+ ${0##*/} "$@" < $tmpdir/data
fi
EOF
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -205,7 +205,7 @@ case "$1" in
"# Source: "*)
shift 2
source="$@"
- filetype="$(file -b "$source")"
+ filetype=$(file -b "$source")
case "$filetype" in
Zip*)
echo "unzip ${tar_dir:-.} ${source// /\\ }"
@@ -273,9 +273,9 @@ while read tag dir arg1 arg2
do
case "$tag" in
tar|unzip)
- tar_dir="$dir"
+ tar_dir=$dir
[ "$tar_dir" = . ] && tar_dir=
- tar_file="$arg1"
+ tar_file=$arg1
;;
patch)
if [ ! -e "$prefix$dir/$QUILT_PATCHES" ]

View File

@ -0,0 +1,20 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: inspect: List all options in usage text
Upstream: Committed (c57b81b7367ebc6f3757b114302b537d6e305431)
Options -v and --sourcedir were not listed.
---
quilt/scripts/inspect.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/quilt/scripts/inspect.in
+++ b/quilt/scripts/inspect.in
@@ -21,7 +21,7 @@ cd ${SUBDIR:-.}
usage()
{
- echo "Usage: ${0##*/} [--fuzz=N] specfile"
+ echo "Usage: ${0##*/} [-v] [--sourcedir dir] [--fuzz=N] specfile"
exit 1
}

View File

@ -0,0 +1,32 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: inspect: Pass through the wrappers when appropriate
Upstream: Committed (e3ee2d8596cbac98d29d72292b6b45706c0010af)
The wrappers may be called before the %prep section is entered, in
which case RPM_BUILD_DIR isn't set yet. In that case we want to
pass trough transparently.
---
quilt/scripts/inspect.in | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--- a/quilt/scripts/inspect.in
+++ b/quilt/scripts/inspect.in
@@ -358,6 +358,10 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
echo "$dir"
}
+ PATH=${PATH#*:}
+ # If we are called too early, pass through without processing
+ [ -n "$RPM_BUILD_DIR" ] || exec ${0##*/} "$@"
+
tmpdir=${RPM_BUILD_DIR%/*}
rm -f $tmpdir/data
case "${0##*/}" in
@@ -404,7 +408,6 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
esac
fi
- PATH=${PATH#*:}
if [ -n "$inputfile" ]
then
${0##*/} "$@"

View File

@ -0,0 +1,24 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: inspect: Don't explicitly delete the temporary data file
Upstream: Committed (3931a551f43751c6c18e6439864a7d012f2d5f4e)
This temporary data file is overwritten as needed and the directory
it sits in is blasted when the script exits, so there is no point in
explicitly deleting this file at the beginning of each wrapper
invocation.
This simple change speeds up "inspect" by 3-4% in my tests.
---
quilt/scripts/inspect.in | 1 -
1 file changed, 1 deletion(-)
--- a/quilt/scripts/inspect.in
+++ b/quilt/scripts/inspect.in
@@ -363,7 +363,6 @@ cat <<-'EOF' > $tmpdir/bin/wrapper
[ -n "$RPM_BUILD_DIR" ] || exec ${0##*/} "$@"
tmpdir=${RPM_BUILD_DIR%/*}
- rm -f $tmpdir/data
case "${0##*/}" in
patch)
inputfile=$(patch_input_file "$@")

View File

@ -0,0 +1,24 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: inspect: Exclude more files from md5sums
Upstream: Committed (367ef38abdfc93ceef435f805c97af7a092ea46e)
A few more files can be excluded from md5sums as we know they are
neither patches nor archives:
* _constraints, _service and baselibs.conf, from the Build Service
* signature files
* rpmlintrc files
---
quilt/scripts/inspect.in | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
--- a/quilt/scripts/inspect.in
+++ b/quilt/scripts/inspect.in
@@ -95,7 +95,7 @@ for file in $sourcedir/*
do
basename=${file##*/}
case "$basename" in
- ready|bigpack|MD5SUMS|MD5SUMS.meta|*.spec|*.changes)
+ ready|bigpack|_constraints|_service|baselibs.conf|MD5SUMS|MD5SUMS.meta|*.spec|*.changes|*.sig|*.sign|*rpmlintrc)
continue
;;
esac

View File

@ -0,0 +1,47 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: setup: Introduce function normalize_path
Upstream: Committed (1e8e4ff9b8027235d0577369719c0c58ba460cf8)
Move the path normalization code to a separate function, to avoid
redundancy and make the code more readable.
---
quilt/setup.in | 21 +++++++++++----------
1 file changed, 11 insertions(+), 10 deletions(-)
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -71,6 +71,15 @@ check_for_existing_files()
return $status
}
+# Resolve ".." in path and clean up double slashes
+normalize_path()
+{
+ echo "$1" | sed -r -e 's://:/:g' \
+ -e ':again' \
+ -e 's:/[^/]+/\.\.(/|$):\1:g' \
+ -e 'tagain'
+}
+
create_symlink()
{
local target=$1 link=$2 up
@@ -80,16 +89,8 @@ create_symlink()
return
fi
- set -- "$(echo "$PWD/$target" | \
- sed -r -e 's://:/:g' \
- -e ':again' \
- -e 's:/[^/]+/\.\.(/|$):\1:g' \
- -e 'tagain')" \
- "$(echo "$PWD/$link" | \
- sed -r -e 's://:/:g' \
- -e ':again' \
- -e 's:/[^/]+/\.\.(/|$):\1:g' \
- -e 'tagain')"
+ set -- "$(normalize_path "$PWD/$target")" \
+ "$(normalize_path "$PWD/$link")"
while [ "${1%%/*}" = "${2%%/*}" ]
do
set -- "${1#*/}" "${2#*/}"

View File

@ -0,0 +1,598 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: inspect: Split the patch/tar/unzip wrapper to a separate script
Upstream: Committed (9f1f21a1fcd6700c9f9fda8c1b953f7e76538c76)
I couldn't find any reason why the patch/tar/unzip wrapper is
generated each time inspect is invoked. Make it a separate script in
its own right and let the patch, tar and unzip links point to it.
This makes this piece of code easier to read, edit, trace and debug.
This also solves the case where the filesystem hosting the temporary
files is mounted with noexec.
---
Makefile.in | 6
quilt/scripts/inspect-wrapper.in | 265 ++++++++++++++++++++++++++++++++++++
quilt/scripts/inspect.in | 282 ---------------------------------------
3 files changed, 271 insertions(+), 282 deletions(-)
--- a/Makefile.in
+++ b/Makefile.in
@@ -79,8 +79,8 @@ QUILT := $(QUILT_IN)
SRC += $(QUILT_SRC:%=quilt/%)
DIRT += $(QUILT_IN:%=quilt/%)
-SCRIPTS_IN := patchfns inspect dependency-graph edmail \
- remove-trailing-ws backup-files
+SCRIPTS_IN := patchfns inspect inspect-wrapper dependency-graph \
+ edmail remove-trailing-ws backup-files
SCRIPTS_SRC := $(SCRIPTS_IN:%=%.in)
SCRIPTS := $(SCRIPTS_IN)
@@ -391,7 +391,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:' \
+ -e 's:quilt/setup:quilt/setup quilt/scripts/inspect quilt/scripts/inspect-wrapper:' \
> $@
ifneq ($(shell . $(QUILTRC) ; echo $$QUILT_PATCHES_PREFIX),)
--- /dev/null
+++ b/quilt/scripts/inspect-wrapper.in
@@ -0,0 +1,265 @@
+#! @BASH@
+
+# find original data file by md5sum
+original_file()
+{
+ local file=$1 md5sum
+
+ set -- $(md5sum < $file)
+ md5sum=$1
+ while read md5sum_ file_
+ do
+ if [ "$md5sum" = "$md5sum_" ]
+ then
+ echo ${file_#\*}
+ return 0
+ fi
+ done < $tmpdir/md5sums
+
+ # Try harder
+ if ! [ -e $tmpdir/more-md5sums ]
+ then
+ ( cd $RPM_BUILD_DIR
+ find . -type f \
+ | sed -e 's:^.\/::' \
+ | xargs md5sum \
+ ) > $tmpdir/more-md5sums
+ fi
+
+ while read md5sum_ file_
+ do
+ if [ "$md5sum" = "$md5sum_" ]
+ then
+ echo ${file_#\*}
+ return 0
+ fi
+ done < $tmpdir/more-md5sums
+
+ return 1
+}
+
+# Extract a command line option with or without argument
+cmdline_option()
+{
+ local letter=$1 no_arg=$2
+ shift
+
+ while [ $# -ne 0 ]
+ do
+ if [ "${1:0:2}" = -$letter ]
+ then
+ if [ -z "$no_arg" ]
+ then
+ [ "$1" = -$letter ] && set -- "$1$2"
+ fi
+ echo $1
+ break
+ fi
+ shift
+ done
+}
+
+# Extract the -p option from the command line
+strip_option()
+{
+ set -- $(cmdline_option p "$@")
+ [ "$1" != -p1 ] && echo $1
+}
+
+# Extract the -R option from the command line
+reverse_option()
+{
+ set -- $(cmdline_option R no_arg "$@")
+ echo $1
+}
+
+patch_opt_d()
+{
+ local subdir=$(cmdline_option d "$@")
+ [ -z "$subdir" ] || echo "${subdir:2}"
+
+}
+
+patch_input_file()
+{
+ while [ $# -gt 0 ]
+ do
+ case "$1" in
+ -i|--input)
+ if [ $# -ge 2 ]
+ then
+ echo "$2"
+ return
+ fi
+ ;;
+ -i*)
+ echo "${1#-i}"
+ return
+ ;;
+ --input=*)
+ echo "${1#--input=}"
+ return
+ ;;
+ esac
+ shift
+ done
+ return 1
+}
+
+tar_input_file()
+{
+ case "$1" in
+ # Modern option format
+ -*)
+ while [ $# -gt 0 ]
+ do
+ case "$1" in
+ # Extract the file name (long option)
+ --file)
+ echo "$2"
+ return
+ ;;
+ --file=*)
+ echo "${1#--file=}"
+ return
+ ;;
+ # Skip other long options
+ --*)
+ shift
+ ;;
+ # Extract the file name (short option)
+ -*f)
+ echo "$2"
+ return
+ ;;
+ -f*)
+ echo "${1#-f}"
+ return
+ ;;
+ # Skip other short options and parameters
+ *)
+ shift
+ ;;
+ esac
+ done
+ ;;
+ # Legacy option format (must always come first)
+ *C*f*)
+ echo "$3"
+ return
+ ;;
+ *f*)
+ echo "$2"
+ return
+ ;;
+ ?*)
+ # Eat legacy options and try again
+ until [ $# -eq 0 -o "${1:0:1}" = "-" ]
+ do
+ shift
+ done
+ tar_input_file "$@"
+ return
+ ;;
+ esac
+ return 1
+}
+
+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*)
+ echo "$2"
+ return ;;
+ esac
+}
+
+pwd_to_dir()
+{
+ local subdir=$1 dir
+
+ if [ -n "$subdir" ]
+ then
+ dir=$(cd "$subdir" && echo $PWD)
+ else
+ dir=$PWD
+ fi
+ dir=${dir/$RPM_BUILD_DIR}
+ dir=${dir##/}
+ dir=${dir// /\\ }
+
+ echo "$dir"
+}
+
+PATH=${PATH#*:}
+# If we are called too early, pass through without processing
+[ -n "$RPM_BUILD_DIR" ] || exec ${0##*/} "$@"
+
+tmpdir=${RPM_BUILD_DIR%/*}
+case "${0##*/}" in
+patch)
+ inputfile=$(patch_input_file "$@")
+ ;;
+tar)
+ inputfile=$(tar_input_file "$@")
+ # 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
+ cat > $tmpdir/data
+fi
+
+unpackfile=$(original_file ${inputfile:-$tmpdir/data})
+if [ -n "$unpackfile" ]
+then
+ case "${0##*/}" in
+ patch)
+ echo -n p >&4
+ subdir=$(patch_opt_d "$@")
+ dir=$(pwd_to_dir $subdir)
+ echo "${0##*/} ${dir:-.} $unpackfile" \
+ $(strip_option "$@") $(reverse_option "$@") >&3
+ ;;
+ tar)
+ echo -n t >&4
+ subdir=$(tar_opt_C "$@")
+ dir=$(pwd_to_dir $subdir)
+ echo "${0##*/} ${dir:-.} $unpackfile" >&3
+ ;;
+ unzip)
+ echo -n Z >&4
+ dir=$(pwd_to_dir)
+ echo "${0##*/} ${dir:-.} $unpackfile" >&3
+ ;;
+ esac
+fi
+
+if [ -n "$inputfile" ]
+then
+ ${0##*/} "$@"
+else
+ ${0##*/} "$@" < $tmpdir/data
+fi
--- a/quilt/scripts/inspect.in
+++ b/quilt/scripts/inspect.in
@@ -150,285 +150,9 @@ done > $tmpdir/md5sums
echo >&4
shopt -u nullglob
-# wrapper script for patch, tar and unzip
-cat <<-'EOF' > $tmpdir/bin/wrapper
- #! @BASH@
-
- # find original data file by md5sum
- original_file()
- {
- local file=$1 md5sum
-
- set -- $(md5sum < $file)
- md5sum=$1
- while read md5sum_ file_
- do
- if [ "$md5sum" = "$md5sum_" ]
- then
- echo ${file_#\*}
- return 0
- fi
- done < $tmpdir/md5sums
-
- # Try harder
- if ! [ -e $tmpdir/more-md5sums ]
- then
- ( cd $RPM_BUILD_DIR
- find . -type f \
- | sed -e 's:^.\/::' \
- | xargs md5sum \
- ) > $tmpdir/more-md5sums
- fi
-
- while read md5sum_ file_
- do
- if [ "$md5sum" = "$md5sum_" ]
- then
- echo ${file_#\*}
- return 0
- fi
- done < $tmpdir/more-md5sums
-
- return 1
- }
-
- # Extract a command line option with or without argument
- cmdline_option()
- {
- local letter=$1 no_arg=$2
- shift
-
- while [ $# -ne 0 ]
- do
- if [ "${1:0:2}" = -$letter ]
- then
- if [ -z "$no_arg" ]
- then
- [ "$1" = -$letter ] && set -- "$1$2"
- fi
- echo $1
- break
- fi
- shift
- done
- }
-
- # Extract the -p option from the command line
- strip_option()
- {
- set -- $(cmdline_option p "$@")
- [ "$1" != -p1 ] && echo $1
- }
-
- # Extract the -R option from the command line
- reverse_option()
- {
- set -- $(cmdline_option R no_arg "$@")
- echo $1
- }
-
- patch_opt_d()
- {
- local subdir=$(cmdline_option d "$@")
- [ -z "$subdir" ] || echo "${subdir:2}"
-
- }
-
- patch_input_file()
- {
- while [ $# -gt 0 ]; do
- case "$1" in
- -i|--input)
- if [ $# -ge 2 ]
- then
- echo "$2"
- return
- fi
- ;;
- -i*)
- echo "${1#-i}"
- return
- ;;
- --input=*)
- echo "${1#--input=}"
- return
- ;;
- esac
- shift
- done
- return 1
- }
-
- tar_input_file()
- {
- case "$1" in
- # Modern option format
- -*)
- while [ $# -gt 0 ]; do
- case "$1" in
- # Extract the file name (long option)
- --file)
- echo "$2"
- return
- ;;
- --file=*)
- echo "${1#--file=}"
- return
- ;;
- # Skip other long options
- --*)
- shift
- ;;
- # Extract the file name (short option)
- -*f)
- echo "$2"
- return
- ;;
- -f*)
- echo "${1#-f}"
- return
- ;;
- # Skip other short options and parameters
- *)
- shift
- ;;
- esac
- done
- ;;
- # Legacy option format (must always come first)
- *C*f*)
- echo "$3"
- return
- ;;
- *f*)
- echo "$2"
- return
- ;;
- ?*)
- # Eat legacy options and try again
- until [ $# -eq 0 -o "${1:0:1}" = "-" ]; do
- shift
- done
- tar_input_file "$@"
- return
- ;;
- esac
- return 1
- }
-
- 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*)
- echo "$2"
- return ;;
- esac
- }
-
- pwd_to_dir()
- {
- local subdir=$1 dir
-
- if [ -n "$subdir" ]
- then
- dir=$(cd "$subdir" && echo $PWD)
- else
- dir=$PWD
- fi
- dir=${dir/$RPM_BUILD_DIR}
- dir=${dir##/}
- dir=${dir// /\\ }
-
- echo "$dir"
- }
-
- PATH=${PATH#*:}
- # If we are called too early, pass through without processing
- [ -n "$RPM_BUILD_DIR" ] || exec ${0##*/} "$@"
-
- tmpdir=${RPM_BUILD_DIR%/*}
- case "${0##*/}" in
- patch)
- inputfile=$(patch_input_file "$@")
- ;;
- tar)
- inputfile=$(tar_input_file "$@")
- # 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
- cat > $tmpdir/data
- fi
-
- unpackfile=$(original_file ${inputfile:-$tmpdir/data})
- if [ -n "$unpackfile" ]
- then
- case "${0##*/}" in
- patch)
- echo -n p >&4
- subdir=$(patch_opt_d "$@")
- dir=$(pwd_to_dir $subdir)
- echo "${0##*/} ${dir:-.} $unpackfile" \
- $(strip_option "$@") $(reverse_option "$@") >&3
- ;;
- tar)
- echo -n t >&4
- subdir=$(tar_opt_C "$@")
- dir=$(pwd_to_dir $subdir)
- echo "${0##*/} ${dir:-.} $unpackfile" >&3
- ;;
- unzip)
- echo -n Z >&4
- dir=$(pwd_to_dir)
- echo "${0##*/} ${dir:-.} $unpackfile" >&3
- ;;
- esac
- fi
-
- if [ -n "$inputfile" ]
- then
- ${0##*/} "$@"
- else
- ${0##*/} "$@" < $tmpdir/data
- fi
-EOF
-
-chmod 755 $tmpdir/bin/wrapper
-# If $TMPDIR is mounted with noexec, rpmbuild won't be able to execute
-# our wrapper script
-if [ ! -x $tmpdir/bin/wrapper ]
-then
- printf "Cannot execute %s; filesystem mounted with noexec?\n" \
- $tmpdir/bin/wrapper >&2
- printf "Setting %s in ~/.quiltrc may help\n" "VARTMPDIR" >&2
- exit 1
-fi
-
-ln -s wrapper $tmpdir/bin/patch
-ln -s wrapper $tmpdir/bin/tar
-ln -s wrapper $tmpdir/bin/unzip
+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

View File

@ -0,0 +1,29 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: inspect-wrapper: Minor code optimization
Upstream: Committed (f159ee6f0bcd6b9abdc8830a1228d902e93311ae)
Don't test if inputfile is set twice in a row.
---
quilt/scripts/inspect-wrapper.in | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
--- a/quilt/scripts/inspect-wrapper.in
+++ b/quilt/scripts/inspect-wrapper.in
@@ -226,13 +226,15 @@ unzip)
inputfile=$(unzip_input_file "$@")
;;
esac
-if [ -z "$inputfile" ]
+if [ -n "$inputfile" ]
then
+ unpackfile=$(original_file "$inputfile")
+else
# put data from stdin into tmpfile
cat > $tmpdir/data
+ unpackfile=$(original_file $tmpdir/data)
fi
-unpackfile=$(original_file ${inputfile:-$tmpdir/data})
if [ -n "$unpackfile" ]
then
case "${0##*/}" in

View File

@ -0,0 +1,74 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: setup: Fix path to extra patches in series file
Upstream: Committed (1e5d95849e4a09427efefc7bd7e9f33bf911f526)
Extra patches (typically contained in archives) end up in the working
directory, not the source directory where regular patches live. In
the most common case, it makes no difference because both directories
are the same. However, as soon as options -d or --sourcedir are used
in conjunction with extra patches, the working directory and the
source directory are different, and the paths to the extra patches in
the series file get wrong.
While we can't possible handle the case where the source and working
directories are completely different, we can easily handle the most
typical case where the working directory is a subdirectory of the
source directory.
---
quilt/scripts/inspect-wrapper.in | 2 +-
quilt/setup.in | 26 ++++++++++++++++++++++++++
2 files changed, 27 insertions(+), 1 deletion(-)
--- a/quilt/scripts/inspect-wrapper.in
+++ b/quilt/scripts/inspect-wrapper.in
@@ -30,7 +30,7 @@ original_file()
do
if [ "$md5sum" = "$md5sum_" ]
then
- echo ${file_#\*}
+ echo $QUILT_SETUP_PREFIX${file_#\*}
return 0
fi
done < $tmpdir/more-md5sums
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -101,6 +101,27 @@ create_symlink()
ln -s "${1:-.}" "$link"
}
+dir_to_dir()
+{
+ local from=$1 to=$2
+
+ [ "${from:0:1}" = / ] || from=$PWD/$from
+ from=$(normalize_path "$from")
+
+ [ "${to:0:1}" = / ] || to=$PWD/$to
+ to=$(normalize_path "$to")
+
+ # If the target is a subdirectory of the origin, we can express the path
+ # in a relative way. Otherwise, return the absolute path.
+ if [ "${to:0:${#from}}" = "$from" ]
+ then
+ to=${to:${#from}}
+ to=${to#/}
+ fi
+
+ echo "$to"
+}
+
usage()
{
printf $"Usage: quilt setup [-d path-prefix] [-v] [--sourcedir dir] [--fuzz=N] {specfile|seriesfile}\n"
@@ -170,6 +191,11 @@ fi
tmpfile=$(gen_tempfile)
add_exit_handler "rm -f $tmpfile"
+# The patches link will point to the source directory, while extra patches
+# may be available under $prefix. If the latter is a subdirectory of the former,
+# a prefix can be added to fix up the path to the extra patches.
+export QUILT_SETUP_PREFIX=$(dir_to_dir "$sourcedir" "$prefix")
+
case "$1" in
*.spec)
spec_file=$1

View File

@ -0,0 +1,53 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: inspect-wrapper: Trace calls earlier
Upstream: Submitted (2014-12-07)
Trace the calls to the patch/tar/unzip wrapper earlier. That way, if
anything goes wrong, we know which type of file was being processed.
Even if nothing goes wrong, the user now sees the file type as it is
being processed (which can take a long time.)
---
quilt/scripts/inspect-wrapper.in | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
--- a/quilt/scripts/inspect-wrapper.in
+++ b/quilt/scripts/inspect-wrapper.in
@@ -215,14 +215,17 @@ PATH=${PATH#*:}
tmpdir=${RPM_BUILD_DIR%/*}
case "${0##*/}" in
patch)
+ echo -n p >&4
inputfile=$(patch_input_file "$@")
;;
tar)
+ echo -n t >&4
inputfile=$(tar_input_file "$@")
# For tar, file - means read from stdin
[ "$inputfile" = "-" ] && inputfile=
;;
unzip)
+ echo -n Z >&4
inputfile=$(unzip_input_file "$@")
;;
esac
@@ -239,20 +242,17 @@ if [ -n "$unpackfile" ]
then
case "${0##*/}" in
patch)
- echo -n p >&4
subdir=$(patch_opt_d "$@")
dir=$(pwd_to_dir $subdir)
echo "${0##*/} ${dir:-.} $unpackfile" \
$(strip_option "$@") $(reverse_option "$@") >&3
;;
tar)
- echo -n t >&4
subdir=$(tar_opt_C "$@")
dir=$(pwd_to_dir $subdir)
echo "${0##*/} ${dir:-.} $unpackfile" >&3
;;
unzip)
- echo -n Z >&4
dir=$(pwd_to_dir)
echo "${0##*/} ${dir:-.} $unpackfile" >&3
;;

View File

@ -0,0 +1,221 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: setup: Add --fast option
Upstream: Submitted (2014-12-07)
This is an alternative implementation of "quilt setup" for rpm spec
files, which is much faster than the original implementation. The
idea is to have rpmbuild generate our working tree directly, instead
of taking note of everything it does and then replaying that record
from scratch.
The new implementation is enabled with option --fast. The original
implementation can be selected with --slow, which is the default.
Having this option makes it possible to set the default to --fast in
~/.quiltrc and revert to --slow on the command line on a case-by-case
basis. This will also make it easier if we decide to change the
default in the future.
In general, the generated working tree should be the same with --slow
or --fast. There are 3 known exceptions though:
* The header of the series files is incomplete when using --fast,
which means that you can't reuse these series files to feed "quilt
setup" later.
* If the spec file generates files other than with the tar, unzip and
patch commands, you wouldn't get these files in your working tree
with --slow, but with --fast you will.
* With --fast, all patches are added to the series file, regardless
of whether they apply or not. This also means that patches which
fail to apply are not reported as such until you attempt to push
them.
On large packages, this alternative implementation was found to be
up to 4 times faster than the original implementation.
---
This is my SUSE hackweek 11 project, more information at:
https://hackweek.suse.com/11/projects/194
quilt/scripts/inspect-wrapper.in | 5 ++++
quilt/scripts/inspect.in | 23 ++++++++++++++++++--
quilt/setup.in | 43 +++++++++++++++++++++++++++++++++++----
3 files changed, 64 insertions(+), 7 deletions(-)
--- a/quilt/scripts/inspect-wrapper.in
+++ b/quilt/scripts/inspect-wrapper.in
@@ -220,12 +220,14 @@ patch)
;;
tar)
echo -n t >&4
+ [ -n "$QUILT_SETUP_FAST" ] && exec ${0##*/} "$@"
inputfile=$(tar_input_file "$@")
# For tar, file - means read from stdin
[ "$inputfile" = "-" ] && inputfile=
;;
unzip)
echo -n Z >&4
+ [ -n "$QUILT_SETUP_FAST" ] && exec ${0##*/} "$@"
inputfile=$(unzip_input_file "$@")
;;
esac
@@ -259,6 +261,9 @@ then
esac
fi
+# In fast mode, we don't actually apply patches
+[ ${0##*/}$QUILT_SETUP_FAST = patch1 ] && exit 0
+
if [ -n "$inputfile" ]
then
${0##*/} "$@"
--- a/quilt/scripts/inspect.in
+++ b/quilt/scripts/inspect.in
@@ -21,11 +21,11 @@ cd ${SUBDIR:-.}
usage()
{
- echo "Usage: ${0##*/} [-v] [--sourcedir dir] [--fuzz=N] specfile"
+ echo "Usage: ${0##*/} [-v] [--sourcedir dir] [--targetdir dir] [--fuzz=N] specfile"
exit 1
}
-options=$(getopt -o v --long sourcedir:,fuzz: -n "${0##*/}" -- "$@") || exit
+options=$(getopt -o v --long sourcedir:,targetdir:,fuzz: -n "${0##*/}" -- "$@") || exit
eval set -- "$options"
@@ -40,6 +40,9 @@ do
--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"
@@ -68,8 +71,16 @@ fi
tmpdir=$(gen_tempfile -d ${VARTMPDIR:-/var/tmp}/${0##*/})
mkdir -p $tmpdir || exit 1
add_exit_handler "rm -rf $tmpdir"
-mkdir -p $tmpdir/build
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
# Older versions of Suse packages have a symbolic release number, and rpmbuild
# won't like that, so change it to something compliant.
@@ -98,6 +109,11 @@ do
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
@@ -158,6 +174,7 @@ ln -s $QUILT_DIR/scripts/inspect-wrapper
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" \
--- a/quilt/setup.in
+++ b/quilt/setup.in
@@ -124,7 +124,7 @@ dir_to_dir()
usage()
{
- printf $"Usage: quilt setup [-d path-prefix] [-v] [--sourcedir dir] [--fuzz=N] {specfile|seriesfile}\n"
+ printf $"Usage: quilt setup [-d path-prefix] [-v] [--sourcedir dir] [--fuzz=N] [--slow|--fast] {specfile|seriesfile}\n"
if [ x$1 = x-h ]
then
printf $"
@@ -139,6 +139,17 @@ Initializes a source tree from an rpm sp
--fuzz=N
Set the maximum fuzz factor (needs rpm 4.6 or later).
+
+--slow Use the original, slow method to process the spec file. This is the
+ default for now, but that might change in the future. In this mode,
+ rpmbuild generates a working tree in a temporary directory while all
+ its actions are recorded, and then everything is replayed from scratch
+ in the target directory.
+
+--fast Use an alternative, faster method to process the spec file. In this
+ mode, rpmbuild is told to generate a working tree directly in the
+ target directory. If the input is a series file, it is assumed that
+ all archives have been extracted manually beforehand.
"
exit 0
else
@@ -146,7 +157,7 @@ Initializes a source tree from an rpm sp
fi
}
-options=`getopt -o d:vh --long sourcedir:,fuzz: -- "$@"`
+options=`getopt -o d:vh --long sourcedir:,fuzz:,slow,fast -- "$@"`
if [ $? -ne 0 ]
then
@@ -175,6 +186,12 @@ do
--fuzz)
opt_fuzz="--fuzz $2"
shift 2 ;;
+ --slow)
+ opt_fast=
+ shift ;;
+ --fast)
+ opt_fast=1
+ shift ;;
--)
shift
break ;;
@@ -208,8 +225,24 @@ case "$1" in
exit 1
fi
- if ! $QUILT_DIR/scripts/inspect $verbose $opt_sourcedir $opt_fuzz \
- "$spec_file" 2>&1 > $tmpfile
+ if [ -n "$opt_fast" ]
+ then
+ if [ "${prefix:0:1}" = / ]
+ then
+ targetdir=$prefix
+ 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 ]
then
printf $"The %%prep section of %s failed; results may be incomplete\n" "$spec_file"
if [ -z "$verbose" ]
@@ -257,8 +290,10 @@ case "$1" in
esac
# Make sure that unpacking will not overwrite anything
+[ -n "$opt_fast" ] || \
check_for_existing_directories || exit 1
+[ -n "$opt_fast" ] || \
while read tag dir arg1 arg2
do
case "$tag" in

View File

@ -0,0 +1,88 @@
From: Jean Delvare <jdelvare@suse.de>
Subject: pop: Rearm consistency check if needed
Upstream: Committed (b42985c9b2a5f8329ad393842487c4142951818e)
If the series file is inconsistent, "quilt pop" will disable the
consistency check as it updates the timestamp of the database file.
It's OK if all patches are popped. If not then the series file may
still be inconsistent. In that case, we want to update the timestamp
of the series file, to rearm the consistency check.
---
quilt/pop.in | 9 +++++++++
test/altered-series.test | 23 +++++++++++++++++------
2 files changed, 26 insertions(+), 6 deletions(-)
--- a/quilt/pop.in
+++ b/quilt/pop.in
@@ -243,6 +243,13 @@ then
exit 2
fi
+# We will update the list of applied patches, which in turn will disable the
+# consistency check. Enable it again if needed.
+if [ -z "$opt_all" -a ! "$DB" -nt "$SERIES" ] && ! consistency_check
+then
+ rearm_check=1
+fi
+
for patch in $patches
do
[ -z "$opt_refresh" ] || quilt_command refresh $QUILT_REFRESH_ARGS
@@ -264,6 +271,8 @@ else
# corner cases such as files added to a patch but not modified.
$QUILT_DIR/scripts/backup-files -L -s -B "$QUILT_PC/$patch/" -
printf $"Now at patch %s\n" "$(print_patch "$patch")"
+
+ [ -z "$rearm_check" ] || touch "$SERIES"
fi
### Local Variables:
### mode: shell-script
--- a/test/altered-series.test
+++ b/test/altered-series.test
@@ -6,22 +6,24 @@ $ cat > patches/series
< 02.patch
< 03.patch
-$ quilt push -q
+$ quilt push -q 2
> Applying patch patches/01.patch
> Patch patches/01.patch does not exist; applied empty patch
-> Now at patch patches/01.patch
+> Applying patch patches/02.patch
+> Patch patches/02.patch does not exist; applied empty patch
+> Now at patch patches/02.patch
$ quilt series -v
-> = patches/01.patch
-> patches/02.patch
+> + patches/01.patch
+> = patches/02.patch
> patches/03.patch
# Touch the series file but preserve the order -> OK
$ touch patches/series
$ quilt series -v
-> = patches/01.patch
-> patches/02.patch
+> + patches/01.patch
+> = patches/02.patch
> patches/03.patch
# Change the order of the patch series -> complain
@@ -33,6 +35,15 @@ $ cat > patches/series
$ quilt series -v
> The series file no longer matches the applied patches. Please run 'quilt pop -a'.
+$ quilt pop
+> Patch patches/02.patch appears to be empty, removing
+>
+> Now at patch patches/01.patch
+
+# That wasn't enough, keep complaining
+$ quilt series -v
+> The series file no longer matches the applied patches. Please run 'quilt pop -a'.
+
$ quilt pop -a
> Patch patches/01.patch appears to be empty, removing
>

View File

@ -1,6 +1,6 @@
From: Jean Delvare <jdelvare@suse.de> From: Jean Delvare <jdelvare@suse.de>
Subject: Check for series file consistency Subject: Check for series file consistency
Upstream: Submitted (2014-10-14) Upstream: Committed (54268c1aab28ce763ec028982bf54236488dacc5)
Quilt allows manual changes to the series file to some degree. For Quilt allows manual changes to the series file to some degree. For
example, adding comments or reordering patches in the unapplied example, adding comments or reordering patches in the unapplied

View File

@ -1,3 +1,48 @@
-------------------------------------------------------------------
Mon Dec 8 10:39:42 CET 2014 - jdelvare@suse.de
- Update upstream references.
- hackweek-11-11-setup-alternative-implementation.patch: Delete,
replaced with new implementation.
- hackweek-11-11-setup-trace-call-first.patch: inspect-wrapper:
Trace calls earlier.
- hackweek-11-12-setup-alternative-implementation-v2.patch: New
implementation of "setup --fast" option.
-------------------------------------------------------------------
Tue Nov 4 13:30:30 CET 2014 - jdelvare@suse.de
- quilt.spec: Only use Recommends for SUSE targets, as it was not
supported upstream until very recently so it breaks the build
on Fedora_18, RHEL_6 and CentOS_6.
-------------------------------------------------------------------
Mon Nov 3 14:09:31 CET 2014 - jdelvare@suse.de
- quilt-check-modified-series.patch: Add upstream reference.
- quilt-check-modified-series-rearm.patch: pop: Rearm consistency
check if needed.
- hackweek-11-01-comment-update.patch: inspect: Comment update.
- hackweek-11-02-cleanups.patch: setup/inspect: Cleanups.
- hackweek-11-03-inspect-list-all-options.patch: inspect: List all
options in usage text.
- hackweek-11-04-pass-through.patch: inspect: Pass through the
wrappers when appropriate.
- hackweek-11-05-no-explicit-rm.patch: inspect: Don't explicitly
delete the temporary data file.
- hackweek-11-06-exclude-from-md5sums.patch: inspect: Exclude more
files from md5sums.
- hackweek-11-07-normalize-path.patch: setup: Introduce function
normalize_path.
- hackweek-11-08-inspect-split-wrapper-script.patch: inspect: Split
the patch/tar/unzip wrapper to a separate script.
- hackweek-11-09-inspect-temporary-data-file.patch:
inspect-wrapper: Minor code optimization.
- hackweek-11-10-setup-fix-path-to-extra-patches.patch: setup: Fix
path to extra patches in series file.
- hackweek-11-11-setup-alternative-implementation.patch: setup: Add
--fast option.
------------------------------------------------------------------- -------------------------------------------------------------------
Tue Oct 14 13:07:53 CEST 2014 - jdelvare@suse.de Tue Oct 14 13:07:53 CEST 2014 - jdelvare@suse.de

View File

@ -51,11 +51,26 @@ Patch9: pop-add-auto-refresh.patch
Patch10: push-add-auto-refresh.patch Patch10: push-add-auto-refresh.patch
Patch11: inspect-skip-version-check.patch Patch11: inspect-skip-version-check.patch
Patch12: quilt-check-modified-series.patch Patch12: quilt-check-modified-series.patch
Patch13: quilt-check-modified-series-rearm.patch
Patch61: hackweek-11-01-comment-update.patch
Patch62: hackweek-11-02-cleanups.patch
Patch63: hackweek-11-03-inspect-list-all-options.patch
Patch64: hackweek-11-04-pass-through.patch
Patch65: hackweek-11-05-no-explicit-rm.patch
Patch66: hackweek-11-06-exclude-from-md5sums.patch
Patch67: hackweek-11-07-normalize-path.patch
Patch68: hackweek-11-08-inspect-split-wrapper-script.patch
Patch69: hackweek-11-09-inspect-temporary-data-file.patch
Patch70: hackweek-11-10-setup-fix-path-to-extra-patches.patch
Patch71: hackweek-11-11-setup-trace-call-first.patch
Patch72: hackweek-11-12-setup-alternative-implementation-v2.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildRoot: %{_tmppath}/%{name}-%{version}-build
BuildArch: noarch BuildArch: noarch
%if 0%{?suse_version}
Recommends: procmail Recommends: procmail
Recommends: bzip2 Recommends: bzip2
Recommends: /usr/bin/rpmbuild Recommends: /usr/bin/rpmbuild
%endif
%if 0%{?suse_version} > 1120 %if 0%{?suse_version} > 1120
Recommends: xz Recommends: xz
%endif %endif
@ -82,6 +97,19 @@ http://www.zip.com.au/~akpm/linux/patches/.
%patch10 -p1 %patch10 -p1
%patch11 -p1 %patch11 -p1
%patch12 -p1 %patch12 -p1
%patch13 -p1
%patch61 -p1
%patch62 -p1
%patch63 -p1
%patch64 -p1
%patch65 -p1
%patch66 -p1
%patch67 -p1
%patch68 -p1
%patch69 -p1
%patch70 -p1
%patch71 -p1
%patch72 -p1
%build %build
# --with-rpmbuild=/usr/lib/rpm/rpmb: # --with-rpmbuild=/usr/lib/rpm/rpmb:
@ -93,7 +121,7 @@ http://www.zip.com.au/~akpm/linux/patches/.
CFLAGS="%{optflags}" \ CFLAGS="%{optflags}" \
./configure --prefix=/usr \ ./configure --prefix=/usr \
--mandir=%{_mandir} \ --mandir=%{_mandir} \
--docdir=%{_docdir}/%{name} \ --docdir=%{_docdir}/%{name}%{!?suse_version:-%{version}} \
--with-sendmail=/usr/sbin/sendmail \ --with-sendmail=/usr/sbin/sendmail \
--with-diffstat=/usr/bin/diffstat \ --with-diffstat=/usr/bin/diffstat \
--with-patch-wrapper \ --with-patch-wrapper \