diff options
author | Maxim Sobolev <sobomax@FreeBSD.org> | 2000-06-05 15:47:25 +0000 |
---|---|---|
committer | Maxim Sobolev <sobomax@FreeBSD.org> | 2000-06-05 15:47:25 +0000 |
commit | 6fed6d6bdd9e493e9d07b3b11d8caada8462cd81 (patch) | |
tree | 3ed04e7964e2c244d3d2f1687ad253f67bbb5945 /Tools/scripts/distclean.sh | |
parent | fbccaad703e9bf25a4e0878d5fff7ea44f37321c (diff) | |
download | ports-6fed6d6bdd9e493e9d07b3b11d8caada8462cd81.tar.gz ports-6fed6d6bdd9e493e9d07b3b11d8caada8462cd81.zip |
Notes
Diffstat (limited to 'Tools/scripts/distclean.sh')
-rwxr-xr-x | Tools/scripts/distclean.sh | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/Tools/scripts/distclean.sh b/Tools/scripts/distclean.sh new file mode 100755 index 000000000000..89081be401ad --- /dev/null +++ b/Tools/scripts/distclean.sh @@ -0,0 +1,55 @@ +#!/bin/sh + +# distclean + +# Compare distfiles in /usr/ports/distfiles +# with currently instaled ports collection +# and removes outdated files + +# +# ---------------------------------------------------------------------------- +# "THE BEER-WARE LICENSE" (Revision 42, (c) Poul-Henning Kamp): +# Maxim Sobolev <sobomax@altavista.net wrote this file. As long as you retain +# this notice you can do whatever you want with this stuff. If we meet some +# day, and you think this stuff is worth it, you can buy me a beer in return. +# +# Maxim Sobolev +# ---------------------------------------------------------------------------- +# + + +PATH=/sbin:/bin:/usr/bin + +echo "Distfiles clean utility v0.40 by Maxim Sobolev <sobomax@altavista.net>." +echo "Assumes that your ports in /usr/ports and distfiles in /usr/ports/distfiles." +echo "" + +umask 077 + +FN_PORTS=`mktemp -t dclean` || exit 1 +FN_DISTFILES=`mktemp -t dclean` || exit 1 +FN_RESULTS_SCRIPT=`mktemp -t dclean` || exit 1 + +echo -n "Building ports md5 index..." +find /usr/ports -name "md5" -type f | xargs cat | grep "^MD5 ("| sort | uniq > $FN_PORTS +echo "Done." +P_MD5_COUNT=`wc -l $FN_PORTS | sed "s| $FN_PORTS|| ; s| ||g"` +echo "Found $P_MD5_COUNT md5 entries in your ports directory." + +echo -n "Building distfiles md5 index..." +find -H /usr/ports/distfiles -type f | xargs md5 | sed 's|/usr/ports/distfiles/||' | sort > $FN_DISTFILES +echo "Done." +D_MD5_COUNT=`wc -l $FN_DISTFILES | sed "s| $FN_DISTFILES|| ; s| ||g"` +echo "Found $D_MD5_COUNT distfile(s) in your distfiles directory." + +echo -n "Comparing results..." +diff -d $FN_DISTFILES $FN_PORTS | grep "^<" | sed 's|.*(|rm -i /usr/ports/distfiles/| ; s|).*||' > $FN_RESULTS_SCRIPT +echo "Done." +R_MD5_COUNT=`wc -l $FN_RESULTS_SCRIPT | sed "s| $FN_RESULTS_SCRIPT|| ; s| ||g"` +echo "$R_MD5_COUNT distfile(s) doesn't have corresponding md5 entries in ports directory." +/bin/sh $FN_RESULTS_SCRIPT + +echo -n "Finishing..." +rm -f $FN_RESULTS_SCRIPT $FN_PORTS $FN_DISTFILES +echo "Done." + |