Arch Linux + yaourt + customizepkg = beauty!
by Alexander Kojevnikov
I recently switched my main desktop from Ubuntu to Arch Linux, mostly for its rolling release model. I really like Ubuntu but I got tired of dealing with lots of custom PPAs. Arch Linux not only provides the latest stable version for all packages, it also has tools to customise the packages to your liking and selectively build them from source.
In this post I will explain how to do it, taking as an example my pet peeve – the vertical Gnome panel. Carey Underwood has recently posted a (mostly) working patch, let’s get it into our box.
First thing you need is to install yaourt and customizepkg, both are available in AUR. ArchWiki has a great tutorial on how to do it. Actually you only need the tutorial to install yaourt, afterwards installing packages from AUR is as simple as running:
$ yaourt -S customizepkg
customizepkg allows to tweak PKGBUILDs. You just add a file to /etc/customizepkg.d/ with the same name as the package you want to change. The file format is not well documented, but it’s pretty intuitive.
In our case we need to create /etc/customizepkg.d/libwnck with the following text (in one line):
replace#global#cd "${srcdir}\/${pkgname}-${pkgver}"#cd "${srcdir}\/${pkgname}-${pkgver}"\nwget -O vertical.patch http:\/\/bugzilla-attachments.gnome.org\/attachment.cgi?id=140334 || return 1\npatch -Np2 -i vertical.patch || return 1
The file will tell customizepkg to add two lines to libwnck’s PKGBUILD:
build() { cd "${srcdir}/${pkgname}-${pkgver}" +wget -O vertical.patch http://bugzilla-attachments.gnome.org/attachment.cgi?id=140334 || return 1 +patch -Np2 -i vertical.patch || return 1 ./configure --prefix=/usr --sysconfdir=/etc --localstatedir=/var --disable-static || return 1 make || return 1
Then you just install the package as you always do, but using yaourt instead of pacman:
$ yaourt -S libwnck
Et voilà, yaourt realises that you want to build libwnck from source, gets its PKGBUILD, changes it, and builds. When building, the patch is downloaded and applied to the source code of libwnck before it’s made.
But wait, there’s more to it! Next time you upgrade the system with `yaourt -Syu`, if there is a new version of libwnck, it will be automatically patched and built from source.
Hope you find this useful, and if you haven’t tried Arch yet – do it today, you won’t be disappointed ;)
Over at the Arch thread I posted about some hacks I’ve found useful for customizepkg.
Comment system ate the url: http://bbs.archlinux.org/viewtopic.php?id=78910
Thanks for telling how to do it instead of that it can be done. I just heard about customizepkg so this is great. Thanks for the tutorial.
@Jim: thanks, I will try it out.
@Gen2ly: you are welcome!
Thanks for the explanation of cutomizepkg. The vertical panel bug has been driving me crazy for, I don’t know, two years now?
I’m trying to apply the rotate window list patches to libwnck and gnome-panel. But got an error with libwnck (I haven’t tried gnome-panel yet). I edited the customizepkg.d line to read:
replace#global#cd “${srcdir}\/${pkgname}-${pkgver}”#cd “${srcdir}\/${pkgname}-${pkgver}”\nwget -O rotate-libwnck.diff http:\/\/bugzilla-attachments.gnome.org\/attachment.cgi?id=90768 || return 1\npatch -Np2 -i rotate-libwnck.diff || return 1
And I got this error, when I ran yaourt:
can’t find file to patch at input line 3
Perhaps you used the wrong -p or –strip option?
The text leading up to this was:
————————–
|— pango1.0-1.16.4.orig/modules/indic/indic-lang.c 2007-01-23 10:41:44.000000000 +1100
|+++ pango1.0-1.16.4/modules/indic/indic-lang.c 2007-06-25 00:22:26.000000000 +1000
————————–
File to patch:
Any thoughts? Is the patch too old now? I’m running Gnome 2.26
That’s because you are wgetting the wrong patch. http://bugzilla-attachments.gnome.org/attachment.cgi?id=90768 is from bug https://bugzilla.gnome.org/show_bug.cgi?id=451682
Thanks. Yeah, it looks like I transposed the 6 and 7 when I typed in the id number for the patch attachment. Unfortunately after correcting this, I still got an error. This time I used this line:
replace#global#cd “${srcdir}\/${pkgname}-${pkgver}”#cd “${srcdir}\/${pkgname}-${pkgver}”\nwget -O rotate-libwnck.diff http:\/\/bugzilla-attachments.gnome.org\/attachment.cgi?id=90678 || return 1\npatch -Np2 -i rotate-libwnck.diff || return 1
And got this error:
missing header for unified diff at line 5 of patch
can’t find file to patch at input line 5
Perhaps you used the wrong -p or –strip option?
The text leading up to this was:
————————–
|Index: tasklist.c
|===================================================================
|— tasklist.c (révision 1379)
|+++ tasklist.c (copie de travail)
————————–
File to patch:
Any more thoughts? I’m dying to resolve what has been the most annoying bug ever for me.
> Perhaps you used the wrong -p or –strip option?
That’s exactly what the error says, you need to use -Np0 instead of -Np2 for this particular patch. `man patch` for details.
EDIT: before applying the patch, you also need to `cd` into the directory where tasklist.c & Co are located
Thanks for the super fast reply. Yeah I was just reading the manual and looking at the text of the patch, but I know nothing about patching (or programming) and didn’t know how to figure out what -p option I needed. So it was all way over my head. How did you know it should be 0 for this patch? What about for the rotate window list gnome-panel patch? Is that also 0?
Also, sorry to ask another very unknowledgeable question, but where would I look for tasklist.c? I searched my file system but came up with nothing. I don’t even see the libwnck tar.bz2 files that yaourt downloaded before the patch and install process failed. Thanks for any more help.
> How did you know it should be 0 for this patch? What about for the rotate window list gnome-panel patch? Is that also 0?
The -p option tells how many directories to strip from the file path before applying the patch. In your patch the files have no directories prefixed to the file names, so the option should be -p0. Read `man patch`, it has some good examples.
> I searched my file system but came up with nothing. I don’t even see the libwnck tar.bz2 files that yaourt downloaded before the patch and install process failed.
Check the PKGBUILD file for libwnck, either in the online repository or using ABS. The file has a link to the location from which the package is downloaded. Download it manually, unpack, and find which directory tasklist.c belongs to.
So I guess the problem with cd-ing into the correct directory, is that tasklist.c is in a directory in the source package for libwnck that yaourt downloads. So I can’t cd into the directory before I run yaourt, because it doesn’t exist yet. It seems like for the patch in your example above, the directory is specified in the patch. But that’s not the case with the rotate window list patches. So does that mean that the customizepkg method simply won’t work for applying these patches and it has to be done manually instead?
Oops, sorry, I posted my last question, before I saw your previous reply. In any case, I guess I’m correct that I can’t use the customizepkg method you desribe in your post for doing this?
Thanks again for the help.
You can. You just need to add `cd X` to that line, so instead of:
…\npatch…
you will have
…\ncd X\npatch…
Substitute X with the relative path of tasklist.c. Also, be careful with escaping, if for example the path is `foo/bar`, you should use `foo\/bar`
I guess this is still going over my head. I keep getting an error like this now:
/tmp/yaourt-tmp-root/abs-libwnck/./PKGBUILD: line 19: cd: /libwnck-2.26.2/libwnck: No such file or directory
can’t find file to patch at input line 5
Perhaps you used the wrong -p or –strip option?
The text leading up to this was:
————————–
|Index: tasklist.c
|===================================================================
|— tasklist.c (révision 1379)
|+++ tasklist.c (copie de travail)
————————–
File to patch:
tasklist.c is in the directory /libwnck-2.26.2/libwnck/ inside the tar.bz2 package that’s downloaded for libwnck in the yaourt-tmp-root directory. In my customizepkg.d/libwnck file I’ve tried libwnck-2.26.2\/libwnck \/libwnck-2.26.2\/libwnck \/libwnck-2.26.2\/libwnck\/. What am I missing?
Thanks.
Hmm. Okay, I tried entering a directory where yaourt pauses and asks, “File to patch:”. I used /tmp/yaourt-tmp-root/abs-libwnck/src/libwnck-2.26.2/libwnck/tasklist.c. This seemed to work, but then I had some “Hunk #19″ failed type errors and the process ended up aborting itself. So now I’m wondering if this patch is too old for 2.26. The patch is two years old. I think libwnck was at 2.22 at the time.
Yeah, that’s because the patch is too old. If you feel brave, you can prepare your own. Ask folks on #archlinux if you have questions on usage of patch/git/etc.
As for the path, you don’t need to specify the first `/`, it means the root of the partition. `cd libwnck` will probably be enough (or `libwnck-2.26.2\/libwnck` depending on how yaourt unpacks the tarball)
Oh well. Thank for all the help. I was excitd that I was going to finally eliminate the most annoying bug of all in my system. Perhaps if I’m feeling super ambitious in a while I’ll try making my own patch, but I imagine it’s way over my head since I know nothing about programming.
I did try Alexey Rusakov’s slightly newer version of the patch, which seemed to work okay, as far as the patching process goes, but then the compiling process failed. I assume that was also due to the patch being meant for libwnck 2.22 and I’m using 2.26. It’s almost tempting to abandon Arch and switch to Debian Lenny, which is using Gnome 2.22.
Why don’t you try the customizepkg files I mentioned in my other post? http://versia.com/2009/09/06/vertical-panel-in-gnome-15-months-later/
You can grab them from http://github.com/alexkay/arch
I too have Gnome 2.26, and they work fine for me.
Thanks. I tried that patch when I first read your post about customizepkg and it worked fine. But it doesn’t fix the problem I want to fix. I want the rotate window list patch, so I can display text in the buttons vertically. I’m working on a laptop and keep my panels thin to save space. But as it is, I see nothing in the window list buttons except “..” Making them useless.
[...] reading ArchLinux documentation. This is seriously impressive: http://versia.com/2009/09/05/arch-linux-yaourt-customizepkg-beauty/ [...]