On November 26, [the Qt/KDE Debian team](http://qt-kde.debian.net/) (qkd from now on) [released an
experimental packaging of KDE SC 4.7](http://lists.debian.org/debian-kde/2011/11/msg00018.html).
This means a substantial and very much awaited upgrade from the
actual version available in `sid`, 4.6.5 . From what I've been told, it has taken
so long because there have been a lot of changes in source code structure (KDE has
recently restructured its source modularization) and in packaging itself, and
even with recent aditions to the group, the resources in terms of developers is
still low. In any case, thanks to them for getting this version out, I really
appreciate your hard work.

But because of this lack of resources, they only got out packages for the `amd64`
architecture, and I'm running `i386` at home, so I decided to try and compile it
by myself. This is the log of the attempt.

First, I added `deb-src http://qt-kde.debian.net/debian experimental-snapshots main`
to my `sources.list` and got the code for `kde4libs`, the package I think is the
root of the whole repo[^1][^2]:

    mdione@mustang:~/src/system/debian$ apt-get source kde4libs
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    NOTICE: 'kde4libs' packaging is maintained in the 'Git' version control system at:
    git://git.debian.org/pkg-kde/kde-sc/kde4libs.git
    Need to get 12.4 MB of source archives.
    Get:1 http://qt-kde.debian.net/debian/ experimental-snapshots/main kde4libs 4:4.7.2-0r3 (dsc) [4,883 B]
    Get:2 http://qt-kde.debian.net/debian/ experimental-snapshots/main kde4libs 4:4.7.2-0r3 (tar) [12.1 MB]
    Get:3 http://qt-kde.debian.net/debian/ experimental-snapshots/main kde4libs 4:4.7.2-0r3 (diff) [334 kB]
    Fetched 12.4 MB in 1min 54s (109 kB/s)
    gpgv: Signature made Sat 22 Oct 2011 02:29:45 AM CEST using RSA key ID 73A85F31
    gpgv: Can't check signature: public key not found
    dpkg-source: warning: failed to verify signature on ./kde4libs_4.7.2-0r3.dsc
    dpkg-source: info: extracting kde4libs in kde4libs-4.7.2
    dpkg-source: info: unpacking kde4libs_4.7.2.orig.tar.bz2
    dpkg-source: info: unpacking kde4libs_4.7.2-0r3.debian.tar.gz
    dpkg-source: info: applying kconf_update_migrate_from_kde3_icon_theme.diff
    dpkg-source: info: applying add_debian_build_type.diff
    dpkg-source: info: applying disable_usr_lib_install_rpath.diff
    dpkg-source: info: applying make_libkdeinit4_private.diff
    dpkg-source: info: applying default_kde4_xdg_menu_prefix.diff
    dpkg-source: info: applying qt4_designer_plugins_path.diff
    dpkg-source: info: applying hardcode_ptm_device.diff
    dpkg-source: info: applying kfreebsd_support.diff
    dpkg-source: info: applying debian_menu.diff
    dpkg-source: info: applying findservicebydesktoppath_try_realfilepath.diff
    dpkg-source: info: applying findqt4_optional_x11_pthread.diff
    dpkg-source: info: applying use_dejavu_as_default_font.diff
    dpkg-source: info: applying hack_in_etc_kde4_in_kstandarddirs.diff
    dpkg-source: info: applying ld_exclude_libs_qtuitools.diff
    dpkg-source: info: applying konsole_kfreebsd_fix.diff
    dpkg-source: info: applying hurd_support.diff
    dpkg-source: info: applying kfileshare_kdesu_fileshareset.diff
    dpkg-source: info: applying relax_plugin_kde_version_check.diff
    dpkg-source: info: applying add_dlrestrictions_support.diff
    dpkg-source: info: applying findpythonlibrary_layout_deb_on_debian.diff
    dpkg-source: info: applying ktar_header_checksum_fix.diff
    dpkg-source: info: applying ktar_longlink_length_in_bytes.diff
    dpkg-source: info: applying nepomuk_unicode.diff

Nice, now get the build-deps:

    mdione@mustang:~/src/system/debian$ sudo apt-get build-dep kde4libs
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Build-Depends dependency for kde4libs cannot be satisfied because candidate version of package shared-desktop-ontologies can't satisfy version requirements

Dang, I have an old `shared-desktop-ontologies` (v. 0.6.x in `sid`), and peeking
in qkd's repo I find no new version of it. The answer must be in `experimental`,
so I add `deb http://ftp.nl.debian.org/debian/ experimental main` to my `sources.list`
and run `apt-get update`. Now it must be just a matter of:

    mdione@mustang:~/src/system/debian$ sudo apt-get install -t experimental shared-desktop-ontologies
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages will be upgraded:
      shared-desktop-ontologies
    1 upgraded, 0 newly installed, 0 to remove and 103 not upgraded.
    Need to get 129 kB of archives.
    After this operation, 4,096 B of additional disk space will be used.
    Get:1 http://ftp.nl.debian.org/debian/ experimental/main shared-desktop-ontologies all 0.8.0-1 [129 kB]
    Fetched 129 kB in 1s (92.7 kB/s)
    Retrieving bug reports... Done
    Parsing Found/Fixed information... Done
    Reading changelogs... Done
    apt-listchanges: Mailing root: apt-listchanges: changelogs for mustang
    (Reading database ... 218251 files and directories currently installed.)
    Preparing to replace shared-desktop-ontologies 0.6.0-1 (using .../shared-desktop-ontologies_0.8.0-1_all.deb) ...
    Unpacking replacement shared-desktop-ontologies ...
    Setting up shared-desktop-ontologies (0.8.0-1) ...

And I try again:

    mdione@mustang:~/src/system/debian$ sudo apt-get build-dep kde4libs
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following NEW packages will be installed:
      hspell libacl1-dev libattica-dev libattr1-dev libdbusmenu-qt-dev libdlrestrictions-dev libpolkit-qt-1-dev libqca2-dev libstreamanalyzer-dev libstreams-dev
      libutempter-dev pkg-kde-tools
    0 upgraded, 12 newly installed, 0 to remove and 8 not upgraded.
    Need to get 1,170 kB of archives.
    After this operation, 3,551 kB of additional disk space will be used.
    Do you want to continue [Y/n]?
    [...]

We're set! now to fire the compilation itself. The method I use must not be the
best one, but I remember it by heart and works for me :)

    mdione@mustang:~/src/system/debian$ cd kde4libs-4.7.2/
    mdione@mustang:~/src/system/debian/kde4libs-4.7.2$ nice -n 19 fakeroot debian/rules binary

