Wednesday, December 31, 2008

Khrooty4Daily - Highly Experimental!

Experiment - Khrooty4Daily

Not much feedback here (but thanks to those wo did reply :)), but, hey - let's give it a go anyway!

I've cleaned up and uploaded a copy of Khrooty4Daily which you can find here. A few notes before people download it:


  • I'm going in completely blind here, and have no idea if this will work across distros - it could easily simple fail for most people at the first hurdle.

  • A chroot is not as insulated as a VM - in particular, processes started in the chroot are not separated from those started outside the chroot.

  • Again unlike a VM, it's possible for apps in a chrooted environment to e.g. crash/ lockup your X session.

  • Based on John's blog here, it seems at least possible that the chrooted KDE4Daily session won't run concurrently with an existing KDE4 session, which is a big shame, if true.

  • I have some difficulty unmounting /dev/ from the chroot, apparently necessitating a reboot if I want to delete the chroot. Important Note: Under no circumstances should you attempt to delete the chroot without properly unmounting it!



Potential doom and gloom aside (I prefer to err on the side of caution :)), it would be great if at least a handful of people - preferably spanning a goodly range of distros - could download and try it and report their findings here :) As mentioned, I've not tried this before outside of Kubuntu 8.04, so if any step fails for you, please post here.

So, from the top, open a shell and navigate to where you want the chroot to be. You will need root access. Download it:

wget "http://home.kde.org/~kde4daily/Khrooty4Daily4.2-experimental.tar.bz2"

Check the md5sum:

md5sum Khrooty4Daily4.2-experimental.tar.bz2
dad7d49fe39e416ff36f3ab59bf23229 Khrooty4Daily4.2-experimental.tar.bz2

Extract *as root* (should take up <2.5 GB). The "p" flag is important, here: we want things that should have root ownership (e.g. kcheckpass) to have root ownership.

tar -xjpf Khrooty4Daily4.2-experimental.tar.bz2

Quick spot-check that the permissions are OK:

ls -l kde4daily-chroot/usr/bin/kcheckpass
-rwsr-sr-x 1 root root 14934 2008-12-06 10:33 kde4daily-chroot/usr/bin/kcheckpass

We now need to mount /sys, /proc and /dev in the correct places in the chroot - please refer to the warning about /dev, above. Again *as root*:

mount -o bind /proc kde4daily-chroot/proc
mount -o bind /sys kde4daily-chroot/sys
mount -o bind /dev kde4daily-chroot/dev

If all has gone well, you are now ready to chroot into your new Khrooty4Daily environment! *As root*, do:

chroot kde4daily-chroot /bin/bash

You will now be running as the root user inside your Khrooty4Daily chroot. You might want to change the password of kde4daily at this point. Let's switch to our kde4daily user:

su - kde4daily

The command-prompt should be red.


The story so far ...


Let's do a quick update:

kde4daily-update

Ok, now to try starting up a GUI session. I believe it's possible to run apps from the chroot transparently inside your current X session, or give Khrooty4Daily a full-blown X session of it's own or even, I would guess, to eventually add it as a selectable option to KDM, but I don't really feel comfortable with that, so I'll just use Xephyr for now. Install Xephyr from your distros packages, and start it up. I'll use screen :1 as I only have one display - you might need to use a different number. There may or may not be xhost authorisation required - please let me know :) Let's use a 1024x600 screen. *Outside* of your chrooted session, launch Xephyr:

Xephyr -screen 1024x600 :1

Now from within your chrooted session, do

export DISPLAY=localhost:1
startkde

The localhost appears to be necessary. The :1 should obviously match the :n you used when launching Xephyr. All being well, Khrooty4Daily should launch in your Xephyr window!


Success!


Obviously, if something has gone wrong before you get to this point, please let me know. If not, let's do something daring - let's compile Amarok!

