-
Notifications
You must be signed in to change notification settings - Fork 3
/
fp-build.sh
94 lines (84 loc) · 2.98 KB
/
fp-build.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
#!/usr/bin/env sh
#
# Copyright © 2021 Lionir
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation;
# version 2.1 of the License.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library. If not, see <https://www.gnu.org/licenses/>.
#
if ! [ -f "$1" ]
then
echo "$1 doesn't exist" >&2
exit
fi
XDG_CACHE_HOME="${XDG_CACHE_HOME:-$HOME/.cache}"
if ! flatpak-builder \
--download-only --no-shallow-clone \
--force-clean --allow-missing-runtimes \
--ccache \
--state-dir="$XDG_CACHE_HOME/flatpak-builder" \
"$XDG_CACHE_HOME/flatpak-builder-builddir/${1%.*}" "$1"
then
echo "Download failed!" >&2
exit 1
fi
if ! flatpak-builder \
--verbose --sandbox --user \
--bundle-sources --force-clean --ccache \
--install-deps-from=flathub \
--default-branch=localtest \
--state-dir="$XDG_CACHE_HOME/flatpak-builder" \
--extra-sources="$XDG_CACHE_HOME/flatpak-builder/downloads" \
"$XDG_CACHE_HOME/flatpak-builder-builddir/${1%.*}" "$1"
then
echo "Build failed!" >&2
exit 1
fi
if ! flatpak-builder \
--user --install --force-clean \
--repo="$XDG_CACHE_HOME/flatpak-builder-repo/" \
--default-branch=localtest \
--state-dir="$XDG_CACHE_HOME/flatpak-builder" \
"$XDG_CACHE_HOME/flatpak-builder-builddir/${1%.*}" "$1"
then
echo "Committing or install failed" >&2
exit 1
fi
flathub_json=$(dirname "$1")/flathub.json
if zgrep -q "<id>${1%.*}\(\.\w\+\)*\(.desktop\)\?</id>" "$XDG_CACHE_HOME/flatpak-builder-builddir/${1%.*}/files/share/app-info/xmls/${1%.*}.xml.gz"
then
echo "---"
echo "AppID check.. passed!"
else
echo "---"
echo "AppID check.. failed!" >&2
fi
if [ -e "$flathub_json" ] && python3 -c 'import sys, json; sys.exit(not json.load(sys.stdin).get("skip-icons-check", False))' < "$flathub_json"
then
echo "Skipping icon check.."
else
if zgrep "<icon type=\\'remote\\'>" "$XDG_CACHE_HOME/flatpak-builder-builddir/${1%.*}/files/share/app-info/xmls/${1%.*}.xml.gz" || test -f "$XDG_CACHE_HOME/flatpak-builder-builddir/${1%.*}/files/share/app-info/icons/flatpak/128x128/${1%.*}.png"
then
echo "128x128 icon check.. passed!"
else
echo "128x128 icon check.. failed!" >&2
fi
fi
if [ -e "$flathub_json" ] && python3 -c 'import sys, json; sys.exit(not json.load(sys.stdin).get("skip-appstream-check", False))' < "$flathub_json"
then
echo "Skipping Appstream check"
echo "---"
else
echo "Appstream check"
flatpak run org.freedesktop.appstream-glib validate "$XDG_CACHE_HOME/flatpak-builder-builddir/${1%.*}/files/share/appdata/${1%.*}.appdata.xml"
echo "---"
fi