2 #**********************************************************************
3 # Copyright (C) 2023 - The Geeqie Team
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #**********************************************************************
23 ## @brief Download full and minimal AppImages from the Continuous build release on GitHub.
24 ## Optionally extract the full size AppImage.
26 ## The user may modify the symbolic links as appropriate.
28 ## Downloads will not be made unless the server version is newer than the local file.
36 printf "Download the latest Geeqie AppImages from the
37 Continuous Build release on GitHub.
39 -b --backups <n> Set number of backups (default is 3)
40 -d --desktop Install desktop icon and menu item
41 -e --extract Extract AppImage
42 -h --help Display this message
43 -m --minimal Download minimal version of AppImage
44 -r --revert <n> Revert to downloaded AppImage backup
45 -v --version Display version of this file
47 The Continuous Build release is updated each
48 time the source code is updated.
50 The default action is to download an AppImage to
51 \$HOME/bin. A symbolic link will be set so that
52 \"geeqie\" points to the executable
54 No downloads will be made unless the file on the
55 server at GitHub is newer than the local file.
57 The full size AppImage is about 120MB and the
58 minimal AppImage is about 10MB. Therefore the full
59 size version will load much slower and will have
60 a slightly slower run speed.
62 However the minimal version has limited capabilities
63 compared to the full size version.
65 The minimal option (-m or --minimal) will download
68 The extract option (-e or --extract) will extract
69 The contents of the AppImage into a sub-directory
70 of \$HOME/bin, and then set the symbolic link to the
73 This will take up some disk space, but the
74 extracted executable will run as fast as a
81 printf "Version: %s\n" "$version"
116 printf '"--backups" requires a non-empty option argument.\n' >&2
128 printf '"--revert" requires a non-empty option argument.\n' >&2
139 --) # End of all options.
144 printf 'Unknown option %s\n' "$1" >&2
156 if [ ! -d "$HOME/bin" ]
158 printf "\$HOME/bin does not exist.
159 It is required for this script to run.\n"
164 cd "$HOME/bin/" || exit 1
166 if [ "$backups_option" -eq 1 ] && {
167 [ "$minimal" = "-minimal" ] || [ "$extract" -eq 1 ] || [ "$revert_option" -eq 1 ]
170 printf "backups must be the only option\n"
175 if [ "$desktop" -eq 1 ] && {
176 [ "$minimal" = "-minimal" ] || [ "$extract" -eq 1 ]
179 printf "desktop must be the only option\n"
184 if [ "$backups_option" -eq 1 ]
186 if ! [ "$backups" -gt 0 ] 2> /dev/null
188 printf "%s is not an integer\n" "$backups"
192 tmp_file=$(mktemp "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
194 sed --in-place "s/^backups=.*/backups=$backups/" "$tmp_file"
202 if [ "$desktop" -eq 1 ]
204 if [ -f "$HOME/Desktop/geeqie.desktop" ]
206 printf "Desktop file already exists\n"
211 file_count=$(find "$HOME/bin/" -name "Geeqie*latest*\.AppImage" -print | wc -l)
212 if [ "$file_count" -eq 0 ]
214 printf "No AppImages have been downloaded\n"
219 tmp_dir=$(mktemp --directory "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
220 cd "$tmp_dir" || exit 1
222 app=$(find "$HOME/bin/" -name "Geeqie*latest*\.AppImage" -print | sort --reverse | head -1)
223 $app --appimage-extract "usr/local/share/applications/geeqie.desktop"
224 $app --appimage-extract "usr/local/share/pixmaps/geeqie.png"
225 xdg-desktop-icon install --novendor "squashfs-root/usr/local/share/applications/geeqie.desktop"
226 xdg-icon-resource install --novendor --size 48 "squashfs-root/usr/local/share/pixmaps/geeqie.png"
227 xdg-desktop-menu install --novendor "squashfs-root/usr/local/share/applications/geeqie.desktop"
228 rm --recursive --force "$tmp_dir"
233 if [ "$revert_option" -eq 1 ]
235 if ! [ "$revert" -gt 0 ] 2> /dev/null
237 printf "%s is not an integer\n" "$revert"
241 if ! [ -f "$HOME/bin/Geeqie$minimal-latest-$architecture.AppImage.$revert" ]
243 printf "Backup $HOME/bin/Geeqie%s-latest-$architecture.AppImage.%s does not exist\n" "$minimal" "$revert"
248 if [ "$extract" -eq 1 ]
250 rm --recursive --force "Geeqie$minimal-latest-$architecture-AppImage"
251 mkdir "Geeqie$minimal-latest-$architecture-AppImage"
252 cd "Geeqie$minimal-latest-$architecture-AppImage" || exit 1
254 printf "Extracting AppImage\n"
255 ../"Geeqie$minimal-latest-$architecture.AppImage.$revert" --appimage-extract | cut --characters 1-50 | tr '\n' '\r'
256 printf "\nExtraction complete\n"
259 ln --symbolic --force "./Geeqie$minimal-latest-$architecture-AppImage/squashfs-root/AppRun" geeqie
261 ln --symbolic --force "$HOME/bin/Geeqie$minimal-latest-$architecture.AppImage.$revert" geeqie
268 log_file=$(mktemp "${TMPDIR:-/tmp}/geeqie.XXXXXXXXXX")
270 wget --no-verbose --show-progress --backups="$backups" --output-file="$log_file" --timestamping "https://github.com/BestImageViewer/geeqie/releases/download/continuous/Geeqie$minimal-latest-$architecture.AppImage"
272 download_size=$(stat --printf "%s" "$log_file")
275 # If a new file was downloaded, check if extraction is required
276 if [ "$download_size" -gt 0 ]
278 chmod +x "Geeqie$minimal-latest-$architecture.AppImage"
280 if [ "$extract" -eq 1 ]
282 rm --recursive --force "Geeqie$minimal-latest-$architecture-AppImage"
283 mkdir "Geeqie$minimal-latest-$architecture-AppImage"
284 cd "Geeqie$minimal-latest-$architecture-AppImage" || exit 1
286 printf "Extracting AppImage\n"
287 ../"Geeqie$minimal-latest-$architecture.AppImage" --appimage-extract | cut --characters 1-50 | tr '\n' '\r'
288 printf "\nExtraction complete\n"
291 ln --symbolic --force "./Geeqie$minimal-latest-$architecture-AppImage/squashfs-root/AppRun" geeqie
293 ln --symbolic --force "Geeqie$minimal-latest-$architecture.AppImage" geeqie