From 2dc6b1e7754c88976aadefb20a4d387e8cf8b4ce Mon Sep 17 00:00:00 2001 From: joey Date: Tue, 17 Aug 1999 04:41:40 +0000 Subject: [PATCH] r43: Initial Import --- README | 18 +++--- TODO | 2 - debian/changelog | 9 +++ debian/rules | 13 +++- dh_du | 2 +- dh_installchangelogs | 4 +- dh_installdirs.1 | 9 +-- dh_installdocs | 2 +- dh_installinit | 6 ++ dh_lib | 140 +++++++++++++++++++++++++++---------------- dh_suidregister | 2 +- 11 files changed, 134 insertions(+), 73 deletions(-) diff --git a/README b/README index 280da78..5c3bf91 100644 --- a/README +++ b/README @@ -2,11 +2,10 @@ Debhelper is a collection of programs that can be used in debian/rules files to automate common tasks. For further documentation, see the man pages for dh_* commands. -To help you get started, I've included an example of a debian/rules file -that uses debhelper commands extensively. See -/usr/doc/debhelper/examples/rules . These files are also useful as they give -one good order you can run the different debhelper scripts in (though other -variations are possible). +To help you get started, I've included examples of debian/rules files +that use debhelper commands extensively. See /usr/doc/debhelper/examples/ . +These files are also useful as they give one good order you can run the +various debhelper scripts in (though other variations are possible). Converting from debstd to debhelper: @@ -76,7 +75,12 @@ All scripts that automatically generate code in this way let it be disabled by the -n parameter. Note that it will be shell code, so you cannot directly use it in a perl -script. +script. If you would like to embed it into a perl script, here is one way to +do that: + +print << `EOF` +#DEBHELPER# +EOF Notes on multiple binary packages: @@ -100,7 +104,7 @@ following parameters: times) These parameters are cumulative. If none are given, the tools default to -effecting all packages. +affecting all packages. See examples/rules.multi for an example of how to use this. diff --git a/TODO b/TODO index 3118ab9..00281d7 100644 --- a/TODO +++ b/TODO @@ -2,7 +2,5 @@ * add all other functionality of debstd (??) * dh_fixperms: allow listing of files not to be touched (diffucult). * add a dh_debstd, which mimics debstd, but uses debhelper tools internally. -* dh_du: change it so it doesn't grep for things with tabs in them. That's - nasty. (and makes cut-and-paste from dh_du -v not work). * dh_compress: add --exclude "*.conf" type-thingy * info support for debhelper diff --git a/debian/changelog b/debian/changelog index 80d0aaa..a1139e5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +debhelper (0.37) unstable; urgency=low + + * dh_du: Fixed hardcoded debian/tmp. + * This change got lost by accident, redid it: Optimized out most of the + slowdown caused byusing dpkg-parsechangelog - now it's only called by + 2 dh_* programs. + + -- Joey Hess Sun, 28 Dec 1997 20:45:22 -0500 + debhelper (0.36) unstable; urgency=low * dh_undocumented: exit with an error message if the man page specified diff --git a/debian/rules b/debian/rules index b236fb1..6ac6d67 100755 --- a/debian/rules +++ b/debian/rules @@ -1,5 +1,5 @@ #!/usr/bin/make -f -# Note that I have to refer to debhelper programs witrh ./, to make sure +# 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 in this debian/ directory. @@ -7,17 +7,24 @@ # be sure to use the new templates from this package. export DH_AUTOSCRIPTDIR=autoscripts +# Figure out the current debhelper version. +VERSION=$(shell expr "`dpkg-parsechangelog 2>/dev/null`" : \ + '.*Version: \(.*\).*Distribution:') + export DH_VERBOSE=1 test_files=dh_lib build: ./dh_testdir $(test_files) + sed "s/#DEBHELPER_VERSION#/$(VERSION)/" < dh_testversion.in \ + > dh_testversion + chmod 755 dh_testversion clean: ./dh_testdir $(test_files) ./dh_testroot - ./dh_clean + ./dh_clean dh_testversion # Build architecture-dependent files here. binary-arch: build @@ -35,7 +42,7 @@ binary-indep: build cp dh_lib debian/tmp/usr/lib/debhelper cp -a autoscripts debian/tmp/usr/lib/debhelper - ./dh_installdocs TODO README BUGS + ./dh_installdocs TODO README ./dh_installexamples examples/* ./dh_installmenu ./dh_installmanpages diff --git a/dh_du b/dh_du index 39c684e..71ce2b1 100755 --- a/dh_du +++ b/dh_du @@ -15,5 +15,5 @@ for PACKAGE in $DH_DOPACKAGES; do # Note that the tabs in this next line are important. complex_doit "du -k $TMP | sed 's: $TMP/: :' | grep -v ' DEBIAN$' | grep -v ' $TMP$' >$TMP/DEBIAN/du" - doit "chown root.root debian/tmp/DEBIAN/du" + doit "chown root.root $TMP/DEBIAN/du" done diff --git a/dh_installchangelogs b/dh_installchangelogs index 7405daa..0dd0991 100755 --- a/dh_installchangelogs +++ b/dh_installchangelogs @@ -12,11 +12,11 @@ PATH=debian:$PATH:/usr/lib/debhelper UPSTREAM=$1 -if [ "$NATIVE" -a "$UPSTREAM" ]; then +if isnative && [ "$UPSTREAM" ]; then error "Cannot specify an upstream changelog for a native debian package." fi -if [ "$NATIVE" ]; then +if isnative; then CHANGELOG_NAME=changelog else CHANGELOG_NAME=changelog.Debian diff --git a/dh_installdirs.1 b/dh_installdirs.1 index 9f5bc35..fc5c8d6 100644 --- a/dh_installdirs.1 +++ b/dh_installdirs.1 @@ -9,8 +9,9 @@ dh_installdirs is a debhelper program that is responsible for creating subdirectories in package build directories. .P Any directory names specified as parameters will be created in the package -build directory of the first binary package listed in debian/control, if -dh_installdirs is acting on that package. +build directory of the first package dh_installdirs is told to act 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/dirs (for the first binary package in debian/control), or debian/package.dirs (for each additional package in debian/control) can @@ -37,8 +38,8 @@ Create directories for the package named "package". Use "tmpdir" for package build directory. .TP .B dir ... -Create these directories in the package build directory of the first binary -package listed in debian/control, if we are acting on that package. +Create these directories in the package build directory of the first package +acted on. .SH NOTES The .B \-a diff --git a/dh_installdocs b/dh_installdocs index 153be9a..a1da8aa 100755 --- a/dh_installdocs +++ b/dh_installdocs @@ -38,7 +38,7 @@ for PACKAGE in $DH_DOPACKAGES; do doit "install -m 644 -p debian/README.Debian $TMP/usr/doc/$PACKAGE/" fi if [ -f debian/TODO ]; then - if [ "$NATIVE" ]; then + if isnative; then doit "install -m 655 -p debian/TODO $TMP/usr/doc/$PACKAGE/TODO" else doit "install -m 644 -p debian/TODO $TMP/usr/doc/$PACKAGE/TODO.Debian" diff --git a/dh_installinit b/dh_installinit index 2ea3440..857e279 100755 --- a/dh_installinit +++ b/dh_installinit @@ -6,6 +6,12 @@ PATH=debian:$PATH:/usr/lib/debhelper . dh_lib +# This works around a bug in getopt(1), where it ignores some parameters. +# Sigh. +if [ "$*" ]; then + DH_U_PARAMS="$DH_U_PARAMS $*" +fi + for PACKAGE in $DH_DOPACKAGES; do TMP=`tmpdir $PACKAGE` EXT=`pkgext $PACKAGE` diff --git a/dh_lib b/dh_lib index 8347aae..2c2b995 100644 --- a/dh_lib +++ b/dh_lib @@ -52,19 +52,26 @@ pkgext() { } # Returns 1 if the package is a native debian package, null otherwise. +# Caches return code so it only needs to run dpkg-parsechangelog once. isnative() { - # Get the package version. - # Note that the 2>/dev/null is because a bug in dpkg-parsechangelog makes it - # output a bogus error message to stderr. - # If it actually has a real error, then the expr will fail, and this whole - # script will come crashing to a halt, which is good enough to inform - # the user something's wrong. :-) - VERSION=`expr "\`dpkg-parsechangelog 2>/dev/null\`" : \ - '.*Version: \(.*\).*Distribution:'` - # Is this a native Debian package? - if expr "$VERSION" : '.*-' >/dev/null; then - return 1 + if [ -z "$DH_ISNATIVE" ]; then + # Get the package version. + # Note that the 2>/dev/null is because a bug in dpkg-parsechangelog makes it + # output a bogus error message to stderr. + # If it actually has a real error, then the expr will fail, and this whole + # script will come crashing to a halt, which is good enough to inform + # the user something's wrong. :-) + VERSION=`expr "\`dpkg-parsechangelog 2>/dev/null\`" : \ + '.*Version: \(.*\).*Distribution:'` + # Is this a native Debian package? + if expr "$VERSION" : '.*-' >/dev/null; then + DH_ISNATIVE=1 + else + DH_ISNATIVE=0 + fi fi + + return "$DH_ISNATIVE" } # Automatically add a shell script snippet to a debian script. @@ -95,10 +102,46 @@ autoscript() { complex_doit "echo '# End automatically added section' >> $autoscript_debscript" } +# Sets 2 global variables, INDEP_PACKAGES is all the arch-independant +# packages, ARCH_PACKAGES is the arch-dependant packages. +get_arch_indep_packages() { + INDEP_PACKAGES="" + ARCH_PACKAGES="" + + # First, get the list of all binary packages. + # Notice we want the list in reverse order, thus the tac. + PACKAGES=`grep ^Package: debian/control | cut -d " " -f 2 | tac | tr "\n" " "` + # Remove trailing space. + PACKAGES=`expr "$PACKAGES" : '\(.*\) '` + # Loop on the list of architectures. + for ARCH in `grep ^Architecture: debian/control | cut -d " " -f 2` ; do + # Pull the last package off the list. + THISPKG=`expr "$PACKAGES" : '.* \(.*\)'` || true + if [ ! "$THISPKG" ]; then + THISPKG=$PACKAGES + fi + PACKAGES=`expr "$PACKAGES" : '\(.*\) .*'` || true + + if [ ! "$THISPKG" ]; then + error "debian/control invalid - too many Architecture lines or too few Package lines" + fi + + if [ "$ARCH" = "all" ]; then + INDEP_PACKAGES="$INDEP_PACKAGES $THISPKG" + else + ARCH_PACKAGES="$ARCH_PACKAGES $THISPKG" + fi + done + + if [ "$PACKAGES" ]; then + error "debian/control invalid - too many Architecure lines or too few Package lines" + fi +} + # Argument processing and global variable initialization is below. # Parse command line. -set -- `getopt xvidrnakp:P:u: $*` +set -- `getopt xvidrnakp:P:u:m: $*` for i; do case "$i" @@ -108,10 +151,14 @@ for i; do shift ;; -i) + get_arch_indep_packages + DH_DOPACKAGES="$DH_DOPACKAGES $INDEP_PACKAGES" DH_DOINDEP=1 shift ;; -a) + get_arch_indep_packages + DH_DOPACKAGES="$DH_DOPACKAGES $ARCH_PACKAGES" DH_DOARCH=1 shift ;; @@ -150,6 +197,11 @@ for i; do shift shift ;; + -m) + DH_M_PARAMS="$2" + shift + shift + ;; --) shift break @@ -157,54 +209,22 @@ for i; do esac done -# Get the name of the main binary package. +# Get the name of the main binary package (first one listed in +# debian/control). MAINPACKAGE=`grep ^Package: debian/control | cut -d " " -f 2 | head -1` -if [ "$DH_DOINDEP" -o "$DH_DOARCH" ]; then - # Figure out all the binary packages to be produced, by looking at the - # control file. Break it into 2 lists, INDEP_PACKAGES and ARCH_PACKAGES. - # - # First, get the list of all binary packages. - PACKAGES=`grep ^Package: debian/control | cut -d " " -f 2 | tr "\n" " "` - # Remove trailing space. - PACKAGES=`expr "$PACKAGES" : '\(.*\) '` - # Loop on the list of architectures. Note that we tac the result to reverse - # it, becuase we are going through the list of packages in reverse. - for ARCH in `grep ^Architecture: debian/control | tac | cut -d " " -f 2` ; do - THISPKG=`expr "$PACKAGES" : '.* \(.*\)'` || true - if [ ! "$THISPKG" ]; then - THISPKG=$PACKAGES - fi - PACKAGES=`expr "$PACKAGES" : '\(.*\) .*'` || true - if [ ! "$THISPKG" ]; then - error "debian/control invalid - too many Architecture lines or too few Package lines" - fi - if [ "$ARCH" = "all" ]; then - INDEP_PACKAGES="$INDEP_PACKAGES $THISPKG" - else - ARCH_PACKAGES="$ARCH_PACKAGES $THISPKG" - fi - done - - if [ "$PACKAGES" ]; then - error "debian/control invalid - too many Architecure lines or too few Package lines" - fi - if [ "$DH_DOINDEP" ]; then - DH_DOPACKAGES="$DH_DOPACKAGES $INDEP_PACKAGES" - fi - if [ "$DH_DOARCH" ]; then - DH_DOPACKAGES="$DH_DOPACKAGES $ARCH_PACKAGES" - fi +# Remove leading spaces from DH_DOPACKAGES. +if expr "$DH_DOPACKAGES" : ' *.*' >/dev/null ; then + DH_DOPACKAGES_NEW=`expr "$DH_DOPACKAGES" : ' *\(.*\)'` fi # Check if packages to build have been specified, if not, fall back to -# the default, doing them all. Note that DH_DOPACKAGES may have a leading -# space and be empty otherwise. -if [ ! "$DH_DOPACKAGES" -o "$DH_DOPACKAGES" = " " ]; then +# the default, doing them all. +if [ ! "$DH_DOPACKAGES" ]; then if [ "$DH_DOINDEP" -o "$DH_DOARCH" ]; then error "I have no package to build." fi - DH_DOPACKAGES=`grep ^Package: debian/control | cut -d " " -f 2` + DH_DOPACKAGES=`grep ^Package: debian/control | cut -d " " -f 2 | tr "\n" " "` fi # Check to see if -P was specified. If so, we can only act on a single @@ -212,3 +232,19 @@ fi if [ "$DH_TMPDIR" ] && echo "$DH_DOPACKAGES" | egrep -q '.+ .+' ; then error "-P was specified, but multiple packages would be acted on." fi + +# Figure out which package is the first one we were instructed to build. +# This package gets special treatement, files and directories specified on +# the command line may effect it. +for PACKAGE in $DH_DOPACKAGES ; do + DH_FIRSTPACKAGE="$PACKAGE" + break +done + +# Check to see if: DH_FIRSTPACKAGE is not the MAINPACKAGE, and +# some command line arguemnts are passed. Display a warning, becuase +# debhelper's behaviour has changed in this case. +if [ "$DH_FIRSTPACKAGE" != "$MAINPACKAGE" -a "$*" ]; then + echo `basename $0`": Warning: my behavior has changed, and command line" >&2 + echo `basename $0`": arguments \"$*\" will apply to package \"$DH_FIRSTPACKAGE\"" >&2 +fi diff --git a/dh_suidregister b/dh_suidregister index e03379f..42e4d16 100755 --- a/dh_suidregister +++ b/dh_suidregister @@ -19,7 +19,7 @@ for PACKAGE in $DH_DOPACKAGES; do files=`tr "\n" " " < debian/${EXT}suid` fi - if [ "$PACKAGE" = "$MAINPACKAGE" -a "$*" ]; then + if [ "$PACKAGE" = "$DH_FIRSTPACKAGE" -a "$*" ]; then files="$* $files" fi -- 2.39.5