[Pkg-voip-commits] r10517 - in /yate/trunk/debian: changelog dh/ dh/dh_shlibdeps dh/dh_strip rules

tzafrir at alioth.debian.org tzafrir at alioth.debian.org
Fri Jul 25 14:57:03 UTC 2014


Author: tzafrir
Date: Fri Jul 25 14:57:03 2014
New Revision: 10517

URL: http://svn.debian.org/wsvn/pkg-voip/?sc=1&rev=10517
Log:
Use private copies of dh_strip and dh_shlipdeps (See #35733).

Added:
    yate/trunk/debian/dh/
    yate/trunk/debian/dh/dh_shlibdeps   (with props)
    yate/trunk/debian/dh/dh_strip   (with props)
Modified:
    yate/trunk/debian/changelog
    yate/trunk/debian/rules

Modified: yate/trunk/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-voip/yate/trunk/debian/changelog?rev=10517&op=diff
==============================================================================
--- yate/trunk/debian/changelog	(original)
+++ yate/trunk/debian/changelog	Fri Jul 25 14:57:03 2014
@@ -4,6 +4,7 @@
     (Closes: #750272).
   * Upstream patch to remove exec bit from modules (Closes: #714771).
   * yate-dev: Add missing dependency yate-qt4 (Closes: #715135).
+  * Use private copies of dh_strip and dh_shlipdeps (See #35733).
 
  -- Tzafrir Cohen <tzafrir at debian.org>  Fri, 25 Jul 2014 09:43:02 +0300
 

Added: yate/trunk/debian/dh/dh_shlibdeps
URL: http://svn.debian.org/wsvn/pkg-voip/yate/trunk/debian/dh/dh_shlibdeps?rev=10517&op=file
==============================================================================
--- yate/trunk/debian/dh/dh_shlibdeps	(added)
+++ yate/trunk/debian/dh/dh_shlibdeps	Fri Jul 25 14:57:03 2014
@@ -0,0 +1,178 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+dh_shlibdeps - calculate shared library dependencies
+
+=cut
+
+use strict;
+use Cwd;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_shlibdeps> [S<I<debhelper options>>] [B<-L>I<package>] [B<-l>I<directory>] [B<-X>I<item>] [S<B<--> I<params>>]
+
+=head1 DESCRIPTION
+
+B<dh_shlibdeps> is a debhelper program that is responsible for calculating
+shared library dependencies for packages.
+
+This program is merely a wrapper around L<dpkg-shlibdeps(1)> that calls it
+once for each package listed in the F<control> file, passing it
+a list of ELF executables and shared libraries it has found.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-X>I<item>, B<--exclude=>I<item>
+
+Exclude files that contain F<item> anywhere in their filename from being
+passed to B<dpkg-shlibdeps>. This will make their dependencies be ignored.
+This may be useful in some situations, but use it with caution. This option
+may be used more than once to exclude more than one thing.
+
+=item B<--> I<params>
+
+Pass I<params> to L<dpkg-shlibdeps(1)>.
+
+=item B<-u>I<params>, B<--dpkg-shlibdeps-params=>I<params>
+
+This is another way to pass I<params> to L<dpkg-shlibdeps(1)>.
+It is deprecated; use B<--> instead.
+
+=item B<-l>I<directory>[B<:>I<directory> ...]
+
+With recent versions of B<dpkg-shlibdeps>, this option is generally not
+needed.
+
+It tells B<dpkg-shlibdeps> (via its B<-l> parameter), to look for private
+package libraries in the specified directory (or directories -- separate
+with colons). With recent
+versions of B<dpkg-shlibdeps>, this is mostly only useful for packages that
+build multiple flavors of the same library, or other situations where
+the library is installed into a directory not on the regular library search
+path.
+
+=item B<-L>I<package>, B<--libpackage=>I<package>
+
+With recent versions of B<dpkg-shlibdeps>, this option is generally not
+needed, unless your package builds multiple flavors of the same library.
+
+It tells B<dpkg-shlibdeps> (via its B<-S> parameter) to look first in the package
+build directory for the specified package, when searching for libraries,
+symbol files, and shlibs files.
+
+=item B<--add-exten>=>I<extension>
+
+An extra file extension of symbols to look into. By default dh_shlibdeps
+will only check files with the pattern *.so* and files that end with
+.cmxs (OCaml native code shared libraries). However your package may
+have libraries or plugins with a different extension. To add all *.foo
+files, use parameter F<foo>.
+
+=back
+
+=head1 EXAMPLES
+
+Suppose that your source package produces libfoo1, libfoo-dev, and
+libfoo-bin binary packages. libfoo-bin links against libfoo1, and should
+depend on it. In your rules file, first run B<dh_makeshlibs>, then B<dh_shlibdeps>:
+
+	dh_makeshlibs
+	dh_shlibdeps
+
+This will have the effect of generating automatically a shlibs file for
+libfoo1, and using that file and the libfoo1 library in the
+F<debian/libfoo1/usr/lib> directory to calculate shared library dependency
+information.
+
+If a libbar1 package is also produced, that is an alternate build of
+libfoo, and is installed into F</usr/lib/bar/>, you can make libfoo-bin depend
+on libbar1 as follows:
+
+	dh_shlibdeps -Llibbar1 -l/usr/lib/bar
+	
+=cut
+
+init(options => {
+	"L|libpackage=s" => \$dh{LIBPACKAGE},
+	"dpkg-shlibdeps-params=s", => \$dh{U_PARAMS},
+	"l=s", => \$dh{L_PARAMS},
+	"add-exten=s" => \$dh{ADD_EXTEN},
+});
+
+if (defined $dh{V_FLAG}) {
+	warning("You probably wanted to pass -V to dh_makeshlibs, it has no effect on dh_shlibdeps");
+}
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+	my $tmp=tmpdir($package);
+	my $ext=pkgext($package);
+
+	# dpkg-shlibdeps expects this directory to exist
+	if (! -d "$tmp/DEBIAN") {
+		doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
+	}
+
+	my @filelist;
+	my $ff;
+
+	# Generate a list of ELF binaries in the package, ignoring any
+	# we were told to exclude.
+	my $find_options='';
+	if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
+		$find_options="! \\( $dh{EXCLUDE_FIND} \\)";
+	}
+
+	my @find_types = qw/so* cmxs/;
+	if (exists $dh{ADD_EXTEN}) {
+		push @find_types, $dh{ADD_EXTEN};
+	}
+	my $types_str = join '', map {" -or -name \"*.$_\""} @find_types;
+
+	foreach my $file (split(/\n/,`find $tmp -type f \\( -perm /111 $types_str \\) $find_options -print`)) {
+		# Prune directories that contain separated debug symbols.
+		next if $file=~m!^\Q$tmp\E/usr/lib/debug/(lib|lib64|usr|bin|sbin|opt|dev|emul)/!;
+		# TODO this is slow, optimize. Ie, file can run once on
+		# multiple files..
+		$ff=`file "$file"`;
+		if ($ff=~m/ELF/ && $ff!~/statically linked/) {
+			push @filelist,$file;
+		}
+	}
+
+	if (@filelist) {
+		my @opts;
+		if (defined $dh{LIBPACKAGE} && length $dh{LIBPACKAGE}) {
+			@opts=("-S".tmpdir($dh{LIBPACKAGE}));
+		}
+		
+		push @opts, "-tudeb" if is_udeb($package);
+		
+		if ($dh{L_PARAMS}) {
+			foreach (split(/:/, $dh{L_PARAMS})) {
+				# Force the path absolute.
+				my $libdir = m:^/: ? $_ : "/$_";
+				push @opts, "-l$libdir";
+			}
+		}
+		
+		doit("dpkg-shlibdeps","-Tdebian/${ext}substvars",
+			@opts,@{$dh{U_PARAMS}}, at filelist);
+	}
+}
+
+=head1 SEE ALSO
+
+L<debhelper(7)>, L<dpkg-shlibdeps(1)>
+
+This program is a part of debhelper.
+
+=head1 AUTHOR
+
+Joey Hess <joeyh at debian.org>
+
+=cut

Propchange: yate/trunk/debian/dh/dh_shlibdeps
------------------------------------------------------------------------------
    svn:executable = *

Added: yate/trunk/debian/dh/dh_strip
URL: http://svn.debian.org/wsvn/pkg-voip/yate/trunk/debian/dh/dh_strip?rev=10517&op=file
==============================================================================
--- yate/trunk/debian/dh/dh_strip	(added)
+++ yate/trunk/debian/dh/dh_strip	Fri Jul 25 14:57:03 2014
@@ -0,0 +1,271 @@
+#!/usr/bin/perl -w
+
+=head1 NAME
+
+dh_strip - strip executables, shared libraries, and some static libraries
+
+=cut
+
+use strict;
+use File::Find;
+use Debian::Debhelper::Dh_Lib;
+
+=head1 SYNOPSIS
+
+B<dh_strip> [S<I<debhelper options>>] [B<-X>I<item>] [B<--dbg-package=>I<package>] [B<--keep-debug>]
+
+=head1 DESCRIPTION
+
+B<dh_strip> is a debhelper program that is responsible for stripping
+executables, shared libraries, and static libraries that are not used for
+debugging.
+
+This program examines your package build directories and works out what
+to strip on its own. It uses L<file(1)> and file permissions and filenames
+to figure out what files are shared libraries (F<*.so>), executable binaries,
+and static (F<lib*.a>) and debugging libraries (F<lib*_g.a>, F<debug/*.so>), and
+strips each as much as is possible. (Which is not at all for debugging
+libraries.) In general it seems to make very good guesses, and will do the
+right thing in almost all cases.
+
+Since it is very hard to automatically guess if a file is a
+module, and hard to determine how to strip a module, B<dh_strip> does not
+currently deal with stripping binary modules such as F<.o> files.
+
+=head1 OPTIONS
+
+=over 4
+
+=item B<-X>I<item>, B<--exclude=>I<item>
+
+Exclude files that contain I<item> anywhere in their filename from being
+stripped. You may use this option multiple times to build up a list of
+things to exclude.
+
+=item B<--dbg-package=>I<package>
+
+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.
+
+For example, if your packages are libfoo and foo and you want to include a
+I<foo-dbg> package with debugging symbols, use B<dh_strip --dbg-package=>I<foo-dbg>.
+
+Note that this option behaves significantly different in debhelper
+compatibility levels 4 and below. Instead of specifying the name of a debug
+package to put symbols in, it specifies a package (or packages) which
+should have separated debug symbols, and the separated symbols are placed
+in packages with B<-dbg> added to their name.
+
+=item B<-k>, B<--keep-debug>
+
+Debug symbols will be retained, but split into an independent
+file in F<usr/lib/debug/> in the package build directory. B<--dbg-package>
+is easier to use than this option, but this option is more flexible.
+
+=item B<--add-exten>=>I<extension>
+
+An extra file extension of symbols to strip. By default dh_strip will only
+strip files with the pattern *.so* and files that end with .cmxs (OCaml
+native code shared libraries). However your package may have libraries
+or plugins with a different extension. To add all *.foo files, use
+parameter F<foo>.
+
+=back
+
+=head1 NOTES
+
+If the B<DEB_BUILD_OPTIONS> environment variable contains B<nostrip>, nothing
+will be stripped, in accordance with Debian policy (section 10.1
+"Binaries").
+
+=head1 CONFORMS TO
+
+Debian policy, version 3.0.1
+
+=cut
+
+init(options => {
+	"keep-debug" => \$dh{K_FLAG},
+	"add-exten=s" => \$dh{ADD_EXTEN},
+});
+
+# This variable can be used to turn off stripping (see Policy).
+if (get_buildoption('nostrip')) {
+	exit;
+}
+
+my $objcopy = cross_command("objcopy");
+my $strip = cross_command("strip");
+
+# I could just use `file $_[0]`, but this is safer
+sub get_file_type {
+	my $file=shift;
+	open (FILE, '-|') # handle all filenames safely
+		|| exec('file', $file)
+		|| die "can't exec file: $!";
+	my $type=<FILE>;
+	close FILE;
+	return $type;
+}
+
+sub get_extens_regex() {
+	my @extens = qw/so.*? cmxs$/;
+	if (exists $dh{ADD_EXTEN}) {
+		push(@extens, "$dh{ADD_EXTEN}\$");
+	}
+	my $regex = ".*\.(". join('|', @extens) . ")";
+	return qr/$regex/;
+}
+
+my $extens_regex = get_extens_regex();
+
+# Check if a file is an elf binary, shared library, or static library,
+# for use by File::Find. It'll fill the following 3 arrays with anything
+# it finds:
+my (@shared_libs, @executables, @static_libs);
+sub testfile {
+	return if -l $_ or -d $_; # Skip directories and symlinks always.
+	
+	# See if we were asked to exclude this file.
+	# Note that we have to test on the full filename, including directory.
+	my $fn="$File::Find::dir/$_";
+	foreach my $f (@{$dh{EXCLUDE}}) {
+		return if ($fn=~m/\Q$f\E/);
+	}
+
+	# Is it a debug library in a debug subdir?
+	return if $fn=~m/debug\/.*\.so/;
+
+	# Does its filename look like a shared library?
+	if (m/$extens_regex/) {
+		# Ok, do the expensive test.
+		my $type=get_file_type($_);
+		if ($type=~m/.*ELF.*shared.*/) {
+			push @shared_libs, $fn;
+			return;
+		}
+	}
+	
+	# Is it executable? -x isn't good enough, so we need to use stat.
+	my (undef,undef,$mode,undef)=stat(_);
+	if ($mode & 0111) {
+		# Ok, expensive test.
+		my $type=get_file_type($_);
+		if ($type=~m/.*ELF.*(executable|shared).*/) {
+			push @executables, $fn;
+			return;
+		}
+	}
+	
+	# Is it a static library, and not a debug library?
+	if (m/lib.*\.a$/ && ! m/.*_g\.a$/) {
+		# Is it a binary file, or something else (maybe a liner
+		# script on Hurd, for example? I don't use file, because
+		# file returns a variety of things on static libraries.
+		if (-B $_) {
+			push @static_libs, $fn;
+			return;
+		}
+	}
+}
+
+sub make_debug {
+	my $file=shift;
+	my $tmp=shift;
+	my $desttmp=shift;
+	
+	# Don't try to copy debug symbols out if the file is already
+	# stripped.
+	return unless get_file_type($file) =~ /not stripped/;
+
+	my ($base_file)=$file=~/^\Q$tmp\E(.*)/;
+	my $debug_path;
+	if (! compat(8) && 
+	    `LC_ALL=C readelf -n $file`=~ /^\s+Build ID: ([0-9a-f]{2})([0-9a-f]+)$/m) {
+		$debug_path=$desttmp."/usr/lib/debug/.build-id/$1/$2.debug"
+	}
+	else {
+		$debug_path=$desttmp."/usr/lib/debug/".$base_file;
+	}
+	my $debug_dir=dirname($debug_path);
+	if (! -d $debug_dir) {
+		doit("install", "-d", $debug_dir);
+	}
+	if (compat(8)) {
+		doit($objcopy, "--only-keep-debug", $file, $debug_path);
+	}
+	else {
+		doit($objcopy, "--only-keep-debug", "--compress-debug-sections", $file, $debug_path);
+	}
+	# No reason for this to be executable.
+	doit("chmod", 644, $debug_path);
+	return $debug_path;
+}
+
+sub attach_debug {
+	my $file=shift;
+	my $debug_path=shift;
+	doit($objcopy, "--add-gnu-debuglink", $debug_path, $file);
+}
+
+foreach my $package (@{$dh{DOPACKAGES}}) {
+	my $tmp=tmpdir($package);
+
+	# Support for keeping the debugging symbols in a detached file.
+	my $keep_debug=$dh{K_FLAG};
+	my $debugtmp=$tmp;
+	if (! compat(4)) {
+		if (ref $dh{DEBUGPACKAGES}) {
+			$keep_debug=1;
+			# Note that it's only an array for the v4 stuff;
+			# for v5 only one value is used.
+			my $debugpackage=@{$dh{DEBUGPACKAGES}}[0];
+			if (! grep { $_ eq $debugpackage } getpackages()) {
+				error("debug package $debugpackage is not listed in the control file");
+			}
+			$debugtmp=tmpdir($debugpackage);
+		}
+	}
+	else {
+		if (ref $dh{DEBUGPACKAGES} && grep { $_ eq $package } @{$dh{DEBUGPACKAGES}}) {
+			$keep_debug=1;
+			$debugtmp=tmpdir($package."-dbg");
+		}
+	}
+	
+	@shared_libs=@executables=@static_libs=();
+	find(\&testfile,$tmp);
+
+	foreach (@shared_libs) {
+		my $debug_path = make_debug($_, $tmp, $debugtmp) 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",$_);
+		attach_debug($_, $debug_path) if defined $debug_path;
+	}
+	
+	foreach (@executables) {
+		my $debug_path = make_debug($_, $tmp, $debugtmp) if $keep_debug;
+		doit($strip,"--remove-section=.comment",
+			"--remove-section=.note",$_);
+ 		attach_debug($_, $debug_path) if defined $debug_path;
+	}
+
+	foreach (@static_libs) {
+		doit($strip,"--strip-debug",$_);
+	}
+}
+
+=head1 SEE ALSO
+
+L<debhelper(7)>
+
+This program is a part of debhelper.
+
+=head1 AUTHOR
+
+Joey Hess <joeyh at debian.org>
+
+=cut

Propchange: yate/trunk/debian/dh/dh_strip
------------------------------------------------------------------------------
    svn:executable = *

Modified: yate/trunk/debian/rules
URL: http://svn.debian.org/wsvn/pkg-voip/yate/trunk/debian/rules?rev=10517&op=diff
==============================================================================
--- yate/trunk/debian/rules	(original)
+++ yate/trunk/debian/rules	Fri Jul 25 14:57:03 2014
@@ -30,6 +30,14 @@
 override_dh_install:
 	dh_install -XCOPYING -XChangeLog -Xamrnbcodec.conf -Xh323chan.conf --fail-missing
 
+override_dh_strip:
+	# A copy that fixes #35733:
+	debian/dh/dh_strip --add-exten yate
+
+override_dh_shlibdeps:
+	# A copy that fixes #35733:
+	debian/dh/dh_shlibdeps --add-exten yate
+
 get-orig-source:
 	@@dh_testdir
 	@@[ -d ../tarballs/. ]||mkdir -p ../tarballs




More information about the Pkg-voip-commits mailing list