Skip to content

Instantly share code, notes, and snippets.

@sp3c73r2038
Created January 17, 2014 03:24
Show Gist options
  • Save sp3c73r2038/8467878 to your computer and use it in GitHub Desktop.
Save sp3c73r2038/8467878 to your computer and use it in GitHub Desktop.
how to package a .deb.

debian packaging

references

install necessary tools

aptitude install build-essential devscripts dpkg-dev

if the package is using dh as packaging helper, then additional packages will be needed, such as

aptitude install dh-autoreconf # ...

.deb file

  • is a ar archive file. ar tv grep-2.14-4_amd64.deb
  • consists of
    • debina-binary: versionof the deb file format
    • control.tar.gz: metadata about the package
      • control, md5sums (pre|post)(rm|inst), triggers, shlibs
    • data.tar.gz: data files of the package

source packages

  • two kinds of packages, native and non-native, if unsure, us non-native
  • main file *.dsc (meta-data)
  • other files
    • pkg_ver.orig.tar.gz: upstream source
    • pkg_debver.debian.tar.gz: tarball with the debian changes

creating a basic source package

  • download the upstream source
  • rename to <source_package>_<upstream_version>.orig.tar.gz
  • untar it
  • rename the directory <source_package>-<upstream_version>
  • cd <source_package>-<upstream_version> && dh_make
  • debian/ created

files in debian/

  • main files
    • control: meta-data about the package
    • rules: specifies how to build the package (a plain Makefile!)
    • copyright: copyright info
    • changelog: history of the debian package
  • other files
    • compat
    • watch
    • dh_install* targets
      • *.dirs, *.docs, *.manpages ...
    • maintainer scripts
      • *.postinst, *.prerm ...
    • source/format
    • patches/ - if you need to modify the upstream source

debian/changelog

  • gives the current version of the package
  • 1.2.1.1-5
    • 1.2.1.1 => upstream version
    • 5 after hyphen => debian revision
  • create a changelog entry for a new release dch -i
    • or by hand!

debian/control

  • meta-data
  • package name, build-dependencies ...

Architecture: all or any (in debian/control)

  • packages with different contents on each Debian architechture
    • ex: C program
    • Architecture: any or Architecture: amd64 i386
    • named package_version_architecture.deb
  • packages with same contents on all architechtures
    • ex: Perl lib
    • Architecture: all
    • named package_version_all.deb

debian/rules

  • Makefile !!!
  • deciding how to build the packages
  • required targets
    • build, build-arch, build-indep: should perform all the configuration and compilation
    • binary, binary-arch, binary-indep: build the binary packages
      • dpkg-buildpackage will call binary to build all the packages
      • binary-arch to build only the Architecture: any packages
    • clean

Packagin helpers

  • debhelper
  • CDBS
  • dh for new package, use this !!

steps building packages

  1. aptitude build-dep foo: install the build-dependencies
  • or mk-build-deps -ir for package not uploaded yet (which depends on equivs)
  1. debuild: build, test with lintain, sign with GPG
  • or dpkg-buildpackage -us -uc directly
  1. more clean && minimal environment ? pbuilder, schroot + sbuild

** for some reason, you don't want to make test or make check, you can specify export DEB_BUILD_OPTIONS=nocheck in rules file, reference 1 2**

this will generates .deb files and a .changes file.

installing , testing , uploading packages

  • upload with dput
  • manage a private debian archive with reprepro

take grep as example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment