View Full Version : 5 minute setup to build KDE 4, using kdesvn-build.

04-09-2008, 06:03 AM
One thing you can do now that Knoppix is new again...
(you will not fail any dependancies when you try, at present)
is to build a debug version of KDE 4.

I had tried this earlier a few months back, and Knoppix 5.1.1 was too old and started failing dependancies... the exact list I can't remember at present. There are many howto's out there... and even on kde's site I found them to be at times even contradictory. I could not find a specific set of instructions that I could call a reference.
I would like to see a vm of a reference platform. I made a 15GB persistent home, a knoppix.img file, and since it is possible to do... I may post a knoppix.img you can just download and begin exploring KDE building.

I won't get into setting up the Knoppix 5.3.1 DVD iso booting except to say I use grub4dos... and it boots the same iso file I downloaded to make the dvd with... using Gilles Van Ruymbeke's minirt_531.gz. Here is my kernel cmdline from the C:\menu.lst file.

ramdisk_size=100000 init=/etc/init knoppix bootfrom=/dev/hda1/KNOPPIX_V5.3.1/knoppix.iso home=/media/hda8/knoppix.img myconfig=/media/hda8 lang=us apm=power-off nomce dma vga=791 loglevel=0 libata.atapi_enabled=1 SELINUX_INIT=NO nmi_watchdog=0 ro ntfs_rw=
Notice the chopped off ntfs_rw= which should have said ntfs_rw=1 but it didn't need the =1 part. But there is a limit to the line length somewhere. I'd think it would be in grub4dos. I had to remove the quiet cheatcode though.

Using kdesvn-build I was able to build (without any fatal errors!) kde4. I have not tried to run it yet... and it may not even run at all. That all depends on what is in the repository at the time you do this. (I have seen suggestions to avoid the early part of the week, as weekend checkins are more likely to break something.) I did mine on monday night.

Here is the main kdesvn-build webpage

Here I grabbed the latest version...
Here is what you'll see somewhere close to the top of the page...
(click download, and then save that as ~/kdesvn-build)

Revision 791962 - (view) (download) (annotate) - [select for diffs]
Modified Sun Mar 30 20:48:52 2008 UTC (8 days, 22 hours ago) by dfaure
File length: 199501 byte(s)

Then you'll need a config file. I used the default one provided here.
(click download, and then save that as ~/.kdesvn-buildrc)

Next, add a new user named kde-devel by opening a Konsole and entering

sudo useradd -m kde-devel -s /bin/bash
sudo passwd kde-devel

Next, we add this user to the /etc/sudoers which must be done using visudo.
In the same terminal you can do this with sudo visudo
Once inside... cursor down to the bottom of the file... and enter exactly these keystrokes. <> are not literal keystrokes... but editing directives.

:i<press enter>
<press enter>
<press Esc>
:wq<press enter>

Then we edit /etc/group and duplicate this account's rights to be the same as the knoppix account.
Here is my edited /etc/group which you should be able to copy directly.

Ya know... ... ... instead of typing on and on about how to do this... I decided it might be better to just make a knoppix.img you can download... ready to run.

That would be here, http://home.comcast.net/~johnrw/knoppix.img.bz2

I made an image file, and compressed it. It compressed down to 8 MB, from 256 MB.
So for you... you will need to put it on a drive with at least 10 GB free. After you do that, you expand it to it's 250 MB size... then boot Knoppix 5.3.1 without mounting it.

Once you are in Knoppix you open a root terminal... and resize it to 10GB+(mine was 15GB) by using resize2fs.
For example, if you have booted the DVD, and now only have your Windows XP drive C: available... and have put the uncompressed knoppix.img on it as C:\knoppix.img... you would first mount drive c as read/write in the usual manner... and then in the root terminal type:
resize2fs /media/hda1/knoppix.img 10000M
and follow the instructions.

Now you are ready to boot Knoppix 5.3.1 and use this persistent home image to build kde from svn trunk.
You would use the
knoppix home=/media/hda1/knoppix.img 2 cheatcode in the above example.
The 2 means to not go to the kde gui... but instead go to runlevel 2 like booting to Dos.
Once you are in the root console... you should set some passwords up by typing
passwd kde-devel and setting one for the root user as well with just passwd.

