forked from dankamongmen/GreenWithEnvy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·96 lines (87 loc) · 2.81 KB
/
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
94
95
96
#!/bin/bash
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case ${key} in
-fl|--flatpak-local)
FLATPAK_LOCAL=1
shift # past argument
;;
-fr|--flatpak-remote)
FLATPAK_REMOTE=1
shift # past argument
;;
-fi|--flatpak-install)
FLATPAK_INSTALL=1
shift # past argument
;;
-fb|--flatpak-bundle)
FLATPAK_BUNDLE=1
shift # past argument
;;
*) # unknown option
POSITIONAL+=("$1") # save it in an array for later
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
APP_ID="com.leinardi.gwe"
BUILD_DIR="build"
OUTPUT_DIR="${BUILD_DIR}/output"
MESON_BUILD_DIR="${BUILD_DIR}/meson"
FLATPAK_BUILD_DIR="${BUILD_DIR}/flatpak/build"
FLATPAK_REPO_DIR="${BUILD_DIR}/flatpak/repo"
FLATPAK_INSTALL_PARAMETERS="--user --install"
FLATPAK_REMOTE_MANIFEST="flatpak/${APP_ID}.json"
FLATPAK_LOCAL_MANIFEST="build/flatpak/${APP_ID}.json"
FLATPAK_OUTPUT_FILE="${OUTPUT_DIR}/${APP_ID}.flatpak"
INSTALL_DIR="${OUTPUT_DIR}/install"
function build_flatpak {
mkdir -p ${FLATPAK_REPO_DIR} && \
mkdir -p ${FLATPAK_BUILD_DIR} && \
time flatpak-builder --force-clean $2 --install-deps-from=flathub --repo=${FLATPAK_REPO_DIR} ${FLATPAK_BUILD_DIR} $1 && \
desktop-file-validate build/flatpak/build/files/share/applications/com.leinardi.gwe.desktop || exit $?
}
function build_flatpak_bundle {
mkdir -p ${OUTPUT_DIR} && \
time flatpak build-bundle ${FLATPAK_REPO_DIR} ${FLATPAK_OUTPUT_FILE} ${APP_ID} || exit $?
}
if [[ ${#POSITIONAL[@]} -ne 0 ]]; then
echo "Unknown option ${POSITIONAL}"
exit 1
fi
appstream-util validate-relax data/com.leinardi.gwe.appdata.xml || exit $?
appstream-util appdata-to-news data/com.leinardi.gwe.appdata.xml | sed '/^~*$/s/~/=/g' > CHANGELOG.md
[[ -d ${OUTPUT_DIR} ]] && rm -rfv ${OUTPUT_DIR}
find . -regex '^.*\(__pycache__\|\.py[co]\)$' -delete
if [[ ${FLATPAK_REMOTE} -eq 1 ]]; then
if [[ ${FLATPAK_INSTALL} -eq 1 ]]; then
build_flatpak "${FLATPAK_REMOTE_MANIFEST}" "${FLATPAK_INSTALL_PARAMETERS}"
else
build_flatpak ${FLATPAK_REMOTE_MANIFEST}
fi
if [[ ${FLATPAK_BUNDLE} -eq 1 ]]; then
build_flatpak_bundle
fi
elif [[ ${FLATPAK_LOCAL} -eq 1 ]]; then
scripts/make_local_manifest.py ${FLATPAK_REMOTE_MANIFEST} ${FLATPAK_LOCAL_MANIFEST}
if [[ ${FLATPAK_INSTALL} -eq 1 ]]; then
build_flatpak "${FLATPAK_LOCAL_MANIFEST}" "${FLATPAK_INSTALL_PARAMETERS}"
else
build_flatpak ${FLATPAK_LOCAL_MANIFEST}
fi
if [[ ${FLATPAK_BUNDLE} -eq 1 ]]; then
build_flatpak_bundle
fi
elif [[ ${FLATPAK_BUNDLE} -eq 1 ]]; then
build_flatpak_bundle
else
[[ -d ${MESON_BUILD_DIR} ]] && rm -rfv ${MESON_BUILD_DIR}
mkdir -pv ${MESON_BUILD_DIR} ${INSTALL_DIR} && \
meson . ${MESON_BUILD_DIR} --prefix=$PWD/${INSTALL_DIR} && \
ninja -v -C ${MESON_BUILD_DIR} && \
desktop-file-validate build/meson/data/com.leinardi.gwe.desktop && \
ninja -v -C ${MESON_BUILD_DIR} install
fi