Skip to content
This repository was archived by the owner on May 6, 2025. It is now read-only.

Commit 6cdbb98

Browse files
committed
Autodetect Linux/MacOS platform and set ACCELERATOR accordingly
1 parent fe466dc commit 6cdbb98

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

build.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ export VIRTIO_WIN_ISO=${VIRTIO_WIN_ISO:-${PACKER_CACHE_DIR}/$(basename "${VIRTIO
1010
export VIRTIO_WIN_ISO_DIR=${VIRTIO_WIN_ISO_DIR:-${PACKER_CACHE_DIR}/virtio-win}
1111
# Do not use any GUI X11 windows
1212
export HEADLESS=${HEADLESS:-true}
13-
# Qemu Accelerator - use kvm for Linux and hvf for MacOS
14-
export ACCELERATOR=${ACCELERATOR:-kvm}
1513
# Packer binary
1614
export PACKER_BINARY=${PACKER_BINARY:-packer}
1715
# Directory where all the images will be stored
@@ -20,8 +18,6 @@ export PACKER_IMAGES_OUTPUT_DIR=${PACKER_IMAGES_OUTPUT_DIR:-/var/tmp/packer-temp
2018
export LOGDIR=${LOGDIR:-/var/tmp/packer-templates-logs}
2119
# Enable packer debug log if set to 1 (default 0)
2220
export PACKER_LOG=${PACKER_LOG:-0}
23-
# Max amount of time which packer can run (default 5 hours) - this prevent packer form running forever when something goes bad during provisioning/build process
24-
export PACKER_RUN_TIMEOUT=${PACKER_RUN_TIMEOUT:-18000}
2521
# Use /var/tmp as temporary directory for Packer, because export of VM images can consume lot of disk space
2622
export TMPDIR=${TMPDIR:-/var/tmp}
2723

@@ -87,6 +83,12 @@ cmdline() {
8783
case ${PACKER_VAGRANT_PROVIDER} in
8884
libvirt )
8985
export PACKER_BUILDER_TYPE="qemu"
86+
# Qemu Accelerator - use kvm for Linux and hvf for MacOS
87+
if [[ $(uname) = "Darwin" ]]; then
88+
export ACCELERATOR=${ACCELERATOR:-hvf}
89+
elif [[ $(uname) = "Linux" ]]; then
90+
export ACCELERATOR=${ACCELERATOR:-kvm}
91+
fi
9092
;;
9193
virtualbox )
9294
export PACKER_BUILDER_TYPE="virtualbox-iso"

0 commit comments

Comments
 (0)