Skip to content

Commit

Permalink
Merge pull request #178 from TheAssassin/lite
Browse files Browse the repository at this point in the history
AppImageLauncher Lite
  • Loading branch information
TheAssassin committed Jul 1, 2019
2 parents a82c11c + 52609f9 commit 7dcc010
Show file tree
Hide file tree
Showing 16 changed files with 428 additions and 63 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Expand Up @@ -12,6 +12,10 @@ matrix:
- env: DIST=bionic ARCH=i386
- env: DIST=xenial ARCH=x86_64
- env: DIST=xenial ARCH=i386
- env: DIST=xenial ARCH=x86_64 BUILD_LITE=1
name: AppImageLauncher Lite AppImage x86_64
- env: DIST=xenial ARCH=i386 BUILD_LITE=1
name: AppImageLauncher Lite AppImage i386

script:
- bash -ex travis/travis-docker.sh "$DIST"
Expand All @@ -20,7 +24,9 @@ after_success:
- wget -c https://github.com/probonopd/uploadtool/raw/master/upload.sh
- if [ "$TRAVIS_BRANCH" != "master" ] && [ "$TRAVIS_TAG" == "" ]; then export TRAVIS_EVENT_TYPE=pull_request; fi
- |2
if [ "$DIST" == "xenial" ]; then
if [[ "$BUILD_LITE" != "" ]]; then
bash upload.sh appimagelauncher-lite-*.AppImage*
elif [[ "$DIST" == "xenial" ]]; then
bash upload.sh appimagelauncher*.{deb,rpm}* appimagelauncher*.tar*
else
bash upload.sh appimagelauncher*.deb*
Expand Down
76 changes: 39 additions & 37 deletions cmake/install.cmake
Expand Up @@ -44,35 +44,49 @@ foreach(i libappimage libappimageupdate libappimageupdate-qt)
endif()
endforeach()

# TODO: find alternative to the following "workaround" (a pretty dirty hack, actually...)
# bundle update-binfmts as a fallback for distros which don't have it installed
find_program(UPDATE_BINFMTS
NAMES update-binfmts
PATHS /usr/sbin
)
if(NOT BUILD_LITE)
# TODO: find alternative to the following "workaround" (a pretty dirty hack, actually...)
# bundle update-binfmts as a fallback for distros which don't have it installed
find_program(UPDATE_BINFMTS
NAMES update-binfmts
PATHS /usr/sbin
)

if(NOT UPDATE_BINFMTS STREQUAL UPDATE_BINFMTS-NOTFOUND AND EXISTS ${UPDATE_BINFMTS})
message(STATUS "Found update-binfmts, bundling: ${UPDATE_BINFMTS}")
install(
FILES /usr/sbin/update-binfmts
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${_private_libdir} COMPONENT APPIMAGELAUNCHER
)
else()
message(WARNING "update-binfmts could not be found. Please install the binfmt-support package if you intend to build RPM packages.")
endif()

if(NOT UPDATE_BINFMTS STREQUAL UPDATE_BINFMTS-NOTFOUND AND EXISTS ${UPDATE_BINFMTS})
message(STATUS "Found update-binfmts, bundling: ${UPDATE_BINFMTS}")
# binfmt.d config file -- used as a fallback, if update-binfmts is not available
configure_file(
${PROJECT_SOURCE_DIR}/resources/binfmt.d/appimage.conf.in
${PROJECT_BINARY_DIR}/resources/binfmt.d/appimage.conf
@ONLY
)
# caution: don't use ${CMAKE_INSTALL_LIBDIR} here, it's really just lib/binfmt.d
install(
FILES /usr/sbin/update-binfmts
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
DESTINATION ${_private_libdir} COMPONENT APPIMAGELAUNCHER
FILES ${PROJECT_BINARY_DIR}/resources/binfmt.d/appimage.conf
DESTINATION lib/binfmt.d COMPONENT APPIMAGELAUNCHER
)
else()
message(WARNING "update-binfmts could not be found. Please install the binfmt-support package if you intend to build RPM packages.")
endif()

# binfmt.d config file -- used as a fallback, if update-binfmts is not available
configure_file(
${PROJECT_SOURCE_DIR}/resources/binfmt.d/appimage.conf.in
${PROJECT_BINARY_DIR}/resources/binfmt.d/appimage.conf
@ONLY
)
# caution: don't use ${CMAKE_INSTALL_LIBDIR} here, it's really just lib/binfmt.d
install(
FILES ${PROJECT_BINARY_DIR}/resources/binfmt.d/appimage.conf
DESTINATION lib/binfmt.d COMPONENT APPIMAGELAUNCHER
)
# install systemd service configuration for appimagelauncherfs
configure_file(
${PROJECT_SOURCE_DIR}/resources/appimagelauncherfs.service.in
${PROJECT_BINARY_DIR}/resources/appimagelauncherfs.service
@ONLY
)
# caution: don't use ${CMAKE_INSTALL_LIBDIR} here, it's really just lib/systemd/user
install(
FILES ${PROJECT_BINARY_DIR}/resources/appimagelauncherfs.service
DESTINATION lib/systemd/user/ COMPONENT APPIMAGELAUNCHERFS
)
endif()

