VOOZH about

URL: https://thenewstack.io/build-a-debian-deb-file-from-your-projects-source/

⇱ Build a Debian DEB File From Your Project’s Source - The New Stack


TNS
SUBSCRIBE
Join our community of software engineering leaders and aspirational developers. Always stay in-the-know by getting the most important news and exclusive content delivered fresh to your inbox to learn more about at-scale software development.
REQUIRED
It seems that you've previously unsubscribed from our newsletter in the past. Click the button below to open the re-subscribe form in a new tab. When you're done, simply close that tab and continue with this form to complete your subscription.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.
Welcome and thank you for joining The New Stack community!
Please answer a few simple questions to help us deliver the news and resources you are interested in.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Great to meet you!
Tell us a bit about your job so we can cover the topics you find most relevant.
REQUIRED
REQUIRED
REQUIRED
REQUIRED
REQUIRED
Welcome!

We’re so glad you’re here. You can expect all the best TNS content to arrive Monday through Friday to keep you on top of the news and at the top of your game.

What’s next?

Check your inbox for a confirmation email where you can adjust your preferences and even join additional groups.

Follow TNS on your favorite social media networks.

Become a TNS follower on LinkedIn.

Check out the latest featured and trending stories while you wait for your first TNS newsletter.

PREV
1 of 2
NEXT
VOXPOP
As a JavaScript developer, what non-React tools do you use most often?
Angular
0%
Astro
0%
Svelte
0%
Vue.js
0%
Other
0%
I only use React
0%
I don't use JavaScript
0%
Thanks for your opinion! Subscribe below to get the final results, published exclusively in our TNS Update newsletter:
NEW! Try Stackie AI
From clobbered drafts to real-time sync
Apr 14th 2026 10:00am, by David Moore
TypeScript 6.0 RC arrives as a bridge to a faster future
Mar 14th 2026 9:00am, by Darryl K. Taft
Mastra empowers web devs to build AI agents in TypeScript
Jan 28th 2026 11:00am, by Loraine Lawson
2024-05-05 06:00:05
Build a Debian DEB File From Your Project’s Source
Linux

Build a Debian DEB File From Your Project’s Source

If you are building a Linux application, creating a package for Debian distributions is a must. Here's how.
May 5th, 2024 6:00am by Jack Wallen
👁 Featued image for: Build a Debian DEB File From Your Project’s Source

If you’re a developer, at some point you might need to build a Debian package from your source. Of course, this means your project would have to have been developed for Linux in the first place, as you certainly won’t be able to build a Debian package from the source designed for either Windows or macOS. But if you’re developing for Linux and you want to create a Debian package, read on.

Your first question might be, “Why create a Debian package?” Well, Debian-based distributions are the most widely used flavors of Linux on the market. You’ll find Debian-based distributions powering desktops, servers, IoT, cloud and more. Plus, Ubuntu is based on the nonprofit Debian, so the need for building a DEB package file makes sense.

The good news is that it’s not nearly as hard as you might think. Even better, you won’t need too much in the way of dependencies to make it happen.

I’m going to walk you through the process of building a DEB file using the source from the Firefox web browser (which is version 125 as of this writing). When the process is complete, you’ll have a package you can install on on Debian-based distribution.

What You’ll Need

To do this, you’ll need the following things:

  • A Debian-based distribution from which to work
  • The Firefox source (which can be downloaded from the official Firefox download page)
  • A user account on the Linux machine

That’s it. Let’s get to the building.

Creating the Necessary Directories

First off, as long as you’re using a Debian-based distribution, you won’t have to install any dependencies or third-party software. The tool used for this process is dpkg-deb, which is a part of the base dpkg package.

To verify you have the required app, issue this command:

which dpkg-deb

If you see /usr/bin/dpkg-deb in the output, you have everything needed.

Next, make sure you’ve downloaded the Firefox source file, which will arrive as a BZ2 file. Save that in ~/Downloads. Open a terminal window and navigate to the ~/Downloads directory:

cd ~/Downloads

Decompress the Firefox file with this command:

bunzip2 firefox-XXX.tar.bz2

Note that XXX should be replaced with the release version number for Firefox.

This will decompress the file and leave you with a TAR archive. Extract that archive with:

tar xvf firefox-XXX.tar

XXX should be replaced with the Firefox release number.

You should now see a directory named firefox.

Our first subdirectory will be used to build the package. Create this directory:

mkdir -p firefox/opt/firefox-deb

Next, we have to create a directory named DEBIAN with the command:

mkdir firefox/DEBIAN

Now, we create a control file. The control file stores control data that specifies the metadata for the package (and can include dependencies and other information). The control file includes fields such as Package, Version, Maintainer, Description, Homepage, Architecture, Depends and more. Most of these fields will be obvious (even Depends, which lists dependencies required for the package).

There are two other (optional) files that can be included:

  • postinst: the post-install script
  • my.ini: any other files that can be included with the package

Create the control file with the following command:

nano firefox/DEBIAN/control

Once the file has been created, open it and paste the following:

Replace the uppercase placeholder text as follows:

  • NAME is your name.
  • EMAIL is your email address.
  • XXX is the version number you’re building.

Save and close the file.

We’ll now create a desktop file so Firefox can be started. Create yet another directory:

mkdir -p firefox/usr/share/applications/

Create the desktop file with this command:

nano firefox/usr/share/applications/firefox-deb.desktop

At a bare minimum, that file should look something like this:

[Desktop Entry]
Type=Application
Terminal=false
Exec=/home/wonko/myapps/firefox/firefox
Name=Firefox
Comment=Firefox
Icon=firefox
Categories=GNOME;GTK;Network;WebBrowser;

You can obviously edit that file as needed, adding languages and more. For more information on these files, you can read about the different desktop entry keys on this specifications page.

Save and close the file.

We can now build the package with this command:

dpkg-deb --build firefox

If you’re building specifically for Ubuntu, you’ll have to use Zstandard compression, which means the command would be:

dpkg-deb -Zgzip --build firefox

It’ll take a minute or so to complete, but when it does, you’ll find a file named firefox.deb on the current working directory. That DEB file is installable with the command:

sudo dpkg -i firefox.deb

You might also want to sign the package with your private GPG key (for security reasons). If you don’t have a GPG key, create one:

gpg --full-gen-key

You’ll be prompted to answer a few straightforward questions. Then, you’ll be required to type and verify a password for the key. Once you have your GPG created, you’ll need to install the required app:

sudo apt-get install dpkg-sig -y

Once that’s installed, sign the package with this command:

dpkg-sig --sign builder firefox.deb

You’ll be prompted for your GPG key password. Upon successful authentication, the package will be signed with you key.

You can now share the package with others and they can install it with ease.

And that, my friends, is how you build a Debian package from your source. I would suggest you try this out with the Firefox source so you can understand how it works. Once you’re confident in the process, give it a try with your own source and see how it goes.

TRENDING STORIES
Jack Wallen is what happens when a Gen Xer mind-melds with present-day snark. Jack is a seeker of truth and a writer of words with a quantum mechanical pencil and a disjointed beat of sound and soul. Although he resides...
Read more from Jack Wallen
SHARE THIS STORY
TRENDING STORIES
SHARE THIS STORY
TRENDING STORIES
TNS DAILY NEWSLETTER Receive a free roundup of the most recent TNS articles in your inbox each day.
The New Stack does not sell your information or share it with unaffiliated third parties. By continuing, you agree to our Terms of Use and Privacy Policy.