#!/bin/csh
# ctm_index						by Julian H. Stacey

# Index which CTM updates affect which source files.

# Useful when faced with the question:
#	Which CTM patches changed src/bin/something/main.c ?
# for when something is broken, & one wants to recover a previous
# version from an older CTM version, whose CTM number is not known.

# Output Example:
#    /pub/freebsd/ctm/src-cur/index.rest.gz:
#	gnu/usr.bin/man/makewhatis/makewhatis.perl 0472
#	gnu/usr.bin/man/makewhatis/makewhatis.perl 0467

# See Also:	man (5) ctm

# I had not edited this from 2010-06-21 to 2014-11-20, I should probably
# now be thinkink more of chasing the SVN revision number.

cd /pub/freebsd/ref/current/ctm/ctm
foreach j ( src-cur ports-cur cvs-cur svn-cur git-cur ) # src-cvs ports-cvs cvs-cur
	pushd $j/deltas >& /dev/null
	zgrep '^CTMF[MSNR]' * 			| \
		sed  -e "s/$j.//" 		| \
		sed  -e 's/.gz:CTMF[MSNR]//'	| \
		uniq				| \
		awk '{print $2,$1;}' 		| \
		grep -v '^.ctm_status' 		| \
		sort -r				  \
		> ../index
	popd >& /dev/null
	end

pushd src-cur	>& /dev/null
	grep	" 0372R20" index > index.base
	grep -v	" 0372R20" index > index.rest
	rm index
	rm -f index.base.gz index.rest.gz
	gzip -f index*
popd	>& /dev/null

pushd ports-cur	>& /dev/null
	grep	" 0249A" index > index.base
	grep -v	" 0249A" index > index.rest
	rm index
	rm -f index.base.gz index.rest.gz
	gzip -f index*
popd	>& /dev/null

# pushd cvs-cur	>& /dev/null
# 	grep	" 0249A" index > index.base
# 	grep -v	" 0249A" index > index.rest
# 	rm index
# 	rm -f index.base.gz index.rest.gz
# 	gzip -f index*
# popd	>& /dev/null
