Archive for August, 2006

libtool and .la files

Monday, August 28th, 2006

Well, today’s lesson was about libtool and what those curious .la files are for. I decided to go through the packages made so far (a couple of dozen) and start to clean out all the dirty hacks that I did to get started while I was learning. For example, I made a ~/.rpmmacros setting “crosspath” to set the active crosscompiler base path instead of embedding it in the spec files all over the place, and when I got started I embedded the literal path to the devel-filesystem directory (you install package-devel packages here so that other packages can link to those libs during crosscompile), now I use a relative path.

While I was at it, I decided to fix the few packages that I left getting stored into /usr/local instead of /usr, well, they ended up like that because I didn’t know what –bindir= was for in ./configure at that time. Curl and PHP fell into this category. Then I remembered that I had not understood how to link PHP to curl libraries at that time either and I could fix that too now. (When you meet something as big as ./configure and crosscompiling and packaging all at the same time, it is a terrible struggle just to get through to a successful compile and corners get cut, but once the process is familiar it’s embarrassing to go back and see what simple things need to be refactored from your early clueless threshing around.)

Anyway I recooked curl and then did PHP. To my surprise PHP kicked out right at the last link stage, it had attempted to link the host /usr/lib/libcurl.so instead of the target-compiled ones which in my system are installed into ./rpm/BUILD/devel-filesystem/usr/lib (by doing an rpm -i on the -devel package with a fake root).

I wandered around trying to understand this for a while changing env vars like LDFLAGS, but it was clear the -L path to my devel-filesystem tree had the right precedence and nothing was on the libtool commandline telling it to go to /usr/lib.

In the end as a test I moved my local /usr/lib/libcurl.so to /root and tried again — this time it linked fine using target libs as intended. Strange because it proved it was some kind of precedence issue, looking in local /usr/lib first and then using the right path if that didn’t exist. But I noticed a warning… it said that /blah/blah/libcurl.la “had moved”. I had a look in the la file — it is actually pretty cool, it is a text file that seems to be generated at library link time and contains paths to the libraries that it linked in. In this case curl has openssl in it, so that was shown and was correct. BUT what is this at the bottom?

# Directory that this library needs to be installed in:
libdir=’/usr/lib’

Hm a bit suspicious since my problems come from /usr/lib. I changed the path to point to my devel-filesystem path, and the build completed correctly!
I tried commenting out the libdir line in the .la file, but the link blows chunks complaining it can’t find the “library name” of libcurl.la. So the only way forward to allow usage of libs in the crosscompile environment seems to be to add a sed line to mess with the libdir setting in the library .la file!

Greylisting is back in town

Wednesday, August 16th, 2006

The last thing that I missed from my oldstyle PC mailserver was the greylisting implementation for postfix, Postgrey. This was not trivial to port over to the new embedded ARM mailserver box because it was written in Perl. I spent considerable time trying to get Perl packaged and crosscompiled; I did get Perl itself to build but got lost trying to get its modules to build correctly (I since learnt more about libtool that might let me finish the job if I ever have to).

Eventually I realized my life was being wasted struggling with Perl, so I looked around for an alternative greylisting solution for Postfix written in something more reasonable. I must have been having a bad day, because I landed on tumgreyspf which is written in Python. Cue another couple of days spent beating my head on Python trying to package and crosscompile another crosscompile basketcase. In a slightly shorter period of time I realized my life was wasting away so this time I looked for a greylisting addon that did not need ten tons of arguably dying language dragged in with it, and I found gps. This is written in C++ (my kinda language) and just needed a library and sqlite, or so it seemed.

