-
Notifications
You must be signed in to change notification settings - Fork 0
/
build-flatpak.sh
executable file
·105 lines (84 loc) · 3.11 KB
/
build-flatpak.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
#!/bin/bash
# creates a custom JRE and self-contained launcher for application using AppImage
set -ex
echo
echo "--- building Flatpak ---"
if ! command -v flatpak > /dev/null; then
echo "flatpak not found, cannot continue"
exit 1
fi
if ! command -v flatpak-builder > /dev/null; then
echo "flatpak-builder not found, cannot continue"
exit 1
fi
# ---
ARCH=x86_64
output_dir="flatpak"
#rm -rf "./strongbox/target"
#rm -rf "./strongbox"
rm -rf "./$output_dir"
mkdir -p "./$output_dir"
# 'lein clean' may delete jar files within ./target, but preserve ./target dir
if [ ! -e strongbox/target/*-standalone.jar ]; then
echo "--- building uberjar ---"
git clone https://github.com/ogri-la/strongbox
(
cd strongbox
lein clean
rm -f resources/full-catalogue.json
wget https://raw.githubusercontent.com/ogri-la/strongbox-catalogue/master/full-catalogue.json \
--quiet \
--directory-prefix resources
lein uberjar
)
fi
cp ./strongbox/target/*-standalone.jar "$output_dir/app.jar"
# ---
echo "--- adding Flathub remote"
flatpak --user remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
echo "--- installing Flatpak runtime"
flatpak install \
--assumeyes \
--arch "$ARCH" \
--user \
flathub \
org.freedesktop.Platform//23.08 \
org.freedesktop.Sdk//23.08 \
org.freedesktop.Sdk.Extension.openjdk11//23.08
cp la.ogri.strongbox.yml metainfo.xml strongbox.svg strongbox.desktop "$output_dir/"
(
cd "$output_dir"
build_dir=".flatpak" # flatpak/.flatpak
appid="la.ogri.strongbox"
manifest="$appid.yml"
tag="master"
output_filename="strongbox.flatpak"
if [ ! -f "$manifest" ]; then
echo "manifest not found, cannot continue"
exit 1
fi
echo "--- building"
# export flatpak to local repo
# --user Install dependencies in user installations
# --repo=DIR Repo to export into
# --force-clean Erase previous contents of DIRECTORY
# --keep-build-dirs Don't remove build directories after install
# --disable-download Don't download any new sources
flatpak-builder --user --repo ./repo --force-clean --keep-build-dirs --disable-download "$build_dir" "$manifest"
#echo "--- linting"
#flatpak remote-add --if-not-exists --user flathub https://dl.flathub.org/repo/flathub.flatpakrepo
#flatpak install --user --noninteractive flathub org.flatpak.Builder
#flatpak run --command=flatpak-builder-lint org.flatpak.Builder --exceptions manifest la.ogri.strongbox.yml
echo "--- installing"
flatpak install --user --reinstall --assumeyes ./repo "$appid"
# create a standalone .flatpak 'bundle' file. requires a repo.
#flatpak build-bundle ./repo "$output_filename" "$appid" "$tag"
# uninstall/install
#flatpak --user list # list installed
#flatpak uninstall --user --noninteractive "$appid"
#flatpak install --user --reinstall --noninteractive "$output_filename"
)
echo
echo "--- cleaning up ---"
echo
echo "done."