|
/Linux/Debian:
Debian: How to Modify a Source Package / Build a New Binary Package[1]
Downloading, building, tweaking, and rebuilding a source tarball is not that difficult a concept for me at this point. Debian, however, has a very sophisticated (complex? obtuse? But I still love Debian....) packaging system.
Quick & Dirty Method[5]:
Say I am trying to debug something with the cron package:
apt-get build-dep cron cd /to/where/you/want/to/install/your/source apt-get source cron cd cron-3.0 modify the code DEB_BUILD_OPTIONS=debug,nostrip fakeroot debian/rules binary debi
where dpkg-buildpackage builds a .deb and places it one directory up and debi installs the package. DEB_BUILD_OPTIONS are optional, but extremely useful if you are going to use gdb for debugging.
Note that the package version is not changed with this method, and the next time you run "apt-get upgrade" it will want to replace your debug version of the package with the repository version.
Patches & Versioning:
Sorting out how to mess with source code using the "Debian way"[3] is not at all transparent. Roberto Sanchez' "Debian Package Customization HOWTO"[4] is better:
Suppose someone sends you a patch that you want to test. Here is how you would obtain, patch, and build the source to create a new .deb with a unique version number, ready for installation:
apt-get source foo cd foo-1.0 patch -p0 < /path/to/patch/file/ # apply patch to source debchange -nmu # See note below sudo apt-get build-dep foo # install build dependencies dpkg-buildpackage # build binary package from source
"debchange -nmu" will bring up the changelog in your default editor. In addition to modifying the text of the log, it is also possible to modify the package version number in the header of the changelog entry. Sanchez[4] recommends decrementing the version, adding a ".0.0" to the end, then adding a "name.0" to that. "name.0" is the part you use locally to track local changes. The preceding decremented-version.0.0 tries to ensure that any packages that appear in the repository afterwards will take precedence over the local package, so that upstream updates get installed (assuming that is what you want).
You should find your new .deb one directory up (..) with the version number as specified in the changelog.
Note that you might optionally want to put the source under the control of the git[2] revision control system if you are going to make modifications yourself and submit patches.
[1] http://www.debian-administration.org/articles/556
[2] http://blog.langex.net/index.cgi/Coding/git-basics.html
[3] http://www.debian.org/doc/maint-guide/
[4] http://people.connexer.com/~roberto/howtos/debcustomize
[5] http://women.debian.org/wiki/English/BuildingTutorial
posted at: 13:24 | path: /Linux/Debian | permanent link to this entry