Jules Bean wrote: >[about the various packaging helpers available] Maybe this is the right time to make my packaging helper available? (Yes, another packaging helper.)
I've been a Debian developer for about a year now, and I've been using my "generic debian/rules" for all my packages. I think it provides a reasonable balance between the desire to hide away the mundane stuff that's the same in every package, and the problems associated with having that mundane stuff hidden away from you. It also doesn't require a helper package to be installed in order to work. These rules are the result of factoring out the common package-independent commands from each of my packages' rules files. Since last year, I've been using this for all my packages, and haven't needed to modify it yet for any specific package. Recently, I built my first multi-binary package, ggi-stable, and this, too, worked with no changes to the rules. The things it does are: checks that debian/rules was invoked from the right place; checks that it's running as root, where necessary; ensures a uniform umask of 022 for the build process; creates and cleans up timestamp files, as appropriate; cleans up standard cruft from debian directory; ensures that everything in the install tree has ownership 0.0 and mode go-ws unless explicitly overridden; works out by itself which packages are architecture-independent and which are applicable to this architecture, and builds them in binary-arch or binary-indep, as appropriate; and runs dpkg-gencontrol and dpkg --build for you. All fairly boring run-of-the-mill stuff, and mostly stuff that you'll never want to change, but, across multiple packages, it adds up to quite a bit of duplicated text, and can be a source of errors (for example, some bugs are due to an arch "any" package becoming arch "all", but not being moved from "binary-arch" to "binary-indep" in debian/rules). (My debian/rules also used to run dpkg-geninfo, a script which builds "md5sums" and "du" control files, until I became enlightened and realised that these were just getting in the way of better solutions.) There is now nothing (AFAICT) in the generic rules pertaining to policy. This means that I'm not relying on a tool to implement policy for me, which might be considered a good thing. So, how are package-specific things done? They are all moved into a separate script, debian/process, which is called by debian/rules as needed. debian/process is another "#!/usr/bin/make -f" job, with these two primary targets: build: prepare and test files to be installed. Often just "make", possibly with a "./configure" beforehand. clean: revert a built package to its unbuilt state. Often just "make clean". It also has two more targets per binary package, in which $(ROOT) and $(CONTROL) can be used to refer to the install tree and the control area, respectively, of the package being built: install-<packagename>: construct the installation image for the binary package named <packagename>. This is where the real work normally goes. finalise-<packagename>: set up any unusual permissions or ownerships on particular files. Often empty. The only part of the build process run as root is finalise-*; everything else is unprivileged. This means anything with unusual ownership or permissions gets mentioned separately, so it's easy to see what binaries are being installed setuid, for example. dpkg-gencontrol is run just after install-*, so the finalise-* targets should not change the sizes of any files, or alternatively they should rerun dpkg-gencontrol. dpkg-gencontrol may also be rerun in finalise-* if you don't want the "-isp" option passed to it. All this enables debian/process to be very small and clean. Here's the file debian/process from "bock": #! /usr/bin/make -f Makefile: ./configure --prefix=/usr build: Makefile make make check clean: if test -e Makefile; then make distclean; fi install-bock: make prefix=$(ROOT)/usr install $(RM) $(ROOT)/usr/doc/bock/COPYING dpkg-shlibdeps -pbock $(ROOT)/usr/bin/* finalise-bock: I find this far easier to follow than the normal debian/rules style, where the build and install rules tend to be mixed together with lots of control flow mechanics. (Incidentally, the "-pbock" option to dpkg-shlibdeps is given to match "debian/control", which contains the line: Depends: ${bock:Depends} This style is needed for multi-binary packages.) Another example, this time from "wenglish": #!/usr/bin/make -f build: (gzip -cd words.english.gz; cat debian/additional-words) | \ sort -df > english clean: rm -f english install-wenglish: install -d $(ROOT)/usr/dict install -m 644 english $(ROOT)/usr/dict/english install -d $(ROOT)/usr/man/man5 install -m 644 words.5 $(ROOT)/usr/man/man5/english.5 install -d $(ROOT)/usr/doc/wenglish install -m 644 debian/changelog \ $(ROOT)/usr/doc/wenglish/changelog.Debian gzip -9n $(ROOT)/usr/doc/*/* $(ROOT)/usr/man/man?/* install -m 644 debian/copyright $(ROOT)/usr/doc/wenglish install -m 755 debian/postinst debian/prerm debian/postrm $(CONTROL) finalise-wenglish: The one from "ggi-stable" might be worth looking at, too, because it's a multi-binary. It is rather long (so I won't include it here), but it's still pretty easy to see what it's doing; the length is mainly due to the number of individual files it installs. It might be worth bearing in mind that, while I maintain quite a number of packages, and use this script in them, most of them are rather simple. "ggi-stable" is my only multi-binary package, and "strn" is the only other package which is at all complex, packaging-wise. That said, it does work for me. Please let me know if you find it useful. ============================================================================= total revisions: 11; selected revisions: 11 description: cpb4's generic debian/rules file. ---------------------------- revision 1.11 date: 1998/08/18 13:43:05; author: cpb4; state: Exp; lines: +13 -6 Pass CONTROL to debian/process; points to control file area. ---------------------------- revision 1.10 date: 1998/02/20 02:40:03; author: cpb4; state: Exp; lines: +1 -6 Remove call to dpkg-geninfo following debian-policy discussion on md5sums and du files. ---------------------------- revision 1.9 date: 1998/02/09 02:22:43; author: cpb4; state: Exp; lines: +3 -2 Include text of clean-install-tree target directly in cpbs-install-tree target, to prevent gratuitous rebuilding of install tree. ---------------------------- revision 1.8 date: 1998/02/01 00:35:45; author: cpb4; state: Exp; lines: +6 -2 Add support for putting dpkg-geninfo in the debian/ directory. ---------------------------- revision 1.7 date: 1997/12/04 00:36:24; author: cpb4; state: Exp; lines: +4 -5 Couple of clean-ups. ---------------------------- revision 1.6 date: 1997/12/03 21:41:55; author: cpb4; state: Exp; lines: +15 -13 Don't touch 'build', it was doing nothing useful. Set umask to 022 when doing anything significant. Add 'cpbs-' to start of touched checkpoint files to ensure they don't clash with anything else. ---------------------------- revision 1.5 date: 1997/09/24 09:11:11; author: cpb4; state: Exp; lines: +10 -7 Directory checks now look for debian/process as well as debian/rules. Added chmod +x debian/process at strategic points. ---------------------------- revision 1.4 date: 1997/09/24 01:54:30; author: cpb4; state: Exp; lines: +4 -4 Fixed withecho bug (not quoting $s in Makefiles...) ---------------------------- revision 1.3 date: 1997/09/24 01:28:50; author: cpb4; state: Exp; lines: +19 -16 added 'withecho', nicked from dpkg-buildpackage ---------------------------- revision 1.2 date: 1997/09/23 23:14:26; author: cpb4; state: Exp; lines: +2 -3 removed dud get-orig-source entry in help text ---------------------------- revision 1.1 date: 1997/09/23 23:10:40; author: cpb4; state: Exp; Initial revision ============================================================================= ============================================================================= #! /usr/bin/make -f # Generic debian/rules # Written by Charles Briscoe-Smith, 1997-8 # Contributed to the public domain # $Id: rules,v 1.11 1998/08/18 13:43:05 cpb4 Exp $ default: @echo "Specify a target:" @echo " build compile it" @echo " binary make all binary packages" @echo " binary-{arch,indep} make subset of all binary packages" @echo " clean clean up all but files generated for upload" @echo " clean-install-tree clean up under debian/ but not otherwise" # Build the package and prepare the install tree build: cpbs-install-tree cpbs-install-tree: cpbs-do-build @[ -f debian/process -a -f debian/rules ] rm -rf debian/tmp* debian/files* debian/substvars @set -e; \ umask 022; \ withecho () { echo " $$@" >&2; "$$@"; }; \ for package in `sed -n '/^Package: /{;s/^Package: \+\([a-zA-Z0-9][a-zA-Z0-9+.-]\+\) *$$/\1/;h;};/^Architecture: .*\(any\|all\|'\`dpkg --print-architecture\`'\)/{;g;p;}' < debian/control` ; do \ withecho install -d debian/tmp-$$package/DEBIAN; \ withecho debian/process install-$$package \ ROOT=`pwd`/debian/tmp-$$package \ CONTROL=`pwd`/debian/tmp-$$package/DEBIAN; \ withecho dpkg-gencontrol -isp -p$$package \ -Pdebian/tmp-$$package; \ done touch cpbs-install-tree cpbs-do-build: @[ -f debian/process -a -f debian/rules ] chmod +x debian/process umask 022; debian/process build touch cpbs-do-build # Build package files binary: binary-arch binary-indep binary-arch: check-root build @[ -f debian/process -a -f debian/rules ] @set -e; \ umask 022; \ withecho () { echo " $$@" >&2; "$$@"; }; \ for package in `sed -n '/^Package: /{;s/^Package: \+\([a-zA-Z0-9][a-zA-Z0-9+.-]\+\) *$$/\1/;h;};/^Architecture: .*\(any\|'\`dpkg --print-architecture\`'\)/{;g;p;}' < debian/control` ; do \ withecho chown -R 0.0 debian/tmp-$$package; \ withecho chmod -R go-ws debian/tmp-$$package; \ withecho debian/process finalise-$$package \ ROOT=`pwd`/debian/tmp-$$package \ CONTROL=`pwd`/debian/tmp-$$package/DEBIAN; \ withecho dpkg-deb --build debian/tmp-$$package ..; \ done binary-indep: check-root build @[ -f debian/process -a -f debian/rules ] @set -e; \ umask 022; \ withecho () { echo " $$@" >&2; "$$@"; }; \ for package in `sed -n '/^Package: /{;s/^Package: \+\([a-zA-Z0-9][a-zA-Z0-9+.-]\+\) *$$/\1/;h;};/^Architecture: .*all/{;g;p;}' < debian/control` ; do \ withecho chown -R 0.0 debian/tmp-$$package; \ withecho chmod -R go-ws debian/tmp-$$package; \ withecho debian/process finalise-$$package \ ROOT=`pwd`/debian/tmp-$$package \ CONTROL=`pwd`/debian/tmp-$$package/DEBIAN; \ withecho dpkg-deb --build debian/tmp-$$package ..; \ done check-root: @[ `id -u` = 0 ] || (echo "You must be root to do this!"; false) # Clean up afterwards clean: clean-install-tree @[ -f debian/process -a -f debian/rules ] rm -f cpbs-do-build chmod +x debian/process umask 022; debian/process clean clean-install-tree: @[ -f debian/process -a -f debian/rules ] rm -f cpbs-install-tree rm -rf debian/tmp* debian/files* debian/substvars ============================================================================= -- Charles Briscoe-Smith White pages entry, with PGP key: <URL:http://alethea.ukc.ac.uk/wp?95cpb4> PGP public keyprint: 74 68 AB 2E 1C 60 22 94 B8 21 2D 01 DE 66 13 E2