#1092592 git-buildpackage: import-dsc does not correctly determine version for old (>20 year old) dsc files

Package:
git-buildpackage
Source:
git-buildpackage
Submitter:
Javier Fernández-Sanguino Peña
Date:
2025-08-14 23:51:01 UTC
Severity:
normal
Tags:
#1092592#5
Date:
2025-01-09 13:16:50 UTC
From:
To:
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 <jfs@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

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:
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

#1092592#10
Date:
2025-01-09 16:17:39 UTC
From:
To:
Hi,

Thanks for looking into this. Could you add a test to
tests/12_test_deb.py so we don't break it again in the future?

If you prefer merge requests you can use https://salsa.debian.org/agx/git-buildpackage/
which would also run the tests automatically.
Cheers,
 -- Guido

#1092592#15
Date:
2025-08-14 23:49:49 UTC
From:
To:
Hi.

This also happened to me while making a git repo for smartlist,
because smartlist_3.10.7-5.dsc is like this:

[...]
Source: smartlist
Version: 3.10.7-5
[...]
-----BEGIN PGP SIGNATURE-----
Version: 2.6.3ia
Charset: latin1


I'd like to mention that this does not happen when using
git-buildpackage from bookworm, so it might be worth to check which of
the commits between 0.9.30 (bookworm) and 0.9.36 (reported by Javier)
is the one where things started to go wrong.

Maybe there is a more simple fix than the one proposed here, for
example, it could be that considering only the very first line
matching "^Version:" would also fix this.


Regarding tests: I would probably need some help to extend tests/12_test_deb.py
but I can explain in simple words what we need:

I'm attaching compartment_1.1.0-1.dsc, one of the files which
currently make gbp import-dsc to fail. When this file is read,
version should be 1.1.0-1 and not 2.6.3ia. I guess this
would be checked in this way:

self.assertEqual(dsc.version, '1.1.0-1')

Javier or Guido: Based on the above, could you fill the gaps?

Thanks.