Now you can login to kde-devel by typing
su kde-devel
Then you start up kde for your kde-devel user by typing

Once inside kde... opening an ordinary Konsole window and typing

./kdesvn-build and you are off to the races. When it finishes, you will have a few new directories...
~/kdesvn/ and ~/kde and ~/qt4

There are some errors you can expect to see... since you are not using snapshots.
Next I'll try and put some info on how to set this up to use.


and more building...


and waddya know... it finally finished.
Of course I did this on a slow machine :)
Notice this built and patched a special qt-copy...


I did add some Firefox extensions and even installed the Google Toolbar but you will still have to click
I accept...

I also added lmsensors but you will need to run sensors-detect in a terminal... and just keep pressing enter until
you get to the summary... where it tells you what kernel module you need to load before using it. It will offer to write a /etc/sysconfig/lm_sensors which is a .conf file without the .conf name ending. I suggest you let it.

I put a knoppix.sh in the image you can set to your module by editing it as root. Ie,

sudo kwrite /KNOPPIX.IMG/knoppix.sh and change the line that reads MODULE=it87

Once you have the correct lmsensors kernel module loaded, you can use kima to show you how hot your cpu is and if your fans are turning. Since building kde will peg your cpu on 100% for the duration... that is a good thing to know. I included kima's deb file, forgot if I installed it, but you can if I forgot to.

When done building... ~/kde and ~/qt4 contains the binaries...
and both the sources and the build are in ~/kdesvn.
The build will be in ~/kdesvn/build

That's all for now. Now I get to see if this build even runs!
Again that is at http://home.comcast.net/~johnrw/knoppix.img.bz2

Here you will find some interesting stuff but they are not setup to build with this method. Mainly
the sources and the resulting build output will vary. I will post some versions tailored to the locations we are using here.

yup... it runs. Here I have dolphin showing hidden dirs in the left pane.


and about dolphin

I'll post my .bashrc next.

04-09-2008, 08:43 AM
Here is a /home/kde-devel/.bashrc
I see some errors in here for some of these functions but it should setup the critical things.
I'll clean it up later.

Remember to use startx to startup kde after you log in to kde-devel.

# /etc/bash.bashrc
[ -f /etc/profile ] && . /etc/profile

## A script to setup some needed variables and functions for KDE 4 development.
## This should normally go in the ~/.bashrc file of your kde-devel user, so
## that it is executed when a session for that user is started.
## If you don't use a separate user, the first section with the
## environment variables should go into a separate script.

