How to create deb package – part 2

Debian packaging is much more than just adding dependencies. It could be quite complex and challenging to learn but I guarantee that it will be very beneficail.

In this example, I would like to use dh_make to create blank Debian packaging templates. This contains basic template to use pre/post scripts, configuration which is very easy to start. However, this template assumes that you have source to build for the package but the example assumes that there is no source.

  1. Create directory with package name and version (version required)
  2. mkdir server-basic-1.0
  3. cd into the directory and run dh_make (refer to dh_make manual for details)
    • It creates a template directory called debian
  4. cd server-basic-1.0
    dh_make -s -n -e email@jakeyoon.com
  5. dh_make created a template debian and it contains all templates
  6. cd debian
    ls
  7. Modify rules file and comment out all line starting with $(Make) to suppress use of Makefile
    • dh_make creates a template assuming package is built from source
    • This example does not have Makefile since it is not built from source
    • Makefile is used when source has to be built prior to packaging
    emacs rules
    #$(MAKE)
    #-$(MAKE) clean
    #$(MAKE) DESTDIR=$(CURDIR)/debian/tns-server install
  8. Modify control file for package information and dependencies
  9. emacs control
    Source: server-basic
    Section: unknown
    Priority: extra
    Maintainer: Jake Yoon <email@jakeyoon.com>
    Build-Depends: debhelper (>= 5)
    Standards-Version: 3.7.2
    
    Package: server-basic
    Architecture: all
    Depends: openssh-server, ntp, snmpd, rsync, htop, iotop, less, tree
    Description: Basic Server Configuration
     Installs various basic services and its configuration.
  10. Build the package
  11. dpkg-buildpackage -b -rfakeroot -tc -uc -us
  12. Install the package
  13. dpkg -i basic-server-1.0_all.deb

Leave a Reply

Your email address will not be published. Required fields are marked *