From b34c9c6b0742d63c694f018dde953258100f03af Mon Sep 17 00:00:00 2001 From: Corey Hemminger Date: Fri, 26 Apr 2024 16:58:49 -0500 Subject: [PATCH] add macos build (#1566) - Require ruby >= 3.0.0 - Add parallels-ipsw source - Added MacOS template for parallels-ipsw - Created MacOS scripts - Adjusted build flags to all be lower case for consistency - Removed extra amazonlinux directories to be more consistent with other builds - Added build_files directory for all temp files to be stored in during packer building - Opensuse-leap-15.5 updated to 15.6 - Remove Fedora 38 and add 40 builds - Remove Ubuntu 23.10 and add 24.04 builds --- .github/workflows/ci-build.yml | 2 +- .github/workflows/pkr-bld-hyperv-x64.yml | 2 +- .github/workflows/pkr-bld-parallels-arm64.yml | 4 +- .github/workflows/pkr-bld-parallels-x64.yml | 4 +- .github/workflows/pkr-bld-qemu-arm64.yml | 4 +- .github/workflows/pkr-bld-qemu-x64.yml | 4 +- .../workflows/pkr-bld-virtualbox-arm64.yml | 4 +- .github/workflows/pkr-bld-virtualbox-x64.yml | 4 +- .github/workflows/pkr-bld-vmware-arm64.yml | 4 +- .github/workflows/pkr-bld-vmware-x64.yml | 4 +- CHANGELOG.md | 86 ++++++----- amazonlinux-2-x86_64-virtualbox-build.sh | 15 +- amazonlinux-2023-aarch64-virtualbox-build.sh | 14 +- amazonlinux-2023-x86_64-virtualbox-build.sh | 14 +- bento.gemspec | 2 +- builds.yml | 79 +++++----- builds/build_files/.gitkeep | 0 lib/bento/cli.rb | 10 +- lib/bento/test.rb | 4 +- lib/bento/upload.rb | 4 +- lib/bento/version.rb | 2 +- .../fedora/fedora-39-aarch64.pkrvars.hcl | 3 +- ...vars.hcl => fedora-40-aarch64.pkrvars.hcl} | 6 +- ...rvars.hcl => fedora-40-x86_64.pkrvars.hcl} | 6 +- os_pkrvars/macos/macos-14-aarch64.pkrvars.hcl | 73 +++++++++ .../opensuse-leap-15-aarch64.pkrvars.hcl | 6 +- .../opensuse-leap-15-x86_64.pkrvars.hcl | 6 +- ...s.hcl => ubuntu-24.04-aarch64.pkrvars.hcl} | 6 +- ...rs.hcl => ubuntu-24.04-x86_64.pkrvars.hcl} | 6 +- packer_templates/amz_seed_iso/README.md | 1 - packer_templates/amz_working_files/README.md | 1 - .../{amz_seed_iso => http/amazon}/meta-data | 0 .../{amz_seed_iso => http/amazon}/user-data | 0 packer_templates/http/ubuntu/user-data | 6 +- packer_templates/pkr-builder.pkr.hcl | 146 ++++++++++-------- packer_templates/pkr-sources.pkr.hcl | 61 ++++++-- packer_templates/pkr-variables.pkr.hcl | 27 ++++ packer_templates/scripts/_common/motd.sh | 7 +- packer_templates/scripts/_common/vagrant.sh | 6 +- .../scripts/macos/parallels-tools.sh | 12 ++ packer_templates/scripts/macos/shrink.sh | 37 +++++ .../scripts/macos/system-default.sh | 32 ++++ .../scripts/macos/system-update.sh | 16 ++ packer_templates/scripts/macos/vagrant.sh | 30 ++++ .../scripts/macos/vmware-tools.sh | 48 ++++++ 45 files changed, 579 insertions(+), 229 deletions(-) create mode 100644 builds/build_files/.gitkeep rename os_pkrvars/fedora/{fedora-38-aarch64.pkrvars.hcl => fedora-40-aarch64.pkrvars.hcl} (59%) rename os_pkrvars/fedora/{fedora-38-x86_64.pkrvars.hcl => fedora-40-x86_64.pkrvars.hcl} (59%) create mode 100644 os_pkrvars/macos/macos-14-aarch64.pkrvars.hcl rename os_pkrvars/ubuntu/{ubuntu-23.10-aarch64.pkrvars.hcl => ubuntu-24.04-aarch64.pkrvars.hcl} (69%) rename os_pkrvars/ubuntu/{ubuntu-23.10-x86_64.pkrvars.hcl => ubuntu-24.04-x86_64.pkrvars.hcl} (61%) delete mode 100644 packer_templates/amz_seed_iso/README.md delete mode 100644 packer_templates/amz_working_files/README.md rename packer_templates/{amz_seed_iso => http/amazon}/meta-data (100%) rename packer_templates/{amz_seed_iso => http/amazon}/user-data (100%) create mode 100644 packer_templates/scripts/macos/parallels-tools.sh create mode 100644 packer_templates/scripts/macos/shrink.sh create mode 100644 packer_templates/scripts/macos/system-default.sh create mode 100644 packer_templates/scripts/macos/system-update.sh create mode 100644 packer_templates/scripts/macos/vagrant.sh create mode 100644 packer_templates/scripts/macos/vmware-tools.sh diff --git a/.github/workflows/ci-build.yml b/.github/workflows/ci-build.yml index 59932627c..4caf23c95 100644 --- a/.github/workflows/ci-build.yml +++ b/.github/workflows/ci-build.yml @@ -31,7 +31,7 @@ jobs: packer-iso-check: uses: chef/github-workflows/.github/workflows/packer-iso-url-checker.yml@main with: - EXCLUDE_REGEX: 'amazonlinux-2.*|rhel.*|sles.*|solaris.*|windows-11-aarch64.*' + EXCLUDE_REGEX: 'amazonlinux-2.*|rhel.*|sles.*|solaris.*|windows-11-aarch64.*,macos-*' packer-lint: uses: chef/github-workflows/.github/workflows/packer-lint.yml@main diff --git a/.github/workflows/pkr-bld-hyperv-x64.yml b/.github/workflows/pkr-bld-hyperv-x64.yml index 833ce338c..7002d7f76 100644 --- a/.github/workflows/pkr-bld-hyperv-x64.yml +++ b/.github/workflows/pkr-bld-hyperv-x64.yml @@ -32,7 +32,7 @@ jobs: - rockylinux-9 - ubuntu-20.04 - ubuntu-22.04 - - ubuntu-23.10 + - ubuntu-24.04 provider: - hyperv-iso steps: diff --git a/.github/workflows/pkr-bld-parallels-arm64.yml b/.github/workflows/pkr-bld-parallels-arm64.yml index 626841710..6934da07f 100644 --- a/.github/workflows/pkr-bld-parallels-arm64.yml +++ b/.github/workflows/pkr-bld-parallels-arm64.yml @@ -20,8 +20,8 @@ jobs: - centos-stream-9 - debian-11 - debian-12 - - fedora-38 - fedora-39 + - fedora-40 - freebsd-13 - freebsd-14 - opensuse-leap-15 @@ -32,7 +32,7 @@ jobs: - rockylinux-9 - ubuntu-20.04 - ubuntu-22.04 - - ubuntu-23.10 + - ubuntu-24.04 provider: - parallels-iso steps: diff --git a/.github/workflows/pkr-bld-parallels-x64.yml b/.github/workflows/pkr-bld-parallels-x64.yml index aa1a55797..9af99ba4c 100644 --- a/.github/workflows/pkr-bld-parallels-x64.yml +++ b/.github/workflows/pkr-bld-parallels-x64.yml @@ -20,8 +20,8 @@ jobs: - centos-stream-9 - debian-11 - debian-12 - - fedora-38 - fedora-39 + - fedora-40 - freebsd-13 - freebsd-14 - opensuse-leap-15 @@ -32,7 +32,7 @@ jobs: - rockylinux-9 - ubuntu-20.04 - ubuntu-22.04 - - ubuntu-23.10 + - ubuntu-24.04 provider: - parallels-iso steps: diff --git a/.github/workflows/pkr-bld-qemu-arm64.yml b/.github/workflows/pkr-bld-qemu-arm64.yml index e32c89878..944f8c95f 100644 --- a/.github/workflows/pkr-bld-qemu-arm64.yml +++ b/.github/workflows/pkr-bld-qemu-arm64.yml @@ -20,8 +20,8 @@ jobs: - centos-stream-9 - debian-11 - debian-12 - - fedora-38 - fedora-39 + - fedora-40 - freebsd-13 - freebsd-14 - opensuse-leap-15 @@ -32,7 +32,7 @@ jobs: - rockylinux-9 - ubuntu-20.04 - ubuntu-22.04 - - ubuntu-23.10 + - ubuntu-24.04 provider: - qemu steps: diff --git a/.github/workflows/pkr-bld-qemu-x64.yml b/.github/workflows/pkr-bld-qemu-x64.yml index 86e2dc5a3..5bb0eee9b 100644 --- a/.github/workflows/pkr-bld-qemu-x64.yml +++ b/.github/workflows/pkr-bld-qemu-x64.yml @@ -20,8 +20,8 @@ jobs: - centos-stream-9 - debian-11 - debian-12 - - fedora-38 - fedora-39 + - fedora-40 - freebsd-13 - freebsd-14 - opensuse-leap-15 @@ -32,7 +32,7 @@ jobs: - rockylinux-9 - ubuntu-20.04 - ubuntu-22.04 - - ubuntu-23.10 + - ubuntu-24.04 provider: - qemu steps: diff --git a/.github/workflows/pkr-bld-virtualbox-arm64.yml b/.github/workflows/pkr-bld-virtualbox-arm64.yml index f97be204e..d649e759c 100644 --- a/.github/workflows/pkr-bld-virtualbox-arm64.yml +++ b/.github/workflows/pkr-bld-virtualbox-arm64.yml @@ -20,8 +20,8 @@ jobs: - centos-stream-9 - debian-11 - debian-12 - - fedora-38 - fedora-39 + - fedora-40 - freebsd-13 - freebsd-14 - opensuse-leap-15 @@ -32,7 +32,7 @@ jobs: - rockylinux-9 - ubuntu-20.04 - ubuntu-22.04 - - ubuntu-23.10 + - ubuntu-24.04 provider: - virtualbox-iso steps: diff --git a/.github/workflows/pkr-bld-virtualbox-x64.yml b/.github/workflows/pkr-bld-virtualbox-x64.yml index 7638f9875..2aafba2ae 100644 --- a/.github/workflows/pkr-bld-virtualbox-x64.yml +++ b/.github/workflows/pkr-bld-virtualbox-x64.yml @@ -20,8 +20,8 @@ jobs: - centos-stream-9 - debian-11 - debian-12 - - fedora-38 - fedora-39 + - fedora-40 - freebsd-13 - freebsd-14 - opensuse-leap-15 @@ -32,7 +32,7 @@ jobs: - rockylinux-9 - ubuntu-20.04 - ubuntu-22.04 - - ubuntu-23.10 + - ubuntu-24.04 provider: - virtualbox-iso steps: diff --git a/.github/workflows/pkr-bld-vmware-arm64.yml b/.github/workflows/pkr-bld-vmware-arm64.yml index ecb3a0c5b..567e56ccd 100644 --- a/.github/workflows/pkr-bld-vmware-arm64.yml +++ b/.github/workflows/pkr-bld-vmware-arm64.yml @@ -20,8 +20,8 @@ jobs: - centos-stream-9 - debian-11 - debian-12 - - fedora-38 - fedora-39 + - fedora-40 - freebsd-13 - freebsd-14 - opensuse-leap-15 @@ -32,7 +32,7 @@ jobs: - rockylinux-9 - ubuntu-20.04 - ubuntu-22.04 - - ubuntu-23.10 + - ubuntu-24.04 provider: - vmware-iso steps: diff --git a/.github/workflows/pkr-bld-vmware-x64.yml b/.github/workflows/pkr-bld-vmware-x64.yml index 8e1bcaa57..71a95f361 100644 --- a/.github/workflows/pkr-bld-vmware-x64.yml +++ b/.github/workflows/pkr-bld-vmware-x64.yml @@ -20,8 +20,8 @@ jobs: - centos-stream-9 - debian-11 - debian-12 - - fedora-38 - fedora-39 + - fedora-40 - freebsd-13 - freebsd-14 - opensuse-leap-15 @@ -32,7 +32,7 @@ jobs: - rockylinux-9 - ubuntu-20.04 - ubuntu-22.04 - - ubuntu-23.10 + - ubuntu-24.04 provider: - vmware-iso steps: diff --git a/CHANGELOG.md b/CHANGELOG.md index 04b123644..1a3583a05 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,41 +5,42 @@ ***Note:** Markdown table generated at -| | hyperv
x86_64 | parallels
x86_64 | parallels
aarch64 | qemu
x86_64 | qemu
aarch64 | virtualbox
x86_64 | virtualbox
aarch64 | vmware
x86_64 | vmware
aarch64 | -|:----------------:|:---:|:-------------------:|:--------------------:|:---:|:---:|:--------------------:|:---:|:-----------------:|:-----------------:| -| almalinux-8 | | x | | x | | x | | x | | -| almalinux-9 | | x | x | | | x | | x | x | -| amazonlinux-2 | | | | | | x | | | | -| amazonlinux-2023 | | | | | | x | | | | -| centos-7 | | x | | x | | x | | x | | -| centos-stream-8 | | x | | x | | x | | x | | -| centos-stream-9 | | | x | | | | | | | -| debian-11 | | x | x | | | x | | x | | -| debian-12 | | x | x | | | x | | x | x | -| fedora-38 | | x | | x | | x | | x | x | -| fedora-39 | | | | | | | | | | -| freebsd-13 | | | | | | x | | x | x | -| freebsd-14 | | | | | | x | | x | | -| opensuse-leap-15 | | x | | x | | x | | x | | -| oraclelinux-7 | | x | | x | | x | | x | | -| oraclelinux-8 | | | | x | | x | | x | | -| oraclelinux-9 | | x | x | | | x | | x | | -| rhel-7 | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | -| rhel-8 | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | -| rhel-9 | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | -| rockylinux-8 | | x | | x | | x | | x | | -| rockylinux-9 | | x | | | | x | | x | x | -| sles-12 | license
needed | license
needed | na | license
needed | na | license
needed | na | license
needed | na | -| sles-13 | license
needed | license
needed | na | license
needed | na | license
needed | na | license
needed | na | -| solaris-11 | license
needed | license
needed | na | license
needed | na | license
needed | na | license
needed | na | -| ubuntu-20.04 | | x | x | | | x | | x | x | -| ubuntu-22.04 | | x | | x | | x | | x | | -| ubuntu-23.10 | | x | x | | | x | | x | x | -| windows-10 | | x | na | | na | x | na | | na | -| windows-11 | | x | x | | na | x | na | | | -| windows-2016 | | x | na | | na | x | na | | na | -| windows-2019 | | x | na | | na | x | na | | na | -| windows-2022 | | x | na | | na | x | na | | na | +| os | hyperv
x86_64 | parallels
x86_64 | parallels
aarch64 | qemu
x86_64 | qemu
aarch64 | virtualbox
x86_64 | virtualbox
aarch64 | vmware
x86_64 | vmware
aarch64 | +|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:| +| almalinux-8 | | x | | | | x | | x | | +| almalinux-9 | | x | | | | x | | x | x | +| amazonlinux-2 | | | | | | x | | | | +| amazonlinux-2023 | | | | | | x | | | | +| centos-7 | | | | | | x | | x | | +| centos-stream-8 | | x | | | | x | | x | | +| centos-stream-9 | | x | | | | x | | x | x | +| debian-11 | | x | x | | | x | | x | | +| debian-12 | | x | x | | | x | | x | x | +| fedora-39 | | x | x | | | x | | x | x | +| fedora-40 | | | | | | | | | | +| freebsd-13 | | | | | | x | | x | x | +| freebsd-14 | | | | | | | | | | +| macos | | | x | | | | | | | +| opensuse-leap-15 | | | | | | x | | x | x | +| oraclelinux-7 | | x | | | | x | | x | | +| oraclelinux-8 | | | | | | x | | x | | +| oraclelinux-9 | | x | x | | | x | | x | x | +| rhel-7 | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | +| rhel-8 | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | +| rhel-9 | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | license
needed | +| rockylinux-8 | | x | | | | x | | x | | +| rockylinux-9 | | x | | | | x | | x | x | +| sles-12 | license
needed | license
needed | na | license
needed | na | license
needed | na | license
needed | na | +| sles-15 | license
needed | license
needed | na | license
needed | na | license
needed | na | license
needed | na | +| solaris-11 | license
needed | license
needed | na | license
needed | na | license
needed | na | license
needed | na | +| ubuntu-20.04 | | | x | | | x | | x | x | +| ubuntu-22.04 | | x | | | | x | | | | +| ubuntu-24.04 | | x | x | | | x | | x | x | +| windows-10 | | | na | | na | x | na | | na | +| windows-11 | | x | x | | | x | | x | | +| windows-2016 | | x | na | | na | x | na | x | na | +| windows-2019 | | x | na | | na | x | na | x | na | +| windows-2022 | | x | na | | na | x | na | | na | ### Todo @@ -53,7 +54,20 @@ Markdown table generated at - Create CD pipeline to upload vagrant boxes after PR is merged - Create CD pipeline to build and upload new versions of vagrant boxes once every 3 months with the latest patches -## [unreleased] (2024-04-11) +## [unreleased] (2024-04-26) + +## [v4.1.1] (2024-04-26) + +- Require ruby >= 3.0.0 +- Add parallels-ipsw source +- Added MacOS template for parallels-ipsw +- Created MacOS scripts +- Adjusted build flags to all be lower case for consistency +- Removed extra amazonlinux directories to be more consistent with other builds +- Added build_files directory for all temp files to be stored in during packer building +- Opensuse-leap-15.5 updated to 15.6 +- Remove Fedora 38 and add 40 builds +- Remove Ubuntu 23.10 and add 24.04 builds ## [v4.1.0] (2024-04-11) diff --git a/amazonlinux-2-x86_64-virtualbox-build.sh b/amazonlinux-2-x86_64-virtualbox-build.sh index 9bddec904..b7d8e0775 100755 --- a/amazonlinux-2-x86_64-virtualbox-build.sh +++ b/amazonlinux-2-x86_64-virtualbox-build.sh @@ -5,8 +5,8 @@ SCRIPT_RELATIVE_DIR=$(dirname "${BASH_SOURCE[0]}") cd "$SCRIPT_RELATIVE_DIR" || exit # set tmp dir for files -AMZDIR="$(pwd)/packer_templates/amz_working_files" - +AMZDIR="$(pwd)/builds/build_files/amazonlinux-2-x86_64-virtualbox" +mkdir -p "$AMZDIR" # Get virtualbox vdi file name with latest version number IMG="$(wget -q https://cdn.amazonlinux.com/os-images/latest/virtualbox/ -O - | grep ".vdi" | cut -d "\"" -f 2)" @@ -24,12 +24,13 @@ echo "Cleaning up old files" rm -f "$AMZDIR"/*.iso "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk echo "Creating ISO" +SEED_ISO_DIR="$(pwd)/packer_templates/http/amazon" if [ -x "$(command -v genisoimage)" ]; then - genisoimage -output "$AMZDIR"/seed.iso -volid cidata -joliet -rock "$AMZDIR"/../amz_seed_iso/user-data "$AMZDIR"/../amz_seed_iso/meta-data + genisoimage -output "$AMZDIR"/seed.iso -volid cidata -joliet -rock "$SEED_ISO_DIR"/user-data "$SEED_ISO_DIR"/meta-data elif [ -x "$(command -v hdiutil)" ]; then - hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso + hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$SEED_ISO_DIR"/ elif [ -x "$(command -v mkisofs)" ]; then - mkfsiso9660 -o "$AMZDIR"/seed.iso "$AMZDIR"/../amz_seed_iso + mkfsiso9660 -o "$AMZDIR"/seed.iso "$SEED_ISO_DIR"/ else echo "No tool found to create the seed.iso" exit 1 @@ -68,9 +69,9 @@ echo Deleting the VM vboxmanage unregistervm $VM --delete echo starting packer build of amazonlinux -if bento build --vars vbox_source_path="$AMZDIR"/amazon2_x86_64.ovf,vbox_checksum=null "$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl; then +if bento build --vars vbox_source_path="$AMZDIR"/amazon2_x86_64.ovf,vbox_checksum=null "$(pwd)"/os_pkrvars/amazonlinux/amazonlinux-2-x86_64.pkrvars.hcl; then echo "Cleaning up files" - rm -f "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.iso + rm -f "$AMZDIR" else exit 1 fi diff --git a/amazonlinux-2023-aarch64-virtualbox-build.sh b/amazonlinux-2023-aarch64-virtualbox-build.sh index 2bee4bf56..bdb1a01e0 100755 --- a/amazonlinux-2023-aarch64-virtualbox-build.sh +++ b/amazonlinux-2023-aarch64-virtualbox-build.sh @@ -5,7 +5,8 @@ SCRIPT_RELATIVE_DIR=$(dirname "${BASH_SOURCE[0]}") cd "$SCRIPT_RELATIVE_DIR" || exit # set tmp dir for files -AMZDIR="$(pwd)/packer_templates/amz_working_files" +AMZDIR="$(pwd)/builds/build_files/amazonlinux-2023-aarch64-virtualbox" +mkdir -p "$AMZDIR" echo "Cleaning up old files" rm -f "$AMZDIR"/*.iso "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.vdi @@ -26,12 +27,13 @@ if [ ! -f "$AMZDIR"/amazon2023_arm64.vdi ]; then fi echo "Creating ISO" +SEED_ISO_DIR="$(pwd)/packer_templates/http/amazon" if [ -x "$(command -v genisoimage)" ]; then - genisoimage -output "$AMZDIR"/seed.iso -volid cidata -joliet -rock "$AMZDIR"/../amz_seed_iso/user-data "$AMZDIR"/../amz_seed_iso/meta-data + genisoimage -output "$AMZDIR"/seed.iso -volid cidata -joliet -rock "$SEED_ISO_DIR"/user-data "$SEED_ISO_DIR"/meta-data elif [ -x "$(command -v hdiutil)" ]; then - hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso + hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$SEED_ISO_DIR"/ elif [ -x "$(command -v mkisofs)" ]; then - mkfsiso9660 -o "$AMZDIR"/seed.iso "$AMZDIR"/../amz_seed_iso + mkfsiso9660 -o "$AMZDIR"/seed.iso "$SEED_ISO_DIR"/ else echo "No tool found to create the seed.iso" exit 1 @@ -76,9 +78,9 @@ echo "Deleting the VM" vboxmanage unregistervm $VM --delete echo "starting packer build of amazonlinux" -if bento build --vars vbox_source_path="$AMZDIR"/amazon2023_arm64.ovf,vbox_checksum=null "$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2023-aarch64.pkrvars.hcl; then +if bento build --vars vbox_source_path="$AMZDIR"/amazon2023_arm64.ovf,vbox_checksum=null "$(pwd)"/os_pkrvars/amazonlinux/amazonlinux-2023-aarch64.pkrvars.hcl; then echo "Cleaning up files" - rm -f "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.iso "$AMZDIR"/*.vdi "$AMZDIR"/*.qcow2 + rm -f "$AMZDIR" else exit 1 fi diff --git a/amazonlinux-2023-x86_64-virtualbox-build.sh b/amazonlinux-2023-x86_64-virtualbox-build.sh index 0591f6a86..da6d3d097 100755 --- a/amazonlinux-2023-x86_64-virtualbox-build.sh +++ b/amazonlinux-2023-x86_64-virtualbox-build.sh @@ -5,7 +5,8 @@ SCRIPT_RELATIVE_DIR=$(dirname "${BASH_SOURCE[0]}") cd "$SCRIPT_RELATIVE_DIR" || exit # set tmp dir for files -AMZDIR="$(pwd)/packer_templates/amz_working_files" +AMZDIR="$(pwd)/builds/build_files/amazonlinux-2023-x86_64-virtualbox" +mkdir -p "$AMZDIR" echo "Cleaning up old files" rm -f "$AMZDIR"/*.iso "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.vdi @@ -26,12 +27,13 @@ if [ ! -f "$AMZDIR"/amazon2023_x86_64.vdi ]; then fi echo "Creating ISO" +SEED_ISO_DIR="$(pwd)/packer_templates/http/amazon" if [ -x "$(command -v genisoimage)" ]; then - genisoimage -output "$AMZDIR"/seed.iso -volid cidata -joliet -rock "$AMZDIR"/../amz_seed_iso/user-data "$AMZDIR"/../amz_seed_iso/meta-data + genisoimage -output "$AMZDIR"/seed.iso -volid cidata -joliet -rock "$SEED_ISO_DIR"/user-data "$SEED_ISO_DIR"/meta-data elif [ -x "$(command -v hdiutil)" ]; then - hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$AMZDIR"/../amz_seed_iso + hdiutil makehybrid -o "$AMZDIR"/seed.iso -hfs -joliet -iso -default-volume-name cidata "$SEED_ISO_DIR"/ elif [ -x "$(command -v mkisofs)" ]; then - mkfsiso9660 -o "$AMZDIR"/seed.iso "$AMZDIR"/../amz_seed_iso + mkfsiso9660 -o "$AMZDIR"/seed.iso "$SEED_ISO_DIR"/ else echo "No tool found to create the seed.iso" exit 1 @@ -74,9 +76,9 @@ echo "Deleting the VM" vboxmanage unregistervm $VM --delete echo "starting packer build of amazonlinux" -if bento build --vars vbox_source_path="$AMZDIR"/amazon2023_x86_64.ovf,vbox_checksum=null "$AMZDIR"/../../os_pkrvars/amazonlinux/amazonlinux-2023-x86_64.pkrvars.hcl; then +if bento build --vars vbox_source_path="$AMZDIR"/amazon2023_x86_64.ovf,vbox_checksum=null "$(pwd)"/os_pkrvars/amazonlinux/amazonlinux-2023-x86_64.pkrvars.hcl; then echo "Cleaning up files" - rm -f "$AMZDIR"/*.ovf "$AMZDIR"/*.vmdk "$AMZDIR"/*.iso "$AMZDIR"/*.vdi "$AMZDIR"/*.qcow2 + rm -f "$AMZDIR" else exit 1 fi diff --git a/bento.gemspec b/bento.gemspec index 51343bad0..23dfd1fd0 100644 --- a/bento.gemspec +++ b/bento.gemspec @@ -11,7 +11,7 @@ Gem::Specification.new do |s| s.email = 'oss@chef.io' s.homepage = 'https://github.com/chef/bento/' - s.required_ruby_version = '>= 2.6' + s.required_ruby_version = '>= 3.0' s.add_dependency 'mixlib-shellout', '>= 2.3.2' s.add_dependency 'test-kitchen' diff --git a/builds.yml b/builds.yml index 873b50a90..373d0b86d 100644 --- a/builds.yml +++ b/builds.yml @@ -2,49 +2,50 @@ vagrant_cloud_account: 'bento' default_architectures: - - 'x86_64' - - 'amd64' + - x86_64 + - amd64 public: - - 'amazonlinux-2' - - 'amazonlinux-2023' - - 'almalinux-8' - - 'almalinux-9' - - 'centos-7' - - 'centos-stream-8' - - 'centos-stream-9' - - 'debian-11' - - 'debian-12' - - 'fedora-38' - - 'fedora-39' - - 'freebsd-13' - - 'freebsd-14' - - 'opensuse-leap-15' - - 'oraclelinux-7' - - 'oraclelinux-8' - - 'oraclelinux-9' - - 'rockylinux-8' - - 'rockylinux-9' - - 'ubuntu-20.04' - - 'ubuntu-22.04' - - 'ubuntu-23.10' + - amazonlinux-2 + - amazonlinux-2023 + - almalinux-8 + - almalinux-9 + - centos-7 + - centos-stream-8 + - centos-stream-9 + - debian-11 + - debian-12 + - fedora-39 + - fedora-40 + - freebsd-13 + - freebsd-14 + - opensuse-leap-15 + - oraclelinux-7 + - oraclelinux-8 + - oraclelinux-9 + - rockylinux-8 + - rockylinux-9 + - ubuntu-20.04 + - ubuntu-22.04 + - ubuntu-24.04 -# slug box name: text string from standard box name to match (generally the same) +# slug box name: text string from standard box name to match slugs: - 'almalinux-8': 'almalinux-8' - 'almalinux-9': 'almalinux-9' - 'centos-7': 'centos-7' - 'debian-12': 'debian-12' - 'debian-11': 'debian-11' - 'fedora-latest': 'fedora-39' - 'freebsd-13': 'freebsd-13' - 'freebsd-14': 'freebsd-14' - 'opensuse-leap-15': 'opensuse-leap-15' - 'oracle-7': 'oracle-7' - 'oracle-8': 'oracle-8' - 'oracle-9': 'oracle-9' - 'rockylinux-8': 'rockylinux-8' - 'rockylinux-9': 'rockylinux-9' + - almalinux-8 + - almalinux-9 + - centos-7 + - debian-12 + - debian-11 + - fedora-latest + - freebsd-13 + - freebsd-14 + - opensuse-leap-15 + - oracle-7 + - oracle-8 + - oracle-9 + - rockylinux-8 + - rockylinux-9 + - macos-14 do_not_build: - amazon diff --git a/builds/build_files/.gitkeep b/builds/build_files/.gitkeep new file mode 100644 index 000000000..e69de29bb diff --git a/lib/bento/cli.rb b/lib/bento/cli.rb index e68ab53c8..696dd5c7d 100644 --- a/lib/bento/cli.rb +++ b/lib/bento/cli.rb @@ -85,7 +85,7 @@ def self.parse(args) options.metadata_only = opt end - opts.on('--on-error', '[cleanup|abort|ask|run-cleanup-provisioner] If the build fails do: clean up (default), abort, ask, or run-cleanup-provisioner.') do |opt| + opts.on('--on-error OPT', '[cleanup|abort|ask|run-cleanup-provisioner] If the build fails do: clean up (default), abort, ask, or run-cleanup-provisioner.') do |opt| options.on_error = opt end @@ -109,15 +109,15 @@ def self.parse(args) options.except = opt end - opts.on('-m MIRROR', '--mirror MIRROR', 'Look for isos at MIRROR') do |opt| + opts.on('-M MIRROR', '--mirror MIRROR', 'Look for isos at MIRROR') do |opt| options.mirror = opt end - opts.on('-C cpus', '--cpus CPUS', '# of CPUs per provider') do |opt| + opts.on('-c CPUS', '--cpus CPUS', '# of CPUs per provider') do |opt| options.cpus = opt end - opts.on('-M MEMORY', '--memory MEMORY', 'Memory (MB) per provider') do |opt| + opts.on('-m MEMORY', '--memory MEMORY', 'Memory (MB) per provider') do |opt| options.mem = opt end @@ -125,7 +125,7 @@ def self.parse(args) options.headed = opt end - opts.on('-S', '--single', 'Disable parallelization of Packer builds') do |opt| + opts.on('-s', '--single', 'Disable parallelization of Packer builds') do |opt| options.single = opt end diff --git a/lib/bento/test.rb b/lib/bento/test.rb index 0d733aa15..5bdbc4952 100644 --- a/lib/bento/test.rb +++ b/lib/bento/test.rb @@ -27,7 +27,9 @@ def start end end banner("Testing finished in #{duration(time.real)}.") - unless errors.empty? + if errors.empty? + banner('All tests passed.') + else raise("Failed Tests:\n#{errors.join("\n")}\nexited #{$CHILD_STATUS}") end end diff --git a/lib/bento/upload.rb b/lib/bento/upload.rb index 582cc9d70..078902800 100644 --- a/lib/bento/upload.rb +++ b/lib/bento/upload.rb @@ -74,8 +74,8 @@ def upload_box(md_file) # @return [String, NilClass] The slug name or nil # def lookup_slug(name) - builds_yml['slugs'].each_pair do |slug, match_string| - return slug if name.start_with?(match_string) + builds_yml['slugs'].each do |slug| + return slug if name.start_with?(slug) end nil diff --git a/lib/bento/version.rb b/lib/bento/version.rb index 4cb808c14..30e078423 100644 --- a/lib/bento/version.rb +++ b/lib/bento/version.rb @@ -1,3 +1,3 @@ module Bento - VERSION = '4.1.0'.freeze + VERSION = '4.1.1'.freeze end diff --git a/os_pkrvars/fedora/fedora-39-aarch64.pkrvars.hcl b/os_pkrvars/fedora/fedora-39-aarch64.pkrvars.hcl index 3ad5175de..b6e1b86db 100644 --- a/os_pkrvars/fedora/fedora-39-aarch64.pkrvars.hcl +++ b/os_pkrvars/fedora/fedora-39-aarch64.pkrvars.hcl @@ -1,4 +1,3 @@ - os_name = "fedora" os_version = "39" os_arch = "aarch64" @@ -7,4 +6,4 @@ iso_checksum = "sha256:d19dc2a39758155fa53e6fd555d0d173ccc8175b55dea4 parallels_guest_os_type = "fedora-core" vbox_guest_os_type = "Fedora_64" vmware_guest_os_type = "arm-fedora-64" -boot_command = ["e inst.text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/fedora/ks.cfg"] \ No newline at end of file +boot_command = ["e inst.text inst.ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/fedora/ks.cfg"] diff --git a/os_pkrvars/fedora/fedora-38-aarch64.pkrvars.hcl b/os_pkrvars/fedora/fedora-40-aarch64.pkrvars.hcl similarity index 59% rename from os_pkrvars/fedora/fedora-38-aarch64.pkrvars.hcl rename to os_pkrvars/fedora/fedora-40-aarch64.pkrvars.hcl index fe5750727..24c62af3a 100644 --- a/os_pkrvars/fedora/fedora-38-aarch64.pkrvars.hcl +++ b/os_pkrvars/fedora/fedora-40-aarch64.pkrvars.hcl @@ -1,8 +1,8 @@ os_name = "fedora" -os_version = "38" +os_version = "40" os_arch = "aarch64" -iso_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/38/Server/aarch64/iso/Fedora-Server-dvd-aarch64-38-1.6.iso" -iso_checksum = "sha256:0b40485d74fc60c0a78f071396aba78fafb2f8f3b1ab4cbc3388bda82f764f9b" +iso_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/40/Server/aarch64/iso/Fedora-Server-dvd-aarch64-40-1.14.iso" +iso_checksum = "file:https://download.fedoraproject.org/pub/fedora/linux/releases/40/Server/aarch64/iso/Fedora-Server-40-1.14-aarch64-CHECKSUM" parallels_guest_os_type = "fedora-core" vbox_guest_os_type = "Fedora_64" vmware_guest_os_type = "arm-fedora-64" diff --git a/os_pkrvars/fedora/fedora-38-x86_64.pkrvars.hcl b/os_pkrvars/fedora/fedora-40-x86_64.pkrvars.hcl similarity index 59% rename from os_pkrvars/fedora/fedora-38-x86_64.pkrvars.hcl rename to os_pkrvars/fedora/fedora-40-x86_64.pkrvars.hcl index 2ae962cb3..18aec053c 100644 --- a/os_pkrvars/fedora/fedora-38-x86_64.pkrvars.hcl +++ b/os_pkrvars/fedora/fedora-40-x86_64.pkrvars.hcl @@ -1,8 +1,8 @@ os_name = "fedora" -os_version = "38" +os_version = "40" os_arch = "x86_64" -iso_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/38/Server/x86_64/iso/Fedora-Server-dvd-x86_64-38-1.6.iso" -iso_checksum = "sha256:66b52d7cb39386644cd740930b0bef0a5a2f2be569328fef6b1f9b3679fdc54d" +iso_url = "https://download.fedoraproject.org/pub/fedora/linux/releases/40/Server/x86_64/iso/Fedora-Server-dvd-x86_64-40-1.14.iso" +iso_checksum = "file:https://download.fedoraproject.org/pub/fedora/linux/releases/40/Server/x86_64/iso/Fedora-Server-40-1.14-x86_64-CHECKSUM" parallels_guest_os_type = "fedora-core" vbox_guest_os_type = "Fedora_64" vmware_guest_os_type = "fedora-64" diff --git a/os_pkrvars/macos/macos-14-aarch64.pkrvars.hcl b/os_pkrvars/macos/macos-14-aarch64.pkrvars.hcl new file mode 100644 index 000000000..d488f91bc --- /dev/null +++ b/os_pkrvars/macos/macos-14-aarch64.pkrvars.hcl @@ -0,0 +1,73 @@ +os_name = "macos" +os_version = "14.4.1" +os_arch = "aarch64" +parallels_ipsw_url = "https://updates.cdn-apple.com/2024WinterFCS/fullrestores/052-77579/4569734E-120C-4F31-AD08-FC1FF825D059/UniversalMac_14.4.1_23E224_Restore.ipsw" +parallels_ipsw_checksum = "78b39816521a6eeaf29221a4e59e83dae98ef5f9e8e718b846f8faab540a48c1" +sources_enabled = ["source.parallels-ipsw.vm"] +boot_command = [ + # hello, hola, bonjour, etc. + "", + # Select Language English (US) + "", + # Select Your Country and Region + "", + # Written and Spoken Languages + "", + # Accessibility + "", + # Data & Privacy + "", + # Migration Assistant + "", + # Sign In with Your Apple ID + "", + # Are you sure you want to skip signing in with an Apple ID? + "", + # Terms and Conditions + "", + # I have read and agree to the macOS Software License Agreement + "", + # Create a Computer Account + "vagrantvagrantvagrant", + # Enable Location Services + "", + # Are you sure you don't want to use Location Services? + "", + # Select Your Time Zone + "UTC", + # Analytics + "", + # Screen Time + "", + # Siri + "", + # Choose Your Look + "", + # Enable keyboard navigation + "", + # Open System Settings + "SystemSettings", + # Enable Remote Management + "", + "", + # Enable Remote Login + "", + # Close System Preferences + "q", + # Disable keyboard navigation + "", + # Open Terminal + "terminal", + # Add vagrant user to sudoers + "echo 'vagrant' | sudo -S sh -c 'echo \"vagrant ALL=(ALL) NOPASSWD: ALL\" > /etc/sudoers.d/vagrant'", + # Set Auto login for vagrant + "sudo sysadminctl -autologin set -userName vagrant -password vagrant", + # Disable screen lock + "sudo sysadminctl -screenLock off -password vagrant", + # Install Parallels Tools + "sudo installer -pkg /Volumes/Parallels\\ Tools/Install.app/Contents/Resources/Install.mpkg -target /", + # Reboot + "sudo shutdown -r +15s", + "exit", + "q" +] diff --git a/os_pkrvars/opensuse/opensuse-leap-15-aarch64.pkrvars.hcl b/os_pkrvars/opensuse/opensuse-leap-15-aarch64.pkrvars.hcl index 754aaebab..fbd8b25d4 100644 --- a/os_pkrvars/opensuse/opensuse-leap-15-aarch64.pkrvars.hcl +++ b/os_pkrvars/opensuse/opensuse-leap-15-aarch64.pkrvars.hcl @@ -1,8 +1,8 @@ os_name = "opensuse-leap" -os_version = "15.5" +os_version = "15.6" os_arch = "aarch64" -iso_url = "http://provo-mirror.opensuse.org/distribution/leap/15.5/iso/openSUSE-Leap-15.5-DVD-aarch64-Media.iso" -iso_checksum = "file:https://provo-mirror.opensuse.org/distribution/leap/15.5/iso/openSUSE-Leap-15.5-DVD-aarch64-Media.iso.sha256" +iso_url = "http://provo-mirror.opensuse.org/distribution/leap/15.6/iso/openSUSE-Leap-15.6-DVD-aarch64-Media.iso" +iso_checksum = "file:https://provo-mirror.opensuse.org/distribution/leap/15.6/iso/openSUSE-Leap-15.6-DVD-aarch64-Media.iso.sha256" parallels_guest_os_type = "opensuse" vbox_guest_os_type = "OpenSUSE_64" vmware_guest_os_type = "arm-other-64" diff --git a/os_pkrvars/opensuse/opensuse-leap-15-x86_64.pkrvars.hcl b/os_pkrvars/opensuse/opensuse-leap-15-x86_64.pkrvars.hcl index 33202e42f..0daf936b8 100644 --- a/os_pkrvars/opensuse/opensuse-leap-15-x86_64.pkrvars.hcl +++ b/os_pkrvars/opensuse/opensuse-leap-15-x86_64.pkrvars.hcl @@ -1,8 +1,8 @@ os_name = "opensuse-leap" -os_version = "15.5" +os_version = "15.6" os_arch = "x86_64" -iso_url = "http://sfo-korg-mirror.kernel.org/opensuse/distribution/leap/15.5/iso/openSUSE-Leap-15.5-DVD-x86_64-Media.iso" -iso_checksum = "file:http://sfo-korg-mirror.kernel.org/opensuse/distribution/leap/15.5/iso/openSUSE-Leap-15.5-DVD-x86_64-Media.iso.sha256" +iso_url = "http://sfo-korg-mirror.kernel.org/opensuse/distribution/leap/15.6/iso/openSUSE-Leap-15.6-DVD-x86_64-Media.iso" +iso_checksum = "file:http://sfo-korg-mirror.kernel.org/opensuse/distribution/leap/15.6/iso/openSUSE-Leap-15.6-DVD-x86_64-Media.iso.sha256" parallels_guest_os_type = "opensuse" vbox_guest_os_type = "OpenSUSE_64" vmware_guest_os_type = "opensuse-64" diff --git a/os_pkrvars/ubuntu/ubuntu-23.10-aarch64.pkrvars.hcl b/os_pkrvars/ubuntu/ubuntu-24.04-aarch64.pkrvars.hcl similarity index 69% rename from os_pkrvars/ubuntu/ubuntu-23.10-aarch64.pkrvars.hcl rename to os_pkrvars/ubuntu/ubuntu-24.04-aarch64.pkrvars.hcl index 770a5671a..f3625a163 100644 --- a/os_pkrvars/ubuntu/ubuntu-23.10-aarch64.pkrvars.hcl +++ b/os_pkrvars/ubuntu/ubuntu-24.04-aarch64.pkrvars.hcl @@ -1,8 +1,8 @@ os_name = "ubuntu" -os_version = "23.10" +os_version = "24.04" os_arch = "aarch64" -iso_url = "https://cdimage.ubuntu.com/releases/mantic/release/ubuntu-23.10-live-server-arm64.iso" -iso_checksum = "file:https://cdimage.ubuntu.com/releases/mantic/release/SHA256SUMS" +iso_url = "https://cdimage.ubuntu.com/releases/noble/release/ubuntu-24.04-live-server-arm64.iso" +iso_checksum = "file:https://cdimage.ubuntu.com/releases/noble/release/SHA256SUMS" parallels_guest_os_type = "ubuntu" vbox_guest_os_type = "Ubuntu_64" vmware_guest_os_type = "arm-ubuntu-64" diff --git a/os_pkrvars/ubuntu/ubuntu-23.10-x86_64.pkrvars.hcl b/os_pkrvars/ubuntu/ubuntu-24.04-x86_64.pkrvars.hcl similarity index 61% rename from os_pkrvars/ubuntu/ubuntu-23.10-x86_64.pkrvars.hcl rename to os_pkrvars/ubuntu/ubuntu-24.04-x86_64.pkrvars.hcl index 43a2a3941..ef40daf4f 100644 --- a/os_pkrvars/ubuntu/ubuntu-23.10-x86_64.pkrvars.hcl +++ b/os_pkrvars/ubuntu/ubuntu-24.04-x86_64.pkrvars.hcl @@ -1,8 +1,8 @@ os_name = "ubuntu" -os_version = "23.10" +os_version = "24.04" os_arch = "x86_64" -iso_url = "https://releases.ubuntu.com/mantic/ubuntu-23.10-live-server-amd64.iso" -iso_checksum = "file:https://releases.ubuntu.com/mantic/SHA256SUMS" +iso_url = "https://releases.ubuntu.com/noble/ubuntu-24.04-live-server-amd64.iso" +iso_checksum = "file:https://releases.ubuntu.com/noble/SHA256SUMS" parallels_guest_os_type = "ubuntu" vbox_guest_os_type = "Ubuntu_64" vmware_guest_os_type = "ubuntu-64" diff --git a/packer_templates/amz_seed_iso/README.md b/packer_templates/amz_seed_iso/README.md deleted file mode 100644 index 8ffadfe42..000000000 --- a/packer_templates/amz_seed_iso/README.md +++ /dev/null @@ -1 +0,0 @@ -# Used by Amazon Linux script to convert vdi to packer/vagrant ready ovf diff --git a/packer_templates/amz_working_files/README.md b/packer_templates/amz_working_files/README.md deleted file mode 100644 index 5142457a4..000000000 --- a/packer_templates/amz_working_files/README.md +++ /dev/null @@ -1 +0,0 @@ -# Used to store temp Amazon Linux files for packer build diff --git a/packer_templates/amz_seed_iso/meta-data b/packer_templates/http/amazon/meta-data similarity index 100% rename from packer_templates/amz_seed_iso/meta-data rename to packer_templates/http/amazon/meta-data diff --git a/packer_templates/amz_seed_iso/user-data b/packer_templates/http/amazon/user-data similarity index 100% rename from packer_templates/amz_seed_iso/user-data rename to packer_templates/http/amazon/user-data diff --git a/packer_templates/http/ubuntu/user-data b/packer_templates/http/ubuntu/user-data index d9393c65d..5e619f9a5 100644 --- a/packer_templates/http/ubuntu/user-data +++ b/packer_templates/http/ubuntu/user-data @@ -13,8 +13,10 @@ autoinstall: install-server: yes allow-pw: yes late-commands: - # - sed -i 's/^#*\(send dhcp-client-identifier\).*$/\1 = hardware;/' /target/etc/dhcp/dhclient.conf - - 'sed -i "s/dhcp4: true/&\n dhcp-identifier: mac/" /target/etc/netplan/00-installer-config.yaml' + - | + if [ -f /target/etc/netplan/00-installer-config.yaml ]; then + 'sed -i "s/dhcp4: true/&\n dhcp-identifier: mac/" /target/etc/netplan/00-installer-config.yaml' + fi - echo 'vagrant ALL=(ALL) NOPASSWD:ALL' > /target/etc/sudoers.d/vagrant # Enable hyper-v daemons only if using hyper-v virtualization - if [ $(virt-what) == "hyperv" ]; then apt-get update && apt-get install -y hyperv-daemons linux-tools-$(uname -r) linux-cloud-tools-$(uname -r) linux-cloud-tools-common cifs-utils && systemctl enable hypervvssd && systemctl enable hypervkvpd && systemctl start hypervvssd && systemctl start hypervkvpd; fi diff --git a/packer_templates/pkr-builder.pkr.hcl b/packer_templates/pkr-builder.pkr.hcl index 66c797904..6c62ae330 100644 --- a/packer_templates/pkr-builder.pkr.hcl +++ b/packer_templates/pkr-builder.pkr.hcl @@ -6,7 +6,7 @@ packer { source = "github.com/hashicorp/hyperv" } parallels = { - version = ">= 1.0.2" + version = ">= 1.1.6" source = "github.com/parallels/parallels" } qemu = { @@ -49,96 +49,106 @@ locals { "${path.root}/scripts/windows/enable-file-sharing.ps1", "${path.root}/scripts/windows/eject-media.ps1" ] : ( - var.os_name == "solaris" ? [ - "${path.root}/scripts/solaris/update_solaris.sh", - "${path.root}/scripts/_common/vagrant.sh", - "${path.root}/scripts/solaris/vmtools_solaris.sh", - "${path.root}/scripts/solaris/minimize_solaris.sh" + var.os_name == "macos" ? [ + "${path.root}/scripts/macos/system-default.sh", + "${path.root}/scripts/macos/system-update.sh", + "${path.root}/scripts/macos/vagrant.sh", + "${path.root}/scripts/_common/motd.sh", + "${path.root}/scripts/macos/parallels-tools.sh", + "${path.root}/scripts/macos/vmware-tools.sh", + "${path.root}/scripts/macos/shrink.sh" ] : ( - var.os_name == "freebsd" ? [ - "${path.root}/scripts/freebsd/update_freebsd.sh", - "${path.root}/scripts/freebsd/postinstall_freebsd.sh", - "${path.root}/scripts/freebsd/sudoers_freebsd.sh", + var.os_name == "solaris" ? [ + "${path.root}/scripts/solaris/update_solaris.sh", "${path.root}/scripts/_common/vagrant.sh", - "${path.root}/scripts/freebsd/vmtools_freebsd.sh", - "${path.root}/scripts/freebsd/cleanup_freebsd.sh", - "${path.root}/scripts/freebsd/minimize_freebsd.sh" + "${path.root}/scripts/solaris/vmtools_solaris.sh", + "${path.root}/scripts/solaris/minimize_solaris.sh" ] : ( - var.os_name == "opensuse-leap" || - var.os_name == "sles" ? [ - "${path.root}/scripts/suse/repositories_suse.sh", - "${path.root}/scripts/suse/update_suse.sh", - "${path.root}/scripts/_common/motd.sh", - "${path.root}/scripts/_common/sshd.sh", + var.os_name == "freebsd" ? [ + "${path.root}/scripts/freebsd/update_freebsd.sh", + "${path.root}/scripts/freebsd/postinstall_freebsd.sh", + "${path.root}/scripts/freebsd/sudoers_freebsd.sh", "${path.root}/scripts/_common/vagrant.sh", - "${path.root}/scripts/suse/unsupported-modules_suse.sh", - "${path.root}/scripts/_common/virtualbox.sh", - "${path.root}/scripts/_common/vmware_suse.sh", - "${path.root}/scripts/_common/parallels.sh", - "${path.root}/scripts/suse/vagrant_group_suse.sh", - "${path.root}/scripts/suse/sudoers_suse.sh", - "${path.root}/scripts/suse/zypper-locks_suse.sh", - "${path.root}/scripts/suse/remove-dvd-source_suse.sh", - "${path.root}/scripts/suse/cleanup_suse.sh", - "${path.root}/scripts/_common/minimize.sh" + "${path.root}/scripts/freebsd/vmtools_freebsd.sh", + "${path.root}/scripts/freebsd/cleanup_freebsd.sh", + "${path.root}/scripts/freebsd/minimize_freebsd.sh" ] : ( - var.os_name == "ubuntu" || - var.os_name == "debian" ? [ - "${path.root}/scripts/${var.os_name}/update_${var.os_name}.sh", + var.os_name == "opensuse-leap" || + var.os_name == "sles" ? [ + "${path.root}/scripts/suse/repositories_suse.sh", + "${path.root}/scripts/suse/update_suse.sh", "${path.root}/scripts/_common/motd.sh", "${path.root}/scripts/_common/sshd.sh", - "${path.root}/scripts/${var.os_name}/networking_${var.os_name}.sh", - "${path.root}/scripts/${var.os_name}/sudoers_${var.os_name}.sh", "${path.root}/scripts/_common/vagrant.sh", - "${path.root}/scripts/${var.os_name}/systemd_${var.os_name}.sh", + "${path.root}/scripts/suse/unsupported-modules_suse.sh", "${path.root}/scripts/_common/virtualbox.sh", - "${path.root}/scripts/_common/vmware_debian_ubuntu.sh", + "${path.root}/scripts/_common/vmware_suse.sh", "${path.root}/scripts/_common/parallels.sh", - "${path.root}/scripts/${var.os_name}/hyperv_${var.os_name}.sh", - "${path.root}/scripts/${var.os_name}/cleanup_${var.os_name}.sh", - "${path.root}/scripts/_common/parallels_post_cleanup_debian_ubuntu.sh", + "${path.root}/scripts/suse/vagrant_group_suse.sh", + "${path.root}/scripts/suse/sudoers_suse.sh", + "${path.root}/scripts/suse/zypper-locks_suse.sh", + "${path.root}/scripts/suse/remove-dvd-source_suse.sh", + "${path.root}/scripts/suse/cleanup_suse.sh", "${path.root}/scripts/_common/minimize.sh" ] : ( - var.os_name == "fedora" ? [ - "${path.root}/scripts/fedora/networking_fedora.sh", - "${path.root}/scripts/fedora/update_dnf.sh", - "${path.root}/scripts/fedora/build-tools_fedora.sh", - "${path.root}/scripts/fedora/install-supporting-packages_fedora.sh", + var.os_name == "ubuntu" || + var.os_name == "debian" ? [ + "${path.root}/scripts/${var.os_name}/update_${var.os_name}.sh", "${path.root}/scripts/_common/motd.sh", "${path.root}/scripts/_common/sshd.sh", - "${path.root}/scripts/_common/virtualbox.sh", - "${path.root}/scripts/_common/vmware_fedora.sh", - "${path.root}/scripts/_common/parallels-rhel.sh", + "${path.root}/scripts/${var.os_name}/networking_${var.os_name}.sh", + "${path.root}/scripts/${var.os_name}/sudoers_${var.os_name}.sh", "${path.root}/scripts/_common/vagrant.sh", - "${path.root}/scripts/fedora/real-tmp_fedora.sh", - "${path.root}/scripts/fedora/cleanup_dnf.sh", + "${path.root}/scripts/${var.os_name}/systemd_${var.os_name}.sh", + "${path.root}/scripts/_common/virtualbox.sh", + "${path.root}/scripts/_common/vmware_debian_ubuntu.sh", + "${path.root}/scripts/_common/parallels.sh", + "${path.root}/scripts/${var.os_name}/hyperv_${var.os_name}.sh", + "${path.root}/scripts/${var.os_name}/cleanup_${var.os_name}.sh", + "${path.root}/scripts/_common/parallels_post_cleanup_debian_ubuntu.sh", "${path.root}/scripts/_common/minimize.sh" ] : ( - "${var.os_name}-${var.os_version}" == "amazonlinux-2" || - "${var.os_name}-${substr(var.os_version, 0, 1)}" == "centos-7" || - "${var.os_name}-${substr(var.os_version, 0, 1)}" == "oracle-7" || - "${var.os_name}-${substr(var.os_version, 0, 1)}" == "rhel-7" ? [ - "${path.root}/scripts/rhel/update_yum.sh", + var.os_name == "fedora" ? [ + "${path.root}/scripts/fedora/networking_fedora.sh", + "${path.root}/scripts/fedora/update_dnf.sh", + "${path.root}/scripts/fedora/build-tools_fedora.sh", + "${path.root}/scripts/fedora/install-supporting-packages_fedora.sh", "${path.root}/scripts/_common/motd.sh", "${path.root}/scripts/_common/sshd.sh", - "${path.root}/scripts/rhel/networking_rhel7.sh", - "${path.root}/scripts/_common/vagrant.sh", "${path.root}/scripts/_common/virtualbox.sh", - "${path.root}/scripts/_common/vmware_rhel.sh", + "${path.root}/scripts/_common/vmware_fedora.sh", "${path.root}/scripts/_common/parallels-rhel.sh", - "${path.root}/scripts/rhel/cleanup_yum.sh", - "${path.root}/scripts/_common/minimize.sh" - ] : [ - "${path.root}/scripts/rhel/update_dnf.sh", - "${path.root}/scripts/_common/motd.sh", - "${path.root}/scripts/_common/sshd.sh", "${path.root}/scripts/_common/vagrant.sh", - "${path.root}/scripts/_common/virtualbox.sh", - "${path.root}/scripts/_common/vmware_rhel.sh", - "${path.root}/scripts/_common/parallels-rhel.sh", - "${path.root}/scripts/rhel/cleanup_dnf.sh", + "${path.root}/scripts/fedora/real-tmp_fedora.sh", + "${path.root}/scripts/fedora/cleanup_dnf.sh", "${path.root}/scripts/_common/minimize.sh" - ] + ] : ( + "${var.os_name}-${var.os_version}" == "amazonlinux-2" || + "${var.os_name}-${substr(var.os_version, 0, 1)}" == "centos-7" || + "${var.os_name}-${substr(var.os_version, 0, 1)}" == "oraclelinux-7" || + "${var.os_name}-${substr(var.os_version, 0, 1)}" == "rhel-7" ? [ + "${path.root}/scripts/rhel/update_yum.sh", + "${path.root}/scripts/_common/motd.sh", + "${path.root}/scripts/_common/sshd.sh", + "${path.root}/scripts/rhel/networking_rhel7.sh", + "${path.root}/scripts/_common/vagrant.sh", + "${path.root}/scripts/_common/virtualbox.sh", + "${path.root}/scripts/_common/vmware_rhel.sh", + "${path.root}/scripts/_common/parallels-rhel.sh", + "${path.root}/scripts/rhel/cleanup_yum.sh", + "${path.root}/scripts/_common/minimize.sh" + ] : [ + "${path.root}/scripts/rhel/update_dnf.sh", + "${path.root}/scripts/_common/motd.sh", + "${path.root}/scripts/_common/sshd.sh", + "${path.root}/scripts/_common/vagrant.sh", + "${path.root}/scripts/_common/virtualbox.sh", + "${path.root}/scripts/_common/vmware_rhel.sh", + "${path.root}/scripts/_common/parallels-rhel.sh", + "${path.root}/scripts/rhel/cleanup_dnf.sh", + "${path.root}/scripts/_common/minimize.sh" + ] + ) ) ) ) diff --git a/packer_templates/pkr-sources.pkr.hcl b/packer_templates/pkr-sources.pkr.hcl index 2cb1a1d21..1b0e9367c 100644 --- a/packer_templates/pkr-sources.pkr.hcl +++ b/packer_templates/pkr-sources.pkr.hcl @@ -20,11 +20,18 @@ locals { var.is_windows ? "attach" : "upload" ) : var.parallels_tools_mode parallels_prlctl = var.parallels_prlctl == null ? ( - var.is_windows ? [ - ["set", "{{ .Name }}", "--efi-boot", "off"], - ["set", "{{ .Name }}", "--efi-secure-boot", "off"], - ["set", "{{ .Name }}", "--device-add", "cdrom", "--image", "${path.root}/../builds/iso/unattended.iso", "--connect"], - ] : null + var.is_windows ? ( + var.os_arch == "x86_64" ? [ + ["set", "{{ .Name }}", "--efi-boot", "off"] + ] : [ + ["set", "{{ .Name }}", "--efi-boot", "off"], + ["set", "{{ .Name }}", "--efi-secure-boot", "off"], + ["set", "{{ .Name }}", "--device-add", "cdrom", "--image", "${path.root}/../builds/iso/unattended.iso", "--connect"], + ] + ) : [ + ["set", "{{ .Name }}", "--3d-accelerate", "off"], + ["set", "{{ .Name }}", "--videosize", "16"] + ] ) : var.parallels_prlctl # qemu @@ -36,7 +43,7 @@ locals { var.is_windows ? [ ["-drive", "file=${path.root}/../builds/iso/virtio-win.iso,media=cdrom,index=3"], ["-drive", "file=${var.iso_url},media=cdrom,index=2"], - ["-drive", "file=${path.root}/../builds/packer-${var.os_name}-${var.os_version}-${var.os_arch}-qemu/{{ .Name }},if=virtio,cache=writeback,discard=ignore,format=qcow2,index=1"], + ["-drive", "file=${path.root}/../builds/build_files/packer-${var.os_name}-${var.os_version}-${var.os_arch}-qemu/{{ .Name }},if=virtio,cache=writeback,discard=ignore,format=qcow2,index=1"], ] : ( var.os_arch == "aarch64" ? [ ["-boot", "strict=off"] @@ -65,7 +72,9 @@ locals { # Source block common default_boot_wait = var.default_boot_wait == null ? ( - var.is_windows ? "60s" : "5s" + var.is_windows ? "60s" : ( + var.os_name == "macos" ? "8m" : "5s" + ) ) : var.default_boot_wait cd_files = var.cd_files == null ? ( var.is_windows ? ( @@ -92,12 +101,16 @@ locals { ] ) : null ) : var.floppy_files - http_directory = var.http_directory == null ? "${path.root}/http" : var.http_directory - memory = var.memory == null ? (var.is_windows ? 4096 : 2048) : var.memory - output_directory = var.output_directory == null ? "${path.root}/../builds/packer-${var.os_name}-${var.os_version}-${var.os_arch}" : var.output_directory + http_directory = var.http_directory == null ? "${path.root}/http" : var.http_directory + memory = var.memory == null ? ( + var.is_windows || var.os_name == "macos" ? 4096 : 2048 + ) : var.memory + output_directory = var.output_directory == null ? "${path.root}/../builds/build_files/packer-${var.os_name}-${var.os_version}-${var.os_arch}" : var.output_directory shutdown_command = var.shutdown_command == null ? ( var.is_windows ? "shutdown /s /t 10 /f /d p:4:1 /c \"Packer Shutdown\"" : ( - var.os_name == "freebsd" ? "echo 'vagrant' | su -m root -c 'shutdown -p now'" : "echo 'vagrant' | sudo -S /sbin/halt -h -p" + var.os_name == "macos" ? "echo 'vagrant' | sudo -S shutdown -h now" : ( + var.os_name == "freebsd" ? "echo 'vagrant' | su -m root -c 'shutdown -p now'" : "echo 'vagrant' | sudo -S /sbin/halt -h -p" + ) ) ) : var.shutdown_command vm_name = var.vm_name == null ? ( @@ -138,6 +151,32 @@ source "hyperv-iso" "vm" { winrm_username = var.winrm_username vm_name = local.vm_name } +source "parallels-ipsw" "vm" { + # Parallels specific options + host_interfaces = var.parallels_host_interfaces + ipsw_url = var.parallels_ipsw_url + ipsw_checksum = var.parallels_ipsw_checksum + prlctl = local.parallels_prlctl + prlctl_post = var.parallels_prlctl_post + prlctl_version_file = var.parallels_prlctl_version_file + # Source block common options + boot_command = var.boot_command + boot_wait = var.parallels_boot_wait == null ? local.default_boot_wait : var.parallels_boot_wait + cpus = var.cpus + communicator = local.communicator + disk_size = var.disk_size + http_directory = local.http_directory + http_content = var.http_content + memory = local.memory + output_directory = "${local.output_directory}-parallels" + shutdown_command = local.shutdown_command + shutdown_timeout = var.shutdown_timeout + ssh_password = var.ssh_password + ssh_port = var.ssh_port + ssh_timeout = var.ssh_timeout + ssh_username = var.ssh_username + vm_name = local.vm_name +} source "parallels-iso" "vm" { # Parallels specific options guest_os_type = var.parallels_guest_os_type diff --git a/packer_templates/pkr-variables.pkr.hcl b/packer_templates/pkr-variables.pkr.hcl index 16ef20dd8..5b0c027fd 100644 --- a/packer_templates/pkr-variables.pkr.hcl +++ b/packer_templates/pkr-variables.pkr.hcl @@ -74,6 +74,33 @@ variable "hyperv_switch_name" { default = "bento" } +# parallels-ipsw +variable "parallels_host_interfaces" { + type = list(string) + default = null + description = "Host interfaces to use for the parallels-ipsw builder" +} +variable "parallels_ipsw_url" { + type = string + default = null + description = "URL to download the IPSW file" +} +variable "parallels_ipsw_checksum" { + type = string + default = null + description = "Checksum of the IPSW file" +} +variable "parallels_prlctl_post" { + type = list(list(string)) + default = null + description = "Commands to run after the VM is created" +} +variable "http_content" { + type = map(string) + default = null + description = "Content to be served by the http server" +} + # parallels-iso variable "parallels_boot_wait" { type = string diff --git a/packer_templates/scripts/_common/motd.sh b/packer_templates/scripts/_common/motd.sh index 2a82b9b70..e3eb4334d 100644 --- a/packer_templates/scripts/_common/motd.sh +++ b/packer_templates/scripts/_common/motd.sh @@ -2,7 +2,9 @@ bento=' This system is built by the Bento project by Chef Software -More information can be found at https://github.com/chef/bento' +More information can be found at https://github.com/chef/bento + +Use of this system is acceptance of the OS vendor EULA and License Agreements.' if [ -d /etc/update-motd.d ]; then MOTD_CONFIG='/etc/update-motd.d/99-bento' @@ -17,5 +19,8 @@ BENTO chmod 0755 "$MOTD_CONFIG" else + touch /etc/motd + chmod 0777 /etc/motd echo "$bento" >> /etc/motd + chmod 0755 /etc/motd fi diff --git a/packer_templates/scripts/_common/vagrant.sh b/packer_templates/scripts/_common/vagrant.sh index 9dfbc090e..37e74bf52 100644 --- a/packer_templates/scripts/_common/vagrant.sh +++ b/packer_templates/scripts/_common/vagrant.sh @@ -5,10 +5,10 @@ HOME_DIR="${HOME_DIR:-/home/vagrant}"; pubkey_url="https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub"; mkdir -p "$HOME_DIR"/.ssh; -if command -v wget >/dev/null 2>&1; then - wget --no-check-certificate "$pubkey_url" -O "$HOME_DIR"/.ssh/authorized_keys; -elif command -v curl >/dev/null 2>&1; then +if command -v curl >/dev/null 2>&1; then curl --insecure --location "$pubkey_url" > "$HOME_DIR"/.ssh/authorized_keys; +elif command -v wget >/dev/null 2>&1; then + wget --no-check-certificate "$pubkey_url" -O "$HOME_DIR"/.ssh/authorized_keys; elif command -v fetch >/dev/null 2>&1; then fetch -am -o "$HOME_DIR"/.ssh/authorized_keys "$pubkey_url"; else diff --git a/packer_templates/scripts/macos/parallels-tools.sh b/packer_templates/scripts/macos/parallels-tools.sh new file mode 100644 index 000000000..4eea703a6 --- /dev/null +++ b/packer_templates/scripts/macos/parallels-tools.sh @@ -0,0 +1,12 @@ +#!/bin/sh + +if [ -e .PACKER_BUILDER_TYPE ] || echo "$PACKER_BUILDER_TYPE" | grep -q '^parallels'; then + echo "Installing Parallels Tools..." + installer -pkg /Volumes/Parallels\ Tools/Install.app/Contents/Resources/Install.mpkg -target / + + # This usually works but gives a failed to eject error + hdiutil detach /Volumes/Parallels\ Tools || echo "exit code $? is suppressed"; + + # Reboot is needed for tools install + reboot +fi diff --git a/packer_templates/scripts/macos/shrink.sh b/packer_templates/scripts/macos/shrink.sh new file mode 100644 index 000000000..14301079a --- /dev/null +++ b/packer_templates/scripts/macos/shrink.sh @@ -0,0 +1,37 @@ +#!/bin/bash +# The MIT License (MIT) +# Copyright (c) 2013-2017 Timothy Sutton +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +# persons to whom the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +echo 'Disable spotlight...' +mdutil -a -i off + +echo 'Turn off hibernation and get rid of the sleepimage' +pmset hibernatemode 0 +rm -f /var/vm/sleepimage + +echo 'Remove Screensaver video files' +rm -rf /Library/Application Support/com.apple.idleassetsd/Customer/* || echo "rm screensaver videos exit code $? is suppressed" + +echo 'Remove logs' +rm -rf /Library/Logs/* || echo "rm library logs exit code $? is suppressed" + +echo 'Remove swap file' +rm -rf /System/Volumes/VM/swapfile* || echo "rm swapfile exit code $? is suppressed" + +if [ -e .vmfusion_version ] || [[ "$PACKER_BUILDER_TYPE" == vmware* ]]; then + echo 'VMware Fusion specific items' + echo 'Shrink the disk' + /Library/Application\ Support/VMware\ Tools/vmware-tools-cli disk shrink / +fi diff --git a/packer_templates/scripts/macos/system-default.sh b/packer_templates/scripts/macos/system-default.sh new file mode 100644 index 000000000..36a56e923 --- /dev/null +++ b/packer_templates/scripts/macos/system-default.sh @@ -0,0 +1,32 @@ +#!/bin/sh +# The MIT License (MIT) +# Copyright (c) 2013-2017 Timothy Sutton +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +# persons to whom the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +PlistBuddy="/usr/libexec/PlistBuddy" + +echo 'Disable loginwindow screensaver to save CPU cycles' +$PlistBuddy -c 'Add :loginWindowIdleTime integer 0' "/Library/Preferences/com.apple.screensaver.plist" +defaults -currentHost write com.apple.screensaver idleTime 0 + +echo 'Prevent the VM from sleeping' +systemsetup -setdisplaysleep Off 2>/dev/null +systemsetup -setsleep Off 2>/dev/null +systemsetup -setcomputersleep Off 2>/dev/null + +echo "Enabling automatic GUI login for the 'Vagrant' user." +sysadminctl -autologin set -userName vagrant -password vagrant + +echo 'Disable screen lock' +sysadminctl -screenLock off -password vagrant diff --git a/packer_templates/scripts/macos/system-update.sh b/packer_templates/scripts/macos/system-update.sh new file mode 100644 index 000000000..b6112915d --- /dev/null +++ b/packer_templates/scripts/macos/system-update.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +echo "Downloading and installing system updates..." +softwareupdate -i -a -R + +echo 'Disable automatic updates' +# TOGGLE ALL OFF (auto checking is on to show other prefs are toggled off) +# before setting values quit system preferences & stop software update - stops defaults cache breaking 'AutomaticCheckEnabled' +osascript -e "tell application \"System Preferences\" to quit" +softwareupdate --schedule off +defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticCheckEnabled -bool No +defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist AutomaticDownload -bool NO +defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist ConfigDataInstall -bool NO +defaults write /Library/Preferences/com.apple.SoftwareUpdate.plist CriticalUpdateInstall -bool NO +defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdateRestartRequired -bool NO +defaults write /Library/Preferences/com.apple.commerce.plist AutoUpdate -bool NO diff --git a/packer_templates/scripts/macos/vagrant.sh b/packer_templates/scripts/macos/vagrant.sh new file mode 100644 index 000000000..108c289d5 --- /dev/null +++ b/packer_templates/scripts/macos/vagrant.sh @@ -0,0 +1,30 @@ +#!/bin/sh +# The MIT License (MIT) +# Copyright (c) 2013-2017 Timothy Sutton +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +# persons to whom the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +date > /etc/box_build_time +OSX_VERS=$(sw_vers -productVersion | awk -F "." '{print $1}') + +# Set computer/hostname +COMPNAME=macos-${OSX_VERS} +scutil --set ComputerName "${COMPNAME}" +scutil --set HostName "${COMPNAME}".vagrantup.com + +echo "Installing vagrant keys for vagrant user" +mkdir "/Users/vagrant/.ssh" +chmod 700 "/Users/vagrant/.ssh" +curl -L 'https://raw.githubusercontent.com/hashicorp/vagrant/main/keys/vagrant.pub' > "/Users/vagrant/.ssh/authorized_keys" +chmod 600 "/Users/vagrant/.ssh/authorized_keys" +chown -R "vagrant" "/Users/vagrant/.ssh" diff --git a/packer_templates/scripts/macos/vmware-tools.sh b/packer_templates/scripts/macos/vmware-tools.sh new file mode 100644 index 000000000..08218ba56 --- /dev/null +++ b/packer_templates/scripts/macos/vmware-tools.sh @@ -0,0 +1,48 @@ +#!/bin/sh +# The MIT License (MIT) +# Copyright (c) 2013-2017 Timothy Sutton +# +# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated +# documentation files (the "Software"), to deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit +# persons to whom the Software is furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +# COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR +# OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +echo 'VMware Fusion specific items' +if [ -e .vmfusion_version ] || echo "$PACKER_BUILDER_TYPE" | grep -q '^vmware'; then + # Globbing here: VMware Fusion >= 8.5.4 includes a second + # 'darwinPre15.iso' for any OS X guests pre-10.11 + TOOLS_PATH=$(find "/Users/vagrant/" -name '*darwin*.iso' -print) + if [ ! -e "$TOOLS_PATH" ]; then + echo "Couldn't locate uploaded tools iso at $TOOLS_PATH!" + exit 1 + fi + + TMPMOUNT=$(/usr/bin/mktemp -d /tmp/vmware-tools.XXXX) + hdiutil attach "$TOOLS_PATH" -mountpoint "$TMPMOUNT" + + INSTALLER_PKG="$TMPMOUNT/Install VMware Tools.app/Contents/Resources/VMware Tools.pkg" + if [ ! -e "$INSTALLER_PKG" ]; then + echo "Couldn't locate VMware installer pkg at $INSTALLER_PKG!" + exit 1 + fi + + echo "Installing VMware tools.." + installer -pkg "$TMPMOUNT/Install VMware Tools.app/Contents/Resources/VMware Tools.pkg" -target / + + # This usually fails + hdiutil detach "$TMPMOUNT" || echo "exit code $? is suppressed"; + rm -rf "$TMPMOUNT" + rm -f "$TOOLS_PATH" + + # Point Linux shared folder root to that used by OS X guests, + # useful for the Hashicorp vmware_fusion Vagrant provider plugin + mkdir /mnt + ln -sf /Volumes/VMware\ Shared\ Folders /mnt/hgfs +fi