Build environment
$ sudo apt-get install build-essential devscripts fakeroot
Fetch source
This is three files: a .dsc, a debian.tar.gz and a .tar.gz.
There are a few ways to do this.
1)
$ apt-get source openssl
2)
$ dget http://security.debian.org/debian-security/pool/updates/main/o/openssl/openssl_1.0.1e-2+deb7u5.dsc
dget is in the devscripts package, which has a tonne of dependencies (such as installing a SMTP mail system).
3)
$ wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/openssl_1.0.1e-2+deb7u5.dsc $ wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/openssl_1.0.1e-2+deb7u5.debian.tar.gz $ wget http://security.debian.org/debian-security/pool/updates/main/o/openssl/openssl_1.0.1e.orig.tar.gz
Unpack the source and apply patches with:
$ dpkg-source -x openssl_1.0.1e-2+deb7u5.dsc $ cd openssl-1.0.1e
Fetch build dependencies
1) The simplest way
$ sudo apt-get build-dep openssl
2) Otherwise look for Build-Requires lines in the file debian/control and install them individually:
$ sudo apt-get install debhelper m4 bc zlib1g-dev dpkg-dev
Build
There are multiple ways to do this.
1) The most basic is:
$ dpkg-buildpackage -us -uc -b
2) Debuild adds various checking of the resulting .deb (debuild is in the devscripts package):
$ debuild -us -uc -b
3) Pbuilder does the build in a clean environment, giving the best result (pbuilder is in the pbuilder package):
$ pbuilder --create $ pbuilder --update $ pbuilder --build --debbuildopts '-us -uc -b'