Preparation
-
sudo apt-get update
As always, before you install packages from the terminal do an update first so that your local package cache is in sync with the repository. - sudo apt-get install build-essential devscripts
Installs the base compiler toolchain. - Open Software Sources from your menu, and make sure "Enable source code repositories" is marked. Then click "Update the cache".
This allows for downloading source for packages.
- apt-get source package
Downloads the source for a package to your current directory. Replace package with the name of the package you want to download the source for. Mind that you must not use sudo! - dpkg-source -x filename.dsc
If the last line output by the previous command is "dpkg-source: info: unpacking […]" you can skip this step as the apt-get source command already did it for you. Otherwise this command extracts the source. Replace filename.dsc with the name of the downloaded .dsc file. You can look in your file manager, or with a command like ls *.dsc to find that. - cd dirname
Change directory to the newly created source directory. Replace dirname with the name of the extracted directory. You can look in your file manager, or with a command like ls -l to find that. - sudo apt-get build-dep package
installs the build time dependencies needed to compile the package from source. Replace package with the same name as used in step 1. - You can now apply any patches you need or change any compile time configuration options. That's a manual step that I can't generalize in this tutorial. Recommend you keep the terminal open on the current directory, and use another terminal if needed for doing modifications.
- debuild -us -uc
Recompiles the package. - cd ..
Goes one directory up, as here you will find your newly created package. - sudo dpkg -i filename.deb
Installs the recompiled package. Replace filename.deb with the name of the created .deb file. You can look in your file manager, or with a command like ls *.deb to find that.