In your Khrooty4Daily session, open up a Konsole and navigate to the KDE4DAILY_SOURCE_DIR (this is just a convention - you can bung it anywhere you want, but it's simpler this way for the time being.)

cd $KDE4DAILY_SOURCE_DIR

Amarok lives in the multimedia (extragear) module (http://websvn.kde.org/trunk/extragear/multimedia/). Due to the way the KDE build system is arranged, we'll have to check out and run cmake on the whole module, although we'll only be actually compiling Amarok itself. Check out the source; we'll put it into a directory called extragear-multimedia to differentiate it from ordinary multimedia:

svn co svn://anonsvn.kde.org/home/kde/trunk/extragear/multimedia extragear-multimedia

Let's make a corresponding build dir for doing out-of-source builds. Again, I'll use $KDE4DAILY_BUILD_DIR by convention:

mkdir $KDE4DAILY_BUILD_DIR/extragear-multimedia
cd $KDE4DAILY_BUILD_DIR/extragear-multimedia

Khrooty4Daily provides the cmakekde command as described on techbase, but this command implicitly does a make && make install on the whole module, whereas we want to do cmake on the whole module, but only make && make install inside the amarok dir. So I provided the onlycmakekde command. This is roughly analogous to the "./configure" step of autotools:

onlycmakekde $KDE4DAILY_SOURCE_DIR/extragear-multimedia

Ordinarily you'd have to hunt around for dependencies at this stage, but Khrooty4Daily is jam-packed with them :)


Almost too easy ...


Now we just need to compile amarok. Make yourself a nice cup of tea during this step - you've earned it! If you have a multi-core CPU, you might want to tweak the "make" parameters.

cd amarok
make VERBOSE=1 && make install

If all goes well (it did at the time of writing), Amarok should be installed and ready to launch! I can't get the Xine backend to work (almost certainly my fault) so I have to change the backend to GStreamer in The Multimedia section of System Settings.


Switching to the GStreamer Backend



Kind of!



Groovy!


Funky Music not included :)

To exit the chroot, simply

exit


from the chroot session until you get back to the shell on the host machine that you entered the chroot from. It doesn't appear to be necessary to unmount your /proc, /sys and /dev unless you're fed up with the chroot and want to delete it, so I always leave mine mounted. If and when you do decide to delete khrooty4daily, you will need to unmount it. From the directory containing khrooty4daily, and as root:

umount kde4daily-chroot/proc
umount kde4daily-chroot/sys
umount kde4daily-chroot/dev

As mentioned, the unmount of /dev might fail. DO NOT attempt to delete kde4daily-chroot until it has been cleanly unmounted! You may need to reboot in order to achieve this. When you are 100% sure that it is no longer mounted, simply delete the kde4daily-chroot directory - this step will need to be performed as root, so it's best to do it from the command-line.

And that's it! Assuming everything went OK, and you haven't followed the instructions too blindy and deleted khrooty4daily, you can check out source for other modules or apps from kde-apps.org and compile them, hack on them, install kdevelop3 from the repositories or kdevelop4 from SVN, whatever floats your coding boat, and get stuck in. Maybe sign up for Klassroom, or help out with the million and one other tasks that could all use an extra pair of hands :)

Good hunting!

27 comments:

hikingpete said...

I recommend looking into umview. It might let you do the /dev mounting and chrooting without being root. It's used by Klik2.

ABCD said...

also, I would suggest either bind mounting /dev/pts or doing a `mount -t devpts devpts kde4daily-chroot/dev/pts`, as that is (on almost all Linux systems) a separate mount, and not copied with a bind mount (unless you use `mount --rbind /dev kde4daily-chroot/dev`)

ivan said...

I couldn't find 'kde4dailyupdate' in the tarball. Where can I get it?

SSJ said...

@ivan

Sorry, that was a typo - it should be

kde4daily-update

Raven24 said...

That sounds like a great way to test kde sources without having to run a vm (and the slow-motion-like experience of one).
I have to give it a try after I played a bit more with kde4daily...

SSJ said...

@Raven24:

Let me know how it goes - I'm interested in successes as well as failures, especially if I can get a "It works" from users of a range of different distros!

Raven24 said...

Ok here is how it went: I did everything according to the instructions, only when I was supposed to startkde it first didn't work but after trying it as root (which failed) and then again trying it as kde4daily, kde started successfully.
Right now everything seems to be working pretty good and I even compiled amarok2 and listened to a few songs.

You wrote you were using Kubuntu 8.10, well, so am I. But I can try to run it on a Fedora or Suse if I get a chance at my university some time next week.

Maybe I'll even look into coding a plasmoid ... who knows ;-)

