Small Mosaic


Categories:

books
career
codinghorrors
comics
events
geekstuff
justdont
languages
languages/bash
linkshot
magazines
meta
misctech
movies
nottech
operatingsystems
operatingsystems/linux
operatingsystems/linux/debian
operatingsystems/solaris
paranoidadmin
perl
ruby
security
security/apache
security/tools
serversmells
sites
specifications
sysadmin
tools
tools/commandline
tools/firefox
tools/gui
tools/network
tools/online
tools/online/greasemonkey
unixdaemon

Archives:

April 20084
March 20081
February 20081
January 200815
August 20072
June 20079
May 20076
April 20078
March 200731
February 20073
January 200721
December 20061
November 20064
October 20066
September 200632
August 200617
July 200614
June 20069
May 200613
March 200611
February 200616
January 200611
December 20051
November 20056
October 200519
September 200525
August 200516
July 200516
June 200513
May 20052
April 200519
March 200531
February 200520
January 200531
December 200421
November 200430
October 200432
September 200418
August 20047
July 200414
June 20045

Tue, 15 Apr 2008

Rebuilding Debian Packages - Debian Delvings
Ever wanted a Debian package to be just a -little- bit different? Here's how. While most of the software we're pulling in from Debian is fine for our uses there are a couple of applications that we'd like to be a little different than the stock versions. Rather than go away and package them ourselves (which would require a lot more packing skills and time than I currently have - improving those skills is one of the reasons I'm doing this series) it's possible to download a source version of a Debian package, make a small amendment and then repackage it for personal use. In this example we'll have a look at how to do this with NginX, a very fast and stripped down webserver I'm evaluating for a couple of services.

Firstly let's be nosey and have a look at the Nginx source package. Assuming you have a deb-src line in your /etc/apt/sources.list file getting a copy of the source package is as simple as apt-get source nginx; it's worth noting that this command doesn't need you to be root to run. While we're here let's pull down the dependencies required to rebuild nginx once we've made our modifications - sudo apt-get build-dep nginx - note the build-dep argument - and then pull down the other packages required but are not specific to this package.sudo apt-get install build-essential devscripts fakeroot (sudo or as root).

It's a bit of a tangent (and an annoyance) but the package of Nginx in Debian stable (nginx 0.4.13-2) has a Nginx package removal bug that stops you from removing the package without hacking the init script. I only point this out as when I was trying to learn how to repackage I couldn't remove it and so assumed I'd broken something.

Before we make any amendments to the package let's try and rebuild it. cd in to the versioned source directory (nginx-0.4.13 in our example) and run debuild -us -uc. A few screens of text later and we've got a package - ../nginx_0.4.13-2_i386.deb.

Now we know we can round trip let's be intrusive and make some amendments to the package. We'll add an optional module (http_realip_module) to the nginx package (you should be able to do something like this to add SSL support for example. In this case it's a small, one line, change -

  
 $ cd nginx-0.4.13 # this is the etch version when I wrote this

 $ vi debian/rules # add '--with-http_realip_module' to the ./configure line.

 $ dch --nmu "Rebuild of package and addition of the http_realip_module module"

 $ vi debian/changelog # change the name and email as required.

 # build the new package with the extra module
 $ DEBFULLNAME="Dean Wilson" DEBEMAIL=dwilson@example.com debuild -us -uc

 $ ls -alh ../nginx_0.4.13-2.1_i386.deb

  # if you have a repo drop it in now and regenerate the index for clients to see it.
  

dch simplifies adding changelog entries to debian/changelog. The two variables before the command tell it who's made the change. In our case we're logging that we added the new module and that this package is a "Non maintainer upload" (NMU). This is important for future users of the package - in essence we're taking responsibility for the repack away from the oringinal maintainer, who knows nothing of the changes you've made, and making ourselves the correct contact point. And if you don't do this lintian will complain when you build the package.

Closing notes - you may need to pin or hold the package to stop it getting overwritten when future (maintainer) upgrades become available - but that's outside the scope of this post.

Bonus Debian Nginx package Evil. Bad idea but useful for some testing I was doing.

Like this post? - Digg Me! | Add to del.icio.us! | reddit this!

Posted: 2008/04/15 09:11 | /operatingsystems/linux/debian | Permanent link to this entry | This entry + same date


books career codinghorrors events geekstuff justdont languages/bash linkshot magazines meta misctech movies nottech operatingsystems/linux operatingsystems/linux/debian operatingsystems/solaris perl ruby security security/apache security/tools serversmells sites specifications sysadmin tools/commandline tools/firefox tools/gui tools/network tools/online tools/online/greasemonkey unixdaemon

Copyright © 2000-2005 Dean Wilson XML feed logo