forked from jellyfin/jellyfin-androidtv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.sh
executable file
·52 lines (43 loc) · 1.38 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
#!/usr/bin/env bash
# Build APKs using a reproducible Docker container
set -o errexit
dockerfile="Dockerfile"
image_name="jellyfin-androidtv-apkbuild"
# Initialize the submodules
git submodule update --init
usage() {
echo -e "Usage:"
echo -e " $0 [-r/--release <release>]"
echo -e "The release defaults to a minified 'production' build; specify 'debug' for a debug release."
exit 1
}
# Handle the release argument
if [[ ${1} == '--release' || ${1} == '-r' ]]; then
if [[ -n ${2} ]]; then
release="${2}"
shift 2
else
usage
fi
else
release="production"
fi
set -o xtrace
package_temporary_dir="$( mktemp -d )"
current_user="$( whoami )"
# Trap cleanup for latter sections
cleanup() {
# Remove tempdir
rm -rf "${package_temporary_dir}"
}
trap cleanup EXIT INT
# Set up the build environment docker image
docker build . -t "${image_name}" -f ./${dockerfile}
# Build the APKs and copy out to ${package_temporary_dir}
docker run --rm -e "RELEASE=${release}" -v "${package_temporary_dir}:/dist" "${image_name}"
# Correct ownership on the APKs (as current user, then as root if that fails)
chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null \
|| sudo chown -R "${current_user}" "${package_temporary_dir}" &>/dev/null
# Move the APKs to the parent directory
mkdir -p ../bin &>/dev/null
mv "${package_temporary_dir}"/apk/*.apk ../bin