-
Notifications
You must be signed in to change notification settings - Fork 4
/
builder.sh
executable file
·148 lines (122 loc) · 4.52 KB
/
builder.sh
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#!/bin/bash
#
# builder.sh should be called by cloudbuilder.yaml. builder accepts a single
# parameter (target) and multiple parameters from the environment. builder.sh
# transalates these into calls to specific build scripts.
set -eu
SOURCE_DIR=$( realpath $( dirname "${BASH_SOURCE[0]}" ) )
source "${SOURCE_DIR}/config.sh"
USAGE="$0 <target>"
TARGET=${1:?Please provide a build target: $USAGE}
function stage1_mlxrom() {
local target=${TARGET:?Please specify a target configuration name}
local project=${PROJECT:?Please specify the PROJECT}
local artifacts=${ARTIFACTS:?Please define an ARTIFACTS output directory}
local version=${MLXROM_VERSION:?Please define the MLXROM_VERSION to build}
local builddir=$( mktemp -d -t build-${TARGET}.XXXXXX )
# For maximum flexibility, embed the root CA of all projects, as well as a
# fallback to the Google Internet Authority intermediate cert used for GCS.
TRUSTED_CERTS="${SOURCE_DIR}/configs/${target}/epoxy-ca.mlab-sandbox.pem"
TRUSTED_CERTS+=",${SOURCE_DIR}/configs/${target}/epoxy-ca.mlab-staging.pem"
TRUSTED_CERTS+=",${SOURCE_DIR}/configs/${target}/epoxy-ca.mlab-oti.pem"
TRUSTED_CERTS+=",${SOURCE_DIR}/configs/${target}/gtsgiag3.pem"
${SOURCE_DIR}/setup_stage1_mlxrom.sh "${project}" "${builddir}" "${artifacts}" \
"${SOURCE_DIR}/configs/${target}" "${version}" "${TRUSTED_CERTS}"
rm -rf "${builddir}"
}
# Build coreos custom initram image.
function stage3_coreos() {
local target=${TARGET:?Please specify a target configuration name}
local artifacts=${ARTIFACTS:?Please define an ARTIFACTS output directory}
local version=${COREOS_VERSION:?Please specify the coreos version}
local builddir=$( mktemp -d -t build-${TARGET}.XXXXXX )
umask 0022
${SOURCE_DIR}/setup_stage3_coreos.sh \
"${SOURCE_DIR}/configs/${target}" \
/go/bin/epoxy_client \
http://stable.release.core-os.net/amd64-usr/${version}/coreos_production_pxe.vmlinuz \
http://stable.release.core-os.net/amd64-usr/${version}/coreos_production_pxe_image.cpio.gz \
"${artifacts}/coreos_custom_pxe_image.cpio.gz" &> ${SOURCE_DIR}/coreos.log \
|| (
tail -100 ${SOURCE_DIR}/coreos.log && false
)
rm -rf ${builddir}
}
function stage3_update() {
local target=${TARGET:?Please specify a target configuration name}
local artifacts=${ARTIFACTS:?Please define an ARTIFACTS output directory}
local builddir=$( mktemp -d -t build-${TARGET}.XXXXXX )
umask 0022
echo 'Starting stage3_update build'
${SOURCE_DIR}/setup_stage3_update.sh \
${builddir} ${artifacts} ${SOURCE_DIR}/configs/${target} \
/go/bin/epoxy_client &> ${SOURCE_DIR}/stage3_update.log \
|| (
tail -100 ${SOURCE_DIR}/stage3_update.log && false
)
rm -rf ${builddir}
}
function stage1_minimal() {
local target=${TARGET:?Please specify a target configuration name}
local artifacts=${ARTIFACTS:?Please define an ARTIFACTS output directory}
local builddir=$( mktemp -d -t build-${TARGET}.XXXXXX )
umask 0022
echo 'Starting stage1_minimal build'
${SOURCE_DIR}/setup_stage1_minimal.sh \
${builddir} ${artifacts} ${SOURCE_DIR}/configs/${target} \
/go/bin/epoxy_client
rm -rf ${builddir}
}
function stage3_ubuntu() {
local target=${TARGET:?Please specify a target configuration name}
local artifacts=${ARTIFACTS:?Please define an ARTIFACTS output directory}
local builddir=$( mktemp -d -t build-${TARGET}.XXXXXX )
umask 0022
echo 'Starting stage3_ubuntu build'
${SOURCE_DIR}/setup_stage3_ubuntu.sh \
${builddir} ${artifacts} ${SOURCE_DIR}/configs/${target} \
/go/bin/epoxy_client
rm -rf ${builddir}
}
function packer_images() {
echo 'Starting packer_images build'
${SOURCE_DIR}/setup_packer_images.sh
}
function stage1_isos() {
local target=${TARGET:?Please specify a target configuration name}
local project=${PROJECT:?Please specify the PROJECT}
local artifacts=${ARTIFACTS:?Please define an ARTIFACTS output directory}
local builddir=$( mktemp -d -t build-${TARGET}.XXXXXX )
${SOURCE_DIR}/setup_stage1_isos.sh "${project}" "${builddir}" "${artifacts}" \
"${SOURCE_DIR}/configs/${target}"
rm -rf "${builddir}"
return
}
mkdir -p ${ARTIFACTS}
case "${TARGET}" in
stage1_mlxrom)
stage1_mlxrom
;;
stage1_minimal)
stage1_minimal
;;
stage1_isos)
stage1_isos
;;
stage3_coreos)
stage3_coreos
;;
stage3_ubuntu)
stage3_ubuntu
;;
packer_images)
packer_images
;;
stage3_update)
stage3_update
;;
*)
echo "Unknown target: ${TARGET}"
exit 1
;;
esac