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