diff options
author | Niels Thykier <niels@thykier.net> | 2017-09-14 16:54:38 +0000 |
---|---|---|
committer | Niels Thykier <niels@thykier.net> | 2017-09-14 18:43:07 +0000 |
commit | 37df80c3d69da0890ffbd22f722df363c4846832 (patch) | |
tree | b571f25eade12beeb0feac1a1898f7ac0006781d /dh_strip | |
parent | 82926e603385057c20456408d2dbe7796040a180 (diff) | |
download | debhelper-37df80c3d69da0890ffbd22f722df363c4846832.tar.gz |
dh_strip: Refactor to reduce code size
Signed-off-by: Niels Thykier <niels@thykier.net>
Diffstat (limited to 'dh_strip')
-rwxr-xr-x | dh_strip | 44 |
1 files changed, 14 insertions, 30 deletions
@@ -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); |