forked from scottyhardy/docker-wine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build
executable file
·46 lines (38 loc) · 1.39 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
#!/usr/bin/env bash
get_hrefs () {
local url="$1"
local regexp="$2"
local download_cmd
if command -v wget >/dev/null 2>&1; then
download_cmd="wget -q -O-"
elif command -v curl >/dev/null 2>&1; then
download_cmd="curl -s -o-"
else
echo "ERROR: Neither wget or curl is available, unable to perform download"
exit 1
fi
$download_cmd "${url}" | sed -E "s/></>\n</g" | sed -n -E "s|^.*<a href=\"(${regexp})\">.*|\1|p" | uniq
}
BUILD_ARGS=("$@")
BUILD_CMD="docker build"
DOCKER_REPO="${DOCKER_REPO:-docker-wine}"
URL="https://dl.winehq.org/wine-builds/ubuntu/dists/"
# Get the latest Ubuntu version codename that Wine is available on
UBUNTU_CODENAME=$(get_hrefs "${URL}" "[^:]+/" | sed -E "s|/$||" | grep -v -E "^([p-z]|/)" | sort -r | head -1)
# Just use latest tag if unable to be determined
if [ -n "${UBUNTU_CODENAME}" ]; then
echo "Found Wine is available on Ubuntu ${UBUNTU_CODENAME}"
TAG="ubuntu-${UBUNTU_CODENAME}"
else
echo "WARNING: Unable to determine version of Ubuntu to use with Wine, so using latest"
TAG="latest"
fi
if ! docker system info >/dev/null 2>&1; then
if buildah -v >/dev/null 2>&1; then
BUILD_CMD="buildah bud"
else
echo "ERROR: Docker is not running or not installed, unable to proceed"
exit 1
fi
fi
${BUILD_CMD} "${BUILD_ARGS[@]}" --build-arg="TAG=${TAG}" -t "${DOCKER_REPO}" .