Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a Debian package as part of autotools build?

All of the Debian packaging examples I can find assume the user is re-packaging from an upstream build, so it unpacks a source tarball, configures, rebuilds, and re-packages. I'm trying to build a package for my own library, which is built using autotools. I've tried several different approaches, and my latest attempt looks like this:

DH_PACKAGE_NAME=`echo $(PACKAGE_NAME) | sed s/_/-/g`
dist-hook:
    cd $(distdir) ; \
    export DEBFULLNAME="Some One" ; \
    export DEBEMAIL="[email protected]" ; \
    echo -e "\n" | dh_make --copyright blank --library --native \
        --packagename $(DH_PACKAGE_NAME)
    mv $(distdir)/debian $(distdir)/DEBIAN
    dpkg-deb --build $(distdir)

for which dpkg-deb complains about dh_makes control file. I have an inkling the solution is something far simpler?

like image 490
CAB Avatar asked Oct 09 '12 21:10

CAB


People also ask

What is Debian source package?

A Debian source package contains the source material used to construct one or more binary packages. A source package consists of a . dsc file (see Debian source control files – . dsc), one or more compressed tar files, and possibly other files depending on the type and format of source package.


1 Answers

the entire packaging process is streamlined towards wrapping the build-process into the packaging-process. trying to wrap the packaging-process into the build-process is therefore probably not super easy, but i don't see a necessity to not do it the standard way.

so:

  • make your autotools based build-system as if you don't care about debian packages at all.
  • create a simple debian/rules file that will call your build-system and make a deb-package
  • if you (or some other user of your package) want(s) to build the deb, run dpkg-buildpackage
  • if you (or some other user of your package) does not want to build a deb, simply run ./configure && make && make install

this is better practice, as it keeps 2 separate stages (building and packaging) apart. it also allows more easy integration into any Debian-based distribution (should you e.g. decide that it would be great to have your package in "real" Debian), since Debian packaging guidelines are quite strict about keeping those two processes apart (upstream-sources that ship their own debian/ are frowned upon and upstream's debian/ is usually removed)

like image 191
umläute Avatar answered Sep 21 '22 02:09

umläute