\documentclass[10pt,letterpaper]{article} % file: deb.pkgs.lat %\voffset -1.0in \hoffset -1.5in \pagestyle{empty} % \evensidemargin -0.65in\oddsidemargin -0.65in \setlength{\textwidth}{7.3in}\setlength{\textheight}{10in} \begin{document} \begin{center}\textbf{\large Building Debian Packages}\end{center} \begin{enumerate} \item Advantages of building Debian packages \begin{enumerate} \item Easy upgrades \item Leverage from following Debian standards \item Feedback via Debian bug system (\texttt{http://www.debian.org/Bugs}) \item Fame and free CDs \end{enumerate} \item{Considerations in building a package} \begin{enumerate} \item Examine the upstream source (README, INSTALL, Makefile, etc.) \item Is the license DFSG compliant (Debian Free Software Guidelines ---\\ \texttt{http://www.debian.org/social\_contract.html\#guidelines}) \item Use boilerplate (the mawk packaging is my best example) \item Install the debian-policy package and read /usr/doc/debian-policy \item Follow the Linux filesystem standard (\texttt{http://www.pathname.com/fhs}) \item Hint: use \texttt{make}(1)'s -n option \item Test the packaging: \begin{itemize} \item \texttt{ls -alR debian/tmp*} \item \texttt{dpkg -c ../new-pkg.deb} \item \texttt{dpkg -I ../new-pkg.deb} \item \texttt{dpkg -i ../new-pkg.deb} \end{itemize} \end{enumerate} \item{Example \texttt{debian/control} file} \begin{verbatim} Source: mawk Section: base Priority: required Maintainer: Chris Fearnley Standards-Version: 2.1.1.0 Package: mawk Architecture: any Provides: awk Depends: ${shlibs:Depends} Description: a pattern scanning and text processing language Mawk is an interpreter for the AWK Programming Language. The AWK language is useful for manipulation of data files, text retrieval and processing, and for prototyping and experimenting with algorithms. Mawk is a new awk meaning it implements the AWK language as defined in Aho, Kernighan and Weinberger, The AWK Programming Language, Addison-Wesley Publishing, 1988. (Hereafter referred to as the AWK book.) Mawk conforms to the Posix 1003.2 (draft 11.3) definition of the AWK language which contains a few features not described in the AWK book, and mawk provides a small number of extensions. . Mawk is smaller and much faster than gawk. It has some compile-time limits such as NF = 32767 and sprintf buffer = 1020. \end{verbatim} \newpage \item{Example \texttt{debian/rules}} \begin{verbatim} #!/usr/bin/make -f # file: debian/rules # Copyright 1994,1995 by Ian Jackson. # I hereby give you perpetual unlimited permission to copy, # modify and relicense this file, provided that you do not remove # my name from the file itself. (I assert my moral right of # paternity under the Copyright, Designs and Patents Act 1988.) # This file may have to be extensively modified # There used to be `source' and `diff' targets in this file, and many # packages also had `changes' and `dist' targets. These functions # have been taken over by dpkg-source, dpkg-genchanges and # dpkg-buildpackage in a package-independent way, and so these targets # are obsolete. package=mawk # The version of the package (for example, `19.28'). version=1.3.3 # The Debian revision of the package (for example, `2'). debian=1 make_directory= install -d -o root -g root -m 755 install_binary= install -s -o root -g root -m 755 install_script= install -o root -g root -m 755 install_files= install -o root -g root -m 644 CC = gcc CFLAGS = -O2 -g -Wall LDFLAGS = build: $(checkdir) @echo "Building the binaries ..." ./configure $(MAKE) CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" bash -n debian/postinst bash -n debian/prerm touch build clean: $(checkdir) @echo "Cleaning up after 'make build' ..." -rm -f build -$(MAKE) -i clean || $(MAKE) -f Makefile.in distclean -rm -f config.cache config.h config.log config.status Makefile man/index.db -rm -rf debian/tmp debian*~ debian/{substvars,files,files.new} binary-indep: checkroot build $(checkdir) @echo 'No architecture independend package components.'; false # There are no architecture-independent files to be uploaded # generated by this package. If there were any they would be # made here. \end{verbatim} \newpage \begin{verbatim} binary-arch: checkroot build $(checkdir) @echo "Making the binary package: $(package)-$(version)-$(debian).deb ..." rm -rf debian/tmp $(make_directory) debian/tmp/DEBIAN $(make_directory) debian/tmp/usr/bin $(make_directory) debian/tmp/usr/man/man1 $(make_directory) debian/tmp/usr/doc/$(package)/examples $(install_script) debian/{prerm,postinst} debian/tmp/DEBIAN/ $(install_binary) mawk debian/tmp/usr/bin/ $(install_files) CHANGES debian/tmp/usr/doc/$(package)/changelog $(install_files) debian/changelog debian/tmp/usr/doc/$(package)/changelog.Debian $(install_files) man/mawk.1 debian/tmp/usr/man/man1/ $(install_files) debian/copyright debian/tmp/usr/doc/$(package)/ $(install_files) examples/* debian/tmp/usr/doc/$(package)/examples/ gzip -9 debian/tmp/usr/{man/man1/mawk.1,doc/$(package)/{changelog,changelog.Debian,examples/*}} dpkg-shlibdeps mawk; dpkg-gencontrol chown -R root.root debian/tmp dpkg --build debian/tmp .. # Below here is fairly generic really. binary: binary-indep binary-arch dist-full: dpkg-buildpackage -rsudo -uc -us -sa @echo "You may run \"debian/rules clean\" to clean up after the build" dist-update: dpkg-buildpackage -rsudo -uc -us -sd @echo "You may run \"debian/rules clean\" to clean up after the build" dist: dist-full update: dist-update checkroot: $(checkdir) test root = "`whoami`" define checkdir test -f $(package).h -a -f debian/rules endef .PHONY: binary binary-indep binary-arch dist update clean checkroot \end{verbatim} \end{enumerate} \end{document}