# install systemd service configuration for appimagelauncherd
configure_file(
Expand All @@ -85,15 +99,3 @@ install(
FILES ${PROJECT_BINARY_DIR}/resources/appimagelauncherd.service
DESTINATION lib/systemd/user/ COMPONENT APPIMAGELAUNCHER
)

# install systemd service configuration for appimagelauncherfs
configure_file(
${PROJECT_SOURCE_DIR}/resources/appimagelauncherfs.service.in
${PROJECT_BINARY_DIR}/resources/appimagelauncherfs.service
@ONLY
)
# caution: don't use ${CMAKE_INSTALL_LIBDIR} here, it's really just lib/systemd/user
install(
FILES ${PROJECT_BINARY_DIR}/resources/appimagelauncherfs.service
DESTINATION lib/systemd/user/ COMPONENT APPIMAGELAUNCHERFS
)
185 changes: 185 additions & 0 deletions resources/appimagelauncher-lite-AppRun.sh
@@ -0,0 +1,185 @@
#! /bin/bash

set -e

if [[ "$VERBOSE" != "" ]]; then
set -x
fi

# shift does not work if no arguments have been passed, therefore we just handle that situation right now
if [[ "$1" == "" ]]; then
echo "Error: no option passed, use --help for more information"
exit 2
fi

firstarg="$1"
shift


prefix="appimagelauncher-lite"
install_dir=~/.local/lib/appimagelauncher-lite
installed_appimage_path="$install_dir"/appimagelauncher-lite.AppImage
settings_desktop_file_path=~/.local/share/applications/"$prefix"-AppImageLauncherSettings.desktop
systemd_user_units_dir=~/.config/systemd/user/
appimagelauncherd_systemd_service_name=appimagelauncherd.service
integrated_icon_path=~/.local/share/icons/hicolor/scalable/apps/AppImageLauncher-Lite.svg

test_globally_installed() {
which AppImageLauncher &>/dev/null && return 0
type AppImageLauncher &>/dev/null && return 0
[[ -d /usr/lib/*/appimagelauncher ]] && return 0

return 1
}

test_installed_already() {
[[ -d "$install_dir" ]] && return 0

return 1
}

ail_lite_notify_desktop_integration() {
update-desktop-database ~/.local/share/applications
gtk-update-icon-cache
}

ail_lite_install() {
if [[ "$APPIMAGE" == "" ]]; then
echo "Error: not running from AppImage, aborting"
return 2
fi

# create default Applications directory
mkdir -p ~/Applications

# prepare install dir
mkdir -p "$install_dir"
mkdir -p "$install_dir"/systemd

# copy ourselves to install dir
cp "$APPIMAGE" "$installed_appimage_path"

# set up appimagelauncherd
cat > "$install_dir"/systemd/"$appimagelauncherd_systemd_service_name" <<EOF
[Unit]
Description=AppImageLauncher daemon
[Service]
ExecStart=${installed_appimage_path} appimagelauncherd
Restart=on-failure
RestartSec=10
[Install]
WantedBy=default.target
EOF

# now we need to make systemd aware of your service file
ln -s "$install_dir"/systemd/"$appimagelauncherd_systemd_service_name" "$systemd_user_units_dir"/

systemctl --user daemon-reload
systemctl --user enable "$appimagelauncherd_systemd_service_name"
systemctl --user start "$appimagelauncherd_systemd_service_name"

# set up desktop file for AppImageLauncherSettings
cat > ~/.local/share/applications/appimagelauncher-lite-AppImageLauncherSettings.desktop <<EOF
[Desktop Entry]
Version=1.0
Type=Application
Exec=${installed_appimage_path} AppImageLauncherSettings %f
Name=AppImageLauncher Settings
Icon=AppImageLauncher-Lite
Terminal=false
Categories=Utility;
X-AppImage-Integrate=false
StartupWMClass=AppImageLauncherSettings
EOF

# copy icon for AppImageLauncherSettings
# TODO: copy PNG icons, too
install "$APPDIR"/usr/share/icons/hicolor/scalable/apps/AppImageLauncher.svg "$integrated_icon_path"

# notify desktop of changes
ail_lite_notify_desktop_integration

echo "AppImageLauncher Lite has been installed successfully."
return 0
}

ail_lite_uninstall() {
# remove appimagelauncherd systemd stuff
systemctl --user stop "$appimagelauncherd_systemd_service_name"
systemctl --user disable "$appimagelauncherd_systemd_service_name"
systemctl --user daemon-reload

# remove all the installed files
rm -r "$install_dir"

echo "AppImageLauncher Lite has been uninstalled successfully."
return 0
}

print_help() {
echo "Usage: $0 <option> ..."
echo
echo "Main options:"
echo " install Install AppImageLauncher into your user account"
echo " uninstall Uninstall AppImageLauncher from your user account"
echo " help|--help Display this help"
echo
echo "Other options (mainly for use by AppImageLauncher Lite internally):"
echo " appimagelauncherd Run appimagelauncherd"
echo " AppImageLauncherSettings Display AppImageLauncher Lite configuration utility"
echo " cli [or ali-cli] Run AppImageLauncher cli (use \"cli --help\" for more information)"
echo " remove <path> Run removal helper to remove AppImage <path>"
echo " update <path> Run update helper to update AppImage <path>"
}

# ensure this important variable is available, as most operations (except for install) can be done without being run
# from via AppImage runtime (e.g., while the AppImage is extracted, which is great for testing)
export APPDIR=${APPDIR:-$(readlink -f $(dirname "$0"))}

case "$firstarg" in
help|--help)
print_help
exit 0
;;
appimagelauncherd|AppImageLauncherSettings)
exec "$APPDIR"/usr/bin/"$firstarg" "$@"
;;
cli|ail-cli)
exec "$APPDIR"/usr/bin/ail-cli "$@"
;;
remove|update)
exec "$APPDIR"/usr/lib/**/appimagelauncher/"$firstarg" "$@"
;;
install)
if test_globally_installed; then
echo "Error: AppImageLauncher is installed system-wide already, not installing on top" 1>&2
exit 2
fi

if test_installed_already; then
echo "Error: AppImageLauncher Lite is installed already, please uninstall before trying to reinstall" 1>&2
exit 2
fi

echo "Installing AppImageLauncher Lite"
ail_lite_install
;;
uninstall)
if ! test_installed_already; then
echo "Error: AppImageLauncher Lite does not seem to be installed" 1>&2
exit 2
fi

echo "Uninstalling AppImageLauncher Lite"
ail_lite_uninstall
;;
*)
echo "Unknown operation: $firstarg";
exit 2
;;
esac



8 changes: 8 additions & 0 deletions resources/appimagelauncher-lite.desktop
@@ -0,0 +1,8 @@
[Desktop Entry]
Name=appimagelauncher-lite
Exec=appimagelauncher-lite
Icon=AppImageLauncher
Type=Application
X-AppImage-Integrate=false
NoDisplay=true
Categories=Utility;
8 changes: 7 additions & 1 deletion src/CMakeLists.txt
Expand Up @@ -35,6 +35,10 @@ endif()

add_compile_options(-Wall -Wpedantic)

if(BUILD_LITE)
add_definitions(-DBUILD_LITE)
endif()

# utility libraries
add_subdirectory(fswatcher)
add_subdirectory(i18n)
Expand All @@ -48,7 +52,9 @@ add_subdirectory(daemon)
add_subdirectory(ui)

# FUSE filesystem AppImageLauncherFS
add_subdirectory(fusefs)
if(NOT BUILD_LITE)
add_subdirectory(fusefs)
endif()

# CLI helper allowing other tools to utilize AppImageLauncher's code for e.g., integrating AppImages
add_subdirectory(cli)
10 changes: 10 additions & 0 deletions src/cli/cli_main.cpp
@@ -1,3 +1,6 @@
// system headers
#include <sstream>

// library headers
#include <QCoreApplication>
#include <QCommandLineParser>
Expand All @@ -16,11 +19,18 @@ int main(int argc, char** argv) {

QCoreApplication app(argc, argv);

std::ostringstream version;
version << "version " << APPIMAGELAUNCHER_VERSION << " "
<< "(git commit " << APPIMAGELAUNCHER_GIT_COMMIT << "), built on "
<< APPIMAGELAUNCHER_BUILD_DATE;
QCoreApplication::setApplicationVersion(QString::fromStdString(version.str()));

QCommandLineParser parser;

parser.addPositionalArgument("<command>", "Command to run (see help for more information");
parser.addPositionalArgument("[...]", "command-specific additional arguments");
parser.addHelpOption();
parser.addVersionOption();

parser.process(app);

Expand Down

0 comments on commit 7dcc010

Please sign in to comment.