improve on clean-old: basically use make show=MAKESUMFILES to figure out

which files are needed.

Also, do some tricky find in mystuff to try to figure out which files are
actually needed for local work.
This commit is contained in:
espie 2008-05-15 10:12:28 +00:00
parent eac6cf7b3c
commit ea8499cbef

View File

@ -3,7 +3,7 @@
# This script actually produces another shell-script that you may edit
# before executing.
# $OpenBSD: clean-old,v 1.3 2007/05/26 20:20:38 espie Exp $
# $OpenBSD: clean-old,v 1.4 2008/05/15 10:12:28 espie Exp $
#
# Copyright (c) 2000 Marc Espie.
#
@ -32,21 +32,30 @@ set -e
: ${PORTSDIR=/usr/ports}
: ${DISTDIR=${PORTSDIR}/distfiles}
: ${TMPDIR=/tmp}
if [ ! -f $DISTDIR/Makefile ]
then
echo >&2 "missing $DISTDIR/Makefile, run make mirror-maker first"
exit 1
fi
cd $DISTDIR
: ${MAKE=make}
TMP1=`mktemp $TMPDIR/list.XXXXXXXXXX` || exit 1
trap 'rm -f $TMP1 $TMP2' 0 1 2 3 5 10 15
#trap 'rm -f $TMP1 $TMP2' 0 1 2 3 5 10 15
TMP2=`mktemp ${TMPDIR}/list.XXXXXXXXXX` || exit 1
touch force$$
make -f Makefile -k FETCH=echo F=force$$ all|sort -u >$TMP1
rm force$$
{
cd $PORTSDIR
${MAKE} show=MAKESUMFILES ECHO_MSG=:
if cd 2>/dev/null $PORTSDIR/mystuff
then
find . -type f -name Makefile|while read i
do
if fgrep -i bsd.port.mk $i
then
( cd `dirname $i`
${MAKE} show=MAKESUMFILES ECHO_MSG=: || true
)
fi
done
fi
}|tr ' ' "\n"|sort -u >$TMP1
cd $DISTDIR
find . -type f -print|sed -e 's,^\./,,' |grep -v '^Makefile$' |sort -u >$TMP2
echo "#! /bin/sh"
echo "cd $DISTDIR"
diff -u $TMP1 $TMP2|tail +3|grep '^\+'|sed -e 's,^\+,rm ,'|sed -e 's,&,\\&,g'
diff -u $TMP1 $TMP2|tail +3|grep '^\+'| \
sed -e 's,^\+,rm ,' -e 's,[[&()],\\&,g' -e 's,],\\&,g'
rm $TMP1 $TMP2