Package: cdbs
Version: 0.4.44
Severity: wishlist
Tags: patch

Hi!

I did some improvements to cdbs-edit-patch:

 - Now works for packages using tarball.mk.
 - Can edit patches which produce rejections.
 - Strips off 'debian/patches/' from patch name argument to comfortably
   work with command line completion.

Patch attached.

Thanks for considering,

Martin
-- 
Martin Pitt        http://www.piware.de
Ubuntu Developer   http://www.ubuntu.com
Debian Developer   http://www.debian.org

In a world without walls and fences, who needs Windows and Gates?
=== modified file 'debian/changelog'
--- debian/changelog    
+++ debian/changelog    
@@ -1,3 +1,13 @@
+cdbs (0.4.44ubuntu3) edgy; urgency=low
+
+  * Various improvements to scripts/cdbs-edit-patch:
+    - Now works for packages using tarball.mk.
+    - Can edit patches which produce rejections.
+    - Strips off 'debian/patches/' from patch name argument to comfortably
+      work with command line completion.
+
+ -- Martin Pitt <[EMAIL PROTECTED]>  Wed,  2 Aug 2006 11:49:46 +0200
+
 cdbs (0.4.44ubuntu2) edgy; urgency=low
 
   * fix bashism in python-distutils.mk.in to fix ftbfs for python packages, 

=== modified file 'scripts/cdbs-edit-patch'
--- scripts/cdbs-edit-patch     
+++ scripts/cdbs-edit-patch     
@@ -31,6 +31,8 @@
 
 SRCDIR=$(pwd)
 PATCHNAME=${1%.patch}.patch
+PATCHNAME=${PATCHNAME#debian/patches/}
+
 TMP=$(mktemp -t -d cdbs-new-patch.XXXXXX)
 TMP2=$(mktemp -t cdbs-old-patch-header.XXXXXX)
 trap "rm -rf $TMP $TMP2" 0 1 2 3 9 11 13 15
@@ -49,7 +53,7 @@
 # lexicographic patch position
 [ -e "debian/patches/$PATCHNAME" ] || touch "debian/patches/$PATCHNAME" 
 
-# remove all patches later than the one to edit
+# remove all patches later than or equal to the one to edit
 for p in $(find debian/patches -type f -name "*.patch" | LC_COLLATE=C sort 
-r); do
     rm -f "$p"
     pname=$(basename "$p")
@@ -58,9 +62,12 @@
 
 debian/rules apply-patches
 
+build_tree=`grep '^[[:space:]]*DEB_TAR_SRCDIR\>' debian/rules | cut -f2- -d=` 
|| true
+[ -z "$build_tree" ] || build_tree="build-tree/$build_tree"
+
 # create new source dir
 cp -a . $TMP/$NEWDIR
-cd $TMP/$NEWDIR
+cd $TMP/$NEWDIR/$build_tree
 
 # if we edit a patch, apply the already existing one to the new directory
 if [ -e "$SRCDIR/debian/patches/$PATCHNAME" ]; then
@@ -77,7 +84,8 @@
     done
     [ "$success" ] || {
         echo " failure"
-        exit 1
+       echo "Forcuefully applying patch at level 1, you have to fix the 
rejections manually."
+       patch --no-backup-if-mismatch -V never -p1 < 
"$SRCDIR/debian/patches/$PATCHNAME" || true
     }
 fi
 
@@ -96,5 +104,10 @@
         cat $TMP2 > $SRCDIR/debian/patches/$PATCHNAME
     fi
     cd $TMP
-    diff -Nur $ORIGDIR $NEWDIR >> $SRCDIR/debian/patches/$PATCHNAME
+    diff -Nur $ORIGDIR/$build_tree $NEWDIR/$build_tree >> 
$SRCDIR/debian/patches/$PATCHNAME || true
+
+    # adjust paths in patches with build tree
+    if [ -n "$build_tree" ]; then
+       sed -i "s_^\(---\|+++\) [^/]*/build-tree/_\1 _" 
$SRCDIR/debian/patches/$PATCHNAME
+    fi 
 fi

Attachment: signature.asc
Description: Digital signature

Reply via email to