How to modify a deb package?

The procedure I use is this:

Get the source (via apt-get src).

Apply a patch, or do whatever needs changing.

run debchange --nmu and type in a description of the change you made. This will auto-incremement the version number so that the system will not try to "upgrade" your custom package back to the standard one.

Run debuild.

Enjoy your deb files.


I found the following guide on the Ubuntu forums for rebuilding the network manager package here

Re: how to patch the source of a deb

Quote: Originally Posted by cord

I want to basically rebuild the network manager package with a custom patch of sorts to test something. So I want to: 1. get the source code for the ubuntu "version" of network manager

Code:

sudo apt-get source network-manager

Quote: 2. patch it with my patch The source files will be downloaded to the working directory. See this for more information.

Quote: 3. make a deb file that I can install in place of the current network manager.

Execute Code:

dpkg-buildpackage -rfakeroot -uc -b
in the directory created.

Also found this article : Debian New Maintainers' Guide Chapter 6 - Building the package


As for your changes being lost by an update from the official repositories I'm not sure. You could always just send your patch back upstream to the compiz-gnome package maintainers or create your own repository for the updated package.


The answer to #3 and #4 is that you should put the package in hold status once you've installed your version. This tells the Debian package management system to "hold" any future changes to this package, in effect lets you manage the package manually.

From the Debian FAQ:

7.11 What is meant by unknown, install, remove, purge and hold in the package status?

These "want" flags tell what the user wanted to do with a package (as indicated either by the user's actions in the "Select" section of dselect, or by the user's direct invocations of dpkg).

Their meanings are:

  • unknown - the user has never indicated whether he wants the package>

  • install - the user wants the package installed or upgraded

  • remove - the user wants the package removed, but does not want to remove any existing configuration files.

  • purge - the user wants the package to be removed completely, including its >configuration files.

  • hold - the user wants this package not to be processed, i.e., he wants to keep the >current version with the current status whatever that is.

7.12 How do I put a package on hold?

There are three ways of holding back packages, with dpkg, aptitude or with dselect.

With dpkg, you have to export the list of package selections, with:

dpkg --get-selections * > selections.txt

Then edit the resulting file selections.txt, change the line containing the package you wish to hold, e.g. libc6, from this:

libc6 install

to this:

libc6 hold

Save the file, and reload it into dpkg database with:

dpkg --set-selections < selections.txt

With aptitude, you can hold a package using

aptitude hold package_name

and remove the hold with

aptitude unhold package_name

With dselect, you have to enter the [S]elect screen, find the package you wish to hold in >its present state, and press the =' key (or H'). The changes will go live immediately >after you exit the [S]elect screen.

Note: People have found issues with the aptitude hold command, so imho you should prefer the dpkg command to hold the package. Alternatively, you could hold the package via the Synaptic package manager GUI interface (Package > Lock Version). My preference is to use dpkg because it has worked well for me.

You already have a good answer for the rest so I'll not venture my opinion on those.