File 0002-Change-where-new-patches-are-inserted-in-series.patch of Package quilt-ks
From 6fbd93cb0f3e7ebf42ee9d5dd4b9164b5848e2ae Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@suse.de>
Date: Tue, 3 Oct 2017 16:30:47 -0400
Subject: [PATCH 2/5] Change where new patches are inserted in series
changes insert_in_series to add the new entry after the specified patch,
not before the next one. This makes a difference when there are comments or
empty lines in between the two.
---
quilt/import.in | 5 +++--
quilt/scripts/patchfns.in | 28 +++++++++++-----------------
2 files changed, 14 insertions(+), 19 deletions(-)
diff --git a/quilt/import.in b/quilt/import.in
index 4ce8bec..f700542 100644
--- a/quilt/import.in
+++ b/quilt/import.in
@@ -176,7 +176,7 @@ then
fi
fi
-before=$(patch_after "$(top_patch)")
+after=$(top_patch)
for orig_patch_file in "$@"
do
if [ -n "$opt_patch" ]
@@ -243,12 +243,13 @@ do
[ "$merged_patch_file" != "$patch_file" ] && rm -f "$merged_patch_file"
if ! patch_in_series $patch &&
- ! insert_in_series $patch "$patch_args" "$before"
+ ! insert_in_series $patch "$patch_args" "$after"
then
printf $"Failed to insert patch %s into file series\n" \
"$(print_patch $patch)" >&2
exit 1
fi
+ after=$patch
rm -rf $QUILT_PC/$patch
done
diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in
index 3532c0f..793093a 100644
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -237,14 +237,14 @@ patch_in_series()
insert_in_series()
{
local patch=$1 patch_args=$2
- local before tmpfile
+ local after tmpfile
if [ -e "$SERIES" -a ! -f "$SERIES" ]; then
printf $"%s is not a regular file\n" "$SERIES" >&2
return 1
fi
- before=${3-$(patch_after "$(top_patch)")}
+ after=${3-$(top_patch)}
if [ -n "$patch_args" ]
then
@@ -252,32 +252,26 @@ insert_in_series()
fi
tmpfile=$(gen_tempfile) || return 1
- mkdir -p "$(dirname "$SERIES")"
- if [ -n "$before" ]
+ mkdir -p $(dirname "$SERIES")
+ if [ -n "$after" ]
then
- awk '
- /^[[:space:]]*'"$(quote_re $before)"'([ \t]|$)/ \
- {
- match($0, "^([[:space:]]*)'"$(quote_re $before | sed -e 's:\\:\\\\:g')"'([ \t]|$)", a)
- print a[1] "'"$patch$patch_args"'"
- }
- { print }
- ' "$SERIES" > $tmpfile
+ sed -Ee 's/^([[:space:]]*)'"$(quote_re $after)"'([ \t]|$).*$/&\n\1'"$(quote_re $patch$patch_args)"'/' \
+ "$SERIES" > $tmpfile
status=$?
if [ $status -ne 0 ]
then
rm -f $tmpfile
return 1
fi
+
+ # Ensure there is a trailing newline in the file
+ ensure_trailing_newline $tmpfile
else
+ echo "$patch$patch_args" > $tmpfile
if [ -e "$SERIES" ]
then
- cat "$SERIES" > $tmpfile
-
- # Ensure there is a trailing newline before we append the rest
- ensure_trailing_newline $tmpfile
+ cat "$SERIES" >> $tmpfile
fi
- echo "$patch$patch_args" >> $tmpfile
fi
cat $tmpfile > "$SERIES"
rm -f $tmpfile
--
2.21.0