From 702d463194f9250d5d0807907655382f81063a12 Mon Sep 17 00:00:00 2001 From: jayofelony Date: Mon, 1 Jul 2024 07:51:18 +0200 Subject: [PATCH] Update build Signed-off-by: jayofelony --- Makefile | 3 +- builder/combined.json.pkr.hcl | 82 ++++++++---------------------- builder/raspberrypi32.json.pkr.hcl | 52 ++++++------------- builder/raspberrypi64.json.pkr.hcl | 44 ++++------------ 4 files changed, 47 insertions(+), 134 deletions(-) diff --git a/Makefile b/Makefile index 14a71834..e8073469 100644 --- a/Makefile +++ b/Makefile @@ -44,6 +44,7 @@ packer: curl https://releases.hashicorp.com/packer/$(PACKER_VERSION)/packer_$(PACKER_VERSION)_linux_amd64.zip -o /tmp/packer.zip unzip -o /tmp/packer.zip -d /tmp sudo mv /tmp/packer /usr/bin/packer + /usr/bin/packer plugins install github.com/solo-io/arm-image image: packer export LC_ALL=en_GB.UTF-8 @@ -51,7 +52,7 @@ image: packer 32bit: packer export LC_ALL=en_GB.UTF-8 - cd builder && sudo /usr/bin/packer init raspberrypi32.json.pkr.hcl && QEMU_CPU=arm1176 sudo -E $(UNSHARE) /usr/bin/packer build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" raspberrypi32.json.pkr.hcl + cd builder && sudo /usr/bin/packer init raspberrypi32.json.pkr.hcl && sudo $(UNSHARE) /usr/bin/packer build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" raspberrypi32.json.pkr.hcl 64bit: packer export LC_ALL=en_GB.UTF-8 diff --git a/builder/combined.json.pkr.hcl b/builder/combined.json.pkr.hcl index e4f0877f..ef345aa0 100644 --- a/builder/combined.json.pkr.hcl +++ b/builder/combined.json.pkr.hcl @@ -1,9 +1,5 @@ packer { required_plugins { - arm = { - version = "1.0.0" - source = "github.com/cdecoux/builder-arm" - } ansible = { source = "github.com/hashicorp/ansible" version = ">= 1.1.1" @@ -19,64 +15,26 @@ variable "pwn_version" { type = string } -source "arm" "rpi64-pwnagotchi" { - file_checksum_url = "https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64-lite.img.xz.sha256" - file_urls = ["https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64-lite.img.xz"] - file_checksum_type = "sha256" - file_target_extension = "xz" - file_unarchive_cmd = ["unxz", "$ARCHIVE_PATH"] - image_path = "../../../pwnagotchi-64bit.img" - qemu_binary_source_path = "/usr/libexec/qemu-binfmt/aarch64-binfmt-P" - qemu_binary_destination_path = "/usr/libexec/qemu-binfmt/aarch64-binfmt-P" - image_build_method = "resize" - image_size = "9G" - image_type = "dos" - image_partitions { - name = "boot" - type = "c" - start_sector = "8192" - filesystem = "fat" - size = "256M" - mountpoint = "/boot/firmware" - } - image_partitions { - name = "root" - type = "83" - start_sector = "532480" - filesystem = "ext4" - size = "0" - mountpoint = "/" - } +source "arm-image" "rpi64-pwnagotchi" { + image_type = "raspberrypi" + iso_url = "https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64-lite.img.xz" + iso_checksum = "sha256:58a3ec57402c86332e67789a6b8f149aeeb4e7bb0a16c9388a66ea6e07012e45" + output_filename = "../../../pwnagotchi-64bit.img" + qemu_binary = "qemu-aarch64-static" + image_mounts = ["/boot/firmware","/"] + target_image_size = 9969908736 } -source "arm" "rpi32-pwnagotchi" { - file_checksum_url = "https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2024-03-15/2024-03-15-raspios-bookworm-armhf-lite.img.xz.sha256" - file_urls = ["https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2024-03-15/2024-03-15-raspios-bookworm-armhf-lite.img.xz"] - file_checksum_type = "sha256" - file_target_extension = "xz" - file_unarchive_cmd = ["unxz", "$ARCHIVE_PATH"] - image_path = "../../../pwnagotchi-32bit.img" - qemu_binary_source_path = "/usr/libexec/qemu-binfmt/arm-binfmt-P" - qemu_binary_destination_path = "/usr/libexec/qemu-binfmt/arm-binfmt-P" - image_build_method = "resize" - image_size = "9G" - image_type = "dos" - image_partitions { - name = "boot" - type = "c" - start_sector = "8192" - filesystem = "fat" - size = "256M" - mountpoint = "/boot/firmware" - } - image_partitions { - name = "root" - type = "83" - start_sector = "532480" - filesystem = "ext4" - size = "0" - mountpoint = "/" - } +source "arm-image" "rpi32-pwnagotchi" { + image_type = "raspberrypi" + iso_url = "https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2024-03-15/2024-03-15-raspios-bookworm-armhf-lite.img.xz" + iso_checksum = "sha256:4fa99737265ac338a9ed0643f502246b97b928e5dfffa92939242e26e290638d" + output_filename = "../../../pwnagotchi-32bit.img" + qemu_binary = "qemu-arm-static" + qemu_args = ["-cpu", "arm1176"] + image_arch = "arm" + image_mounts = ["/boot/firmware","/"] + target_image_size = 9969908736 } # a build block invokes sources and runs provisioning steps on them. The @@ -84,7 +42,7 @@ source "arm" "rpi32-pwnagotchi" { # https://www.packer.io/docs/from-1.5/blocks/build build { name = "Raspberry Pi 64 Pwnagotchi" - sources = ["source.arm.rpi64-pwnagotchi"] + sources = ["source.arm-image.rpi64-pwnagotchi"] provisioner "file" { destination = "/usr/bin/" @@ -136,7 +94,7 @@ build { build { name = "Raspberry Pi 32 Pwnagotchi" - sources = ["source.arm.rpi32-pwnagotchi"] + sources = ["source.arm-image.rpi32-pwnagotchi"] provisioner "file" { destination = "/usr/bin/" sources = [ diff --git a/builder/raspberrypi32.json.pkr.hcl b/builder/raspberrypi32.json.pkr.hcl index 4880d521..cacd8b88 100644 --- a/builder/raspberrypi32.json.pkr.hcl +++ b/builder/raspberrypi32.json.pkr.hcl @@ -1,9 +1,9 @@ packer { required_plugins { - arm = { - version = ">=1.0.0" - source = "github.com/michalfita/cross" - } + #arm = { + # version = ">=1.0.0" + # source = "github.com/michalfita/cross" + #} ansible = { source = "github.com/hashicorp/ansible" version = ">= 1.1.1" @@ -19,41 +19,21 @@ variable "pwn_version" { type = string } -source "arm" "rpi32-pwnagotchi" { - file_checksum_url = "https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2024-03-15/2024-03-15-raspios-bookworm-armhf-lite.img.xz.sha256" - file_urls = ["https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2024-03-15/2024-03-15-raspios-bookworm-armhf-lite.img.xz"] - file_checksum_type = "sha256" - file_target_extension = "xz" - file_unarchive_cmd = ["unxz", "$ARCHIVE_PATH"] - image_path = "../../../pwnagotchi-32bit.img" - qemu_binary_source_path = "/usr/libexec/qemu-binfmt/arm-binfmt-P" - qemu_binary_destination_path = "/usr/libexec/qemu-binfmt/arm-binfmt-P" - image_build_method = "resize" - image_size = "9G" - image_type = "dos" - image_partitions { - name = "boot" - type = "c" - start_sector = "8192" - filesystem = "fat" - size = "256M" - mountpoint = "/boot/firmware" - } - image_partitions { - name = "root" - type = "83" - start_sector = "532480" - filesystem = "ext4" - size = "0" - mountpoint = "/" - } +source "arm-image" "rpi32-pwnagotchi" { + image_type = "raspberrypi" + iso_url = "https://downloads.raspberrypi.com/raspios_lite_armhf/images/raspios_lite_armhf-2024-03-15/2024-03-15-raspios-bookworm-armhf-lite.img.xz" + iso_checksum = "sha256:4fa99737265ac338a9ed0643f502246b97b928e5dfffa92939242e26e290638d" + output_filename = "../../../pwnagotchi-32bit.img" + qemu_binary = "qemu-arm-static" + qemu_args = ["-cpu", "arm1176"] + image_arch = "arm" + image_mounts = ["/boot/firmware","/"] + target_image_size = 9969908736 } + build { name = "Raspberry Pi 32 Pwnagotchi" - sources = ["source.arm.rpi32-pwnagotchi"] - provisioner "shell" { - inline = ["uname -m"] - } + sources = ["source.arm-image.rpi32-pwnagotchi"] provisioner "file" { destination = "/usr/bin/" sources = [ diff --git a/builder/raspberrypi64.json.pkr.hcl b/builder/raspberrypi64.json.pkr.hcl index 1e22695d..680a65e2 100644 --- a/builder/raspberrypi64.json.pkr.hcl +++ b/builder/raspberrypi64.json.pkr.hcl @@ -1,9 +1,5 @@ packer { required_plugins { - arm = { - version = ">=1.0.0" - source = "github.com/michalfita/cross" - } ansible = { source = "github.com/hashicorp/ansible" version = ">= 1.1.1" @@ -19,44 +15,22 @@ variable "pwn_version" { type = string } -source "arm" "rpi64-pwnagotchi" { - file_checksum_url = "https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64-lite.img.xz.sha256" - file_urls = ["https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64-lite.img.xz"] - file_checksum_type = "sha256" - file_target_extension = "xz" - file_unarchive_cmd = ["unxz", "$ARCHIVE_PATH"] - image_path = "../../../pwnagotchi-64bit.img" - qemu_binary_source_path = "/usr/libexec/qemu-binfmt/aarch64-binfmt-P" - qemu_binary_destination_path = "/usr/libexec/qemu-binfmt/aarch64-binfmt-P" - image_build_method = "resize" - image_size = "9G" - image_type = "dos" - image_partitions { - name = "boot" - type = "c" - start_sector = "8192" - filesystem = "fat" - size = "256M" - mountpoint = "/boot/firmware" - } - image_partitions { - name = "root" - type = "83" - start_sector = "532480" - filesystem = "ext4" - size = "0" - mountpoint = "/" - } +source "arm-image" "rpi64-pwnagotchi" { + image_type = "raspberrypi" + iso_url = "https://downloads.raspberrypi.com/raspios_lite_arm64/images/raspios_lite_arm64-2024-03-15/2024-03-15-raspios-bookworm-arm64-lite.img.xz" + iso_checksum = "sha256:58a3ec57402c86332e67789a6b8f149aeeb4e7bb0a16c9388a66ea6e07012e45" + output_filename = "../../../pwnagotchi-64bit.img" + qemu_binary = "qemu-aarch64-static" + image_mounts = ["/boot/firmware","/"] + target_image_size = 9969908736 } - - # a build block invokes sources and runs provisioning steps on them. The # documentation for build blocks can be found here: # https://www.packer.io/docs/from-1.5/blocks/build build { name = "Raspberry Pi 64 Pwnagotchi" - sources = ["source.arm.rpi64-pwnagotchi"] + sources = ["source.arm-image.rpi64-pwnagotchi"] provisioner "file" { destination = "/usr/bin/"