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

« back to all changes in this revision

Viewing changes to make-recipe-and-package.bash

  • Committer: Aaron Bentley
  • Date: 2014-02-24 17:18:29 UTC
  • mto: This revision was merged to the branch mainline in revision 252.
  • Revision ID: aaron.bentley@canonical.com-20140224171829-sz644yhoygu7m9dm
Use tags to identify and shut down instances.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/bin/bash
 
2
# Create a bzr-builder recipe and build it.
 
3
#
 
4
# The package built by this script can be used for testing to verify
 
5
# the release candidate is viable. The recipe can be added to launchpad
 
6
# to build packages (after the RC has proven to be viable).
 
7
set -eu
 
8
 
 
9
HERE=$(pwd)
 
10
DEFAULT_JUJU_CORE="lp:juju-core"
 
11
DEFAULT_PACKAGING="lp:~ce-orange-squad/juju-core/unstable-packaging"
 
12
LTS_SERIES="precise"
 
13
 
 
14
 
 
15
usage() {
 
16
    echo "usage: $0 REVNO [JUJU_CORE_BRANCH [PACKAGING_BRANCH]]"
 
17
    echo "  REVNO: The juju-core revno to build"
 
18
    echo "  JUJU_CORE_BRANCH: The juju-core branch; defaults to ${DEFAULT_JUJU_CORE}"
 
19
    echo "  PACKAGING_BRANCH: The packaging branch; defaults to ${DEFAULT_PACKAGING}"
 
20
    exit 1
 
21
}
 
22
 
 
23
 
 
24
check_deps() {
 
25
    echo "Phase 0: Checking requirements."
 
26
    has_deps=1
 
27
    which dh || has_deps=0
 
28
    which bzr || has_deps=0
 
29
    bzr plugins | grep bzr-builder || has_deps=0
 
30
    if [[ $has_deps == 0 ]]; then
 
31
        echo "Install debhelper, bzr, and bzr-builder"
 
32
        exit 2
 
33
    fi
 
34
}
 
35
 
 
36
 
 
37
create_recipe() {
 
38
    echo "Phase 1: Creating a recipe for juju-core r${REVNO}."
 
39
    echo "Retrieving dependencies.tsv from $JUJU_CORE_BRANCH r$REVNO"
 
40
    VERSION=$(bzr cat -q -d $JUJU_CORE_BRANCH -r $REVNO version/version.go |
 
41
        sed -n 's/^const version = "\(.*\)"/\1/p')
 
42
    DEPENDENCIES=$(bzr cat -d $JUJU_CORE_BRANCH -r $REVNO dependencies.tsv)
 
43
    BASE="\
 
44
# bzr-builder format 0.3 deb-version ${VERSION}+${REVNO}-0
 
45
${PACKAGING_BRANCH}
 
46
nest juju-core ${JUJU_CORE_BRANCH} src/launchpad.net/juju-core revno:${REVNO}
 
47
"
 
48
    NESTED=$(
 
49
        echo "${DEPENDENCIES}" |
 
50
        sed -e '/^code/d;' \
 
51
            -e 's,^\(.*\)/\([^/]*\)\tbzr.*\t\([0-9]*\)$,nest \2 lp:\2 src/\1/\2 revno:\3,;' \
 
52
            -e 's,lp:mgo,lp:mgo/v2,' |
 
53
        sort)
 
54
    RECIPE="${BASE}${NESTED}"
 
55
    echo "${RECIPE}" > $RECIPE_NAME
 
56
    echo "Created ${RECIPE_NAME}"
 
57
}
 
58
 
 
59
 
 
60
create_source_package() {
 
61
    echo "Phase 2: Creating a source package."
 
62
    mkdir -p "${TESTING_DIR}"
 
63
    bzr dailydeb --allow-fallback-to-native --append-version ~$LTS_SERIES \
 
64
        $RECIPE_NAME $TESTING_DIR
 
65
}
 
66
 
 
67
 
 
68
create_binary_package() {
 
69
    echo "Phase 3: creating a binary package."
 
70
    cd ${TESTING_DIR}
 
71
    tar zxf *.tar.gz
 
72
    cd juju-core-$VERSION+$REVNO/
 
73
    fakeroot debian/rules binary
 
74
    PACKAGES=$(ls ${TESTING_DIR}/*.deb)
 
75
    echo "Created $PACKAGES"
 
76
}
 
77
 
 
78
 
 
79
test $# -ge 1 ||  usage
 
80
REVNO=$1
 
81
JUJU_CORE_BRANCH=${2:-$DEFAULT_JUJU_CORE}
 
82
PACKAGING_BRANCH=${3:-$DEFAULT_PACKAGING}
 
83
 
 
84
RECIPE_NAME="juju-core-r${REVNO}.recipe"
 
85
TESTING_DIR="${HERE}/testing-juju-core-r${REVNO}"
 
86
 
 
87
check_deps
 
88
create_recipe
 
89
create_source_package
 
90
create_binary_package