-
Notifications
You must be signed in to change notification settings - Fork 18
/
bt-openstack-ami
executable file
·94 lines (69 loc) · 2.39 KB
/
bt-openstack-ami
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
#!/bin/bash -e
# Copyright (c) 2011-2015 TurnKey GNU/Linux - http://www.turnkeylinux.org
#
# This file is part of buildtasks.
#
# Buildtasks is free software; you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as published by the
# Free Software Foundation; either version 3 of the License, or (at your
# option) any later version.
fatal() { echo "FATAL [$(basename $0)]: $@" 1>&2; exit 1; }
warning() { echo "WARNING [$(basename $0)]: $@"; }
info() { echo "INFO [$(basename $0)]: $@"; }
usage() {
cat<<EOF
Syntax: $(basename $0) [--publish] appname
Converts appliance appname (e.g., core) to openstack image
Options::
--publish - if set, image will be devpay'ed and made public
Environment::
BT_DEBUG - turn on debugging
EOF
exit 1
}
while [ "$1" != "" ]; do
case $1 in
--help|-h ) usage;;
--publish) publish="yes";;
*) if [ -n "$appname" ]; then usage; else appname=$1; fi ;;
esac
shift
done
[ -n "$appname" ] || usage
[ -n "$publish" ] || warning "--publish was not specified"
[ -n "$BT_DEBUG" ] && set -x
export BT=$(dirname $(readlink -f $0))
export BT_CONFIG=$BT/config
. $BT_CONFIG/common.cfg
. $BT_CONFIG/build.cfg
O=$BT_BUILDS/openstack
mkdir -p $O
[ -n "$BT_VERSION" ] || fatal "BT_VERSION not set"
isofile=turnkey-$appname-$BT_VERSION.iso
name=turnkey-$appname-$BT_VERSION
rootfs=$name.rootfs
cdroot=$name.cdroot
$BT/bin/iso-download $BT_ISOS $BT_VERSION $appname
$BT/bin/iso-verify $BT_ISOS $BT_VERSION $appname
cd $O
tklpatch-extract-iso $BT_ISOS/$isofile
tklpatch-apply $rootfs $BT/patches/headless
tklpatch-apply $rootfs $BT/patches/cloud
tklpatch-apply $rootfs $BT/patches/openstack-ami
$BT/bin/rootfs-cleanup $rootfs
$BT/bin/aptconf-tag $rootfs openstack
$BT/bin/build-tag $rootfs openstack
$BT/bin/openstack-bundle-ami $rootfs
$BT/bin/generate-signature $O/$name-openstack.tar.gz
$BT/bin/generate-buildenv openstack $BT_ISOS/$isofile.hash > $O/$name-openstack.tar.gz.buildenv
# publish if specified
if [ "$publish" == "yes" ]; then
export PUBLISH_DEST=${BT_PUBLISH_IMGS}/openstack/
$BT/bin/publish-files $O/$name-openstack.tar.gz
export PUBLISH_DEST=${BT_PUBLISH_META}/
$BT/bin/publish-files $O/$name-openstack.{tar.gz.hash,tar.gz.buildenv}
fi
if [ -z "$BT_DEBUG" ] && ! (mount | grep -q $(basename $rootfs)); then
rm -rf $rootfs
rm -rf $cdroot
fi