Subject: GNU Makefile that generates Debian package directly

From: [email-masked] (Bruce Perens)
Date: Tue, 16 Jul 96 22:09 PDT

Here's another pass at a strategy for GNU Makefiles to generate Debian
packages directly. This one does not require that the base system contain
"make", it uses the shell to execute the preinst and postinst commands.
How does this look?

	Thanks

	Bruce

--- begin Makefile ---

prefix=/usr

# Flag to suppress informational messages from GNU Make.
NO_INFORMATIONAL=-s

# The install target is split into pre_install, install_files, and
# post_install. Install_files does everything you would not need to run
# on the target system.
# pre_install and post_install do things that need to run on the target,
# and they are constrained to be executable by
# the shell directly, and to use the restricted command set on our
# base system.

install: pre_install install_files post_install

pre_install:
	echo running pre_install

install_files:
	echo installing files into $(prefix)

post_install:
	echo running post_install

# The debian_binary target generates the Debian binary package.

debian_binary:
	- mkdir debian-tmp debian-tmp/DEBIAN debian-tmp/usr
	make prefix=debian-tmp/usr install_files
	echo "#!	/bin/sh" > debian-tmp/DEBIAN/preinst
	echo "#!	/bin/sh" > debian-tmp/DEBIAN/postinst
	make $(NO_INFORMATIONAL) -n pre_install >> debian-tmp/DEBIAN/preinst
	make $(NO_INFORMATIONAL) -n post_install >> debian-tmp/DEBIAN/postinst
	echo "exit 0" >> debian-tmp/DEBIAN/preinst
	echo "exit 0" >> debian-tmp/DEBIAN/postinst
	chmod 755 debian-tmp/DEBIAN/preinst debian-tmp/DEBIAN/postinst
	# ...
	
.FAKE: pre_install install_files post_install

--- end Makefile ---
--
The "Toy Story Animated Storybook" CD was the best selling software product
during the month of May, outselling the Windows '95 upgrade, Quicken, etc.
Bruce Perens AB6YM          [email-masked]            http://www.hams.com/

---

From: Manoj Srivastava <[email-masked]>
Date: 17 Jul 1996 14:04:27 -0400

Hi,

	If I understand this correctly, the pre and post install
 scripts are encapsulated in the debian.rules (using echo to generate
 the files). This gets rather tedious for large scripts^1, unless
 external files are used.  

	Even if we use external files (and use cat rather than echo),
 the current scripts expect to be called in a variety of different
 scenarios with different command line options^2. How do we introduce
 even a shadow of the complex dance  that dpkg dances in a makefile
 snippet?  Or am I missing the point entirely?

	manoj

^1 Script sizes: on my system the following holds:
----------------------------------------------------------------------
Number of lines in script                 Number of scripts
----------------------------------------------------------------------
  1 -   9					90
 10 -  99					84
100 - 199					 7
200 - 299					 4
300 - 399					 3
400+						 1
----------------------------------------------------------------------
					       189
----------------------------------------------------------------------
^2: Script options.
<new preinst> install
<new preinst> install <old-version>
<new preinst> upgrade <old-version>
<old preinst> abort-upgrade <new-version>

<postinst> configure <most-recently-configured-version>
<old postinst> abort-upgrade <new version>
<conflictor's postinst> abort-remove in-favour <package> <new version>
<deconfigured's postinst> abort-deconfigure \
              in-favour <package-being-installed-but-failed> <version>
              removing <conflicting-package> <version>

<prerm> remove
<old prerm> upgrade <new version>
<new prerm> failed-upgrade <old-vppersion>
<conflictor's prerm> remove in-favour <package> <new version>
<deconfigured's prerm> deconfigure \
              in-favour <package-being-installed> <version> \
              removing <conflicting-package> <version>

<postrm> remove
<postrm> purge
<old postrm> upgrade <new-version>
<new postrm> failed-upgrade <old-version>
<new postrm> abort-install
<new postrm> abort-install <old-version>
<new postrm> abort-upgrade <old-version>
<disappearer's postrm> disappear <overwriter> <new version>

-- 
 If the newspapers of a country are filled with good news, the jails
 will be filled with good people.  -- Daniel P. Monynihan
Manoj Srivastava               Systems Research Programmer, Project Pilgrim,
Phone: (413) 545-3918                A143B Lederle Graduate Research Center,
Fax:   (413) 545-1249         University of Massachusetts, Amherst, MA 01003
<[email-masked]> <URL:http://www.pilgrim.umass.edu/%7Esrivasta/>

---

From: Ian Jackson <[email-masked]>
Date: Fri, 19 Jul 96 22:04 BST

> "make", it uses the shell to execute the preinst and postinst commands.

Apart from the other problems people have pointed out, you can't just
take bits of makefile and sed them out into scripts.  The variable
substitution, change directory, error handling &c are all different.

Why not just have the scripts as separate files, called from the
makefile ?

Ian.