Friday, March 4, 2011

Get that package!

Another quick 'howto' in order to pull the latest packages from the Ubuntu repositories. This is because chances are you want a fairly recent release of some package but the one for your release is like 200 years old (and there's nothing in backports.)

My problem is that I do not want to upgrade to the latest Ubuntu release. I am running Lucid servers and I want to stay with a LTS release on them (I will make the jump when 12.04 LTS will come out). So if I need something new/recent/updated I have two choices:
  1. Compile it myself.
  2. See if Maverick or Natty have a more recent release (maybe the one I am after.)

If I am lucky, Maverick or Natty have the thing I am after. So I can install the package and make full use of the package manager in case I need to update/remove. The process is called package pinning and it is described here.
    In summary, the recommended way says to add the sources for the release you are after to your sources.list file and then fetch&build them.

    # echo deb-src http://archive.ubuntu.com/ubuntu/ <release> main restricted universe >> /etc/apt/sources.list
    # apt-get update
    # apt-get source -b -t <release> <package-name>

    All well and good but this method does not work for Natty, yet, since Natty hasn't been released, yet. If you try you get an error (unrecognised release... or something like that.) So we need to 'force' it.

    Create a latest.sources.list file in /etc/apt/sources.list.d and add deb-src for Natty:

    # echo deb-src http://archive.ubuntu.com/ubuntu/ natty main restricted universe >> /etc/apt/sources.list.d/latest.sources.list

    OK. Now we have the sources list from Natty. But this won't work (it produces the error I mentioned above.)

    We will nuke our sources.list, for now.

    # mv /etc/apt/sources.list /etc/apt/sources.list_orig
    # apt-get update
    # apt-get source -b <package-name>

    Notice the absence of the -t switch! We do not need to specify a release.

    If you prefer to download the sources (to make sure the right sources have been fetched) and then compile it yourself:

    # apt-get source -d <package-name>

    This is useful if you want to patch (with a patch of yours) the package. If you do this you will have to build it yourself afterward. There are two ways to do this.

    When you download sources for packages they come in two flavours:
    1. *.orig.tar.*z*, *.diff.gz, *.dsc
    2. *.orig.tar.*z*, *.debian.tar.gz, *.dsc
    The difference is that #1 gives you the patch to apply to the original sources and #2 gives you the debianized sources. So if you get #1 you have to apply the patch first.

    If you have applied the patch, cd into the sources directory and issue:

    # dpkg-buildpackage <options>

    If you got the debianized sources issue:

    # dpkg-source

    This will apply any patch in <sources>/patches automagically, then you can 

    # dpkg-buildpackage <options>

    I learned this the hard way.

    For both methods, apply your patch(es) after the official patch(es).

    Remember to move back your original sources.list if you have neutralised it.

    # mv /etc/apt/sources.list_orig /etc/apt/sources.list
    # sed -i 's/deb/#deb/g' /etc/apt/sources.list.d/latest.sources.list
    # apt-get update

    As a note. If the package you're after is nowhere to be found in a nice .deb form, do not bother trying to create a .deb package. Just compile/install in some meaningful place like /usr/local and check for updates regularly. 

    Or <grin>

    You could try using the uupdate command. Basically you need to download the package sources as described earlier. You will then need to download the latest release as well (from the original site.)  

    Here is the example taken from the Debian New Maintener's Guide:

    # apt-get source foo 
    ... 
    dpkg-source: info: extracting foo in foo-oldversion 
    dpkg-source: info: unpacking foo_oldversion.orig.tar.gz 
    dpkg-source: info: applying foo_oldversion-1.debian.tar.gz 
    # ls -F foo-oldversion/ 
    foo_oldversion-1.debian.tar.gz 
    foo_oldversion-1.dsc 
    foo_oldversion.orig.tar.gz 
    # wget http://example.org/foo/foo-newversion.tar.gz 
    # cd foo-oldversion 
    # uupdate -v newversion ../foo-newversion.tar.gz 
    # cd ../foo-newversion 
    # while quilt push; do quilt refresh; done 
    # dch

    Good luck with your packages!

    --- 

    Useful links:


    ---

    No comments:

    Post a Comment