-
Notifications
You must be signed in to change notification settings - Fork 10
/
build.sh
executable file
·132 lines (116 loc) · 3.73 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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#!/bin/bash
# error codes
# 2 Invalid base image
# 3 Invalid build_mode parameter
# 4 Invalid proxy parameter
declare -A base_images
base_images[sid]=debian:sid-slim
base_images[stable]=debian:stable-slim
base_images[unstable]=debian:unstable-slim
base_images[trixie]=debian:trixie-slim
base_images[bookworm]=debian:bookworm-slim
base_images[bullseye]=debian:bullseye-slim
base_images[buster]=debian:buster-slim
base_images[trusty]=ubuntu:trusty
base_images[xenial]=ubuntu:xenial
base_images[bionic]=ubuntu:bionic
base_images[focal]=ubuntu:focal
base_images[jammy]=ubuntu:jammy
base_images[kinetic]=ubuntu:kinetic
base_images[lunar]=ubuntu:lunar
base_images[mantic]=ubuntu:mantic
base_images[rolling]=ubuntu:rolling
base_images[debian:sid]=debian:sid-slim
base_images[debian:stable]=debian:stable-slim
base_images[debian:unstable]=debian:unstable-slim
base_images[debian:trixie]=debian:trixie-slim
base_images[debian:bookworm]=debian:bookworm-slim
base_images[debian:bullseye]=debian:bullseye-slim
base_images[debian:buster]=debian:buster-slim
base_images[ubuntu:trusty]=ubuntu:trusty
base_images[ubuntu:xenial]=ubuntu:xenial
base_images[ubuntu:bionic]=ubuntu:bionic
base_images[ubuntu:focal]=ubuntu:focal
base_images[ubuntu:jammy]=ubuntu:jammy
base_images[ubuntu:kinetic]=ubuntu:kinetic
base_images[ubuntu:lunar]=ubuntu:lunar
base_images[ubuntu:mantic]=ubuntu:mantic
base_images[ubuntu:rolling]=ubuntu:rolling
DEFAULT_BASE_IMAGE=stable
DEFAULT_BUILD_MODE=std
DEFAULT_TAG=local
DEFAULT_USE_PROXY=N
build_mode=$DEFAULT_BUILD_MODE
tag=$DEFAULT_TAG
while getopts b:d:t:p:m:f: flag
do
case "${flag}" in
b) base_image=${OPTARG};;
d) build_mode=${OPTARG};;
t) tag=${OPTARG};;
p) proxy=${OPTARG};;
m) binary_mode=${OPTARG};;
f) force_arch=${OPTARG};;
esac
done
echo "Input: Base Image = [$base_image]";
echo "Input: Build Mode = [$build_mode]";
echo "Input: Download from SourceForge = [$d]";
echo "Input: Force Architecture = [$force_arch]";
echo "Input: Image Tag = [$tag]";
echo "Input: Proxy = [$proxy]";
echo "Input: Binary mode = [$binary_mode]";
if [ -z "${base_image}" ]; then
base_image=$DEFAULT_BASE_IMAGE
fi
expanded_base_image=${base_images[$base_image]}
if [ -z "${expanded_base_image}" ]; then
echo "invalid base image ["${base_image}"]"
exit 2
fi
if [ -z "${build_mode}" ]; then
build_mode="std"
fi
if [[ "${build_mode}" == "sf" ]]; then
build_mode="sf"
elif [[ "${build_mode}" == "std" ]]; then
build_mode="std"
elif [[ "${build_mode}" == "r2" ]]; then
build_mode="r2"
else
echo "invalid build_mode parameter ["${build_mode}"]"
exit 3
fi
if [ -z "${proxy}" ]; then
proxy="N"
fi
if [[ "${proxy^^}" == "Y" || "${proxy^^}" == "YES" ]]; then
proxy="Y"
elif [[ "${proxy^^}" == "N" || "${proxy^^}" == "NO" ]]; then
proxy="N"
else
echo "invalid proxy parameter ["${proxy}"]"
exit 4
fi
if [[ -z "${binary_mode}" ]]; then
binary_mode=full
else
if [[ ! "${binary_mode}" == "alsa" ]] && [[ ! "${binary_mode}" == "pulse" ]] && [[ ! "${binary_mode}" == "full" ]] && [[ ! "${binary_mode}" == "alsa-bt" ]]; then
echo "invalid binary_mode parameter ["${binary_mode}"]"
exit 4
fi
fi
echo "Build Argument: Base Image = ["$expanded_base_image"]"
echo "Build Argument: Download from SourceForge = ["$build_mode"]"
echo "Build Argument: Force Architecture = [$force_arch]";
echo "Build Argument: Image Tag = ["$tag"]"
echo "Build Argument: Binary Mode = ["$binary_mode"]"
echo "Build Argument: Proxy = ["$proxy"]"
docker build . \
--build-arg BASE_IMAGE=${expanded_base_image} \
--build-arg BUILD_MODE=${build_mode} \
--build-arg BINARY_MODE=${binary_mode} \
--build-arg FORCE_ARCH=${force_arch} \
--build-arg USE_APT_PROXY=${proxy} \
-t giof71/squeezelite:$tag \
--progress=plain