Do not truncate socket path
[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 x86_64()
31 {
32         linuxdeploy-x86_64.AppImage \
33                 --appdir ./AppDir \
34                 --output appimage \
35                 --desktop-file ./AppDir/usr/share/applications/geeqie.desktop \
36                 --icon-file ./AppDir/usr/share/pixmaps/geeqie.png \
37                 --plugin gtk \
38                 --executable ./AppDir/usr/bin/geeqie
39 }
40
41 ## @FIXME arm AppImage of linuxdeploy does not yet exist
42 ## Compile from sources
43 aarch64()
44 {
45         linuxdeploy \
46                 --appdir ./AppDir \
47                 --output appimage \
48                 --desktop-file ./AppDir/usr/share/applications/geeqie.desktop \
49                 --icon-file ./AppDir/usr/share/pixmaps/geeqie.png \
50                 --plugin gtk \
51                 --executable ./AppDir/usr/bin/geeqie
52
53         appimagetool-aarch64.AppImage ./AppDir/ ./Geeqie-aarch64.AppImage
54 }
55
56 if [ ! -f geeqie.spec.in ] || [ ! -d .git ]
57 then
58         printf '%s\n' "This is not a Geeqie folder"
59         exit 1
60 fi
61
62 if ! target_dir=$(realpath "$1")
63 then
64         printf '%s\n' "No target dir specified"
65         exit 1
66 fi
67
68 rm -rf ./build-appimge
69 rm -rf "$target_dir"/AppDir
70 mkdir "$target_dir"/AppDir || {
71         printf '%s\n' "Cannot make $target_dir/AppDir"
72         exit 1
73 }
74
75 meson setup build-appimage
76 meson configure build-appimage -Dprefix="/usr/"
77 DESTDIR=/"$target_dir"/AppDir ninja -C build-appimage install
78
79 VERSION=$(git tag | tail -1)
80 export VERSION
81
82 cd "$target_dir" || {
83         printf '%s\n' "Cannot cd to $target_dir"
84         exit 1
85 }
86
87 case $(uname -m) in
88         "x86_64")
89                 x86_64
90
91                 new_version="$(./Geeqie-"$VERSION"-x86_64.AppImage -v | sed 's/git//' | sed 's/-.* /-/' | sed 's/ /-v/' | sed 's/-GTK3//')-x86_64.AppImage"
92                 mv "./Geeqie-$VERSION-x86_64.AppImage" "$new_version"
93                 gpg --armor --detach-sign --output "$new_version.asc" "$new_version"
94                 ;;
95
96         "aarch64")
97                 aarch64
98
99                 new_version="$(./Geeqie-aarch64.AppImage -v | sed 's/git//' | sed 's/-.* /-/' | sed 's/ /-v/' | sed 's/-GTK3//')-aarch64.AppImage"
100                 mv "./Geeqie-aarch64.AppImage" "$new_version"
101                 gpg --armor --detach-sign --output "$new_version.asc" "$new_version"
102                 ;;
103
104         *)
105                 printf "Architecture unknown"
106                 ;;
107 esac