Include quilt tooling and convert patches to be used with quilt

This is not a functional change and merely adds quilt scripts and a README
explaining their usage. In addition, it rewrites patch levels to be in line
with the result of 'quilt refresh -p ab'. No source changes are involved and
the source files are identical.
This commit is contained in:
Arjun Shankar 2018-06-27 14:05:06 +02:00 committed by Arjun Shankar
parent 3a93f14080
commit 2aa1cb2053
8 changed files with 112 additions and 14 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ flex-2.5.35.tar.bz2
/flex-2.5.39.tar.bz2
/flex-2.6.0.tar.bz2
/flex-2.6.1.tar.xz
series

40
README.quilt Normal file
View File

@ -0,0 +1,40 @@
This package supports working with patch files using quilt.
To regenerate the quilt series file run:
./gen-quilt-series.sh
Setup environment:
export QUILT_PATCHES=$PWD
Setup the source:
./quilt-patch.sh [-f]
Use `-f` if you want to have quilt-patch always remove the existing
source directory before starting. Otherwise you'll be patching on top of
an already patched tree generated perhaps by `*pkg prep`.
To add a new patch:
Option 1: Create a new patch:
cd flex-2.6.1/
quilt new flex-rh1439367.patch
quilt add tests/test-bison-yylloc/parser.y
# edit tests/test-bison-yylloc/parser.y
# you may add and edit several files in the same fashion
Option 2: Add an already prepared patch (e.g. from an upstream commit):
cd flex-2.6.1/
quilt import -P flex-rh1439367.patch ~/backport/obsolete-bison.patch
quilt push # if this fails, manually deal with conflicts (as in Option 1)
Finally:
quilt refresh -p ab
cd ..
git add flex-rh1439367.patch
# edit flex.spec to build with the new patch
git add flex.spec
git commit
You're done!

View File

