-
-
Notifications
You must be signed in to change notification settings - Fork 11
/
build-enter.sh
executable file
·55 lines (45 loc) · 1.32 KB
/
build-enter.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
#!/usr/bin/env bash
if [ -z "${SUDO_USER}" ]; then
echo "ERROR! You must use sudo to run this script: sudo ./$(basename "${0}")"
exit 1
else
BUILDS_DIR="$(getent passwd "${SUDO_USER}" | cut -d: -f6)"
fi
BUILDS_DIR="${OVERRIDE_BUILDS_DIR:-$BUILDS_DIR}"
if [ -z "${1}" ]; then
echo "Usage: $(basename "${0}") <codename>"
exit 1
fi
DISTRO="${1}"
if [ -n "${2}" ]; then
CMD="${2}"
OPT="${3}"
else
CMD="/bin/bash"
OPT=""
fi
. "$(dirname "$0")/build-config"
if [[ "${TARGETABLE_DISTROS[@]}" =~ "${DISTRO}" ]]; then
true
else
echo "ERROR! Unknown version: ${DISTRO}"
exit 1
fi
R="${BUILDS_DIR}/Builds/obs-builder-${DISTRO}"
APT_CACHE_IP=$(ip route get 1.1.1.1 | head -n 1 | cut -d' ' -f 7)
if pidof -q apt-cacher-ng && [ -d "${R}/etc/apt/apt.conf.d" ]; then
echo "Acquire::http { Proxy \"http://${APT_CACHE_IP}:3142\"; }" > "${R}/etc/apt/apt.conf.d/90cache"
fi
echo "nameserver 1.1.1.1" > "/tmp/resolv-${DISTRO}.conf"
echo "nameserver 1.0.0.1" >> "/tmp/resolv-${DISTRO}.conf"
systemd-nspawn \
--bind-ro="/tmp/resolv-${DISTRO}.conf":/etc/resolv.conf \
--chdir=/root \
--directory="${R}" \
--hostname="${DISTRO}" \
--machine="${DISTRO}" \
--resolv-conf=off \
${CMD} ${OPT}
if [ -e "${R}/etc/apt/apt.conf.d/90cache" ]; then
rm -f "${R}/etc/apt/apt.conf.d/90cache"
fi