#! /bin/sh -e
# Take TODO list and make html summary of it.
SOURCE=~/devel/kernel/2.6-TODO
DEST=index.html
CACHEDIR=~/tmp
barf()
{
echo "$@" >&2
exit 1
}
# Takes patch and produces impact-o-meter results.
analyze_patch()
{
AP_BYTES=`wc -c < $1`
AP_CHANGES=`grep -c '^+++ ' < $1`
# New files have old file date at epoch w/ timezone adjust.
# Don't get spurious failure on no matches.
AP_NEW=`egrep -c '^--- .*[^0-9]19(69|70)([^0-9]|$)' < $1 || true`
AP_CONFIG=`egrep -i '^--- .*(Makefile|Config.in|Config.help|CREDITS|MAINTAINERS|Kconfig)' < $1 | egrep -cv ' 19(69|70)$' || true`
echo 'S: '$(($AP_BYTES / 1000)) kbytes, $(($AP_CHANGES - $AP_NEW - $AP_CONFIG))/$AP_CONFIG files altered, $AP_NEW new'
'
}
# Skip over patches to Config.in, config.in, Makefile, and new/deleted files.
executive_summary()
{
ES_STATE=SKIPPING
while IFS="
" read -r ES_LINE; do
case "$ES_LINE" in
diff\ *) ES_STATE=SKIPPING;;
---\ */config.in*) ES_STATE=SKIPPING;;
---\ */Config.in*) ES_STATE=SKIPPING;;
---\ */Config.help*) ES_STATE=SKIPPING;;
---\ */Makefile*) ES_STATE=SKIPPING;;
---\ */CREDITS*) ES_STATE=SKIPPING;;
---\ */MAINTAINERS*) ES_STATE=SKIPPING;;
---\ *) ES_STATE=SAVING;;
@@\ -0,0*) ES_SAVED=""; ES_STATE=SKIPPING;;
@@\ *+0,0\ @@) ES_SAVED=""; ES_STATE=SKIPPING;;
@@\ *) [ x"$ES_SAVED" = x ] || { echo "$ES_SAVED"; ES_SAVED=""; ES_STATE=OUTPUTTING; }
;;
esac
case "$ES_STATE" in
SAVING) ES_SAVED="$ES_SAVED
$ES_LINE";;
OUTPUTTING) echo "$ES_LINE";;
esac
done < $1 | gzip -9 > $2.summary.patch.gz
echo "T: Diffstat
"
diffstat -p1 < $1 > $2.diffstat.txt 2>/dev/null
ES_SIZE=$(($(zcat $2.summary.patch.gz | wc -c) / 1000))
echo "X: Summary patch (${ES_SIZE}k)
"
}
try_cache()
{
CACHESUM=`echo "$1" | md5sum | cut -d\ -f1`
if [ -f $CACHEDIR/$CACHESUM.tar.gz ]; then
tar xfz $CACHEDIR/$CACHESUM.tar.gz
fi
}
save_cache()
{
CACHESUM=`echo "$1" | md5sum | cut -d\ -f1`
tar cfz $CACHEDIR/$CACHESUM.tar.gz .
}
create_summary()
{
mkdir /tmp/summary.$$
trap "rm -rf /tmp/summary.$$*" 0
CS_URL=`echo "$@" | sed 's/[^"]*"\([^"]*\)"[^"]*/\1 /g'`
pushd /tmp/summary.$$ >/dev/null
echo Analyzing "$CS_URL"... >&2
try_cache "$CS_URL"
for CS_U in $CS_URL; do
case $CS_U in
*/) wget -q --level=1 --reject '*.html*' --no-directories --timestamping -r --relative $CS_U || barf "Can't get $CS_U";;
ftp*) wget -q --timestamping $CS_U || barf "Can't get $CS_U";;
*) wget -q --timestamping $CS_U || barf "Can't get $CS_U";;
esac
done
for f in *; do
case $f in
*.bz2) bzcat $f;;
*.gz) zcat $f;;
*) cat $f;;
esac
done > /tmp/summary.$$.diff
if isapplied ~/devel/kernel/linux-`latest-kernel-version` /tmp/summary.$$.diff >/dev/null; then
echo WARNING: "$CS_URL" already applied >&2
fi
analyze_patch /tmp/summary.$$.diff
save_cache "$CS_URL"
popd >/dev/null
executive_summary /tmp/summary.$$.diff `echo $CS_URL | sed 's/ .*//' | sed 's/[^-A-Za-z0-9._]\+/_/g'`
rm -rf /tmp/summary.$$*
}
cd 2.6-not-in-yet
cat $DEST.head > $DEST
# Insert linebreaks before single letter prefixes, highlight titles,
# href urls...
sed 's/^\( *[A-Z]:.*\)/\1
/' < $SOURCE |
sed 's,^\([-A-Za-z0-9/() ]\+\)$,