Pages

September 29, 2010

Scrpit for building Debian Squeeze libcairo2 with Ubuntu patches

[Update 2011-06-25: Indeed, you should consider this post obsolete. See this post for more info.] 
[Update 2011-06-24: This whole business may be unnecessary as it appears installing a recent version of Iceweasel from http://mozilla.debian.net/ also installs new libcairo2 with decent font rendering. I've yet to do careful comparisons, but it's possible that this solves both "ugly rendering in general" as well as "ugly rendering in Firefox" issues.]
[Update 2011-03-06 Reader datSilencer points out that the location of the Arch patch has changed. I have updated the script to reflect the change.]

Based on the post I wrote earlier, which is itself based on work published in a CrunchBang Linux Forum thread and by quanliking, I put together a script for quasi-automatically building libcario2 for Squeeze using the Ubuntu and Arch patches.

You can get the script at http://download.tuxfamily.org/skinny/libcairo2-patched/build-libcairo2.sh.

Prerequisites
  • Enable sources in your /etc/apt/sources.list (i.e.,  make sure sources.list has something similar to deb-src http://ftp.us.debian.org/debian/ squeeze main non-free contrib in it). If you make any changes, be sure to # apt-get update
  • # apt-get install build-essential devscripts fakeroot
  • # apt-get build-dep cairo
To use
  1. Download build-libcairo2.sh into the directory where you plan to build the packages. I recommend you start with a dedicated and empty directory.
  2. Open the script in a text editor and change the constants at the top as documented.
  3. Make the script executable and execute it:
    $ chmod +x build-libcairo2.sh
    $ ./build-libcairo2.sh
  4. Part of the way through, it will prompt you to fill in a line that opens in your default CLI editor. Do what it asks.
  5. When it's finished, open a term and follow the directions to install.
Rebuilding
When it comes time to rebuild (i.e., after a new Debian release) you must start over with an empty directory. Or at the very least, you must rename the top-level folder named libcairo2 that your previous build generated. This is to make sure that you get the most recent everything and that there are no goofy problems that might lead to a build that melts Arctic ice or increases the mercury content of fish.

Todo
An obvious bit of low-hanging fruit is to make entering of version info interactive, but it's arguable that that would be easier and less error prone that editing the script.

To round this out, we also need an additional script or package that adds the needed files from Ubuntu's fontconfig-config package to /etc/fonts/conf.avail and /etc/fonts/conf.d.

Notes
I uploaded the i386 packages that I built for my own use to http://download.tuxfamily.org/skinny/libcairo2-patched. Feel free to try these if you don't feel like building them yourself. However, I'm not making any promises that I'll keep these up-to-date.

Legal disclaimer
I have tested the code and packages mentioned here to make sure they don't bruise kittens or eat children. However, I wrote and built this stuff for my own use and have made it available here with no warranty of any kind whatsoever in the hopes it might be useful to others. Use at your own risk.

14 comments:

Anonymous said...

Thanks, really usefull.

datSilencer said...

Hi. It seems that the ubuntu cairo patch URL has changed to this:

http://aur.archlinux.org/packages/cairo-ubuntu/cairo-ubuntu.tar.gz

What would I need to change in the script to patch the source? Thanks!

Mithat said...

@datSilencer

Grrrr. I'll try to look into it later in the week and make a fix.

Mithat said...

I have updated the script to reflect the change in the Arch patch as mentioned by datSilencer above.

Unknown said...

The patches doesn't work for me.
Look here: http://pastebin.com/VDLnJr61

Mithat said...

@ Miguel

The script was made for libcairo2 1.8 -- which is the version in Squeeze (currently at 1.8.10-6). You appear to be building libcairo2 1.10.

Unknown said...

I get the following error while running the script (Running Debian Testing).

********************************
-e In the editor that appears next, add something like the following
text after the first asterisk (*):
'David Turner's ClearType-like LCD filtering patch and fix.'
Then save and exit the editor.

Press to continue...read: 94: arg count

Mithat said...

@ Lother: I just tried building on both my Wheezy machine and on a Squeeze machine. Both cases were successful, so I don't know why you are seeing this error.

What I find strange in your output listing is that the first line has an "-e" in it. The "-e" is supposed to be interpreted by the echo command as an argument, not as text it should output. How are you running the script?

Unknown said...

I'm running it using the "sh ./scriptname.sh" command in the root terminal in GNOME.

Mithat said...

@Lothar: I am pretty sure that invoking the script with sh rather than bash is a factor in your problem. (build-libcairo2.sh was written as a bash script.)

To test this, I just wrote a script foo.sh with a single line echo -e "Foobar \nFoo". When I run it as
$ sh foo.sh
I get the -e output as you did. When I run it as
$ bash foo.sh
it runs as expected.

build-libcairo2.sh is tested (and expected to be run) by setting its execute bit:
$ chmod +x build-libcairo2.sh
and then running it with the bash shebang setting the shell:
$ ./build-libcairo2.sh

I suggest you try this. But if for some reason you really don't want to set the execute bit, then at least try:

$ bash build-libcairo2.sh

Also, there's no need to run it in a root term. Just use a regular user term. The resulting packages will be owned by the user, but dpkg doesn't care who owns them when you go to install them.

Unknown said...

Thanks, it works! :)

Unknown said...

http://aur.archlinux.org/packages/ca/cairo-ubuntu/cairo-ubuntu.tar.gz

change directory arch rep

linuxpixie said...

Unfortunately, as of now, this script fails to build on packages from Ubuntu 12.04 and Debian Wheezy.
So I am stuck with ugly fonts in Debian.

Mithat said...

@linuxpixie: Please check out the Update 2011-06-25 at the top of the post!