git.iko.soy/typeable/nixpkgs
on master help sign in
create_amis.sh: fix logic for non-zfs amis
commit4d765caecdc91e6efa61822499f2275b59926dee authorTimothy DeHerrera <tim.deh@pm.me> dateTue 9 Nov 2021, 15:41 (5 years ago) parentdbb930d
1 file changed+11−6
nixos/maintainers/scripts/ec2/create-amis.sh+11−6
nixos/maintainers/scripts/ec2/create-amis.sh+11−6
@@ -65,13 +65,18 @@ read_image_info() {
6565# We handle a single image per invocation, store all attributes in
6666# globals for convenience.
6767zfs_disks=$(read_image_info .disks)
68−image_label="$(read_image_info .label)${zfs_disks:+-ZFS}"
68+is_zfs_image=
69+if jq -e .boot <<< "$zfs_disks"; then
70+ is_zfs_image=1
71+ zfs_boot=".disks.boot"
72+fi
73+image_label="$(read_image_info .label)${is_zfs_image:+-ZFS}"
6974image_system=$(read_image_info .system)
70−image_files=( $(read_image_info "${zfs_disks:+.disks.root}.file") )
75+image_files=( $(read_image_info ".disks.root.file") )
7176
72−image_logical_bytes=$(read_image_info "${zfs_disks:+.disks.boot}.logical_bytes")
77+image_logical_bytes=$(read_image_info "${zfs_boot:-.disks.root}.logical_bytes")
7378
74−if [[ -n "$zfs_disks" ]]; then
79+if [[ -n "$is_zfs_image" ]]; then
7580 image_files+=( $(read_image_info .disks.boot.file) )
7681fi
7782
@@ -192,7 +197,7 @@ upload_image() {
192197 for image_file in "${image_files[@]}"; do
193198 local aws_path=${image_file#/}
194199
195− if [[ -n "$zfs_disks" ]]; then
200+ if [[ -n "$is_zfs_image" ]]; then
196201 local suffix=${image_file%.*}
197202 suffix=${suffix##*.}
198203 fi
@@ -239,7 +244,7 @@ upload_image() {
239244 "DeviceName=/dev/xvda,Ebs={SnapshotId=$snapshot_id,VolumeSize=$image_logical_gigabytes,DeleteOnTermination=true,VolumeType=gp3}"
240245 )
241246
242− if [[ -n "$zfs_disks" ]]; then
247+ if [[ -n "$is_zfs_image" ]]; then
243248 local root_snapshot_id=$(read_state "$region.$image_label.root.$image_system" snapshot_id)
244249
245250 local root_image_logical_bytes=$(read_image_info ".disks.root.logical_bytes")