28
29
test -f ~/.juju/awstoolsrc || has_deps=0
29
30
test -f ~/.juju/azuretoolsrc || has_deps=0
30
31
if [[ $has_deps == 0 ]]; then
31
echo "Install lftp, python-swiftclient, and s3cmd"
32
echo "Install python-swiftclient, and s3cmd"
32
33
echo "Your ~/.juju dir must contain rc files to publish:"
33
34
echo " canonistacktoolsrc, hptoolsrc, awstoolsrc, azuretoolsrc"
40
if [[ ! -d $DEST_DEBS ]]; then
43
if [[ ! -d $DEST_TOOLS ]]; then
46
if [[ ! -d $DEST_DIST ]]; then
52
retrieve_released_tools() {
53
# Retrieve previously released tools to ensure the metadata continues
54
# to work for historic releases.
55
source ~/.juju/awstoolsrc
56
s3cmd sync s3://juju-dist/tools/releases/ $DEST_TOOLS
61
# Retrieve the $RELEASE packages that contain jujud.
63
for archive in $UBUNTU_ARCH $STABLE_ARCH $DEVEL_ARCH; do
64
echo "checking $archive for $RELEASE."
65
lftp -c mirror -I "juju-core_${RELEASE}*.deb" $archive;
73
# Defines $version. $version can be different than $RELEASE used to
74
# match the packages in the archives.
76
version=$(echo "$control_version" |
77
sed -n 's/^\([0-9]\+\).\([0-9]\+\).\([0-9]\+\)-[0-9].*/\1.\2.\3/p')
78
if [ "${version}" == "" ] ; then
79
echo "Invalid version: $control_version"
88
pkg_series=$(echo "$control_version" |
89
sed -e 's/~juju.//;' \
90
-e 's/^.*~\(ubuntu[0-9][0-9]\.[0-9][0-9]\|[a-z]\+\).*/\1/')
91
series=${version_names["$pkg_series"]}
93
"precise" | "quantal" | "raring" | "saucy" )
96
echo "Invalid series: $control_version"
106
arch=$(sed -n 's/^Architecture: \([a-z]\+\)/\1/p' $control_file)
108
"amd64" | "i386" | "armel" | "armhf" )
111
echo "Invalid arch: $arch"
119
# Builds the jujud tgz for each series and arch.
123
packages=$(ls ${DEST_DEBS}/*.deb)
124
for package in $packages; do
125
echo "Extracting jujud from ${package}."
126
dpkg-deb -e $package ${WORK}/juju
127
control_file="${WORK}/juju/control"
128
control_version=$(sed -n 's/^Version: \(.*\)/\1/p' $control_file)
129
get_version $control_version
130
get_series $control_version
131
get_arch $control_file
132
tool="${DEST_TOOLS}/juju-${version}-${series}-${arch}.tgz"
133
echo "Creating $tool."
134
dpkg-deb -x $package ${WORK}/juju
135
bin_dir="${WORK}/juju/usr/bin"
136
lib_dir="${WORK}/juju/usr/lib/juju-${version}/bin"
137
if [[ -f "${bin_dir}/jujud" ]]; then
139
elif [[ -f "${lib_dir}/jujud" ]]; then
142
echo "jujud is not in /usr/bin or /usr/lib"
145
tar cvfz $tool -C $change_dir jujud
146
echo "Created ${tool}."
153
# Create the streams metadata and organised the tree for later publication.
155
${GOPATH}/bin/juju sync-tools --all --dev \
156
--source=${DESTINATION} --destination=${DEST_DIST}
157
# Support old tools location so that deployments can upgrade to new tools.
158
cp ${DEST_DIST}/tools/releases/*tgz ${DEST_DIST}/tools
159
echo "The tools are in ${DEST_DIST}."
37
juju_version=$(juju --version)
38
echo "Using installed juju: $juju_version"
163
42
publish_to_canonistack() {
164
echo "Phase 6.1: Publish to canonistack."
43
echo "Phase 1: Publish to canonistack."
166
44
source ~/.juju/canonistacktoolsrc
167
${GOPATH}/bin/juju --show-log \
168
sync-tools -e public-tools-canonistack --dev --source=${DEST_DIST}
46
sync-tools -e public-tools-canonistack --dev --source=${JUJU_DIST}
169
47
# This needed to allow old deployments upgrade.
171
swift upload juju-dist tools/*.tgz
48
# XXX sinzui 2013-10-09: Ian fixed this.
50
#swift upload juju-dist tools/*.tgz
54
testing_to_canonistack() {
55
echo "Phase 1: Testing to canonistack."
56
source ~/.juju/canonistacktoolsrc
57
cd $JUJU_DIST/tools/releases/
58
swift upload juju-dist/testing/tools/releases *.tgz
59
cd $JUJU_DIST/tools/streams/v1
60
swift upload juju-dist/testing/tools/streams/v1 *.json
176
echo "Phase 6.2: Publish to HP Cloud."
65
echo "Phase 2: Publish to HP Cloud."
178
66
source ~/.juju/hptoolsrc
179
${GOPATH}/bin/juju --show-log \
180
sync-tools -e public-tools-hp --dev --source=${DEST_DIST}
68
sync-tools -e public-tools-hp --dev --source=${JUJU_DIST}
181
69
# Support old tools location so that deployments can upgrade to new tools.
183
swift upload juju-dist tools/*.tgz
70
# XXX sinzui 2013-10-09: Ian fixed this.
72
#swift upload juju-dist tools/*.tgz
77
# sync-tools cannot place the tools in a testing location, so swift is
79
echo "Phase 2: Testing to HP Cloud."
80
source ~/.juju/hptoolsrc
81
cd $JUJU_DIST/tools/releases/
82
swift upload juju-dist/testing/tools/releases *.tgz
83
cd $JUJU_DIST/tools/streams/v1
84
swift upload juju-dist/testing/tools/streams/v1 *.json
187
88
publish_to_aws() {
188
echo "Phase 6.3: Publish to AWS."
190
source ~/.juju/awstoolsrc
191
s3cmd sync ${DEST_DIST}/tools s3://juju-dist/
89
echo "Phase 3: Publish to AWS."
90
source ~/.juju/awstoolsrc
91
s3cmd sync ${JUJU_DIST}/tools s3://juju-dist/
96
# this is the same as the publishing command except that the
97
# destination is juju-dist/testing/
98
echo "Phase 3: Testing to AWS."
99
source ~/.juju/awstoolsrc
100
s3cmd sync ${JUJU_DIST}/tools s3://juju-dist/testing/
195
104
publish_to_azure() {
196
105
# This command sets the tool name from the local path! The local path for
197
106
# each public file MUST match the destination path :(.
198
echo "Phase 6.4: Publish to Azure."
107
echo "Phase 4: Publish to Azure."
200
108
source ~/.juju/azuretoolsrc
202
110
public_files=$(find tools -name *.tgz -o -name *.json)
203
111
for public_file in $public_files; do
204
112
echo "Uploading $public_file to Azure West US."
215
# These are the archives that are search for matching releases.
216
UBUNTU_ARCH="http://archive.ubuntu.com/ubuntu/pool/universe/j/juju-core/"
217
STABLE_ARCH="http://ppa.launchpad.net/juju/stable/ubuntu/pool/main/j/juju-core/"
218
DEVEL_ARCH="http://ppa.launchpad.net/juju/devel/ubuntu/pool/main/j/juju-core/"
124
# This command is like the publish command expcept tht -container is
126
echo "Phase 4: Testing to Azure."
127
source ~/.juju/azuretoolsrc
129
public_files=$(find tools -name *.tgz -o -name *.json)
130
for public_file in $public_files; do
131
echo "Uploading $public_file to Azure West US."
132
go run $GOPATH/src/launchpad.net/gwacl/example/storage/run.go \
133
-account=${AZURE_ACCOUNT} -container=juju-tools/testing \
134
-location="West US" \
135
-key=${AZURE_JUJU_TOOLS_KEY} \
136
-filename=$public_file \
220
# Series names found in package versions need to be normalised.
221
declare -A version_names
222
version_names+=(["ubuntu12.04"]="precise")
223
version_names+=(["ubuntu12.10"]="quantal")
224
version_names+=(["ubuntu13.04"]="raring")
225
version_names+=(["ubuntu13.10"]="saucy")
226
version_names+=(["precise"]="precise")
227
version_names+=(["quantal"]="quantal")
228
version_names+=(["raring"]="raring")
229
version_names+=(["saucy"]="saucy")
231
142
test $# -eq 2 || usage
234
DESTINATION=$(cd $2; pwd)
235
DEST_DEBS="${DESTINATION}/debs"
236
DEST_TOOLS="${DESTINATION}/tools/releases"
237
DEST_DIST="${DESTINATION}/juju-dist"
239
echo "Phase 0: Checking requirements."
145
if [[ $PURPOSE != "RELEASE" && $PURPOSE != "TESTING" ]]; then
149
JUJU_DIST=$(cd $2; pwd)
150
if [[ ! -d $JUJU_DIST/tools/releases && ! -d $JUJU_DIST/tools/streams ]]; then
242
echo "Phase 1: Building collection and republication tree."
245
echo "Phase 2: Retrieving released tools."
246
retrieve_released_tools
248
echo "Phase 3: Retrieving juju-core packages from archives"
251
echo "Phase 4: Extracting jujud from packages and archiving tools."
254
echo "Phase 5: Generating streams data."
257
echo "Phase 6: Publishing tools."
258
publish_to_canonistack
155
if [[ $PURPOSE == "RELEASE" ]]; then
156
publish_to_canonistack
161
testing_to_canonistack