From a3403b0fc366cae5c1a37fef79572c6f92f75d4d Mon Sep 17 00:00:00 2001 From: Kyle Isom Date: Wed, 12 Apr 2023 00:01:56 +0000 Subject: [PATCH] packer/build-image: format and build as root root is required for some of the build steps. --- packer/build-image.sh | 44 +++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/packer/build-image.sh b/packer/build-image.sh index 228988e..1d51767 100755 --- a/packer/build-image.sh +++ b/packer/build-image.sh @@ -10,29 +10,33 @@ errmsg () { } preflight () { - case "${IMAGE_TYPE}" in - ubuntu) PACKER_BUILD_FILE="boards/raspberry-pi-4/ubuntu_server_20.04_arm64.json" ;; - raspbian) PACKER_BUILD_FILE="boards/raspberry-pi/raspios-lite-arm.json" ;; - custom) - PACKER_BUILD_FILE="${2:-}" - if [ -z "${PACKER_BUILD_FILE}" ] - then - errmsg "[!] custom board requires a board file path" + case "${IMAGE_TYPE}" in + ubuntu) PACKER_BUILD_FILE="boards/raspberry-pi-4/ubuntu_server_20.04_arm64.json" ;; + raspbian) PACKER_BUILD_FILE="boards/raspberry-pi/raspios-lite-arm.json" ;; + custom) + PACKER_BUILD_FILE="${2:-}" + if [ -z "${PACKER_BUILD_FILE}" ] + then + errmsg "[!] custom board requires a board file path" + exit 1 + fi + ;; + *) + errmsg "[!] invalid image type ${IMAGE_TYPE}." + errmsg "[!] valid image types are" + errmsg " - raspbian" + errmsg " - ubuntu" + errmsg " - custom path/to/board/file" exit 1 - fi - ;; - *) - errmsg "[!] invalid image type ${IMAGE_TYPE}." - errmsg "[!] valid image types are" - errmsg " - raspbian" - errmsg " - ubuntu" - errmsg " - custom path/to/board/file" - exit 1 - ;; + ;; esac } build_image () { cd build/packer-builder-arm - packer build ${PACKER_BUILD_FILE} -} \ No newline at end of file + sudo packer build ${PACKER_BUILD_FILE} +} + +preflight +build_image +