Joachim Breitner's Homepage
Creating a Debian source package without unpacking the source
There may be a situation where you want to create a Debian source package without having to unpack the upstream source. One case is where you store your debian/
directory in a version control system of its own and to build your package, you pass the .dsc
file to a tool like pbuilder or some remote builder. Now a modern debian source package is just a text file (the .dsc
file) that references two tarballs, one being the upstream source and the other being the Debian directory. Thanks to Niels Thykier on #debian, I found the magic invocation of dpkg-source
that allows you to create the .dsc
directly from the two tarballs, the control file and the changelog:
> apt-get source --download-only -t experimental haskell-mtl Reading package lists... Done Building dependency tree Reading state information... Done NOTICE: 'haskell-mtl' packaging is maintained in the 'Darcs' version control system at: http://darcs.debian.org/darcs/pkg-haskell/haskell-mtl Need to get 18.8 kB of source archives. Get:1 http://http.debian.net/debian/ experimental/main haskell-mtl 2.1.2-1 (dsc) [1616 B] Get:2 http://http.debian.net/debian/ experimental/main haskell-mtl 2.1.2-1 (tar) [13.7 kB] Get:3 http://http.debian.net/debian/ experimental/main haskell-mtl 2.1.2-1 (diff) [3509 B] Fetched 18.8 kB in 0s (22.3 kB/s) Download complete and in download only mode > cp ./haskell-mtl_2.1.2-1.dsc ./haskell-mtl_2.1.2-1.dsc-orig > tar xzf haskell-mtl_2.1.2-1.debian.tar.gz > dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" -b / haskell-mtl_2.1.2.orig.tar.gz haskell-mtl_2.1.2-1.debian.tar.gz dpkg-source: info: using source format `3.0 (custom)' dpkg-source: info: building haskell-mtl in haskell-mtl_2.1.2-1.dsc > diff -u haskell-mtl_2.1.2-1.dsc haskell-mtl_2.1.2-1.dsc-orig --- haskell-mtl_2.1.2-1.dsc 2012-10-13 15:09:00.031695856 +0200 +++ haskell-mtl_2.1.2-1.dsc-orig 2012-10-13 15:08:47.267696329 +0200 @@ -1,3 +1,6 @@ +-----BEGIN PGP SIGNED MESSAGE----- +Hash: SHA1 + Format: 3.0 (quilt) Source: haskell-mtl Binary: libghc-mtl-dev, libghc-mtl-prof, libghc-mtl-doc @@ -23,3 +26,11 @@ Files: 943c110524d96126bfa0e61f7df1ebcd 13723 haskell-mtl_2.1.2.orig.tar.gz dda5ded58a8d009ecddeed68058ca787 3509 haskell-mtl_2.1.2-1.debian.tar.gz + +-----BEGIN PGP SIGNATURE----- +Version: GnuPG v1.4.12 (GNU/Linux) + +iEYEARECAAYFAlBzRQIACgkQ9ijrk0dDIGwymwCfW87jwCv5ZvAXPBwh0LbvYLP9 +n+wAn3TCJwPRuBDEWRYmcv3Opn1Kb9+F +=/Llc +-----END PGP SIGNATURE-----
As you can see, the resulting .dsc
file is identical to the original one, so this approach works. The parameter to -b
does not matter as long as it is some existing directory. Of course you can easily shoot yourself and others in the foot, almost as easily as hand-editing the .dsc
file... but if you know what you are doing, then this can be quite handy.
Next to do: Write a tool that takes an unpacked Debian directory as an argument, packs it, finds the original tarball using uscan and creates the .dsc
file. Would this be something that people would want in the devscripts package?
Comments
Have something to say? You can post a comment by sending an e-Mail to me at <mail@joachim-breitner.de>, and I will include it here.
People should review what is included in the upstream before they create/upload a source package. So I think having something like this in devscripts is not too useful.