[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

RFC: New source packaging format



Hi all,

I've just repackaged hello using my new proposed source packaging
scheme which does away with dpkg-source and uses just dpkg and 
standard .deb files instead.

You can grab the files from:

 ftp://ftp.jimpick.com/pub/debian/experimental/hello/

      444 Oct 22 14:49 README
    17506 Oct 22 14:42 hello_1.3-13.1_i386.deb
     4306 Oct 22 14:53 src-deb-hello_1.3-1.1_all.deb
    88758 Oct 22 14:54 src-orig-hello_1.3-1_all.deb

To compile:

Install the src-deb-hello_1.3-1.1_all.deb and 
 src-orig-hello_1.3-1_all.deb files, then make a directory somewhere 
 and execute:

sudo make -f /usr/src/debian/src-deb-hello/Makefile binary finaldebdir=.

(note: you don't have to be root)

This will create the hello_1.3-1.1_i386.deb binary package.

Then you can use:

sudo make -f /usr/src/debian/src-deb-hello/Makefile debclean

to clean up.

Unfortunately, fakeroot doesn't work for some reason.  I suspect that
fakeroot could be fixed.

Here are the contents of the upstream src-orig-hello file:
-- cut here --
 new debian package, version 2.0.
 size 88758 bytes: control archive= 313 bytes.
     231 bytes,     9 lines      control              
 Package: src-orig-hello
 Version: 1.3-1
 Architecture: all
 Maintainer: Jim Pick <jim@jimpick.com>
 Source: upstream
 Description: Upstream source code for GNU hello
  This source was retrieved from:
  .
    ftp://prep.ai.mit.edu/pub/gnu/
 drwxr-xr-x jim/jim           0 1997-10-22 11:51 ./
drwxr-xr-x jim/jim           0 1997-10-22 11:51 usr/
drwxr-xr-x jim/jim           0 1997-10-22 11:51 usr/src/
drwxr-xr-x jim/jim           0 1997-10-22 11:51 usr/src/debian/
drwxr-xr-x jim/jim           0 1997-10-22 11:53 usr/src/debian/src-orig-hello/
-rw-r--r-- jim/jim       87942 1993-05-22 18:41 usr/src/debian/src-orig-hello/hello-1.3.tar.gz
-- cut here --

See, not much there.  Nor should there be.  The key thing is that it
installs the source tarball into a predictable place - and the control
file contains useful information about where the file came from, and
who put it together.

Here are the contents of the debian-specific src-deb-hello file:
-- cut here --
 new debian package, version 2.0.
 size 4306 bytes: control archive= 286 bytes.
     242 bytes,     8 lines      control              
 Package: src-deb-hello
 Version: 1.3-1.1
 Architecture: all
 Maintainer: Jim Pick <jim@jimpick.com>
 Source: debian-specific
 Depends: src-orig-hello
 Description: Debian-specific source code for GNU hello
  Debian-specifc source code for GNU hello
 drwxr-xr-x jim/jim           0 1997-10-22 12:02 ./
drwxr-xr-x jim/jim           0 1997-10-22 12:02 usr/
drwxr-xr-x jim/jim           0 1997-10-22 12:02 usr/src/
drwxr-xr-x jim/jim           0 1997-10-22 12:02 usr/src/debian/
drwxr-xr-x jim/jim           0 1997-10-22 14:36 usr/src/debian/src-deb-hello/
-rw-r--r-- jim/jim        2741 1997-10-22 14:36 usr/src/debian/src-deb-hello/Makefile
-rw-r--r-- jim/jim        2721 1997-10-22 14:36 usr/src/debian/src-deb-hello/changelog
-rw-r--r-- jim/jim         598 1997-10-22 14:36 usr/src/debian/src-deb-hello/control
-rw-r--r-- jim/jim        2412 1997-10-22 14:36 usr/src/debian/src-deb-hello/copyright
-rw-r--r-- jim/jim         122 1997-10-22 14:36 usr/src/debian/src-deb-hello/hello.postinst
-rw-r--r-- jim/jim          68 1997-10-22 14:36 usr/src/debian/src-deb-hello/hello.prerm
-- cut here --

You will notice that this is essentially the same thing that goes into
the debian directory in a convention debian source package.

I've done several things:

 * It is no longer in a subdir off of the base where the upstream source
   gets unpacked.
 * The debian/rules file is now just called Makefile (a bit less scary to
   the uninitiated)
 * I prefixed the postinst and prerm with the name of the binary package
   they are supposed to go into.  It's not absolutely necessary, but I
   prefer this when it comes to making multi-binary packages.  (I'm a
   neat freak)
 * !!! A source depedency !!! - well not really, it's just the same old
   dependencies we always had.  But you can't install this package using
   dpkg unless you also have src-orig-hello installed (or you override).
   The cool thing is that this package could also declare a dependency to
   a binary package (ie. say it needed debmake).

OK.  Let's look at the Makefile (formerly debian/rules) where the action occurs:
-- cut here --
#!/usr/bin/make -f
# Sample debian.rules file - for GNU Hello (1.3).
# 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

# This has been severely modified by Jim Pick to demonstrate a
# new source packaging scheme

SHELL=/bin/sh
  
package=hello
srcdebiandir=/usr/src/debian
topbuilddir=$(shell pwd)
srcdebdir=$(srcdebiandir)/src-deb-hello
finaldebdir=..

build:	unpack
	$(checkdir)
	(cd $(topbuilddir)/hello.src; \
	 ./configure --prefix=/usr; \
	 $(MAKE) CFLAGS=-O2 LDFLAGS= ; \
	)
	touch build

unpack: 
	cd $(topbuilddir)
	-rm -rf hello.src
	tar xzvf $(srcdebiandir)/src-orig-hello/hello-1.3.tar.gz
	mv hello-1.3 hello.src
	touch unpack

clean:
	cd $(topbuilddir)
	-rm -f build unpack
	-(cd hello.src; \
	 -$(MAKE) -i distclean || $(MAKE) -f Makefile.in distclean; \
	)
	-rm -rf *~ hello.build files* hello.substvars files

debclean: clean
	cd $(topbuilddir)
	-rm -rf hello.src

binary-indep:	checkroot build
	$(checkdir)
# There are no architecture-independent files to be uploaded
# generated by this package.  If there were any they would be
# made here.

binary-arch:	checkroot build
	$(checkdir)
	cd $(topbuilddir)
	-rm -rf hello.build
	install -d hello.build/DEBIAN
	install -d hello.build/usr/doc/$(package)
	cp $(srcdebdir)/hello.postinst hello.build/DEBIAN/postinst
	cp $(srcdebdir)/hello.prerm hello.build/DEBIAN/prerm
	chmod +x hello.build/DEBIAN/{postinst,prerm}
	(cd hello.src; \
	 $(MAKE) CFLAGS=-O2 LDFLAGS=-s INSTALL_PROGRAM='install -c -s' \
		prefix=$(topbuilddir)/hello.build/usr install ; \
	)
	gzip -9v hello.build/usr/info/*
	cp $(srcdebdir)/copyright hello.build/usr/doc/$(package)/.
	cp $(srcdebdir)/changelog hello.build/usr/doc/$(package)/changelog.Debian
	cp hello.src/ChangeLog hello.build/usr/doc/$(package)/changelog
	gzip -9v hello.build/usr/doc/$(package)/changelog{,.Debian}
	dpkg-shlibdeps -Thello.substvars hello.build/usr/bin/hello
	dpkg-gencontrol -phello -Phello.build -Thello.substvars \
	    -c$(srcdebdir)/control -l$(srcdebdir)/changelog -ffiles
	chown -R root.root hello.build
	chmod -R g-ws hello.build
	dpkg --build hello.build $(finaldebdir)

define checkdir
	(cd $(srcdebdir); test -f Makefile -a -f control -a -f changelog)
endef

# Below here is fairly generic really

binary:		binary-indep binary-arch

source diff:
	@echo >&2 'source and diff are obsolete - use dpkg-source -b'; false

checkroot:
	$(checkdir)
	test root = "`whoami`"

.PHONY: binary binary-arch binary-indep clean debclean checkroot
-- cut here --

Ok it's mostly the same, except for a few small differences:

 * I made some useful defines at the top, specifically:
    
  srcdebiandir=/usr/src/debian  # The predefined place where source 
    # packages are put on the system.  Only root can install source 
    # packages here (using dpkg).  But a user can install the source 
    # elsewhere using dpkg-deb --extract, and then call 
    # make srcdebiandir=xxxx to override the source location.
  topbuilddir=$(shell pwd)  # where the source is unpacked and 
    # temporary files are put - this defaults to the current
    # directory but can be easily override by supplying a 
    # parameter to make (ie. you might have a prefered temp dir) 
  srcdebdir=$(srcdebiandir)/src-deb-hello  # Just the location of 
    # this particular package.
  finaldebdir=..  # Where you want the final .deb containing 
    #the binary files to land.  Perhaps this should default to "."

 * The default rule is build.  Seems like a good starting point.
 
 * An additional rule: unpack - pretty clear what this does.  Source 
    is kept in packed up tarballs in the source packages, and is only 
    unpacked on a temporary basis under the $(topbuilddir) which
    is usually the current directory owned by the user making the 
    package.  There is no reason to unpack things in the same 
    directory as the debian-specific files (as we currently do now).
    In this example, I unpacked to a directory called hello.src -
    that just me being a neat freak again.

    So the upstream source can be anything (ie. .src.rpm's), since
    the packaging system doesn't unpack them - only the rules the
    maintainer puts into the Makefile really matter.

 * OK, I didn't do this since hello didn't need to be patched.  But
   if it did - I was just add another step to unpack (or maybe even
   a new rule) which would just apply a patch located in 
   $(srcdebdir) or below to the unpacked source.  Yes, Virginia,
   you can include debian-specific binary files using this
   source packaging format.
   
 * Another additional rule: debclean - just calls make clean and
    additionally nukes the temporary source directory created by
    unpack. 

 * The binary rules installs everything into a temporary subdir
   called hello.build.  I'm just being neat again.
 
The rest of it is pretty standard.  Additional parameters needed to
be given to dpkg-shlibdeps and dpkg-gencontrol since I am no longer
using the default locations for the control, files, and changelog
files.

The only thing missing from the mix was the utilities for creating
source packages automatically.  I just created a directory structure
and control file by hand, and used dpkg-deb --create to make them.
It was really easy, since the source packages are extremely
unsophisticated.

OK, that's it.  Tell me how you like it.  I know I like it.  :-)

Cheers,

 - Jim



Attachment: pgpivJpQSzitt.pgp
Description: PGP signature


Reply to: