Check source freedom
Some of these tutorials may refer to nonfree software. Make sure to check the freedom of the source code or application before following any external tutorial.
Building a deb Package
- Building a deb Package
- Installing required Programs
- Building a new .deb Package
- Modifying an Existing .deb Package
- Official Guides for Building & Packaging
- Building Custom Kernels
Installing required Programs
To handle packages, you need to install some programs:
sudo apt-get install debhelper dh-make dpkg-dev
Building a new .deb Package
Downloading and Extracting
First, check if the program is free!
Then, if it is or if there is not enough information on the program's website, download the program you want to build:
Extract the program source code from the archive:
tar -xzf program.tar.gz
tar -xjf program.tar.bz2
Generate "debian" Hierarchy
You may want to keep your full name and email address from package to package. In that case, add the following lines to your ~/.bashrc:
export DEBFULLNAME="Joe Black" export DEBEMAIL="firstname.lastname@example.org"
cd inside the extracted folder:
Check if the program is free! Sometimes, the license inside the source code is different from the one stated on the program's website, in that case file a bug on the program's website.
Remove unneeded files:
cd debian rm unneeded-files
To convert your package to "quilt v3":
mkdir -p source echo "3.0 (quilt)" >source/format
Edit all needed files: see Debian New Maintainers' Guide for details.
cd to original program folder:
Updating the changelog
Debian provides a tool called dch to help ensure your changelog is valid.
If updating a debian package, you should change the version to indicate it has gNewSense changes. For example, if the debian changelog entry looks like this:
- freeciv (2.2.2-1) unstable; urgency=low
Then our updated version will be:
- freeciv (2.2.2-1gnewsense1) parkes; urgency=low
Note that we don't have an unstable suite and use the name of the target suite instead.
Building the Package
Build the package:
dpkg-buildpackage -rfakeroot -us -uc
Checking the Package
To check a package, you need to install lintian:
sudo apt-get install lintian
Then, check the package:
cd .. lintian package.dsc lintian package.changes
If you have warnings (W) or errors (E), the page explaining lintian tags can be helpful to correct them.
Applying a Patch
Note: this section needs to be updated to use quilt v3.
To apply a patch, you need the quilt package:
sudo apt-get install quilt
You have to create the ~/.quiltrc configuration file:
cat > ~/.quiltrc << "EOF" QUILT_PATCHES=debian/patches QUILT_DIFF_ARGS="--no-timestamps --no-index -pab" QUILT_REFRESH_ARGS="--no-timestamps --no-index -pab" EOF
Explanations for these options can be found in the howto for "quilt".
mkdir debian/patches quilt new fix-my-problem.patch quilt add my-problematic-file.ext
Edit the problematic file and then:
quilt refresh quilt header -e
The last line is for editing the patch header which has to look like:
Description: fixes the lintian's `E: usb-modeswitch: shell-script-fails-syntax-check' error. Author: Joe Black <email@example.com> Origin: vendor Forwarded: no Last-Update: 2010-10-28
Note: you can skip the following instructions for patching if you use quilt v3.
Edit the debian/control file and add "quilt" to the "Build-Depends:" line.
If not already present, add the following lines inside your debian/rules:
include /usr/share/quilt/quilt.make [...] build: build-stamp build-stamp: $(QUILT_STAMPFN) dh_testdir [...] clean: unpatch dh_clean build-stamp [...]
Be sure to replace eight spaces " " by a <TAB> or you will have an error when building the package.
Overriding Lintian Notifications
If you have a good reason to do so, you can override lintian's tags. For example:
In this file, write the lintian warning or error you want to override:
usb-modeswitch: shell-script-fails-syntax-check ./lib/udev/usb_modeswitch
Save and quit. Then open rules file:
And add "dh_lintian" in it:
[...] binary-arch: build install dh_testdir [...] dh_installman dh_lintian dh_link [...]
Save and quit, then rebuild the package:
cd package dpkg-buildpackage -rfakeroot -us -uc
Finally, check the package with lintian.
Modifying an Existing .deb Package
The way to modify an existing .deb package is documented on quilt howto. Firstly, get the source:
apt-get source my-program
Rebuild the source tree with the format "3.0 (quilt)":
mkdir -p my-program-0.1/debian/source echo "3.0 (quilt)" >my-program-0.1/debian/source/format dpkg-source -b my-program-0.1
Apply diffs to the source tree:
dpkg-source -x my-program-0.1-1.dsc cd my-program-0.1
Patch the source code (see Applying a Patch section).
If you use "quilt v3", you need to remove quilt temporary files (see http://wiki.debian.org/Projects/DebSrc3.0#Howtoconvertasourcepackage.3F):
rm -Rf .pc
Update the changelog (see Updating the changelog section).
Then rebuild the .deb package with your modifications:
debuild -us -uc
Official Guides for Building & Packaging
Building Custom Kernels