13#include <alkimia/alkenvironment.h> 
   15void AlkEnvironment::checkForAppImageEnvironment(
const char* applicationPath)
 
   18#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 
   19    if (qEnvironmentVariableIsSet(
"APPDIR")) {
 
   20        QByteArray appFullPath(applicationPath);
 
   21        auto lastDirSeparator = appFullPath.lastIndexOf(
'/');
 
   22        auto appDir = appFullPath.left(lastDirSeparator + 1);
 
   24        alkDebug() << 
"AppImageInfo:" << appFullPath << appDir << 
appName;
 
   25        if (appName == QStringLiteral(
"AppRun.wrapped")) {
 
   26            appDir.append(
"usr/lib");
 
   27            const auto libPath = qgetenv(
"LD_LIBRARY_PATH");
 
   28            auto newLibPath = appDir;
 
   29            if (!libPath.isEmpty()) {
 
   30                newLibPath.append(
':');
 
   31                newLibPath.append(libPath);
 
   33            qputenv(
"RUNNING_AS_APPIMAGE", 
"true");
 
   34            qputenv(
"LD_LIBRARY_PATH", newLibPath);
 
   35            alkDebug() << 
"LD_LIBRARY_PATH set to" << newLibPath;
 
   42bool AlkEnvironment::isRunningAsAppImage()
 
   45#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 
   46    return qEnvironmentVariableIsSet(
"RUNNING_AS_APPIMAGE");
 
   55void AlkEnvironment::removeAppImagePathFromLinkLoaderLibPath(
QProcess* process)
 
   58#if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) 
   59    if (isRunningAsAppImage() && process) {
 
   61        auto ld_library_path = environment.value(QLatin1String(
"LD_LIBRARY_PATH"));
 
   62        if (!ld_library_path.isEmpty()) {
 
   63            const auto appdir = environment.value(QLatin1String(
"APPDIR"));
 
   64            auto path_list = ld_library_path.split(QLatin1Char(
':'));
 
   65            while (!path_list.isEmpty() && path_list.at(0).startsWith(appdir)) {
 
   66                path_list.removeAt(0);
 
   67                ld_library_path.clear();
 
   68                if (!path_list.isEmpty()) {
 
   69                    ld_library_path = path_list.join(QLatin1Char(
':'));
 
   71                if (!ld_library_path.isEmpty()) {
 
   72                    environment.insert(QLatin1String(
"LD_LIBRARY_PATH"), ld_library_path);
 
   74                    environment.remove(QLatin1String(
"LD_LIBRARY_PATH"));
 
Wrapper for debug output.
 
QCA_EXPORT QString appName()
 
void setProcessEnvironment(const QProcessEnvironment &environment)
 
QProcessEnvironment systemEnvironment()
 
QString fromUtf8(QByteArrayView str)