From 67b74298f08a3e2b30e43cbcd7cdaccc2e1b1614 Mon Sep 17 00:00:00 2001 From: joey Date: Thu, 2 Mar 2000 21:23:22 +0000 Subject: [PATCH] r338: * Patch from Jorgen `forcer' Schaefer (much modified)to make dh_installwm use new window manager registration method, update-alternatives. Closes: #52156, #34684 (latter bug is obsolete) * Fixed $dh{flavor} to be upper-case. * Deprecated dh_installemavcsen --number; use --priority instead. Also, the option parser requires the parameter be a number now. And, dh_installwm now accepts --priority, and window manager packages should start using it. * dh_installwm now behaves like a proper debhelper command, and reads debian/.wm too. This is a small behavior change; filenames specified on the command line no longer apply to all packages it acts on. I can't belive this program existed for 2 years with such a glaring problem; I guess most people don't need ot register 5 wm's in 3 sub-packages. Anyway, it can handle such things now. :-) * Moved Dh_*.pm to /usr/lib/perl5/Debian/Debhelper. *big* change. --- autoscripts/postinst-wm | 5 +- autoscripts/postrm-wm | 5 +- debian/changelog | 22 +++++++- debian/fixlinks | 2 - debian/rules | 17 +++--- dh_builddeb | 3 +- dh_clean | 53 ++++++++++++++---- dh_compress | 3 +- dh_debstd | 7 ++- dh_du | 19 ++----- dh_fixperms | 3 +- dh_gencontrol | 35 +++++++----- dh_installchangelogs | 5 +- dh_installcron | 39 ++++++++------ dh_installdeb | 3 +- dh_installdebconf | 3 +- dh_installdirs | 62 ++++++++++----------- dh_installdocs | 3 +- dh_installemacsen | 69 +++++++++++++++--------- dh_installemacsen.1 | 4 +- dh_installexamples | 3 +- dh_installinfo | 5 +- dh_installinit | 117 ++++++++++++++++++++++------------------ dh_installmanpages | 11 ++-- dh_installmenu | 54 +++++++++++++------ dh_installmime | 5 +- dh_installmodules | 5 +- dh_installpam | 3 +- dh_installwm | 33 +++++++++--- dh_installwm.1 | 30 +++++++---- dh_installxaw | 3 +- dh_installxfonts | 3 +- dh_link | 27 +++++----- dh_listpackages | 4 +- dh_makeshlibs | 3 +- dh_md5sums | 57 ++++++++++++++------ dh_movefiles | 3 +- dh_perl | 54 ++++++++++++++----- dh_shlibdeps | 3 +- dh_strip | 90 ++++++++++++++++++++++--------- dh_suidregister | 3 +- dh_testdir | 16 +++--- dh_testroot | 3 +- dh_testversion | 9 ++-- dh_undocumented | 3 +- doc/PROGRAMMING | 23 ++++---- doc/README | 2 +- doc/TODO | 3 ++ doc/v2 | 1 + 49 files changed, 577 insertions(+), 361 deletions(-) diff --git a/autoscripts/postinst-wm b/autoscripts/postinst-wm index 94c052f..794ad70 100644 --- a/autoscripts/postinst-wm +++ b/autoscripts/postinst-wm @@ -1,3 +1,2 @@ -if [ -x /usr/sbin/register-window-manager ] ; then - register-window-manager --add #WM# -fi +update-alternatives --install /usr/bin/x-window-manager \ + x-window-manager #WM# #PRIORITY# diff --git a/autoscripts/postrm-wm b/autoscripts/postrm-wm index 6dc9f5d..c4670b9 100644 --- a/autoscripts/postrm-wm +++ b/autoscripts/postrm-wm @@ -1,3 +1,2 @@ -if [ "$1" == "purge" -a -x /usr/sbin/register-window-manager ] ; then - register-window-manager --remove #WM# -fi +update-alternatives --remove x-window-manager #WM# + diff --git a/debian/changelog b/debian/changelog index 9808971..fc64c04 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,23 @@ +debhelper (2.0.89) unstable; urgency=low + + * Patch from Jorgen `forcer' Schaefer (much + modified)to make dh_installwm use new window manager registration method, + update-alternatives. Closes: #52156, #34684 (latter bug is obsolete) + * Fixed $dh{flavor} to be upper-case. + * Deprecated dh_installemavcsen --number; use --priority instead. Also, + the option parser requires the parameter be a number now. And, + dh_installwm now accepts --priority, and window manager packages should + start using it. + * dh_installwm now behaves like a proper debhelper command, and reads + debian/.wm too. This is a small behavior change; filenames + specified on the command line no longer apply to all packages it acts + on. I can't belive this program existed for 2 years with such a glaring + problem; I guess most people don't need ot register 5 wm's in 3 + sub-packages. Anyway, it can handle such things now. :-) + * Moved Dh_*.pm to /usr/lib/perl5/Debian/Debhelper. *big* change. + + -- Joey Hess Thu, 2 Mar 2000 11:39:56 -0800 + debhelper (2.0.88) unstable; urgency=low * Copyright update: files in the examples directory are public domain. @@ -1328,7 +1348,7 @@ debhelper (1.2.0) unstable; urgency=low perl.. Since 1.1 has actually stabalized, I've upped this to 1.2. * dh_md5sums: rewritten in perl, for large speed gain under some circumstances (old version called perl sometimes, once per package.) - * dh_installmenu, dh_installwmacsen, dh_installwm: perlized. + * dh_installmenu, dh_installemacsen, dh_installwm: perlized. * Dh_Lib.pm: made autoscript() really work. -- Joey Hess Mon, 9 Nov 1998 13:04:16 -0800 diff --git a/debian/fixlinks b/debian/fixlinks index f90bf4d..23d4306 100644 --- a/debian/fixlinks +++ b/debian/fixlinks @@ -1,8 +1,6 @@ #!/bin/sh -e # Clean up after cvs's dreadful symlink handling, by making all the symlinks # this package needs. -ln -sf ../Dh_Lib.pm debian/Dh_Lib.pm -ln -sf ../Dh_Getopt.pm debian/Dh_Getopt.pm ln -sf postinst-menu autoscripts/postrm-menu ln -sf postinst-modules autoscripts/postrm-modules ln -sf postinst-mime autoscripts/postrm-mime diff --git a/debian/rules b/debian/rules index ccc0a36..da3305e 100755 --- a/debian/rules +++ b/debian/rules @@ -1,11 +1,10 @@ #!/usr/bin/make -f # Note that I have to refer to debhelper programs with ./, to make sure -# I run the most current ones. That's also why there is a symlink to the -# current Dh_lib.pm and the current Dh_getopt.pm in this debian/ directory. +# I run the most current ones. # # This is _not_ a good example of a debhelper rules file, but I didn't need -# to tell you that; just see the 25 lines of inlined perl below.. See -# examples/ for some good examples. +# to tell you that; just see the 25 lines of inlined perl below.. +# See examples/ for some good examples. # If any automatic script generation is done in building this package, # be sure to use the new templates from this package. @@ -41,12 +40,15 @@ binary-indep: link-stamp build ./dh_testdir ./dh_testroot ./dh_clean -k - ./dh_installdirs usr/bin usr/share/debhelper + ./dh_installdirs usr/bin usr/share/debhelper \ + usr/lib/perl5/Debian/Debhelper - echo -e "package Dh_Version;\n\$$version='$(VERSION)';" > debian/debhelper/usr/share/debhelper/Dh_Version.pm + echo -e "package Dh_Version;\n\$$version='$(VERSION)';" > \ + debian/debhelper/usr/lib/perl5/Debian/Debhelper/Dh_Version.pm find . -perm +111 -maxdepth 1 -type f -not -name "*.pl" \ -exec install -p {} debian/debhelper/usr/bin \; - cp -a Dh_*.pm debian/debhelper/usr/share/debhelper + cp -a Debian/Debhelper/*.pm \ + debian/debhelper/usr/lib/perl5/Debian/Debhelper/ cp -a autoscripts debian/debhelper/usr/share/debhelper rm -rf debian/debhelper/usr/share/debhelper/autoscripts/CVS @@ -111,3 +113,4 @@ installhook: binary: binary-indep binary-arch .PHONY: build clean binary-indep binary-arch binary dist + diff --git a/dh_builddeb b/dh_builddeb index 0822f50..1082dd2 100755 --- a/dh_builddeb +++ b/dh_builddeb @@ -2,8 +2,7 @@ # # Build the .deb package, assuming all the files are set up. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); # Set the default destination directory. diff --git a/dh_clean b/dh_clean index da2c4b2..1f73bea 100755 --- a/dh_clean +++ b/dh_clean @@ -1,16 +1,47 @@ -#!/bin/sh -e +#!/usr/bin/perl -w # -# Clean up debian/tmp and other teporary files generated by the +# Clean up $TMP and other tepmorary files generated by the # build process. -PATH=debian:$PATH:/usr/lib/debhelper -source dh_lib +use Debian::Debhelper::Dh_Lib; +init(); -doit "rm -rf debian/tmp" -doit "rm -f debian/substvars debian/*.substvars debian/files*" +foreach $PACKAGE (@{$dh{DOPACKAGES}}) { + $TMP=tmpdir($PACKAGE); + $EXT=pkgext($PACKAGE); + + if (! $dh{D_FLAG}) { + doit("rm","-f","debian/$EXT\substvars", + "debian/$EXT\postinst.debhelper", + "debian/$EXT\postrm.debhelper", + "debian/$EXT\preinst.debhelper", + "debian/$EXT\prerm.debhelper"); + } + + doit ("rm","-rf",$TMP); +} + +if (! $dh{D_FLAG}) { + if (@ARGV) { + doit("rm","-f","--",@ARGV); + } + + if (! $dh{K_FLAG}) { + doit("rm","-f","debian/files"); + } + + # Remove other temp files. + # (The \s+ is important, \s won't work because find would get null + # parameters). Note that you _don't_ quote wildcards used by find + # in here. + doit(split(/\s+/,"find . -type f -a + ( -name #*# -o -name *~ -o -name DEADJOE + -o -name *.orig -o -name *.rej -o -name *.bak + -o -name .*.orig -o -name .*.rej -o -name .SUMS + -o -name TAGS -o -name core -o ( -path */.deps/* -a -name *.P ) + ) -exec rm -f {} ;")); +} + +doit('rm', '-rf', 'debian/tmp') + if -x 'debian/tmp' && ! Debian::Debhelper::Dh_Lib::compat(1); -# Remove other temp files. I don't run this through doit becuase -# I haven't figured out what I have to esacape to put it in quotes. -# However, it doesn't modify debian/tmp, so I guess it's ok to not run it -# through doit. -find . \( -name "\#*\#" -o -name "*~" -o -name "DEADJOE" \) -exec rm -f {} \; diff --git a/dh_compress b/dh_compress index e3c6e0b..015a1ab 100755 --- a/dh_compress +++ b/dh_compress @@ -4,8 +4,7 @@ # compressed files get fixed. use Cwd; -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_debstd b/dh_debstd index 12e99ff..5577150 100755 --- a/dh_debstd +++ b/dh_debstd @@ -10,10 +10,12 @@ # This has been gutted and extensively rewritten to function as a debhelper # command by Joey Hess. And then completly rewritten in perl. +use Debian::Debhelper::Dh_Lib; + # Need to stay compatable with debstd, so force use of level 1. $ENV{DH_COMAPT}=1; -# Pre-parse command line before we load Dh_lib, becuase we use a +# Pre-parse command line before we parse the command line, becuase we use a # different style of arguments. @argv=(); foreach (@ARGV) { @@ -37,9 +39,6 @@ foreach (@ARGV) { } } @ARGV=@argv; - -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; init(); # Tolerate old style debstd invocations diff --git a/dh_du b/dh_du index a7ec6f4..d786e49 100755 --- a/dh_du +++ b/dh_du @@ -1,19 +1,10 @@ -#!/bin/sh -e +#!/usr/bin/perl -w # # Generate a DEBIAN/du file, that lists the disk usage of the directories in # the package. +# +# No longer - it was decided these files are a bad idea. -PATH=debian:$PATH:/usr/lib/debhelper -. dh_lib - -for PACKAGE in $DH_DOPACKAGES; do - TMP=`tmpdir $PACKAGE` - - if [ ! -d "debian/$TMP/DEBIAN" ]; then - doit "install -d debian/$TMP/DEBIAN" - fi +use Debian::Debhelper::Dh_Lib; - verbose_echo "du -k debian/$TMP | sed \"s: debian/$TMP/: :\" | grep -v \" DEBIAN$\" | grep -v \" debian/$TMP$\" > debian/$TMP/DEBIAN/du" - du -k debian/$TMP | sed "s: debian/$TMP/: :" | grep -v " DEBIAN$" | grep -v " debian/$TMP$" >debian/$TMP/DEBIAN/du - doit "chown root.root debian/tmp/DEBIAN/du" -done +warning("this program does nothing and is deprecated. Remove it from debian/rules."); diff --git a/dh_fixperms b/dh_fixperms index 98201e9..191f3d0 100755 --- a/dh_fixperms +++ b/dh_fixperms @@ -2,8 +2,7 @@ # # Do some general file permission fixups. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_gencontrol b/dh_gencontrol index e2a4e70..df53a75 100755 --- a/dh_gencontrol +++ b/dh_gencontrol @@ -1,19 +1,30 @@ -#!/bin/sh -e +#!/usr/bin/perl -w # # Generate and install the control file. Simple dpkg-gencontrol wrapper. -PATH=debian:$PATH:/usr/lib/debhelper -. dh_lib +use Debian::Debhelper::Dh_Lib; +init(); -for PACKAGE in $DH_DOPACKAGES; do - TMP=`tmpdir $PACKAGE` - EXT=`pkgext $PACKAGE` +foreach $PACKAGE (@{$dh{DOPACKAGES}}) { + $TMP=tmpdir($PACKAGE); + $EXT=pkgext($PACKAGE); + + $changelog=pkgfile($PACKAGE,'changelog'); + if (! $changelog) { + $changelog='debian/changelog'; + } - if [ ! -d $TMP/DEBIAN ]; then - doit "install -o root -g root -d $TMP/DEBIAN" - fi + if ( ! -d '$TMP/DEBIAN' ) { + doit("install","-o","root","-g","root","-d","$TMP/DEBIAN"); + } # Generate and install control file. - doit "dpkg-gencontrol -p$PACKAGE -Tdebian/${EXT}substvars -P$TMP $DH_U_PARAMS" - doit "chown root.root $TMP/DEBIAN/control" -done + doit("dpkg-gencontrol","-l$changelog","-isp","-p$PACKAGE", + "-Tdebian/$EXT\substvars","-P$TMP",@{$dh{U_PARAMS}}); + + # This chmod is only necessary if the user sets the umask to something odd. + doit("chmod","644","$TMP/DEBIAN/control"); + + doit("chown","root.root","$TMP/DEBIAN/control"); +} + diff --git a/dh_installchangelogs b/dh_installchangelogs index 5325f7b..e653019 100755 --- a/dh_installchangelogs +++ b/dh_installchangelogs @@ -7,8 +7,7 @@ # if so, the debian changelog is just installed as "changelog", and it is an # error to specify an upstream changelog on the command line. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); $upstream=shift; @@ -59,7 +58,7 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) { if ($dh{K_FLAG}) { # Install symlink to original name of the upstream changelog file. # Use basename in case original file was in a subdirectory or something. - doit("ln","-sf",$link_to,"$TMP/usr/share/doc/$PACKAGE/".Dh_Lib::basename($upstream)); + doit("ln","-sf",$link_to,"$TMP/usr/share/doc/$PACKAGE/".Debian::Debhelper::Dh_Lib::basename($upstream)); } } } diff --git a/dh_installcron b/dh_installcron index 7db8cdc..149c3d9 100755 --- a/dh_installcron +++ b/dh_installcron @@ -1,20 +1,27 @@ -#!/bin/sh -e +#!/usr/bin/perl -w # # Install cron scripts into the appropriate places. -PATH=debian:$PATH:/usr/lib/debhelper -source dh_lib +use Debian::Debhelper::Dh_Lib; +init(); -for PACKAGE in $DH_DOPACKAGES; do - TMP=`tmpdir $PACKAGE` - EXT=`pkgext $PACKAGE` - - for type in daily weekly monthly; do - if [ -e debian/${EXT}cron.$type ]; then - if [ ! -d debian/$TMP/etc/cron.$type ]; then - doit "install -o root -g root -d debian/$TMP/etc/cron.$type" - fi - doit "install debian/${EXT}cron.$type debian/$TMP/etc/cron.$type/$PACKAGE" - fi - done -done +foreach $PACKAGE (@{$dh{DOPACKAGES}}) { + $TMP=tmpdir($PACKAGE); + foreach $type (qw{daily weekly monthly}) { + $cron=pkgfile($PACKAGE,"cron.$type"); + if ($cron) { + if (! -d "$TMP/etc/cron.$type") { + doit("install","-o","root","-g","root","-d","$TMP/etc/cron.$type"); + } + doit("install",$cron,"$TMP/etc/cron.$type/$PACKAGE"); + } + } + # Seperate because this needs to be mode 644. + $cron=pkgfile($PACKAGE,"cron.d"); + if ($cron) { + if (! -d "$TMP/etc/cron.d") { + doit("install","-o","root","-g","root","-d","$TMP/etc/cron.d"); + } + doit("install","-m",644,$cron,"$TMP/etc/cron.d/$PACKAGE"); + } +} diff --git a/dh_installdeb b/dh_installdeb index d3eebe7..e0ec36c 100755 --- a/dh_installdeb +++ b/dh_installdeb @@ -2,8 +2,7 @@ # # Install files from debian/ into the package's DEBIAN directory. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_installdebconf b/dh_installdebconf index 489db99..03ac235 100755 --- a/dh_installdebconf +++ b/dh_installdebconf @@ -2,8 +2,7 @@ # # Integration with debconf. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_installdirs b/dh_installdirs index bab883d..1ecf907 100755 --- a/dh_installdirs +++ b/dh_installdirs @@ -1,39 +1,41 @@ -#!/bin/sh -e +#!/usr/bin/perl -w # -# Reads debian/dirs, creates the directories listed there there +# Reads debian/dirs, creates the directories listed there -PATH=debian:$PATH:/usr/lib/debhelper -. dh_lib +use Debian::Debhelper::Dh_Lib; +init(); -for PACKAGE in $DH_DOPACKAGES; do - TMP=`tmpdir $PACKAGE` - EXT=`pkgext $PACKAGE` +foreach $PACKAGE (@{$dh{DOPACKAGES}}) { + $TMP=tmpdir($PACKAGE); + $file=pkgfile($PACKAGE,"dirs"); - if [ ! -d $TMP/usr/doc/$PACKAGE ]; then - doit "install -d $TMP/usr/doc/$PACKAGE" - fi + if (! -e $TMP) { + doit("install","-d",$TMP); + } - dirs="" + undef @dirs; - if [ -e debian/${EXT}dirs ]; then - dirs=`tr "\n" " " < debian/${EXT}dirs` - fi + if ($file) { + @dirs=filearray($file) + } - if [ "$PACKAGE" = "$MAINPACKAGE" -a "$*" ]; then - dirs="$* $dirs" - fi + if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) { + push @dirs, @ARGV; + } + + if (@dirs) { + # Stick the $TMP onto the front of all the dirs. + # This is necessary, for 2 reasons, one to make them + # be in the right directory, but more importantly, it + # protects against the danger of absolute dirs being + # specified. + @dirs=map { + $_="$TMP/$_"; + tr:/:/:s; # just beautification. + $_ + } @dirs; - if [ "$dirs" ]; then - # Check to see if any of the dirs are absolute. - for dir in "$dirs" ; do - if expr "$dir" : "/" >/dev/null ; then - error "Absolute directory name \"$dir\" specified." - fi - done # Create dirs. - verbose_echo "cd $TMP && install -d $dirs && cd ../.." - cd $TMP - install -d $dirs - cd ../.. - fi -done + doit("install","-d",@dirs); + } +} diff --git a/dh_installdocs b/dh_installdocs index 86b6f20..ad50423 100755 --- a/dh_installdocs +++ b/dh_installdocs @@ -5,8 +5,7 @@ # Also installs the debian/copyright and debian/README.debian and debian/TODO # and handles debian/doc-base. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_installemacsen b/dh_installemacsen index e87cece..8d8982c 100755 --- a/dh_installemacsen +++ b/dh_installemacsen @@ -1,34 +1,51 @@ -#!/bin/sh -e +#!/usr/bin/perl -w # # Registration with emacsen-common. -PATH=debian:$PATH:/usr/lib/debhelper -. dh_lib +use Debian::Debhelper::Dh_Lib; +init(); -for PACKAGE in $DH_DOPACKAGES; do - TMP=`tmpdir $PACKAGE` +if (! defined $dh{PRIORITY}) { + $dh{PRIORITY}=50; +} +if (! defined $dh{FLAVOR}) { + $dh{FLAVOR}='emacs'; +} - emacsen_install=`pkgfile $PACKAGE emacsen-install` - emacsen_remove=`pkgfile $PACKAGE emacsen-remove` +foreach $PACKAGE (@{$dh{DOPACKAGES}}) { + $TMP=tmpdir($PACKAGE); - if [ "$emacsen_install" ]; then - if [ ! -d "$TMP/usr/lib/emacsen-common/packages/install" ]; then - doit "install -d $TMP/usr/lib/emacsen-common/packages/install" - fi - doit "install $emacsen_install $TMP/usr/lib/emacsen-common/packages/install/$PACKAGE" - fi + $emacsen_install=pkgfile($PACKAGE,"emacsen-install"); + $emacsen_remove=pkgfile($PACKAGE,"emacsen-remove"); + $emacsen_startup=pkgfile($PACKAGE,"emacsen-startup"); - if [ "$emacsen_remove" ]; then - if [ ! -d "$TMP/usr/lib/emacsen-common/packages/remove" ]; then - doit "install -d $TMP/usr/lib/emacsen-common/packages/remove" - fi - doit "install $emacsen_remove $TMP/usr/lib/emacsen-common/packages/remove/$PACKAGE" - fi + if ($emacsen_install ne '') { + if (! -d "$TMP/usr/lib/emacsen-common/packages/install") { + doit("install","-d","$TMP/usr/lib/emacsen-common/packages/install"); + } + doit("install","-m0755",$emacsen_install,"$TMP/usr/lib/emacsen-common/packages/install/$PACKAGE"); + } - if [ "$emacsen_install" -o "$emacsen_remove" ]; then - if [ ! "$DH_NOSCRIPTS" ]; then - autoscript "postinst" "postinst-emacsen" - autoscript "prerm" "prerm-emacsen" - fi - fi -done + if ($emacsen_remove ne '') { + if (! -d "$TMP/usr/lib/emacsen-common/packages/remove") { + doit("install","-d","$TMP/usr/lib/emacsen-common/packages/remove"); + } + doit("install","-m0755","$emacsen_remove","$TMP/usr/lib/emacsen-common/packages/remove/$PACKAGE"); + } + + if ($emacsen_startup ne '') { + if (! -d "$TMP/etc/$dh{FLAVOR}/site-start.d/") { + doit("install","-d","$TMP/etc/$dh{FLAVOR}/site-start.d/"); + } + doit("install","-m0644",$emacsen_startup,"$TMP/etc/$dh{FLAVOR}/site-start.d/$dh{PRIORITY}$PACKAGE.el"); + } + + if ($emacsen_install ne '' || $emacsen_remove ne '') { + if (! $dh{NOSCRIPTS}) { + autoscript($PACKAGE,"postinst","postinst-emacsen", + "s/#PACKAGE#/$PACKAGE/"); + autoscript($PACKAGE,"prerm","prerm-emacsen", + "s/#PACKAGE#/$PACKAGE/"); + } + } +} diff --git a/dh_installemacsen.1 b/dh_installemacsen.1 index d52cff2..7615ad6 100644 --- a/dh_installemacsen.1 +++ b/dh_installemacsen.1 @@ -3,7 +3,7 @@ dh_installemacsen \- register an emacs add on package .SH SYNOPSIS .B dh_installemacsen -.I "[debhelper options] [-n] [--number=n] [--flavor=foo]" +.I "[debhelper options] [-n] [--priority=n] [--flavor=foo]" .SH "DESCRIPTION" dh_installemacsen is a debhelper program that is responsible for installing files used by the debian emacsen-common package into package build directories. @@ -32,7 +32,7 @@ for a list of options common to all debhelper commands. .B \-n, \--noscripts Do not modify postinst/prerm scripts. .TP -.B \--number=n +.B \--priority=n Sets the priority number of a site-start.d file. Default is 50. .TP .B \--flavor=foo diff --git a/dh_installexamples b/dh_installexamples index 033564e..bf0bbe4 100755 --- a/dh_installexamples +++ b/dh_installexamples @@ -3,8 +3,7 @@ # Reads debian/examples, installs all files listed there into # /usr/share/doc/$PACKAGE/examples -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_installinfo b/dh_installinfo index fe03433..3e64209 100755 --- a/dh_installinfo +++ b/dh_installinfo @@ -3,8 +3,7 @@ # Reads debian/info, installs all files listed there into /usr/share/info # and puts appropriate commands into the postinst. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { @@ -45,7 +44,7 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) { } close IN; - my $fn="/usr/share/info/".Dh_Lib::basename($file); + my $fn="/usr/share/info/".Debian::Debhelper::Dh_Lib::basename($file); if ($section ne '') { $section=~s:/:\\/:g; # allow / in section. diff --git a/dh_installinit b/dh_installinit index 2ea3440..7836a9e 100755 --- a/dh_installinit +++ b/dh_installinit @@ -1,58 +1,73 @@ -#!/bin/sh -e +#!/usr/bin/perl -w # # Install debian/init[.d], and set up the postinst and postrm for init # scripts. -PATH=debian:$PATH:/usr/lib/debhelper -. dh_lib - -for PACKAGE in $DH_DOPACKAGES; do - TMP=`tmpdir $PACKAGE` - EXT=`pkgext $PACKAGE` - - if [ -e debian/${EXT}init ]; then - if [ ! -d $TMP/etc/init.d ]; then - doit "install -d $TMP/etc/init.d" - fi - - # Figure out what filename to install it as. - if [ "$DH_D_FLAG" ]; then - # -d on the command line sets DH_D_FLAG. We will - # remove a trailing 'd' from the package name and - # use that as the name. - script=`expr $PACKAGE : '\(.*\)d$'` || true - if [ ! "$script" ]; then - echo `basename $0`" warning: \"$PACKAGE\" has no final -d, but -d was specified." - script=$PACKAGE - fi - else - script=$PACKAGE - fi - doit "install -p -m755 debian/${EXT}init $TMP/etc/init.d/$script" +use Debian::Debhelper::Dh_Lib; +init(); + +foreach $PACKAGE (@{$dh{DOPACKAGES}}) { + $TMP=tmpdir($PACKAGE); + + # Figure out what filename to install it as. + my $script; + if ($dh{D_FLAG}) { + # -d on the command line sets D_FLAG. We will + # remove a trailing 'd' from the package name and + # use that as the name. + $script=$PACKAGE; + if ($script=~m/(.*)d$/) { + $script=$1; + } + else { + warning("\"$PACKAGE\" has no final d' in its name, but -d was specified."); + } + } + elsif ($dh{INIT_SCRIPT}) { + $script=$dh{INIT_SCRIPT}; + } + else { + $script=$PACKAGE; + } + + $init=pkgfile($PACKAGE,$script) || pkgfile($PACKAGE,"init") || + pkgfile($PACKAGE,"init.d"); + + if ($init ne '') { + if (! -d "$TMP/etc/init.d") { + doit("install","-d","$TMP/etc/init.d"); + } + + doit("install","-p","-m755",$init,"$TMP/etc/init.d/$script"); # This is set by the -u "foo" command line switch, it's - # the parameters to pass to update-rc.d. If not set, + # the parameters to pass to update-rc.d. If not set, # we have to say "defaults". - if [ "$DH_U_PARAMS" = "" ]; then - DH_U_PARAMS="defaults" - fi - - # -r on the command line sets DH_R_FLAG. If it's set, there - # is no restart on upgrade. - if [ ! "$DH_NOSCRIPTS" ]; then - if [ "$DH_R_FLAG" ]; then - autoscript "postinst" "postinst-init-norestart" \ - "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/" - autoscript "postrm" "postrm-init" \ - "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/" - else - autoscript "postinst" "postinst-init" \ - "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/" - autoscript "postrm" "postrm-init" \ - "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/" - autoscript "prerm" "prerm-init" \ - "s/#SCRIPT#/$script/;s/#INITPARMS#/$DH_U_PARAMS/" - fi - fi - fi -done + my $params=''; + if (defined($dh{U_PARAMS})) { + $params=join(' ',@{$dh{U_PARAMS}}); + } + if ($params eq '') { + $params="defaults"; + } + + if (! $dh{NOSCRIPTS}) { + # -r on the command line sets R_FLAG. If it's set, there + # is no restart on upgrade. + if ($dh{R_FLAG}) { + autoscript($PACKAGE,"postinst","postinst-init-norestart", + "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/"); + autoscript($PACKAGE,"postrm","postrm-init", + "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/"); + } + else { + autoscript($PACKAGE,"postinst","postinst-init", + "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/"); + autoscript($PACKAGE,"postrm","postrm-init", + "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/"); + autoscript($PACKAGE,"prerm","prerm-init", + "s/#SCRIPT#/$script/;s/#INITPARMS#/$params/"); + } + } + } +} diff --git a/dh_installmanpages b/dh_installmanpages index 82681f3..448f089 100755 --- a/dh_installmanpages +++ b/dh_installmanpages @@ -7,8 +7,7 @@ # This is a little bit (hah!) DWIMish, but still very handy. use File::Find; -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); # Check if a file is a man page, for use by File::Find. @@ -60,8 +59,8 @@ sub find_so_man { if ($l=~m/\.so\s+(.*)/) { my $solink=$1; # This test is here to prevent links like ... man8/../man8/foo.8 - if (Dh_Lib::basename($File::Find::dir) eq Dh_Lib::dirname($solink)) { - $solink=Dh_Lib::basename($solink); + if (Debian::Debhelper::Dh_Lib::basename($File::Find::dir) eq Debian::Devhelper::Dh_Lib::dirname($solink)) { + $solink=Debian::Debhelper::Dh_Lib::basename($solink); } else { $solink="../$solink"; @@ -83,14 +82,14 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) { foreach $page (@manpages) { $page=~s:^\./::; # just for looks - $basename=Dh_Lib::basename($page); + $basename=Debian::Debhelper::Dh_Lib::basename($page); # Skip all files listed on command line. my $install=1; foreach $skip (@ARGV) { # Look at basename of what's on connect line # for backwards compatability. - if ($basename eq Dh_Lib::basename($skip)) { + if ($basename eq Debian::Debhelper::Dh_Lib::basename($skip)) { $install=undef; last; } diff --git a/dh_installmenu b/dh_installmenu index 26798c2..d6050fe 100755 --- a/dh_installmenu +++ b/dh_installmenu @@ -1,24 +1,44 @@ -#!/bin/sh -e +#!/usr/bin/perl -w # # Integration with debian menu system: # -# If debian/menu file exists, save it to debian/tmp/usr/lib/menu/$PACKAGE +# If debian/menu file exists, save it to $TMP/usr/lib/menu/$PACKAGE # If debian/menu-method file exists, save it to -# debian/tmp/etc/menu-methods/$PACKAGE +# $TMP/etc/menu-methods/$PACKAGE +# +# Also, add to postinst and postrm. + +use Debian::Debhelper::Dh_Lib; +init(); -PATH=debian:$PATH:/usr/lib/debhelper -source dh_lib +foreach $PACKAGE (@{$dh{DOPACKAGES}}) { + $TMP=tmpdir($PACKAGE); + $menu=pkgfile($PACKAGE,"menu"); + $menu_method=pkgfile($PACKAGE,"menu-method"); + + if ($menu ne '') { + if (! -d "$TMP/usr/lib/menu") { + doit("install","-d","$TMP/usr/lib/menu"); + } + doit("install","-p","-m644",$menu,"$TMP/usr/lib/menu/$PACKAGE"); + + # Add the scripts if a menu-method file doesn't exist. + # The scripts for menu-method handle everything these do, too. + if ($menu_method eq "" && ! $dh{NOSCRIPTS}) { + autoscript($PACKAGE,"postinst","postinst-menu"); + autoscript($PACKAGE,"postrm","postrm-menu") + } + } -if [ -e debian/menu ]; then - if [ ! -d debian/tmp/usr/lib/menu ]; then - doit "install -d debian/tmp/usr/lib/menu" - fi - doit "install -p -m644 debian/menu debian/tmp/usr/lib/menu/$PACKAGE" -fi + if ($menu_method ne '') { + if (!-d "$TMP/etc/menu-methods") { + doit("install","-d","$TMP/etc/menu-methods"); + } + doit("install","-p",$menu_method,"$TMP/etc/menu-methods/$PACKAGE"); -if [ -e debian/menu-method ]; then - if [ ! -d debian/tmp/etc/menu-methods ]; then - doit "install -d debian/tmp/etc/menu-methods" - fi - doit "install -p debian/menu-method debian/tmp/etc/menu-methods/$PACKAGE" -fi + if (! $dh{NOSCRIPTS}) { + autoscript($PACKAGE,"postinst","postinst-menu-method","s/#PACKAGE#/$PACKAGE/"); + autoscript($PACKAGE,"postrm","postrm-menu-method","s/#PACKAGE#/$PACKAGE/"); + } + } +} diff --git a/dh_installmime b/dh_installmime index 232ddc1..0dbc08b 100755 --- a/dh_installmime +++ b/dh_installmime @@ -1,7 +1,8 @@ #!/usr/bin/perl -w +# +# Mime support. -BEGIN { push @INC, "debian", "/usr/lib/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_installmodules b/dh_installmodules index 264ae9c..a801630 100755 --- a/dh_installmodules +++ b/dh_installmodules @@ -2,8 +2,7 @@ # # Register modules with modutils. -BEGIN { push @INC, "debian", "/usr/lib/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { @@ -17,7 +16,7 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) { if ($file) { if (! -e "$TMP/etc/modutils") { doit("install","-d","$TMP/etc/modutils"); - doit("cp","-m0644",$file,"$TMP/etc/modutils/$PACKAGE"); + doit("install","-m","0644",$file,"$TMP/etc/modutils/$PACKAGE"); } if (! $dh{NOSCRIPTS}) { diff --git a/dh_installpam b/dh_installpam index 2262d81..72f8d7d 100755 --- a/dh_installpam +++ b/dh_installpam @@ -4,8 +4,7 @@ # # If debian/pam file exists, save it to $TMP/etc/pam.d/$PACKAGE -BEGIN { push @INC, "debian", "/usr/lib/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_installwm b/dh_installwm index b3b9059..8cb7af0 100755 --- a/dh_installwm +++ b/dh_installwm @@ -2,21 +2,38 @@ # # Add to postinst and postrm to register a window manager. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); -$wm=shift; +if (! defined $dh{PRIORITY}) { + $dh{PRIORITY}=20; +} -if ($wm eq '') { - error("No window manager filename was specified."); +if (@ARGV) { + # This is here for backwards comatability. If the filename doesn't + # include a path, assume it's in /usr/X11R6/bin. + if ($ARGV[0] !~ m:/:) { + $ARGV[0]="/usr/X11R6/$ARGV[0]"; + } } foreach $PACKAGE (@{$dh{DOPACKAGES}}) { # $TMP=tmpdir($PACKAGE); + $file=pkgfile($PACKAGE,"wm"); + + if ($file) { + @wm=filearray($file); + } - if (! $dh{NOSCRIPTS}) { - autoscript($PACKAGE,"postinst","postinst-wm","s:#WM#:$wm:"); - autoscript($PACKAGE,"postrm","postrm-wm","s:#WM#:$wm:"); + if (($PACKAGE eq $dh{FIRSTPACKAGE} || $dh{PARAMS_ALL}) && @ARGV) { + push @wm, @ARGV; + } + + if (@wm && ! $dh{NOSCRIPTS}) { + foreach (@wm) { + autoscript($PACKAGE,"postinst","postinst-wm","s:#WM#:$_:;s/#PRIORITY#/$dh{PRIORITY}/",); + autoscript($PACKAGE,"postrm","postrm-wm","s:#WM#:$_:"); + } } } + diff --git a/dh_installwm.1 b/dh_installwm.1 index 486e511..33345a9 100644 --- a/dh_installwm.1 +++ b/dh_installwm.1 @@ -3,14 +3,21 @@ dh_installwm \- register a window manager .SH SYNOPSIS .B dh_installwm -.I "[debhelper options] [-n] wmfilename" +.I "[debhelper options] [-n] [--priority=n] [wm ...]" .SH "DESCRIPTION" dh_installwm is a debhelper program that is responsible for -generating the postinst and postrm commands needed to -interface with the the -.BR register-window-manager (8) -command. This results in a window manager being registered when it is -installed. +generating the postinst and postrm commands that register a window manager +with +.BR update-alternatives (8) +.P +Any windowmanager filenames specified as parameters will be registered in +the first package dh_installwm is told to ast on. By default, this is the +first binary package in debian/control, but if you use -p, -i, or -a flags, it +will be the first package specified by those flags. +.P +A file named debian/package.wm (debian/wm may be used for the +first binary package in debian/control) can list other window manager to +register. .SH OPTIONS .TP .B debhelper options @@ -18,13 +25,16 @@ See .BR debhelper (1) for a list of options common to all debhelper commands. .TP +.B \--priority=n +Set the priority of the window manager. Default is 20, which is too low for +most window managers; see the Debian Policy document for instructions on +calculating the correct value. +.TP .B \-n, \--noscripts Do not modify postinst/postrm scripts. Turns this command into a no-op. .TP .B wmfilename -The filename of the window manager you wish to register. May be either a -simple filename if the window manager is in /usr/X11R6/bin/, or a complete -path otherwise. +The filename of the window manager you wish to register. .SH NOTES Note that this command will set up postinst and postrm scripts for every package it acts on. It's wise to limit its action to a single package with, @@ -41,6 +51,6 @@ instances of the same text to be added to maintainer scripts. .TP .BR debhelper (1) .TP -.BR register-window-manager (8) +.BR update-alternatives (8) .SH AUTHOR Joey Hess diff --git a/dh_installxaw b/dh_installxaw index bee9710..5cb94e2 100755 --- a/dh_installxaw +++ b/dh_installxaw @@ -7,8 +7,7 @@ # # Also, add calls to postinst and postrm. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_installxfonts b/dh_installxfonts index 1ceb3cb..83f38c0 100755 --- a/dh_installxfonts +++ b/dh_installxfonts @@ -2,8 +2,7 @@ # # Integration with the Debian X11 font policy. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_link b/dh_link index 8d4c32a..0cbe6b7 100755 --- a/dh_link +++ b/dh_link @@ -3,8 +3,7 @@ # Generate symlinks in debian packages, reading debian/links. The # file contains pairs of files and symlinks. -BEGIN { push @INC, "debian", "/usr/lib/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { @@ -31,14 +30,16 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) { error("parameters list a link without a destination."); } - # Now I'd prefer to work with a hash. - %links=@links; + while (@links) { + $dest=pop @links; + $src=pop @links; + + # Relivatize src and dest. + $src=~s:^/::; + $dest=~s:^/::; - foreach $src (keys %links) { - $dest=$links{$src}; - # Make sure the directory the link will be in exists. - $basedir=Dh_Lib::dirname("$TMP/$dest"); + $basedir=Debian::Debhelper::Dh_Lib::dirname("$TMP/$dest"); if (! -e $basedir) { doit("install","-d",$basedir); } @@ -52,18 +53,20 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) { # Figure out how much of a path $src and $dest # share in common. for ($x=0; $x<$#src_dirs && $src_dirs[$x] eq $dest_dirs[$x]; $x++) {} - # Build up the new src. $src=""; for (1..$#dest_dirs - $x) { $src.="../"; } - # The + 1 is here to include the actual filename. - for (1..$#src_dirs - $x + 1) { + for ($x .. $#src_dirs) { $src.=$src_dirs[$_]."/"; } $src=~s:/$::; - } + } + else { + # Make sure it's properly absolute. + $src="/$src"; + } doit("ln","-sf",$src,"$TMP/$dest"); } diff --git a/dh_listpackages b/dh_listpackages index 7a764af..1123e6d 100755 --- a/dh_listpackages +++ b/dh_listpackages @@ -2,7 +2,7 @@ # # Output a list of all packages debhelper will act on. -BEGIN { push @INC, "debian", "/usr/lib/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); print join("\n",@{$dh{DOPACKAGES}})."\n"; + diff --git a/dh_makeshlibs b/dh_makeshlibs index c374226..237602b 100755 --- a/dh_makeshlibs +++ b/dh_makeshlibs @@ -2,8 +2,7 @@ # # Automatically generate shlibs files. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_md5sums b/dh_md5sums index 634e2fd..9a3354d 100755 --- a/dh_md5sums +++ b/dh_md5sums @@ -1,22 +1,45 @@ -#!/bin/sh -e +#!/usr/bin/perl -w # -# Generate a DEBIAN/md5sums file, that lists the md5sums of all -# non-conffiles in the package +# Generate a DEBIAN/md5sums file, that lists the md5sums of all files in the +# package. -PATH=debian:$PATH:/usr/lib/debhelper -. dh_lib +use Cwd; +use Debian::Debhelper::Dh_Lib; +init(); -for PACKAGE in $DH_DOPACKAGES; do - TMP=`tmpdir $PACKAGE` +foreach $PACKAGE (@{$dh{DOPACKAGES}}) { + $TMP=tmpdir($PACKAGE); - if [ ! -d "debian/$TMP/DEBIAN" ]; then - doit "install -d debian/$TMP/DEBIAN" - fi + if (! -d "$TMP/DEBIAN") { + doit("install","-d","$TMP/DEBIAN"); + } - doit "pushd debian/$TMP" >/dev/null - # Doit isn't smart enough to hande this next command so echo by hand. (sigh) - verbose_echo 'md5sum `find * -type f ! -regex "^DEBIAN/.*"` > DEBIAN/md5sums DEBIAN/md5sums /dev/null" >/dev/null -done + # Check if we should exclude conffiles. + my $exclude=""; + if (! $dh{INCLUDE} && -r "$TMP/DEBIAN/conffiles") { + # Generate exclude regexp. + open (CONFF,"$TMP/DEBIAN/conffiles"); + while () { + chomp; + s/^\///; + $exclude.="! -path \"$_\" "; + } + close CONFF; + } + + # See if we should exclude other files. + if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') { + $exclude.="! \\( $dh{EXCLUDE_FIND} \\) "; + } + + $olddir=getcwd(); + complex_doit("cd $TMP >/dev/null ; find * -type f $exclude ! -regex '^DEBIAN/.*' -print0 | xargs -r0 md5sum > DEBIAN/md5sums ; cd $olddir >/dev/null"); + # If the file's empty, no reason to waste inodes on it. + if (-z "$TMP/DEBIAN/md5sums") { + doit("rm","-f","$TMP/DEBIAN/md5sums"); + } + else { + doit("chmod",644,"$TMP/DEBIAN/md5sums"); + doit("chown","root.root","$TMP/DEBIAN/md5sums"); + } +} diff --git a/dh_movefiles b/dh_movefiles index e026373..9795b78 100755 --- a/dh_movefiles +++ b/dh_movefiles @@ -2,8 +2,7 @@ # # Move files out of debian/tmp, into subpackages. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); $ret=0; diff --git a/dh_perl b/dh_perl index 4136414..dc614e4 100755 --- a/dh_perl +++ b/dh_perl @@ -3,12 +3,28 @@ # Find dependencies on perl stuff # Remove .packlist files -BEGIN { push @INC, "debian", "/usr/lib/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); -my $perl = $ENV{'PERL'} || '/usr/bin/perl'; -$version=sprintf("%.3f", $]); +my $ext = ''; +my $lib_dir = 'usr/lib/perl5'; + +# Figure out the version of perl. If $ENV{PERL} is set, query the perl binary +# it points to, otherwise query perl directly. +my $version=sprintf("%.3f", $]); +if (defined $ENV{PERL}) { + $version=`$ENV{PERL} -e 'printf "%.3f", \$]'`; +} + +# Cleaning the paths given on the command line +foreach (@ARGV) { + s#/$##; + s#^/##; +} + +# If -d is given, then we'll try to depend on one of the perl-5.00X-base +# package instead of perl-5.00X +$ext='-base' if ($dh{'D_FLAG'}); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { $TMP=tmpdir($PACKAGE); @@ -19,17 +35,24 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) { my $dep = ''; my $found = 0; + # Check also for alternate locations given on the command line + my $dirs = ''; + foreach ($lib_dir, @ARGV) { + $dirs .= "$TMP/$_ " if (-d "$TMP/$_"); + } + my $re = '(?:' . join('|', ($lib_dir, @ARGV)) . ')'; + # Look for perl modules and check where they are installed - if (-d "$TMP/usr/lib/perl5") { - foreach $file (split(/\n/,`find $TMP/usr/lib/perl5 -type f -name "*.pm"`)) { + if ($dirs) { + foreach $file (split(/\n/,`find $dirs -type f \\( -name "*.pm" -or -name "*.so" \\)`)) { $found++; - if ($file =~ m<^$TMP/usr/lib/perl5/(\d\.\d{3})/([^/]+)/>) { + if ($file =~ m<^$TMP/$re/(\d\.\d{3})/([^/]+)/>) { $v = $1; $arch = $2; check_module_version ($v, $version); - $v .= '-thread' if ($arch =~ /-thread/); + $v .= '-thread' if ($arch =~ /-thread/); $dep_arch = add_deps ($dep_arch, "perl-$v"); - } elsif ($file =~ m<^$TMP/usr/lib/perl5/(\d.\d{3})/>) { + } elsif ($file =~ m<^$TMP/$re/(\d.\d{3})/>) { $v = $1; check_module_version ($v, $version); $dep_arch = add_deps ($dep_arch, "perl-$v"); @@ -38,7 +61,7 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) { } if ($found and not $dep_arch) { - $dep = "perl5"; + $dep = "perl5$ext"; } elsif ($dep_arch) { $dep = $dep_arch; } @@ -68,14 +91,14 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) { next unless $dep; - if (-e "debian/$EXT\subtsvars") { - open (IN, "; close IN; - open (OUT, ">debian/$EXT\subtsvars"); + open (OUT, ">debian/$EXT\substvars"); print OUT @lines; } else { - open (OUT, ">debian/$EXT\subtsvars"); + open (OUT, ">debian/$EXT\substvars"); } print OUT "perl:Depends=$dep\n"; close OUT; @@ -84,6 +107,9 @@ foreach $PACKAGE (@{$dh{DOPACKAGES}}) { sub add_deps { my ($dep, $new) = @_; + # If the $new-base package can exist then add $ext to $new + $new = "$new$ext" if ($new =~ m/^(?:perl5|perl-\d\.\d{3})$/); + # If $new = perl5 or perl5-thread check if perl-X.XXX(-thread)? # is not already in the dependencies if ($new eq "perl5") { diff --git a/dh_shlibdeps b/dh_shlibdeps index f6ae235..83783ae 100755 --- a/dh_shlibdeps +++ b/dh_shlibdeps @@ -2,8 +2,7 @@ # # Find dependancies. Simple dpkg-shlibdeps wrapper. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_strip b/dh_strip index 2ecdcd2..b39d465 100755 --- a/dh_strip +++ b/dh_strip @@ -1,30 +1,70 @@ -#!/bin/sh -e +#!/usr/bin/perl -w # # Strip files. -PATH=debian:$PATH:/usr/lib/debhelper -source dh_lib +use File::Find; +use Debian::Debhelper::Dh_Lib; +init(); -for PACKAGE in $DH_DOPACKAGES; do - TMP=`tmpdir $PACKAGE` +# 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. + $fn="$File::Find::dir/$_"; + foreach $f (@{$dh{EXCLUDE}}) { + return if ($fn=~m/\Q$f\E/); + } + + # Does its filename look like a shared library? + if (m/.*\.so.*?/) { + # Ok, do the expensive test. + my $type=`file $_`; + if ($type=~m/.*ELF.*shared.*/) { + push @shared_libs, $fn; + return; + } + } + + # Is it executable? -x isn't good enough, so we need to use stat. + (undef,undef,$mode,undef)=stat(_); + if ($mode & 0111) { + # Ok, expensive test. + my $type=`file $_`; + if ($type=~m/.*ELF.*executable.*/) { + push @executables, $fn; + return; + } + } + + # Is it a static library, and not a debug library? + if (m/lib.*\.a/ && ! m/.*_g\.a/) { + push @static_libs, $fn; + return; + } +} + +foreach $PACKAGE (@{$dh{DOPACKAGES}}) { + $TMP=tmpdir($PACKAGE); + + @shared_libs=@executables=@static_libs=(); + find(\&testfile,$TMP); + + foreach (@shared_libs) { + # Note that all calls to strip on shared libs + # *must* inclde the --strip-unneeded. + doit("strip","--remove-section=.comment","--remove-section=.note","--strip-unneeded",$_); + } - # Handle executables and shared libraries. - for file in `find debian/$TMP -type f \( -perm +111 -or -name "*.so*" \) 2>/dev/null` ; do - case "`file $file`" in - *ELF*shared*) - doit "strip --strip-unneeded $file" - ;; - *ELF*executable*) - doit "strip --remove-section=comment --remove-section=note $file" - ;; - esac - done - - # Handle static libraries. - for file in `find debian/$TMP -type f -name "lib*.a" 2>/dev/null` ; do - # Don't strip debug libraries. - if ! expr "$file" : ".*_g\.a" >/dev/null ; then - doit "strip --strip-debug $file" - fi - done -done + foreach (@executables) { + doit("strip","--remove-section=.comment","--remove-section=.note",$_); + } + + foreach (@static_libs) { + doit("strip","--strip-debug",$_); + } +} diff --git a/dh_suidregister b/dh_suidregister index b82bc7d..50d64b2 100755 --- a/dh_suidregister +++ b/dh_suidregister @@ -6,8 +6,7 @@ # If there are parameters, or there is a debian/suid, register the files # listed there. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/dh_testdir b/dh_testdir index 4d3c700..8bd960d 100755 --- a/dh_testdir +++ b/dh_testdir @@ -1,14 +1,14 @@ -#!/bin/sh -e +#!/usr/bin/perl -w # # Checks to make sure we are building the package in the right directory. # Tests for the existance of debian/control, and for the existance # of any other files you specify on the command line. -PATH=debian:$PATH:/usr/lib/debhelper -source dh_lib +use Debian::Debhelper::Dh_Lib; +init(); -for file in debian/control $@; do - if [ ! -e "$file" ] ; then - error "\"$file\" not found. Are you sure you are in the correct directory?" - fi -done +foreach $file ('debian/control',@ARGV) { + if (! -e $file) { + error("\"$file\" not found. Are you sure you are in the correct directory?"); + } +} diff --git a/dh_testroot b/dh_testroot index c62894c..b76a1e5 100755 --- a/dh_testroot +++ b/dh_testroot @@ -2,8 +2,7 @@ # # Checks to make sure you are root. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; if ($< != 0) { error("You must run this as root."); diff --git a/dh_testversion b/dh_testversion index 57c0e58..8f25214 100755 --- a/dh_testversion +++ b/dh_testversion @@ -2,9 +2,8 @@ # # Debhelper version check. -BEGIN { push @INC, "debian", "/usr/lib/debhelper" } -use Dh_Lib; -use Dh_Version; # contains the version number of debhelper. +use Debian::Debhelper::Dh_Lib; +use Debian::Debhelper::Dh_Version; # contains the version number of debhelper. init(); my($compare, $ver); @@ -19,6 +18,6 @@ elsif ($#ARGV eq 0) { } if (defined $compare and defined $ver) { - system('dpkg','--compare-versions',$Dh_Version::version,$compare,$ver) == 0 || - error("debhelper version $Dh_Version::version is installed, but a version $compare $ver is needed to build this package."); + system('dpkg','--compare-versions',$Debian::Debhelper::Dh_Version::version,$compare,$ver) == 0 || + error("debhelper version $Debian::Debhelper::Dh_Version::version is installed, but a version $compare $ver is needed to build this package."); } diff --git a/dh_undocumented b/dh_undocumented index b1b7b16..93328ad 100755 --- a/dh_undocumented +++ b/dh_undocumented @@ -6,8 +6,7 @@ # Also, it looks for debian/undocumented files for more lists of # undocumented man pages. -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib; init(); foreach $PACKAGE (@{$dh{DOPACKAGES}}) { diff --git a/doc/PROGRAMMING b/doc/PROGRAMMING index f4d14bd..df9a728 100644 --- a/doc/PROGRAMMING +++ b/doc/PROGRAMMING @@ -16,9 +16,9 @@ passed -v, and if you output the commands, you should indent them with 1 tab). This is so we don't have a lot of noise output when all the debhelper commands in a debian/rules are run, so the important stuff is clearly visible. -Debhelper programs should accept the options, -v, -i, -a, -p, --no-act, and --P, and any long forms of these options, like --verbose . If necessary, the -options may be ignored. +Debhelper programs should accept all options listed in the "SHARED +DEBHELPER OPTIONS" section of debhelper(1), including and any long forms of +these options, like --verbose . If necessary, the options may be ignored. If debhelper commands need config files, they should use debian/package.filename as the name of the config file (replace filename @@ -41,9 +41,9 @@ There are always exceptions. Just ask me. Introducing Dh_Lib.pm: --------------------- -Dh_lib.pm is the library used by all debhelper programs to parse their +Dh_Lib.pm is the library used by all debhelper programs to parse their arguments and set some useful variables. It's not mandatory that your -program use Dh_lib.pm, but it will make it a lot easier to keep it in sync +program use Dh_Lib.pm, but it will make it a lot easier to keep it in sync with the rest of debhelper if it does, so this is highly encouraged. (There used to be a version of Dh_lib.pm that was a library of functions for @@ -51,17 +51,16 @@ shell scripts. If you want to write a debhelper command that is a shell script, I can dig up that old library for you. Only the perl one is supported now, though.) -Use Dh_lib.pm like this: +Use Dh_Lib.pm like this: -BEGIN { push @INC, "debian", "/usr/share/debhelper" } -use Dh_Lib; +use Debian::Debhelper::Dh_Lib init(); The BEGIN block is there to make perl look for the module in all the right places. -The init() function in the perl version. This causes Dh_lib to -parse the command line and do some other initialization tasks. +The init() function causes Dh_lib to parse the command line and do some other +initialization tasks. Argument processing: ------------------- @@ -126,7 +125,8 @@ switch variable description dh_builddeb will ever use this) --flavor FLAVOR will be set to a string (probably only dh_installemacsen will ever use this) ---number NUMBER will be set to a number +--number PRIORITY will be set to a number (deprecated) +--priority PRIORITY will be set to a number Any additional command line parameters that do not start with "-" will be ignored, and you can access them later just as you normally would. @@ -206,3 +206,4 @@ autoscript() maintainer script (like the postinst or prerm). -- Joey Hess + diff --git a/doc/README b/doc/README index dcc42e6..9335157 100644 --- a/doc/README +++ b/doc/README @@ -20,7 +20,6 @@ Debhelper v2 is a major new version of Debhelper, still under development. Debhelper will continue to work in v1 compatability mode for now, if you're interested in trying the new versiln, read the file named "v2". - Starting a new package: ---------------------- @@ -72,3 +71,4 @@ Other notes: * Debhelper's home page is at http://kitenet.net/programs/debhelper/ -- Joey Hess + diff --git a/doc/TODO b/doc/TODO index 54c95f3..c341e96 100644 --- a/doc/TODO +++ b/doc/TODO @@ -57,3 +57,6 @@ Deprecated: one year after they were deprecated, whichever comes first. Be sure to grep whole debian archive for all of them before removing them, though! - currently, a few packages in potato use dh_du, but bugs have been filed. +* Remove support for --number option + - only dh_installemacsen ever used it, it is not --priority. + diff --git a/doc/v2 b/doc/v2 index fdfa548..327e625 100644 --- a/doc/v2 +++ b/doc/v2 @@ -65,3 +65,4 @@ them. * dh_makeshlibs will generate autoscript fragments for ldconfig. This will require you call it before dh_installdeb, which isn't always done now. + -- 2.39.5