Skip to content

Commit 832d405

Browse files
committed
pkg-auto: Diff directories based on updates directory
This is a continuation of passing the explicit location of an output directory instead of hardcoding `${REPORTS_DIR}`. Signed-off-by: Krzesimir Nowak <[email protected]>
1 parent 26d9249 commit 832d405

File tree

1 file changed

+45
-19
lines changed

1 file changed

+45
-19
lines changed

pkg_auto/impl/pkg_auto_lib.sh

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -2075,6 +2075,7 @@ function handle_package_changes() {
20752075
# "manual action needed" report.
20762076

20772077
local warnings_dir="${REPORTS_DIR}"
2078+
local updates_dir="${REPORTS_DIR}/updates"
20782079

20792080
local pkg_idx=0
20802081
local old_name new_name old_repo new_repo
@@ -2086,9 +2087,9 @@ function handle_package_changes() {
20862087
local hpc_cmp_result
20872088
local -A hpc_only_old_slots_set hpc_only_new_slots_set hpc_common_slots_set
20882089
local -a lines
2089-
local hpc_update_dir
2090+
local update_dir
20902091
local -A empty_map_or_set
2091-
local hpc_changed hpc_slot_changed hpc_update_dir_non_slot hpc_category_dir
2092+
local hpc_changed hpc_slot_changed update_dir_non_slot hpc_slot_dirname hpc_category_dir
20922093
local which slots_set_var_name_var_name slot_verminmax_map_var_name_var_name filtered_slots_set_var_name verminmax
20932094
local -A hpc_old_filtered_slots_set hpc_new_filtered_slots_set
20942095
empty_map_or_set=()
@@ -2194,17 +2195,17 @@ function handle_package_changes() {
21942195
pkg_debug "slots only for old name: ${!hpc_only_old_slots_set[*]}"
21952196
pkg_debug "slots only for new name: ${!hpc_only_new_slots_set[*]}"
21962197

2197-
update_dir_non_slot "${new_name}" hpc_update_dir_non_slot
2198-
mkdir -p "${hpc_update_dir_non_slot}"
2198+
update_dir_non_slot="${updates_dir}/${new_name}"
2199+
mkdir -p "${update_dir_non_slot}"
21992200

22002201
package_output_paths_declare hpc_package_output_paths
2201-
hpc_package_output_paths[POP_OUT_DIR_IDX]="${REPORTS_DIR}/updates"
2202-
hpc_package_output_paths[POP_PKG_OUT_DIR_IDX]=${hpc_update_dir_non_slot}
2202+
hpc_package_output_paths[POP_OUT_DIR_IDX]="${updates_dir}"
2203+
hpc_package_output_paths[POP_PKG_OUT_DIR_IDX]=${update_dir_non_slot}
22032204
# POP_PKG_SLOT_OUT_DIR_IDX will be set in loops below
22042205

2205-
generate_non_ebuild_diffs "${hpc_update_dir_non_slot}" "${OLD_PORTAGE_STABLE}" "${NEW_PORTAGE_STABLE}" "${old_name}" "${new_name}"
2206-
generate_full_diffs "${hpc_update_dir_non_slot}" "${OLD_PORTAGE_STABLE}" "${NEW_PORTAGE_STABLE}" "${old_name}" "${new_name}"
2207-
generate_package_mention_reports "${hpc_update_dir_non_slot}" "${NEW_STATE}" "${old_name}" "${new_name}"
2206+
generate_non_ebuild_diffs "${update_dir_non_slot}" "${OLD_PORTAGE_STABLE}" "${NEW_PORTAGE_STABLE}" "${old_name}" "${new_name}"
2207+
generate_full_diffs "${update_dir_non_slot}" "${OLD_PORTAGE_STABLE}" "${NEW_PORTAGE_STABLE}" "${old_name}" "${new_name}"
2208+
generate_package_mention_reports "${update_dir_non_slot}" "${NEW_STATE}" "${old_name}" "${new_name}"
22082209

22092210
hpc_changed=
22102211
pkg_debug 'going over common slots'
@@ -2223,9 +2224,10 @@ function handle_package_changes() {
22232224
" - minmax: ${new_verminmax}"
22242225
continue
22252226
fi
2226-
update_dir "${new_name}" "${s}" "${s}" hpc_update_dir
2227-
mkdir -p "${hpc_update_dir}"
2228-
hpc_package_output_paths[POP_PKG_SLOT_OUT_DIR_IDX]=${hpc_update_dir}
2227+
slot_dirname "${s}" "${s}" hpc_slot_dirname
2228+
update_dir="${update_dir_non_slot}/${hpc_slot_dirname}"
2229+
mkdir -p "${update_dir}"
2230+
hpc_package_output_paths[POP_PKG_SLOT_OUT_DIR_IDX]=${update_dir}
22292231
old_version=${old_verminmax%%:*}
22302232
new_version=${new_verminmax##*:}
22312233
gentoo_ver_cmp_out "${new_version}" "${old_version}" hpc_cmp_result
@@ -2238,7 +2240,7 @@ function handle_package_changes() {
22382240
hpc_slot_changed=
22392241
handle_pkg_as_is hpc_package_output_paths "${pkg_to_tags_mvm_var_name}" "${old_name}" "${new_name}" "${old_version}" hpc_slot_changed
22402242
if [[ -z ${hpc_slot_changed} ]]; then
2241-
rm -rf "${hpc_update_dir}"
2243+
rm -rf "${update_dir}"
22422244
else
22432245
hpc_changed=x
22442246
fi
@@ -2267,9 +2269,10 @@ function handle_package_changes() {
22672269
" - slot: ${hpc_new_s}" \
22682270
" - minmax: ${new_verminmax}"
22692271
else
2270-
update_dir "${new_name}" "${hpc_old_s}" "${hpc_new_s}" hpc_update_dir
2271-
mkdir -p "${hpc_update_dir}"
2272-
hpc_package_output_paths[POP_PKG_SLOT_OUT_DIR_IDX]=${hpc_update_dir}
2272+
slot_dirname "${hpc_old_s}" "${hpc_new_s}" hpc_slot_dirname
2273+
update_dir="${update_dir_non_slot}/${hpc_slot_dirname}"
2274+
mkdir -p "${update_dir}"
2275+
hpc_package_output_paths[POP_PKG_SLOT_OUT_DIR_IDX]=${update_dir}
22732276
old_version=${old_verminmax%%:*}
22742277
new_version=${new_verminmax##*:}
22752278
gentoo_ver_cmp_out "${new_version}" "${old_version}" hpc_cmp_result
@@ -2282,7 +2285,7 @@ function handle_package_changes() {
22822285
hpc_slot_changed=
22832286
handle_pkg_as_is hpc_package_output_paths "${pkg_to_tags_mvm_var_name}" "${old_name}" "${new_name}" "${old_version}" hpc_slot_changed
22842287
if [[ -z ${hpc_slot_changed} ]]; then
2285-
rm -rf "${hpc_update_dir}"
2288+
rm -rf "${update_dir}"
22862289
else
22872290
hpc_changed=x
22882291
fi
@@ -2324,8 +2327,8 @@ function handle_package_changes() {
23242327
# sys-apps)
23252328
if [[ -z ${hpc_changed} ]]; then
23262329
pkg_debug 'no changes, dropping reports'
2327-
rm -rf "${hpc_update_dir_non_slot}"
2328-
dirname_out "${hpc_update_dir_non_slot}" hpc_category_dir
2330+
rm -rf "${update_dir_non_slot}"
2331+
dirname_out "${update_dir_non_slot}" hpc_category_dir
23292332
if dir_is_empty "${hpc_category_dir}"; then
23302333
rmdir "${hpc_category_dir}"
23312334
fi
@@ -2945,6 +2948,29 @@ function update_dir() {
29452948
dir_ref="${ud_non_slot_dir}/${slot_dir}"
29462949
}
29472950

2951+
# Gets a slot-specific directory name for ebuild diffs.
2952+
#
2953+
# Params:
2954+
#
2955+
# 1 - old slot
2956+
# 2 - new slot
2957+
# 3 - name of a variable where the path will be stored
2958+
function slot_dirname() {
2959+
local old_s=${1}; shift
2960+
local new_s=${1}; shift
2961+
local -n dirname_ref=${1}; shift
2962+
2963+
# slots may have slashes in them - replace them with "-slash-"
2964+
local slot_dir
2965+
if [[ ${old_s} = "${new_s}" ]]; then
2966+
slot_dir=${old_s//\//-slash-}
2967+
else
2968+
slot_dir="${old_s//\//-slash-}-to-${new_s//\//-slash-}"
2969+
fi
2970+
2971+
dirname_ref=${slot_dir}
2972+
}
2973+
29482974
# Greps for a package name in selected directories of the passed
29492975
# repo. It prints, so the invocation needs to be captured.
29502976
#

0 commit comments

Comments
 (0)