rebuilding packages and the package manager on debian
Solution 1:
Specifically with Nginx, you will pass the configure script specific parameters as noted here.
A new version of Nginx means you will have to download the source and rebuild and install it again, each time. Once you build from source, your package manager has nothing to do with that package. This is almost a non-issue for you, though, because Debian moves at the speed of erosion. The brand-new source release today won't be in the Debian repositories any sooner than half a year from now.
Yes, this entire building-from-source business is a can of worms. It means that the nice startup scripts that Debian includes won't apply to your custom build of Nginx, and there will be a bit of reverse-engineering to get it to work right.
Do you need the absolute latest Nginx with special compile-time options, or can you settle for a version from Dotdeb?
If you absolutely, positively insist on building your own Nginx, at least turn it into a Debian package so you can reuse your custom build. Here are some instructions. There are a bunch of people that are way better at packaging software for Debian. Use their packages. Don't make your own.
UPDATE: Read this changelog for Nginx 1.2.3. They link to this spreadsheet where it indicates that the nginx-extras package offers MP4 module support.
Solution 2:
Joel mentions some good alternatives to building a Debian package which you should seriously consider, since they are most likely a better fit. However, to answer your question directly, there are a few ways to go about it.
First, you could compile and package the software from scratch. This is a complicated process, and probably not what you want to do, but if so, check out the Debian New Maintainers' Guide.
Second, you could unpack the existing package, modify the source and build environment as needed, rebuild and repackage. This is fairly simple, though full of potential hazards. The steps are, generally,
Install the
build-essential
package, which has the tools needed to build Debian packages.Download the package source by running
apt-get source nginx
, or whatever package name is appropriate. This will download and unpack the source package, including any patches, in a format ready to repackage. You may need to add or uncomment thedeb-src
configuration lines in/etc/apt/sources.list
for the appropriate section of the repository.Install the appropriate build dependencies with
apt-get build-dep nginx
.Make your modifications. Referring to the New Maintainers' Guide is helpful here, since the build will be automated, and may undo some of your changes. Be sure to increment the build version so that your package can be installed over the existing one.
Build the package with
dpkg-buildpackage -b
. The-b
flag tellsdpkg
that you don't want to regenerate the source package.Install your package.
An easier approach is to use the checkinstall
program, which generates a Debian package by running an installation command and making a package that reproduces the changes that command made. This works for many software packages, and is fairly straightforward:
Download the source code and make your modifications as needed.
Build the project as you normally would (
make
, for instance, but notmake install
).Run
sudo checkinstall -D make install
. You can modify this for a different installation command if necessary (python setup.py install
for Python projects, for instance).Follow the interactive prompts to build the package. Knowledge of Debian packaging conventions is helpful to make a useful package; you'll have to copy dependencies from the existing package, for instance.
One final approach is to use Alien to convert an existing package (RPM, Slackware tgz, etc) to a .deb
package. I have not used this approach myself, and it requires an existing package that meets your needs in terms of compile-time configurations.
These options should all work for Debian or Ubuntu, but I've only tried them on Ubuntu.