prepend() { [ -d "$2" ] && eval $1=\"$2\$\{$1:+':'\$$1\}\" && export $1 ; }

# Other
# you might want to set a full value for PATH rather than prepend'ing, to make
# sure the your kde3 path isn't in here.

# Everything kde3 seems to be in /usr/bin so /usr/sbin seems okay to leave in.

# Qt
# only set Qt related variables if you compiled Qt on your own
# (which is discouraged). if you use the distro provided Qt, skip
# this section. Comment it if necessary.
export QTDIR=$HOME/qt4
prepend PATH $QTDIR/bin
prepend PKG_CONFIG_PATH $QTDIR/lib/pkgconfig

export KDEDIR=$HOME/kde
export KDEHOME=$HOME/.kde4
export KDETMP=/tmp/$USER-kde4
mkdir -p $KDETMP
prepend PATH $KDEDIR/bin
prepend PKG_CONFIG_PATH $KDEDIR/lib/pkgconfig
prepend QT_PLUGIN_PATH $KDEDIR/lib/kde4/plugins

# DBus
# only set DBUS related variables if you compiled dbus on your own
# (which is really discouraged). if you use the distro provided dbus,
# skip this variable. Uncomment it if necessary.
#prepend PKG_CONFIG_PATH $DBUSDIR/lib/pkgconfig

# only needed on some strange systems for compiling Qt. do not set
# it unless you have to.
#export YACC='byacc -d'

unset XDG_DATA_DIRS # to avoid seeing kde3 files from /usr

# you might want to change these:
export KDE_BUILD=$HOME/kdesvn/build
export KDE_SRC=$HOME/kdesvn

# make the debug output prettier

# Make
# Tell many scripts how to switch from source dir to build dir:
# Use makeobj instead of make, to automatically switch to the build dir.
# If you don't have makeobj, install the package named kdesdk-scripts or
# kdesdk, or check out kdesdk/scripts from svn.
alias make=makeobj

# Uncomment the following lines if DBus does not work. DBus is not
# working if, when you run `dbus-uuidgen --ensure && qdbus`, you get an error.
# alias dbusstart="eval `PATH=$DBUSDIR/bin \
# $DBUSDIR/bin/dbus-launch --auto-syntax`"

# A function to easily build the current directory of KDE.
# This builds only the sources in the current ~/{src,build}/KDE subdirectory.
# Usage: cs KDE/kdebase && cmakekde
# will build/rebuild the sources in ~/src/KDE/kdebase
function cmakekde {
if test -n "$1"; then
# srcFolder is defined via command line argument
# get srcFolder for current dir
srcFolder=`pwd | sed -e s,$KDE_BUILD,$KDE_SRC,`
# we are in the src folder, change to build directory
# Alternatively, we could just use makeobj in the commands below...
if [ "$srcFolder" = "$current" ]; then
# to enable tests, add -DKDE4_BUILD_TESTS=TRUE to the next line.
# you can also change "debugfull" to "debug" to save disk space.

# uncomment the following two lines to make builds wait after
# configuration step, so that the user can check configure output
#echo "Press <ENTER> to continue..."
#read userinput

# Note: To speed up compiling, change 'make -j2' to 'make -jx',
# where x is your number of processors +1
nice make -j2 && \
make install;

# for the lazy ones, add/comment other directories
function cmakekdeall {
cs kdesupport && svn up && cmakekde
cs KDE/kdelibs && svn up && cmakekde
cs KDE/kdepimlibs && svn up && cmakekde
cs KDE/kdebase && svn up && cmakekde
cs KDE/kdepim && svn up && cmakekde
cs KDE/kdegraphics && svn up && cmakekde
cs KDE/kdemultimedia && svn up && cmakekde
cs KDE/kdenetwork && svn up && cmakekde
cs KDE/kdeutils && svn up && cmakekde

# A function to easily change to the build directory.
# Usage: cb KDE/kdebase
# will change to $KDE_BUILD/KDE/kdebase
# Usage: cb
# will simply go to the build folder if you are currently in a src folder
# Example:
# $ pwd
# /home/user/src/KDE/kdebase
# $ cb && pwd
# /home/user/build/KDE/kdebase
function cb {
# Make sure build directory exists.
mkdir -p "$KDE_BUILD"

# command line argument
if test -n "$1"; then
cd "$KDE_BUILD/$1"
# substitute src dir with build dir
dest=`pwd | sed -e s,$KDE_SRC,$KDE_BUILD,`
if test ! -d "$dest"; then
# build directory does not exist, create
mkdir -p "$dest"
cd "$dest"

# Change to the source directory. Same as cb, except this
# switches to $KDE_SRC instead of $KDE_BUILD.
# Usage: cs KDE/kdebase
# will change to $KDE_SRC/KDE/kdebase
# Usage: cs
# will simply go to the source folder if you are currently in a build folder
# Example:
# $ pwd
# /home/user/build/KDE/kdebase
# $ cs && pwd
# /home/user/src/KDE/kdebase
function cs {
# Make sure source directory exists.
mkdir -p "$KDE_SRC"

# command line argument
if test -n "$1"; then
cd "$KDE_SRC/$1"
# substitute build dir with src dir
dest=`pwd | sed -e s,$KDE_BUILD,$KDE_SRC,`
if [ "$dest" = "$current" ]; then
cd "$KDE_SRC"
cd "$dest"

# Add autocompletion to cs function
function _cs_scandir
if [ -d $base ]; then
for d in `ls $base`; do
if [ -d $base/$d ]; then
dirs="$dirs $ext$d/"

function _cs()
local cur dirs
_cs_scandir "$KDE_SRC"
_cs_scandir "$KDE_SRC/KDE" "KDE/"
COMPREPLY=( $(compgen -W "${dirs}" -- ${cur}) )

# Remove comment on next line to enable cs autocompletion
#complete -F _cs cs

function start3app {
mkdir -p /tmp/$USER-kde
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/bin/X11:/usr/games
export KDETMP=/tmp/$USER-kde
export KDEVARTMP=/var/tmp/$USER-kde
export KDEHOME=$HOME/.kde
export KDEDIR=/usr
export DISPLAY=:0
eval "$@"
source $HOME/.bashrc #Reset environment variables again

02-08-2009, 11:38 PM
Well it's been a year almost... so I revisited this page to see if it would still work.
So I downloaded the img and started following the steps I had done. A couple things are needed now that weren't before.

1. cmake - needs to be upgraded. I had to get it from experimental, as kde requires cmake 2.6.2 now.

sudo apt-get -update
sudo apt-get install -t experimental cmake

Here was the symptom:
I found this error in the log directory

CMake Error: ERROR: Could not find KDE4 kde4-config
Very illumiinating...! :)
I was long on questions and short on answers until I checked the kdesupport directory.
There it told me I need to upgrade cmake. The rest just complained about kde4-config being missing.

After you install the latest cmake, you may want to include, or at least be made aware of them, some additional variables:

The environment variable CMAKE_INSTALL_PREFIX, is supposed to point to where cmake itself is installed... should be of a minor importance unless you had to install it to a non root account.
The environment variable CMAKE_PREFIX_PATH, is intended to be a list of directories that are searched before the directories in the shell's PATH variable. Each directory in that list, is a top level directory that may also have bin/ include/ and lib/ directories.

There is now a KDEDIRS environment variable... which I just point to whatever KDEDIR is. It can hold more than one directory.
It must have been needed by some. :)


Some other things I noticed...
esfsck - After I extracted the knoppix.img to a drive... before resize2fs would allow it to be resized, it complained that I should run e2fsck -f knoppix.img. That went quickly.

/etc/sysconfig - On a completely different system, the files in the knoppix.img's /etc/sysconfig will not agree with the new machine's hardware. I needed to boot Knoppix without the Persistant $HOME mounted... and copy /etc/sysconfig to a thumbdrive. Once I booted back into the persistant home... copying /etc/sysconfig from the thumbdrive got the correct files in place. Then run mkxorgconfig to update /etc/X11/xorg.conf to the new hardware.
Now X would start on this new machine. :)

Ordinarily, you could tell knoppix-image to "Overwrite/update stored system configuration" but that feature had a bug in 5.3.1.
Someone tried to discuss it here, (http://www.knoppix.net/forum/viewtopic.php?p=118120#118120) but noone seemed to address the issue there.

Okay... let's look at the knoppix-image script that does the overwrite of those system settings... at the very bottom I found...

case "$SELECTION" in *overwrite*)
[ -z "$OLDHOMEDIR" ] && rsync --update --exclude /ramdisk/etc/mtab -Ha /ramdisk/etc/ /UNIONFS/etc

So maybe I could have just looked in /ramdisk for the new /etc/sysconfig :)

Ok... that's about all I can remember for now. I'll post my .bashrc with the new values for building KDE 4.2 from trunk, after my build finishes.

Oh look, more errors...
I'll be editing this later.

Edit1: It seems that there is some discrepancy about phonon as there are a few versions... one is called a trunk version, and another is in kdesupport. So maybe this fixes it. Edit and comment out the whole phonon module in .kdesvn-buildrc. Then add
in the kdesupport module

module kdesupport
cmake-options -DBUILD_phonon=ON
end module

Edit2: Well... they say you should not build from trunks pulled on the weekend, and maybe mondays are the worst day of all but... hey, I had time. But for me, phonon had a problem, so I just cheated. I didn't need multimedia to get a basic debug build so I removed the multimedia. Here's how I did that. (By the time you read this... it may not even be needed.)

module kdebase
end module

It sure is sweet looking!
I can't wait till Klaus puts out a Knoppix DVD with this on it!