@ -1,7 +1,8 @@
diff -Nrup a/src/flex.skl b/src/flex.skl
--- a/src/flex.skl 2015-11-10 18:28:54.000000000 -0500
+++ b/src/flex.skl 2016-03-07 23:52:46.527139783 -0500
@@ -506,7 +506,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
Index: b/src/flex.skl
===================================================================
--- a/src/flex.skl
+++ b/src/flex.skl
@@ -494,7 +494,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
*/
#define YY_LESS_LINENO(n) \
do { \
@ -10,7 +11,7 @@ diff -Nrup a/src/flex.skl b/src/flex.skl
for ( yyl = n; yyl < yyleng; ++yyl )\
if ( yytext[yyl] == '\n' )\
--yylineno;\
@@ -532,7 +532,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
@@ -520,7 +520,7 @@ m4_ifdef( [[M4_YY_NOT_IN_HEADER]],
do \
{ \
/* Undo effects of setting up yytext. */ \
@ -19,7 +20,7 @@ diff -Nrup a/src/flex.skl b/src/flex.skl
YY_LESS_LINENO(yyless_macro_arg);\
*yy_cp = YY_G(yy_hold_char); \
YY_RESTORE_YY_MORE_OFFSET \
@@ -2591,7 +2591,7 @@ void yyFlexLexer::LexerError( yyconst ch
@@ -2576,7 +2576,7 @@ void yyFlexLexer::LexerError( yyconst ch
do \
{ \
/* Undo effects of setting up yytext. */ \

View File

@ -4,8 +4,8 @@ Date: Sun Feb 28 15:20:31 2016 +0100
generated code, `max_size' seems to be of type `int', fix casts accordingly
diff --git a/src/gen.c b/src/gen.c
index 21b27ae..d31aab3 100644
Index: b/src/gen.c
===================================================================
--- a/src/gen.c
+++ b/src/gen.c
@@ -1875,7 +1875,7 @@ void make_tables (void)

View File

@ -4,8 +4,8 @@ Date: Sun Feb 28 15:20:31 2016 +0100
generated code, here `new_size' is of type `int', fix casts accordingly
diff --git a/src/flex.skl b/src/flex.skl
index 2c25d21..540ce95 100644
Index: b/src/flex.skl
===================================================================
--- a/src/flex.skl
+++ b/src/flex.skl
@@ -1782,7 +1782,7 @@ m4_ifdef( [[M4_YY_USES_REJECT]],

View File

@ -4,8 +4,8 @@ Date: Sun Feb 28 15:20:31 2016 +0100
generated code, `yy_buf_size' is of type `int', fix casts accordingly
diff --git a/src/flex.skl b/src/flex.skl
index 0631725..2c25d21 100644
Index: b/src/flex.skl
===================================================================
--- a/src/flex.skl
+++ b/src/flex.skl
@@ -1732,7 +1732,7 @@ m4_ifdef( [[M4_YY_USES_REJECT]],
@ -17,7 +17,7 @@ index 0631725..2c25d21 100644
}
else
/* Can't grow it, we don't own it. */
@@ -2102,12 +2102,12 @@ static void yy_load_buffer_state YYFARGS0(void)
@@ -2102,12 +2102,12 @@ static void yy_load_buffer_state YYFARG
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
@ -32,7 +32,7 @@ index 0631725..2c25d21 100644
if ( ! b->yy_ch_buf )
YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
@@ -2397,7 +2397,7 @@ YY_BUFFER_STATE yy_scan_buffer YYFARGS2( char *,base, yy_size_t ,size)
@@ -2397,7 +2397,7 @@ YY_BUFFER_STATE yy_scan_buffer YYFARGS2
if ( ! b )
YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );

34
gen-quilt-series.sh Executable file
View File

@ -0,0 +1,34 @@
#!/bin/bash
# Autogenerates the quilt `series` from the patch order in the spec file.
# We don't use `quilt setup` because it makes a huge mess and doesn't work.
component="flex"
rm -f series.new
extra_args="--fuzz=0"
count=0
# Filter out the patches, and use `_` as our pseudo-IFS to prevent expansion.
for i in `grep '^%patch' flex.spec | sed -e 's,%patch,,g' -e 's, ,_,g'`; do
# Split the patch into number and arguments.
# 1 - Patch number.
# 2-N - Patch arguments.
# Get back our elements by undoing pseudo-IFS change.
elements=(`echo $i | sed -e 's,_, ,g'`)
num=${elements[0]}
args=${elements[@]:1}
# Find the next patch that applies in order and write it out.
# This way we transform the patch # list into a patch file list in order.
grep "Patch${num}: " flex.spec \
| sed -e 's,Patch.*: ,,g' -e "s,\$, ${args[@]} ${extra_args},g" \
| sed -e "s,%{name},${component},g" \
>> series.new
((count++))
done
# Double check we processed the correct number of patches.
fcount=`wc -l series.new | sed -e 's, .*$,,g'`
if [ $fcount -ne $count ]; then
echo "Error! Processed patch count doesn't match spec file count ($fcount != $count)."
exit 1
fi
echo "Processed $count patches."
mv series.new series
echo "Generated quilt ./series file. Please do not commit."
exit 0

22
quilt-patch.sh Executable file
View File

@ -0,0 +1,22 @@
#!/bin/bash
# Patches are in the current directory.
export QUILT_PATCHES=$PWD
# Extract source file name from sources file,
# and assume it's the same name as the directory.
source=`awk -F '[() ]+' '/^[A-Z0-9]+ /{print $2}; /^[0-9a-f]+ /{print $2}' sources`
srcdir=${source%.tar.xz}
if [ "$1" == "-f" ] && [ -d "$srcdir" ]; then
echo Cleaning up $srcdir
rm -rf $srcdir
fi
if [ -d "$srcdir" ]; then
# Don't overwrite existing source directory.
echo "ERROR: Source directory $srcdir already exists. Use -f to force cleanup step."
exit 1
fi
tar xvf $source
echo "Entering $srcdir"
pushd $srcdir
# Apply all patches.
quilt push -a
popd