quilt-dev
[Top][All Lists]
Advanced

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

[Quilt-dev] [PATCH] patch-wrapper: Make the patch names that quilt shows


From: Jean Delvare
Subject: [Quilt-dev] [PATCH] patch-wrapper: Make the patch names that quilt shows more convenient
Date: Thu, 01 Dec 2016 11:15:48 +0100

From: Andreas Grünbacher <address@hidden>

When operating on an rpm package, create links to the rpm sources and
build directories and make patch names relative to these links. This is
more convenient than using ugly absolute paths.
---
 bin/patch-wrapper.in |   45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)

Andreas, this patch has been in the SUSE quilt package since February
2006. Is there any reason why you never pushed it upstream? It looks
good to me and I don't want to carry extra patches forever.

--- a/bin/patch-wrapper.in
+++ b/bin/patch-wrapper.in
@@ -28,7 +28,7 @@ fi
 
 backup_files()
 {
-    declare dir=${QUILT_PC:-.pc}/$patch
+    declare dir=${QUILT_PC:-.pc}/$name
 
     if [ "$backup_mode" = --backup-if-mismatch ]
     then
@@ -201,39 +201,56 @@ then
 fi
 
 quilt_patches=${QUILT_PATCHES:-patches}
-dir=$(dirname "$quilt_patches/$patch")
-mkdir -p "$dir"
-if [ -e "$patch" ]
+
+if [ "${patch#$RPM_SOURCE_DIR}" != "$patch" ]
+then
+    name=SOURCES/${patch#$RPM_SOURCE_DIR/}
+    if [ ! -e "$quilt_patches/SOURCES" ]
+    then
+       mkdir -p "$quilt_patches"
+       ln -s $RPM_SOURCE_DIR "$quilt_patches/SOURCES"
+    fi
+elif [ "${patch#$RPM_BUILD_DIR}" != "$patch" ]
 then
+    name=BUILD/${patch#$RPM_BUILD_DIR/}
+    if [ ! -e "$quilt_patches/BUILD" ]
+    then
+       mkdir -p "$quilt_patches"
+       ln -s $RPM_BUILD_DIR "$quilt_patches/BUILD"
+    fi
+else
+    name=${patch#/}
+    dir=$(dirname "$quilt_patches/$name")
+    mkdir -p "$dir"
+
     if [ "${patch:0:1}" = / ]
     then
-       ln -s "$patch" "$quilt_patches$patch"
-       patch=${patch#/}
+       ln -s "$patch" "$quilt_patches/${name#/}"
     else
-       while ! [ "$dir/$updir$patch" -ef "$patch" ]
+       while ! [ "$dir/$updir$name" -ef "$patch" ]
        do
            updir=$updir../
            [ ${#updir} -gt 96 ] && break
        done
-       if [ "$dir/$updir$patch" -ef "$patch" ]
+       if [ "$dir/$updir$name" -ef "$patch" ]
        then
-           ln -s "$updir$patch" "$quilt_patches/$patch"
+           ln -s "$updir$patch" "$quilt_patches/$name"
        fi
     fi
 fi
 
 if [ "$opt_strip" = -p1 ]; then
-    echo "$patch"
+    echo "$name"
 else
-    echo "$patch $opt_strip"
+    echo "$name $opt_strip"
 fi >> $quilt_patches/series
 
-$PATCH "address@hidden" --backup --prefix "${QUILT_PC:-.pc}/$patch/" \
+$PATCH "address@hidden" --backup --prefix "${QUILT_PC:-.pc}/$name/" \
     | backup_files
 status=${PIPESTATUS[0]}
 if [ $status -eq 0 ]
 then
-    dir=${QUILT_PC:-.pc}/$patch
+    dir=${QUILT_PC:-.pc}/$name
     if [ ! -e "$dir" ]
     then
        mkdir -p "$dir"
@@ -243,6 +260,6 @@ then
     then
        echo 2 > ${QUILT_PC:-.pc}/.version
     fi
-    echo "$patch" >> "${QUILT_PC:-.pc}/applied-patches"
+    echo "$name" >> "${QUILT_PC:-.pc}/applied-patches"
 fi
 exit $status

-- 
Jean Delvare
SUSE L3 Support




reply via email to

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