From: Michael Prokop Date: Tue, 21 Nov 2017 15:10:23 +0000 (+0100) Subject: packer: use latest VirtualBox Guest Additions ISO X-Git-Tag: v0.80~3 X-Git-Url: https://git.grml.org/?p=grml-debootstrap.git;a=commitdiff_plain;h=3314417c2d2dc914523186434b3352637ef7ea12;ds=sidebyside packer: use latest VirtualBox Guest Additions ISO Using the default local Virtualbox Guest Additions ISO will result in different builds depending on the system being used. My Debian jessie system with Virtualbox 5.1.8-dfsg-6~bpo8+2 from jessie-backports/contrib is actually too old to build stretch and newer as the kernel module can't be compiled. So instead use a specific VBoxGuestAdditions ISO, currently being the one recommended by upstream on https://www.virtualbox.org/ While at it: * increase VM memory size from 512MB to 1GB during build, otherwise we can't even use a temporary apt cache directory and will fail with OOM * check for build errors in virtualbox logs * /var/log/VBoxGuestAdditions.log doesn't necessarily exist, so instead display the last 10 lines of the according log files that actually exist --- diff --git a/packer/debian64.json b/packer/debian64.json index 7c45eee..bac55c1 100644 --- a/packer/debian64.json +++ b/packer/debian64.json @@ -26,7 +26,12 @@ "boot_command": [ " ssh=grml " ], - "shutdown_command": "shutdown -h now" + "shutdown_command": "shutdown -h now", + "guest_additions_url": "https://www.virtualbox.org/download/testcase/VBoxGuestAdditions_5.2.1-118918.iso", + "guest_additions_sha256": "5023b5b6314593c092d2680fbbfe37870977b1d7fa790af9bdd4a75944ca0603", + "vboxmanage": [ + ["modifyvm", "{{.Name}}", "--memory", "1024"] + ] } ], "provisioners": [ diff --git a/packer/debian64_provision.sh b/packer/debian64_provision.sh index c7eed1f..2a416de 100644 --- a/packer/debian64_provision.sh +++ b/packer/debian64_provision.sh @@ -67,7 +67,13 @@ virtualbox_setup() { mountpoint "${TARGET}/media/cdrom" >/dev/null && umount "${TARGET}/media/cdrom" mount -t iso9660 $isofile "${TARGET}/media/cdrom/" UTS_RELEASE=$KERNELVERSION LD_PRELOAD=/tmp/fake-uname.so grml-chroot "$TARGET" /media/cdrom/VBoxLinuxAdditions.run --nox11 || true - tail -10 "${TARGET}/var/log/VBoxGuestAdditions.log" + if grep -q "make: .*vboxguest.*Error 2" "${TARGET}/var/log/vboxadd-install.log" ; then + echo "Error: looks like a fatal error happened during installation of VirtualBox Guest Additions." >&2 + exit 1 + fi + [ -r "${TARGET}/var/log/VBoxGuestAdditions.log" ] && tail -10 "${TARGET}/var/log/VBoxGuestAdditions.log" + [ -r "${TARGET}/var/log/vboxadd-install.log" ] && tail -10 "${TARGET}/var/log/vboxadd-install.log" + [ -r "${TARGET}/var/log/vboxadd-setup.log" ] && tail -10 "${TARGET}/var/log/vboxadd-setup.log" umount "${TARGET}/media/cdrom/" # work around bug in VirtualBox 4.3.18 which leaves process behind,