-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
build-bootstrap.sh
executable file
·63 lines (50 loc) · 1.98 KB
/
build-bootstrap.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
#!/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
. "$(dirname "$0")/build-config"
DISTRO="${1}"
if [[ "${TARGETABLE_DISTROS[@]}" =~ "${DISTRO}" ]]; then
true
else
echo "ERROR! Unknown version: ${DISTRO}"
exit 1
fi
R="${BUILDS_DIR}/Builds/obs-builder-${DISTRO}"
if [ ! -d "${R}" ]; then
DEBIAN_FRONTEND=noninteractive apt-get -y update
DEBIAN_FRONTEND=noninteractive apt-get -y install debootstrap systemd-container debian-archive-keyring ubuntu-keyring
if pidof apt-cacher-ng; then
REPO="http://localhost:3142/gb.archive.ubuntu.com/ubuntu/"
else
REPO="http://gb.archive.ubuntu.com/ubuntu/"
fi
debootstrap \
--components=main,restricted,universe,multiverse \
--exclude=ubuntu-minimal,ubuntu-advantage-tools \
--include=nano,systemd-container \
"${DISTRO}" "${R}" "${REPO}"
# Make sure the container has a machine-id
systemd-machine-id-setup --root "${R}" --print
echo "127.0.0.1 localhost ${DISTRO}" > "${R}/etc/hosts"
# Set locale to C.UTF-8 by default.
# https://git.launchpad.net/livecd-rootfs/tree/live-build/auto/build#n159
echo "LANG=C.UTF-8" > "${R}/etc/default/locale"
echo "
deb http://archive.ubuntu.com/ubuntu/ ${DISTRO} main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ ${DISTRO}-updates main restricted universe multiverse
deb http://archive.ubuntu.com/ubuntu/ ${DISTRO}-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu ${DISTRO}-security main restricted universe multiverse" > "${R}/etc/apt/sources.list"
else
echo "WARNING! ${R} already exists!"
echo " Updating OBS build scripts only."
fi
cp builder/* "${R}/root/"