跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

update-template-debian.sh

466 行 · 21.2 KB历史下载
1#!/usr/bin/env bash
2
3# SPDX-FileCopyrightText: Copyright The Lima Authors
4# SPDX-License-Identifier: Apache-2.0
5
6set -eu -o pipefail
7
8# Functions in this script assume error handling with 'set -e'.
9# To ensure 'set -e' works correctly:
10# - Use 'set +e' before assignments and '$(set -e; <function>)' to capture output without exiting on errors.
11# - Avoid calling functions directly in conditions to prevent disabling 'set -e'.
12# - Use 'shopt -s inherit_errexit' (Bash 4.4+) to avoid repeated 'set -e' in all '$(...)'.
13shopt -s inherit_errexit || error_exit "inherit_errexit not supported. Please use bash 4.4 or later."
14
15function debian_print_help() {
16 cat <<HELP
17$(basename "${BASH_SOURCE[0]}"): Update the Debian image location in the specified templates
18
19Usage:
20 $(basename "${BASH_SOURCE[0]}") [--backports[=<bool>]] [--daily[=<bool>]] [--timestamped[=<bool>]] [--version <version>] <template.yaml>...
21
22Description:
23 This script updates the Debian image location in the specified templates.
24 If the image location in the template contains a release date in the URL, the script replaces it with the latest available date.
25 If no flags are specified, the script uses the version from the image location basename in the template.
26
27 Image location basename format: debian-<version>[-backports]-genericcloud-<arch>[-daily][-<timestamp>].qcow2
28
29 Published Debian image information is fetched from the following URLs:
30
31 https://cloud.debian.org/images/cloud/<codename>[-backports]/[daily/](latest|<timestamp>)/debian-<version>[-backports]-genericcloud-<arch>[-daily][-<timestamp>].json
32
33 The downloaded JSON file will be cached in the Lima cache directory.
34
35Examples:
36 Update the Debian image location in templates/**.yaml:
37 $ $(basename "${BASH_SOURCE[0]}") templates/**.yaml
38
39 Update the Debian image location in ~/.lima/debian/lima.yaml:
40 $ $(basename "${BASH_SOURCE[0]}") ~/.lima/debian/lima.yaml
41 $ limactl factory-reset debian
42
43 Update the Debian image location to debian-13-genericcloud-<arch>.qcow2 in ~/.lima/debian/lima.yaml:
44 $ $(basename "${BASH_SOURCE[0]}") --version trixie ~/.lima/debian/lima.yaml
45 $ limactl factory-reset debian
46
47Flags:
48 --backports[=<bool>] Use the backports image
49 The boolean value can be true, false, 1, or 0
50 --daily[=<bool>] Use the daily image
51 --timestamped[=<bool>] Use the timestamped image
52 --version <version> Use the specified version
53 The version can be a codename, version number, or alias (testing, stable, oldstable)
54 -h, --help Print this help message
55HELP
56}
57
58readonly debian_base_url=https://cloud.debian.org/images/cloud/
59
60function debian_target_vendor_from_arch() {
61 local arch=$1
62 case "$arch" in
63 amd64 | arm64)
64 echo "genericcloud"
65 ;;
66 *)
67 echo "generic"
68 ;;
69 esac
70}
71
72readonly -A debian_version_to_codename=(
73 [10]=buster
74 [11]=bullseye
75 [12]=bookworm
76 [13]=trixie
77 [14]=forky
78)
79
80declare -A debian_codename_to_version
81function debian_setup_codename_to_version() {
82 local version codename
83 for version in "${!debian_version_to_codename[@]}"; do
84 codename=${debian_version_to_codename[${version}]}
85 debian_codename_to_version[${codename}]="${version}"
86 done
87 readonly -A debian_codename_to_version
88}
89debian_setup_codename_to_version
90
91readonly -A debian_alias_to_codename=(
92 [testing]=trixie
93 [stable]=bookworm
94 [oldstable]=bullseye
95)
96
97# debian_downloaded_json downloads the JSON file for the given url_spec(JSON) and caches it
98# e.g.
99# ```console
100# debian_downloaded_json '{"backports":false,"daily":false,"version":12,"arch":"amd64","file_extension":"qcow2"}'
101#
102# ```
103function debian_downloaded_json() {
104 local url_spec=$1 json_url_spec json_url
105 json_url_spec=$(jq -r '. | del(.timestamp) | .file_extension = "json"' <<<"${url_spec}") || error_exit "Failed to create JSON URL spec"
106 json_url=$(debian_location_from_url_spec "${json_url_spec}")
107 download_to_cache "${json_url}"
108}
109
110function debian_digest_from_upload_entry() {
111 local upload_entry=$1 debian_digest digest
112 debian_digest=$(jq -e -r '.metadata.annotations."cloud.debian.org/digest"' <<<"${upload_entry}") ||
113 error_exit "Failed to get the digest from ${upload_entry}"
114 case "${debian_digest%:*}" in
115 sha512) digest=$(echo "${debian_digest#*:}==" | base64 -d | xxd -p -c 128) ||
116 error_exit "Failed to decode the digest from ${debian_digest}" ;;
117 *) error_exit "Unsupported digest type: ${debian_digest%:*}" ;;
118 esac
119 echo "${debian_digest/:*/:}${digest}"
120}
121
122# debian_image_url_timestamped prints the latest image URL and its digest for the given flavor, version, arch, and path suffix.
123function debian_image_url_timestamped() {
124 local url_spec=$1 debian_downloaded_json jq_filter upload_entry timestamp timestamped_url_spec location arch digest
125 debian_downloaded_json=$(debian_downloaded_json "${url_spec}")
126 # shellcheck disable=SC2016
127 jq_filter='
128 [.items[]|select(.kind == "Upload")|
129 select(.metadata.labels."upload.cloud.debian.org/image-format" == $ARGS.named.url_spec.image_format)]|first
130 '
131 upload_entry=$(jq -e -r --argjson url_spec "${url_spec}" "${jq_filter}" "${debian_downloaded_json}") ||
132 error_exit "Failed to find the upload entry from ${debian_downloaded_json}"
133 timestamp=$(jq -e -r '.metadata.labels."cloud.debian.org/version"' <<<"${upload_entry}") ||
134 error_exit "Failed to get the timestamp from ${upload_entry}"
135 timestamped_url_spec=$(json_vars timestamp <<<"${url_spec}")
136 location=$(debian_location_from_url_spec "${timestamped_url_spec}")
137 location=$(validate_url_without_redirect "${location}")
138 arch=$(jq -e -r '.arch' <<<"${url_spec}") || error_exit "missing arch in ${url_spec}"
139 arch=$(limayaml_arch "${arch}")
140 digest=$(debian_digest_from_upload_entry "${upload_entry}")
141 json_vars location arch digest
142}
143
144# debian_image_url_not_timestamped prints the release image URL for the given url_spec(JSON)
145function debian_image_url_not_timestamped() {
146 local url_spec=$1 location arch
147 location=$(debian_location_from_url_spec "${url_spec}")
148 location=$(validate_url_without_redirect "${location}")
149 arch=$(jq -e -r '.arch' <<<"${url_spec}") || error_exit "missing arch in ${url_spec}"
150 arch=$(limayaml_arch "${arch}")
151 json_vars location arch
152}
153
154# debian_version_resolve_aliases resolves the version aliases.
155# e.g.
156# ```console
157# debian_version_resolve_aliases testing
158# 13
159# debian_version_resolve_aliases stable
160# 12
161# debian_version_resolve_aliases oldstable
162# 11
163# debian_version_resolve_aliases bookworm
164# 12
165# debian_version_resolve_aliases 10
166# 10
167# debian_version_resolve_aliases ''
168#
169# ```
170function debian_version_resolve_aliases() {
171 local version=$1
172 [[ -v debian_alias_to_codename[${version}] ]] && version=${debian_alias_to_codename[${version}]}
173 [[ -v debian_codename_to_version[${version}] ]] && version=${debian_codename_to_version[${version}]}
174 [[ -v debian_version_to_codename[${version}] ]] || error_exit "Unsupported version: ${version}"
175 [[ -z ${version} ]] || echo "${version}"
176}
177
178function debian_arch_from_location_basename() {
179 local location=$1 location_basename arch
180 location_basename=$(basename "${location}")
181 location_basename=${location_basename/-backports/}
182 arch=$(echo "${location_basename}" | cut -d- -f4 | cut -d. -f1)
183 [[ -n ${arch} ]] || error_exit "Failed to get arch from ${location}"
184 echo "${arch}"
185}
186
187# debian_target_vendor_from_location_basename returns the target vendor segment
188# (e.g. "genericcloud", "generic", "nocloud") from the given location.
189function debian_target_vendor_from_location_basename() {
190 local location=$1 location_basename target_vendor
191 location_basename=$(basename "${location}")
192 location_basename=${location_basename/-backports/}
193 target_vendor=$(echo "${location_basename}" | cut -d- -f3)
194 [[ -n ${target_vendor} ]] || error_exit "Failed to get target_vendor from ${location}"
195 echo "${target_vendor}"
196}
197
198function debian_file_extension_from_location_basename() {
199 local location=$1 location_basename file_extension
200 location_basename=$(basename "${location}")
201 file_extension=$(echo "${location_basename}" | cut -d. -f2-) # remove the first field
202 [[ -n ${file_extension} ]] || error_exit "Failed to get file extension from ${location}"
203 echo "${file_extension}"
204}
205
206function debian_image_format_from_file_extension() {
207 local file_extension=$1
208 case "${file_extension}" in
209 json) echo "json" ;;
210 qcow2) echo "qcow2" ;;
211 raw) echo "raw" ;;
212 tar.xz) echo "internal" ;;
213 *) error_exit "Unsupported file extension: ${file_extension}" ;;
214 esac
215}
216
217# debian_url_spec_from_location returns the URL spec for the given location.
218# If the location is not supported, it returns 1.
219# e.g.
220# ```console
221# debian_url_spec_from_location https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2
222# {"backports":false,"daily":false,"version":12,"arch":"amd64","file_extension":"qcow2","image_format":"qcow2"}
223# debian_url_spec_from_location https://cloud.debian.org/images/cloud/bookworm/20241004-1890/debian-12-generic-amd64-20241004-1890.qcow2
224# {"backports":false,"daily":false,"timestamp":"20241019-1905","version":12,"arch":"amd64","file_extension":"qcow2","image_format":"qcow2"}
225# debian_url_spec_from_location https://cloud.debian.org/images/cloud/bookworm/daily/latest/debian-12-genericcloud-amd64-daily.qcow2
226# {"backports":false,"daily":true,"version":12,"arch":"amd64","file_extension":"qcow2","image_format":"qcow2"}
227# debian_url_spec_from_location https://cloud.debian.org/images/cloud/bookworm/daily/20241019-1905/debian-12-genericcloud-amd64-daily-20241019-1905.qcow2
228# {"backports":false,"daily":true,"timestamp":"20241019-1905","version":12,"arch":"amd64","file_extension":"qcow2","image_format":"qcow2"}
229# debian_url_spec_from_location https://cloud.debian.org/images/cloud/bookworm-backports/latest/debian-12-backports-genericcloud-amd64.qcow2
230# {"backports":true,"daily":false,"version":12,"arch":"amd64","file_extension":"qcow2","image_format":"qcow2"}
231# debian_url_spec_from_location https://cloud.debian.org/images/cloud/bookworm-backports/20241004-1890/debian-12-backports-genericcloud-amd64-20241004-1890.qcow2
232# {"backports":true,"daily":false,"timestamp":"20241019-1905","version":12,"arch":"amd64","file_extension":"qcow2","image_format":"qcow2"}
233# debian_url_spec_from_location https://cloud.debian.org/images/cloud/bookworm-backports/daily/latest/debian-12-backports-genericcloud-amd64-daily.qcow2
234# {"backports":true,"daily":true,"version":12,"arch":"amd64","file_extension":"qcow2","image_format":"qcow2"}
235# debian_url_spec_from_location https://cloud.debian.org/images/cloud/bookworm-backports/daily/20241019-1905/debian-12-backports-genericcloud-amd64-daily-20241019-1905.qcow2
236# {"backports":true,"daily":true,"timestamp":"20241019-1905","version":12,"arch":"amd64","file_extension":"qcow2","image_format":"qcow2"}
237# ```
238# shellcheck disable=SC2034
239function debian_url_spec_from_location() {
240 local location=$1 backports=false daily=false timestamp='' codename version='' arch target_vendor file_extension image_format
241 local -r timestamp_pattern='[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]'
242 case "${location}" in
243 ${debian_base_url}*-backports/*) backports=true ;;&
244 ${debian_base_url}*/daily/*) daily=true ;;&
245 ${debian_base_url}*/${timestamp_pattern}/*) [[ ${location} =~ ${timestamp_pattern} ]] && timestamp=${BASH_REMATCH[0]} ;;
246 ${debian_base_url}*/latest/*) timestamp='' ;;
247 *)
248 # echo "Unsupported image location: ${location}" >&2
249 return 1
250 ;;
251 esac
252 codename=$(echo "${location#"${debian_base_url}"}" | cut -d/ -f1 | cut -d- -f1)
253 [[ -v debian_codename_to_version[${codename}] ]] || error_exit "Unknown codename: ${codename}"
254 version=${debian_codename_to_version[${codename}]}
255 arch=$(debian_arch_from_location_basename "${location}")
256 target_vendor=$(debian_target_vendor_from_location_basename "${location}")
257 file_extension=$(debian_file_extension_from_location_basename "${location}")
258 image_format=$(debian_image_format_from_file_extension "${file_extension}")
259 json_vars backports daily timestamp version arch target_vendor file_extension image_format
260}
261
262# debian_location_from_url_spec returns the location for the given URL spec.
263# e.g.
264# ```console
265# debian_location_from_url_spec '{"backports":false,"daily":false,"version":12,"arch":"amd64","file_extension":"qcow2"}'
266# https://cloud.debian.org/images/cloud/bookworm/latest/debian-12-genericcloud-amd64.qcow2
267# debian_location_from_url_spec '{"backports":false,"daily":false,"timestamp":"20241019-1905","version":12,"arch":"amd64","file_extension":"qcow2"}'
268# https://cloud.debian.org/images/cloud/bookworm/20241019-1905/debian-12-generic-amd64-20241019-1905.qcow2
269# debian_location_from_url_spec '{"backports":false,"daily":true,"version":12,"arch":"amd64","file_extension":"qcow2"}'
270# https://cloud.debian.org/images/cloud/bookworm/daily/latest/debian-12-genericcloud-amd64-daily.qcow2
271# debian_location_from_url_spec '{"backports":false,"daily":true,"timestamp":"20241019-1905","version":12,"arch":"amd64","file_extension":"qcow2"}'
272# https://cloud.debian.org/images/cloud/bookworm/daily/20241019-1905/debian-12-generic-amd64-daily-20241019-1905.qcow2
273# debian_location_from_url_spec '{"backports":true,"daily":false,"version":12,"arch":"amd64","file_extension":"qcow2"}'
274# https://cloud.debian.org/images/cloud/bookworm-backports/latest/debian-12-backports-genericcloud-amd64.qcow2
275# debian_location_from_url_spec '{"backports":true,"daily":false,"timestamp":"20241019-1905","version":12,"arch":"amd64","file_extension":"qcow2"}'
276# https://cloud.debian.org/images/cloud/bookworm-backports/20241019-1905/debian-12-backports-genericcloud-amd64-20241019-1905.qcow2
277# debian_location_from_url_spec '{"backports":true,"daily":true,"version":12,"arch":"amd64","file_extension":"qcow2"}'
278# https://cloud.debian.org/images/cloud/bookworm-backports/daily/latest/debian-12-backports-genericcloud-amd64-daily.qcow2
279# debian_location_from_url_spec '{"backports":true,"daily":true,"timestamp":"20241019-1905","version":12,"arch":"amd64","file_extension":"qcow2"}'
280# https://cloud.debian.org/images/cloud/bookworm-backports/daily/20241019-1905/debian-12-backports-genericcloud-amd64-daily-20241019-1905.qcow2
281# ```
282function debian_location_from_url_spec() {
283 local url_spec=$1 base_url version backports daily timestamp arch target_vendor file_extension
284 base_url=${debian_base_url}
285 version=$(jq -e -r '.version' <<<"${url_spec}")
286 [[ -v debian_version_to_codename[${version}] ]] || error_exit "Unsupported version: ${version}"
287 base_url+=${debian_version_to_codename[${version}]}
288 backports=$(jq -r 'if .backports then "-backports" else empty end' <<<"${url_spec}")
289 base_url+=${backports}/
290 daily=$(jq -r 'if .daily then "daily" else empty end' <<<"${url_spec}")
291 base_url+=${daily:+${daily}/}
292 timestamp=$(jq -r 'if .timestamp then .timestamp else empty end' <<<"${url_spec}")
293 base_url+=${timestamp:-latest}/
294 arch=$(jq -e -r '.arch' <<<"${url_spec}")
295 target_vendor=$(jq -r '.target_vendor // empty' <<<"${url_spec}")
296 [[ -z ${target_vendor} ]] && target_vendor=$(debian_target_vendor_from_arch "${arch}")
297 file_extension=$(jq -e -r '.file_extension' <<<"${url_spec}")
298 base_url+=debian-${version}${backports}-${target_vendor}-${arch}${daily:+-${daily}}${timestamp:+-${timestamp}}.${file_extension}
299 echo "${base_url}"
300}
301
302# debian_cache_key_for_image_kernel_overriding returns the cache key for the given location, kernel_location, flavor, and version.
303# If the image location is not supported, it returns 1.
304# kernel_location is not validated.
305# e.g.
306# ```console
307# debian_cache_key_for_image_kernel_overriding https://cloud-images.debian.com/minimal/releases/24.04/release-20210914/debian-24.04-minimal-cloudimg-amd64.img
308# debian_latest_24.04-minimal-amd64-release-.img
309# debian_cache_key_for_image_kernel_overriding https://cloud-images.debian.com/minimal/releases/24.04/release-20210914/debian-24.04-minimal-cloudimg-amd64.img https://...
310# debian_latest_with_kernel_24.04-minimal-amd64-release-.img
311# debian_cache_key_for_image_kernel_overriding https://cloud-images.debian.com/releases/24.04/release/debian-24.04-server-cloudimg-amd64.img null
312# debian_release_24.04-server-amd64-.img
313# ```
314function debian_cache_key_for_image_kernel_overriding() {
315 local location=$1 kernel_location=${2:-null} url_spec with_kernel='' version backports arch daily timestamped file_extension
316 url_spec=$(debian_url_spec_from_location "${location}")
317 [[ ${kernel_location} != "null" ]] && with_kernel=_with_kernel
318 version=$(jq -r '.version|if . then "-\(.)" else empty end' <<<"${url_spec}")
319 backports=$(jq -r 'if .backports then "-backports" else empty end' <<<"${url_spec}")
320 arch=$(jq -e -r '.arch' <<<"${url_spec}")
321 target_vendor=$(jq -r '.target_vendor // empty' <<<"${url_spec}")
322 [[ -z ${target_vendor} ]] && target_vendor=$(debian_target_vendor_from_arch "${arch}")
323 daily=$(jq -r 'if .daily then "-daily" else empty end' <<<"${url_spec}")
324 timestamped=$(jq -r 'if .timestamp then "-timestamped" else empty end' <<<"${url_spec}")
325 file_extension=$(jq -e -r '.file_extension' <<<"${url_spec}")
326 echo "debian${with_kernel}${version}${backports}-${target_vendor}-${arch}${daily}${timestamped}.${file_extension}"
327}
328
329function debian_image_entry_for_image_kernel_overriding() {
330 local location=$1 kernel_location=$2 overriding=${3:-"{}"} url_spec timestamped
331 [[ ${kernel_location} == "null" ]] || error_exit "Updating image with kernel is not supported"
332 url_spec=$(debian_url_spec_from_location "${location}" | jq -r ". + ${overriding}")
333 timestamped=$(jq -r 'if .timestamp then "timestamped" else "not_timestamped" end' <<<"${url_spec}")
334
335 local image_entry
336 image_entry=$(debian_image_url_"${timestamped}" "${url_spec}")
337 if [[ -z ${image_entry} ]]; then
338 error_exit "Failed to get the ${url_spec} image location for ${location}"
339 elif jq -e ".location == \"${location}\"" <<<"${image_entry}" >/dev/null; then
340 echo "Image location is up-to-date: ${location}" >&2
341 else
342 echo "${image_entry}"
343 fi
344}
345
346# check if the script is executed or sourced
347# shellcheck disable=SC1091
348if [[ ${BASH_SOURCE[0]} == "${0}" ]]; then
349 scriptdir=$(dirname "${BASH_SOURCE[0]}")
350 # shellcheck source=./cache-common-inc.sh
351 . "${scriptdir}/cache-common-inc.sh"
352
353 # shellcheck source=/dev/null # avoid shellcheck hangs on source looping
354 . "${scriptdir}/update-template.sh"
355else
356 # this script is sourced
357 if [[ -v SUPPORTED_DISTRIBUTIONS ]]; then
358 SUPPORTED_DISTRIBUTIONS+=("debian")
359 else
360 declare -a SUPPORTED_DISTRIBUTIONS=("debian")
361 fi
362 # required functions for Debian
363 function debian_cache_key_for_image_kernel() { debian_cache_key_for_image_kernel_overriding "$@"; }
364 function debian_image_entry_for_image_kernel() { debian_image_entry_for_image_kernel_overriding "$@"; }
365
366 return 0
367fi
368
369declare -a templates=()
370declare overriding="{}"
371while [[ $# -gt 0 ]]; do
372 case "$1" in
373 -h | --help)
374 debian_print_help
375 exit 0
376 ;;
377 -d | --debug) set -x ;;
378 --backports | --daily | --timestamped)
379 overriding=$(json "${1#--}" true <<<"${overriding}")
380 ;;
381 --backports=* | --daily=* | --timestamped=*)
382 overriding=$(
383 key=${1#--} value=$(validate_boolean "${1#*=}")
384 json "${key%%=*}" "${value}" <<<"${overriding}"
385 )
386 ;;
387 --version)
388 if [[ -n $2 && $2 != -* ]]; then
389 overriding=$(
390 version=$(debian_version_resolve_aliases "$2")
391 json_vars version <<<"${overriding}"
392 )
393 shift
394 else
395 error_exit "--version requires a value"
396 fi
397 ;;
398 --version=*)
399 overriding=$(
400 version=$(debian_version_resolve_aliases "${1#*=}")
401 json_vars version <<<"${overriding}"
402 )
403 ;;
404 *.yaml) templates+=("$1") ;;
405 *)
406 error_exit "Unknown argument: $1"
407 ;;
408 esac
409 shift
410 [[ -z ${overriding} ]] && overriding="{}"
411done
412
413if [[ ${#templates[@]} -eq 0 ]]; then
414 debian_print_help
415 exit 0
416fi
417
418declare -A image_entry_cache=()
419
420for template in "${templates[@]}"; do
421 echo "Processing ${template}"
422 # 1. extract location by parsing template using arch
423 yq_filter="
424 .images[] | [.location, .kernel.location, .kernel.cmdline] | @tsv
425 "
426 parsed=$(yq eval "${yq_filter}" "${template}")
427
428 # 3. get the image location
429 arr=()
430 while IFS= read -r line; do arr+=("${line}"); done <<<"${parsed}"
431 locations=("${arr[@]}")
432 for ((index = 0; index < ${#locations[@]}; index++)); do
433 [[ ${locations[index]} != "null" ]] || continue
434 set -e
435 IFS=$'\t' read -r location kernel_location kernel_cmdline <<<"${locations[index]}"
436 set +e # Disable 'set -e' to avoid exiting on error for the next assignment.
437 cache_key=$(
438 set -e # Enable 'set -e' for the next command.
439 debian_cache_key_for_image_kernel_overriding "${location}" "${kernel_location}"
440 ) # Check exit status separately to prevent disabling 'set -e' by using the function call in the condition.
441 # shellcheck disable=2181
442 [[ $? -eq 0 ]] || continue
443 image_entry=$(
444 set -e # Enable 'set -e' for the next command.
445 if [[ -v image_entry_cache[${cache_key}] ]]; then
446 echo "${image_entry_cache[${cache_key}]}"
447 else
448 debian_image_entry_for_image_kernel_overriding "${location}" "${kernel_location}" "${overriding}"
449 fi
450 ) # Check exit status separately to prevent disabling 'set -e' by using the function call in the condition.
451 # shellcheck disable=2181
452 [[ $? -eq 0 ]] || continue
453 set -e
454 image_entry_cache[${cache_key}]="${image_entry}"
455 if [[ -n ${image_entry} ]]; then
456 [[ ${kernel_cmdline} != "null" ]] &&
457 jq -e 'has("kernel")' <<<"${image_entry}" >/dev/null &&
458 image_entry=$(jq ".kernel.cmdline = \"${kernel_cmdline}\"" <<<"${image_entry}")
459 echo "${image_entry}" | jq
460 limactl edit --log-level error --set "
461 .images[${index}] *= ${image_entry}|
462 (.images[${index}] | ..) style = \"double\"
463 " "${template}"
464 fi
465 done
466done