Run shellcheck on script files
[geeqie.git] / scripts / generate-linuxdeploy-for-arm.sh
1 #!/bin/sh
2
3 #**********************************************************************
4 # Copyright (C) 2022 - The Geeqie Team
5 #
6 # Author: Colin Clark
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License along
19 # with this program; if not, write to the Free Software Foundation, Inc.,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #**********************************************************************
22 ## @file
23 ## @brief Compile linuxdeploy for use on arm
24 ##  
25 ## There is no AppImage for linuxdeploy on arm. It must be compiled
26 ## from sources.
27 ##
28 ## This is just a hack until AppImages are available on github.
29 ##
30
31 set -x
32
33 arch=$(uname -m)
34 if [ "$arch" != "aarch64" ]
35 then
36         exit
37 fi
38
39 sudo apt install libfuse2
40 sudo apt install libgirepository1.0-dev
41
42 rm -rf /tmp/linuxdeploy-*
43
44 cd "$HOME" || exit
45 if [ ! -d bin ]
46 then
47         mkdir bin
48 fi
49
50 cd "$HOME"/bin || exit
51
52 if [ ! -f appimagetool-aarch64.AppImage ]
53 then
54         wget https://github.com/AppImage/AppImageKit/releases/download/continuous/appimagetool-aarch64.AppImage
55         chmod +x appimagetool-aarch64.AppImage
56 fi
57
58 if [ ! -f linuxdeploy-plugin.sh ]
59 then
60         wget https://raw.githubusercontent.com/linuxdeploy/linuxdeploy-plugin-gtk/master/linuxdeploy-plugin-gtk.sh
61         chmod +x linuxdeploy-plugin-gtk.sh
62 fi
63
64 if [ ! -d linuxdeploy-download ]
65 then
66         git clone --recursive https://github.com/linuxdeploy/linuxdeploy.git
67         mv linuxdeploy linuxdeploy-download
68 fi
69
70 cd linuxdeploy-download || exit
71
72 # Use arm architecture
73 sed -i 's/"x86_64"/"aarch64"/g' ./ci/build.sh
74 sed -i 's/"x86_64"/"aarch64"/g' ./ci/build-static-binutils.sh
75 sed -i 's/"x86_64"/"aarch64"/g' ./ci/build-static-patchelf.sh
76
77 # Always use /tmp
78 sed -i 's/TEMP_BASE=\/dev\/shm/TEMP_BASE=\/tmp/' ./ci/build.sh
79
80 # Do not erase working directory
81 sed -i 's/trap cleanup EXIT//' ./ci/build.sh
82
83 # Fix possible error in current (2022-12-13) version
84 sed -i 's/\/\/ system headers/#include <array>/' ./src/subprocess/subprocess.cpp
85 sed -i 's/\/\/ system headers/#include <array>/' ./src/plugin/plugin_process_handler.cpp
86
87 # No downloads
88 sed -i 's/wget/\#/g' ./ci/build.sh
89
90 # No exit on fail
91 sed -i 's/set\ \-e/\#/' .ci/build.sh
92
93 cp src/core/copyright/copyright.h src/core
94
95 cd ..
96
97 ARCH=aarch64 bash linuxdeploy-download/ci/build.sh
98
99 find /tmp/linuxdeploy-build* -type f -name linuxdeploy -exec cp {} "$HOME"/bin/ \;
100 find /tmp/linuxdeploy-build* -type f -name patchelf -exec cp {} "$HOME"/bin \;
101
102 if [ ! -d linuxdeploy-plugin-appimage ]
103 then
104         git clone --recursive https://github.com/linuxdeploy/linuxdeploy-plugin-appimage.git
105 fi
106
107 cd linuxdeploy-plugin-appimage || exit
108
109 # Always use /tmp
110 sed -i 's/TEMP_BASE=\/dev\/shm/TEMP_BASE=\/tmp/' ./ci/build-appimage.sh
111
112 # Do not erase working directory
113 sed -i 's/trap cleanup EXIT//' ./ci/build-appimage.sh
114
115 # Use arm architecture
116 sed -i 's/"x86_64"/"aarch64"/g' ./ci/build-appimage.sh
117
118 # No downloads
119 sed -i 's/wget/\#/g' ./ci/build-appimage.sh
120
121 # No exit on fail
122 sed -i 's/set\ \-e/\#/' ./ci/build-appimage.sh
123
124 cd ..
125
126 ARCH=aarch64 bash linuxdeploy-plugin-appimage/ci/build-appimage.sh
127
128