I managed to finally get sqlite to crosscompile and be packaged nicely today, so at last I was ready to attack gps. gps uses an interesting database abstraction library called libdbi. I packaged that, then noticed that it has a child project libdbi-drivers which actually contains the interfaces to the various SQL backends that are possible. Finally it was all packaged and sent over to the ARM board, after a little spring cleaning to make room in its 8MByte root filesystem.
Well gps is broken for use with sqlite3, which it turns out is different from “sqlite” target in the config file. Thanks to this commendable sharing of solutions from Uffe Vedenbrant and a hack to allow sqlite3 in place of sqlite in the sources I was able to get it cooking. Because it runs as ‘nobody’ via Postfix, a little care was needed to make sure the config file and the sqlite database file were accessible for that user. However it seems the gps maintainer is a little asleep at the wheel, since Uffe’s patch was not taken in since nearly a year to the main project and it means out of the tarball gps doesn’t work at all with sqlite.
Anyway the end result is once again I have some protection from spam just like the old days, except whereas before the box to do this was pulling down ~250W 24/7 the embedded solution only pulls 1.5W, for the same capabilities!

Edit: Ooooh yes, two spams waiting for me thismorning instead of 20, lovely

Dead Languages

Monday, August 14th, 2006

Perl and Python. Now Perl there is already angst about its demise, I can second it: Perl is dying, Netcraft may later confirm it, but I can do it now.

Python dying is a bit more eyebrow-raising, since bittorrent and yum and other GTK apps are done in it and until today I assumed it had a future. But not with me. It seems to have become impossible to crosscompile the thing. In both cases the problem seems to have been a lust for bootstrapping because it was a “real language”. Because it is a “real language”, when it makes itself it just HAS to do it in its own language. So Perl first makes a miniperl app that is then used to complete the build of the rest of perl. Because perl must be so damn indispensible, you can’t even think of making Perl without doing it in Perl.

Likewise Python insists on building its modules via a Python script, run using the python it just compiled. These conceits of the language devs mean that crosscompiling is impossible, because the python or miniperl that was built WILL NOT RUN on the host that is doing the building since they are compiled for another type of CPU. The bootstrapping concept, so they can hold their head up in academia as a Real Language, destroys the possibility for crosscompile.

Dudes, you killed your languages for crosscompile. There is a lot of crosscompiling going on and it is only going to increase.

Now PHP was easy to crosscompile. Lots of people sniff at it as not being a real language, but look, I can run it down on my ARM box no trouble, and I can’t use Perl or Python. Sell Perl! Sell Python! Buy PHP!!!!

Conexant ADSL Binary driver damage

Monday, August 14th, 2006

A couple who are friends with Jenny and I asked what must be getting on for two years ago about what could be done to remove the constant virus problems they were having with their Windows box. Naturally after making sure they did not need anything that Linux was poor at, ie, 3D games and so on, I recommended FC2 at that time. I nuked their box with it and the guy has been very happy all this time. I updated him to FC4 a while back.

But now he is upgrading from dialup to ADSL, he needed this taking care of. He had a Zoom PCI Adsl card, model 5506 with a conexant chipset. I found a driver here for it:
http://patrick.spacesurfer.com/linux_conexant_pci_adsl.html

Hm so the first sign all was not well was the age of the page and the results from Google, they are all from circa 2003. This project has been continued to be worked up in the last couple of months though. After some struggle trying to avoid the 4kBytes/sec modem download we got the driver and the kernel-devel sorted out and compiled it. It quickly blew chunks, on a #error that our kernel had CONFIG_REGPARM defined. Well we run the stock Fedora kernel and are not much interested in moving off it, why on earth should the driver care about this detail? Hm closer inspection of the site showed:

”Note: Linux 2.6.* users should note that their kernel must be compiled without the “use register arguments” (CONFIG_REGPARM) option. This is an experimental option that will almost certainly never work reliably with this driver or any other driver that uses proprietary object code. Newer versions of Fedora and SuSE come with kernels that use this option, in these cases you will have to recompile the kernel.”

