-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathbuild-image
executable file
·143 lines (107 loc) · 2.13 KB
/
build-image
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
#!/bin/bash
#
# Build a silver image
#
: ${WORKSPACE:=~/susetest/build}
main_options="--workspace $WORKSPACE"
function get_build_result_name {
base_platform=
features=
while [ $# -gt 0 ]; do
opt=$1; shift
case $opt in
--base-platform)
base_platform=$1
shift;;
--feature)
features+="-$1"; shift;;
--debug)
main_options+=" $opt";;
--backend)
# ignore for now
shift;;
*) echo "Cannot handle argument $1" >&2
exit 1;;
esac
done
if [ -z "$base_platform" ]; then
echo "Required option --base-platform is missing" >&2
exit 1
fi
if [ -z "$features" ]; then
features="-silver"
fi
declare -g output_platform
output_platform="$base_platform$features"
}
function prepare_build_conf {
base_platform=
features=
while [ $# -gt 0 ]; do
opt=$1; shift
case $opt in
--base-platform)
base_platform=$1
shift;;
--feature)
if [ -z "$features" ]; then
features="build \"$1\""
else
features+=", \"$1\""
fi
shift;;
--backend)
backend="backend $1;"
shift;;
*) : ;;
esac
done
if [ -n "$features" ]; then
features+=";"
fi
file=$(mktemp /tmp/twopence-build-XXXXXX.conf)
cat >$file <<EOF
testcase build;
$backend
node build {
platform "$base_platform";
$features
}
EOF
declare -g build_config
build_config=$file
trap "rm -f $build_config" EXIT
}
function do_build {
if ! twopence provision $main_options init --config $build_config; then
return 1
fi
if ! twopence provision $main_options create; then
return 1
fi
twopence provision $main_options package $output_platform
return $?
}
get_build_result_name "$@"
prepare_build_conf "$@"
cat <<EOF
Output plaform: $output_platform
Build commands:
twopence provision $main_options init --config $build_config
twopence provision $main_options create
twopence provision $main_options package $output_platform
twopence provision $main_options destroy --force --zap
Build config file:
EOF
cat $build_config
exitcode=0
if ! do_build; then
exitcode=$?
fi
twopence provision $main_options destroy --force --zap
if [ $exitcode -ne 0 ]; then
cat <<-EOF
*** BUILD FAILED ***
EOF
fi
exit $exitcode