From 427e0392404998e9f4a0f3d341eaa4299158d42b Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Feb 05 2016 11:14:13 +0000 Subject: Add quilt support scripts --- diff --git a/gen-quilt-series.sh b/gen-quilt-series.sh new file mode 100755 index 0000000..35412de --- /dev/null +++ b/gen-quilt-series.sh @@ -0,0 +1,34 @@ +#!/bin/bash +# Autogeneries 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="glibc" +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' glibc.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}: " glibc.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 commit." +exit 0 diff --git a/quilt-patch.sh b/quilt-patch.sh new file mode 100755 index 0000000..983a75d --- /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=`cat sources | sed -e 's,^.* ,,g'` +srcdir=${source%.tar.gz} +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 zxvf $source +echo "Entering $srcdir" +pushd $srcdir +# Apply all patches. +quilt push -a +popd