From 4d765caecdc91e6efa61822499f2275b59926dee Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Tue, 9 Nov 2021 15:41:20 -0700 Subject: [PATCH] create_amis.sh: fix logic for non-zfs amis --- nixos/maintainers/scripts/ec2/create-amis.sh | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/nixos/maintainers/scripts/ec2/create-amis.sh b/nixos/maintainers/scripts/ec2/create-amis.sh index 712d9b548ff0..355894587391 100755 --- a/nixos/maintainers/scripts/ec2/create-amis.sh +++ b/nixos/maintainers/scripts/ec2/create-amis.sh @@ -65,13 +65,18 @@ read_image_info() { # We handle a single image per invocation, store all attributes in # globals for convenience. zfs_disks=$(read_image_info .disks) -image_label="$(read_image_info .label)${zfs_disks:+-ZFS}" +is_zfs_image= +if jq -e .boot <<< "$zfs_disks"; then + is_zfs_image=1 + zfs_boot=".disks.boot" +fi +image_label="$(read_image_info .label)${is_zfs_image:+-ZFS}" image_system=$(read_image_info .system) -image_files=( $(read_image_info "${zfs_disks:+.disks.root}.file") ) +image_files=( $(read_image_info ".disks.root.file") ) -image_logical_bytes=$(read_image_info "${zfs_disks:+.disks.boot}.logical_bytes") +image_logical_bytes=$(read_image_info "${zfs_boot:-.disks.root}.logical_bytes") -if [[ -n "$zfs_disks" ]]; then +if [[ -n "$is_zfs_image" ]]; then image_files+=( $(read_image_info .disks.boot.file) ) fi @@ -192,7 +197,7 @@ upload_image() { for image_file in "${image_files[@]}"; do local aws_path=${image_file#/} - if [[ -n "$zfs_disks" ]]; then + if [[ -n "$is_zfs_image" ]]; then local suffix=${image_file%.*} suffix=${suffix##*.} fi @@ -239,7 +244,7 @@ upload_image() { "DeviceName=/dev/xvda,Ebs={SnapshotId=$snapshot_id,VolumeSize=$image_logical_gigabytes,DeleteOnTermination=true,VolumeType=gp3}" ) - if [[ -n "$zfs_disks" ]]; then + if [[ -n "$is_zfs_image" ]]; then local root_snapshot_id=$(read_state "$region.$image_label.root.$image_system" snapshot_id) local root_image_logical_bytes=$(read_image_info ".disks.root.logical_bytes")