Apply bash scripting suggestions from code review

Thank you Krzesimir!

Co-authored-by: Krzesimir Nowak <knowak@microsoft.com>
This commit is contained in:
Thilo Fromm 2023-10-20 16:41:13 +02:00
parent b775036a62
commit c2d1c13abd
3 changed files with 13 additions and 14 deletions

View File

@ -33,8 +33,7 @@ create_prod_sysext() {
local grp_pkg="$7"
local pkginfo="${8:-}"
local pkginfo_opt=""
local manglefs_opt=""
local -a build_sysext_opts=()
local msg="Installing ${grp_pkg}' in sysext ${name}.raw"
@ -44,12 +43,12 @@ create_prod_sysext() {
die "Sysext build '${grp_pkg}': unable to find package info at '${output_dir}/${pkginfo}'."
fi
msg="${msg} w/ package info '${pkginfo}'"
pkginfo_opt="--base_pkginfo=${output_dir}/${pkginfo}"
build_sysext_opts+=( "--base_pkginfo=${output_dir}/${pkginfo}" )
fi
# Include FS mangle script if present
if [[ -x "${BUILD_LIBRARY_DIR}/sysext_mangle_${name}" ]] ; then
manglefs_opt="--manglefs_script=${BUILD_LIBRARY_DIR}/sysext_mangle_${name}"
build_sysext_opts+=( "--manglefs_script=${BUILD_LIBRARY_DIR}/sysext_mangle_${name}" )
msg="${msg}, FS mangle script 'sysext_mangle_${name}'"
fi
@ -60,7 +59,7 @@ create_prod_sysext() {
--image_builddir="${workdir}/sysext-build" \
--squashfs_base="${base_sysext}" \
--generate_pkginfo \
${manglefs_opt} ${pkginfo_opt} \
"${build_sysext_opts[@]}" \
"${name}" "${grp_pkg}"
sudo mv "${workdir}/sysext-build/${name}.raw" "${workdir}/sysext-build/${name}_pkginfo.raw" \

View File

@ -51,10 +51,10 @@ function set_vars() {
# Read by the mantle container.
# The local directory ("pwd") will be mounted to /work/ in the container.
cat > sdk_container/.env <<EOF
export export QEMU_IMAGE_NAME="/work/__build__/images/images/${arch}-usr/latest/flatcar_production_image.bin"
export QEMU_UEFI_BIOS="/work/__build__/images/images/${arch}-usr/latest/flatcar_production_qemu_uefi_efi_code.fd"
export QEMU_UPDATE_PAYLOAD="/work/__build__/images/images/${arch}-usr/latest/flatcar_test_update.gz"
export PARALLEL_TESTS=${parallel}
export QEMU_IMAGE_NAME="/work/__build__/images/images/${arch@Q}-usr/latest/flatcar_production_image.bin"
export QEMU_UEFI_BIOS="/work/__build__/images/images/${arch@Q}-usr/latest/flatcar_production_qemu_uefi_efi_code.fd"
export QEMU_UPDATE_PAYLOAD="/work/__build__/images/images/${arch@Q}-usr/latest/flatcar_test_update.gz"
export PARALLEL_TESTS=${parallel@Q}
EOF
export MAX_RETRIES=5
@ -62,7 +62,7 @@ EOF
}
#--
function run_local_tests() {
function run_local_tests() (
local arch="${1:-amd64}"
if [[ $# -gt 0 ]] ; then shift; fi
local parallel="${1:-2}"
@ -98,7 +98,7 @@ function run_local_tests() {
test_run "${arch}" qemu_update
fi
}
)
# --

View File

@ -51,7 +51,7 @@ usage() {
}
# --
update_versionfile="true"
update_versionfile=x
while [ 0 -lt $# ] ; do
case "$1" in
-h) usage; exit 0;;
@ -66,7 +66,7 @@ while [ 0 -lt $# ] ; do
-C) custom_image="$2"; shift; shift;;
-U) sdk_version="$(get_sdk_version_from_versionfile)"
os_version="$(get_version_from_versionfile)"
update_versionfile="false"
update_versionfile=
shift;;
*) break;;
esac
@ -79,7 +79,7 @@ else
container_image_name="$sdk_container_common_registry/flatcar-sdk-${arch}:${docker_sdk_vernum}"
fi
if [[ "${update_versionfile}" == true ]] ; then
if [[ -n ${update_versionfile} ]] ; then
create_versionfile "$sdk_version" "$os_version"
fi