Notice I use `nice` to not hog too much my computer and `fakeroot`. I don't
remember why I must use it :| , but I remember I must. Later, asking in `#debian-devel`
I was pointed to `dpkg-buildpackage`, to which you can give the `-j#` option,
which makes the package to be compiled with `#` processes in parallel (actually
it only works if the compilation is `make` based, as is in this case), so from
now on I'll use that.

The resulting packages are these:

    kdelibs5-data_4.7.2-0r3_all.deb
    kdelibs5-dbg_4.7.2-0r3_i386.deb
    kdelibs5-dev_4.7.2-0r3_i386.deb
    kdelibs5-plugins_4.7.2-0r3_i386.deb
    kdelibs-bin_4.7.2-0r3_i386.deb
    kdoctools_4.7.2-0r3_i386.deb
    libkcmutils4_4.7.2-0r3_i386.deb
    libkde3support4_4.7.2-0r3_i386.deb
    libkdeclarative5_4.7.2-0r3_i386.deb
    libkdecore5_4.7.2-0r3_i386.deb
    libkdesu5_4.7.2-0r3_i386.deb
    libkdeui5_4.7.2-0r3_i386.deb
    libkdewebkit5_4.7.2-0r3_i386.deb
    libkdnssd4_4.7.2-0r3_i386.deb
    libkemoticons4_4.7.2-0r3_i386.deb
    libkfile4_4.7.2-0r3_i386.deb
    libkhtml5_4.7.2-0r3_i386.deb
    libkidletime4_4.7.2-0r3_i386.deb
    libkimproxy4_4.7.2-0r3_i386.deb
    libkio5_4.7.2-0r3_i386.deb
    libkjsapi4_4.7.2-0r3_i386.deb
    libkjsembed4_4.7.2-0r3_i386.deb
    libkmediaplayer4_4.7.2-0r3_i386.deb
    libknewstuff2-4_4.7.2-0r3_i386.deb
    libknewstuff3-4_4.7.2-0r3_i386.deb
    libknotifyconfig4_4.7.2-0r3_i386.deb
    libkntlm4_4.7.2-0r3_i386.deb
    libkparts4_4.7.2-0r3_i386.deb
    libkprintutils4_4.7.2-0r3_i386.deb
    libkpty4_4.7.2-0r3_i386.deb
    libkrosscore4_4.7.2-0r3_i386.deb
    libkrossui4_4.7.2-0r3_i386.deb
    libktexteditor4_4.7.2-0r3_i386.deb
    libkunitconversion4_4.7.2-0r3_i386.deb
    libkutils4_4.7.2-0r3_i386.deb
    libnepomuk4_4.7.2-0r3_i386.deb
    libnepomukquery4a_4.7.2-0r3_i386.deb
    libnepomukutils4_4.7.2-0r3_i386.deb
    libplasma3_4.7.2-0r3_i386.deb
    libsolid4_4.7.2-0r3_i386.deb
    libthreadweaver4_4.7.2-0r3_i386.deb

