From 2aa1cb2053cbf192a27a5c3aa2ad002e82b251d9 Mon Sep 17 00:00:00 2001 From: Arjun Shankar Date: Wed, 27 Jun 2018 14:05:06 +0200 Subject: [PATCH] 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. --- .gitignore | 1 + README.quilt | 40 ++++++++++++++++++++++++++++++++++++++++ flex-2.6.0-yyless.patch | 13 +++++++------ flex-max_size.patch | 4 ++-- flex-new_size.patch | 4 ++-- flex-yy_buf_size.patch | 8 ++++---- gen-quilt-series.sh | 34 ++++++++++++++++++++++++++++++++++ quilt-patch.sh | 22 ++++++++++++++++++++++ 8 files changed, 112 insertions(+), 14 deletions(-) create mode 100644 README.quilt create mode 100755 gen-quilt-series.sh create mode 100755 quilt-patch.sh diff --git a/.gitignore b/.gitignore index bba8076..c92bc60 100644 --- a/.gitignore +++ b/.gitignore @@ -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 diff --git a/README.quilt b/README.quilt new file mode 100644 index 0000000..e53b9b9 --- /dev/null +++ b/README.quilt @@ -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! diff --git a/flex-2.6.0-yyless.patch b/flex-2.6.0-yyless.patch index 4bb7c3e..bf7cf6f 100644 --- a/flex-2.6.0-yyless.patch +++ b/flex-2.6.0-yyless.patch @@ -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. */ \ diff --git a/flex-max_size.patch b/flex-max_size.patch index 83d6753..133cfc1 100644 --- a/flex-max_size.patch +++ b/flex-max_size.patch @@ -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) diff --git a/flex-new_size.patch b/flex-new_size.patch index 8de8bc3..8f7fb5c 100644 --- a/flex-new_size.patch +++ b/flex-new_size.patch @@ -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]], diff --git a/flex-yy_buf_size.patch b/flex-yy_buf_size.patch index 7031eb7..fcf1e2e 100644 --- a/flex-yy_buf_size.patch +++ b/flex-yy_buf_size.patch @@ -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()" ); diff --git a/gen-quilt-series.sh b/gen-quilt-series.sh new file mode 100755 index 0000000..6a2fc3a --- /dev/null +++ b/gen-quilt-series.sh @@ -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 diff --git a/quilt-patch.sh b/quilt-patch.sh new file mode 100755 index 0000000..686d320 --- /dev/null +++ b/quilt-patch.sh @@ -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