Commit 05d1460f authored by Michael Pyne's avatar Michael Pyne
Browse files

xsession: Extract var setting to separate script.

dfaure reinforced a point I was thinking after doing testing on my
system... the environment variable-setting portion of the script needs
to be factored out into its own script so that it can be sourced easily
from login profile setup, shell setup, etc. and not just used from the
xsession startup.

It's still not active (but the code is used in the test suite), will try
to work on that tomorrow assuming the sequel to "Perfect Storm" about to
strike here in DC leaves me with power...
parent 013246ae
......@@ -33,6 +33,7 @@ package main;
use Test::More import => ['!note'];
use File::Temp 'tempdir';
use Storable 'dclone';
use File::Copy;
# From kdesrc-build
our %ENV_VARS;
......@@ -516,16 +517,34 @@ SKIP: {
like ($newQMakePossibility, qr/^qmake/, 'qmake looks like an executable even in scalar context.');
}
is(system('/bin/sh', '-n', "$RealBin/sample-xsession.sh"), 0, 'xsession pre-install syntax check');
# This test set must be run first as xsession depends on this env-master.
is(system('/bin/sh', '-n', "$RealBin/sample-kde-env-master.sh"), 0,
'env-master pre-install syntax check');
$ENV{KDESRC_BUILD_TESTING} = 1; # Tell sample-xsession.sh not to run.
is(system('/bin/sh', '-u', "$RealBin/sample-xsession.sh"), 0, 'xsession unset variable check');
is(system('/bin/sh', '-u', "$RealBin/sample-kde-env-master.sh"), 0,
'env-master unset variable check');
# Ensure this function can run without throwing exception.
ok(installTemplatedFile("$RealBin/sample-xsession.sh", "$testSourceDirName/xsession.sh", $ctx) || 1,
'xsession template installation');
ok(installTemplatedFile("$RealBin/sample-kde-env-master.sh", "$testSourceDirName/.kde-env-master.sh", $ctx) || 1,
'env-master template installation');
is(system('/bin/sh', '-n', "$RealBin/sample-xsession.sh"), 0,
'xsession pre-install syntax check');
ok(File::Copy::copy("$RealBin/sample-xsession.sh", "$testSourceDirName/xsession.sh"),
'xsession installation');
is(system('/bin/sh', '-n', "$testSourceDirName/xsession.sh"), 0, 'xsession post-install syntax check');
$ENV{KDESRC_BUILD_TESTING} = 1; # Tell sample-xsession.sh not to run.
is(system('/bin/sh', '-u', "$RealBin/sample-xsession.sh"), 0,
'xsession unset variable check');
do {
local $ENV{HOME} = "$testSourceDirName"; # Search right spot for kde-env-master.sh
is(system('/bin/sh', '-n', "$testSourceDirName/xsession.sh"), 0,
'xsession post-install syntax check');
};
done_testing();
### TESTS GO ABOVE THIS LINE
......
#!/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 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.
#
# Use by copying this script to ~/.kde-env-master (this will be done for you by
# kdesrc-build and/or kdesrc-build-setup, later).
# === User-modifiable variables. Should be set automatically by kdesrc-build.
# 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
# Where KDE libraries and applications are installed to.
kde_prefix="<% kdedir %>" # E.g. "$HOME/kde-4"
# 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
# Directory to use for KDE configuration and other user customizations.
KDEHOME="$HOME/.kde4-self" # Or perhaps "$HOME/.kde-selfmade", etc.
# "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.
# Additional paths to add to PATH, can be left blank.
user_path="" # Set to colon-separated PATH to add to the Qt/KDE paths.
# If more user customizations to the environment are needed, you can "source"
# this file from a more-specific file such as .bashrc, .profile, etc.
# === End of user-modifiable variables.
# Find system Qt
if test -z "$qt_prefix"; then
# Find right qmake
for qmake_candidate in qmake-qt4 qmake4 qmake; do
if ${qmake_candidate} --version >/dev/null 2>&1; then
qmake="$qmake_candidate"
break;
fi
done
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)
fi
# Add path elements to a colon-separated environment variable,
# taking care not to add extra unneeded colons.
# Should be sh-compatible.
# Can't use function keyword in Busybox-sh
path_add()
{
eval curVal=\$'{'$1'-}'
if [ -n "$curVal" ]; then
eval "$1"="$2:$curVal";
else
eval "$1"="$2"
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.
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";
# 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 "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";
# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
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 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
......@@ -7,129 +7,14 @@
#
# From there, select "custom" session when logging in, in order to login using
# this script.
# === User-modifiable variables. Should be set automatically by kdesrc-build.
# 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
# Where KDE libraries and applications are installed to.
kde_prefix="<% kdedir %>" # E.g. "$HOME/kde-4"
# 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
# Directory to use for KDE configuration and other user customizations.
KDEHOME="$HOME/.kde4-self" # Or perhaps "$HOME/.kde-selfmade", etc.
# "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.
# Additional paths to add to PATH, can be left blank.
user_path="" # Set to colon-separated PATH to add to the Qt/KDE paths.
#
# If more user customizations to the environment are needed, create a file
# .xsession-local, which will be sourced just prior to running KDE. This can
# read .bashrc, just set a few vars, etc.
# === End of user-modifiable variables.
# Find system Qt
if test -z "$qt_prefix"; then
# Find right qmake
for qmake_candidate in qmake-qt4 qmake4 qmake; do
if ${qmake_candidate} --version >/dev/null 2>&1; then
qmake="$qmake_candidate"
break;
fi
done
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)
fi
# Add path elements to a colon-separated environment variable,
# taking care not to add extra unneeded colons.
# Should be sh-compatible.
# Can't use function keyword in Busybox-sh
path_add()
{
eval curVal=\$'{'$1'-}'
if [ -n "$curVal" ]; then
eval "$1"="$2:$curVal";
else
eval "$1"="$2"
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.
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";
# 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 "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";
# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
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"
source "$HOME/.kde-env-master.sh" # Should be installed by kdesrc-build
# Finally, export the variables.
export CMAKE_PREFIX_PATH
export KDEDIRS
export LD_LIBRARY_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
# See .kde-env-master.sh for details on the kdesrc-build: filter stuff
if ! test -n "$KDESRC_BUILD_TESTING"; then # kdesrc-build: filter
# Read in user-specific customizations
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment