neděle 29. srpna 2010

YUM to URPMI aka TeX Live 2010 to Mandriva

Disclaimer: The stuff below can qualify as an ugly hack. However, I'm not aware of any cases of kittens being killed by it or anything like that. You've been warned ;-)

Once upon a time I wanted to have a, let's say, slightly less outdated TeX distribution than TeX Live 2007 that's still shipped even with the shiny new Mandriva 2010.1. I've been using TL 2009 before, through the tlmgr installer, but I hate that way of doing it (mostly because you have to resort to ugly RPM dependency hacks to get things like Kile or KDevelop installed).

Since I'm a happy Fedora user, too, I wondered: Is there a way to use the Fedora TeX Live 2010 packages made by Jindřich Nový over at http://jnovy.fedorapeople.org/texlive/? There ought to be one, because Mandriva is not that different from Fedora, except for the package manager used. (Yes, there's an YUM package for Mandriva, yes, I've tried that and no, it wasn't good. YUM can't work with URPMI repositories and thus it can't properly resolve inter-repo dependencies. And no, I don't want to switch to Smart Package Manager just to get TeX installed.)

The usual solution suggested by Google for similar problems is: Just download the RPMs and add a local repo. The thing is, I really don't want to download thousands of useless stuff (and waste both my and Fedora's bandwidth). So there was only one possible solution left: Make URPMI understand YUM repos (somehow).

Fortunately, YUM stores repository metadata using nice clean XML files. Unfortunately, I haven't found the specs anywhere (let me know if you have). Two hours of reverse engineering later (with the help of this), I've come up with this small XSL stylesheet that takes a YUM primary.xml database and converts that to a URPMI synthesis file.

The process can look like this:
(0. Uninstall the stock Mandriva texlive-2007 packages.)
1. Get the YUM primary.xml.gz from the F13 repo. (I don't know whether the F12 or F14 ones aren't somehow better, but the F13 one worked flawlessly for me.)
2. xsltproc xml2synth.xsl primary.xml | cut -s -f 3- | gzip > synthesis.hdlist.cz
(That "cut" there is to get rid of the leading whitespace, I don't know how to do this better without making the XSL stylesheet unreadable.)
3. Add this to your /etc/urpmi/urpmi.cfg:
texlive-f13 http://jnovy.fedorapeople.org/texlive/packages.f13 {
static
xml-info: never
}
The repo is marked static so that URPMI doesn't try to update the synthesis (you'll have to do that manually).
4. Put the generated synthesis to /var/lib/urpmi/texlive-f13/
5. You're done! You can now e.g. urpmi texlive-collection-latex and enjoy.

There are two minor annoyances:
1. You'll have to use urpmi --allow-nodeps to get fonts installed. This is completely harmless (in this case) and the reason is Mandriva lacking the fontpackages-filesystem Fedora package (that doesn't do anything useful, just owns the directories).
2. You'll need to fix your languages.dat/def files manually to make non-english hyphenation work (this is an upstream bug, the Fedora packages simply don't do this yet).