7

I am running an Ubuntu 12.04 LTS server. I currently have an issue where one of my used packages has an annoying bug. Instead of removing it and just building it from source, I want to integrate it into Ubuntus/Debians package management.

Coming from ArchLinux we did this by copying the original PKGBUILD and changing it in such a way that it compiles the new package. This is a very simple process but it informs the package manager about this package even though it is in no local repositories.

Is there a similar way for Ubuntu/Debian? Can I easily base my package on the outdated Ubuntu version and install this package instead of the original repository one?

Note: The concerning software is libvirt (I need 0.9.13 at least, 12.04 runs 0.9.8) and while I would appreciate a solution for this particular package in the comments, I am looking for a more general solution for such problems should they arise in the future.

Contrary to questions How can I manually assemble my own package “the hard way”? and What is the simplest Debian Packaging Guide? I am not interested in creating a new package but instead using existing resources and update them to a newer version.

5
  • possible duplicate of How to get my software into Ubuntu?
    – Panther
    Jan 27, 2014 at 22:13
  • 1
    This doesn't answer your question, but updated libvirt is in the Cloud Archive: wiki.ubuntu.com/ServerTeam/CloudArchive Jan 27, 2014 at 22:14
  • 1
    You can always download the older package version from wherever, and then install it by hand, without repackaging everything.
    – Thomas Ward
    Jan 27, 2014 at 22:45
  • @bodhi.zazen he wants to fix a bug locally no submitting a new package to Ubuntu.
    – Braiam
    Jan 29, 2014 at 1:47
  • @Braiam Thanks, I suppose I misunderstood "I want to integrate it into Ubuntus/Debians package management."
    – Panther
    Jan 29, 2014 at 15:55

2 Answers 2

6

I would download the source and the build dependencies for the Ubuntu version first:

apt-get install dpkg-dev
apt-get build-dep <package>
apt-get source <package>

The unmodified, upstream source the Ubuntu version is based on will be in a file called <pkg>_<ver>.orig.tar.gz (compression scheme may vary) - I would decompress this to one directory (let's call it "dir A"), then download the source to the bug-fixed version into another directory ("dir B"), and then generate a patch for what's changed:

diff -Nur <dirA> <dirB> >/tmp/upgrade.patch

Then change to the directory where apt-get source decompressed the modified Ubuntu version, and apply the patch

patch -p1 </tmp/upgrade.patch

Assuming there weren't many changes between the two upstream versions, and they didn't conflict with any of the Ubuntu packager's changes, this should work. Then edit debian/changelog in the Ubuntu package to give it a new version number, and dpkg-buildpackage should build you a custom version..

1

Just to toot my own horn, I have creating a solution for this exact circumstance. You can have a Debian package downloaded, unpacked, built, and reinstalled in 2 or 3 commands.

It is a shell script debtool and is available on GitHub via the aforementioned link.

Building Debian packages from source can be cumbersome, especially on a daily driver that you don't necessarily want to muddle up with numerous build dependencies and the like.

Assuming libvirt is available via sources, run the following command:

debtool --download --unpack libvirt

The above command just downloaded the libvirt_0.9.8_all.deb file and unpacked it into the directory libvirt_0.9.8_all.

Alternatively, you can unpack the version of libvirt that is currently installed on your system:

debtool --unpack libvirt

At this point you should make all of your changes to the files in the directory. You will also likely want to bump up the package's version number (i.e. 0.9.8-custom1) located in ./libvirt_0.9.8_all/DEBIAN/control.

Now build the package by running the following command:

debtool --build ./libvirt_0.9.8_all

Your finished package is now in the current directory as libvirt_0.9.8-custom1_all.deb.

You can quickly reinstall this package by running debtool --reinst ./libvirt_0.9.8-custom1_all.deb or alternatively debtool --build --reinst ./libvirt_0.9.8_all to build and reinstall in one fell swoop.

Etcetera

You can do a couple of other related tasks with debtool as well.

Show Available Versions

If there are several versions of a package available in the repositories, you can list them as follows:

debtool --show zsh

The above command will return the following:

zsh 5.0.5-4ubuntu1~ubuntu14.04.1 amd64
zsh 5.0.2-3ubuntu6 amd64

If you'd like to download the packages manually then you can use the --show-format option.

debtool --show --show-format zsh

Will return the following:

apt-get download zsh=5.0.5-4ubuntu1~ubuntu14.04.1 -a=amd64
apt-get download zsh=5.0.2-3ubuntu6 -a=amd64

Download Debian Archives

You can download the most recent version of a package as follows:

debtool --download zsh

You can download a specific version as follows:

debtool --download zsh=5.0.2-3ubuntu6

Unpacking Packages

You can unpack a package on your hard drive:

debtool --unpack package.deb

You can also unpack a package that is currently installed on your system:

debtool --unpack package

If you have made changes to any of the installed files, they will be incorporated as well. This is perfect if you want to work with a package that is no longer available from sources or if you want to incorporate pre-existing fixes into a 'patched' deb.

1
  • Depending upon how local is meant by local, and given you may want stable software, the process should be extendable to a custom repository (not a ppa). Note how this is done for many rebadged distros such as Zorin, Mint, Peppermint etc.
    – mckenzm
    Jan 30, 2017 at 2:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .