Skip to content

Commit fbacf5b

Browse files
committed
Adjust bash scripts to support arm64
1 parent b24d514 commit fbacf5b

File tree

2 files changed

+33
-15
lines changed

2 files changed

+33
-15
lines changed

tools/appliance/build.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ function usage() {
2323
Usage:
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
8688
fi
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
95103
BUILD_NUMBER="${4:-${BUILD_NUMBER:-}}"
@@ -105,7 +113,7 @@ elif [ ! -z "${BUILD_NUMBER}" ]; then
105113
version_tag="-${BUILD_NUMBER}"
106114
fi
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

219227
function 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

224232
function 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 ..

tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ function install_packages() {
8787
apt_clean
8888

8989
# 32 bit architecture support for vhd-util
90-
if [ "${arch}" != "i386" ]; then
90+
if [[ "${arch}" != "i386" && "${arch}" != "arm64" ]]; then
9191
dpkg --add-architecture i386
9292
apt-get update
9393
${apt_get} install libuuid1:i386 libc6:i386
@@ -96,17 +96,25 @@ function install_packages() {
9696
# Install docker and containerd for CKS
9797
curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add -
9898
apt-key fingerprint 0EBFCD88
99-
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
99+
if [ "${arch}" == "arm64" ]; then
100+
add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
101+
elif [ "${arch}" == "amd64" ]; then
102+
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
103+
else
104+
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable"
105+
fi
100106
apt-get update
101107
${apt_get} install containerd.io
102108

103109
apt_clean
104110

105-
install_vhd_util
106-
# Install xenserver guest utilities as debian repos don't have it
107-
wget https://mirrors.kernel.org/ubuntu/pool/main/x/xe-guest-utilities/xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb
108-
dpkg -i xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb
109-
rm -f xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb
111+
if [ "${arch}" != "arm64" ]; then
112+
install_vhd_util
113+
# Install xenserver guest utilities as debian repos don't have it
114+
wget https://mirrors.kernel.org/ubuntu/pool/main/x/xe-guest-utilities/xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb
115+
dpkg -i xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb
116+
rm -f xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb
117+
fi
110118
}
111119

112120
return 2>/dev/null || install_packages

0 commit comments

Comments
 (0)