@@ -23,6 +23,8 @@ function usage() {
2323Usage:
2424 ./build.sh [template] [version] [BUILD_NUMBER]
2525
26+ * Set \$ target_arch to provide target architecture
27+ (or use command line arg, default to current architecture. Currently x86_64 and aarch64 are implemented)
2628 * Set \$ appliance to provide definition name to build
2729 (or use command line arg, default systemvmtemplate)
2830 * Set \$ version to provide version to apply to built appliance
@@ -85,11 +87,17 @@ if [[ ! -z "${JENKINS_HOME}" ]]; then
8587 DEBUG=1
8688fi
8789
90+ # get current system architecture
91+ base_arch=` arch`
92+
93+ # which architecture to build the template for
94+ target_arch=" ${1:- ${target_arch:- ${base_arch} } } "
95+
8896# which packer definition to use
89- appliance=" ${1 :- ${appliance:- systemvmtemplate} } "
97+ appliance=" ${2 :- ${appliance:- systemvmtemplate} } "
9098
9199# optional version tag to put into the image filename
92- version=" ${2 :- ${version:- } } "
100+ version=" ${3 :- ${version:- } } "
93101
94102# optional (jenkins) build number tag to put into the image filename
95103BUILD_NUMBER=" ${4:- ${BUILD_NUMBER:- } } "
@@ -105,7 +113,7 @@ elif [ ! -z "${BUILD_NUMBER}" ]; then
105113 version_tag=" -${BUILD_NUMBER} "
106114fi
107115
108- appliance_build_name=${appliance}${version_tag}
116+ appliance_build_name=" ${appliance}${version_tag} - ${target_arch} "
109117
110118# ##
111119# ## Generic helper functions
@@ -218,7 +226,7 @@ function prepare() {
218226
219227function packer_build() {
220228 log INFO " building new image with packer"
221- cd ${appliance_build_name} && packer build template.json && cd ..
229+ cd ${appliance_build_name} && packer build template-base_ ${base_arch} -target_ ${target_arch} .json && cd ..
222230}
223231
224232function stage_vmx() {
@@ -349,10 +357,12 @@ function main() {
349357
350358 # process the disk at dist
351359 kvm_export
352- ovm_export
353- xen_server_export
354- vmware_export
355- hyperv_export
360+ if [ " ${target_arch} " == " x86_64" ]; then
361+ ovm_export
362+ xen_server_export
363+ vmware_export
364+ hyperv_export
365+ fi
356366 rm -f " dist/${appliance} "
357367 cd dist && chmod +r * && cd ..
358368 cd dist && md5sum * > md5sum.txt && cd ..
0 commit comments