[debhelper-devel] [debhelper] 01/02: dh_strip: Refactor to reduce code size

Niels Thykier nthykier at moszumanska.debian.org
Thu Sep 14 20:34:37 UTC 2017


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

nthykier pushed a commit to branch bug-35733-elf-detection
in repository debhelper.

commit 37df80c3d69da0890ffbd22f722df363c4846832
Author: Niels Thykier <niels at thykier.net>
Date:   Thu Sep 14 16:54:38 2017 +0000

    dh_strip: Refactor to reduce code size
    
    Signed-off-by: Niels Thykier <niels at thykier.net>
---
 dh_strip | 44 ++++++++++++++------------------------------
 1 file changed, 14 insertions(+), 30 deletions(-)

diff --git a/dh_strip b/dh_strip
index beca220..b1e767c 100755
--- a/dh_strip
+++ b/dh_strip
@@ -146,20 +146,14 @@ init(options => {
 
 });
 
-if ($dh{K_FLAG} and $dh{MIGRATE_DBGSYM}) {
-	error("--keep-debug and --dbgsym-migration are mutually exclusive");
-}
-if ($dh{DEBUGPACKAGE} and $dh{MIGRATE_DBGSYM}) {
-	error("--dbg-package and --dbgsym-migration are mutually exclusive");
+if ($dh{MIGRATE_DBGSYM}) {
+	error("--keep-debug and --dbgsym-migration are mutually exclusive") if ($dh{K_FLAG});
+	error("--dbg-package and --dbgsym-migration are mutually exclusive") if ($dh{DEBUGPACKAGE});
 }
 
-if ($dh{ENABLE_DBGSYM} and $dh{ENABLE_DBGSYM} ne 'auto') {
-	if ($dh{K_FLAG}) {
-		error("--keep-debug and explicit --automatic-dbgsym are mutually exclusive");
-	}
-	if ($dh{DEBUGPACKAGE}) {
-		error("--dbg-package and explicit --automatic-dbgsym are mutually exclusive");
-	}
+if ($dh{ENABLE_DBGSYM}) {
+	error("--keep-debug and explicit --automatic-dbgsym are mutually exclusive") if ($dh{K_FLAG});
+	error("--dbg-package and explicit --automatic-dbgsym are mutually exclusive") if ($dh{DEBUGPACKAGE});
 }
 
 $dh{ENABLE_DBGSYM} = 1 if not defined($dh{ENABLE_DBGSYM});
@@ -169,9 +163,7 @@ if ($dh{MIGRATE_DBGSYM} and not $dh{ENABLE_DBGSYM}) {
 }
 
 # This variable can be used to turn off stripping (see Policy).
-if (get_buildoption('nostrip')) {
-	exit;
-}
+exit 0 if (get_buildoption('nostrip'));
 
 my $objcopy = cross_command("objcopy");
 my $strip = cross_command("strip");
@@ -273,15 +265,13 @@ sub make_debug {
 		my ($base_file)=$file=~/^\Q$tmp\E(.*)/;
 		$debug_path=$desttmp."/usr/lib/debug/".$base_file;
 	}
-	my $debug_dir=dirname($debug_path);
-	install_dir($debug_dir);
+	install_dir(dirname($debug_path));
 	if (compat(8) && $use_build_id < 2) {
 		doit($objcopy, "--only-keep-debug", $file, $debug_path);
 	}
 	else {
 		# Compat 9 OR a dbgsym package.
-		doit($objcopy, "--only-keep-debug", "--compress-debug-sections", $file, $debug_path)
-			unless -e $debug_path;
+		doit($objcopy, "--only-keep-debug", "--compress-debug-sections", $file, $debug_path) unless -e $debug_path;
 	}
 
 	# No reason for this to be executable.
@@ -290,8 +280,7 @@ sub make_debug {
 }
 
 sub attach_debug {
-	my $file=shift;
-	my $debug_path=shift;
+	my ($file, $debug_path) = @_;
 	doit($objcopy, "--add-gnu-debuglink", $debug_path, $file);
 }
 
@@ -308,9 +297,7 @@ sub process_packages {
 		if ($dh{DEBUGPACKAGE}) {
 			$keep_debug=1;
 			my $debugpackage=$dh{DEBUGPACKAGE};
-			if (!$all_packages{$debugpackage}) {
-				error("debug package $debugpackage is not listed in the control file");
-			}
+			error("debug package $debugpackage is not listed in the control file") if (!$all_packages{$debugpackage});
 			$debugtmp=tmpdir($debugpackage);
 		}
 		# Temporary workaround: Do not build dbgsym packages for udebs as
@@ -335,15 +322,13 @@ sub process_packages {
 			my $debug_path = make_debug($_, $tmp, $debugtmp, $use_build_id) if $keep_debug;
 			# Note that all calls to strip on shared libs
 			# *must* include the --strip-unneeded.
-			doit($strip,"--remove-section=.comment",
-				"--remove-section=.note","--strip-unneeded",$_);
+			doit($strip, "--remove-section=.comment", "--remove-section=.note", "--strip-unneeded", $_);
 			attach_debug($_, $debug_path) if defined $debug_path;
 		}
 
 		foreach (@executables) {
 			my $debug_path = make_debug($_, $tmp, $debugtmp, $use_build_id) if $keep_debug;
-			doit($strip,"--remove-section=.comment",
-				"--remove-section=.note",$_);
+			doit($strip, "--remove-section=.comment", "--remove-section=.note", $_);
 			attach_debug($_, $debug_path) if defined $debug_path;
 		}
 
@@ -385,8 +370,7 @@ sub process_packages {
 			if ($use_build_id > 1) {
 				$dir = "debian/.debhelper/${package}";
 			} else {
-				my $dbg_pkg = $dh{DEBUGPACKAGE};
-				$dir = "debian/.debhelper/${dbg_pkg}";
+				$dir = "debian/.debhelper/$dh{DEBUGPACKAGE}";
 			}
 			$path = "${dir}/dbgsym-build-ids";
 			install_dir($dir);

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