-
Notifications
You must be signed in to change notification settings - Fork 6
/
make-appimage.sh
executable file
·98 lines (72 loc) · 1.92 KB
/
make-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
#!/usr/bin/env bash
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
pushd $SCRIPT_DIR
#
# Build Project
#
BUILD_DIR="target"
BIN="$BUILD_DIR/release/logicrs"
cargo build --release
if [ ! -f $BIN ]; then
echo "Release build was not successful."
exit 1
fi
#
# Create AppDir
#
APP_DIR="$BUILD_DIR/appimage/logicrs.AppDir"
if [ -d $APP_DIR ]; then
rm -rf $APP_DIR
fi
mkdir -p $APP_DIR/usr/{bin,lib,share/icons}
cp $BIN $APP_DIR/usr/bin/logicrs
# Copy binary
sed -i -e 's#/usr#././#g' $APP_DIR/usr/bin/logicrs
# Collect libraries
mkdir -p $APP_DIR/usr/lib
LIB_PATH="/usr/lib64"
IFS=' ' read -ra LIBRARIES <<< $(pkg-config --libs gtk4 libadwaita-1)
for i in "${LIBRARIES[@]}"; do
LIB_FILE="lib${i:2}.so"
if [ ! -f $LIB_PATH/$LIB_FILE ]; then
echo "could not find \`$LIB_FILE\` in \`$LIB_PATH\`"
fi
cp $LIB_PATH/$LIB_FILE $APP_DIR/usr/lib/$LIB_FILE
done
# Patch binaries
pushd $APP_DIR/usr/lib
find . -type f -exec sed -i -e 's#/usr#././#g' {} \;
popd
#
# Generate Icons
#
DIR_ICON=".DirIcon"
RELEASE_ICON_FILE="style/icons/hicolor/com.spydr06.logicrs.svg"
DEBUG_ICON_FILE="style/icons/hicolor/com.spydr06.logicrs.Devel.svg"
ICON_FILE=$DEBUG_ICON_FILE
inkscape -z -w 256 -h 256 "$ICON_FILE" -o $APP_DIR/$DIR_ICON.png
if [ ! -f $APP_DIR/$DIR_ICON.png ]; then
echo "Icon generation was not successful."
exit 1
fi
mv $APP_DIR/$DIR_ICON.png $APP_DIR/$DIR_ICON
cp $ICON_FILE $APP_DIR/logicrs.svg
ICONS_DIR=$APP_DIR/usr/share/icons
mkdir -p $ICONS_DIR
cp $ICON_FILE $ICONS_DIR/logicrs.svg
SNIPPETS_DIR="snippets"
#
# Prepare AppDir
#
# Copy desktop file
DESKTOP_FILE="com.spydr06.logicrs.desktop"
cp $SNIPPETS_DIR/$DESKTOP_FILE $APP_DIR/$DESKTOP_FILE
# Create build directory
BUILD_DIR="target/appimage"
mkdir -p $BUILD_DIR
#
# Generate AppImage
#
RECIPE_FILE="$SNIPPETS_DIR/AppImageBuilder.yml"
appimage-builder --recipe $RECIPE_FILE --appdir $APP_DIR --build-dir $BUILD_DIR
popd