With the Debian directory ready, you should be able to build the package now. This guide focuses on building unsigned, signed, binary, and source packages; install package to test run; and removing test package. As per guide, you can use various methods to build your package. In this guide however, we'll be using the commonly used tool: debuild.
You must not assume the deb package is working fine. Follow the New Maintainer Guide clearly.
Before building, you must assemble the package directory properly. Otherwise, the build fails. You need to create a directory in this format:
<package name>-<version>Example:
fennec-0.5.0Copy all the files into this folder, including the Debian directory. Ensure the changelog is updated.
Now, let's build the unsigned binary package for testing. Get into the package directory and execute the debuild instruction.
$ cd <package name>-<version>$ debuild -us -ucIf you're using a custom Lintian profile or data, then append the Lintian argument as well. Here's an example:
$ debuild -us -uc --lintian-opts --include-dir /path/to/lintian-data --profile ubuntuKeep in mind that there is a argument order for debuild tool. Read its help instruction for more details. As you build, watch for Lintian warning. Example:
dpkg-buildpackage -rfakeroot -us -ucdpkg-buildpackage: info: source package fennecdpkg-buildpackage: info: source version 0.5.0+debiandpkg-buildpackage: info: source distribution stabledpkg-buildpackage: info: source changed by ZORALab Enterprise <tech@zoralab.com> dpkg-source --before-build fennec-0.5.0dpkg-buildpackage: info: host architecture amd64 fakeroot debian/rules cleandh clean dh_testdir dh_auto_clean dh_clean dpkg-source -b fennec-0.5.0dpkg-source: info: using source format '3.0 (native)'dpkg-source: info: building fennec in fennec_0.5.0+debian.tar.xzdpkg-source: info: building fennec in fennec_0.5.0+debian.dsc debian/rules builddh build dh_testdir dh_update_autotools_config dh_auto_configure debian/rules override_dh_auto_buildmake[1]: Entering directory '/home/holloway/src/gitlab.com/zoralab/fennec/tmp/fennec-0.5.0'mv fennec.sh fennecmake[1]: Leaving directory '/home/holloway/src/gitlab.com/zoralab/fennec/tmp/fennec-0.5.0' dh_auto_test create-stamp debian/debhelper-build-stamp fakeroot debian/rules binarydh binary create-stamp debian/debhelper-build-stamp dh_testroot dh_prep dh_auto_install dh_install dh_installdocs dh_installchangelogs dh_installman dh_perl dh_link dh_strip_nondeterminism dh_compress dh_fixperms dh_installdeb dh_gencontroldpkg-gencontrol: warning: Depends field of package fennec: unknown substitution variable ${shlibs:Depends} dh_md5sums dh_builddebdpkg-deb: building package 'fennec' in '../fennec_0.5.0+debian_all.deb'. dpkg-genbuildinfo dpkg-genchanges >../fennec_0.5.0+debian_amd64.changesdpkg-genchanges: info: including full source code in upload dpkg-source --after-build fennec-0.5.0dpkg-buildpackage: info: full upload; Debian-native package (full source is included)Now running lintian...Finished running lintian.Successfully signed dsc, buildinfo, changes filesIf you see something as above, it means you built a clean and proper package. If you see something like:
Now running lintian...E: fennec source: invalid-standards-version 0.5.0Finished running lintian.It means your package has invalid values or settings. You should search the Lintian tag in the list, study it properly, and then fix it accordingly. There are 3 main types of responses:
E - stands for error. You must fix this issue.W - stands for warning. You're recommended to fix this issue. I - stands for info. Minor issue like spelling or wording detected. It's best to fix it.By common practice, there shouldn't be any reporting issues.
If there is no critical issue detected by the Lintian, you should get the packages right next to the package directory. Here is an example:
tmp├── fennec-0.5.0├── fennec_0.5.0+debian_all.deb├── fennec_0.5.0+debian_amd64.build├── fennec_0.5.0+debian_amd64.buildinfo├── fennec_0.5.0+debian_amd64.changes├── fennec_0.5.0+debian.dsc└── fennec_0.5.0+debian.tar.xzUnless you're building for different architecture with explicit instruction, this is good enough for testing your package settings. To test the package. Simply use dpkg instruction to install the compiled deb package. Following the example above, the instruction should be like:
$ sudo dpkg -i tmp/fennec_0.5.0+debian_all.debThese are the things you should observe:
$ sudo apt install -i" to install those dependencies.debian/install is moved correctly.If all things are good. You can proceed to the next stage.
Don't panic. Fix the issue, update the changelog and recompile again. With the new version, use --force-overwrite argument to force install the new version. Example command:
$ sudo dpkg -i --force-overwrite tmp/fennec_0.5.1+debian_all.debKeep doing it until you fix all the installation issue.
Once you've tested the installation process, it's time to uninstall it. Use dpkg --remove command to remove your test package. Following the example above (my package name is fennec), you should have:
$ sudo dpkg --remove fennecThese are the things you need to check:
debian/install removed cleanly?Don't panic. Fix the issue, update the changelog and recompile again. Force-overwrite the new installation and test the uninstall process again. If all else still fails, DON'T UPSTREAM IT. To clean up your system use this nuclear command as your last option:
$ sudo dpkg --remove --force-remove-reinstreq fennecIf you have an earlier version of your package, you should install it now. Then use dpkg to install the latest version you had built. This is for testing the updating process. YOU MUST NOT FAIL THIS PROCESS. Almost all the software life-cycle depends on this update process.
Don't panic, follows the Install and Uninstall sections above until you fix the issue.
Now that we have our package tested and cleared the known bugs, it's time to build the signed version. You'll need to setup your private GnuPG key that has its public key synchronized with your upstream server. Once done, you can:
-k argument instead to state the use of GnuPG signing.The command, following the example above, should be as follows depending on whether the usage of custom Lintian data and profile:
$ debuild -k[MYGPGID]$ debuild -k[MYGPGID] --lintian-opts --include-dir /path/to/lintian-data --profile ubuntuThis builds the signed binary version. Run all the test again to test it is working fine. You shouldn't be facing too much obstacles by now.
Most open-source upstream server wants source-only package. This means that they're looking for .changes file, not .deb. In this case, since our package is now cleared of installation, update, uninstall process bugs, we can safely build the source only package. You can:
-S after -k argument. It stands for source-only.The command, following the example above, should be as follows depending on your usage for custom Lintian data and profile:
$ debuild -k[MYGPGID] -S$ debuild -k[MYGPGID] -S --lintian-opts --include-dir /path/to/lintian-data --profile ubuntuIf you did not remove your previous signed binary package artifact, the output should be:
tmp/├── fennec-0.5.0├── fennec_0.5.0+debian_all.deb├── fennec_0.5.0+debian_amd64.build├── fennec_0.5.0+debian_amd64.buildinfo├── fennec_0.5.0+debian_amd64.changes├── fennec_0.5.0+debian.dsc├── fennec_0.5.0+debian_source.build├── fennec_0.5.0+debian_source.buildinfo├── fennec_0.5.0+debian_source.changes└── fennec_0.5.0+debian.tar.xzYou should see that there are extra _source files and a .changes. These are the files (bolded) open-source upstream server is looking for. They will rebuild your package based on the received changes.
That's all about builds. If no error occurs during testing for all 3 builds, congratulations! You had successfully built your first deb software package.
Beyond this topic are advanced options, like customizing the debian/rules build rules and adding pre/post install/remove scripts for your package.