From 556b2d8aee2e642030dca384c5902de74b33988a Mon Sep 17 00:00:00 2001 From: olf Date: Thu, 30 Dec 2021 06:39:25 +0100 Subject: [PATCH 1/2] Prepare for multiple conversion runs This still ought be functionally equivalent to the original version as of PM 3.2.0: please test! --- src/tools/pm_apply | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/src/tools/pm_apply b/src/tools/pm_apply index 43e50248..0ee66ff1 100644 --- a/src/tools/pm_apply +++ b/src/tools/pm_apply @@ -104,7 +104,7 @@ mangle_libpath() { totl_lines=$(grep -c "^+++" "$PATCH_PATH") cand_lines=$(grep -c "^+++ $p" "$PATCH_PATH") if [ $cand_lines -eq 0 ]; then - continue # nothing found, try next + continue # nothing found, try next else found=$(( $found + $cand_lines )) if [ $totl_lines -ne $cand_lines ]; then @@ -112,12 +112,9 @@ mangle_libpath() { log "WARNING: mixed patch, conversion might not work" fi fi - - patch_edited_path="$PM_PATCH_BACKUP_DIR"/"$PATCH_EDITED_NAME" log "found: ${p}, replacing libpath references" - - mkdir -p "$PM_PATCH_BACKUP_DIR" - # prepare the pattern + + # prepare the replacement pattern pr="" if [ $SYS_BITNESS -eq 32 ]; then pr=$(printf '%s' "$p" | sed 's@/usr/lib64/@/usr/lib/@') @@ -125,23 +122,26 @@ mangle_libpath() { pr=$(printf '%s' "$p" | sed 's@/usr/lib/@/usr/lib64/@') fi # doit - printf '#\n# patch converted to %sbit library paths from its original by Patchmanager >= 3.1\n# Date: %s\n#\n' $SYS_BITNESS $(date -Iseconds) > "$patch_edited_path" + mkdir -p "$PM_PATCH_BACKUP_DIR" + patch_edited_path="$PM_PATCH_BACKUP_DIR"/"$PATCH_EDITED_NAME" + printf '#\n# Patch converted to %sbit library paths from its original by Patchmanager > 3.1\n# Date: %s\n#\n' $SYS_BITNESS $(date -Iseconds) > "$patch_edited_path" sed "s@^+++ $p@+++ $pr@;s@^--- $p@--- $pr@" "$PATCH_PATH" >> "$patch_edited_path" if [ $? -ne 0 ]; then failure fi - log - log "OK, conversion produced: $patch_edited_path" - log - # set the patch to apply to the new one: - PATCH_PATH="$patch_edited_path" - return + break done if [ $found -eq 0 ]; then log - log "OK, found nothing to convert" + log "OK, found nothing to convert." + log + else + log + log "OK, replaced $found paths and created: $patch_edited_path" log - fi + # set the patch to apply to the new one: + PATCH_PATH="$patch_edited_path" + fi fi } From dda3f1a32c11778ed6d775aef382635bec519447 Mon Sep 17 00:00:00 2001 From: olf Date: Thu, 30 Dec 2021 06:42:37 +0100 Subject: [PATCH 2/2] Enhance log output --- src/tools/pm_apply | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tools/pm_apply b/src/tools/pm_apply index 0ee66ff1..750f1640 100644 --- a/src/tools/pm_apply +++ b/src/tools/pm_apply @@ -137,7 +137,7 @@ mangle_libpath() { log else log - log "OK, replaced $found paths and created: $patch_edited_path" + log "OK, replaced $found libpath references and created: $patch_edited_path" log # set the patch to apply to the new one: PATCH_PATH="$patch_edited_path"