Skip to content

Commit af4e870

Browse files
authored
Merge pull request #2863 from norio-nomura/update-injectcmdline-to-template.sh
Update `inject-cmdline-to-template.sh`
2 parents 5d06891 + d07eef3 commit af4e870

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

hack/inject-cmdline-to-template.sh

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ arch="${arch:-$(uname -m)}"
2121
case "${arch}" in
2222
amd64 | x86_64) arch=x86_64 ;;
2323
aarch64 | arm64) arch=aarch64 ;;
24+
armv7l | armhf) arch=armv7l ;;
25+
riscv64) arch=riscv64 ;;
2426
*)
2527
echo "Unsupported arch: ${arch}" >&2
2628
exit 1
@@ -29,9 +31,7 @@ esac
2931

3032
# 2. extract location by parsing template using arch
3133
readonly yq_filter="
32-
[
33-
.images | map(select(.arch == \"${arch}\")) | [.[].location]
34-
]|flatten|.[]
34+
.images[]|select(.arch == \"${arch}\")|.location
3535
"
3636
parsed=$(yq eval "${yq_filter}" "${template}")
3737

@@ -57,6 +57,8 @@ done
5757
if [[ -z ${location} ]]; then
5858
echo "Failed to get the image location for ${template}" >&2
5959
exit 1
60+
elif [[ ${location} == https://cloud-images.ubuntu.com/minimal/* ]]; then
61+
readonly default_cmdline="root=/dev/vda1 ro console=tty1 console=ttyAMA0"
6062
elif [[ ${location} == https://cloud-images.ubuntu.com/* ]]; then
6163
readonly default_cmdline="root=LABEL=cloudimg-rootfs ro console=tty1 console=ttyAMA0"
6264
else
@@ -91,7 +93,7 @@ function inject_to() {
9193
for field_name in location digest cmdline; do
9294
[[ -z ${!field_name} ]] || fields+=("\"${field_name}\": \"${!field_name}\"")
9395
done
94-
yq -i -I 2 eval "setpath([(.images[] | select(.arch == \"${arch}\") | path)].[${index}] + \"${key}\"; { ${fields[*]}})" "${template}"
96+
limactl edit --log-level error --set "setpath([(.images[] | select(.arch == \"${arch}\") | path)].[${index}] + \"${key}\"; { ${fields[*]}})" "${template}"
9597
}
9698
inject_to "${template}" "${arch}" "${index}" "kernel" "${kernel_location}" "${kernel_digest}" "${cmdline}"
9799
inject_to "${template}" "${arch}" "${index}" "initrd" "${initrd_location}" "${initrd_digest}"

0 commit comments

Comments
 (0)