[debhelper-devel] Bug#820446: dh_strip: only match lib*.a static libraries

Peter Pentchev roam at ringlet.net
Fri Apr 8 14:51:19 UTC 2016


Package: debhelper
Version: 9.20160403
Severity: normal
Tags: patch

Hi,

Thanks for maintaining debhelper!

What do you think about the attached patch that makes dh_strip only
match static libraries with "lib" at the start of the filename, not
just anywhere in there?  It makes dh_strip's behavior consistent when
a Debian package ships *.a files with weird names, like e.g. gforth's
/usr/lib/*/gforth/0.7.2/cstr.a and /usr/lib/*/gforth/0.7.2./fflib.a -
the first one is not stripped, but the second one is :) [1]

On an unrelated note, the second patch is a bit of clean-up for regular
expressions that start with /.*/ and are not anchored (don't start with
/^.*/) - this is pretty much a no-op and, in the worst case, may make
the Perl virtual machine handle the regexp a bit inefficiently.  Well,
I do believe that the regexp compiler is smart enough to drop the ".*"
at the start anyway, but there's no need to make it do even that much :)

Thanks again for taking care of debhelper, and keep up the great work!

G'luck,
Peter

[1] Yes, with this patch neither one will be stripped, but in this case
this is not really a problem - these are dynamically generated (compiled
from dynamically generated *.c files) helpers for loading native system
libraries, and we don't care about debug symbols for them.  Moreover,
stripping the ones shipped with GForth would lead to an inconsistency
when the user later generates new ones that shall not be stripped; not
that anyone would ever notice, but oh well :)


-- System Information:
Debian Release: stretch/sid
  APT prefers oldoldstable
  APT policy: (500, 'oldoldstable'), (500, 'testing')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 4.4.0-1-amd64 (SMP w/4 CPU cores)
Locale: LANG=bg_BG.UTF-8, LC_CTYPE=bg_BG.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Init: systemd (via /run/systemd/system)

Versions of packages debhelper depends on:
ii  autotools-dev            20150820.1
ii  binutils                 2.26-8
ii  dh-autoreconf            12
ii  dh-strip-nondeterminism  0.016-1
ii  dpkg                     1.18.4
ii  dpkg-dev                 1.18.4
ii  file                     1:5.25-2
ii  libdpkg-perl             1.18.4
ii  man-db                   2.7.5-1
ii  perl                     5.22.1-9
ii  po-debconf               1.0.19

debhelper recommends no packages.

Versions of packages debhelper suggests:
ii  dh-make  2.201605

-- no debconf information
-------------- next part --------------
From 63b79a7d50ed3e89de4b093b44da25ba899d86e1 Mon Sep 17 00:00:00 2001
From: Peter Pentchev <roam at ringlet.net>
Date: Fri, 8 Apr 2016 17:31:13 +0300
Subject: [PATCH 1/2] dh_strip: Only match *.a files that start with "lib"

---
 dh_strip | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/dh_strip b/dh_strip
index 752176e..a7206db 100755
--- a/dh_strip
+++ b/dh_strip
@@ -230,7 +230,7 @@ sub testfile {
 	}
 	
 	# Is it a static library, and not a debug library?
