This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 73
/
build-appimage.sh
136 lines (115 loc) · 3.31 KB
/
build-appimage.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/bin/bash
set -x
set -e
# do cleanup, even if errors occur
cleanup ()
{
# remove temp downloaded files and AppImage-build artifacts
rm -f linuxdeploy-x86_64.AppImage
rm -f appimagetool-x86_64.AppImage
rm -f $apprun_filepath
rm -f $desktop_filepath
rm -f $icon_filepath
}
trap cleanup EXIT
# variables
REPO_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
BUILD_DIR=release
APPDIR=$BUILD_DIR/AppDir
ID=org.curv3d.curv # software id
cd "$REPO_ROOT"
# remove AppDir from previous builds
rm -rf $APPDIR
# build project and install files into AppDir/usr
make -j$(nproc)
make install DESTDIR=AppDir
# rename usr/local -> usr/
cd $APPDIR/usr/local && mv * .. && cd .. && rmdir local
cd "$REPO_ROOT"
# patch absolute paths (make binary relocatable)
sed -i -e 's#/usr#././#g' $APPDIR/usr/bin/curv
# configure the dummy X server
if [[ -z "$DISPLAY" ]]; then
sudo apt update
sudo apt install xserver-xorg-video-dummy -y
dummy_xconf=dummy-1920x1080.conf
cat > $dummy_xconf << EOL
Section "Monitor"
Identifier "Monitor0"
HorizSync 28.0-80.0
VertRefresh 48.0-75.0
# https://arachnoid.com/modelines/
# 1920x1080 @ 60.00 Hz (GTF) hsync: 67.08 kHz; pclk: 172.80 MHz
Modeline "1920x1080_60.00" 172.80 1920 2040 2248 2576 1080 1081 1084 1118 -HSync +Vsync
EndSection
Section "Device"
Identifier "Card0"
Driver "dummy"
VideoRam 256000
EndSection
Section "Screen"
DefaultDepth 24
Identifier "Screen0"
Device "Card0"
Monitor "Monitor0"
SubSection "Display"
Depth 24
Modes "1920x1080_60.00"
EndSubSection
EndSection
EOL
sudo X -config $dummy_xconf &
export DISPLAY=:0
sleep 1
fi
# create AppImage's icons using curv
icon_filepath=$BUILD_DIR/curv.png
./$APPDIR/usr/bin/curv -o $icon_filepath -O xsize=512 -O ysize=512 icon.curv
# kill dummy X server
if [[ ! -z $dummy_xconf ]]; then
sudo kill $(pgrep X)
rm $dummy_xconf
fi
# create desktop entry for AppImage
desktop_filepath=$BUILD_DIR/$ID.desktop
cat > $desktop_filepath << EOL
[Desktop Entry]
Name=Curv
GenericName=2D/3D Graphics and Model Editor
Exec=curv -le %U
Type=Application
StartupNotify=true
Icon=curv
StartupWMClass=curv
Categories=Graphics
Terminal=true
Comment=Art creator app using mathematics
EOL
# create custom AppRun
apprun_filepath=$BUILD_DIR/AppRun
cat > $apprun_filepath << \EOL
#!/bin/bash
[[ -z "$APPDIR" ]] && export APPDIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" &> /dev/null && pwd)"
export PATH="$APPDIR/usr/bin:$PATH"
export LD_LIBRARY_PATH="$APPDIR/usr/lib/:$LD_LIBRARY_PATH"
export XDG_DATA_DIRS="$APPDIR/usr/share/:$XDG_DATA_DIRS"
curv $@
EOL
# add metainfo to AppDir
mkdir -p $APPDIR/usr/share/metainfo
cp metainfo.xml $APPDIR/usr/share/metainfo/$ID.appdata.xml
# now, build AppImage using linuxdeploy
# download linuxdeploy
wget https://github.com/linuxdeploy/linuxdeploy/releases/download/continuous/linuxdeploy-x86_64.AppImage
chmod +x linuxdeploy-x86_64.AppImage
# bundle shared libraries for curv to AppDir and build AppImage from AppDir
export UPDATE_INFORMATION="gh-releases-zsync|curv3d|curv|latest|Curv-*x86_64.AppImage.zsync"
./linuxdeploy-x86_64.AppImage \
--appdir=$APPDIR \
--custom-apprun=$apprun_filepath \
--desktop-file=$desktop_filepath \
--icon-file=$icon_filepath \
--output=appimage
# move built AppImage into release folder
mv Curv-*.AppImage $BUILD_DIR
mv Curv-*.AppImage.zsync $BUILD_DIR