From d883d6df642228048be8c920ac42246efed89216 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Fri, 13 Apr 2018 02:38:47 +0200 Subject: [PATCH 1/3] Improve excludelist generation (fixes #274) --- tools/excludelist.sh | 12 ----- tools/generate-excludelist.sh | 42 ++++++++++++++++ tools/linuxdeployqt/CMakeLists.txt | 5 +- tools/linuxdeployqt/excludelist.h | 69 +++++++++++++++++++++++++++ tools/linuxdeployqt/linuxdeployqt.pro | 12 ++--- tools/linuxdeployqt/shared.cpp | 18 +++---- 6 files changed, 123 insertions(+), 35 deletions(-) delete mode 100755 tools/excludelist.sh create mode 100755 tools/generate-excludelist.sh create mode 100644 tools/linuxdeployqt/excludelist.h diff --git a/tools/excludelist.sh b/tools/excludelist.sh deleted file mode 100755 index 373b0ad..0000000 --- a/tools/excludelist.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -set -e - -# Download excludelist -blacklisted=($(wget --quiet https://raw.githubusercontent.com/probonopd/AppImages/master/excludelist -O - | sort | uniq | grep -v "^#.*" | grep "[^-\s]")) - -# Create array -for item in ${blacklisted[@]:0:${#blacklisted[@]}-1}; do - echo -ne '\\"'$item'\\" << ' -done -echo -ne '\\"'${blacklisted[-1]}'\\"' diff --git a/tools/generate-excludelist.sh b/tools/generate-excludelist.sh new file mode 100755 index 0000000..9155c3a --- /dev/null +++ b/tools/generate-excludelist.sh @@ -0,0 +1,42 @@ +#!/bin/bash + +set -e + +# download excludelist +blacklisted=($(wget --quiet https://raw.githubusercontent.com/probonopd/AppImages/master/excludelist -O - | sort | uniq | grep -v "^#.*" | grep "[^-\s]")) + +# sanity check +if [ "$blacklisted" == "" ]; then + exit 1; +fi + +filename=$(readlink -f $(dirname "$0"))/linuxdeployqt/excludelist.h + +# overwrite existing source file +cat > "$filename" < + +static const QStringList generatedExcludelist = { +EOF + +# Create array +for item in ${blacklisted[@]:0:${#blacklisted[@]}-1}; do + echo -e ' "'"$item"'",' >> "$filename" +done +echo -e ' "'"${blacklisted[-1]}"'"' >> "$filename" + +echo "};" >> "$filename" diff --git a/tools/linuxdeployqt/CMakeLists.txt b/tools/linuxdeployqt/CMakeLists.txt index 01c658d..657489c 100644 --- a/tools/linuxdeployqt/CMakeLists.txt +++ b/tools/linuxdeployqt/CMakeLists.txt @@ -9,14 +9,15 @@ add_definitions("-DBUILD_NUMBER=\"${BUILD_NUMBER}\"") find_package(Qt5 REQUIRED COMPONENTS Core) # update excludelist +message(STATUS "Updating excludelist...") execute_process( - COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/../excludelist.sh + COMMAND bash ${CMAKE_CURRENT_SOURCE_DIR}/../generate-excludelist.sh OUTPUT_VARIABLE EXCLUDELIST TIMEOUT 10 RESULT_VARIABLE EXCLUDELIST_RESULT ) if(NOT EXCLUDELIST_RESULT EQUAL 0) - message(FATAL_ERROR "Failed to fetch and generate excludelist") + message(WARNING "Updating excludelist failed, using outdated copy") endif() mark_as_advanced(EXCLUDELIST EXCLUDELIST_RESULT) diff --git a/tools/linuxdeployqt/excludelist.h b/tools/linuxdeployqt/excludelist.h new file mode 100644 index 0000000..87cc316 --- /dev/null +++ b/tools/linuxdeployqt/excludelist.h @@ -0,0 +1,69 @@ +/* + * List of libraries to exclude for different reasons. + * + * Automatically generated from + * https://raw.githubusercontent.com/probonopd/AppImages/master/excludelist + * + * This file shall be committed by the developers occassionally, + * otherwise systems without access to the internet won't be able to build + * fully working versions of linuxdeployqt. + * + * See https://github.com/probonopd/linuxdeployqt/issues/274 for more + * information. + */ + +#include + +static const QStringList generatedExcludelist = { + "ld-linux.so.2", + "ld-linux-x86-64.so.2", + "libanl.so.1", + "libasound.so.2", + "libBrokenLocale.so.1", + "libcidn.so.1", + "libcom_err.so.2", + "libcrypt.so.1", + "libc.so.6", + "libdl.so.2", + "libdrm.so.2", + "libexpat.so.1", + "libfontconfig.so.1", + "libfreetype.so.6", + "libgcc_s.so.1", + "libgdk_pixbuf-2.0.so.0", + "libgio-2.0.so.0", + "libglib-2.0.so.0", + "libGL.so.1", + "libgobject-2.0.so.0", + "libgpg-error.so.0", + "libharfbuzz.so.0", + "libICE.so.6", + "libjack.so.0", + "libkeyutils.so.1", + "libm.so.6", + "libmvec.so.1", + "libnsl.so.1", + "libnss_compat.so.2", + "libnss_db.so.2", + "libnss_dns.so.2", + "libnss_files.so.2", + "libnss_hesiod.so.2", + "libnss_nisplus.so.2", + "libnss_nis.so.2", + "libp11-kit.so.0", + "libpango-1.0.so.0", + "libpangocairo-1.0.so.0", + "libpangoft2-1.0.so.0", + "libpthread.so.0", + "libresolv.so.2", + "librt.so.1", + "libSM.so.6", + "libstdc++.so.6", + "libthread_db.so.1", + "libusb-1.0.so.0", + "libutil.so.1", + "libuuid.so.1", + "libX11.so.6", + "libxcb.so.1", + "libz.so.1" +}; diff --git a/tools/linuxdeployqt/linuxdeployqt.pro b/tools/linuxdeployqt/linuxdeployqt.pro index 823568e..0257bb0 100644 --- a/tools/linuxdeployqt/linuxdeployqt.pro +++ b/tools/linuxdeployqt/linuxdeployqt.pro @@ -38,18 +38,12 @@ DEFINES += LINUXDEPLOYQT_VERSION="'\"$(shell cd $$PWD && git describe --tags $(s contains(DEFINES, EXCLUDELIST.*) { message("EXCLUDELIST specified, to use the most recent exclude list, please run qmake without EXCLUDELIST definition and with internet.") } else { - message("Creating exclude list.") + message("Updating exclude list...") # check whether command _would_ run successfully EXCLUDELIST_GENERATION_WORKS = FALSE - system($$_PRO_FILE_PWD_/../excludelist.sh): EXCLUDELIST_GENERATION_WORKS = TRUE + system($$_PRO_FILE_PWD_/../generate-excludelist.sh): EXCLUDELIST_GENERATION_WORKS = TRUE isEqual(EXCLUDELIST_GENERATION_WORKS, FALSE) { - error("Generating excludelist failed") + warning("Updating excludelist failed, using outdated copy") } - - EXCLUDELIST = $$system($$_PRO_FILE_PWD_/../excludelist.sh) - isEmpty(EXCLUDELIST) { - error("Generated excludelist is empty") - } - DEFINES += EXCLUDELIST=\""$$EXCLUDELIST"\" } diff --git a/tools/linuxdeployqt/shared.cpp b/tools/linuxdeployqt/shared.cpp index 1c68b47..aed1a10 100644 --- a/tools/linuxdeployqt/shared.cpp +++ b/tools/linuxdeployqt/shared.cpp @@ -44,6 +44,7 @@ #include #include #include "shared.h" +#include "excludelist.h" QString appBinaryPath; bool runStripEnabled = true; @@ -465,20 +466,13 @@ LibraryInfo parseLddLibraryLine(const QString &line, const QString &appDirPath, This is more suitable for bundling in a way that is portable between different distributions and target systems. Along the way, this also takes care of non-Qt libraries. - The excludelist can be updated by running - #/bin/bash - blacklisted=$(wget https://raw.githubusercontent.com/probonopd/AppImages/master/excludelist -O - | sort | uniq | grep -v "^#.*" | grep "[^-\s]") - for item in $blacklisted; do - echo -ne '"'$item'" << ' - done + The excludelist can be updated by running the bundled script generate-excludelist.sh */ - QStringList excludelist; - #ifndef EXCLUDELIST - #error "EXCLUDELIST not defined! Please have your build system download run excludelist.sh and add -DEXCLUDE_LIST=" - #else - excludelist << EXCLUDELIST; - #endif + // copy generated excludelist + QStringList excludelist = generatedExcludelist; + + // append exclude libs excludelist += excludeLibs; LogDebug() << "excludelist:" << excludelist; From b09cf168d7575a9d78f782ee3a53fbe839cb87f2 Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Fri, 13 Apr 2018 03:15:36 +0200 Subject: [PATCH 2/3] C++11 required --- tools/linuxdeployqt/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/linuxdeployqt/CMakeLists.txt b/tools/linuxdeployqt/CMakeLists.txt index 657489c..e7af15a 100644 --- a/tools/linuxdeployqt/CMakeLists.txt +++ b/tools/linuxdeployqt/CMakeLists.txt @@ -1,5 +1,8 @@ set(CMAKE_AUTOMOC ON) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + # expose version data as compiler definition add_definitions("-DLINUXDEPLOYQT_VERSION=\"${GIT_TAG_NAME}\"") add_definitions("-DLINUXDEPLOYQT_GIT_COMMIT=\"${GIT_COMMIT}\"") From 45088e5a5e86989c5b755f48880608afacbfb20b Mon Sep 17 00:00:00 2001 From: TheAssassin Date: Fri, 13 Apr 2018 03:37:26 +0200 Subject: [PATCH 3/3] Fix -show-exclude-libs Had to move the parsing of -show-exclude-lib up to the block where the version options are parsed, otherwise a call like ./linuxdeployqt<...>.AppImage -show-exclude-libs wouldn't work. CC @patrickelectric --- tools/linuxdeployqt/main.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/tools/linuxdeployqt/main.cpp b/tools/linuxdeployqt/main.cpp index 51d4660..95ce4dd 100644 --- a/tools/linuxdeployqt/main.cpp +++ b/tools/linuxdeployqt/main.cpp @@ -34,6 +34,7 @@ #include #include #include +#include "excludelist.h" int main(int argc, char **argv) { @@ -60,6 +61,10 @@ int main(int argc, char **argv) // can just exit normally, version has been printed above return 0; } + if (argument == QByteArray("-show-exclude-libs")) { + qInfo() << generatedExcludelist; + return 0; + } } if (argc < 2 || (firstArgument.startsWith("-"))) { @@ -426,9 +431,6 @@ int main(int argc, char **argv) LogDebug() << "Argument found:" << argument; int index = argument.indexOf("="); excludeLibs = QString(argument.mid(index + 1)).split(","); - } else if (argument == QByteArray("-show-exclude-libs")) { - qInfo() << EXCLUDELIST; - return 0; } else if (argument.startsWith("--")) { LogError() << "Error: arguments must not start with --, only -:" << argument << "\n"; return 1;