-	if (m/lib.*\.a$/ && ! m/.*_g\.a$/) {
+	if (m/\/lib[^\/]*\.a$/ && ! m/.*_g\.a$/) {
 		# Is it a binary file, or something else (maybe a linker
 		# script on Hurd, for example? I don't use file, because
 		# file returns a variety of things on static libraries.
-- 
2.8.0.rc3

-------------- next part --------------
From 3aa558d06a82b2c86dafaf9efac88e6f786d3e86 Mon Sep 17 00:00:00 2001
From: Peter Pentchev <roam at ringlet.net>
Date: Fri, 8 Apr 2016 17:42:25 +0300
Subject: [PATCH 2/2] Drop .* from the beginning of unanchored regular
 expressions

---
 Debian/Debhelper/Dh_Lib.pm | 2 +-
 dh_installman              | 4 ++--
 dh_installmanpages         | 4 ++--
 dh_strip                   | 6 +++---
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm
index bc2bd43..2f028d3 100644
--- a/Debian/Debhelper/Dh_Lib.pm
+++ b/Debian/Debhelper/Dh_Lib.pm
@@ -567,7 +567,7 @@ sub pkgfilename {
 		}
 
 		# Is this a native Debian package?
-		if ($dh{VERSION}=~m/.*-/) {
+		if ($dh{VERSION}=~m/-/) {
 			return $isnative_cache{$package}=0;
 		}
 		else {
diff --git a/dh_installman b/dh_installman
index 46b0366..826eeae 100755
--- a/dh_installman
+++ b/dh_installman
@@ -140,7 +140,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		close(IN);
 		# Failing that, we can try to get it from the filename.
 		if (! $section) {
-			($section)=$basename=~m/.*\.([1-9]\S*)/;
+			($section)=$basename=~m/\.([1-9]\S*)/;
 		}
 
 		# Now get the numeric component of the section.
@@ -158,7 +158,7 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 			# Translated man pages are typically specified by adding the
 			# language code to the filename, so detect that and
 			# redirect to appropriate directory, stripping the code.
-			($langcode)=$basename=~m/.*\.([a-z][a-z](?:_[A-Z][A-Z])?)\.(?:[1-9]|man)/;
+			($langcode)=$basename=~m/\.([a-z][a-z](?:_[A-Z][A-Z])?)\.(?:[1-9]|man)/;
 		}
 		elsif ($dh{LANGUAGE} ne 'C') {
 			$langcode=$dh{LANGUAGE};
diff --git a/dh_installmanpages b/dh_installmanpages
index d393500..e58415a 100755
--- a/dh_installmanpages
+++ b/dh_installmanpages
@@ -158,13 +158,13 @@ foreach my $package (@{$dh{DOPACKAGES}}) {
 		if ($install) {
 			my $extdir="share";
 			
-			my ($section)=$basename=~m/.*\.([1-9])/;
+			my ($section)=$basename=~m/\.([1-9])/;
 			
 			my $destdir="$tmp/usr/$extdir/man/man$section/";
 			
 			# Handle translated man pages.
 			my $instname=$basename;
-			my ($langcode)=$basename=~m/.*\.([a-z][a-z])\.([1-9])/;
+			my ($langcode)=$basename=~m/\.([a-z][a-z])\.([1-9])/;
 			if (defined $langcode && $langcode ne '') {
 				$destdir="$tmp/usr/$extdir/man/$langcode/man$section/";
 				$instname=~s/\.$langcode\./\./;
diff --git a/dh_strip b/dh_strip
index a7206db..fb5d74b 100755
--- a/dh_strip
+++ b/dh_strip
@@ -209,10 +209,10 @@ sub testfile {
 	# Does its filename look like a shared library?
 	#  - *.cmxs are OCaml native code shared libraries
 	#  - *.node are also native ELF binaries (for node-js)
-	if (m/.*\.(?:so.*?|cmxs|node)$/) {
+	if (m/\.(?:so.*?|cmxs|node)$/) {
 		# Ok, do the expensive test.
 		my $type=get_file_type($_);
-		if ($type=~m/.*ELF.*shared.*/) {
+		if ($type=~m/ELF.*shared.*/) {
 			push @shared_libs, $fn;
 			return;
 		}
@@ -223,7 +223,7 @@ sub testfile {
 	if ($mode & 0111) {
 		# Ok, expensive test.
 		my $type=get_file_type($_);
-		if ($type=~m/.*ELF.*(executable|shared).*/) {
+		if ($type=~m/ELF.*(executable|shared).*/) {
 			push @executables, $fn;
 			return;
 		}
-- 
2.8.0.rc3

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/debhelper-devel/attachments/20160408/f9d7d445/attachment-0001.sig>


More information about the debhelper-devel mailing list