From b5940ba40cbc5b9f07d400e3f7aea45a2481550c Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Sun, 23 Jul 2017 12:39:10 -0400 Subject: [PATCH 1/6] Install session driver support scripts. Otherwise they can only be found if running kdesrc-build from the source directory. --- CMakeLists.txt | 14 +++++++++----- kdesrc-build | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 22cf21c..5bebbff 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.9) +cmake_minimum_required(VERSION 3.0) project(kdesrc-build) # Needed for the docs, but optional. If not found, we will simply @@ -20,12 +20,10 @@ if (ECM_FOUND) else() message(WARNING "Found ECM, but not KF5::DocTools; documentation will not be built") endif() - # ECM sets DATA_INSTALL_DIR to PREFIX/share, the "/apps" is gone in KF5. - # To get a consistent install with and without ECM, override this: - set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/apps" CACHE PATH "The parent directory where applications can install their data") else() message(WARNING "Did not find extra-cmake-modules; documentation will not be built and install paths will be guessed based on CMake settings.") - set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share/apps" CACHE PATH "The parent directory where applications can install their data") + # ECM sets DATA_INSTALL_DIR to PREFIX/share, try to match + set(DATA_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/share" CACHE PATH "The parent directory where applications can install their data") set(BIN_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "The install dir for executables") endif() @@ -90,6 +88,12 @@ endif() install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/kdesrc-build DESTINATION ${BIN_INSTALL_DIR}) install(PROGRAMS ${CMAKE_CURRENT_SOURCE_DIR}/kdesrc-build-setup DESTINATION ${BIN_INSTALL_DIR}) +install(PROGRAMS + ${CMAKE_SOURCE_DIR}/sample-kde-env-master.sh + ${CMAKE_SOURCE_DIR}/sample-kde-env-user.sh + ${CMAKE_SOURCE_DIR}/sample-xsession.sh + DESTINATION ${DATA_INSTALL_DIR}/kdesrc-build) + if (ECM_FOUND) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) endif() diff --git a/kdesrc-build b/kdesrc-build index ff25a2b..3265945 100755 --- a/kdesrc-build +++ b/kdesrc-build @@ -33,7 +33,7 @@ # Adding an option? Grep for 'defaultGlobalOptions' in ksb::BuildContext --mpyne use FindBin qw($RealBin); -use lib "$RealBin/../share/apps/kdesrc-build/modules"; +use lib "$RealBin/../share/kdesrc-build/modules"; use lib "$RealBin/modules"; # Force all symbols to be in this package. We can tell if we're being called From 65ad4c424f82e1d4ae4d12a96d69c59d1822d419 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Sun, 23 Jul 2017 13:14:26 -0400 Subject: [PATCH 2/6] Add install-environment-driver option. This installs needed KDE-related environment settings without going so far as to install .xsession support. For that, see install-session-driver, whose documentation has been fixed to make clear it's not a default. --- doc/index.docbook | 38 +++++++++++++++++++++++++++++++++-- modules/ksb/Application.pm | 11 +++++++--- modules/ksb/BuildContext.pm | 28 +++++++++++++------------- vim/syntax/kdesrc-buildrc.vim | 12 ++++++----- 4 files changed, 65 insertions(+), 24 deletions(-) diff --git a/doc/index.docbook b/doc/index.docbook index e4e40a6..85516c3 100644 --- a/doc/index.docbook +++ b/doc/index.docbook @@ -2140,10 +2140,43 @@ flag. + +install-environment-driver +Cannot be overridden +By default, &kdesrc-build; will install a shell script that can be +sourced in a user's profile setup scripts to easily establish needed environment +variables to run the Plasma desktop built by &kdesrc-build;. + +This driver will alter the following files: + + +$XDG_CONFIG_HOME/kde-env-master.sh (normally found at ~/.config/kde-env-master.sh). +$XDG_CONFIG_HOME/kde-env-user.sh (normally found at ~/.config/kde-env-user.sh). + + +The kde-env-user.sh is optional. It is +intended for user customizations (see the Troubleshooting and Debugging +section of the &kde; UserBase for examples of customizable settings), but these settings +can be set elsewhere by the user in their existing profile setup scripts. + +You can disable this feature by setting this option to +false, and ensuring that the install-session-driver option is +also disabled. + +This option was introduced with &kdesrc-build; 17.08. + +&kdesrc-build; will not overwrite your existing files (if present) +unless you also pass the +command-line option. + + + install-session-driver Cannot be overridden -By default, &kdesrc-build; will try to install a driver for the graphical +If enabled, &kdesrc-build; will try to install a driver for the graphical login manager that allows you to login to your &kdesrc-build;-built &kde; desktop. This driver will alter the following files: @@ -2155,7 +2188,8 @@ login manager that allows you to login to your &kdesrc-build;-built &kde; deskto If you maintain your own login driver then you can disable this feature by setting this -option to false. +option to false. If enabled, this feature also enables the +install-environment-driver feature. This option was introduced with &kdesrc-build; 1.16. diff --git a/modules/ksb/Application.pm b/modules/ksb/Application.pm index 78ddf4b..f16da20 100644 --- a/modules/ksb/Application.pm +++ b/modules/ksb/Application.pm @@ -693,7 +693,12 @@ sub runAllModulePhases $ctx->setPersistentOption('global', 'last-failed-module-list', $failedModules); } - _installCustomSessionDriver($ctx) if $ctx->getOption('install-session-driver'); + # env driver is just the ~/.config/kde-env-*.sh, session driver is that + ~/.xsession + if ($ctx->getOption('install-environment-driver') || + $ctx->getOption('install-session-driver')) + { + _installCustomSessionDriver($ctx); + } my $color = 'g[b['; $color = 'r[b[' if $result; @@ -2368,7 +2373,7 @@ sub _installCustomSessionDriver _installCustomFile($ctx, $envScript, "$destDir/kde-env-master.sh", 'kde-env-master-digest'); _installCustomFile($ctx, $sessionScript, "$ENV{HOME}/.xsession", - 'xsession-digest'); + 'xsession-digest') if $ctx->getOption('install-session-driver'); if (!pretending()) { if (! -e "$destDir/kde-env-user.sh") { @@ -2378,7 +2383,7 @@ sub _installCustomSessionDriver }; } - chmod (0744, "$ENV{HOME}/.xsession") or do { + if ($ctx->getOption('install-session-driver') && !chmod (0744, "$ENV{HOME}/.xsession")) { error ("\tb[r[*] Error making b[~/.xsession] executable: $!"); error ("\tb[r[*] If this file is not executable you may not be able to login!"); }; diff --git a/modules/ksb/BuildContext.pm b/modules/ksb/BuildContext.pm index f106ebc..3e2c3aa 100644 --- a/modules/ksb/BuildContext.pm +++ b/modules/ksb/BuildContext.pm @@ -73,20 +73,20 @@ my %internalGlobalOptions = ( # Holds boolean flags that could be altered from cmdline. our %defaultGlobalFlags = ( - "delete-my-patches" => 0, # Should only be set from cmdline - "delete-my-settings" => 0, # Should only be set from cmdline - "disable-agent-check" => 0, # If true we don't check on ssh-agent - "disable-snapshots" => 1, # 2016-07-31 Temp. disabled until kde.org fixed to supply snapshots - "ignore-kde-structure" => 0, # Whether to use kde dir structure like extragear/network - "install-after-build" => 1, # Default to true - "install-session-driver" => 0,# Default to false - "purge-old-logs" => 1, - "run-tests" => 0, # 1 = make test, upload = make Experimental - "stop-on-failure" => 0, - "use-clean-install" => 0, - "use-idle-io-priority" => 0, - # Controls whether to build "stable" branches instead of "master" - "use-stable-kde" => 0, + "delete-my-patches" => 0, # Should only be set from cmdline + "delete-my-settings" => 0, # Should only be set from cmdline + "disable-agent-check" => 0, # If true we don't check on ssh-agent + "disable-snapshots" => 1, # 2016-07-31 Temp. disabled until kde.org fixed to supply snapshots + "ignore-kde-structure" => 0, # Whether to use kde dir structure like extragear/network + "install-after-build" => 1, + "install-environment-driver" => 1, # Setup ~/.config/kde-env-*.sh for login scripts + "install-session-driver" => 0, # Above, + ~/.xsession + "purge-old-logs" => 1, + "run-tests" => 0, # 1 = make test, upload = make Experimental + "stop-on-failure" => 0, + "use-clean-install" => 0, + "use-idle-io-priority" => 0, + "use-stable-kde" => 0, ); # Holds other cmdline-accessible options that aren't simply binary flags. diff --git a/vim/syntax/kdesrc-buildrc.vim b/vim/syntax/kdesrc-buildrc.vim index eca0734..934c11f 100644 --- a/vim/syntax/kdesrc-buildrc.vim +++ b/vim/syntax/kdesrc-buildrc.vim @@ -1,9 +1,9 @@ " Vim syntax file " Language: kdesrc-build configuration file " Maintainer: Michael Pyne -" Latest Revision: 31 July 2016 +" Latest Revision: 23 July 2017 -" Copyright (c) 2014-2016 Michael Pyne +" Copyright (c) 2014-2017 Michael Pyne " Redistribution and use in source and binary forms, with or without " modification, are permitted provided that the following conditions " are met: @@ -63,19 +63,21 @@ syn keyword ksbrcErrorModuleSetOption contained skipwhite nextgroup=ksbrcStringV syn keyword ksbrcBoolOption contained skipwhite nextgroup=ksbrcBoolValue \ build-system-only build-when-unchanged ignore-kde-structure - \ install-after-build install-session-driver manual-build manual-update + \ install-after-build manual-build manual-update \ no-src reconfigure recreate-configure refresh-build run-tests \ use-clean-install syn keyword ksbrcGlobalBoolOption contained skipwhite nextgroup=ksbrcBoolValue \ async colorful-output disable-agent-check disable-snapshots pretend - \ purge-old-logs stop-on-failure use-idle-io-priority + \ purge-old-logs stop-on-failure use-idle-io-priority install-session-driver + \ install-environment-driver " MUST BE CONSISTENT WITH ABOVE. Used when a global option is used in the " wrong spot to highlight the error. syn keyword ksbrcErrorBoolOption contained skipwhite nextgroup=ksbrcBoolValue \ async colorful-output disable-agent-check disable-snapshots pretend - \ purge-old-logs stop-on-failure use-idle-io-priority + \ purge-old-logs stop-on-failure use-idle-io-priority install-session-driver + \ install-environment-driver " Matches syn match ksbrcKeyword "\" From 84aad277bebeb8b16150097d97a643b85f840154 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Sun, 23 Jul 2017 19:32:58 -0400 Subject: [PATCH 3/6] Simplify environment/session driver scripts. The kde-env-user stuff is probably extraneous, users who will go through and tweak the installed kde-env-master.sh script should be skilled enough to already have their own .bashrc (or equivalent) and be able to setup their own env vars prior to sourcing kde-env-master.sh This also ports some of the Qt4/KDE4 stuff to Qt5/KF5, removes now-unnecessary environment variable settings, etc. --- modules/ksb/Application.pm | 10 ----- sample-kde-env-master.sh | 75 ++++++++++++-------------------------- sample-kde-env-user.sh | 39 -------------------- 3 files changed, 24 insertions(+), 100 deletions(-) delete mode 100644 sample-kde-env-user.sh diff --git a/modules/ksb/Application.pm b/modules/ksb/Application.pm index f16da20..a4c2717 100644 --- a/modules/ksb/Application.pm +++ b/modules/ksb/Application.pm @@ -2357,9 +2357,6 @@ sub _installCustomSessionDriver my $sessionScript = first { -f $_ } ( map { "$_/sample-xsession.sh" } @searchPaths ); - my $userSample = first { -f $_ } ( - map { "$_/sample-kde-env-user.sh" } @searchPaths - ); if (!$envScript || !$sessionScript) { warning ("b[*] Unable to find helper files to setup a login session."); @@ -2376,13 +2373,6 @@ sub _installCustomSessionDriver 'xsession-digest') if $ctx->getOption('install-session-driver'); if (!pretending()) { - if (! -e "$destDir/kde-env-user.sh") { - copy($userSample, "$destDir/kde-env-user.sh") or do { - warning ("b[*] Unable to install b[$userSample]: $!"); - warning ("b[*] You should create b[~/.config/kde-env-user.sh] yourself or fix the error and re-run"); - }; - } - if ($ctx->getOption('install-session-driver') && !chmod (0744, "$ENV{HOME}/.xsession")) { error ("\tb[r[*] Error making b[~/.xsession] executable: $!"); error ("\tb[r[*] If this file is not executable you may not be able to login!"); diff --git a/sample-kde-env-master.sh b/sample-kde-env-master.sh index 883a770..55e8fd4 100644 --- a/sample-kde-env-master.sh +++ b/sample-kde-env-master.sh @@ -1,56 +1,52 @@ #!/bin/sh # -# This sets the various environment variables needed to start a KDE desktop -# built by kdesrc-build, or to run programs/build programs/etc. in the same -# environment. +# This sets the various environment variables needed to start Plasma (or other KDE +# software built by kdesrc-build), or to run programs/build programs/etc. in the +# same environment. # # This should not produce any output in order to make it usable by # non-interactive scripts. # -# See also the sample xsession setup script which requires this file. +# See also the sample xsession setup script, which requires this file. # # Use by copying this script to $XDG_CONFIG_HOME/kde-env-master.sh (this will # be done for you by kdesrc-build and/or kdesrc-build-setup, later). 99% of the # time this means ~/.config/kde-env-master.sh # # NOTHING IN THIS FILE IS MODIFIABLE, OTHERWISE WARNINGS WILL BE GENERATED +# (instead make your changes in your ~/.bashrc, ~/.bash_profile, or whatever else +# you are using) # === Load user environment settings (i.e. not set through kdesrc-buildrc) XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-$HOME/.config}" - -# ALL USER MODS GO HERE ↴ -if test -f "$XDG_CONFIG_HOME/kde-env-user.sh"; then - . "$XDG_CONFIG_HOME/kde-env-user.sh" -fi +export XDG_CONFIG_HOME # === Modifiable variables. Should be set automatically by kdesrc-build based # on kdesrc-buildrc settings. Nothing below this line is user-modifiable! -# kdesrc-build: filter | The KDESRC_BUILD_TESTING stuff is to allow the script to -# kdesrc-build: filter | be executable by testsuite. It is filtered from destination. -if ! test -n "$KDESRC_BUILD_TESTING"; then # kdesrc-build: filter +# The KDESRC_BUILD_TESTING stuff is to allow the script to # kdesrc-build: filter +# be executable by testsuite. It is filtered from destination. # kdesrc-build: filter +if ! test -n "$KDESRC_BUILD_TESTING"; then # kdesrc-build: filter # Where KDE libraries and applications are installed to. -kde_prefix="<% kdedir %>" # E.g. "$HOME/kde-4" +kde_prefix="<% kdedir %>" # E.g. "$HOME/kf5" # Where Qt is installed to. If using the system Qt, leave blank or set to # 'auto' and this script will try to auto-detect. -qt_prefix="<% qtdir %>" # E.g. "$HOME/qt4" or "/usr" on many systems. -else # kdesrc-build: filter -kde_prefix="$HOME/kde" # kdesrc-build: filter -qt_prefix="$HOME/qt4" # kdesrc-build: filter -fi # kdesrc-build: filter +qt_prefix="<% qtdir %>" # E.g. "$HOME/qt5" or "/usr" on many systems. +else # kdesrc-build: filter +kde_prefix="$HOME/kf5" # kdesrc-build: filter +qt_prefix="$HOME/qt5" # kdesrc-build: filter +fi # kdesrc-build: filter # === End of modifiable variables. # Set defaults if these are unset or null. ':' is a null command : ${lib_suffix:=""} -: ${user_path:=""} -: ${KDEHOME:="$HOME/.kde4-self"} -# Find system Qt +# Find system Qt5 if test -z "$qt_prefix"; then # Find right qmake - for qmake_candidate in qmake-qt4 qmake4 qmake; do + for qmake_candidate in qmake-qt5 qmake5 qmake; do if ${qmake_candidate} --version >/dev/null 2>&1; then qmake="$qmake_candidate" break; @@ -60,14 +56,12 @@ if test -z "$qt_prefix"; then qt_prefix=$(${qmake} -query QT_INSTALL_PREFIX 2>/dev/null) test -z "$qt_prefix" && qt_prefix="/usr" # Emergency fallback? - - echo "Using Qt found in $qt_prefix" fi # Try to auto-determine lib suffix if not set. This requires KDE to already # have been installed though. -if test -z "$lib_suffix" && test -x "$kde_prefix/bin/kde4-config"; then - lib_suffix=$("$kde_prefix/bin/kde4-config" --libsuffix 2>/dev/null) +if test -z "$lib_suffix" && test -x "$kde_prefix/bin/kde5-config"; then + lib_suffix=$("$kde_prefix/bin/kde5-config" --libsuffix 2>/dev/null) fi # Add path elements to a colon-separated environment variable, @@ -85,29 +79,25 @@ path_add() fi } -# Initialize some variables based on Qt and KDE install paths. -# Since this should be run as .xsession there's no guarantee of any -# user-specific variables being set already. libname="lib$lib_suffix" # Now add the necessary directories, starting with Qt (although we don't add Qt # if it's system Qt to avoid moving /usr up in the PATH. +# Note that LD_LIBRARY_PATH *should* be extraneous with KF5 and Qt5 if test "x$qt_prefix" != "x/usr"; then path_add "PATH" "$qt_prefix/bin"; - path_add "LD_LIBRARY_PATH" "$qt_prefix/$libname"; path_add "PKG_CONFIG_PATH" "$qt_prefix/$libname/pkgconfig"; path_add "MANPATH" "$qt_prefix/share/man"; +# Do we need path_add for CMAKE_MODULE_PATH for Qt CMake .config files? fi # Now add KDE-specific paths. path_add "PATH" "$kde_prefix/bin"; -path_add "LD_LIBRARY_PATH" "$kde_prefix/$libname"; path_add "PKG_CONFIG_PATH" "$kde_prefix/$libname/pkgconfig"; path_add "MANPATH" "$kde_prefix/share/man"; path_add "CMAKE_PREFIX_PATH" "$kde_prefix"; -path_add "KDEDIRS" "$kde_prefix"; +path_add "CMAKE_MODULE_PATH" "$kde_prefix/share/cmake"; path_add "QML_IMPORT_PATH" "$kde_prefix/$libname/kde4/imports"; -path_add "STRIGI_PLUGIN_PATH" "$kde_prefix/$libname/strigi"; # For Python bindings support. path_add "PYTHONPATH" "$kde_prefix/$libname/site-packages"; @@ -116,30 +106,13 @@ path_add "PYTHONPATH" "$kde_prefix/$libname/site-packages"; path_add "XDG_DATA_DIRS" "$kde_prefix/share"; path_add "XDG_CONFIG_DIRS" "$kde_prefix/etc/xdg"; -# -### Some Convenience stuff -# -if test -n "$user_path"; then - path_add "PATH" "$user_path" -fi - -test -d "$HOME/local/bin" && path_add "PATH" "$HOME/local/bin" -test -d "$HOME/local/man" && path_add "MANPATH" "$HOME/local/man" - # Finally, export the variables. export CMAKE_PREFIX_PATH -export KDEDIRS -export LD_LIBRARY_PATH +export CMAKE_MODULE_PATH export PATH export PKG_CONFIG_PATH export PYTHONPATH export QML_IMPORT_PATH -export STRIGI_PLUGIN_PATH export XDG_DATA_DIRS export XDG_CONFIG_DIRS export MANPATH -export KDEHOME - -if ! test -e "$KDEHOME"; then - mkdir -p "$KDEHOME" >/dev/null 2>&1 -fi diff --git a/sample-kde-env-user.sh b/sample-kde-env-user.sh deleted file mode 100644 index b1bce52..0000000 --- a/sample-kde-env-user.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# -# This is a sample user customization script. Unlike other example environment -# setup files, this one can be modified by the user, and kdesrc-build will not -# warn about it or overwrite it. -# -# This file should be installed to $XDG_CONFIG_HOME/kde-env-user.sh (which -# normally means ~/.config/kde-env-user.sh) -# -# As long as it is found here, the kdesrc-build sample session and environment -# setup scripts will pull in settings from that file first. - -### Variables supported by the environment script: - -# Directory to use for KDE configuration and other user customizations. -# Syntax uses existing value if set, otherwise sets a different one. -# You can also leave blank, but this risks interfering with system KDE. -KDEHOME="$HOME/.kde4-self" - -# "Bitness" suffix to use for library directories. If left blank, will try to -# auto-detect from installed KDE's compiled defaults, which may still leave -# this blank. -lib_suffix="" # Or 32, or 64, as appropriate for your system. -# lib_suffix="32" -# lib_suffix="64" - -# Additional paths to add to PATH, can be left blank. -user_path="" # Set to colon-separated PATH to add to the Qt/KDE paths. - -### KDE-specific environment variables: -# KDE supports various environment variables that might be useful for your -# kdesrc-build desktop. See also: -# https://techbase.kde.org/KDE_System_Administration/Environment_Variables - -KDE_COLOR_DEBUG=1 -export KDE_COLOR_DEBUG # Be sure to "export" variables you set yourself. - -# If more user customizations to the environment are needed, you can add them -# here. From 6062a35237821aee880bd6accc053113e5608089 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Sun, 23 Jul 2017 19:39:28 -0400 Subject: [PATCH 4/6] kdesrc-build-setup: Remove dev question, add drivers. --- kdesrc-build-setup | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/kdesrc-build-setup b/kdesrc-build-setup index 2f2a06e..5c437a3 100755 --- a/kdesrc-build-setup +++ b/kdesrc-build-setup @@ -220,9 +220,6 @@ modules. EOF } -my $dev = getYesNoAnswer('Do you already have commit ' . - 'access to the KDE repositories?'); - # If the user appears to be using a proxy, ask for it directly, otherwise # prompt for one. my $proxy = $ENV{http_proxy} // ''; @@ -345,17 +342,14 @@ print $output < Date: Sun, 23 Jul 2017 23:10:00 -0400 Subject: [PATCH 5/6] env-driver: Quote value for assignment in eval. This permits using path_add when the environment variable already contains entries with characters that break shell quoting rules. Technically we'd need to pipe to sed or similar to re-quote single quotes, hopefully that won't come up... --- sample-kde-env-master.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sample-kde-env-master.sh b/sample-kde-env-master.sh index 55e8fd4..8dee868 100644 --- a/sample-kde-env-master.sh +++ b/sample-kde-env-master.sh @@ -72,10 +72,10 @@ path_add() { eval curVal=\$'{'$1'-}' - if [ -n "$curVal" ]; then - eval "$1"="$2:$curVal"; + if test -n "$curVal"; then + eval "$1"="$2:'$curVal'"; else - eval "$1"="$2" + eval "$1"="'$2'" fi } From 38bf5d6ff1464c675133e7720633502e8d72d359 Mon Sep 17 00:00:00 2001 From: Michael Pyne Date: Sun, 23 Jul 2017 23:12:13 -0400 Subject: [PATCH 6/6] env-driver: Complete porting std config to KF5. --- sample-kde-env-master.sh | 52 +++++++++++++++++++++------------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/sample-kde-env-master.sh b/sample-kde-env-master.sh index 8dee868..b115bd6 100644 --- a/sample-kde-env-master.sh +++ b/sample-kde-env-master.sh @@ -2,7 +2,7 @@ # # This sets the various environment variables needed to start Plasma (or other KDE # software built by kdesrc-build), or to run programs/build programs/etc. in the -# same environment. +# same environment, ideally without clashing with system-built KDE or Qt. # # This should not produce any output in order to make it usable by # non-interactive scripts. @@ -30,8 +30,8 @@ if ! test -n "$KDESRC_BUILD_TESTING"; then # kdesrc-build: f # Where KDE libraries and applications are installed to. kde_prefix="<% kdedir %>" # E.g. "$HOME/kf5" -# Where Qt is installed to. If using the system Qt, leave blank or set to -# 'auto' and this script will try to auto-detect. +# Where Qt is installed to. If using the system Qt, leave blank and this script +# will try to auto-detect. qt_prefix="<% qtdir %>" # E.g. "$HOME/qt5" or "/usr" on many systems. else # kdesrc-build: filter kde_prefix="$HOME/kf5" # kdesrc-build: filter @@ -40,13 +40,13 @@ fi # kdesrc-build: f # === End of modifiable variables. -# Set defaults if these are unset or null. ':' is a null command -: ${lib_suffix:=""} +# Default qmake executable if we don't find a better one +qmake=qmake # Find system Qt5 if test -z "$qt_prefix"; then - # Find right qmake - for qmake_candidate in qmake-qt5 qmake5 qmake; do + # Find right qmake, look for specific executables first + for qmake_candidate in qmake-qt5 qmake5; do if ${qmake_candidate} --version >/dev/null 2>&1; then qmake="$qmake_candidate" break; @@ -58,12 +58,6 @@ if test -z "$qt_prefix"; then test -z "$qt_prefix" && qt_prefix="/usr" # Emergency fallback? fi -# Try to auto-determine lib suffix if not set. This requires KDE to already -# have been installed though. -if test -z "$lib_suffix" && test -x "$kde_prefix/bin/kde5-config"; then - lib_suffix=$("$kde_prefix/bin/kde5-config" --libsuffix 2>/dev/null) -fi - # Add path elements to a colon-separated environment variable, # taking care not to add extra unneeded colons. # Should be sh-compatible. @@ -79,25 +73,35 @@ path_add() fi } -libname="lib$lib_suffix" - # Now add the necessary directories, starting with Qt (although we don't add Qt # if it's system Qt to avoid moving /usr up in the PATH. # Note that LD_LIBRARY_PATH *should* be extraneous with KF5 and Qt5 if test "x$qt_prefix" != "x/usr"; then - path_add "PATH" "$qt_prefix/bin"; - path_add "PKG_CONFIG_PATH" "$qt_prefix/$libname/pkgconfig"; - path_add "MANPATH" "$qt_prefix/share/man"; -# Do we need path_add for CMAKE_MODULE_PATH for Qt CMake .config files? + path_add "PATH" "$(${qmake} -query QT_INSTALL_BINS 2>/dev/null)"; + path_add "PKG_CONFIG_PATH" "$(${qmake} -query QT_INSTALL_LIBS 2>/dev/null)/pkgconfig"; +fi + +# There doesn't seem to be a great way to get this from CMake easily +# but we can reason that if there's a /usr/lib64, there will likely end +# up being a $kde_prefix/lib64 once kdesrc-build gets done installing it +libname=lib +if test -d /usr/lib64; then + libname=lib64 fi # Now add KDE-specific paths. path_add "PATH" "$kde_prefix/bin"; -path_add "PKG_CONFIG_PATH" "$kde_prefix/$libname/pkgconfig"; +# For some reason I've seen both of lib and lib64 used. I think due +# to qmake vs. cmake modules +if test $libname = lib64; then + path_add "PKG_CONFIG_PATH" "$kde_prefix/lib64/pkgconfig"; +fi +path_add "PKG_CONFIG_PATH" "$kde_prefix/lib/pkgconfig"; path_add "MANPATH" "$kde_prefix/share/man"; path_add "CMAKE_PREFIX_PATH" "$kde_prefix"; -path_add "CMAKE_MODULE_PATH" "$kde_prefix/share/cmake"; -path_add "QML_IMPORT_PATH" "$kde_prefix/$libname/kde4/imports"; +path_add "QML2_IMPORT_PATH" "$kde_prefix/$libname/qml"; +path_add "QT_PLUGIN_PATH" "$kde_prefix/$libname/qt5/plugins" # phonon likes this one +path_add "QT_PLUGIN_PATH" "$kde_prefix/$libname/plugins" # others like this more # For Python bindings support. path_add "PYTHONPATH" "$kde_prefix/$libname/site-packages"; @@ -108,11 +112,11 @@ path_add "XDG_CONFIG_DIRS" "$kde_prefix/etc/xdg"; # Finally, export the variables. export CMAKE_PREFIX_PATH -export CMAKE_MODULE_PATH export PATH export PKG_CONFIG_PATH export PYTHONPATH -export QML_IMPORT_PATH +export QML2_IMPORT_PATH +export QT_PLUGIN_PATH export XDG_DATA_DIRS export XDG_CONFIG_DIRS export MANPATH