#!/bin/bash PACKER_LOG_FILE='./packer.log' SOURCES="$(for FILE in *.pkr.hcl; do cat $FILE | awk 'BEGIN{f=0} {if($1 ~ /build/ && $2 ~ /{/){f=1};if(f == 1){if($1 ~ /sources/ && $2 ~ /=/ && $3 ~ /\[/){f=2;next}};if(f == 2){if($1 ~ /\]/) {f=0}};if(f == 2){print $0}}' | sed -E 's/"//g;s/,//g;s/sources\.//g'; done)" SOURCE='' NO_PAKER_INIT='' NO_PKG_INSTALL='' # ------------------------------------------------------------------------------ Usage() { cat < [option] source name: EOF for SRC in $SOURCES; do echo -e "\t$SRC" done cat </dev/null; then install edk2-ovmf libvirt libvirt-daemon-kvm fi fi [ -z "$NO_PAKER_INIT" ] && packer init -upgrade . || exit 1 PACKER_LOG=1 packer build -only=$SOURCE . 2>$PACKER_LOG_FILE || exit 1 if [ "$SOURCE" = "vmware-iso.msvsphere-9-ovf-x86_64" ]; then OUT_DIR='./vmware-iso.msvsphere-9-ovf-x86_64_ovf' rm -rf $OUT_DIR mkdir $OUT_DIR /usr/lib/vmware-ovftool/ovftool --machineOutput --X:logFile=./ovftool.log --X:logLevel=verbose --exportFlags=extraconfig --allowExtraConfig --X:vCloudEnableGuestCustomization ./output-msvsphere-9-ovf-x86_64/msvsphere-9.4.vmx $OUT_DIR || exit 1 fi