bfb4782867f40f70a5ed11f530e7a70cf9d53f7f
[geeqie.git] / scripts / generate-appimage.sh
1 #! /bin/sh
2 #**********************************************************************
3 # Copyright (C) 2022 - The Geeqie Team
4 #
5 # Author: Colin Clark
6 #
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.
11 #
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.
16 #
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 #**********************************************************************
21
22 ## @file
23 ## @brief Generate a Geeqie AppImage.
24 ##
25 ## It must be run from the base Geeqie folder.  
26 ## The single parameter is the directory where the AppDir
27 ## will be created.
28 ##
29
30 if [ ! -f geeqie.spec.in ] || [ ! -d .git ]
31 then
32         printf '%s\n' "This is not a Geeqie folder"
33         exit 1
34 fi
35
36 if ! target_dir=$(realpath "$1");
37 then
38         printf '%s\n' "No target dir specified"
39         exit 1
40 fi
41
42 rm -rf ./build-appimge
43 rm -rf "$target_dir"/AppDir
44 mkdir "$target_dir"/AppDir || { printf '%s\n' "Cannot make $target_dir/AppDir"; exit 1; }
45
46 meson setup build-appimage
47 meson configure build-appimage -Dprefix="/usr/"
48 DESTDIR=/"$target_dir"/AppDir ninja -C build-appimage install
49
50 VERSION=$(git tag | tail -1)
51 export VERSION
52
53 cd "$target_dir" || { printf '%s\n' "Cannot cd to $target_dir"; exit 1; }
54
55 linuxdeploy-x86_64.AppImage \
56         --appdir ./AppDir --output appimage \
57         --desktop-file ./AppDir/usr/share/applications/geeqie.desktop \
58         --icon-file ./AppDir/usr/share/pixmaps/geeqie.png \
59         --plugin gtk \
60         --executable ./AppDir/usr/bin/geeqie
61
62 mv "./Geeqie-$VERSION-x86_64.AppImage" "$(./Geeqie-"$VERSION"-x86_64.AppImage -v | sed 's/git//' | sed 's/-.* /-/' | sed 's/ /-v/' | sed 's/-GTK3//').AppImage"