SHA256
1
0
forked from pool/quilt
quilt/hackweek-11-12-setup-alternative-implementation-v2.patch
Jean Delvare 6732de62cf - Update upstream references.
- quilt-el-fix-tramp-support.patch: quilt-el: Fix tramp support.
- quilt-el-fix-patch-select-completion.patch: quilt-el: Fix patch
  select completion.
- hackweek-11-13-setup-let-normalize_path-deal-with-dot.patch:
  setup: Let normalize_path deal with ".".
- hackweek-11-14-setup-fix-link-creation.patch: setup: Fix link
  creation.

OBS-URL: https://build.opensuse.org/package/show/devel:tools:scm/quilt?expand=0&rev=94
2015-01-28 10:58:31 +00:00

222 lines
6.7 KiB
Diff

From: Jean Delvare <jdelvare@suse.de>
Subject: setup: Add --fast option
Upstream: Committed (c0f677497b760028ae8aafb72d4d08604aa7870e)
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