diff --git a/pkg_auto/impl/pkg_auto_lib.sh b/pkg_auto/impl/pkg_auto_lib.sh index 4342e59254..1f7b33c7bd 100644 --- a/pkg_auto/impl/pkg_auto_lib.sh +++ b/pkg_auto/impl/pkg_auto_lib.sh @@ -53,6 +53,7 @@ source "$(dirname "${BASH_SOURCE[0]}")/util.sh" source "${PKG_AUTO_IMPL_DIR}/cleanups.sh" source "${PKG_AUTO_IMPL_DIR}/debug.sh" source "${PKG_AUTO_IMPL_DIR}/gentoo_ver.sh" +source "${PKG_AUTO_IMPL_DIR}/md5_cache_diff_lib.sh" # Sets up the workdir using the passed config. The config can be # created basing on the config_template file or using the @@ -2185,9 +2186,9 @@ function handle_pkg_update() { local pkg_name pkg_name=${new_pkg#*/} local -a lines - lines=( "from ${old} to ${new}") + lines=( "0:from ${old} to ${new}") if [[ ${old_pkg} != "${new_pkg}" ]]; then - lines+=( "renamed from ${old_pkg}" ) + lines+=( "0:renamed from ${old_pkg}" ) fi # shellcheck disable=SC2153 # OLD_PORTAGE_STABLE is not a misspelling, it comes from globals file generate_ebuild_diff "${OLD_PORTAGE_STABLE}" "${NEW_PORTAGE_STABLE}" "${old_pkg}" "${new_pkg}" "${old_s}" "${new_s}" "${old}" "${new}" @@ -2196,15 +2197,28 @@ function handle_pkg_update() { local hpu_update_dir hpu_update_dir_non_slot update_dir_non_slot "${new_pkg}" hpu_update_dir_non_slot update_dir "${new_pkg}" "${old_s}" "${new_s}" hpu_update_dir + + local diff_report_name + gen_varname diff_report_name + diff_report_declare "${diff_report_name}" + generate_cache_diff_report "${diff_report_name}" "${WORKDIR}/pkg-reports/old/portage-stable-cache" "${WORKDIR}/pkg-reports/new/portage-stable-cache" "${old_pkg}" "${new_pkg}" "${old}" "${new}" + + local -n diff_report_ref=${diff_report_name} + local -n diff_lines_ref=${diff_report_ref[${DR_LINES_IDX}]} + lines+=( "${diff_lines_ref[@]}" ) + unset -n diff_lines_ref + unset -n diff_report_ref + diff_report_unset "${diff_report_name}" + if [[ -s "${hpu_update_dir}/ebuild.diff" ]]; then - lines+=( 'TODO: review ebuild.diff' ) + lines+=( '0:TODO: review ebuild.diff' ) fi if [[ -s "${hpu_update_dir_non_slot}/other.diff" ]]; then - lines+=( 'TODO: review other.diff' ) + lines+=( '0:TODO: review other.diff' ) fi - lines+=( 'TODO: review occurences' ) + lines+=( '0:TODO: review occurences' ) if [[ ${old_pkg} != "${new_pkg}" ]]; then - lines+=( 'TODO: review occurences-for-old-name' ) + lines+=( '0:TODO: review occurences-for-old-name' ) fi local -a hpu_tags @@ -2213,7 +2227,7 @@ function handle_pkg_update() { if ver_test "${new_no_r}" -gt "${old_no_r}"; then # version bump generate_changelog_entry_stub "${pkg_name}" "${new_no_r}" "${hpu_tags[@]}" - lines+=( 'release notes: TODO' ) + lines+=( '0:release notes: TODO' ) fi generate_summary_stub "${new_pkg}" "${hpu_tags[@]}" -- "${lines[@]}" @@ -2253,12 +2267,12 @@ function handle_pkg_as_is() { local pkg_name pkg_name=${new_pkg#/} local -a lines - lines=( "still at ${v}" ) + lines=( "0:still at ${v}" ) local renamed renamed= if [[ ${old_pkg} != "${new_pkg}" ]]; then - lines+=( "renamed from ${old_pkg}" ) + lines+=( "0:renamed from ${old_pkg}" ) renamed=x fi generate_ebuild_diff "${OLD_PORTAGE_STABLE}" "${NEW_PORTAGE_STABLE}" "${old_pkg}" "${new_pkg}" "${old_s}" "${new_s}" "${v}" "${v}" @@ -2267,12 +2281,28 @@ function handle_pkg_as_is() { update_dir "${new_pkg}" "${old_s}" "${new_s}" hpai_update_dir local modified modified= + + local diff_report_name + gen_varname diff_report_name + diff_report_declare "${diff_report_name}" + generate_cache_diff_report "${diff_report_name}" "${WORKDIR}/pkg-reports/old/portage-stable-cache" "${WORKDIR}/pkg-reports/new/portage-stable-cache" "${old_pkg}" "${new_pkg}" "${v}" "${v}" + + local -n diff_report_ref=${diff_report_name} + local -n diff_lines_ref=${diff_report_ref[${DR_LINES_IDX}]} + if [[ ${#diff_lines_ref[@]} -gt 0 ]]; then + lines+=( "${diff_lines_ref[@]}" ) + modified=x + fi + unset -n diff_lines_ref + unset -n diff_report_ref + diff_report_unset "${diff_report_name}" + if [[ -s "${hpai_update_dir}/ebuild.diff" ]]; then - lines+=( 'TODO: review ebuild.diff' ) + lines+=( '0:TODO: review ebuild.diff' ) modified=x fi if [[ -s "${hpai_update_dir_non_slot}/other.diff" ]]; then - lines+=( 'TODO: review other.diff' ) + lines+=( '0:TODO: review other.diff' ) modified=x fi if [[ -z ${renamed} ]] && [[ -z ${modified} ]]; then @@ -2281,9 +2311,9 @@ function handle_pkg_as_is() { fi # shellcheck disable=SC2034 # ref to an external variable changed_ref=x - lines+=( 'TODO: review occurences' ) + lines+=( '0:TODO: review occurences' ) if [[ ${old_pkg} != "${new_pkg}" ]]; then - lines+=( 'TODO: review occurences-for-old-name' ) + lines+=( '0:TODO: review occurences-for-old-name' ) fi local -a hpai_tags @@ -2324,24 +2354,37 @@ function handle_pkg_downgrade() { local pkg_name pkg_name=${new_pkg#*/} local -a lines - lines=( "downgraded from ${old} to ${new}" ) + lines=( "0:downgraded from ${old} to ${new}" ) if [[ ${old_pkg} != "${new_pkg}" ]]; then - lines+=( "renamed from ${old_pkg}" ) + lines+=( "0:renamed from ${old_pkg}" ) fi generate_ebuild_diff "${OLD_PORTAGE_STABLE}" "${NEW_PORTAGE_STABLE}" "${old_pkg}" "${new_pkg}" "${old_s}" "${new_s}" "${old}" "${new}" local hpd_update_dir hpd_update_dir_non_slot update_dir_non_slot "${new_pkg}" hpd_update_dir_non_slot update_dir "${new_pkg}" "${old_s}" "${new_s}" hpd_update_dir + + local diff_report_name + gen_varname diff_report_name + diff_report_declare "${diff_report_name}" + generate_cache_diff_report "${diff_report_name}" "${WORKDIR}/pkg-reports/old/portage-stable-cache" "${WORKDIR}/pkg-reports/new/portage-stable-cache" "${old_pkg}" "${new_pkg}" "${old}" "${new}" + + local -n diff_report_ref=${diff_report_name} + local -n diff_lines_ref=${diff_report_ref[${DR_LINES_IDX}]} + lines+=( "${diff_lines_ref[@]}" ) + unset -n diff_lines_ref + unset -n diff_report_ref + diff_report_unset "${diff_report_name}" + if [[ -s "${hpd_update_dir}/ebuild.diff" ]]; then - lines+=( 'TODO: review ebuild.diff' ) + lines+=( '0:TODO: review ebuild.diff' ) fi if [[ -s "${hpd_update_dir_non_slot}/other.diff" ]]; then - lines+=( 'TODO: review other.diff' ) + lines+=( '0:TODO: review other.diff' ) fi - lines+=( 'TODO: review occurences' ) + lines+=( '0:TODO: review occurences' ) if [[ ${old_pkg} != "${new_pkg}" ]]; then - lines+=( 'TODO: review occurences-for-old-name' ) + lines+=( '0:TODO: review occurences-for-old-name' ) fi local -a hpd_tags @@ -2350,7 +2393,7 @@ function handle_pkg_downgrade() { if ver_test "${new_no_r}" -lt "${old_no_r}"; then # version bump generate_changelog_entry_stub "${pkg_name}" "${new_no_r}" "${hpd_tags[@]}" - lines+=( "release notes: TODO" ) + lines+=( "0:release notes: TODO" ) fi generate_summary_stub "${new_pkg}" "${hpd_tags[@]}" -- "${lines[@]}" @@ -2456,10 +2499,16 @@ function generate_summary_stub() { printf ' [%s]' "${tags[@]}" fi printf '\n' - if [[ ${#} -gt 0 ]]; then - printf ' - %s\n' "${@}" - printf '\n' - fi + local indent_line indent line + for indent_line; do + indent=${indent_line%%:*} + line=${indent_line#*:} + if [[ ${indent} -gt 0 ]]; then + printf -- ' %.0s' $(seq 1 "${indent}") + fi + printf ' - %s\n' "${line}" + done + printf '\n' } >>"${REPORTS_DIR}/updates/summary_stubs" } @@ -2565,6 +2614,32 @@ function generate_ebuild_diff() { xdiff --unified=3 "${old_path}" "${new_path}" >"${ged_update_dir}/ebuild.diff" } +function generate_cache_diff_report() { + local diff_report_var_name=${1}; shift + local old_cache_dir=${1}; shift + local new_cache_dir=${1}; shift + local old_pkg=${1}; shift + local new_pkg=${1}; shift + local old=${1}; shift + local new=${1}; shift + + source "${WORKDIR}/globals" + + local old_entry=${old_cache_dir}/${old_pkg}-${old} + local new_entry=${new_cache_dir}/${new_pkg}-${new} + + local old_cache_name new_cache_name + gen_varname old_cache_name + gen_varname new_cache_name + cache_file_declare "${old_cache_name}" "${new_cache_name}" + parse_cache_file "${old_cache_name}" "${old_entry}" "${ARCHES[@]}" + parse_cache_file "${new_cache_name}" "${new_entry}" "${ARCHES[@]}" + + diff_cache_data "${old_cache_name}" "${new_cache_name}" "${diff_report_var_name}" + + cache_file_unset "${old_cache_name}" "${new_cache_name}" +} + # Generate a report with information where the old and new packages # are mentioned in entire scripts repository. May result in two # separate reports if the package got renamed. @@ -2936,11 +3011,11 @@ function handle_eclass() { if [[ -e "${OLD_PORTAGE_STABLE}/${eclass}" ]] && [[ -e "${NEW_PORTAGE_STABLE}/${eclass}" ]]; then mkdir -p "${REPORTS_DIR}/updates/${eclass}" xdiff --unified=3 "${OLD_PORTAGE_STABLE}/${eclass}" "${NEW_PORTAGE_STABLE}/${eclass}" >"${REPORTS_DIR}/updates/${eclass}/eclass.diff" - lines+=( 'TODO: review the diff' ) + lines+=( '0:TODO: review the diff' ) elif [[ -e "${OLD_PORTAGE_STABLE}/${eclass}" ]]; then - lines+=( 'unused, dropped' ) + lines+=( '0:unused, dropped' ) else - lines+=( 'added from Gentoo' ) + lines+=( '0:added from Gentoo' ) fi generate_summary_stub "${eclass}" -- "${lines[@]}" } @@ -3014,7 +3089,7 @@ function handle_profiles() { done <"${out_dir}/full.diff" lines_to_file_truncate "${out_dir}/relevant.diff" "${relevant_lines[@]}" lines_to_file_truncate "${out_dir}/possibly-irrelevant-files" "${possibly_irrelevant_files[@]}" - generate_summary_stub profiles -- 'TODO: review the diffs' + generate_summary_stub profiles -- '0:TODO: review the diffs' } # Handles changes in license directory. Generates brief reports and @@ -3083,15 +3158,15 @@ function handle_licenses() { local joined if [[ ${#dropped[@]} -gt 0 ]]; then join_by joined ', ' "${dropped[@]}" - lines+=( "dropped ${joined}" ) + lines+=( "0:dropped ${joined}" ) fi if [[ ${#added[@]} -gt 0 ]]; then join_by joined ', ' "${added[@]}" - lines+=( "added ${joined}" ) + lines+=( "0:added ${joined}" ) fi if [[ ${#changed[@]} -gt 0 ]]; then join_by joined ', ' "${changed[@]}" - lines+=( "updated ${joined}" ) + lines+=( "0:updated ${joined}" ) fi generate_summary_stub licenses -- "${lines[@]}" } @@ -3106,7 +3181,7 @@ function handle_scripts() { mkdir -p "${out_dir}" xdiff --unified=3 --recursive "${OLD_PORTAGE_STABLE}/scripts" "${NEW_PORTAGE_STABLE}/scripts" >"${out_dir}/scripts.diff" - generate_summary_stub scripts -- 'TODO: review the diffs' + generate_summary_stub scripts -- '0:TODO: review the diffs' } fi