Krita/kf5build

From KDE Community Wiki
Revision as of 12:15, 12 August 2015 by Halla (talk | contribs) (Created page with "This page provides information about how to build and install Krita 3 from source using the kdesrc-build tool. This installation of Krita will be separate from any existing pl...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

This page provides information about how to build and install Krita 3 from source using the kdesrc-build tool. This installation of Krita will be separate from any existing plasma installation, so that either of them can be run as desired.

Preparation

Git remote prefix

Let's setup a "kde:" prefix for git commands. Add the following text to your ~/.gitconfig:

[url "git://anongit.kde.org/"]
   insteadOf = kde:
[url "ssh://[email protected]/"]
   pushInsteadOf = kde:

Create directories for build and installation

sudo mkdir -p ~/kf5/{sources,build,install,logs}
sudo chown -R $USER:$GROUP ~/kf5
mkdir -p ~/.kde5/{local,config,cache}    # Optional, only if you want separate directory for config files in your home

Clone kdesrc-build

First you need kdesrc-build:

cd ~/kf5/sources
git clone kde:kdesrc-build
cd kdesrc-build

The rest of the commands will be run from inside this directory.

kdesrc-build configuration

Save the following as ~/.kdesrc-buildrc.

global

    #qtdir /path/to/custom/qt          # Uncomment if you have your own qt build
    source-dir  ~/kf5/sources
    build-dir  ~/kf5/build
    kdedir  ~/kf5/install
    log-dir  ~/kf5/logs

    git-repository-base     kde-projects kde:
    branch-group            kf5-qt5

    cmake-options -DCMAKE_BUILD_TYPE:STRING=debug

    cxxflags -pipe -DQT_STRICT_ITERATORS -DQURL_NO_CAST_FROM_STRING -DQT_NO_HTTP -DQT_NO_FTP -Wformat -Werror=format-security -Werror=return-type -Wno-variadic-macros -Wlogical-op -Wmissing-include-dirs

    # If you want to use ninja instead of make (it's faster!), add -GNinja to cmake-options above
    # and uncomment the next line
    #custom-build-command ninja

    # Adjust to the number of  CPU cores
    #make-options -j2

    ignore-kde-structure    true        # Downloads all modules directly into the source folder instead of subdirectories
    stop-on-failure         true        # Stop kdesrc-build when a build fails.

end global

include ~/kf5/sources/kdesrc-build/kf5-frameworks-build-include
include ~/kf5/sources/kdesrc-build/kf5-workspace-build-include

#Uncomment the next two lines to build application and PIM modules
#include ~/kf5/sources/kdesrc-build/kf5-applications-build-include
#include ~/kf5/sources/kdesrc-build/kf5-kdepim-build-include
  • Adjust the paths to wherever you want to build and install Krita 3
  • Adjust the value of 'make-options -j4'. It is usually recommended to set to the number of CPU cores.
  • Uncomment the last two lines if you also want to build the Applications and PIM suite.

Explore other available options in the official documentation

Building

Dependencies

Krita 3 will need various dependencies to be installed. You can find a list of dependencies for atleast the frameworks here. Any other dependencies can be figured out and installed as you continue building the modules one by one.

At the very minimum, qt5, cmake, g++, git, bzr, libwww-perl, libjson-perl and libxml-parser-perl needs to be installed to get started.

Kubuntu

Warning

Building Krita using these instructions does not work on Kubuntu due to the way they have incorrectly set up Qt. Please use any non Debian based distro


For Kubuntu 15.04, here's a list of packages that should satisfy all the dependencies of the default kdesrc-build projects, including Frameworks, Applications and Krita Workspace but excluding kdegames. Just copy-paste this to your terminal:

sudo apt-get install libxslt1-dev libpolkit-agent-1-dev libpolkit-gobject-1-dev libpolkit-backend-1-dev debhelper dh-apparmor icu-devtools libboost1.55-dev libcln-dev libglib2.0-dev libgmp-dev libgmpxx4ldbl libgps-dev libicu-dev libqalculate-dev libqimageblitz-dev libqt5sensors5 libqt5sensors5-dev libqt5webkit5-dev libqt5x11extras5-dev libraw1394-dev libudev-dev libusb-dev libxapian-dev libxcb-composite0-dev libxcb-cursor-dev libxcb-cursor0 libxcb-damage0-dev libxcb-dpms0 libxcb-dpms0-dev libxcb-ewmh-dev libxcb-ewmh2 libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-record0-dev libxcb-render-util0-dev libxcb-res0 libxcb-res0-dev libxcb-screensaver0 libxcb-screensaver0-dev libxcb-shm0-dev libxcb-util0-dev libxcb-xevie0 libxcb-xevie0-dev libxcb-xf86dri0 libxcb-xf86dri0-dev libxcb-xinerama0 libxcb-xinerama0-dev libxcb-xkb-dev libxcb-xprint0 libxcb-xprint0-dev libxcb-xtest0-dev libxcb-xv0 libxcb-xv0-dev libxcb-xvmc0 libxcb-xvmc0-dev libxml2-dev pkg-kde-tools po-debconf qttools5-dev xcb-proto xvfb qtscript5-dev qtdeclarative5-dev qtbase5-dev qtbase5-dev-tools qt5-qmake doxygen bzr libjson-perl perl-modules cmake cmake-data libapr1 libaprutil1 libserf-1-1 libsvn1 libxml-parser-perl subversion git build-essential libqt5svg5-dev libgpgme11-dev libgcrypt20-dev libepoxy-dev  libssl-dev libjpeg-dev libjpeg-turbo8-dev libjpeg8-dev libgif-dev qtbase5-private-dev qtxmlpatterns5-dev-tools libqt5xmlpatterns5-dev libqt5xmlpatterns5-private-dev libvlc-dev libvlccore-dev gir1.2-gst-plugins-base-1.0 gir1.2-gstreamer-1.0 libasound2-dev libgstreamer-plugins-base1.0-dev libgstreamer1.0-dev libnm-util-dev libnm-glib-dev libattr1-dev qtquick1-5-dev libgrantlee5-dev liblcms2-dev libexiv2-dev libarchive-dev libcups2-dev libfakekey-dev libpam-dev libxrender-dev libpng-dev libxcursor-dev liblmdb-dev libsm-dev

Arch

For Arch, here's a list of packages that should satisfy all the dependencies of the default kdesrc-build projects, including Frameworks, Applications and Krita Workspace but excluding kdegames. Just copy-paste this to your terminal:

sudo pacman -S base-devel bzr cmake perl-libwww perl-xml-parser perl-json git qt5-tools docbook-xml docbook-xsl python2 boost modemmanager networkmanager vlc xapian-core xorg-server-devel 

kdesrc-build commands

Run kdesrc-build as:

./kdesrc-build --debug

By default, kdesrc-build sends all output to log files. --debug will print build and install progress in the terminal too.

Sometimes a build will fail, and if stop-on-failure true is present in the options (as above), kdesrc-build will stop here. After the reason for the build failure has been analysed and fixed, you can resume building from that module by:

./kdesrc-build --debug --resume-from=<name>

If that application build cannot be fixed at present, you can skip building it by:

./kdesrc-build --debug --resume-after=<name>

A single module can be build using:

./kdesrc-build --debug <name>

Explore other options in the official documentation

Running plasma

Save the following script as ~/kf5/runKrita5.sh

#!/bin/bash
 
if [ -d /etc/X11/xinit/xinitrc.d ]; then
  for f in /etc/X11/xinit/xinitrc.d/*; do
    [ -x "$f" ] && . "$f"
  done
  unset f
fi

DISTRO=`source /etc/os-release 2>/dev/null; echo $ID_LIKE`
 
export KF5=~/kf5/install
export QTDIR=/opt/qt5      # Change if you have your own qt build
 
export PATH=$KF5/bin:$QTDIR/bin:$PATH
 
export QT_PLUGIN_PATH=$KF5/lib/plugins:$KF5/lib64/plugins:$QTDIR/plugins:$QT_PLUGIN_PATH
#On some distros, this is $KF5/lib64/qml:$QTDIR/qml or something similar. After the installation, choose the directory/directories which contains the "qt/qml" folder.
export QML2_IMPORT_PATH=$KF5/lib/qml:$QTDIR/qml

#Fixes for Debian's "look at me, I'm so important" setups
if [ $DISTRO == "debian" ] 
then
    export QT_PLUGIN_PATH=$KF5/lib/`uname -i`-linux-gnu/plugins:$QTDIR/plugins
    export QML2_IMPORT_PATH=$KF5/lib/`uname -i`-linux-gnu/qml:$QTDIR/qml
fi

export QML_IMPORT_PATH=$QML2_IMPORT_PATH
 
export XDG_DATA_DIRS=$KF5/share:/usr/share
export XDG_CONFIG_DIRS=$KF5/etc/xdg:/etc/xdg
  
# Uncomment to change default home paths
#export XDG_DATA_HOME=$HOME/.kde5/local
#export XDG_CONFIG_HOME=$HOME/.kde5/config
#export XDG_CACHE_HOME=$HOME/.kde5/cache
 
exec startkde

Configuring dbus

Because we installed Krita 3 to a custom path, we need to make dbus aware of these new locations.

Create a file /etc/dbus-1/session-local.conf with the following contents:

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<servicedir>~/kf5/install/share/dbus-1/services</servicedir>
</busconfig>

Create another file /etc/dbus-1/system-local.conf with the following contents:

<!DOCTYPE busconfig PUBLIC "-//freedesktop//DTD D-Bus Bus Configuration 1.0//EN"
 "http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<servicedir>~/kf5/install/share/dbus-1/system-services</servicedir>
<includedir>~/kf5/install/etc/dbus-1/system.d</includedir>
</busconfig>

Because dbus will load all these new paths each time you login, you should rename these files (to eg system-local.conf.bk and session-local.conf.bk) before starting your default Krita 4 or other distro sessions.

Finally, there are two ways of running Krita 3. Choose the one which suits you best.

Using a login manager

The recommended login manager is SDDM. But this should method work with any login manager.

sudo cp ~/kf5/runKrita5.sh /usr/share/xsessions
sudo chmod +x /usr/share/xsessions/runKrita5.sh
sudo cp ~/kf5/install/share/xsessions/plasma.desktop  /usr/share/xsessions/plasmaGit.desktop

Edit /usr/share/xsessions/plasma.desktop and change the paths as:

Exec=/usr/share/xsessions/runKrita5.sh
TryExec=/usr/share/xsessions/runKrita5.sh
Name=Krita Git

After this logout of your current session, select Krita Git in the options and login. You should now have the last Krita 3 running.

From the command line

Edit your xinitrc file:

mv ~/.xinitrc ~/.xinitrc.bk                # Backup any existing xinitrc file
ln -s ~/kf5/runKrita5.sh ~/.xinitrc

Log out of your current session, login to a tty (eg tty2 by pressing Ctrl+Alt+F2) and run startx. This should read your ~/.xinitrc and log you into a Krita 3 desktop.

Updating

Run kdesrc-build each time you want the latest updates.

cd ~/kf5/sources/kdesrc-build
git pull                # First update kdesrc-build
./kdesrc-build --debug

Troubleshooting

You may not be able to successfully build or run Krita 3 at first go.

  • You may not have all dependencies installed. Read the output to see what missing dependency it is complaining about, search for the corresponding package for your disto, and install it.
  • If you get a build failure, simple fix might be to delete the build folder for that module and try building it again.
  • Because we are compiling from the source code, some latest changes might be the cause of build failures. You may try going back to a previous code version (git skills required), wait sometime for the developers to fix the code, or even better, try to fix the build yourself and submit a patch :)

For any help, communicate with the KDE team.