Next package is `kadebase`. Again, we find the missing deps with:

    mdione@mustang:~/src/system/debian$ sudo apt-get build-dep kdebase
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    E: Build-Depends dependency for kdebase cannot be satisfied because candidate version of package kde-sc-dev-latest can't satisfy version requirements

The message is simlar to the one about `shared-desktop-ontologies`, but I have
not even the slightest idea which one of the packages above is the one
responsible for it, so I'll just install everything, as most probably they're
`build-dep`s for most of the remaining packages (it's `kde5libs`, after all):

    mdione@mustang:~/src/system/debian$ sudo dpkg -i *.deb
    (Reading database ... 218481 files and directories currently installed.)
    [...]

After that I try again, but still the same thing. Poking around I find that a
package with that name exists (it's the first time I met him, __enchanté__), so I
get the source in the usual way:

    mdione@mustang:~/src/system/debian$ apt-get source meta-kde
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Need to get 14.0 kB of source archives.
    Get:1 http://qt-kde.debian.net/debian/ experimental-snapshots/main meta-kde 5:71~pre15 (dsc) [2,098 B]
    Get:2 http://qt-kde.debian.net/debian/ experimental-snapshots/main meta-kde 5:71~pre15 (tar) [11.9 kB]
    Fetched 14.0 kB in 0s (49.3 kB/s)
    gpgv: Signature made Mon 21 Nov 2011 09:38:12 PM CET using RSA key ID 73A85F31
    gpgv: Can't check signature: public key not found
    dpkg-source: warning: failed to verify signature on ./meta-kde_71~pre15.dsc
    dpkg-source: info: extracting meta-kde in meta-kde-71~pre15
    dpkg-source: info: unpacking meta-kde_71~pre15.tar.gz

And to compile:

    mdione@mustang:~/src/system/debian$ ( cd meta-kde-71~pre15 && nice -n 19 dpkg-buildpackage -j3 -b -us -uc )
    dpkg-buildpackage: source package meta-kde
    dpkg-buildpackage: source version 5:71~pre15
    dpkg-buildpackage: source changed by Debian Qt/KDE Maintainers <debian-qt-kde@lists.debian.org>
    dpkg-buildpackage: host architecture i386
    [...]

That generates several packages, but I just install the one I want:

    mdione@mustang:~/src/system/debian$ sudo dpkg -i kde-sc-dev-latest_4.7.2+5.71~pre15_all.deb
    Selecting previously unselected package kde-sc-dev-latest.
    (Reading database ... 218469 files and directories currently installed.)
    Unpacking kde-sc-dev-latest (from kde-sc-dev-latest_4.7.2+5.71~pre15_all.deb) ...
    Setting up kde-sc-dev-latest (4:4.7.2+5.71~pre15) ...

Now the `build-dep`s again:

    mdione@mustang:~/src/system/debian$ sudo apt-get build-dep kdebase
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    The following packages will be REMOVED:
      libkatepartinterfaces4
    The following NEW packages will be installed:
      libqimageblitz-dev libtidy-dev
    0 upgraded, 2 newly installed, 1 to remove and 8 not upgraded.
    Need to get 205 kB of archives.
    After this operation, 1,932 kB disk space will be freed.
    Do you want to continue [Y/n]?
    [...]

You'll probably won't notice (as I didn't) that it has removed a package,
`libkatepartinterfaces`. This is because in my system I have the old version of
it and there seems to be some kind of conflict somewhere. I just cross my
fingers it won't break much[^3].

Now get the sources and compile:

    mdione@mustang:~/src/system/debian$ apt-get source kdebase
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    NOTICE: 'kdebase' packaging is maintained in the 'Git' version control system at:
    git://git.debian.org/pkg-kde/kde-sc/kdebase.git
    Need to get 2,721 kB of source archives.
    Get:1 http://qt-kde.debian.net/debian/ experimental-snapshots/main kdebase 4:4.7.1-0r2 (dsc) [3,217 B]
    Get:2 http://qt-kde.debian.net/debian/ experimental-snapshots/main kdebase 4:4.7.1-0r2 (tar) [2,685 kB]
    Get:3 http://qt-kde.debian.net/debian/ experimental-snapshots/main kdebase 4:4.7.1-0r2 (diff) [33.1 kB]
    Fetched 2,721 kB in 26s (105 kB/s)
    gpgv: Signature made Tue 27 Sep 2011 09:43:53 PM CEST using RSA key ID 73A85F31
    gpgv: Can't check signature: public key not found
    dpkg-source: warning: failed to verify signature on ./kdebase_4.7.1-0r2.dsc
    dpkg-source: info: extracting kdebase in kdebase-4.7.1
    dpkg-source: info: unpacking kdebase_4.7.1.orig.tar.bz2
    dpkg-source: info: unpacking kdebase_4.7.1-0r2.debian.tar.gz
    dpkg-source: info: applying enable_debianabimanager.diff
    dpkg-source: info: applying enable_dlrestrictions.diff

    mdione@mustang:~/src/system/debian$ ( cd kdebase-4.7.1 && nice -n 19 dpkg-buildpackage -j3 -b -us -uc )
    [...]

Installing the resulting packages is another history, as some of them depend on
`kde-runtime`, so it's better if you compile `kde-runtime` before[^4]. Trying to
install its `build-dep`s, you realize taht you actually need to compile `soprano`
first.

You get the idea. Now I'll just show the generated packages I installed by hand
after each compilation, but only those that suited my needs:

`soprano`:

    mdione@mustang:~/src/system/debian$ sudo dpkg -i \
    soprano-daemon_2.7.3+dfsg.1-0r0_i386.deb \
    libsoprano4_2.7.3+dfsg.1-0r0_i386.deb \
    libsoprano-dev_2.7.3+dfsg.1-0r0_i386.deb

`kde-runtime`:

    mdione@mustang:~/src/system/debian$ sudo dpkg -i \
    kdebase-runtime_4.7.2-0r3_all.deb \
    khelpcenter4_4.7.2-0r3_i386.deb \
    kde-config-phonon-xine_4.7.2-0r3_i386.deb \
    kde-runtime-data_4.7.2-0r3_all.deb \
    kde-runtime_4.7.2-0r3_i386.deb \
    plasma-scriptengine-javascript_4.7.2-0r3_i386.deb

While installing `kde-runtime-data` I had to remove `kdebase-runtime-data`:

    [...]
    Selecting previously unselected package kde-runtime-data.
    dpkg: regarding kde-runtime-data_4.7.2-0r3_all.deb containing kde-runtime-data:
     kde-runtime-data breaks kdebase-runtime-data (<< 4:4.7.2)
      kdebase-runtime-data (version 4:4.6.5-1) is present and installed.
    [...]

    mdione@mustang:~/src/system/debian$ sudo dpkg --remove kdebase-runtime-data
    (Reading database ... 218612 files and directories currently installed.)
    Removing kdebase-runtime-data ...
    [...]

`kdebase`:

    mdione@mustang:~/src/system/debian$ sudo dpkg -i \
    dolphin_4.7.1-0r2_i386.deb \
    kdebase-bin_4.7.1-0r2_i386.deb \
    kdebase-data_4.7.1-0r2_all.deb \
    kdepasswd_4.7.1-0r2_i386.deb \
    konq-plugins_4.7.1-0r2_i386.deb \
    konqueror_4.7.1-0r2_i386.deb \
    konqueror-nsplugins_4.7.1-0r2_i386.deb \
    libkonq5abi1_4.7.1-0r2_i386.deb \
    libkonq-common_4.7.1-0r2_i386.deb \
    plasma-widget-folderview_4.7.1-0r2_i386.deb

While trying to get `akonadi` I got this error message:

    Failed to fetch http://qt-kde.debian.net/debian/pool/main/a/akonadi/akonadi_1.6.2-0r1.dsc  Hash Sum mismatch

Checking the MD5, SHA1 and SHA256 checksums and comparing to the ones in the
`.dsc` file revealed no difference. `lisandro` told me to use `dget` instead:

    mdione@mustang:~/src/system/debian$ dget http://qt-kde.debian.net/debian/pool/main/a/akonadi/akonadi_1.6.2-0r1.dsc
    dget: retrieving http://qt-kde.debian.net/debian/pool/main/a/akonadi/akonadi_1.6.2-0r1.dsc
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100  2620  100  2620    0     0   6842      0 --:--:-- --:--:-- --:--:--  8161
    dget: using existing akonadi_1.6.2.orig.tar.bz2
    dget: using existing akonadi_1.6.2-0r1.debian.tar.gz
    akonadi_1.6.2-0r1.dsc:
    dscverify: akonadi_1.6.2-0r1.dsc failed signature check:
    gpg: Signature made Thu 03 Nov 2011 08:55:52 AM CET using RSA key ID 73A85F31
    gpg: Can't check signature: public key not found
    Validation FAILED!!

Unpacking by hand:

    mdione@mustang:~/src/system/debian$ dpkg-source -x akonadi_1.6.2-0r1.dsc
    gpgv: Signature made Thu 03 Nov 2011 08:55:52 AM CET using RSA key ID 73A85F31
    gpgv: Can't check signature: public key not found
    dpkg-source: warning: failed to verify signature on ./akonadi_1.6.2-0r1.dsc
    dpkg-source: info: extracting akonadi in akonadi-1.6.2
    dpkg-source: info: unpacking akonadi_1.6.2.orig.tar.bz2
    dpkg-source: info: unpacking akonadi_1.6.2-0r1.debian.tar.gz
    dpkg-source: info: applying x11_not_required.diff

`akonadi`:

    mdione@mustang:~/src/system/debian$ sudo dpkg -i \
    akonadi-server_1.6.2-0r1_i386.deb \
    akonadi-backend-sqlite_1.6.2-0r1_i386.deb \
    libakonadi-dev_1.6.2-0r1_i386.deb \
    libakonadiprotocolinternals1_1.6.2-0r1_i386.deb

Here I cheated: I really didn't want to spend 10 minutes of iterative attempts
to find the minimal set of lib packages to install:

`libkdepim`:

    mdione@mustang:~/src/system/debian$ sudo dpkg -i \
    kdepimlibs5-dev_4.7.2-0r1_i386.deb \
    kdepimlibs-kio-plugins_4.7.2-0r1_i386.deb \
    lib*.deb

`kde-wallpapers`:

    mdione@mustang:~/src/system/debian$ sudo dpkg -i \
    kde-wallpapers-default_4.7.2-0r0_all.deb

`kde-workspace`:

    sudo dpkg -i --auto-deconfigure \
    systemsettings_4.7.2-0r7_i386.deb \
    plasma-desktop_4.7.2-0r7_i386.deb \
    plasma-scriptengine-python_4.7.2-0r7_all.deb \
    plasma-widgets-workspace_4.7.2-0r7_i386.deb \
    plasma-dataengines-workspace_4.7.2-0r7_i386.deb \
    klipper_4.7.2-0r7_i386.deb \
    kdm_4.7.2-0r7_i386.deb \
    kde-workspace-bin_4.7.2-0r7_i386.deb \
    kde-workspace-data_4.7.2-0r7_all.deb \
    kde-window-manager_4.7.2-0r7_i386.deb \
    kdebase-workspace_4.7.2-0r7_all.deb \
    kdebase-workspace-bin_4.7.2-0r7_all.deb \
    libkworkspace4_4.7.2-0r7_i386.deb \
    kde-workspace-kgreet-plugins_4.7.2-0r7_i386.deb \
    kde-style-oxygen_4.7.2-0r7_i386.deb \
    libkdecorations4_4.7.2-0r7_i386.deb \
    libkephal4abi1_4.7.2-0r7_i386.deb \
    libkwineffects1abi2_4.7.2-0r7_i386.deb \
    libkworkspace4_4.7.2-0r7_i386.deb \
    libplasmagenericshell4_4.7.2-0r7_i386.deb \
    libtaskmanager4abi2_4.7.2-0r7_i386.deb \
    libplasmaclock4abi2_4.7.2-0r7_i386.deb \
    libksgrd4_4.7.2-0r7_i386.deb \
    libplasma-geolocation-interface4_4.7.2-0r7_i386.deb \
    libsolidcontrol4abi2_4.7.2-0r7_i386.deb \
    libprocesscore4abi1_4.7.2-0r7_i386.deb \
    libweather-ion6_4.7.2-0r7_i386.deb \
    libkscreensaver5_4.7.2-0r7_i386.deb \
    libprocessui4a_4.7.2-0r7_i386.deb \
    libsolidcontrolifaces4abi2_4.7.2-0r7_i386.deb \
    kde-workspace_4.7.2-0r7_all.deb \
    ksysguard_4.7.2-0r7_i386.deb \
    freespacenotifier_4.7.2-0r7_i386.deb \
    libksignalplotter4_4.7.2-0r7_i386.deb \ 
    ksysguardd_4.7.2-0r7_i386.deb


I'll just finish this post here. The rest is just more of the same. The final
list of packages a compile in right order is:

    kde4libs
    meta-kde
    soprano
    kde-runtime
    kdebase
    akonadi
    prison
    kdepimlibs
    kde-wallpapers
    kde-workspace

All in all, this took some 10 hours of finding deps, compiling and installing,
and 6.4 GiB between original `.tar.gz` files, compilation dirs and generated
packages.

[^1]: It's nice that I don't need to compile `libqt4*`, those take *ages*[^5]:.

[^2]: Later `lisandro` from qkd pointed me to [the dependency graph](http://pkg-kde.alioth.debian.org/build-deps.html)
      that confirms my guess.

[^3]: I did all this while running a KDE SC 4.6.5 session, and even writing this
      post in `kate`. Thanks to Linux and Debian not much actually broke, I only lost
      the ability to browse with `konqueror` after I installed the first batch of
      packages because `KIO` could not instantiate an HTTP/HTTPS ioslave anymore.

[^4]: Note that the dependency graph two notes above is actually a build dependency
      graph.

[^5]: Not that this compilation was fast. `kdelibs` without parallelism took some
      3h and `kdepimlibs` and `kde-workspace` are two huge beasts.

