mirror of
https://github.com/flatcar/scripts.git
synced 2025-10-02 19:11:20 +02:00
eclass/coreos-cargo: Ensure the modified config is valid TOML
We were appending the [build] section, and the updated cargo eclass already added that to the config, so we ended up with having two [build] sections in the config file. Try to amend the section instead of appending it to the file. While at it, do the same with the target.${RUST_TARGET} section too to be a bit more futureproof.
This commit is contained in:
parent
f302e69455
commit
14ec0b2456
@ -76,15 +76,36 @@ coreos-cargo_src_unpack() {
|
|||||||
|
|
||||||
# Compile for the built-in target, using the SDK cross-tools.
|
# Compile for the built-in target, using the SDK cross-tools.
|
||||||
export RUST_TARGET=$(rust_builtin_target "${CHOST}")
|
export RUST_TARGET=$(rust_builtin_target "${CHOST}")
|
||||||
cat <<- EOF >> "${ECARGO_HOME}/config"
|
local -a config_lines
|
||||||
|
local build_amended=0
|
||||||
[build]
|
local target_rust_target_amended=0
|
||||||
target = "${RUST_TARGET}"
|
local REPLY
|
||||||
|
readonly b_header='[build]'
|
||||||
[target.${RUST_TARGET}]
|
readonly t_header="[target.${RUST_TARGET}]"
|
||||||
ar = "${TARGET_AR}"
|
readonly target_line="target = \"${RUST_TARGET}\""
|
||||||
linker = "${TARGET_CC}"
|
readonly ar_line="ar = \"${TARGET_AR}\""
|
||||||
EOF
|
readonly linker_line="linker = \"${TARGET_CC}\""
|
||||||
|
while read -r; do
|
||||||
|
config_lines+=("${REPLY}")
|
||||||
|
case "${REPLY}" in
|
||||||
|
"${b_header}")
|
||||||
|
config_lines+=("${target_line}")
|
||||||
|
build_amended=1
|
||||||
|
;;
|
||||||
|
"${t_header}")
|
||||||
|
config_lines+=("${ar_line}")
|
||||||
|
config_lines+=("${linker_line}")
|
||||||
|
target_rust_target_amended=1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
done <"${ECARGO_HOME}/config"
|
||||||
|
if [[ "${build_amended}" -eq 0 ]]; then
|
||||||
|
config_lines+=('' "${b_header}" "${target_line}")
|
||||||
|
fi
|
||||||
|
if [[ "" -eq 0 ]]; then
|
||||||
|
config_lines+=('' "${t_header}" "${ar_line}" "${linker_line}")
|
||||||
|
fi
|
||||||
|
printf '%s\n' "${config_lines[@]}" >"${ECARGO_HOME}/config"
|
||||||
}
|
}
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
x
Reference in New Issue
Block a user