~snappy-dev/snappy/snappy-tools-update

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
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/sh

COPY_PACKAGE=copy-package
CURRENT_SUITE=vivid
CURRENT_SUITE_DEVEL=wily
TARGET_SUITES="vivid utopic trusty"
PACKAGES_TOOLS="snappy-tools ubuntu-snappy goget-ubuntu-touch snappy-remote ubuntu-core-security click-reviewers-tools"
PACKAGES_ARCHIVE="ubuntu-snappy goget-ubuntu-touch ubuntu-core-security click-reviewers-tools"

cleanup() {
    leave "Aborting..."
}

leave() {
    echo $@
    exit 1
}

copy() {
    sync_type=$1
    package=$2
    suite=$3

    if [ "$sync_type" = "tools" ]; then
        echo Attempting to copy $package from ppa:snappy-dev/tools \($CURRENT_SUITE\) to \
             ppa:snappy-dev/tools-proposed for $suite
        COPY_OPTIONS="--from-suite=$CURRENT_SUITE \
                      --ppa=snappy-dev \
                      --ppa-name=tools-proposed \
                      --to-ppa=snappy-dev \
                      --to-ppa-name=tools \
                      --to-suite=$suite"
    else
        echo Attempting to copy $package from archive \($CURRENT_SUITE_DEVEL\) to \
             ppa:snappy-dev/tools-proposed for $suite
        COPY_OPTIONS="--suite=$CURRENT_SUITE_DEVEL \
                      --to-ppa=snappy-dev \
                      --to-ppa-name=tools-proposed \
                      --to-suite=$suite"
    fi

    $COPY_PACKAGE \
        --include-binaries \
        --distribution=ubuntu \
        $COPY_OPTIONS \
        $package
}

print_usage() {
    cat << EOF
usage: $(basename $0) [-s SYNC_TYPE]

  Update either the 'tools' or the 'tools-proposed' PPAs, by copying binary
  packages using the copy-package tool.

  -s SYNC_TYPE     Sync type: 'tools' (default) to sync packages from
                   tools-proposed into tools or 'archive', to sync packages
                   from the ubuntu archive into tools-proposed.
  -h               This message
EOF
}

trap cleanup 1 2 3 9 15

while getopts s:h opt; do
    case $opt in
    h)
        print_usage
        exit 0
        ;;
    s)
        SYNC="$OPTARG"
        ;;
    esac
done

if [ -z "$SYNC" ] || [ "$SYNC" != "archive" ]; then
    SYNC="tools"
    PACKAGES_TO_COPY=$PACKAGES_TOOLS
else
    PACKAGES_TO_COPY=$PACKAGES_ARCHIVE
fi

if [ -n "$COPY_PACKAGE_PATH" ] && [ -f "$COPY_PACKAGE_PATH" ]; then
    COPY_PACKAGE=$COPY_PACKAGE_PATH
elif [ -z $(which "$COPY_PACKAGE") ]; then
    leave "$COPY_PACKAGE" not found, set COPY_PACKAGE_PATH and run again
fi

for package in $PACKAGES_TO_COPY
do
    for suite in $TARGET_SUITES
    do
        copy $SYNC $package $suite
    done
done

echo DONE