Merge pull request #1201 from flatcar/krnowak/fix-image-changes

Fix garbled output in image changes reports
This commit is contained in:
Krzesimir Nowak 2023-09-29 14:16:26 +02:00 committed by GitHub
commit 1f5658e7ad
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 33 additions and 20 deletions

View File

@ -225,6 +225,9 @@ jobs:
) )
show_changes_env=( show_changes_env=(
# Nothing to add. # Nothing to add.
"SCRIPTS_REPO=scripts"
"COREOS_OVERLAY_REPO=coreos-overlay"
"PORTAGE_STABLE_REPO=portage-stable"
) )
show_changes_params_overrides=( show_changes_params_overrides=(
# We may not have a tag handy, so we tell show-changes # We may not have a tag handy, so we tell show-changes

View File

@ -63,6 +63,9 @@ function image_changes() (
show_changes_env=( show_changes_env=(
# Provide a python3 command for the CVE DB parsing # Provide a python3 command for the CVE DB parsing
"PATH=${PATH}:${PWD}/ci-automation/python-bin" "PATH=${PATH}:${PWD}/ci-automation/python-bin"
"SCRIPTS_REPO=scripts"
"COREOS_OVERLAY_REPO=coreos-overlay"
"PORTAGE_STABLE_REPO=portage-stable"
) )
show_changes_params_overrides=( show_changes_params_overrides=(
# Nothing to override. # Nothing to override.
@ -83,7 +86,7 @@ function image_changes() (
echo "Image URL: http://${BUILDCACHE_SERVER}/images/${arch}/${vernum}/flatcar_production_image.bin.bz2" echo "Image URL: http://${BUILDCACHE_SERVER}/images/${arch}/${vernum}/flatcar_production_image.bin.bz2"
echo echo
generate_image_changes_report \ generate_image_changes_report \
"${arch}" "${channel}" "${vernum}" /dev/stdout "${fbs_repo}" "${work_directory}" \ "${arch}" "${channel}" "${vernum}" '-' "${fbs_repo}" "${work_directory}" \
"${package_diff_env[@]}" --- "${package_diff_params_b[@]}" -- \ "${package_diff_env[@]}" --- "${package_diff_params_b[@]}" -- \
"${size_changes_env[@]}" --- "${size_changes_params_b[@]}" -- \ "${size_changes_env[@]}" --- "${size_changes_params_b[@]}" -- \
"${show_changes_env[@]}" --- "${show_changes_params_overrides[@]}" "${show_changes_env[@]}" --- "${show_changes_params_overrides[@]}"
@ -177,14 +180,21 @@ function generate_image_changes_report() (
"${show_changes_params[@]}" "${show_changes_params[@]}"
) )
{ local print_image_reports_invocation=(
# Using "|| :" to avoid failing the job. print_image_reports
print_image_reports \ "${flatcar_build_scripts_repo}" "${channel_a}" "${version_a}" "${work_directory}"
"${flatcar_build_scripts_repo}" "${channel_a}" "${version_a}" "${work_directory}" \ "${package_diff_env[@]}" --- "${package_diff_params[@]}" --
"${package_diff_env[@]}" --- "${package_diff_params[@]}" -- \ "${size_changes_env[@]}" --- "${size_changes_params[@]}" --
"${size_changes_env[@]}" --- "${size_changes_params[@]}" -- \ "${show_changes_env[@]}" --- "${show_changes_params[@]}"
"${show_changes_env[@]}" --- "${show_changes_params[@]}" || : )
} >"${report_output}" # Using "|| :" to avoid failing the job.
if [[ ${report_output} = '-' ]]; then
"${print_image_reports_invocation[@]}" || :
else
{
"${print_image_reports_invocation[@]}" || :
} >"${report_output}"
fi
) )
# -- # --
@ -301,25 +311,25 @@ function print_image_reports() {
env \ env \
--chdir="${work_directory}" \ --chdir="${work_directory}" \
"${package_diff_env[@]}" FILE=flatcar_production_image_packages.txt \ "${package_diff_env[@]}" FILE=flatcar_production_image_packages.txt \
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" "${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" 2>&1
echo echo
echo "Image file changes, compared to ${channel_a} ${version_a}:" echo "Image file changes, compared to ${channel_a} ${version_a}:"
env \ env \
--chdir="${work_directory}" \ --chdir="${work_directory}" \
"${package_diff_env[@]}" FILE=flatcar_production_image_contents.txt FILESONLY=1 CUTKERNEL=1 \ "${package_diff_env[@]}" FILE=flatcar_production_image_contents.txt FILESONLY=1 CUTKERNEL=1 \
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" "${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" 2>&1
echo echo
echo "Image kernel config changes, compared to ${channel_a} ${version_a}:" echo "Image kernel config changes, compared to ${channel_a} ${version_a}:"
env \ env \
--chdir="${work_directory}" \ --chdir="${work_directory}" \
"${package_diff_env[@]}" FILE=flatcar_production_image_kernel_config.txt \ "${package_diff_env[@]}" FILE=flatcar_production_image_kernel_config.txt \
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" "${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" 2>&1
echo echo
echo "Image init ramdisk file changes, compared to ${channel_a} ${version_a}:" echo "Image init ramdisk file changes, compared to ${channel_a} ${version_a}:"
env \ env \
--chdir="${work_directory}" \ --chdir="${work_directory}" \
"${package_diff_env[@]}" FILE=flatcar_production_image_initrd_contents.txt FILESONLY=1 \ "${package_diff_env[@]}" FILE=flatcar_production_image_initrd_contents.txt FILESONLY=1 \
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" "${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" 2>&1
echo echo
local size_changes_invocation=( local size_changes_invocation=(
@ -329,13 +339,13 @@ function print_image_reports() {
"${flatcar_build_scripts_repo}/size-change-report.sh" "${flatcar_build_scripts_repo}/size-change-report.sh"
) )
echo "Image file size changes, compared to ${channel_a} ${version_a}:" echo "Image file size changes, compared to ${channel_a} ${version_a}:"
if ! "${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:wtd}"; then if ! "${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:wtd}" 2>&1; then
"${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:old}" "${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:old}" 2>&1
fi fi
echo echo
echo "Image init ramdisk file size changes, compared to ${channel_a} ${version_a}:" echo "Image init ramdisk file size changes, compared to ${channel_a} ${version_a}:"
if ! "${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:initrd-wtd}"; then if ! "${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:initrd-wtd}" 2>&1; then
"${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:initrd-old}" "${size_changes_invocation[@]}" "${size_change_report_params[@]/%/:initrd-old}" 2>&1
fi fi
echo "Take the total size difference with a grain of salt as normally initrd is compressed, so the actual difference will be smaller." echo "Take the total size difference with a grain of salt as normally initrd is compressed, so the actual difference will be smaller."
echo "To see the actual difference in size, see if there was a report for /boot/flatcar/vmlinuz-a." echo "To see the actual difference in size, see if there was a report for /boot/flatcar/vmlinuz-a."
@ -346,7 +356,7 @@ function print_image_reports() {
env \ env \
--chdir="${work_directory}" \ --chdir="${work_directory}" \
"${package_diff_env[@]}" FILE=flatcar_production_image_contents.txt CALCSIZE=1 \ "${package_diff_env[@]}" FILE=flatcar_production_image_contents.txt CALCSIZE=1 \
"${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" "${flatcar_build_scripts_repo}/package-diff" "${package_diff_params[@]}" 2>&1
echo echo
local param local param
@ -359,7 +369,7 @@ function print_image_reports() {
"${show_changes_env[@]}" \ "${show_changes_env[@]}" \
"${flatcar_build_scripts_repo}/show-changes" \ "${flatcar_build_scripts_repo}/show-changes" \
"${SHOW_CHANGES_NEW_CHANNEL}-${SHOW_CHANGES_NEW_CHANNEL_PREV_VERSION}" \ "${SHOW_CHANGES_NEW_CHANNEL}-${SHOW_CHANGES_NEW_CHANNEL_PREV_VERSION}" \
"${SHOW_CHANGES_NEW_VERSION}" "${SHOW_CHANGES_NEW_VERSION}" 2>&1
# See if a channel transition happened and print the changelog against ${channel_a} ${version_a} which is the previous release # See if a channel transition happened and print the changelog against ${channel_a} ${version_a} which is the previous release
if [ "${channel_a}" != "${SHOW_CHANGES_NEW_CHANNEL}" ]; then if [ "${channel_a}" != "${SHOW_CHANGES_NEW_CHANNEL}" ]; then
env \ env \
@ -367,7 +377,7 @@ function print_image_reports() {
"${show_changes_env[@]}" \ "${show_changes_env[@]}" \
"${flatcar_build_scripts_repo}/show-changes" \ "${flatcar_build_scripts_repo}/show-changes" \
"${channel_a}-${version_a}" \ "${channel_a}-${version_a}" \
"${SHOW_CHANGES_NEW_VERSION}" "${SHOW_CHANGES_NEW_VERSION}" 2>&1
fi fi
} }
# -- # --