Package: lintian
Version: 2.5.77~bpo9+1
Severity: wishlist
Tags: patch
If a package uses gbp and a deban-branch is specified in d/gbp.conf, then
vcswatch should probably be checking that branch. In #886334, it's pointed out
that vcswatch cannot use gbp.conf since that requires unpacked source. So
here's a lintian check to warn on the mismatch.
Thanks,
Ross
>From 56cec96dbd4ddfcc9c1c25637d0c07ba16c22048 Mon Sep 17 00:00:00 2001
From: Ross Vandegrift
Date: Sun, 15 Apr 2018 11:39:30 -0700
Subject: [PATCH] Warn about mismatches between git branches in gbp.conf &
Vcs-Git
If d/gbp.conf exists and the buildpackage section specifies a
debian-branch, then Vcs-Git should match that branch. This helps with the
issue described in #886334.
---
checks/git-buildpackage.desc | 15 +
checks/git-buildpackage.pm | 66 ++
debian/control | 1 +
.../debian/debian/control.in | 20 +++
.../debian/debian/gbp.conf | 2 +
t/tests/gbp-vcs-git-branch-mismatch/desc | 6 ++
t/tests/gbp-vcs-git-branch-mismatch/tags | 1 +
.../gbp-vcs-git-no-branch/debian/debian/control.in | 20 +++
.../gbp-vcs-git-no-branch/debian/debian/gbp.conf | 2 +
t/tests/gbp-vcs-git-no-branch/desc | 6 ++
t/tests/gbp-vcs-git-no-branch/tags | 1 +
11 files changed, 140 insertions(+)
create mode 100644 checks/git-buildpackage.desc
create mode 100644 checks/git-buildpackage.pm
create mode 100644 t/tests/gbp-vcs-git-branch-mismatch/debian/debian/control.in
create mode 100644 t/tests/gbp-vcs-git-branch-mismatch/debian/debian/gbp.conf
create mode 100644 t/tests/gbp-vcs-git-branch-mismatch/desc
create mode 100644 t/tests/gbp-vcs-git-branch-mismatch/tags
create mode 100644 t/tests/gbp-vcs-git-no-branch/debian/debian/control.in
create mode 100644 t/tests/gbp-vcs-git-no-branch/debian/debian/gbp.conf
create mode 100644 t/tests/gbp-vcs-git-no-branch/desc
create mode 100644 t/tests/gbp-vcs-git-no-branch/tags
diff --git a/checks/git-buildpackage.desc b/checks/git-buildpackage.desc
new file mode 100644
index 0..3d0d06973
--- /dev/null
+++ b/checks/git-buildpackage.desc
@@ -0,0 +1,15 @@
+Check-Script: git-buildpackage
+Author: Ross Vandegrift
+Abbrev: gbp
+Type: source
+Needs-Info: unpacked
+Info: This script checks for issues in gbp.conf.
+
+Tag: mismatch-between-vcs-git-and-gbp-debian-branch
+Severity: normal
+Certainty: possible
+Info: This package includes a debian/gbp.conf file, and the
+ buildpackage section specifies a branch name. However, Vcs-Git in
+ debian/control points to a different branch. If this package is
+ built with git-buildpackage, this will confuse vcswatch.
+Ref: policy 5.6.26
diff --git a/checks/git-buildpackage.pm b/checks/git-buildpackage.pm
new file mode 100644
index 0..64d63e76a
--- /dev/null
+++ b/checks/git-buildpackage.pm
@@ -0,0 +1,66 @@
+# git-buildpackage -- lintian check script -*- perl -*-
+
+# Copyright (C) 2018 Ross Vandegrift
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, you can find it on the World Wide
+# Web at http://www.gnu.org/copyleft/gpl.html, or write to the Free
+# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
+# MA 02110-1301, USA.
+
+package Lintian::git_buildpackage;
+use strict;
+use warnings;
+use autodie;
+
+use Lintian::Tags qw(tag);
+
+use Config::IniFiles;
+
+sub run {
+my ($pkg_name, $pkg_type, $info, $pkg, $group) = @_;
+
+# check for a gbp.conf with debian-branch set in the buildpackage section
+my $gbp_conf = $info->index_resolved_path('debian/gbp.conf');
+return if not $gbp_conf;
+
+my $cfg = Config::IniFiles->new(-file => $gbp_conf->fs_path);
+my $gbp_branch = $cfg->val('buildpackage', 'debian-branch');
+return if not $gbp_branch;
+
+# check for a branch in Vcs-Git
+my $dcontrol = $info->index_resolved_path('debian/control');
+return if not $dcontrol;
+
+my $fd = $dcontrol->open;
+while (my $line = <$fd>) {
+if ($line =~ /^Vcs-Git: /) {
+my (undef, $url, $dash_b, $dcontrol_branch) = split(/\s+/, $line);
+if ($dash_b ne '-b' || $dcontrol_branch ne $gbp_branch) {
+tag 'mismatch-between-vcs-git-and-gbp-debian-branch';
+}
+last;
+