Ugh, so the reason it couldn’t survive CONFIG_REGPARM is because it has a binary blob which demands stack args! No chance apparently to get two binary blobs compiled with and without. This is a stupid situation, because the site itself documents that Fedora kernels after 2.6.9 on FC3 are compiled with CONFIG_REGPARM, since it should speed things up at no cost. His solution is to insist on a vanilla kernel.org kernel solely to support the needs of the binary blob :-(

We had to give up trying to get it cooking, and instead the guy blew GBP20 on an ADSL router from ebuyer. Just what awesome secrets do they think that binary blob is concealing? What astounding concepts that would set the world on fire if their sources were known?
Binary blobs, causing trouble and bitrotting where ever you find them.

I sent the guy running the project a polite email

Hi Patrick – First thanks for your work on the Conexant ADSL project. I was trying to install a Zoom ADSL PCI card for a friend, we are both running Fedora Core 5. I saw after some time that I was on a loser because there is a binary blob in the project which was basically compiled with different compiler switches to cut a long story short. What is the situation with Conexant and this blob as you understand it? It seems that the chipset dates from 2002 or 2003, is there no chance that this far down the road they might be willing to be more liberal with the sources for it? My friend and I gave up on the PCI card and ordered a GBP20 ADSL router from ebuyer instead, simply due to there being a binary blob. -Andy

I got a reply a couple of hours later, the guy does not have a relationship with Conexant and says they are ignoring his mails.

Autotools crosscompile hall of shame

Friday, August 11th, 2006

In theory autotools has good support for configuring a project to be crosscompiled, and for some projects it works very well. Often it is simply enough to set the $PATH to your compiler dir, and say ./configure –host=arm-linux. However there are some patholgical projects that blow chunks violently when presented with a crosscompile action that they claim to support.

A good example of such an evil project is perl. This generates an executable called miniperl which is used in the build process to generate the final perl executable. But it does not take care to generate miniperl using a host compiler that is different from the target compiler, so the build process generates miniperl fine, just that it can’t execute on the build host since it is an Arm ELF app. Therefore the build process drops dead.

A common issue is that the configure script wants to compile a short test app with the crosscompiler, which is fine, but it then wants to run it and look for a returncode. I added some infrastructure to the Octotux build tools scripts to enable this by prepending the helper script name to the app to be run remotely via ssh, and to capture the retcode transparently and return it to configure. Since the Octotux system captures any edits into a patchfile anyway, this is a relatively non-fragile solution.

One that caused much pain this last week is sqlite, which suffered from another common problem, the generated configure file wants to determine if include files or libraries exist, but decides that it cannot because you are crosscompiling. In this case it was the configure logic around the readline library that felt unable to survive the crosscompile action with an explicit test and fatal error. Despite hacking that out and overriding various configure defines and makefile definitions in the RPM specfile that tries to build it, there are still problems.

Edit 2006-08-13 sqlite seems to be compiled and packaged okay now, needs readline and ncurses.

Python is another monster like Perl. There are some patches to help here, but they are incomplete

http://mail.python.org/pipermail/python-dev/2003-October/039690.html

The guy who posted them had the whole crosscompiling deal politely rejected in 2003, yet the configure half supports it, even though the build process can’t handle it at all. The patches in the link seem to magically require host-compiled python and Parser/pgen, which are used on the host as part of the build process, but they are not generated anywhere, and although python can come from Fedora python, pgen isn’t available even in the -devel package. So it looks like you must compile the damn thing twice and hack the host packages into the crosscompile build process!

RT73 Belkin stick depression

Wednesday, August 9th, 2006

Sadly I have thrown three days down the toilet on trying to get a Belkin “Wireless G Network Adapter”, F5D7050, containing a Ralink RT2571 chip to work using either the Ralink RT73 driver or the newer serialmonkey rt2x00 driver which contains the rt73usb.ko driver, this is on my AT91 platform.

Initially I started, like a happy idiot, trying to get either to work with wpa_supplicant, since we have a WPA2 80211g network here. The Ralink RT73 sources did not initially crosscompile cleanly, there is a bad reference to asm/i386/… in an include, but after that it went better. However, at least when crosscompiled on gcc 4.02, this driver is a useless piece of crap, I outlined the problems here but naturally there was zero response from Ralink.
Well okay, I knew about the alternative serialmonkey driver from getting my elder stepson’s laptop working, which incorporated another Ralink chipset. They did not seem to have any support in the form of the modified Ralink drivers, but they do have a beta 2×00 driver which supports the RT73 chipset. This got a lot further, the MAC address was correctly initialized and in the end, with some coaxing, it can be made to show results from iwlist wlan0 scan that include our AP. But it won’t associate and stay associated. After I removed the encryption from the AP temporarily, I was once – one time only – able to contact the DHCP server long enough to get an IP, but then it immediately deassociated again. And this is with no encryption! Again I posted to the forums here and again there was zero response. Perhaps it is the Arm crosscompile that is freaking the devs out, but since it is littleendian and 32 bits, it’s really not so wild to expect it to just work.

Another issue – actually here is the one bit of good news from the work – is there are two versions of firmware for the RT73 I found, in the form rt73.bin. One is shipped with the ralink driver and is also available on their site, which claims to be version 1.7. The other was provided in the Win98 directory on the CDROM that came with the Belkin device and is referred to as version 1.0 in the debug output. The Ralink-supplied driver has its own code to grab the file from a specific path – /etc/Wireless/something – and also has a private copy of the firmware in the sources of the driver itself if it can’t find the driver in its magic path. The serialmonkey driver does it the proper Linux way using the firmware API in the kernel. Anyway this was the good news, I learned how this worked and created a hotplug script that is compatible with it, allowing it to load the firmware successfully from /lib/firmware.

Anyway, while I have been saying recently that the wifi driver problems are largely resolved in Linux, which has been my experience on x86 laptops, they sure as hell aren’t resolved for crosscompile usage :-( ((

Edit 2006-08-13: I posted to the serialmonkey project mailing list about it, it’s too tantalizing close to forget about it.  Head serialmonkey replied, “send hardware”.  Trying to see how feasible that it, since they need a build env and so on.

Postfix relaying for Dynamic clients

Wednesday, August 9th, 2006

My in-laws have a Fedora box on residential ADSL in Spain. They experienced trouble with the terra.es mailservers, so I installed Postfix for them and set Thunderbird to use this local Postfix to directly forward their mail to the destination.

This works well except for a correspondent in Australia, who is on bigpond.com. They use a blackholing service which has blackholed the whole residential ADSL netblock for their ISP, on the basis a lot of spam is coming directly from compromised Windows boxes, meaning that the Postfix on their box doesn’t get anywhere talking to bigpond (and annoyingly bigpond rejects the mail with a 450 not a 550, delaying notification that there are problems).

I am in a similar position, I run my own MX at home where I work, so mail is sent directly to me, but I am unable to reliably send outgoing mail directly due to some blackhole lists including my whole netblock. My solution is to run a Postfix instance on warmcat.com, which is not used for incoming mail and is firewalled off from everyone except my home IP address. As a belt-and-braces, the Postfix on warmcat.com is configured to only relay from my IP address anyway.

So the obvious solution to the problem with the in-laws would be to also route their outgoing mail through warmcat.com, which pretty much everybody will talk to since it is sat in a server farm. But the fly in the ointment is that they are on residential ADSL, their IP address is changing every boot. I don’t want to add an authentication layer because I don’t want to disrupt their mail any further while I get it working and the pinhole in the Firewall method is working fine for me too.

The first move was to regularize their dynamic IP using dyndns.org and the perl client from there. This gave me a reliable FQDN that always resolves to their machine. Then the problem was simplified to “how can I get Postfix to accept a list of clients allowed to relay using FQDNs? And to track changes where the DNS mapping is dynamic?”. It seems that you can’t, it only accepts netblocks.

To solve this problem I created the following script which runs from a cronjob. See inside the script for instructions. (more…)