mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-10-31 22:51:22 +00:00
create_amis.sh: fix logic for non-zfs amis
This commit is contained in:
parent
dbb930d037
commit
4d765caecd
@ -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")
|
||||
|
Loading…
Reference in New Issue
Block a user