Writing this for myself and others since most documentation online, official or otherwise, tend to make it look way more complicated than it really is.
-
Install the required packages:
$ sudo apt install build-essential devscripts dh-make lintian -
Fetch the source code:
$ wget https://example.com/path/to/pkgname/vx.y.z.tar.gz -
Unpack the source code:
$ tar xvf /path/to/your/vx.y.z.tar.gz -
Make sure the unpacked source code is in all lowercase
-
Change directory to the unpacked source code:
$ cd /path/to/your/pkgname-x.y.z -
Run this:
$ dh_make --native. Choosesfor arch-specific stuff,ifor arch-independent stuff (such as Node.js programs) -
This creates a
debian/subdirectory in the source code. Delete all files except the following indebian/(if the other files are required, we can add them back later):debian/changelogdebian/controldebian/copyrightdebian/rulesdebian/source/format
See also: https://www.debian.org/doc/manuals/maint-guide/dreq.en.html#rules
-
Modify the remaining files under
debian/accordingly -
Create a file
debian/<pkgname>.install. It has the following format:some/file path/to/destination/ some/folder/* path/to/destination/folder/ ... (e.g.) myexec usr/bin/ -
Ensuring your current directory is
/path/to/your/pkgname-x.y.z, run this:$ dpkg-buildpackage -us -uc -
A deb is generated in
/path/to/your/pkgname-x.y.z/... Lint the deb:$ lintian /path/to/your/pkgname_x.y.z_all.deb -
If the linting gave no errors and few warnings, you're done - enjoy :-)