KDE Frameworks 5 Pre-installation Configuration

KF5 can be installed in /usr or /opt/kf5. The BLFS editors recommend the latter in the BLFS environment.

Installing in /usr

One option is to install KDE Frameworks 5 into the /usr hierarchy. This creates a simpler setup but makes it more difficult to try multiple versions of KDE Frameworks.

export KF5_PREFIX=/usr

It is a good idea to add the following variables to your system or personal profiles:

cat >> /etc/profile.d/qt5.sh << "EOF"
# Begin kf5 extension for /etc/profile.d/qt5.sh

pathappend /usr/lib/plugins        QT_PLUGIN_PATH
pathappend $QT5DIR/lib/plugins     QT_PLUGIN_PATH

pathappend /usr/lib/qt5/qml        QML2_IMPORT_PATH
pathappend $QT5DIR/lib/qml         QML2_IMPORT_PATH

# End extension for /etc/profile.d/qt5.sh
EOF

cat > /etc/profile.d/kf5.sh << "EOF"
# Begin /etc/profile.d/kf5.sh

export KF5_PREFIX=/usr

# End /etc/profile.d/kf5.sh
EOF
[Note]

Note

If qt5 was installed in /usr, the $QT5DIR/lib/ portions of the above paths may need to be changed to $QT5DIR/lib/qt5/.

Additionally, if Sudo-1.9.13p1 is installed, these variables should be available to the super user. Execute the following commands as the root user:

cat >> /etc/sudoers.d/qt << "EOF"
Defaults env_keep += QT_PLUGIN_PATH
Defaults env_keep += QML2_IMPORT_PATH
EOF

cat >> /etc/sudoers.d/kde << "EOF"
Defaults env_keep += KF5_PREFIX
EOF

Installing in /opt

A method of building multiple versions installs KDE Frameworks 5 in the /opt hierarchy:

export KF5_PREFIX=/opt/kf5

If you are not installing KDE Frameworks 5 in /usr, you will need to make some additional configuration changes. Best practice is to add those to your system or personal profile:

cat > /etc/profile.d/kf5.sh << "EOF"
# Begin /etc/profile.d/kf5.sh

export KF5_PREFIX=/opt/kf5

pathappend $KF5_PREFIX/bin              PATH
pathappend $KF5_PREFIX/lib/pkgconfig    PKG_CONFIG_PATH

pathappend $KF5_PREFIX/etc/xdg          XDG_CONFIG_DIRS
pathappend $KF5_PREFIX/share            XDG_DATA_DIRS

pathappend $KF5_PREFIX/lib/plugins      QT_PLUGIN_PATH
pathappend $KF5_PREFIX/lib/plugins/kcms QT_PLUGIN_PATH

pathappend $KF5_PREFIX/lib/qml          QML2_IMPORT_PATH

pathappend $KF5_PREFIX/lib/python3.11/site-packages PYTHONPATH

pathappend $KF5_PREFIX/share/man        MANPATH
# End /etc/profile.d/kf5.sh
EOF

cat >> /etc/profile.d/qt5.sh << "EOF"
# Begin Qt5 changes for KF5

pathappend /usr/lib/plugins            QT_PLUGIN_PATH
pathappend $QT5DIR/plugins             QT_PLUGIN_PATH
pathappend $QT5DIR/qml                 QML2_IMPORT_PATH

# End Qt5 changes for KF5
EOF

Expand your /etc/ld.so.conf file:

cat >> /etc/ld.so.conf << "EOF"
# Begin KF5 addition

/opt/kf5/lib

# End KF5 addition
EOF

Several KDE Frameworks 5 and Plasma 5 packages install files into D-Bus and Polkit directories. When installing KDE Frameworks 5 in a location other than /usr, D-Bus and Polkit need to be able to find these files. The easiest way to achieve this is to create the following symlinks (as the root user):

install -v -dm755           $KF5_PREFIX/{etc,share} &&
ln -sfv /etc/dbus-1         $KF5_PREFIX/etc         &&
ln -sfv /usr/share/dbus-1   $KF5_PREFIX/share       &&
ln -sfv /usr/share/polkit-1 $KF5_PREFIX/share

Some packages may also install icons from the "hicolor" icon set. Since that icon set is used by many packages, it is a good idea to create a symlink to the one in /usr/share to avoid having multiple installations of hicolor-icon-theme-0.17. Run the following commands as the root user:

install -v -dm755                $KF5_PREFIX/share/icons &&
ln -sfv /usr/share/icons/hicolor $KF5_PREFIX/share/icons
[Tip]

Tip

Sometimes, the installation paths are hardcoded into installed files. This is the reason why /opt/kf5 is used as installation prefix instead of /opt/kf5-5.103.0. After installing KDE Frameworks, you may rename the directory and create a symlink:

mv /opt/kf5{,-5.103.0}
ln -sfv kf5-5.103.0 /opt/kf5

Later on, you may want to install other versions of KDE Frameworks 5. To do that, just remove the symlink and use /opt/kf5 as the prefix again. Which version of KDE Frameworks 5 you use depends only on where the symlink points. No other reconfiguration will be needed.