Boy, Interrupted

Submitted by illogic-al on Sun, 06/01/2008 - 23:45

Was working on the amarok bundle again this weekend. Same problem. Can't get klauncher to load kio_file from within amarok.app. I'm not sure that this will work eventually either. What I've done is include almost everything amarok needs to run, external dependencies as well, in the bundle. I thought the external dependencies, which for our purposes, is software not provided by KDE, would have the biggest problem being place inside a bundle. Indeed, software such as dbus, needs an installation routine of its own. That's mostly because of a startup item that gets placed in /Library/StartupItems. However, it is actually the KDE software which is giving me the most problems when placed inside the bundle .

In relation to dbus, an external installer is the simplest way to get around it needing things installed outside of our sandbox. Then there's the shared-mime-info package. That requires some black magic which we can probably take care of programatically. It would be far easier to simply install to the user's computer and have a post-flight script do the work for us instead. And let's not even get to xine. Really. Let's not. In any case, phonon-qt7 should solve everything. Really. I believe in the phonon folks. They will come to our rescue.

BUT I DIE GRESS.

Instead, what I find myself fighting with is KDE's kioslave loading. Here's how the bundle is laid out.

Contents -
         - MacOS
         - Frameworks
         - share
         - lib

The MacOS and Frameworks dirs are OS Xisms. The things in share, (images, translations) would ideally go in a Resources directory. The code of course isn't setup to look for that. Instead what happens is, we look at what directory the app's executable is in, cd up to its parent directory, which is Contents, and then look for the normal directory structure there. It kinda works; if the only things to be found were items provided by Amarok. Once I start putting KDE liibraries into the bundle stuff starts not showing up. Like the splash screen. The icons (fixable). kded modules (also fixable). kioslaves (haven't figured it out yet). The most infuriating thing? Everything below lib is loaded once I use the install_name_tool to point to the correct location of libraries. Everything except the kioslaves.

In hunting down this bug I've discovered far more about how KDE works under the hood than I ever wanted to. You see (now correct me if I'm wrong here), once a KDE app starts up it invokes the almighty kdeinit4 to get the party started. kdeinit4, being the lazy type, pops out some kids to do the real work. I believe the technical term is "forking". Yes. I know. A big "Fork you". Haahaah. Highlarity ensues. Now here, I believe, is where things get hairy. Child number one says, "I really don't wanna." and taking a page out of mommy's book delegates some responsibility to klauncher. The other kids do various sundry things like start kded and knotify and konlygodknowswhatelse. Or maybe klauncher does that after the other kdeinit4 kiddies request it. I don't really know, and I don't really care. I do know that at Amarok's request klauncher attempts to open a few kioslaves. kio_trash for absolutely no good reason, kio_file to access the local filesystem, and kio_http to ride the tubes.

If the kioslaves are in their installed location, they load fine. If they're in the bundle they don't get found. Even though everything else in lib and under it does get found. Even the bloody kded modules that no one gives a rat's ass about on OS X. But the stuff we want to work, the stuff we need to work: Nooooooooooooo. We can't load that. That would just make too much sense. It's enough to drive a man to curse. I'm holding it in though. But I figured all this out in the middle of last week. I spent my weekend painstakingly adding things to the bundle, to see where the problem lie. I thought it might have something to do with the fact that I moved klauncher from its normal location @ lib/kde4/libexec to MacOS, which in our bundles acts as the bin dir. That's where kded4.app and knotify.app and kdeinit4.app are as well. Actually, anything from libexec which I need was placed in MacOS. You know what the problem really is though?

Wait for it...

Steve Jobs hates me. Having come to this realization I gave up. Actually, that's a lie. I just wanted to go see Speed Racer at the IMAX. So I did. And it was awesome. I haven't touched that damn bundle except to delete it since. In the interim I did think of possible solutions to my little problem. One involves having individual bundles for kdeinit4, kded, and knotify, and loading klauncher and the kioslaves into kdeinit4.app. I'll tell you more after it works. Or not.