How to create a .DEB Package/installer

It took a bit to figure it out, and this is by no means the best or only way to create a simple .deb package, There is a lot more to package creation, but I made it work very well for the simple desktop apps/packages I create for Debian/Gnome. This also works to make the app icon show up in the application menu and search. If I made mistakes or someone can provide additional inputs, please do.

Open a terminal (or use the GUI) and navigate to your home folder:
cd

create a working folder:
mkdir yourapp

In this folder create the following folders:

DEBIAN/
(place your control file here)
control

opt/yourapp/
(Put your ready build app folders here)
Libs folder
Resourses folders
app_iconlogo.xmp (128x128px)
yourapp executable

var/opt/yourapp/
(writeable database can be placed here)
yourapp.sqlite

(Make sure to correct app path to database. In my case I use the following:)
 SpecialFolder.Variable.Child("opt").Child("yourappfolder").Child("yourapp.sqlite")

usr/share/applications
(place your .desktop file here)
yourapp.desktop

In the /usr/share folder also create a /doc folder with /yourapp folder:

usr/share/doc/yourapp/
(in this folder you place the following files:)
authors (not necessary)
copyright
changelog (gzip file with --best option, =)
changelog.gz
changelog.debian (gzip file with --best option, =)
changelog.Debian.gz
README.Debian
NEWS.Debian (gzip file with --best option, =)
NEWS.Debian.gz

You can still get away with building the .deb without most of these files, but it’s recommended to add them and it’s good practice.

You don’t have to update NEWS.Debian files with every release, unless you have something particularly newsworthy for your users to know.

There are also the ‘man’ pages, but this is beyond my experience and so far has not been relevant for my desktop apps.

Once all your folders and files are created and files placed in the appropriate folders you can proceed to the final step.

Open a terminal and cd yourself to your home folder:
cd

now enter
dpkg --build yourapp

You should now have a file in your home folder called yourapp.deb

Either install from GUI with software installer or use the terminal:
sudo dpkg -i yourapp.deb


A few useful links:
https://tldp.org/HOWTO/html_single/Debian-Binary-Package-Building-HOWTO/
https://www.baeldung.com/linux/create-debian-package
https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-binarycontrolfiles
https://www.debian.org/doc/manuals/maint-guide/dother.en.html

1 Like