Source: git-buildpackage Version: 0.9.30 Severity: normal Tags: patch Dear Guido,
Source format 1.0 native packages with a hyphen in their version number are considered non-native by gbp import-dsc: $ git init --initial-branch=master Initialized empty Git repository in /tmp/p3d/.git/ $ gbp import-dsc --allow-unauthenticated --create-missing-branches http://snapshot.debian.org/archive/debian/20240720T144054Z/pool/main/p/python3-defaults/python3-defaults_3.12.4-1.dsc gbp:info: Downloading 'http://snapshot.debian.org/archive/debian/20240720T144054Z/pool/main/p/python3-defaults/python3-defaults_3.12.4-1.dsc' using 'dget'... gbp:warning: Didn't find a diff to apply. gbp:info: Version '3.12.4-1' imported under '/tmp/p3d' $ gbp import-dsc --allow-unauthenticated http://snapshot.debian.org/archive/debian/20240808T091320Z/pool/main/p/python3-defaults/python3-defaults_3.12.5-1.dsc gbp:info: Downloading 'http://snapshot.debian.org/archive/debian/20240808T091320Z/pool/main/p/python3-defaults/python3-defaults_3.12.5-1.dsc' using 'dget'... gbp:warning: Didn't find a diff to apply. gbp:info: Version '3.12.5-1' imported under '/tmp/p3d' $ git log --oneline 740baad (HEAD -> master, tag: upstream/3.12.4) Import Upstream version 3.12.4 $ git log --oneline upstream f662363 (tag: upstream/3.12.5, upstream) Import Upstream version 3.12.5 740baad (HEAD -> master, tag: upstream/3.12.4) Import Upstream version 3.12.4 The symptoms are the "Didn't find a diff to apply" warnings, using an "upstream" branch and leaving the "master" branch behind. Please consider https://github.com/agx/git-buildpackage/pull/96, the patch is attached here as well. -- Thanks, Feri.
>From 1c181f7cc27ad4f5fafec89255c38da485984dd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ferenc=20W=C3=A1gner?= <ferenc.wag...@balabit.com> Date: Thu, 29 Aug 2024 12:11:52 +0200 Subject: [PATCH] dscfile.py: decide native/non-native based on diff presence, not version format Source format 1.0 native packages with a hyphen in their version number were mistaken by the original code for non-native. For example: $ git init --initial-branch=master Initialized empty Git repository in /tmp/p3d/.git/ $ gbp import-dsc --allow-unauthenticated --create-missing-branches http://snapshot.debian.org/archive/debian/20240720T144054Z/pool/main/p/python3-defaults/python3-defaults_3.12.4-1.dsc gbp:info: Downloading 'http://snapshot.debian.org/archive/debian/20240720T144054Z/pool/main/p/python3-defaults/python3-defaults_3.12.4-1.dsc' using 'dget'... gbp:warning: Didn't find a diff to apply. gbp:info: Version '3.12.4-1' imported under '/tmp/p3d' $ gbp import-dsc --allow-unauthenticated http://snapshot.debian.org/archive/debian/20240808T091320Z/pool/main/p/python3-defaults/python3-defaults_3.12.5-1.dsc gbp:info: Downloading 'http://snapshot.debian.org/archive/debian/20240808T091320Z/pool/main/p/python3-defaults/python3-defaults_3.12.5-1.dsc' using 'dget'... gbp:warning: Didn't find a diff to apply. gbp:info: Version '3.12.5-1' imported under '/tmp/p3d' $ git log --oneline 740baad (HEAD -> master, tag: upstream/3.12.4) Import Upstream version 3.12.4 $ git log --oneline upstream f662363 (tag: upstream/3.12.5, upstream) Import Upstream version 3.12.5 740baad (HEAD -> master, tag: upstream/3.12.4) Import Upstream version 3.12.4 The symptoms are the "Didn't find a diff to apply" warnings, using an "upstream" branch and leaving the "master" branch behind. After this change the same commands result in: $ git init --initial-branch=master Initialized empty Git repository in /tmp/p3d/.git/ $ gbp import-dsc --allow-unauthenticated --create-missing-branches http://snapshot.debian.org/archive/debian/20240720T144054Z/pool/main/p/python3-defaults/python3-defaults_3.12.4-1.dsc gbp:info: Downloading 'http://snapshot.debian.org/archive/debian/20240720T144054Z/pool/main/p/python3-defaults/python3-defaults_3.12.4-1.dsc' using 'dget'... gbp:info: Tag debian/3.12.4-1 not found, importing Debian tarball gbp:info: Version '3.12.4-1' imported under '/tmp/p3d' $ gbp import-dsc --allow-unauthenticated http://snapshot.debian.org/archive/debian/20240808T091320Z/pool/main/p/python3-defaults/python3-defaults_3.12.5-1.dsc gbp:info: Downloading 'http://snapshot.debian.org/archive/debian/20240808T091320Z/pool/main/p/python3-defaults/python3-defaults_3.12.5-1.dsc' using 'dget'... gbp:info: Tag debian/3.12.5-1 not found, importing Debian tarball gbp:info: Version '3.12.5-1' imported under '/tmp/p3d' $ git log --oneline 4dd04b9 (HEAD -> master, tag: debian/3.12.5-1) Import Debian version 3.12.5-1 107717c (tag: debian/3.12.4-1) Import Debian version 3.12.4-1 No warnings and a single "master" branch with two commits, which means the package was handled as native. Source format 3.0 has a separate subtype for native packages, so that case is straightforward as well. --- gbp/deb/dscfile.py | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/gbp/deb/dscfile.py b/gbp/deb/dscfile.py index f6829b50..aa2f9dd6 100644 --- a/gbp/deb/dscfile.py +++ b/gbp/deb/dscfile.py @@ -39,7 +39,7 @@ class DscFile(object): r'\.diff.(gz|bz2))$') deb_tgz_re = re.compile(r'^\s\w+\s\d+\s+(?P<deb_tgz>[^_]+_[^_]+' r'\.debian.tar.%s)$' % compressions) - format_re = re.compile(r'Format:\s+(?P<format>[0-9.]+)\s*') + format_re = re.compile(r'Format:\s+(?P<format>[0-9.]+)\s*(?:\((?P<subtype>native|quilt|git)\))?') sig_re = re.compile(r'^\s\w+\s\d+\s+(?P<sig>[^_]+_[^_]+' r'\.orig(-[a-z0-9-]+)?\.tar\.%s.asc)$' % compressions) @@ -60,12 +60,27 @@ class DscFile(object): except UnicodeDecodeError: raise GbpError(f"{self.dscfile} is not UTF-8 encoded") - # Source format 1.0 can have non-native packages without a Debian revision: - # e.g. http://snapshot.debian.org/archive/debian/20090801T192339Z/pool/main/l/latencytop/latencytop_0.5.dsc - if self.pkgformat == "1.0" and self.diff: - self.native = False - elif not self.native and not self.debian_version: - raise GbpError("Cannot parse Debian version number from '%s'" % self.dscfile) + if self.pkgformat == "1.0": + self.native = self.diff == "" + else: + self.native = self.subtype == 'native' + if self.native: + # Source format 1.0 native versions may contain hyphens. Examples: + # http://snapshot.debian.org/package/python3-defaults/3.10.6-1/ + # http://archive.ubuntu.com/ubuntu/pool/main/p/pam/pam_1.1.8-3.6ubuntu2.18.04.6.dsc + self.upstream_version = self.full_version + else: + self.upstream_version, separator, self.debian_version = self.full_version.rpartition('-') + if separator: + if not self.debian_version: + raise GbpError("Cannot parse Debian version number from '%s'" % self.dscfile) + if not self.upstream_version: + raise GbpError("Cannot parse upstream version number from '%s'" % self.dscfile) + else: + # Source format 1.0 non-native versions without hyphen: + # http://snapshot.debian.org/package/latencytop/0.5/ + self.upstream_version = self.full_version + self.debian_version = '' if not self.pkg: raise GbpError("Cannot parse package name from '%s'" % self.dscfile) @@ -81,18 +96,9 @@ class DscFile(object): for line in f: m = self.version_re.match(line) - if m and not self.upstream_version: - if '-' in m.group('version'): - self.debian_version = m.group('version').split("-")[-1] - self.upstream_version = "-".join(m.group('version').split("-")[0:-1]) - self.native = False - else: - self.native = True # Debian native package - self.upstream_version = m.group('version') - if m.group('epoch'): - self.epoch = m.group('epoch') - else: - self.epoch = "" + if m: + self.full_version = m.group('version') + self.epoch = m.group('epoch') or '' continue m = self.pkg_re.match(line) if m: @@ -122,6 +128,7 @@ class DscFile(object): m = self.format_re.match(line) if m: self.pkgformat = m.group('format') + self.subtype = m.group('subtype') or '' continue self.additional_tarballs = dict(add_tars) -- 2.39.2