File: create-testbed

package info (click to toggle)
debci 3.13
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 1,656 kB
  • sloc: ruby: 6,516; sh: 2,437; javascript: 100; makefile: 92; perl: 11
file content (75 lines) | stat: -rwxr-xr-x 1,973 bytes parent folder | download | duplicates (2)
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
#!/bin/sh

set -eu

base=$(readlink -f "$(dirname "$(readlink -f "$0")")/../..")
. "$base/lib/environment.sh"

if [ "$(whoami)" != root ]; then
  echo "E: This script must be run as root"
  exit 1
fi

# fail right away if lxc is not installed
if ! which lxc-create >/dev/null; then
  echo "E: lxc is not installed"
  exit 1
fi

# determine whether it's Debian or Ubuntu
script="/usr/share/debootstrap/scripts/${debci_suite:?}"
if [ -r "$script" ]; then
  if grep -q ubuntu.com "$script"; then
    distro=ubuntu
  elif grep -q kali.org "$script"; then
    distro=kali
  else
    distro=debian
  fi
else
  echo "ERROR: $script does not exist; debootstrap is not installed, or $debci_suite is an unknown suite" >&2
  exit 1
fi

sources_list=$(mktemp --tmpdir "debci-lxc-customize-${debci_suite}-XXXXXXXXXXX.list")
script=$(mktemp --tmpdir "debci-lxc-customize-${debci_suite}-XXXXXXXXXXX.sh")
trap 'rm -rf "$sources_list" "$script"' INT TERM EXIT
if [ "$distro" = debian ]; then
  dbgsym=
  test -z "${debci_keyring:-}" && dbgsym=--dbgsym
  debci-generate-apt-sources \
    --source \
    $dbgsym \
    -- \
    "$debci_suite" > "$sources_list"
  export AUTOPKGTEST_APT_SOURCES_FILE="$sources_list"
fi
# configure guest proxy
if [ -n "${GUEST_PROXY:-}" ]; then
  echo "echo \"Acquire::http::Proxy \\\"$GUEST_PROXY\\\" ;\" > /etc/apt/apt.conf.d/70proxy" >> "$script"
else
  cat >> "$script" <<EOF
if apt-cache show auto-apt-proxy >/dev/null 2>&1; then
  DEBIAN_FRONTEND=noninteractive \
    apt-get install auto-apt-proxy -q -y --no-install-recommends
fi
EOF
fi
cat >> "$script" <<EOF
DEBIAN_FRONTEND=noninteractive \
  apt-get install dpkg-dev ca-certificates -q -y --no-install-recommends

DEBIAN_FRONTEND=noninteractive \
  apt-get clean

useradd \
  --home-dir /home/debci \
  --create-home \
  debci
EOF

set -- "$distro" "$debci_suite" "${debci_arch:?}" "$script"
if [ -n "${debci_keyring:-}" ]; then
  set -- --keyring "$debci_keyring" "$@"
fi
autopkgtest-build-lxc "$@"