Package: git-buildpackage
Version: 0.9.36
Severity: normal
Tags: patch

When importing packages that were built and signed a long time ago (>20 years),
gbp import-dsc fails to determine correcly the version for the package (and for
upstream).

This prevents me from importing all my old history of packages in one go to
GIT. I found a workaround by importing manually one DSC file at a time and then
fixing the git tags manually.


Take, for example, the following situation. Compartment, which is a package of 
over 20 years, with the following DSC files:

jfs@silicio:compartment$ ls -ltr ../*dsc
-rw-r--r-- 1 jfs jfs  681 ene  6  2003 ../compartment_1.1-2.dsc
-rw-r--r-- 1 jfs jfs  681 ene  6  2003 ../compartment_1.1-1.dsc
-rw-r--r-- 1 jfs jfs  682 ene  6  2003 ../compartment_1.1-3.dsc
-rw-r--r-- 1 jfs jfs  682 may 27  2003 ../compartment_1.1-4.dsc
-rw-r--r-- 1 jfs jfs  682 oct 28  2003 ../compartment_1.1-5.dsc
-rw-r--r-- 1 jfs jfs  688 dic 24  2003 ../compartment_1.1.0-1.dsc
-rw-r--r-- 1 jfs jfs  700 feb 25  2005 ../compartment_1.1.0-2.dsc
-rw-r--r-- 1 jfs jfs  700 abr 30  2006 ../compartment_1.1.0-3.dsc
-rw-r--r-- 1 jfs jfs  972 may 31  2008 ../compartment_1.1.0-4.dsc
-rw-r--r-- 1 jfs jfs 1725 ene  4  2017 ../compartment_1.1.0-5.dsc

The oldest one uses the format from GnuPG at the time which has a Version: 
header which is as follows:

-----BEGIN PGP SIGNED MESSAGE-----

Format: 1.0
Source: compartment
Version: 1.1-1
Binary: compartment
Maintainer: Javier Fernandez-Sanguino Pena <j...@computer.org>
Architecture: any
Standards-Version: 3.1.0
Build-Depends: debhelper
Files:
 e97310bc577ee033c5c7fa753ba5d7d1 23942 compartment_1.1.orig.tar.gz
 58cf68a70f34e6df2f6f61ec44ea8ff6 2261 compartment_1.1-1.diff.gz

-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: noconv

iQCVAwUBPNB9SPtEPvakNq0lAQEm/gQAtdE0pWwH0XWzV4BDm6kumzgIvx+y3HHZ
2Erbyv3/9trVmVwaCgCa2XS3hbzCxGqJJU8ysO005BgnKen9rNLfe4rZYzhVbprD
otIlkhZzkKsDooIRpR862ZVPytAuBxiBymp3pUv5wEh6T/hsmPY57Hd5335W3wsw
RW+SynTqrC8=
=+bMW
-----END PGP SIGNATURE-----


The dscs from version 1.1.0-2 and later have a PGP signature header with the 
following content:

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iQCVAwUBQh5wrPtEPvakNq0lAQI1oQQAgoaGTvODCDqMbp7aLx4FEb+xhmYWRLYG
c1TJ5ukhXC57H8rqQsSrNCAopW1QvDKQt/GZZkj+OR9SZib2kKhCEJHYNuSpTQeb
5npdKDQLrisWaEd6LOIdKxFSDIgG/20wUayPpg6behqTCnFzdcBI8wjh5CU2JulO
G7SKvG7D4RI=
=5vpc
-----END PGP SIGNATURE-----

If I try to import them all using import-dscs into a single GIT repository, the 
following happens:

jfs@silicio:compartment-test$ gbp import-dscs 
/home/jfs/debian/security/compartment/*dsc
gbp:info: Version '1.1.0-2' imported under '/tmp/compartment-test'
gbp:info: Version '1.1.0-3' imported under '/tmp/compartment-test'
gbp:info: Version '1.1.0-4' imported under '/tmp/compartment-test'
gbp:info: Version '1.1.0-5' imported under '/tmp/compartment-test'
gbp:info: Version '2.6.3ia' imported under '/tmp/compartment-test'
gbp:warning: Version 2.6.3ia already imported.
gbp:warning: Version 2.6.3ia already imported.
gbp:warning: Version 2.6.3ia already imported.
gbp:warning: Version 2.6.3ia already imported.
gbp:warning: Version 2.6.3ia already imported.
gbp:info: Everything imported under /tmp/compartment-test


And the following is the result on tags:

jfs@silicio:compartment-test$ git tag
debian/1.1.0-2
debian/1.1.0-3
debian/1.1.0-4
debian/1.1.0-5
debian/2.6.3ia
upstream/1.1.0
upstream/2.6.3ia

As you can see, a tag 'debian/2.6.3ia' has been created as well as a
'upstream/2.6.3ia'. This appears to be due to import-dsc misinterpreting the 
Version: header
used in the PGP signature footer.

The attached proposed patch skips the section of the DSCs files that contain
the PGP signature, to avoid the parsing of the headers in that section of the
DSC file.

It seems to work find when bulk importing. With this patch, gbp import-dscs now 
works fine in my case:

jfs@silicio:compartment-test-fix$ gbp import-dscs 
/home/jfs/debian/security/compartment/*dsc
gbp:info: Version '1.1-1' imported under '/tmp/compartment-test-fix'
gbp:info: Version '1.1-2' imported under '/tmp/compartment-test-fix'
gbp:info: Version '1.1-3' imported under '/tmp/compartment-test-fix'
gbp:info: Version '1.1-4' imported under '/tmp/compartment-test-fix'
gbp:info: Version '1.1-5' imported under '/tmp/compartment-test-fix'
gbp:info: Version '1.1.0-1' imported under '/tmp/compartment-test-fix'
gbp:info: Version '1.1.0-2' imported under '/tmp/compartment-test-fix'
gbp:info: Version '1.1.0-3' imported under '/tmp/compartment-test-fix'
gbp:info: Version '1.1.0-4' imported under '/tmp/compartment-test-fix'
gbp:info: Version '1.1.0-5' imported under '/tmp/compartment-test-fix'
gbp:info: Everything imported under /tmp/compartment-test-fix
jfs@silicio:compartment-test-fix$ git tag
debian/1.1-1
debian/1.1-2
debian/1.1-3
debian/1.1-4
debian/1.1-5
debian/1.1.0-1
debian/1.1.0-2
debian/1.1.0-3
debian/1.1.0-4
debian/1.1.0-5
upstream/1.1
upstream/1.1.0


Could you please review and upload this fix to the new release?

Thanks!

Javier







-- System Information:
Debian Release: trixie/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: i386 (i686)

Kernel: Linux 6.10.12-686-pae (SMP w/4 CPU threads; PREEMPT)
Locale: LANG=es_ES.UTF-8, LC_CTYPE=es_ES.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled

Versions of packages git-buildpackage depends on:
ii  devscripts        2.24.1
ii  git               1:2.45.2-1
ii  man-db            2.13.0-1
ii  python3           3.12.6-1
ii  python3-dateutil  2.9.0-3
ii  python3-yaml      6.0.2-1
ii  sensible-utils    0.0.24

Versions of packages git-buildpackage recommends:
ii  cowbuilder        0.90
ii  pbuilder          0.231.1
ii  pristine-tar      1.50+nmu2
ii  python3-requests  2.32.3+dfsg-1

Versions of packages git-buildpackage suggests:
ii  python3-notify2  0.3-5
ii  sudo             1.9.15p5-3+b1
ii  unzip            6.0-28

-- no debconf information
--- dscfile.py.orig     2025-01-09 14:07:46.436216047 +0100
+++ dscfile.py  2025-01-09 14:13:22.697862184 +0100
@@ -95,6 +95,8 @@
         fromdir = os.path.dirname(self.dscfile)
 
         for line in f:
+            if line.strip() == "-----BEGIN PGP SIGNATURE-----":
+                break
             m = self.version_re.match(line)
             if m:
                 self.full_version = m.group('version')

Reply via email to