~smoser/curtin/trunk.bzr-dead

« back to all changes in this revision

Viewing changes to tools/vmtest-system-setup

  • Committer: Scott Moser
  • Date: 2017-12-20 17:33:03 UTC
  • Revision ID: smoser@ubuntu.com-20171220173303-29gha5qb8wpqrd40
README: Mention move of revision control to git.

curtin development has moved its revision control to git.
It is available at
  https://code.launchpad.net/curtin

Clone with
  git clone https://git.launchpad.net/curtin
or
  git clone git+ssh://git.launchpad.net/curtin

For more information see
  http://curtin.readthedocs.io/en/latest/topics/development.html

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/bin/bash
2
 
 
3
 
_APT_UPDATED=false
4
 
error() { echo "$@" 1>&2; }
5
 
fail() { [ $# -eq 0 ] || error "$@"; exit 2; }
6
 
 
7
 
rel="$(lsb_release -sc)"
8
 
case "$(uname -m)" in
9
 
  i?86|x86_64) qemu="qemu-system-x86";;
10
 
  ppc*) qemu="qemu-system-ppc";;
11
 
  s390x) qemu="qemu-system-s390x";;
12
 
esac
13
 
DEPS=(
14
 
  cloud-image-utils
15
 
  make
16
 
  net-tools
17
 
  python3
18
 
  python3-nose
19
 
  python3-simplestreams
20
 
  python3-yaml
21
 
  ovmf
22
 
  simplestreams
23
 
  $qemu
24
 
  ubuntu-cloudimage-keyring
25
 
  tgt
26
 
)
27
 
 
28
 
apt_get() {
29
 
    local ret=""
30
 
    if [ "$1" != "update" ] && ! $_APT_UPDATED; then
31
 
        error "updating apt"
32
 
        apt_get update >/dev/null || {
33
 
            ret=$?;
34
 
            error "failed to update apt [$ret]";
35
 
            return $ret;
36
 
        }
37
 
        _APT_UPDATED=true
38
 
    fi
39
 
    sudo DEBIAN_FRONTEND=noninteractive apt-get --quiet \
40
 
        --assume-yes "$@" </dev/null
41
 
}
42
 
 
43
 
filter_installed_packages() {
44
 
    # write to stdout, a list of packages not installed locally
45
 
    local fmt='${Package} ${Version}\n'
46
 
    LC_ALL=C dpkg-query --show "--showformat=${fmt}" "$@" 2>&1 | awk '
47
 
        $0 ~ /[Nn]o packages/ {
48
 
            sub("[.]$","",$NF);
49
 
            pkgs[n]=$NF;
50
 
            n=n+1;
51
 
        }
52
 
        $2 == "" {
53
 
                pkgs[n]=$1;
54
 
                n=n+1;
55
 
        };
56
 
        END { for(p in pkgs) {printf("%s ",pkgs[p])}; printf("\n"); }' n=0
57
 
}
58
 
 
59
 
apt_install() {
60
 
    local needed
61
 
    needed=$(filter_installed_packages "$@")
62
 
    [ -z "$needed" ] && return 0
63
 
    error "installing: $needed"
64
 
    apt_get install "$@"
65
 
}
66
 
 
67
 
 
68
 
apt_install "${DEPS[@]}"
69
 
 
70
 
# vi: ts=4 expandtab