Create a backported Ruby 1.9.3p484 Ubuntu package. For the purposes of this post, we will assume that you are OK with not creating a signed package (required if uploading to launchpad). If you wish to upload to launchpad (for example to share your backport with the world), it may be useful for you to check out this site after reading through this guide.
At my day job, I had to upgrade Ruby on very old production boxes that were running Oneiric AMD64. Upgrading the OS was a chore that would be happening later but we needed to start using the latest Ruby as soon as possible.
Unfortunately, there is no Ruby 1.9.3p484 Debian package readily available for Oneiric, not even as a backport.
- A reasonable Ubuntu environment. Use Vagrant (and its dependencies, such as Virtualbox) if you are on OSX
- Basic *Nix knowledge (command line editors and various tools)
The idea is to use tools readily available on Ubuntu and Debian to create a backported package. These include
pbuilder among others.
Without going into too much detail,
backportpackage helps us “prep” (e.g. generating .dsc files with conventional names for backported packages) our existing target package on to be backported.
pbuilder is a tool that sets up a clean chroot environment (via debootstrap) to build Debian packages. See the man page for backportpackage and the pbuilder howto page for more information.
pbuilder are very straightforward to use when backporting packages that do not have many dependencies. However, when porting the Ruby 1.9.3p484 package from Trusty to Oneiric, quite a bit of “massaging” needed to be done, mostly because of the significant time difference between the two Ubuntu releases.
- Have a reasonable Ubuntu environment ready. It doesn’t matter which version you are currently on because we will be using the aforementioned tools to download, prep and build packages. It may be a good idea to run
$ sudo apt-get update
$ sudo apt-get install ubuntu-dev-toolsto install Ubuntu dev tools on your host machine. This will install
- If you are using a version of Ubuntu newer than Precise, you may be able to skip this step.
$ wget http://ubuntu.wikimedia.org/ubuntu//pool/universe/u/ubuntu-dev-tools/ubuntu-dev-tools_0.143_all.deb && sudo dpkg -i ubuntu-dev-tools_0.143_all.debThis installs a newer version of
backportpackagesthat allows us to not sign our packages
$ mkdir -p ~/backport_workdir/ruby191 && cd ~/backport_workdir/ruby191to create and go to our working directory
$ backportpackage --dont-sign -s trusty -d oneiric -w . ruby1.9.1to download the newest (at time or writing) Ruby 1.9.3p484 package and create the prepped .dsc files for backporting.
- Important Open up
ruby1.9.1_126.96.36.1994-1ubuntu2~ubuntu11.10.1.dscwith your preferred editor and remove the versioning constraints on
Build-Dependsline. Theoretically you could backport dependencies as well and put them in a local apt-get repo, but these particular packages are nasty in that they have many further dependencies and since in this case, the default versions that come with Oneiric are fine, we can safely remove these constraints.
$ sudo apt-get install pbuilderto install
pbuilder8. Create a
~/.pbuilderrcfile with the following contents. This is a preference file for
pbuilderand the following configuration will allow us to easily toggle between different distributions of Ubuntu and architectures when using it to build packages. Credit to tolaris.com
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
The only additions I’ve made are to add the
-d flag, which is required for us to ignore dependency discrepancies (in this case, our
cdbs dependencies are not at the version specified by the official package) and to update the list of Ubuntu distro names.
$ sudo DIST=oneiric ARCH=amd64 pbuilder create to create an Oneiric AMD64 chroot environment to build our backport on.
$ sudo DIST=oneiric ARCH=amd64 pbuilder login --save-after-login to login to our chroot environment. The
--save-after-login flag tells pbuilder to save the environment after we exit.
11. In chroot environment
$ apt-get update && apt-get install tcl8.5-dev tk8.5-dev to install tcl/tk dev packages. Next, symlink the .so files to where the Ruby 1.9.3p484 package for Trusty expects them to be by doing:
$ ln -s /usr/lib/libtk8.5.so /usr/lib/x86_64-linux-gnu/libtk8.5.so && ln -s /usr/lib/libtcl8.5.so /usr/lib/x86_64-linux-gnu/libtcl8.5.so. Next, exit the chroot environment by hitting Control-D or
$ exit. Normally,
pbuilder will take care of downloading build-dependencies for you, but in this case, the problem is that the Ruby 1.9.3p484 package for Trusty assumes taht
.so files are located in places where they are not installed by default on our target distro.
$ sudo DIST=oneiric ARCH=amd64 pbuilder build ruby1.9.1_188.8.131.524-1ubuntu2~ubuntu11.10.1.dsc to instruct
pbuilder to build your package. Go grab a coffee, walk your dog, etc. because this may take a while. If you are running in a VM (e.g. in Vagrant), be sure you’ve allocated enough memory (I recommend at least 2GB) so that the build tests for Ruby will pass.
pbuilder is done, look in
/var/cache/pbuilder/oneiric-amd64/result/ for your packages
There are a few places where I needed to get my hands dirty and look at package source code to understand where and why things were failing. Hopefully this guide helps you to backport not only Ruby, but any Ubuntu/Debian package between different releases !
If you have problems and questions, please leave a comment :)