Debian binary packages can be built from the source, a patch file and
a “description” file with extension .dsc
.
This is needed, when, e.g. a certain package is not included in the Debian version of the server.
Notes:
This page does not describe the process of creating or fixing/patching a Debian package which is included in the respective Debian version. In that case, you would include “source” repositories in your
sources.list
and download the source package files withapt‑get source packagename
.Packages built this way will most probably expose problems while installing, configuring or running them. Be prepared to deal with these problems.
Requirements
apt-get install build-essential dpkg-dev fakeroot
Get the package source
For package with version v.v.v-d.d download following three files:
- package
_
v.v.v-d.d.dsc
- package
_
v.v.v.orig.tar.gz
- package
_
v.v.v-d.d.diff.gz
These often come from URLs like:
http://deb.debian.org/debian/pool/main/p/package/package_v.v.v-d.d.dsc
http://deb.debian.org/debian/pool/main/p/package/package_v.v.v-d.d.orig.tar.gz
http://deb.debian.org/debian/pool/main/p/package/package_v.v.v-d.d.diff.gz
curl -OL
is your friend here.
?shnippet:
pkg=package
ver=v.v.v-d.d
pre=${pkg%%${pkg##?}}
for post in dsc diff.gz; do
curl -OL http://deb.debian.org/debian/pool/main/$pre/$pkg/${pkg}_$ver.$post;
done
curl -OL http://deb.debian.org/debian/pool/main/$pre/$pkg/${pkg}_${ver%-*}.orig.tar.gz
Building
Run dpkg-source -x package_v.v.v-d.d.dsc
, this will
create the directory package_v.v.v
.
Enter the package_v.v.v
directory and run
dpkg-buildpackage -us -uc -rfakeroot
. This will build all packages
in the parent directory.
Return to the parent directory, you will find package with names like
package-v.v.v-d.d_amd64.dpkg
(Note: -
, not _
).
?shnippet:
pkg=package
ver=v.v.v-d.d
dpkg-source -x ${pkg}_$ver.dsc
cd ${pkg}-${ver%-*}
dpkg-buildpackage -us -uc -rfakeroot
cd ..
ls ${pkg}*.deb