SSJ said...

"Ok here is how it went: I did everything according to the instructions, only when I was supposed to startkde it first didn't work but after trying it as root (which failed) and then again trying it as kde4daily, kde started successfully."

That's strange that it failed the first time, but at least it worked in the end :)

"Right now everything seems to be working pretty good and I even compiled amarok2 and listened to a few songs."

Great!

"You wrote you were using Kubuntu 8.10, well, so am I."

Actually, the chroot is 8.10 - I'm using 8.04. So it works on at least one other distro, which is promising :)

"But I can try to run it on a Fedora or Suse if I get a chance at my university some time next week."

That would be greatly appreciated!

"Maybe I'll even look into coding a plasmoid ... who knows ;-)"

Hehe :)

Raven24 said...

Ok now I know why I couldn't login the first time. When I chrooted into kde4daily I was root. Then I switched user by typing
su kde4daily
It didn't work with that so I exited to root again and tried it there. When it didn't work there either I switched user again, but this time with
su - kde4daily
as described in your text. I am not sure what the "-" does, but it seems that it was my mistake after all and that if I would have followed the instructions more blindly it would have worked the first time. ;-)
(I noticed that because when I tryed to play around in kde4daily today, I made the same mistake.)

SSJ said...

@Raven24:

Ah, mystery solved :) According to su --help, "-" means "make this a login shell", so it's probably sourcing some critical ~/.bash* file that it wouldn't otherwise (/home/kde4daily/.bashrc has tons of essential stuff in it).

Moshe Basanchig said...

I'm using Ubuntu 8.10, and it was necessary to use "-ac" as a parameter to Xephyr.
Great job in the entire chroot solution. I always wanted to help KDE 4.2, and now I have an easy way.
Is it possible to turn on the desktop effects?

SSJ said...

@Moshe:

Thanks for the info! It's possible to use XRender in Xephyr, which gives you some of the common desktop effects (but not the full set that OpenGL supports). Make sure you choose XRender as your backend before Apply'ing.

It's also possible, I gather, to run the chroot'd kwin in your normal X session and if that has composite and OpenGL, you should be able to get the full range of effects. I don't know enough to be able to write up a guide, though, but Google should help :)

Remember that Khrooty4Daily is compiled in debug mode (although you can of course easily re-compile it in Release mode, if you wish) so effects might be slower than they could be.

Good luck!

Greg said...

Working on Debian Lenny. (which is not released yet)

Things I had to change:

- Needed to make kde4daily a member of the audio group to get sound to work.
- Needed to `mount -o /dev/pts ...` to get Konsole to actually display a prompt
- Needed the -ac switch on Xephyr

Other than that, everything is working well! Thanks for putting this together -- it's actually my first experience with KDE4.

SSJ said...

Thanks for the valuable info Greg - glad it all worked out for you in the end!

If I get a few more testimonials from users of other distros e.g. Gentoo, Suse, Fedora, Mandriva, etc, I'll roll all this information together and put in on a page somewhere :)

PhantomsDad said...

Works great! Thank you.

My experience is the same as Greg's.

Apparently, amarok no longer lives in extreagear/multimedia.

I had some trouble resolving network names of machines on my local lan, which I solved by copying /etc/resolv.conf kde4daily-chroot/etc/resolv.conf.

SSJ said...

@PhantomsDad:

Thanks for the feeback - the resolv.conf thing will definitely be added to any guides that I may write in the future!

Amarok appears not to have moved from extragear-multimedia - what problems are you having? Oh, and what distro did you try khrooty4daily on? :)

PhantomsDad said...

Hmm, seems amarok IS part of extragear/multimedia. However, the onlycmakekde step didn't work for me, so I did not end up with an amarok directory in the build directory.

