File: prep-debianish-root

package info (click to toggle)
puppetdb 8.8.1-1~exp1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 19,692 kB
  • sloc: javascript: 23,285; ruby: 5,620; sh: 3,457; python: 389; xml: 114; makefile: 38
file content (85 lines) | stat: -rwxr-xr-x 2,124 bytes parent folder | download
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
76
77
78
79
80
81
82
83
84
85
#!/usr/bin/env bash

set -uxeo pipefail

usage() {
    echo 'Usage: $(basename "$0") --for PDB_TEST_SPEC --install DIR'
}

misuse() { usage 1>&2; exit 2; }

# this handles the issue where apt-get update fails but has an exit
# code of zero because there's a mirror sync going on. This failure is
# retryable, but you have to look for it in the output from the
# command. This is a common failure on AWS and GCP because they inject
# their own mirrors into /etc/apt/sources.list at VM start time, and
# there's a delay in getting all their mirrors in sync.
apt-get-update() {
    local tmpdir
    tmpdir=$(mktemp)
    set +e
    for i in $(seq 1 20); do
        apt-get update 2>&1 | tee "$tmpdir"
        grep -x "[WE]:.*" "$tmpdir" || break
        sleep 1
    done
    set -e
    echo "Executed apt-get update $i times"
}

install-pg() {
    local need_pgdg=
    for pkg in "$@"; do
        if ! apt-cache show "$pkg"; then
            need_pgdg=1
            break
        fi
    done
    if test "$need_pgdg"; then
        apt install -y lsb-release gnupg2
        curl https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
        echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -sc)-pgdg main" \
             > /etc/apt/sources.list.d/pdb-pgdg.list
        apt-get-update
    fi

    apt-get -y install "$@"
}

spec=''
install=''
while test $# -gt 0; do
    case "$1" in
        --install)
            test $# -gt 1 || misuse
            install="$2"
            shift 2
            ;;
        --for)
            test $# -gt 1 || misuse
            spec="$2"
            shift 2
            ;;
        *) misuse ;;
    esac
done

test "$spec" || misuse
test "$install" || misuse
flavor=$(ext/bin/flavor-from-spec "$spec")

apt-get-update

# moreutils for ts
apt-get -y install bundler moreutils

case "$flavor" in
    core|ext|core+ext|int)
        pgver="$(ext/bin/prefixed-ref-from-spec "$spec" pg-)"
        if test "$pgver" = 9.6; then
            install-pg postgresql-9.6 postgresql-contrib-9.6
        else
            install-pg postgresql-"$pgver"
        fi
        ;;
esac