File 0001-patchfns-Extend-format-of-series-file.patch of Package quilt-ks
From 9b5bd4df2daedeee92ce7f468d4fcb2f9f4bd692 Mon Sep 17 00:00:00 2001
From: Benjamin Poirier <bpoirier@suse.de>
Date: Mon, 20 Mar 2017 09:51:26 -0700
Subject: [PATCH 1/5] patchfns: Extend format of series file
Support whitespace before patch file name
Interpret lines that begin with +- as comments (in fact, they are "guards")
Reuse leading space from previous entry when inserting a new entry
This effectively allows using series.conf directly as a series file. The
benefit is that the former doesn't need to be updated after using `quilt
import` and other functions that change the series file.
---
quilt/scripts/patchfns.in | 26 ++++++++++++++++----------
1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/quilt/scripts/patchfns.in b/quilt/scripts/patchfns.in
index 15ffa98..3532c0f 100644
--- a/quilt/scripts/patchfns.in
+++ b/quilt/scripts/patchfns.in
@@ -227,7 +227,7 @@ patch_in_series()
if [ -e "$SERIES" ]
then
- grep -q "^$(quote_bre $patch)\([ \t]\|$\)" "$SERIES"
+ grep -q "^[[:space:]]*$(quote_bre $patch)\([ \t]\|$\)" "$SERIES"
else
return 1
fi
@@ -256,8 +256,11 @@ insert_in_series()
if [ -n "$before" ]
then
awk '
- /^'"$(quote_re $before)"'([ \t]|$)/ \
- { print "'"$patch$patch_args"'" }
+ /^[[: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
status=$?
@@ -286,7 +289,7 @@ remove_from_series()
tmpfile=$(gen_tempfile) || return 1
awk '
- ! /^'"$(quote_re $patch)"'([ \t]|$)/ \
+ ! /^[[:space:]]*'"$(quote_re $patch)"'([ \t]|$)/ \
{ print }
' "$SERIES" > $tmpfile
if [ $? -ne 0 ]
@@ -304,7 +307,7 @@ rename_in_series()
tmpfile=$(gen_tempfile) || return 1
awk '
- /^'"$(quote_re $from)"'([ \t]|$)/ \
+ /^[[:space:]]*'"$(quote_re $from)"'([ \t]|$)/ \
{ sub(/'"$(quote_re $from)"'/, "'"${to//\"/\\\"}"'")
good=1 }
{ print }
@@ -355,8 +358,10 @@ cat_series()
{
if [ -e "$SERIES" ]
then
- sed -e '/^#/d' -e 's/^[ '$'\t'']*//' \
- -e 's/[ '$'\t''].*//' -e '/^$/d' "$SERIES"
+ sed -e '/^[[:space:]]*[-#+]/d' \
+ -e 's/^[ '$'\t'']*//' \
+ -e 's/[ '$'\t''].*//' \
+ -e '/^$/d' "$SERIES"
else
return 1
fi
@@ -542,9 +547,10 @@ find_patch()
fi
local patch=${1#$SUBDIR_DOWN$QUILT_PATCHES/}
- local bre=$(quote_bre "$patch")
- set -- $(sed -e "/^$bre\(\|\.patch\|\.diff\?\)\(\|\.gz\|\.bz2\|\.xz\|\.lzma\|\.lz\)\([ "$'\t'"]\|$\)/!d" \
- -e 's/[ '$'\t''].*//' "$SERIES")
+ set -- $(cat_series | awk '
+ /^'$(quote_re $patch)'(.patch|.diff)?(.gz|.bz2|.xz|.lzma|.lz)?/ {
+ print $1
+ }')
if [ $# -eq 1 ]
then
echo $1
--
2.21.0