[debhelper-devel] [Git][debian/debhelper][master] 6 commits: Prototype; extract compat level from build-depends

Niels Thykier gitlab at salsa.debian.org
Sun Feb 25 09:53:23 UTC 2018


Niels Thykier pushed to branch master at Debian / debhelper


Commits:
c91b3ff8 by Niels Thykier at 2018-02-24T15:58:51+00:00
Prototype; extract compat level from build-depends

Signed-off-by: Niels Thykier <niels at thykier.net>

- - - - -
2712458b by Niels Thykier at 2018-02-24T15:58:51+00:00
Dh_Lib: Ensure that debhelper-compat is in Build-Depends

Signed-off-by: Niels Thykier <niels at thykier.net>

- - - - -
c013048d by Niels Thykier at 2018-02-24T15:58:51+00:00
Generate Provides field automatically

Signed-off-by: Niels Thykier <niels at thykier.net>

- - - - -
f27c5786 by Niels Thykier at 2018-02-24T16:00:45+00:00
d/changelog: Add changelog for the experimental feature

Signed-off-by: Niels Thykier <niels at thykier.net>

- - - - -
76d30a5e by Niels Thykier at 2018-02-24T16:01:50+00:00
Release debhelper/11.1.5~alpha1 into experimental

Signed-off-by: Niels Thykier <niels at thykier.net>

- - - - -
77389851 by Niels Thykier at 2018-02-25T09:51:36+00:00
Dh_Lib: add warning for d-compat B-Ds being experimental

Signed-off-by: Niels Thykier <niels at thykier.net>

- - - - -


5 changed files:

- debian/changelog
- debian/control
- + debian/gen-provides
- debian/rules
- lib/Debian/Debhelper/Dh_Lib.pm


Changes:

=====================================
debian/changelog
=====================================
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,5 +1,12 @@
 debhelper (11.1.5) UNRELEASED; urgency=medium
 
+  * Add a warning for using the new experimental feature for
+    requesting the compat level via the Build-Depends field.
+
+ -- Niels Thykier <niels at thykier.net>  Sun, 25 Feb 2018 09:49:57 +0000
+
+debhelper (11.1.5~alpha1) experimental; urgency=medium
+
   * dh_installdocs: Add missing documentation about --sourcedir
     in compat 11.
   * dh_installdocs: Document that d/tmp is used by default
@@ -32,8 +39,10 @@ debhelper (11.1.5) UNRELEASED; urgency=medium
     that the current binutils is installed for other reasons
     any way.  Thanks to Helmut Grohne for the report.
     (Closes: #891187)
+  * Dh_Lib: Add an experimental feature to determine the requested
+    compat level from the Build-Depends field.
 
- -- Niels Thykier <niels at thykier.net>  Sun, 04 Feb 2018 18:03:34 +0000
+ -- Niels Thykier <niels at thykier.net>  Sat, 24 Feb 2018 16:01:31 +0000
 
 debhelper (11.1.4) unstable; urgency=medium
 


=====================================
debian/control
=====================================
--- a/debian/control
+++ b/debian/control
@@ -45,6 +45,7 @@ Breaks: dh-systemd (<< 1.38),
         meson (<< 0.40.0~),
 Replaces: dh-systemd (<< 1.38)
 Suggests: dh-make, dwz
+Provides: ${dh:CompatLevels}
 Multi-Arch: foreign
 Description: helper programs for debian/rules
  A collection of programs that can be used in a debian/rules file to


=====================================
debian/gen-provides
=====================================
--- /dev/null
+++ b/debian/gen-provides
@@ -0,0 +1,16 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use Debian::Debhelper::Dh_Version;
+use Debian::Debhelper::Dh_Lib ();
+
+my @provides;
+my $version = $Debian::Debhelper::Dh_Version::version;
+$version =~ s/~.*//; # Drop backports marker
+$version =~ s/^\d+\K\..*//;
+for (my $i = Debian::Debhelper::Dh_Lib::LOWEST_NON_DEPRECATED_COMPAT_LEVEL ; $i <= $version ; $i++) {
+    push(@provides, "debhelper-compat (= $i)");
+}
+print "dh:CompatLevels=" . join(", ", @provides) . "\n";
+


=====================================
debian/rules
=====================================
--- a/debian/rules
+++ b/debian/rules
@@ -9,6 +9,8 @@
 # We disable autoreconf to avoid build-depending on it (it does
 # nothing for debhelper and it keeps the set of B-D smaller)
 
+PERL ?= perl
+
 %:
 	./run dh $@ --without autoreconf --with build-stamp
 
@@ -18,3 +20,5 @@ override_dh_update_autotools_config override_dh_strip_nondeterminism:
 
 override_dh_auto_install:
 	./run dh_auto_install --destdir=debian/debhelper
+	PERLLIBDIR=$$($(PERL) -MConfig -e 'print $$Config{vendorlib}')/Debian/Debhelper ; \
+	    $(PERL) -I"debian/debhelper/$${PERLLIBDIR}" debian/gen-provides > debian/debhelper.substvars


=====================================
lib/Debian/Debhelper/Dh_Lib.pm
=====================================
--- a/lib/Debian/Debhelper/Dh_Lib.pm
+++ b/lib/Debian/Debhelper/Dh_Lib.pm
@@ -674,6 +674,7 @@ sub dirname {
 
 # Pass in a number, will return true iff the current compatibility level
 # is less than or equal to that number.
+my $compat_from_bd;
 {
 	my $warned_compat = $ENV{DH_INTERNAL_TESTSUITE_SILENT_WARNINGS} ? 1 : 0;
 	my $c;
@@ -681,6 +682,8 @@ sub dirname {
 	sub compat {
 		my $num=shift;
 		my $nowarn=shift;
+
+		getpackages() if not defined($compat_from_bd);
 	
 		if (! defined $c) {
 			$c=1;
@@ -694,15 +697,23 @@ sub dirname {
 				}
 				else {
 					chomp $l;
-					$c=$l;
-					$c =~ s/^\s*+//;
-					$c =~ s/\s*+$//;
-					if ($c !~ m/^\d+$/) {
-						error("debian/compat must contain a positive number (found: \"$c\")");
+					my $new_compat = $l;
+					$new_compat =~ s/^\s*+//;
+					$new_compat =~ s/\s*+$//;
+					if ($new_compat !~ m/^\d+$/) {
+						error("debian/compat must contain a positive number (found: \"${new_compat}\")");
+					}
+					if (defined($compat_from_bd) and $compat_from_bd != -1) {
+						warning("Please specific the debhelper compat level exactly once.");
+						warning(" * debian/compat requests compat ${new_compat}.");
+						warning(" * debian/control requests compat ${compat_from_bd} via \"debhelper-compat (= ${compat_from_bd})\"");
+						error("debhelper compat level specified both in debian/compat and via build-dependency on debhelper-compat");
 					}
+					$c = $new_compat;
 				}
-			}
-			elsif (not $nowarn) {
+			} elsif ($compat_from_bd != -1) {
+				$c = $compat_from_bd;
+			} elsif (not $nowarn) {
 				error("Please specify the compatibility level in debian/compat");
 			}
 
@@ -1386,7 +1397,8 @@ sub getpackages {
 	my $arch="";
 	my $section="";
 	my ($package_type, $multiarch, %seen, @profiles, $source_section,
-		$included_in_build_profile, $cross_type, $cross_target_arch);
+		$included_in_build_profile, $cross_type, $cross_target_arch,
+		%bd_fields, $bd_field_value);
 	if (exists $ENV{'DEB_BUILD_PROFILES'}) {
 		@profiles=split /\s+/, $ENV{'DEB_BUILD_PROFILES'};
 	}
@@ -1404,15 +1416,73 @@ sub getpackages {
 
 		if (/^Source:\s*(.*)/i) {
 			$sourcepackage = $1;
+			$bd_field_value = undef;
 			next;
 		} elsif (/^Section:\s(.*)$/i) {
 			$source_section = $1;
+			$bd_field_value = undef;
 			next;
+		} elsif (/^(Build-Depends(?:-Arch|-Indep)?):\s*(.*)$/i) {
+			my ($field, $value) = (lc($1), $2);
+			$bd_field_value = [$value];
+			$bd_fields{$field} = $bd_field_value;
+		} elsif (/^\S/) {
+			$bd_field_value = undef;
+		} elsif (/^\s/ and $bd_field_value) {
+			push(@{$bd_field_value}, $_);
 		}
 		next if not $_ and not defined($sourcepackage);
 		last if (!$_ or eof); # end of stanza.
 	}
 	error("could not find Source: line in control file.") if not defined($sourcepackage);
+	if (%bd_fields) {
+		my ($dh_compat_bd, $final_level);
+		for my $field (sort(keys(%bd_fields))) {
+			my $value = join(' ', @{$bd_fields{$field}});
+			$value =~ s/\s*,\s*$//;
+			for my $dep (split(/\s*,\s*/, $value)) {
+				if ($dep =~ m/^debhelper-compat\s*[(]\s*=\s*(${PKGVERSION_REGEX})\s*[)]$/) {
+					my $version = $1;
+					if ($version =~m/^(\d+)\D.*$/) {
+						my $guessed_compat = $1;
+						warning("Please use the compat level as the exact version rather than the full version.");
+						warning("  Perhaps you meant: debhelper-compat (= ${guessed_compat})");
+						if ($field ne 'build-depends') {
+							warning(" * Also, please move the declaration to Build-Depends (it was found in ${field})");
+						}
+						error("Invalid compat level ${version}, derived from relation: ${dep}");
+					}
+					$final_level = $version;
+					error("Duplicate debhelper-compat build-dependency: ${dh_compat_bd} vs. ${dep}") if $dh_compat_bd;
+					error("The debhelper-compat build-dependency must be in the Build-Depends field (not $field)")
+						if $field ne 'build-depends';
+					$dh_compat_bd = $dep;
+				} elsif ($dep =~ m/^debhelper-compat\s*(?:\S.*)?$/) {
+					my $clevel = "${\MAX_COMPAT_LEVEL}";
+					eval {
+						require Debian::Debhelper::Dh_Version;
+						$clevel = $Debian::Debhelper::Dh_Version::version;
+					};
+					$clevel =~ s/^\d+\K\D.*$//;
+					warning("Found invalid debhelper-compat relation: ${dep}");
+					warning(" * Please format the relation as (example): debhelper-compat (= ${clevel})");
+					warning(" * Note that alternatives, architecture restrictions, build-profiles etc. are not supported.");
+					if ($field ne 'build-depends') {
+						warning(" * Also, please move the declaration to Build-Depends (it was found in ${field})");
+					}
+					warning(" * If this is not possible, then please remove the debhelper-compat relation and insert the");
+					warning("   compat level into the file debian/compat.  (E.g. \"echo ${clevel} > debian/compat\")");
+					error("Could not parse desired debhelper compat level from relation: $dep");
+				}
+			}
+		}
+		if (defined($final_level)) {
+			warning("The use of \"debhelper-compat (= ${final_level})\" is experimental and may change (or be retired) without notice");
+		}
+		$compat_from_bd = $final_level // -1;
+	} else {
+		$compat_from_bd = -1;
+	}
 
 	while (<$fd>) {
 		chomp;



View it on GitLab: https://salsa.debian.org/debian/debhelper/compare/9108d9b9d70d06e4b89f67255230972b5625c0ec...77389851ea6559f1d0c7edbd87d1aa540cccd8ab

---
View it on GitLab: https://salsa.debian.org/debian/debhelper/compare/9108d9b9d70d06e4b89f67255230972b5625c0ec...77389851ea6559f1d0c7edbd87d1aa540cccd8ab
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alioth.debian.org/pipermail/debhelper-devel/attachments/20180225/3d677b3f/attachment-0001.html>


More information about the debhelper-devel mailing list