Skip to content

Commit 7108079

Browse files
authored
pm_apply: improve regexp (#237)
1 parent f6af3d4 commit 7108079

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/tools/pm_apply

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,8 +102,8 @@ mangle_libpath() {
102102
fi
103103

104104
for p in $candidates; do
105-
totl_lines=$(grep -c "^+++" "$PATCH_PATH")
106-
cand_lines=$(grep -c "^+++ $p" "$PATCH_PATH")
105+
totl_lines=$(grep -c "^\+\+\+" "$PATCH_PATH")
106+
cand_lines=$(grep -c "^\+\+\+ [^/]*$p" "$PATCH_PATH")
107107
if [ $cand_lines -eq 0 ]; then
108108
continue # nothing found, try next
109109
else
@@ -114,7 +114,7 @@ mangle_libpath() {
114114
fi
115115
fi
116116
log "found: ${p}, replacing libpath references"
117-
117+
118118
# prepare the replacement pattern
119119
pr=""
120120
if [ $SYS_BITNESS -eq 32 ]; then
@@ -129,7 +129,7 @@ mangle_libpath() {
129129
printf '#\n# Patch converted to %sbit library paths from its original by Patchmanager > 3.1\n# Date: %s\n#\n' $SYS_BITNESS $(date -Iseconds) \
130130
| cat - "$PATCH_PATH" > "$patch_edited_path"
131131
fi
132-
sed -i "s@^+++ $p@+++ $pr@;s@^--- $p@--- $pr@" "$patch_edited_path" || failure || true # patch the Patch
132+
sed -i "s@^\+\+\+ \([^/]*\)$p@+++ \1$pr@;s@^--- \([^/]*\)$p@--- \1$pr@" "$patch_edited_path" || failure || true # patch the Patch
133133
done
134134
if [ $found -eq 0 ]; then
135135
log

0 commit comments

Comments
 (0)