summaryrefslogtreecommitdiff
path: root/tools/run-centos
blob: 4506b20dadeb506fdadfa6923e0adcfc0610ba54 (plain)
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
#!/bin/bash
# This file is part of cloud-init. See LICENSE file for license information.

deprecated() {
cat <<EOF
             ================ DEPRECATED ================
             | run-centos is deprecated. Please replace |
             | your usage with tools/run-container .    |
             ================ DEPRECATED ================
EOF
}

Usage() {
    deprecated
    cat <<EOF
Usage: ${0##*/} [ options ] version

    This utility can makes it easier to run tests, build rpm and source rpm
        generation inside a LXC of the specified version of CentOS.

    version is major release number (6 or 7)

    options:
      -a | --artifact keep .rpm artifacts
           --dirty    apply local changes before running tests.
                      If not provided, a clean checkout of branch is tested.
                      Inside container, changes are in local-changes.diff.
      -k | --keep     keep container after tests
      -r | --rpm      build .rpm
      -s | --srpm     build .src.rpm
      -u | --unittest run unit tests

    Example:
      * ${0##*/} --rpm --srpm --unittest 6
EOF
    deprecated
EOF
}

bad_Usage() { Usage 1>&2; [ $# -eq 0 ] || error "$@"; return 1; }

main() {
    if [ "$1" = "-h" -o "$1" == "--help" ]; then
        Usage 1>&2;
        exit 0;
    fi
    local pt="" mydir=$(dirname "$0")
    local run_container="$mydir/run-container"
    if [ ! -x "$run_container" ]; then
        bad_Usage "Could not find run-container."
        return
    fi
    
    pt=( "$run_container" )
    while [ $# -ne 0 ]; do
        cur="${1:-}"; next="${2:-}";
        case "$cur" in
            -r|--rpm) cur="--package";;
            -s|--srpm) cur="--source-package";;
            -a|--artifact) cur="--artifacts=.";;
            6|7) cur="centos/$cur";;
        esac
        pt[${#pt[@]}]="$cur"
        shift;
    done
    deprecated
    exec "${pt[@]}"
}

main "$@"

# vi: ts=4 expandtab