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

dpkg-source produces invalid diffs



Hi everyone,

I'm the new maintainer for patch. Currently, there's version 2.5 of patch
in Debian, but while packaging version 2.5.4 I discovered the
following: dpkg-source produces invalid diffs. If a new file is created,
the heaser of the patch in the *.diff.gz file looks as follows (all
examples I use in this mail are taken from plugger_3.2-3):

--- plugger-3.2.orig/debian/sys-build.mk
+++ plugger-3.2/debian/sys-build.mk
@@ -0,0 +1,149 @@


The problem is dpkg-source produces this headers using the "-L" option of
patch - but it doesn't produce a valid diff. The manual page for patch
says about creating new files:

...
       You  can create a file by sending out a diff that compares
       /dev/null or an empty file  dated  the  Epoch  (1970-01-01
       00:00:00  UTC)  to the file you want to create.  This only
       works if the file you want to create doesn't exist already
       in  the  target  directory.   Conversely, you can remove a
...


But if you look at the first line of the header there's neither the Epoch
or /dev/null. And the main problem is: You can't distinguish if a diff was
produced using "-L" to create a new file with the invalid header as done
in dpkg-source or if it is a valid context free patch (using the
"-u0" option of diff) that adds some lines at the beginning of a
file. patch version 2.5 didn't accept these valid context free patches,
but patch 2.5.4 does - with bad effects for the invalid patches made by
dpkg-source: you can apply them more than once. An example:

patch version 2.5:

$ tar xzf plugger_3.2.orig.tar.gz
$ cd plugger-3.2.orig/
$ patch -p1 < ../plugger_3.2-3.diff 
patching file `debian/sys-build.mk'
patching file `debian/dirs'
patching file `debian/arch.mk'
patching file `debian/override.Lintian'
patching file `debian/conffiles'
patching file `debian/README.Debian'
patching file `debian/rules'
patching file `debian/copyright'
patching file `debian/patches/002_pluggerrc_png.diff'
patching file `debian/patches/000_no_DEBUG_compile.diff'
patching file `debian/patches/001_pluggerrc_loc.diff'
patching file `debian/changelog'
patching file `debian/control'
patching file `debian/scripts/source.unpack'
patching file `debian/scripts/patch.unapply'
patching file `debian/scripts/patch.apply'
patching file `debian/scripts/fix.source.patch'
patching file `debian/scripts/source.patch'
patching file `debian/scripts/vars'
patching file `debian/scripts/unfix.source.patch'
patching file `debian/ns_control'
patching file `debian/archmap'
$ patch -p1 < ../plugger_3.2-3.diff 
The next patch would create the file `debian/sys-build.mk',
which already exists!  Assume -R? [n] 


patch version 2.5.4:

$ tar xzf plugger_3.2.orig.tar.gz
$ cd plugger-3.2.orig/
$ patch -p1 < ../plugger_3.2-3.diff
patching file `debian/sys-build.mk'
patching file `debian/dirs'
patching file `debian/arch.mk'
patching file `debian/override.Lintian'
patching file `debian/conffiles'
patching file `debian/README.Debian'
patching file `debian/rules'
patching file `debian/copyright'
patching file `debian/patches/002_pluggerrc_png.diff'
patching file `debian/patches/000_no_DEBUG_compile.diff'
patching file `debian/patches/001_pluggerrc_loc.diff'
patching file `debian/changelog'
patching file `debian/control'
patching file `debian/scripts/source.unpack'
patching file `debian/scripts/patch.unapply'
patching file `debian/scripts/patch.apply'
patching file `debian/scripts/fix.source.patch'
patching file `debian/scripts/source.patch'
patching file `debian/scripts/vars'
patching file `debian/scripts/unfix.source.patch'
patching file `debian/ns_control'
patching file `debian/archmap'
$ cat debian/dirs    
usr/lib/netscape/plugins-libc6/
usr/share/man/man5/
etc
$ patch -p1 < ../plugger_3.2-3.diff
patching file debian/sys-build.mk
patching file debian/dirs
patching file debian/arch.mk
patching file debian/override.Lintian
patching file debian/conffiles
patching file debian/README.Debian
patching file debian/rules
patching file debian/copyright
patching file debian/patches/002_pluggerrc_png.diff
patching file debian/patches/000_no_DEBUG_compile.diff
patching file debian/patches/001_pluggerrc_loc.diff
patching file debian/changelog
patching file debian/control
patching file debian/scripts/source.unpack
patching file debian/scripts/patch.unapply
patching file debian/scripts/patch.apply
patching file debian/scripts/fix.source.patch
patching file debian/scripts/source.patch
patching file debian/scripts/vars
patching file debian/scripts/unfix.source.patch
patching file debian/ns_control
patching file debian/archmap
$ cat debian/dirs 
usr/lib/netscape/plugins-libc6/
usr/share/man/man5/
etc
usr/lib/netscape/plugins-libc6/
usr/share/man/man5/
etc
$ 


As you can see, you can apply this diff as often as you want without a
warning. In practice, this could happen if you package a new version of a
program and you apply the patch for the old version accidentially
twice (you will run into trouble later when you run dpkg-buildpackage). 
A patch for dpkg-source to produce valid diffs is simple and is in the
BTS as #65021 (reported on dpkg instead of dpkg-dev) provided by Paul
Eggert (the upstream maintainer of patch).

This patch should be applied on dpkg-source. The other question is if a
warning to all maintainers is needed that there is a problem with the old
diffs and the new version of patch.


cu,
Adrian

(Please Cc me because I'm not on this list.)

-- 
A "No" uttered from deepest conviction is better and greater than a
"Yes" merely uttered to please, or what is worse, to avoid trouble.
                -- Mahatma Ghandi





Reply to: