[debhelper-devel] [debhelper] 07/28: dh_strip: Add --ddeb-migration=RELATION option

Niels Thykier nthykier at moszumanska.debian.org
Sun Jun 28 12:57:16 UTC 2015


This is an automated email from the git hooks/post-receive script.

nthykier pushed a commit to branch master
in repository debhelper.

commit 8a83ae9de0d068b8ce16527cdb32b522bbc773d3
Author: Niels Thykier <niels at thykier.net>
Date:   Fri May 15 17:19:52 2015 +0200

    dh_strip: Add --ddeb-migration=RELATION option
    
    Add an --debug-migration option that accepts a Breaks+Replaces
    relation.  This relation is added to the generated to ddebs to avoid
    file-conflicts.
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 dh_gencontrol | 29 ++++++++++++++++++++++++++---
 dh_strip      | 41 ++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 66 insertions(+), 4 deletions(-)

diff --git a/dh_gencontrol b/dh_gencontrol
index a987499..bd18916 100755
--- a/dh_gencontrol
+++ b/dh_gencontrol
@@ -50,7 +50,8 @@ my $src_pkg;
 foreach my $package (@{$dh{DOPACKAGES}}) {
 	my $tmp=tmpdir($package);
 	my $ext=pkgext($package);
-	my $ddeb_tmp = "debian/.debhelper/${package}/ddeb-root";
+	my $ddeb_info_dir = "debian/.debhelper/${package}";
+	my $ddeb_tmp = "${ddeb_info_dir}/ddeb-root";
 
 	my $substvars="debian/${ext}substvars";
 	
@@ -77,13 +78,13 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		my $arch = package_arch($package);
 		my $ddeb_filename = ddeb_filename($package);
 		my $multiarch = package_multiarch($package);
+		my $replaces = read_ddeb_migration($ddeb_info_dir);
 		$src_pkg = sourcepackage() if not defined($src_pkg);
 
 		# Remove and override more or less every standard field.
 		my @ddeb_options = (qw(
 			-UPre-Depends -URecommends -USuggests -UEnhances -UProvides -UEssential
-			-UReplaces -UBreaks -UConflicts
-			-DPriority=extra -DSection=debug
+			-UConflicts -DPriority=extra -DSection=debug
 			),
 			 "-DPackage=${package}-dbgsym",
 			 "-DDepends=${package}:${arch} (= \${binary:Version})",
@@ -97,6 +98,15 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		if ($multiarch ne 'same') {
 			push(@ddeb_options, '-UMulti-Arch');
 		}
+		# If the ddeb is replacing an existing -dbg package, then
+		# declare the necessary Breaks + Replaces.  Otherwise, clear
+		# the fields.
+		if ($replaces) {
+			push(@ddeb_options, "-DReplaces=${replaces}",
+				 "-DBreaks=${replaces}");
+		} else {
+			push(@ddeb_options, '-UReplaces', '-UBreaks');
+		}
 		if ( ! -d "${ddeb_tmp}/DEBIAN" ) {
 			install_dir("${ddeb_tmp}/DEBIAN");
                 }
@@ -118,6 +128,19 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 	doit("chown","0:0","$tmp/DEBIAN/control");
 }
 
+sub read_ddeb_migration {
+	my ($ddeb_info_dir) = @_;
+	my $ddeb_migration = "${ddeb_info_dir}/ddeb-migration";
+	my $result;
+	if (-f $ddeb_migration) {
+		open(my $fd, '<', $ddeb_migration)
+			or error("open $ddeb_migration failed: $!");
+		chomp($result = <$fd>);
+		close($fd);
+	}
+	return $result;
+}
+
 =head1 SEE ALSO
 
 L<debhelper(7)>
diff --git a/dh_strip b/dh_strip
index 23b1eec..ada7e9b 100755
--- a/dh_strip
+++ b/dh_strip
@@ -44,6 +44,13 @@ things to exclude.
 
 =item B<--dbg-package=>I<package>
 
+B<This option is a now special purpose option that you normally do not
+need>.  In most cases, there should be little reason to use this
+option for new source packages as debhelper generates automatic debug
+packages ("ddebs").  B<If you have a manual --dbg-package> that you
+want to migrate to the automatic ddeb, please see the
+B<--ddeb-migration> option.
+
 Causes B<dh_strip> to save debug symbols stripped from the packages it acts on
 as independent files in the package build directory of the specified debugging
 package.
@@ -66,6 +73,22 @@ is easier to use than this option, but this option is more flexible.
 This option will inhibit the creation of automatic "ddebs" for the
 affected packages.
 
+=item B<--ddeb-migration=>I<package-relation>
+
+This option is used to migrate from a manual "-dbg" package (created
+with B<--dbg-package>) to the automatic "ddebs".  The value of this
+option should describe a valid B<Replaces>- and B<Breaks>-relation,
+which will be added to the ddebs to avoid file conflicts with the (now
+obsolete) -dbg package.
+
+This option B<cannot> be used with B<--keep-debug> nor B<--dbg-package>.
+
+Examples:
+
+  dh_strip --ddeb-migration='libfoo-dbg (<< 2.1-3~)'
+
+  dh_strip --ddeb-migration='libfoo-tools-dbg (<< 2.1-3~), libfoo2-dbg (<< 2.1-3~)'
+
 =back
 
 =head1 NOTES
@@ -83,10 +106,20 @@ Debian policy, version 3.0.1
 
 =cut
 
+my $migrate_ddeb;
+
 init(options => {
-	"keep-debug" => \$dh{K_FLAG},
+	"keep-debug"       => \$dh{K_FLAG},
+	'ddeb-migration=s' => \$migrate_ddeb,
 });
 
+if ($dh{K_FLAG} and $migrate_ddeb) {
+	error("--keep-debug and --ddeb-migration are mutually exclusive");
+}
+if ($dh{DEBUGPACKAGES} and $migrate_ddeb) {
+	error("--dbg-package and --ddeb-migration are mutually exclusive");
+}
+
 # This variable can be used to turn off stripping (see Policy).
 if (get_buildoption('nostrip')) {
 	exit;
@@ -274,6 +307,12 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			install_dir($ddeb_docdir) if not -d $ddeb_docdir;
 			doit('ln', '-s', $package, $doc_symlink);
 		}
+		if ($migrate_ddeb) {
+			my $path = "debian/.debhelper/${package}/ddeb-migration";
+			open(my $fd, '>', $path) or error("open $path failed: $!");
+			print {$fd} "$migrate_ddeb\n";
+			close($fd) or error("close $path failed: $!");
+		}
 	}
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debhelper/debhelper.git




More information about the debhelper-devel mailing list