Welcome! Log In Create A New Profile
We moved to this Improved Forum!

Do not use this old forum, we MOVED to here!


Backporting Packages In Detail

Posted by gplgeek 
This forum is currently read only. You can not log in or make any changes. This is a temporary situation.
Backporting Packages In Detail
October 09, 2007 08:30AM
How to backport packages the safe(r) way. By FossZombie at gmail dot com.
This how-to is loosley based on alejolp.com's instalendo-pidgin documentation.
Thank you alejolp for supporting the community.

Backporting is a process where one goes into testing or unstable repositories
and grabs a source package which is already configured for debian use but has
not have the benfeit of complete testing or may have flaws to work out or it
may just be a newer version that has not been pushed to stable. Generally speaking
packages that are in testing are stable enough to use on a desktop system.

You can try to install the binary streight up like:
$ apt-get -t testing install packagename
This will not always work because it this is build against the test repository and
some of the versions may be off on some files.

Let's assume that does not work, as it is not the cleanest way to get a package.
Let's set up a environment we can work in without clobbering anything.

$ apt-get -t stable install debootstrap
Then install a directory to become our "jail" for this package so we don't mess up our actual root.
# su
$ cd /var
$ mkdir jailroots
$ chmod 700 jailroots
$ cd jailroots
$ mkdir jail1
$ debootstrap –arch i386 etch jail1 file:///media/cdrom
In this case we specify file:///media/cdrom the cdrom as a location to get the basic packages for etch.
This will save you a lot of time and bandwidth.

This folder will contain a minimalistic debian witch will trap everything you do so you don't clobber
your system until you exit out of it. To enter it let's chroot!
$ chroot /var/jailroots/jail1 /bin/su -
Now let's add a user whitch will be our builder
$ adduser builder
pasword: …

Exit the chroot and then login as builder instead of root:
chroot /var/jailroots/jail1 /bin/su - builder

Since the system inside the jail1 chroot is a minimal debian you may have to install many packages you
already have on your real system, this is why it's fast to have a debian CD rom or DVD avaliable.

From now on we assume ALL commands are to be executed in the jail1 chroot. This is where the magic happens.

Before we start it's necesary to have the stable testing and unstable repositories configured in our
apt sources.list like below (add other repos if you like, ie ones closer to you):

    deb [mirrors.kernel.org] stable main contrib non-free
    deb-src [mirrors.kernel.org] stable main contrib non-free

    deb [mirrors.kernel.org] testing main contrib non-free
    deb-src [mirrors.kernel.org] testing main contrib non-free

    deb [mirrors.kernel.org] unstable main contrib non-free
    deb-src [mirrors.kernel.org] unstable main contrib non-free
#   If you have a debian dvd at heand please uncomment the below line and make 
#   sure the path is correct.
#   You MUST mount the cdrom from outside the chroot if you use one because 
#   there will be no cdrom in the chroot's /dev
#	deb file:///media/cdrom stable main contrib

Please note that this is the sources.list in your chroot and not your system.
If you clobber your real sysetm it's your own damn fault =).

To avoid blowing up our system on the next upgrade we need to change how apt
behaves. in /etc/apt/apt.conf
Cache-Limit “41943040?;
Default-Release “stable”;
This code will make sure the default repo used is "stable" instead of testing or unstable.
Now you are ready to update your sysetm:

apt-get update

The following step is to create a temporary directory within ours home folder, and to unpack
the source of the program we want to backport. Example:

$ cd ~
$ mkdir packagename-tmp
$ cd packagename-tmp/
$ apt-get -t testing source packagename
Getting list of packages... done
Checking dependancies... done
Need to get 10.9MB of archives.
Get:1 [mirrors.kernel.org] testing/main packagename-0.0.0 (dsc) [1234B]
Get:2 [mirrors.kernel.org] testing/main packagename-0.0.0 (tar) [10,8MB]
Get:3 [mirrors.kernel.org] testing/main packagename-0.0.0 (diff) [37,4kB]
Downloaded 10,9MB in 1s (10.9MB/s)
dpkg-source: extracting packagename in packagename-0.0.0
dpkg-source: unpacking packagename-0.0.0.orig.tar.gz
dpkg-source: applying ./packagename-0.0.0.diff.gz

WARNING: NEVER EVER USE $ apt-get -t testing build-dep packagename you will reget it!
There is a hack to figure out the depends.
$ apt-cache showsrc packagename | grep Build-Depends:

Once you have your list of depends you should use
#Note this is -t STABLE otherwise it wont build for your system.
apt-get -t stable install depends_listed_from_above_command

In any case if you are building something you will want to install these packages:
$ apt-get -t stable install autotools-dev debhelper devscripts dh-make
$ apt-get -t stable install build-essential fakeroot debian-keyring
#I'd also reccomend installing solitare on your base system to play while it's all compiling.

Now the fun part! Let's make some packages!
# go into source directory
$ cd packagename-0.0.0
$ fakeroot debian/rules binary

Look at it go! you are almost done!

$ cd …
$ ls *deb

The -dbg package has symbols for gdb
The -dev package is to install extra libraries needed in the program.

Now we can exit the chroot, and as root in our base system we can install the backported package.

# dpkg -i packagename-0.0.0_i386.deb packagename-data_0.0.0_all.deb

Finally run your package:
# dpkg -r packagename

Edited 1 time(s). Last edit at 10/09/2007 08:32AM by gplgeek.