From b24d51487c27a517114fb150d3a02a9e7adf7a00 Mon Sep 17 00:00:00 2001 From: StepBee Date: Fri, 6 Jan 2023 15:48:18 +0000 Subject: [PATCH 01/10] Move and copy files to new filenames --- .../http/{preseed.cfg => preseed_aarch64.cfg} | 0 .../systemvmtemplate/http/preseed_x86_64.cfg | 113 ++++++++++++++++++ ...template-base_aarch64-target_aarch64.json} | 0 .../template-base_x86_64-target_aarch64.json | 75 ++++++++++++ .../template-base_x86_64-target_x86_64.json | 75 ++++++++++++ 5 files changed, 263 insertions(+) rename tools/appliance/systemvmtemplate/http/{preseed.cfg => preseed_aarch64.cfg} (100%) create mode 100644 tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg rename tools/appliance/systemvmtemplate/{template.json => template-base_aarch64-target_aarch64.json} (100%) create mode 100644 tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json create mode 100644 tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json diff --git a/tools/appliance/systemvmtemplate/http/preseed.cfg b/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg similarity index 100% rename from tools/appliance/systemvmtemplate/http/preseed.cfg rename to tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg diff --git a/tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg b/tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg new file mode 100644 index 000000000000..ae71ed5c0638 --- /dev/null +++ b/tools/appliance/systemvmtemplate/http/preseed_x86_64.cfg @@ -0,0 +1,113 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +### Localization +# Locale sets language and country. +d-i debian-installer/locale string en_US.UTF-8 +d-i debian-installer/country string IN + +# Keyboard selection. +d-i keymap select us +d-i keyboard-configuration/xkb-keymap select us + +### Network configuration +d-i netcfg/choose_interface select auto +d-i netcfg/get_hostname string systemvm +d-i netcfg/get_domain string apache.org +d-i netcfg/wireless_wep string + +d-i hw-detect/load_firmware boolean true + +### Mirror settings +d-i mirror/country string manual +d-i mirror/http/hostname string deb.debian.org +d-i mirror/http/directory string /debian +d-i mirror/http/proxy string + +### Apt setup +d-i apt-setup/cdrom/set-first false +d-i apt-setup/security-updates boolean true +d-i apt-setup/services-select multiselect security, updates +d-i apt-setup/security_host string security.debian.org +d-i apt-setup/local0/source boolean false +d-i apt-setup/multiarch string i386 +d-i apt-setup/backports boolean true +d-i apt-setup/contrib boolean true +d-i apt-setup/multiverse boolean true +d-i apt-setup/universe boolean true + +### Clock and time zone setup +d-i clock-setup/utc boolean true +d-i time/zone string UTC +d-i clock-setup/ntp boolean true + +### Partitioning +d-i partman-auto/disk string /dev/vda +d-i partman-auto/method string regular +d-i partman-auto/expert_recipe string \ + boot-root :: \ + 400 60 400 ext2 \ + $primary{ } $bootable{ } \ + method{ format } format{ } \ + use_filesystem{ } filesystem{ ext2 } \ + mountpoint{ /boot } \ + . \ + 256 1000 256 linux-swap \ + method{ swap } format{ } \ + . \ + 2240 40 4000 ext4 \ + method{ format } format{ } \ + use_filesystem{ } filesystem{ ext4 } \ + mountpoint{ / } \ + . + +d-i partman-md/confirm boolean true +d-i partman-partitioning/confirm_write_new_label boolean true +d-i partman/choose_partition select finish +d-i partman/confirm boolean true +d-i partman/confirm_nooverwrite boolean true + +### Base system installation +# ... + +### Account setup +d-i passwd/root-login boolean false +d-i passwd/root-password password password +d-i passwd/root-password-again password password +d-i passwd/user-fullname string Cloud User +d-i passwd/username string cloud +d-i passwd/user-password password cloud +d-i passwd/user-password-again password cloud +d-i user-setup/encrypt-home boolean false +d-i user-setup/allow-password-weak boolean true +d-i passwd/user-default-groups string audio cdrom video admin + +### Package selection +tasksel tasksel/first multiselect ssh-server +d-i pkgsel/include string openssh-server ntp acpid sudo bzip2 openssl +# Allowed values: none, safe-upgrade, full-upgrade +d-i pkgsel/upgrade select full-upgrade +d-i pkgsel/update-policy select none + +popularity-contest popularity-contest/participate boolean false + +### Boot loader installation +d-i grub-installer/only_debian boolean true +d-i grub-installer/bootdev string default +d-i finish-install/reboot_in_progress note + +#### Advanced options diff --git a/tools/appliance/systemvmtemplate/template.json b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json similarity index 100% rename from tools/appliance/systemvmtemplate/template.json rename to tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json new file mode 100644 index 000000000000..165caed7525f --- /dev/null +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json @@ -0,0 +1,75 @@ +{ + "_license": "Apache License 2.0", + "builders": [ + { + "accelerator": "kvm", + "boot_command": [ + "", + "install ", + "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", + "debian-installer=en_US.UTF-8 ", + "auto ", + "language=en locale=en_US.UTF-8 ", + "kbd-chooser/method=us ", + "keyboard-configuration/xkb-keymap=us ", + "netcfg/get_hostname=systemvm ", + "netcfg/get_domain=apache.org ", + "country=IN keymap=us ", + "fb=false ", + "debconf/frontend=noninteractive ", + "console-setup/ask_detect=false ", + "console-keymaps-at/keymap=us ", + "" + ], + "boot_wait": "5s", + "disk_interface": "virtio", + "disk_size": "5000M", + "format": "qcow2", + "headless": true, + "http_directory": "http", + "iso_checksum": "sha512:224cd98011b9184e49f858a46096c6ff4894adff8945ce89b194541afdfd93b73b4666b0705234bd4dff42c0a914fdb6037dd0982efb5813e8a553d8e92e6f51", + "iso_url": "https://cdimage.debian.org/debian-cd/11.6.0/amd64/iso-cd/debian-11.6.0-amd64-netinst.iso", + "net_device": "virtio-net", + "output_directory": "../dist", + "qemuargs": [ + [ + "-m", + "500M" + ], + [ + "-smp", + "1" + ] + ], + "shutdown_command": "sudo halt -p", + "ssh_password": "cloud", + "ssh_timeout": "30m", + "ssh_username": "cloud", + "type": "qemu", + "vm_name": "systemvmtemplate" + } + ], + "description": "CloudStack SystemVM template", + "provisioners": [ + { + "execute_command": "echo 'cloud' | sudo -u root -S bash {{.Path}}", + "scripts": [ + "scripts/apt_upgrade.sh", + "scripts/configure_grub.sh", + "scripts/configure_locale.sh", + "scripts/configure_networking.sh", + "scripts/configure_acpid.sh", + "scripts/install_systemvm_packages.sh", + "scripts/configure_conntrack.sh", + "scripts/authorized_keys.sh", + "scripts/configure_persistent_config.sh", + "scripts/configure_login.sh", + "../cloud_scripts_shar_archive.sh", + "scripts/configure_systemvm_services.sh", + "scripts/cleanup.sh", + "scripts/finalize.sh" + ], + "type": "shell" + } + ] +} diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json new file mode 100644 index 000000000000..165caed7525f --- /dev/null +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json @@ -0,0 +1,75 @@ +{ + "_license": "Apache License 2.0", + "builders": [ + { + "accelerator": "kvm", + "boot_command": [ + "", + "install ", + "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", + "debian-installer=en_US.UTF-8 ", + "auto ", + "language=en locale=en_US.UTF-8 ", + "kbd-chooser/method=us ", + "keyboard-configuration/xkb-keymap=us ", + "netcfg/get_hostname=systemvm ", + "netcfg/get_domain=apache.org ", + "country=IN keymap=us ", + "fb=false ", + "debconf/frontend=noninteractive ", + "console-setup/ask_detect=false ", + "console-keymaps-at/keymap=us ", + "" + ], + "boot_wait": "5s", + "disk_interface": "virtio", + "disk_size": "5000M", + "format": "qcow2", + "headless": true, + "http_directory": "http", + "iso_checksum": "sha512:224cd98011b9184e49f858a46096c6ff4894adff8945ce89b194541afdfd93b73b4666b0705234bd4dff42c0a914fdb6037dd0982efb5813e8a553d8e92e6f51", + "iso_url": "https://cdimage.debian.org/debian-cd/11.6.0/amd64/iso-cd/debian-11.6.0-amd64-netinst.iso", + "net_device": "virtio-net", + "output_directory": "../dist", + "qemuargs": [ + [ + "-m", + "500M" + ], + [ + "-smp", + "1" + ] + ], + "shutdown_command": "sudo halt -p", + "ssh_password": "cloud", + "ssh_timeout": "30m", + "ssh_username": "cloud", + "type": "qemu", + "vm_name": "systemvmtemplate" + } + ], + "description": "CloudStack SystemVM template", + "provisioners": [ + { + "execute_command": "echo 'cloud' | sudo -u root -S bash {{.Path}}", + "scripts": [ + "scripts/apt_upgrade.sh", + "scripts/configure_grub.sh", + "scripts/configure_locale.sh", + "scripts/configure_networking.sh", + "scripts/configure_acpid.sh", + "scripts/install_systemvm_packages.sh", + "scripts/configure_conntrack.sh", + "scripts/authorized_keys.sh", + "scripts/configure_persistent_config.sh", + "scripts/configure_login.sh", + "../cloud_scripts_shar_archive.sh", + "scripts/configure_systemvm_services.sh", + "scripts/cleanup.sh", + "scripts/finalize.sh" + ], + "type": "shell" + } + ] +} From fbacf5b2caed958e90ed4c134948aa4eb8dafed1 Mon Sep 17 00:00:00 2001 From: StepBee Date: Fri, 6 Jan 2023 16:03:49 +0000 Subject: [PATCH 02/10] Adjust bash scripts to support arm64 --- tools/appliance/build.sh | 26 +++++++++++++------ .../scripts/install_systemvm_packages.sh | 22 +++++++++++----- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh index 1c83f9aba510..c6fadcbd12fa 100755 --- a/tools/appliance/build.sh +++ b/tools/appliance/build.sh @@ -23,6 +23,8 @@ function usage() { Usage: ./build.sh [template] [version] [BUILD_NUMBER] + * Set \$target_arch to provide target architecture + (or use command line arg, default to current architecture. Currently x86_64 and aarch64 are implemented) * Set \$appliance to provide definition name to build (or use command line arg, default systemvmtemplate) * Set \$version to provide version to apply to built appliance @@ -85,11 +87,17 @@ if [[ ! -z "${JENKINS_HOME}" ]]; then DEBUG=1 fi +# get current system architecture +base_arch=`arch` + +# which architecture to build the template for +target_arch="${1:-${target_arch:-${base_arch}}}" + # which packer definition to use -appliance="${1:-${appliance:-systemvmtemplate}}" +appliance="${2:-${appliance:-systemvmtemplate}}" # optional version tag to put into the image filename -version="${2:-${version:-}}" +version="${3:-${version:-}}" # optional (jenkins) build number tag to put into the image filename BUILD_NUMBER="${4:-${BUILD_NUMBER:-}}" @@ -105,7 +113,7 @@ elif [ ! -z "${BUILD_NUMBER}" ]; then version_tag="-${BUILD_NUMBER}" fi -appliance_build_name=${appliance}${version_tag} +appliance_build_name="${appliance}${version_tag}-${target_arch}" ### ### Generic helper functions @@ -218,7 +226,7 @@ function prepare() { function packer_build() { log INFO "building new image with packer" - cd ${appliance_build_name} && packer build template.json && cd .. + cd ${appliance_build_name} && packer build template-base_${base_arch}-target_${target_arch}.json && cd .. } function stage_vmx() { @@ -349,10 +357,12 @@ function main() { # process the disk at dist kvm_export - ovm_export - xen_server_export - vmware_export - hyperv_export + if [ "${target_arch}" == "x86_64" ]; then + ovm_export + xen_server_export + vmware_export + hyperv_export + fi rm -f "dist/${appliance}" cd dist && chmod +r * && cd .. cd dist && md5sum * > md5sum.txt && cd .. diff --git a/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh b/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh index 3b4ef6537286..ebf53dfc2d34 100644 --- a/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh +++ b/tools/appliance/systemvmtemplate/scripts/install_systemvm_packages.sh @@ -87,7 +87,7 @@ function install_packages() { apt_clean # 32 bit architecture support for vhd-util - if [ "${arch}" != "i386" ]; then + if [[ "${arch}" != "i386" && "${arch}" != "arm64" ]]; then dpkg --add-architecture i386 apt-get update ${apt_get} install libuuid1:i386 libc6:i386 @@ -96,17 +96,25 @@ function install_packages() { # Install docker and containerd for CKS curl -fsSL https://download.docker.com/linux/debian/gpg | sudo apt-key add - apt-key fingerprint 0EBFCD88 - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" + if [ "${arch}" == "arm64" ]; then + add-apt-repository "deb [arch=arm64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" + elif [ "${arch}" == "amd64" ]; then + add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" + else + add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/debian $(lsb_release -cs) stable" + fi apt-get update ${apt_get} install containerd.io apt_clean - install_vhd_util - # Install xenserver guest utilities as debian repos don't have it - wget https://mirrors.kernel.org/ubuntu/pool/main/x/xe-guest-utilities/xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb - dpkg -i xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb - rm -f xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb + if [ "${arch}" != "arm64" ]; then + install_vhd_util + # Install xenserver guest utilities as debian repos don't have it + wget https://mirrors.kernel.org/ubuntu/pool/main/x/xe-guest-utilities/xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb + dpkg -i xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb + rm -f xe-guest-utilities_7.10.0-0ubuntu1_amd64.deb + fi } return 2>/dev/null || install_packages From 8f406e7fd1bcf9b71202fe526f0adaff40402884 Mon Sep 17 00:00:00 2001 From: StepBee Date: Fri, 6 Jan 2023 16:06:40 +0000 Subject: [PATCH 03/10] change preseed for arm64 to create EFI partition --- .../appliance/systemvmtemplate/http/preseed_aarch64.cfg | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg b/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg index ae71ed5c0638..5262603deaa4 100644 --- a/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg +++ b/tools/appliance/systemvmtemplate/http/preseed_aarch64.cfg @@ -60,6 +60,12 @@ d-i partman-auto/disk string /dev/vda d-i partman-auto/method string regular d-i partman-auto/expert_recipe string \ boot-root :: \ + 538 538 1075 free \ + $iflabel{ gpt } \ + $reusemethod{ } \ + method{ efi } \ + format{ } \ + . \ 400 60 400 ext2 \ $primary{ } $bootable{ } \ method{ format } format{ } \ @@ -80,6 +86,9 @@ d-i partman-partitioning/confirm_write_new_label boolean true d-i partman/choose_partition select finish d-i partman/confirm boolean true d-i partman/confirm_nooverwrite boolean true +grub-efi-arm64 grub2/force_efi_extra_removable boolean true +d-i partman-partitioning/choose_label select gpt +d-i partman-partitioning/default_label string gpt ### Base system installation # ... From a7077a8453dc944048a236bb44e19beeffaec7f9 Mon Sep 17 00:00:00 2001 From: StepBee Date: Fri, 6 Jan 2023 16:11:04 +0000 Subject: [PATCH 04/10] change packer template files to support arm64 --- .../template-base_aarch64-target_aarch64.json | 36 ++++++++++++++----- .../template-base_x86_64-target_aarch64.json | 35 +++++++++++++----- 2 files changed, 53 insertions(+), 18 deletions(-) diff --git a/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json index 165caed7525f..934bebc60ed7 100644 --- a/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json @@ -4,9 +4,9 @@ { "accelerator": "kvm", "boot_command": [ - "", - "install ", - "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", + "c", + "linux /install.a64/vmlinuz ", + "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed_aarch64.cfg ", "debian-installer=en_US.UTF-8 ", "auto ", "language=en locale=en_US.UTF-8 ", @@ -19,31 +19,49 @@ "debconf/frontend=noninteractive ", "console-setup/ask_detect=false ", "console-keymaps-at/keymap=us ", - "" + "---", + "", + "initrd /install.a64/initrd.gz", + "", + "boot" ], - "boot_wait": "5s", + "boot_wait": "180s", "disk_interface": "virtio", + "cdrom_interface": "virtio-scsi", "disk_size": "5000M", "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:224cd98011b9184e49f858a46096c6ff4894adff8945ce89b194541afdfd93b73b4666b0705234bd4dff42c0a914fdb6037dd0982efb5813e8a553d8e92e6f51", - "iso_url": "https://cdimage.debian.org/debian-cd/11.6.0/amd64/iso-cd/debian-11.6.0-amd64-netinst.iso", + "iso_checksum": "sha512:7b575eb212aba8921c314dc3b0fb29e6fc54c931013cad6764f10a26d9363c257f027a45d96bb750e48638ea4a1f223ab86ccc024d3e983853420fcde54ac999", + "iso_url": "https://cdimage.debian.org/debian-cd/11.6.0/arm64/iso-cd/debian-11.6.0-arm64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", + "qemu_binary": "qemu-system-aarch64", "qemuargs": [ [ "-m", "500M" ], + [ + "-machine", + "virt" + ], + [ + "-cpu", + "host" + ], [ "-smp", "1" - ] + ], + [ "-pflash", "/usr/share/AAVMF/AAVMF_CODE.fd" ], + [ "-monitor", "none" ], + [ "-enable-kvm" ], + [ "-boot", "strict=off" ] ], "shutdown_command": "sudo halt -p", "ssh_password": "cloud", - "ssh_timeout": "30m", + "ssh_timeout": "120m", "ssh_username": "cloud", "type": "qemu", "vm_name": "systemvmtemplate" diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json index 165caed7525f..5c0181576142 100644 --- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json @@ -4,9 +4,9 @@ { "accelerator": "kvm", "boot_command": [ - "", - "install ", - "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", + "c", + "linux /install.a64/vmlinuz ", + "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed_aarch64.cfg ", "debian-installer=en_US.UTF-8 ", "auto ", "language=en locale=en_US.UTF-8 ", @@ -19,31 +19,48 @@ "debconf/frontend=noninteractive ", "console-setup/ask_detect=false ", "console-keymaps-at/keymap=us ", - "" + "---", + "", + "initrd /install.a64/initrd.gz", + "", + "boot" ], - "boot_wait": "5s", + "boot_wait": "60s", "disk_interface": "virtio", + "cdrom_interface": "virtio-scsi", "disk_size": "5000M", "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:224cd98011b9184e49f858a46096c6ff4894adff8945ce89b194541afdfd93b73b4666b0705234bd4dff42c0a914fdb6037dd0982efb5813e8a553d8e92e6f51", - "iso_url": "https://cdimage.debian.org/debian-cd/11.6.0/amd64/iso-cd/debian-11.6.0-amd64-netinst.iso", + "iso_checksum": "sha512:7b575eb212aba8921c314dc3b0fb29e6fc54c931013cad6764f10a26d9363c257f027a45d96bb750e48638ea4a1f223ab86ccc024d3e983853420fcde54ac999", + "iso_url": "https://cdimage.debian.org/debian-cd/11.6.0/arm64/iso-cd/debian-11.6.0-arm64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", + "qemu_binary": "qemu-system-aarch64", "qemuargs": [ [ "-m", "500M" ], + [ + "-machine", + "virt" + ], + [ + "-cpu", + "cortex-a57" + ], [ "-smp", "1" - ] + ], + [ "-pflash", "/usr/share/AAVMF/AAVMF_CODE.fd" ], + [ "-monitor", "none" ], + [ "-boot", "strict=off" ] ], "shutdown_command": "sudo halt -p", "ssh_password": "cloud", - "ssh_timeout": "30m", + "ssh_timeout": "120m", "ssh_username": "cloud", "type": "qemu", "vm_name": "systemvmtemplate" From e590dcca5168631dbbdc350c27278cc1e2a50bf0 Mon Sep 17 00:00:00 2001 From: StepBee Date: Fri, 6 Jan 2023 20:43:41 +0000 Subject: [PATCH 05/10] Correct preseed file name in x86_64 packer template --- .../systemvmtemplate/template-base_x86_64-target_x86_64.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json index 165caed7525f..9ae050f48b39 100644 --- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_x86_64.json @@ -6,7 +6,7 @@ "boot_command": [ "", "install ", - "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", + "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed_x86_64.cfg ", "debian-installer=en_US.UTF-8 ", "auto ", "language=en locale=en_US.UTF-8 ", From 82a2e33ac7699bcbd422029df280fd027764cbdf Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Wed, 24 Jul 2024 10:30:41 +0530 Subject: [PATCH 06/10] fixes Signed-off-by: Rohit Yadav --- tools/appliance/README.md | 11 +++++++++-- .../template-base_aarch64-target_aarch64.json | 4 ++-- .../template-base_x86_64-target_aarch64.json | 4 ++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/tools/appliance/README.md b/tools/appliance/README.md index e9293d6373be..eae8b105220d 100644 --- a/tools/appliance/README.md +++ b/tools/appliance/README.md @@ -33,10 +33,17 @@ CentOS based built-in user VM template. http://packages.shapeblue.com/systemvmtemplate/vhd-util http://packages.shapeblue.com/systemvmtemplate/libvhd.so.1.0 +- For building ARM64 systemvm template on amd64 systems, please also install: + qemu-utils qemu-system-arm qemu-efi-aarch64 + # How to build appliances Just run build.sh, it will export archived appliances for KVM, XenServer, VMWare and HyperV in `dist` directory: - bash build.sh systemvmtemplate - bash build.sh builtin + bash build.sh x86_64 systemvmtemplate + bash build.sh aarch64 systemvmtemplate + +For building builtin template run: + + bash build.sh x86_64 builtin diff --git a/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json index 934bebc60ed7..4d8a540a396d 100644 --- a/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_aarch64-target_aarch64.json @@ -32,8 +32,8 @@ "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:7b575eb212aba8921c314dc3b0fb29e6fc54c931013cad6764f10a26d9363c257f027a45d96bb750e48638ea4a1f223ab86ccc024d3e983853420fcde54ac999", - "iso_url": "https://cdimage.debian.org/debian-cd/11.6.0/arm64/iso-cd/debian-11.6.0-arm64-netinst.iso", + "iso_checksum": "sha512:4980197fa30646a43df2672d98500a182d6636422e39e809d986551356f4d24b1ffab6d745331369b27f2e9a5326f020ba141df5772ac2c6328c08cce73de7e8", + "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/11.10.0/arm64/iso-cd/debian-11.10.0-arm64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", "qemu_binary": "qemu-system-aarch64", diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json index 5c0181576142..bddf99fe7475 100644 --- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json @@ -32,8 +32,8 @@ "format": "qcow2", "headless": true, "http_directory": "http", - "iso_checksum": "sha512:7b575eb212aba8921c314dc3b0fb29e6fc54c931013cad6764f10a26d9363c257f027a45d96bb750e48638ea4a1f223ab86ccc024d3e983853420fcde54ac999", - "iso_url": "https://cdimage.debian.org/debian-cd/11.6.0/arm64/iso-cd/debian-11.6.0-arm64-netinst.iso", + "iso_checksum": "sha512:4980197fa30646a43df2672d98500a182d6636422e39e809d986551356f4d24b1ffab6d745331369b27f2e9a5326f020ba141df5772ac2c6328c08cce73de7e8", + "iso_url": "https://cdimage.debian.org/mirror/cdimage/archive/11.10.0/arm64/iso-cd/debian-11.10.0-arm64-netinst.iso", "net_device": "virtio-net", "output_directory": "../dist", "qemu_binary": "qemu-system-aarch64", From d1d238f13663dc34d8babc7c8352931e912e84cc Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Wed, 24 Jul 2024 10:46:46 +0530 Subject: [PATCH 07/10] try different machine cpu Signed-off-by: Rohit Yadav --- .../systemvmtemplate/template-base_x86_64-target_aarch64.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json index bddf99fe7475..374d787588fa 100644 --- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json @@ -48,7 +48,7 @@ ], [ "-cpu", - "cortex-a57" + "cortex-a72" ], [ "-smp", From e7073897dd8fdcac1cd10df1c0959b0e03aafd8e Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Wed, 24 Jul 2024 10:54:37 +0530 Subject: [PATCH 08/10] don't accelerate KVM for different arch (arm64 vm on amd64 host) Signed-off-by: Rohit Yadav --- .../systemvmtemplate/template-base_x86_64-target_aarch64.json | 1 - 1 file changed, 1 deletion(-) diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json index 374d787588fa..ee5a53b0a4a4 100644 --- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json @@ -2,7 +2,6 @@ "_license": "Apache License 2.0", "builders": [ { - "accelerator": "kvm", "boot_command": [ "c", "linux /install.a64/vmlinuz ", From 468ecdd1488973e2797b489fe2023b6b65819842 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Wed, 24 Jul 2024 13:41:29 +0530 Subject: [PATCH 09/10] fix building arm64 on x86 Signed-off-by: Rohit Yadav --- tools/appliance/README.md | 9 +++++---- tools/appliance/build.sh | 14 +++++++------- .../template-base_x86_64-target_aarch64.json | 18 +++++++++--------- 3 files changed, 21 insertions(+), 20 deletions(-) diff --git a/tools/appliance/README.md b/tools/appliance/README.md index eae8b105220d..1aa5a17c4f91 100644 --- a/tools/appliance/README.md +++ b/tools/appliance/README.md @@ -41,9 +41,10 @@ CentOS based built-in user VM template. Just run build.sh, it will export archived appliances for KVM, XenServer, VMWare and HyperV in `dist` directory: - bash build.sh x86_64 systemvmtemplate - bash build.sh aarch64 systemvmtemplate + bash build.sh + bash build.sh systemvmtemplate 4.19.1.0 x86_64 + bash build.sh systemvmtemplate 4.19.1.0 aarch64 -For building builtin template run: +For building builtin x86_64 template run: - bash build.sh x86_64 builtin + bash build.sh builtin diff --git a/tools/appliance/build.sh b/tools/appliance/build.sh index c6fadcbd12fa..4865842d17b4 100755 --- a/tools/appliance/build.sh +++ b/tools/appliance/build.sh @@ -23,12 +23,12 @@ function usage() { Usage: ./build.sh [template] [version] [BUILD_NUMBER] - * Set \$target_arch to provide target architecture - (or use command line arg, default to current architecture. Currently x86_64 and aarch64 are implemented) * Set \$appliance to provide definition name to build (or use command line arg, default systemvmtemplate) * Set \$version to provide version to apply to built appliance (or use command line arg, default empty) + * Set \$target_arch to provide target architecture + (or use command line arg, default to current architecture. Currently x86_64 and aarch64 are implemented) * Set \$BUILD_NUMBER to provide build number to apply to built appliance (or use command line arg, default empty) * Set \$DEBUG=1 to enable debug logging @@ -90,14 +90,14 @@ fi # get current system architecture base_arch=`arch` -# which architecture to build the template for -target_arch="${1:-${target_arch:-${base_arch}}}" - # which packer definition to use -appliance="${2:-${appliance:-systemvmtemplate}}" +appliance="${1:-${appliance:-systemvmtemplate}}" # optional version tag to put into the image filename -version="${3:-${version:-}}" +version="${2:-${version:-}}" + +# which architecture to build the template for +target_arch="${3:-${target_arch:-${base_arch}}}" # optional (jenkins) build number tag to put into the image filename BUILD_NUMBER="${4:-${BUILD_NUMBER:-}}" diff --git a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json index ee5a53b0a4a4..4763d1e3e821 100644 --- a/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json +++ b/tools/appliance/systemvmtemplate/template-base_x86_64-target_aarch64.json @@ -18,11 +18,11 @@ "debconf/frontend=noninteractive ", "console-setup/ask_detect=false ", "console-keymaps-at/keymap=us ", - "---", + "---", "", - "initrd /install.a64/initrd.gz", - "", - "boot" + "initrd /install.a64/initrd.gz", + "", + "boot" ], "boot_wait": "60s", "disk_interface": "virtio", @@ -41,11 +41,11 @@ "-m", "500M" ], - [ + [ "-machine", "virt" ], - [ + [ "-cpu", "cortex-a72" ], @@ -53,9 +53,9 @@ "-smp", "1" ], - [ "-pflash", "/usr/share/AAVMF/AAVMF_CODE.fd" ], - [ "-monitor", "none" ], - [ "-boot", "strict=off" ] + [ "-bios", "/usr/share/qemu-efi-aarch64/QEMU_EFI.fd" ], + [ "-monitor", "none" ], + [ "-boot", "strict=off" ] ], "shutdown_command": "sudo halt -p", "ssh_password": "cloud", From c6900cde38b172503d9973e88912137c7dda2f29 Mon Sep 17 00:00:00 2001 From: Rohit Yadav Date: Thu, 25 Jul 2024 18:17:44 +0530 Subject: [PATCH 10/10] Update README.md --- tools/appliance/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/appliance/README.md b/tools/appliance/README.md index 1aa5a17c4f91..bc5b2014a59c 100644 --- a/tools/appliance/README.md +++ b/tools/appliance/README.md @@ -25,7 +25,8 @@ CentOS based built-in user VM template. # Setting up Tools and Environment -- Install packer and latest KVM, qemu on a Linux machine +- Install packer (v1.8.x, v1.9.x tested) and latest KVM, qemu on a Linux x86 + machine (Ubuntu 20.04 tested) - Install tools for exporting appliances: qemu-img, ovftool, faketime, sharutils - Build and install `vhd-util` as described in build.sh or use pre-built binaries at: