app-misc/ca-certificates: Account for certs missing newlines

Concatenating certificates missing newlines naively with cat results in broken
bundle. Fix the issue by using a sed expression that appends a trailing newline
after the lastline if it is missing.

Issue: flatcar/flatcar#1601
Signed-off-by: Jeremi Piotrowski <jpiotrowski@microsoft.com>
This commit is contained in:
Jeremi Piotrowski 2025-02-14 10:49:37 +01:00
parent 5bf6167cb2
commit 2379713951
2 changed files with 2 additions and 1 deletions

View File

@ -32,7 +32,8 @@ if [[ ! -e "${CERTBUNDLE}" || "${CERTSDIR}" -nt "${CERTBUNDLE}" ]]; then
trap "rm -f '${CERTSDIR}/${TEMPBUNDLE}'" EXIT
# Use .0 instead of .pem to pull in only what c_rehash validated
cat "${CERTSDIR}"/*.[0-9] > "${TEMPBUNDLE}"
sed --separate '$a\' "${CERTSDIR}"/*.[0-9] >"${TEMPBUNDLE}"
chmod 644 "${TEMPBUNDLE}"
mv -f "${TEMPBUNDLE}" "${CERTBUNDLE}"
trap - EXIT