Hi there,

In an unrelated exercise, I had the occasion to try and "bisect"
a RedHat kernel to figure out a bug. I thought that using quilt
would be rather handy to manage my patches for me.

Reading the man page, it looked like 'quilt setup' would do the
trick. However, it had a little problem with the -d and --path
arguments, as the setup script and scripts/inspect weren't really
playing nice with each other. Specifically, if you pass --path to
setup, scripts/inspect never finds out about it, and when it
tries to untar the tarballs, it can't find them.

For example:

----------------------------
[EMAIL PROTECTED] redhat]# pwd
/usr/src/redhat
[EMAIL PROTECTED] redhat]# ls
BUILD  RPMS  SOURCES  SPECS  SRPMS
----------------------------

If one were to follow along with the standard RedHat way of
building kernels:

  SPECS   <- kernel-2.6.spec file
  SOURCES <- upstream kernel tarball + all RedHat patches
  BUILD   <- will contain the patched source tree after rpmbuild -bp

Issuing:

----------------------------
  quilt setup -v -d /usr/src/redhat/BUILD --path /usr/src/redhat/SOURCES \
        kernel-2.6.spec
----------------------------

while inside of SPECS causes scripts/inspect to become confused
about where to find things:

----------------------------
error: File /usr/src/redhat/SPECS/linux-2.6.18.tar.bz2: No such file or 
directory
The %prep section of kernel-2.6.spec failed; results may be incomplete
----------------------------

scripts/inspect is assuming that the tarball is in the same
directory as the spec file. I don't think that is a correct
assumption, given the presence of the --path option to quilt
setup.

Here is a patch that teaches setup and scripts/inspect about the
--path option, when passed to quilt setup.

Caveat: I'm probably the world's worst bash hacker, so there are
probably a few ways to make the patch better. I can obviously
rework it, or maybe someone smarter than me can just take the
general idea and do it the correct way.

Also, I didn't really understand why setup wanted to modify $path
such that it leads off with a ":". That is why I substituted it
out near the bottom, in the create_symlinks line. Maybe there's a
real reason for it, but I couldn't figure it out.

hth,

/ac

Index: quilt/scripts/inspect
===================================================================
--- quilt.orig/scripts/inspect
+++ quilt/scripts/inspect
@@ -21,11 +21,24 @@ usage() {
        exit 1
 }
 
-if [ "$1" = -v ]
-then
-       verbose=1
-       shift
-fi
+options=`getopt -o v --long path: -- "$@"`
+
+eval set -- "$options"
+
+while true
+do
+       case "$1" in
+       -v)
+               verbose=1
+               shift ;;
+       --path)
+               path="$2"
+               shift 2 ;;
+       --)
+               shift
+               break ;;
+       esac
+done
 
 specfile=$1
 if [ $# -ne 1 -o ! -f "$specfile" ]
@@ -36,8 +49,15 @@ fi
 if [ "${specfile:0:1}"  != / ]
 then
        specfile="$PWD/$specfile"
+       specdir=$PWD
+fi
+
+if [ "$path" ]
+then
+       sourcedir=${path#:}
+else
+       sourcedir=${specfile%/*}
 fi
-sourcedir=${specfile%/*}
 
 tmpdir="$(gen_tempfile -d ${TMPDIR-/var/tmp}/${0##*/})"
 mkdir -p $tmpdir || exit 1
@@ -56,6 +76,7 @@ fi
 # create md5 sums, also for uncompressed files
 echo -n "### md5sum: " >&4
 shopt -s nullglob
+cd $sourcedir
 for file in *
 do
        file=${file##*/}
@@ -225,7 +246,7 @@ echo -n "### rpmbuild: " >&4
 
 export PATH="$tmpdir/bin:$PATH"
 rpmbuild --eval "%define _sourcedir $sourcedir" \
-        --eval "%define _specdir   $sourcedir" \
+        --eval "%define _specdir   $specdir" \
         --eval "%define _builddir  $tmpdir/build" \
         --nodeps \
         -bp "$specfile" < /dev/null >&2
Index: quilt/setup
===================================================================
--- quilt.orig/setup
+++ quilt/setup
@@ -153,7 +153,7 @@ case "$1" in
 *.spec)
        spec_file=$1
 
-       if ! $QUILT_DIR/scripts/inspect $verbose "$spec_file" 2>&1 > $tmpfile
+       if ! $QUILT_DIR/scripts/inspect $verbose --path $path "$spec_file" 2>&1 
> $tmpfile
        then
                printf $"The %%prep section of %s failed; results may be 
incomplete\n" "$spec_file"
                if [ -z "$verbose" ]
@@ -215,7 +215,7 @@ do
                ;;
        patch)
                [ -e "$prefix$dir/$QUILT_PATCHES" ] \
-               || create_symlink "" "$prefix$dir/$QUILT_PATCHES"
+               || create_symlink "${path#:}" "$prefix$dir/$QUILT_PATCHES"
                if [ -n "$series_file" ]
                then
                        [ -e "$prefix$dir/${QUILT_SERIES:-series}" ] \


_______________________________________________
Quilt-dev mailing list
[email protected]
http://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to