Daniel Watrous
Daniel Watrous

Reputation: 3861

How to use Packer with xz images

I'm following this (rather old) article about building a Raspberry Pi image using Packer: https://linuxhit.com/build-a-raspberry-pi-image-packer-packer-builder-arm/

The process works great except that I want to use a newer image. The problem is that the newer images are "xz", not "zip": https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2023-05-03/

I attempted to just change the json as follows:

"file_urls" : ["https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2023-05-03/2023-05-03-raspios-bullseye-armhf-lite.img.xz"],
"file_checksum_url": "https://downloads.raspberrypi.org/raspios_lite_armhf/images/raspios_lite_armhf-2023-05-03/2023-05-03-raspios-bullseye-armhf-lite.img.xz.sha256",
"file_checksum_type": "sha256",
"file_target_extension": "xz",

I get the following error

==> arm: error while unpacking format specified by source filename is not an archive format: /build/.packer_cache/fe4721540a01c6d3803b8521974cf57e233cea3d.xz (*archiver.Xz): N/A

I have searched, but can't find any examples or documentation about how to use xz images, other than a single bug on github saying that xz support was added to packer a few years ago. Any idea how I can update this to use the new xz images?

Upvotes: 0

Views: 334

Answers (1)

Daniel Watrous
Daniel Watrous

Reputation: 3861

I'm using a Docker image for this build that can be found here: https://github.com/mkaczanowski/packer-builder-arm

I started digging around in the other examples in the repository and found this example: https://github.com/mkaczanowski/packer-builder-arm/blob/fec4cd5c642a736e0a81c11827d085c7f1a84b0a/boards/raspberry-pi-4/ubuntu_server_20.04_arm64.json#L9C51-L9C51

What I needed to make this work was to add the custom decompressor statement. I can now build with the XZ file.

Upvotes: 0

Related Questions