How do I make a Debian package?

To make a .deb package for use with Debian / Ubuntu:

$ sudo apt-get install devscripts debhelper

Rename the source tarball following the syntax package name_1.x.orig.tar.gz:

$ mv go1.3.src.tar.gz go_1.3.orig.tar.gz

Extract the tarball:

$ tar xf go_1.3.orig.tar.gz

Go into the source directory and create a “debian” subdirectory under it:

$ cd go
 $ mkdir debian

Create the “debian/source” directory and create “debian/source/format” with the Debian package format version:

../go$ mkdir debian/source
 ../go$ echo "3.0 (quilt)" > debian/source/format

Run “dch” to create an initial changelog file:

.../go$ dch --create -v 1.3-1 --package go

Create the “debian/compat” file:

../go$ echo 9 > debian/compat

Create the “debian/control” file:

Source: go
 Section: interpreters
 Priority: optional
 Maintainer: Eric Shalov <eric@ericshalov.com>
 Build-Depends: gcc-4.8
 Homepage: http://golang.org
Package: go
 Architecture: any
 Description: Go Programming Language

Make the “debian/rules” file (make sure to use a TAB before “dh”, not spaces):

$ vi debian/rules
#!/usr/bin/make -f
 %:
 dh $@

Make the “debian/copyright” file:

$ echo "" > debian/copyright

Build the package:

$ debuild -us -uc

Go up a directory and find the .deb file. Look at it’s contents:

../go$ cd ..
 $ dpkg -c go_1.3-1_amd64.deb
 drwxr-xr-x root/root 0 2014-08-20 23:59 ./
 drwxr-xr-x root/root 0 2014-08-20 23:59 ./usr/
 drwxr-xr-x root/root 0 2014-08-20 23:59 ./usr/share/
 drwxr-xr-x root/root 0 2014-08-20 23:59 ./usr/share/doc/
 drwxr-xr-x root/root 0 2014-08-20 23:59 ./usr/share/doc/go/
 -rw-r--r-- root/root 1 2014-08-20 23:37 ./usr/share/doc/go/copyright
 -rw-r--r-- root/root 161 2014-08-20 23:33 ./usr/share/doc/go/changelog.Debian.gz
 $
Share: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Twitter
  • Facebook
  • Google Bookmarks
  • LinkedIn
  • Reddit
  • StumbleUpon

Leave a Reply

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