From d83416213fffb69375c85368f4a95a91a234d9d8 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Wed, 6 Sep 2023 17:49:26 +0100 Subject: [PATCH] Enhanced AppImage downloader with --extract option If the full size AppImage is extracted locally, the extracted executable will run as fast as a packaged release - but will take more disk space. --- README.md | 7 ++ scripts/geeqie-download-appimage.sh | 100 +++++++++++++++++++++++++++- 2 files changed, 104 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 0512814b..884c3a23 100644 --- a/README.md +++ b/README.md @@ -126,6 +126,13 @@ This script file will download the latest Continuous Build AppImages for you: wget https://raw.githubusercontent.com/BestImageViewer/geeqie/master/scripts/geeqie-download-appimage.sh chmod +x geeqie-download-appimage.sh ``` +You should read the contents of the file before running it. The option ```--help``` gives some information about its functions. + +The script downloads both the full size and the minimal versions of the AppIamge, and sets symbolic links to these files. + +The full version takes a noticeable time to load, and runs slightly slower than a normal packaged release. +The above script has the option ```--extract``` which extracts the contents of the full size AppImage to a local sub-directory. +If the executable is run from there the loading and run time is the same as for a packaged release. ### Installation scripts diff --git a/scripts/geeqie-download-appimage.sh b/scripts/geeqie-download-appimage.sh index c7bab7e3..95e54e86 100755 --- a/scripts/geeqie-download-appimage.sh +++ b/scripts/geeqie-download-appimage.sh @@ -21,19 +21,113 @@ ## @file ## @brief Download full and minimal AppImages from the Continuous build release on GitHub. +## Optionally extract the full size AppImage. ## +## $1: -e | --extract Extract full size AppImage ## The user should modify the symbolic links as appropriate. ## ## Downloads will not be made unless the server version is newer than the local file. ## +show_help() +{ +printf "Download the latest Geeqie AppImages from the +Continuous Build release on GitHub. + +The Continuous Build release is updated each +time the source code is updated. + +You should read the contents of this file before +running it and modify it to your requirements. + +The default action is to download both the +minimal and full size AppImages to \$HOME/bin. +Symbolic links will be set so that: +\"geeqie\" points to the minimal version +and +\"Geeqie\" points to the full version. + +No downloads will be made unless the file on the +server at GitHub is newer than the local file. + +The full size AppImage is about 120MB and the +minimal AppImage is about 10MB. Therefore the full +size version will load much slower and will have +a slightly slower run speed. + +However the minimal version has limited capabilities +compared to the full size version. + +The extract option (-e or --extract) will extract +The contents of the full size image into a sub-directory +of \$HOME/bin, and then set the symbolic link to the +extracted executable. This will take up disk space, but the +extracted executable will run as fast as a packaged release. + +When a new file is downloaded the extracted files will +be replaced by the newly downloaded files\n\n" +} + +extract=0 + +while :; do + case $1 in + -h|-\?|--help) + show_help + exit + ;; + -e|--extract) # AppImage extraction is required + extract=1 + ;; + --) # End of all options. + shift + break + ;; + -?*) + printf 'ERROR: Unknown option %s\n' "$1" >&2 + exit + ;; + *) + break + esac + + shift +done + cd "$HOME/bin/" || exit architecture=$(arch) -wget --quiet --show-progress --backups=3 --timestamping "https://github.com/BestImageViewer/geeqie/releases/download/continuous/Geeqie-latest-$architecture.AppImage"; -chmod +x "Geeqie-latest-$architecture.AppImage" -ln --symbolic --force "Geeqie-latest-$architecture.AppImage" Geeqie +# Download full size AppImage +log_file=$(mktemp "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX") + +wget --no-verbose --show-progress --backups=3 --output-file="$log_file" --timestamping "https://github.com/BestImageViewer/geeqie/releases/download/continuous/Geeqie-latest-$architecture.AppImage"; + +download_size=$(stat --printf "%s" "$log_file") +rm "$log_file" + +# If a new file was downloaded, check if extraction is required +if [ "$download_size" -gt 0 ] +then + chmod +x "Geeqie-latest-$architecture.AppImage" + + if [ "$extract" -eq 1 ] + then + rm -rf "Geeqie-latest-$architecture-AppImage" + mkdir "Geeqie-latest-$architecture-AppImage" + cd "Geeqie-latest-$architecture-AppImage" || exit + + printf "Extracting AppImage\n" + ../"Geeqie-latest-$architecture.AppImage" --appimage-extract | cut -c 1-50 | tr '\n' '\r' + + printf "\n" + cd .. + ln --symbolic --force "./Geeqie-latest-$architecture-AppImage/squashfs-root/AppRun" Geeqie + else + ln --symbolic --force "Geeqie-latest-$architecture.AppImage" Geeqie + fi +fi +# Download minimal AppImage wget --quiet --show-progress --backups=3 --timestamping "https://github.com/BestImageViewer/geeqie/releases/download/continuous/Geeqie-minimal-latest-$architecture.AppImage"; chmod +x "Geeqie-minimal-latest-$architecture.AppImage" ln --symbolic --force "Geeqie-minimal-latest-$architecture.AppImage" geeqie -- 2.20.1