diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fa21c65..3c5ee063 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,7 +48,11 @@ FetchContent_Declare(AppImageUpdate # work around Wimplicit-function-declaration in ancient squashfuse code set(DEPENDENCIES_CFLAGS "-Wno-implicit-function-declaration" CACHE STRING "" FORCE) -option(ENABLE_UPDATE_HELPER ON) +option(ENABLE_UPDATE_HELPER "Build the AppImage update helper" OFF) +if(BUILD_LITE) + set(ENABLE_UPDATE_HELPER OFF CACHE BOOL "Build the AppImage update helper" FORCE) +endif() + if(ENABLE_UPDATE_HELPER) # instruct AppImageUpdate to build the Qt UI set(BUILD_QT_UI ON CACHE BOOL "" FORCE) diff --git a/ci/build.sh b/ci/build.sh index 33898391..ffbf7ae5 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -52,7 +52,7 @@ cmake_args=( if [[ "${BUILD_LITE:-}" == "" ]]; then cmake_args+=("-DENABLE_UPDATE_HELPER=ON") else - cmake_args+=("-DBUILD_LITE=ON") + cmake_args+=("-DBUILD_LITE=ON" "-DENABLE_UPDATE_HELPER=OFF") fi export QT_SELECT=qt5 @@ -161,7 +161,7 @@ if [[ "${BUILD_LITE:-}" == "" ]]; then # updater is not available for the lite build linuxdeploy_extra_args+=( - -e "$(find AppDir/usr/lib/*/appimagelauncher/update | head -n1)" + -e AppDir/usr/bin/appimagelauncher-update --output native_packages ) @@ -202,7 +202,7 @@ ldd AppDir/usr/bin/AppImageLauncherSettings --appdir "$(readlink -f AppDir)" \ --plugin qt \ -d AppDir/usr/share/applications/appimagelauncher.desktop \ - -e "$(find AppDir/usr/lib/*/appimagelauncher/remove | head -n1)" \ + -e AppDir/usr/bin/appimagelauncher-remove \ "${linuxdeploy_extra_args[@]}" if [[ "${BUILD_LITE:-}" == "" ]]; then diff --git a/resources/appimagelauncher-lite-AppRun.sh b/resources/appimagelauncher-lite-AppRun.sh index 5f217a6a..42aa408a 100755 --- a/resources/appimagelauncher-lite-AppRun.sh +++ b/resources/appimagelauncher-lite-AppRun.sh @@ -35,7 +35,6 @@ print_help() { echo " AppImageLauncherSettings Display AppImageLauncher Lite configuration utility" echo " cli [or ali-cli] Run AppImageLauncher cli (use \"cli --help\" for more information)" echo " remove Run removal helper to remove AppImage " - echo " update Run update helper to update AppImage " } case "$firstarg" in @@ -49,9 +48,8 @@ case "$firstarg" in cli|ail-cli) exec "$APPDIR"/usr/bin/ail-cli "$@" ;; - remove|update) - #exec "$APPDIR"/usr/lib/**/appimagelauncher/"$firstarg" "$@" - exec "$APPDIR"/usr/bin/"$firstarg" "$@" + remove) + exec "$APPDIR"/usr/bin/appimagelauncher-remove "$@" ;; install) if test_globally_installed; then @@ -118,5 +116,3 @@ EOF ;; esac - - diff --git a/src/shared/shared.cpp b/src/shared/shared.cpp index 7432e8f6..5094b261 100644 --- a/src/shared/shared.cpp +++ b/src/shared/shared.cpp @@ -598,8 +598,7 @@ QString privateLibDirPath(const QString& srcSubdirName) { } // if there is no such directory like /bin/../lib/... or the binary is not found there, there is a chance - // the binary is just next to this one (this is the case in the update/remove helpers) - // therefore we compare the binary directory path with PRIVATE_LIBDIR + // the private libraries are next to this binary, so compare the binary directory path with PRIVATE_LIBDIR if (!QDir(privateLibDirPath).exists()) { if (privateLibDirPath.contains(PRIVATE_LIBDIR)) { privateLibDirPath = ownBinaryDirPath; @@ -608,6 +607,18 @@ QString privateLibDirPath(const QString& srcSubdirName) { return privateLibDirPath; } + +static QString helperExecutablePath(const QString& executableName) { + const QDir ownBinaryDir(QFileInfo(getOwnBinaryPath().get()).dir()); + + // Installed helpers and helpers launched from the UI build directory live next to the calling executable. + const auto adjacentHelperPath = ownBinaryDir.absoluteFilePath(executableName); + if (QFileInfo(adjacentHelperPath).isExecutable()) + return adjacentHelperPath; + + // During development, callers such as appimagelauncherd and ail-cli live in sibling build directories. + return QDir(ownBinaryDir.absoluteFilePath("../ui")).absoluteFilePath(executableName); +} #endif bool installDesktopFileAndIcons(const QString& pathToAppImage, bool resolveCollisions) { @@ -798,8 +809,6 @@ bool installDesktopFileAndIcons(const QString& pathToAppImage, bool resolveColli #endif #ifndef BUILD_LITE - auto privateLibDir = privateLibDirPath("ui"); - const char helperIconName[] = "AppImageLauncher"; #else const char helperIconName[] = "AppImageLauncher-Lite"; @@ -815,7 +824,7 @@ bool installDesktopFileAndIcons(const QString& pathToAppImage, bool resolveColli std::ostringstream removeExecPath; #ifndef BUILD_LITE - removeExecPath << privateLibDir.toStdString() << "/remove"; + removeExecPath << helperExecutablePath("appimagelauncher-remove").toStdString(); #else removeExecPath << getenv("HOME") << "/.local/lib/appimagelauncher-lite/appimagelauncher-lite.AppImage remove"; #endif @@ -849,11 +858,7 @@ bool installDesktopFileAndIcons(const QString& pathToAppImage, bool resolveColli std::ostringstream updateExecPath; -#ifndef BUILD_LITE - updateExecPath << privateLibDir.toStdString() << "/update"; -#else - updateExecPath << getenv("HOME") << "/.local/lib/appimagelauncher-lite/appimagelauncher-lite.AppImage update"; -#endif + updateExecPath << helperExecutablePath("appimagelauncher-update").toStdString(); updateExecPath << " \"" << pathToAppImage.toStdString() << "\""; g_key_file_set_string(desktopFile.get(), updateSectionName.c_str(), "Exec", updateExecPath.str().c_str()); diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt index 785a7c81..f7553a74 100644 --- a/src/ui/CMakeLists.txt +++ b/src/ui/CMakeLists.txt @@ -33,28 +33,27 @@ install( ) # AppImage removal helper -add_executable(remove remove_main.cpp remove.ui resources.qrc) -target_link_libraries(remove shared translationmanager libappimage) +add_executable(appimagelauncher-remove remove_main.cpp remove.ui resources.qrc) +target_link_libraries(appimagelauncher-remove shared translationmanager libappimage) # see AppImageLauncher for a description -set_target_properties(remove PROPERTIES INSTALL_RPATH "\$ORIGIN") +set_target_properties(appimagelauncher-remove PROPERTIES INSTALL_RPATH ${_rpath}) install( TARGETS - remove - RUNTIME DESTINATION ${_private_libdir} COMPONENT APPIMAGELAUNCHER + appimagelauncher-remove + RUNTIME DESTINATION ${_bindir} COMPONENT APPIMAGELAUNCHER ) - # AppImage update helper if(ENABLE_UPDATE_HELPER) - add_executable(update update.ui update_main.cpp resources.qrc) - target_link_libraries(update shared translationmanager libappimage libappimageupdate-qt Qt5::Quick Qt5::QuickWidgets Qt5::Qml) + add_executable(appimagelauncher-update update.ui update_main.cpp resources.qrc) + target_link_libraries(appimagelauncher-update shared translationmanager libappimage libappimageupdate-qt Qt5::Quick Qt5::QuickWidgets Qt5::Qml) # see AppImageLauncher for a description - set_target_properties(update PROPERTIES INSTALL_RPATH "\$ORIGIN") + set_target_properties(appimagelauncher-update PROPERTIES INSTALL_RPATH ${_rpath}) install( TARGETS - update - RUNTIME DESTINATION ${_private_libdir} COMPONENT APPIMAGELAUNCHER + appimagelauncher-update + RUNTIME DESTINATION ${_bindir} COMPONENT APPIMAGELAUNCHER ) endif()