Fix Patch Debian Packages
###########################

For automatic script check this out: sdbe

Here are manual steps to patch a debian package:

# Download the old package
cd /tmp
apt-get download packagename
# move it to WORK directory where we will extract it
mkdir /tmp/WORK
cd /tmp/WORK
mv packagename.deb WORK
ar vx packagename.deb
# That gives us data.tar.gz and control.tar.gz and debian-binary
# Make build folder BUILDDIR inside it we will put NEW (inside NEW is where the new package will go)
# data.tar.gz extracts to NEW/ folder
# control.tar.gz extracts to NEW/DEBIAN/ folder
# then you build the new package from the folder above NEW which here is BUILDDIR
mkdir /tmp/WORK/BUILDDIR
mkdir /tmp/WORK/BUILDDIR/NEW
# extract data
tar xf data.tar.gz -C /tmp/WORK/BUILDDIR/NEW
# extract control
mkdir /tmp/WORK/BUILDDIR/NEW/DEBIAN
tar xf control.tar.gz -C /tmp/WORK/BUILDDIR/NEW

cd /tmp/WORK/BUILDDIR/NEW
# Now fix the problem ( stuff in /tmp/WORK/BUILDDIR/NEW is like the equivalent of stuff on / root of the system after install or prefix install folder)
Stuff in DEBIAN folder is the control stuff (Scripts that run before and after installs and uninstalls)

# when done - time to build
cd /tmp/WORK/BUILDDIR
dpkg -b NEW
# if not root: fakeroot dpkg -b NEW
mv NEW.deb packagename-NEW.deb

# check new package

 

dpkg –info packagename-NEW.deb
dpkg –contents packagename-NEW.deb
# install new package
dpkg -i packagename-NEW.deb

GOOD NOTES:
http://www.g-loaded.eu/2008/01/28/how-to-extract-rpm-or-deb-packages/
http://ubuntuforums.org/showthread.php?t=1826900
Re: patching a deb package using “ar” for unpacking and packing
I’ve been told that it is not a good idea to use ar for packaging debs. Apparently there are two versions of ar. The one that comes with Ubuntu/Debian is the GNU version. But the one that is built into dpkg is the BSD version and apparently there are small differences in the produced packages. I’m not 100% sure about this, but it is what I have been told.
This is what I would do: Create a directory to hold the contents of the deb. Unpack the contents of data.tar.gz to the directory. Make a subdirectory called “DEBIAN” and extract the contents of control.tar.gz to the DEBIAN directory. Make your changes then repackage using dpkg. From a terminal navigate to the directory that contains your new directory. So if you placed your directory on the desktop you would navigate to the desktop. Now use the following command to package the deb (I’m doing this from memory so I hope that it is all correct):
Code:
fakeroot dpkg -b mydirectory

 

Leave a Reply

Your email address will not be published. Required fields are marked *