2015-07-07 18:04:07 +00:00
|
|
|
#!/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.
|
2015-11-10 02:26:45 +00:00
|
|
|
component="glibc"
|
2015-07-07 18:04:07 +00:00
|
|
|
rm -f series.new
|
2015-10-21 19:24:28 +00:00
|
|
|
extra_args="--fuzz=0"
|
2015-07-07 18:04:07 +00:00
|
|
|
count=0
|
|
|
|
# Filter out the patches, and use `_` as our pseudo-IFS to prevent expansion.
|
2015-08-28 19:29:26 +00:00
|
|
|
for i in `grep '^%patch' glibc.spec | sed -e 's,%patch,,g' -e 's, ,_,g'`; do
|
2015-07-07 18:04:07 +00:00
|
|
|
# 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}
|
2015-08-28 19:29:26 +00:00
|
|
|
# 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.
|
2015-10-21 19:24:28 +00:00
|
|
|
grep "Patch${num}: " glibc.spec \
|
|
|
|
| sed -e 's,Patch.*: ,,g' -e "s,\$, ${args[@]} ${extra_args},g" \
|
2015-11-10 02:26:45 +00:00
|
|
|
| sed -e "s,%{name},${component},g" \
|
2015-10-21 19:24:28 +00:00
|
|
|
>> series.new
|
2015-07-07 18:04:07 +00:00
|
|
|
((count++))
|
|
|
|
done
|
2015-08-28 19:29:26 +00:00
|
|
|
# Double check we processed the correct number of patches.
|
2015-07-07 18:04:07 +00:00
|
|
|
fcount=`wc -l series.new | sed -e 's, .*$,,g'`
|
|
|
|
if [ $fcount -ne $count ]; then
|
2015-08-28 19:29:26 +00:00
|
|
|
echo "Error! Processed patch count doesn't match spec file count ($fcount != $count)."
|
2015-07-07 18:04:07 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
echo "Processed $count patches."
|
|
|
|
mv series.new series
|
2016-04-30 03:11:30 +00:00
|
|
|
echo "Generated quilt ./series file. Please do not commit."
|
2015-07-07 18:04:07 +00:00
|
|
|
exit 0
|