onlycmakekde $KDE4DAILY_SOURCE_DIR/extragear-multimedia
-- Found Qt-Version 4.4.3 (using /home/kde4daily/install/qt-copy/bin/qmake)
-- Found X11: /usr/lib/libX11.so
-- Phonon Version: 4.2.96
-- Found KDE 4.2 include dir: /home/kde4daily/install/kde/include
-- Found KDE 4.2 library dir: /home/kde4daily/install/kde/lib
-- Found the KDE4 kconfig_compiler preprocessor: /home/kde4daily/install/kde/bin/kconfig_compiler
-- Found automoc4: /home/kde4daily/install/kde/bin/automoc4
-- Could NOT find KdeMultimedia (missing: KDEMULTIMEDIA_LIBRARIES KDEMULTIMEDIA_INCLUDE_DIR)
-- Could NOT find Taglib (missing: TAGLIB_INCLUDES TAGLIB_LIBRARIES)
-- Found MySQL: /usr/include/mysql, /usr/lib/libmysqlclient.so
-- Found MySQL Embedded: /usr/include/mysql, /usr/lib/mysql/libmysqld.a
-- Found ALSA: /usr/lib/libasound.so
-- WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig
-- WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig
-- WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig
-- WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig
-- WARNING: you are using the obsolete 'PKGCONFIG' macro use FindPkgConfig
have cairo cflags: ldflags:-lcairo;-lpangocairo-1.0 -lpango-1.0 -lcairo -lgobject-2.0 -lgmodule-2.0 -lglib-2.0
extra -I/usr/include/cairo -I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/dbus-1.0 -I/usr/lib/dbus-1.0/include -I/usr/include/glib-2.0 -I/usr/lib/glib-2.0/include libs -lcairo -L//lib -ldbus-glib-1 -ldbus-1 -lgobject-2.0 -lglib-2.0
build npp
--

--

-- Configuring done
-- Generating done
-- Build files have been written to: /home/kde4daily/build/extragear-multimedia
kde4daily@newton:~/build/extragear-multimedia$ ls
CMakeCache.txt cmake_uninstall.cmake doc kmplayer
CMakeFiles CPackConfig.cmake kaffeine kplayer
cmake_install.cmake CPackSourceConfig.cmake kaffeinegl lib
CMakeTmp CTestTestfile.cmake kmid Makefile

PhantomsDad said...

Problem with amarok is probably my fault. I've modified the .bashrc file and prolly broke something. Don't worry about it, unless other people are having the same problem. And thanks!

SSJ said...

"Problem with amarok is probably my fault. I've modified the .bashrc file and prolly broke something. Don't worry about it, unless other people are having the same problem. And thanks!"

Hehe - OK, thanks :)

PhantomsDad said...

Wasn't my "fault" afterall. amarok did not build because of missing taglib dependency. Here's solution:

sudo aptitude install libtag1-dev

PhantomsDad said...

One more thing. xine worked for me as Phonon backend, but I had installed the xine gui before I started amarok. This installed some libraries so maybe that is why it didn't work for you.

sudo aptitude install xine-ui

SSJ said...

@PhantomsDad:

Thanks for the info! I guess the Amarok dependencies must have changed since I compiled it.

kolstae said...

Great post!

Been using kde4daily on VirtualBox for both 4.1(?) and 4.2, this really is a step up! Thanks

Working on openSUSE 11.1 (x86_64)

I had to `mount -o /dev/pts ...` to make konsole work (thanks Greg)

SSJ said...

kolstae:

Cool :) Thanks for giving me the first bit of feedback from a non-Debian-based distro - and non-32-bit, too :)

Daniel said...

Great Work!

Just tested - and works here under Kubuntu 8.04

PhantomsDad said...

Now that kde4daily is at end of life, what is the best way forward to keep up with the latest code? I'd hate to have to build all the kde packages. There's neon, but how do I use that with kde4daily, which has installed everything to /home/kde4daily/install?

What are others planning on doing going forward?

SSJ said...

@PhantomsDad:

Compiling from source should be relatively easy (it's what Khrooty4Daily is used for, after all ;)), but if you don't have time/ desire, simply renaming the .bashrc (to .bashrc.kde4daily, for example) and logging in and out should move the KDE4Daily stuff out of the way, allowing you to use your own packages without interference (obviously, if you do this, you won't have a working KDE/ Qt installation until you install one yourself via e.g. Project Neon!).

If things go wrong, moving .bashrc.kde4daily back to .bashrc and logging in and out again should restore your kde4daily install.

If you've moved the stock .bashrc aside or deleted it, installed Project Neon or whatever, and are 100% happy with your own non-KDE4Daily KDE install, then you can delete $KDE4DAILY_INSTALL_DIR if you want to save space.