Sunday, 31 July 2011

Repacking an Ubuntu/Debian Package

Some problems might require you to repack an existing .deb file with some extra goodies in or with some config removed from a control file, MySQL password prompt on install comes to mind... The easiest solution to repack a package (or only extract the files within the package) is:

For this mini howto I'm using MySQL for Ubuntu 10.04 LTS:

Download the file required using apt-get:

apt-get -d install mysql-server
cd /var/cache/apt/archives/

Copy the file that looks similar to the one below to a temp directory eg. /tmp:

mv mysql-server-5.1_5.1.41-3ubuntu12.10_i386.deb /tmp/

Create a folder for the extracted content and extract the binary part of things:

mkdir /tmp/extracted
dpkg -x mysql-server-5.1_5.1.41-3ubuntu12.10_i386.deb /tmp/extracted

Create the DEBIAN folder in extracted, the folder name has to be called DEBIAN for the build to work. Once created dpkg -e will extract the control file etc for the package:

mkdir /tmp/extracted/DEBIAN
dpkg -e mysql-server-5.1_5.1.41-3ubuntu12.10_i386.deb /root/extracted/DEBIAN

Build the new package:
mkdir /tmp/build
dpkg -b /tmp/extracted /tmp/build

No comments:

Post a Comment