forked from jellyfin-archive/jellyfin-android-original
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·65 lines (56 loc) · 1.87 KB
/
build
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
#!/usr/bin/env bash
# Build APKs using a reproducible Docker container
set -o errexit
dockerfile="Dockerfile"
image_name="jellyfin-android-apkbuild"
usage() {
echo -e "Usage:"
echo -e " $0 [-r/--release <release>] [-b/--web-branch <web_branch>]"
echo -e "The release defaults to a minified 'production' build; specify 'unminified' or 'debug' for alternate releases."
echo -e "The web branch defaults to 'origin/master'; specify any valid tag or branch for the 'jellyfin-web' repository."
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
# Check out the proper jellyfin-web branch or update submodule
if [[ ${1} == '--web-branch' || ${1} == '-b' ]]; then
if [[ -n ${2} ]]; then
pushd src/jellyfin-web
git fetch --all
git checkout ${2} || usage
popd
shift 2
else
usage
fi
else
# Initialize the submodule jellyfin-web with the most branch master
git submodule update --init --remote
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
mv "${package_temporary_dir}"/apk/*.apk ../