~andrewjbeach/juju-ci-tools/make-local-patcher

591 by Curtis Hovey
Added a script to retrieve and test ubuntu packages.
1
#!/bin/bash
2
# Download Ubuntu juju packages that match the version under test.
593 by Curtis Hovey
Fixed opt loop.
3
set -eu
591 by Curtis Hovey
Added a script to retrieve and test ubuntu packages.
4
5
: ${LOCAL_JENKINS_URL=http://juju-ci.vapour.ws:8080}
6
ARTIFACTS_PATH=$WORKSPACE/artifacts
7
8
: ${SCRIPTS=$(readlink -f $(dirname $0))}
9
export PATH="$SCRIPTS:$PATH"
10
11
UBUNTU_ARCH="http://archive.ubuntu.com/ubuntu/pool/universe/j/juju-core/"
12
PORTS_ARCH="http://ports.ubuntu.com/pool/universe/j/juju-core/"
13
ALL_ARCHIVES="$UBUNTU_ARCH $PORTS_ARCH"
14
15
TRUSTY_AMD64="certify-trusty-amd64"
16
TRUSTY_PPC64="certify-trusty-ppc64"
17
TRUSTY_I386="certify-trusty-i386"
18
593 by Curtis Hovey
Fixed opt loop.
19
set -x
20
591 by Curtis Hovey
Added a script to retrieve and test ubuntu packages.
21
usage() {
22
    echo "usage: $0 VERSION"
23
    echo "  VERSION: The juju package version to retrive."
24
    exit 1
25
}
26
27
28
check_deps() {
29
    echo "Phase 0: Checking requirements."
30
    has_deps=1
31
    which lftp || has_deps=0
32
    if [[ $has_deps == 0 ]]; then
33
        echo "Install lftp."
34
        exit 2
35
    fi
36
}
37
38
39
retrieve_packages() {
40
    # Retrieve the $RELEASE packages that contain jujud,
41
    # or copy a locally built package.
42
    echo "Phase 1: Retrieving juju-core packages from archives"
599 by Curtis Hovey
Do not archive for Jenkins because it wont find the archived files.
43
    cd $WORKSPACE
591 by Curtis Hovey
Added a script to retrieve and test ubuntu packages.
44
    for archive in $ALL_ARCHIVES; do
45
        safe_archive=$(echo "$archive" | sed -e 's,//.*@,//,')
593 by Curtis Hovey
Fixed opt loop.
46
        echo "checking $safe_archive for $VERSION."
594 by Curtis Hovey
Update common-startup.sh to understand Ubuntu and juju package names.
47
        lftp -c mirror -I "juju*${VERSION}*.deb" $archive;
591 by Curtis Hovey
Added a script to retrieve and test ubuntu packages.
48
    done
599 by Curtis Hovey
Do not archive for Jenkins because it wont find the archived files.
49
    if [ -d $WORKSPACE/juju-core ]; then
50
        found=$(find $WORKSPACE/juju-core/ -name "*deb")
591 by Curtis Hovey
Added a script to retrieve and test ubuntu packages.
51
        if [[ $found != "" ]]; then
599 by Curtis Hovey
Do not archive for Jenkins because it wont find the archived files.
52
            mv $WORKSPACE/juju-core/*deb ./
591 by Curtis Hovey
Added a script to retrieve and test ubuntu packages.
53
        fi
599 by Curtis Hovey
Do not archive for Jenkins because it wont find the archived files.
54
        rm -r $WORKSPACE/juju-core
591 by Curtis Hovey
Added a script to retrieve and test ubuntu packages.
55
    fi
56
}
57
58
59
start_series_arch_tests() {
918.1.1 by Curtis Hovey
Remove redundant workspace setup and hardcoded token.
60
    [[ -z $TOKEN ]] && return 0
604 by Curtis Hovey
Encode the version before asking other jobs to test it.
61
    encoded_version=$(echo "$VERSION" | sed 's,[+],%2B,')
62
    query="token=$TOKEN&VERSION=$encoded_version"
592 by Curtis Hovey
Update ami for trusty and fix bash.
63
    for job in $TRUSTY_AMD64 $TRUSTY_PPC64 $TRUSTY_I386; do
600 by Curtis Hovey
Pass the version to the other jobs.
64
        curl -o /dev/null \
601 by Curtis Hovey
Call with buildWithParameters
65
            "$LOCAL_JENKINS_URL/job/$job/buildWithParameters?$query"
591 by Curtis Hovey
Added a script to retrieve and test ubuntu packages.
66
    done
67
}
68
69
918.1.1 by Curtis Hovey
Remove redundant workspace setup and hardcoded token.
70
TOKEN=""
71
while [[ "${1-}" != "" && $1 =~ ^-.* ]]; do
593 by Curtis Hovey
Fixed opt loop.
72
    case $1 in
73
        --start-other-tests)
918.1.1 by Curtis Hovey
Remove redundant workspace setup and hardcoded token.
74
            shift
75
            TOKEN=$1
593 by Curtis Hovey
Fixed opt loop.
76
            ;;
77
    esac
78
    shift
591 by Curtis Hovey
Added a script to retrieve and test ubuntu packages.
79
done
80
81
test $# -eq 1 || usage
82
VERSION=$1
83
84
check_deps
593 by Curtis Hovey
Fixed opt loop.
85
retrieve_packages
591 by Curtis Hovey
Added a script to retrieve and test ubuntu packages.
86
start_series_arch_tests