1
0
mirror of https://git.FreeBSD.org/ports.git synced 2025-01-26 09:46:09 +00:00

Add distclean.sh - a little script to check set of distfiles against currently

installed ports collection and prompt to remove unmatching entries (i.e.
distfiles that doesn't have corresponding md5 file).

Hardly requiested by:	will
This commit is contained in:
Maxim Sobolev 2000-06-05 15:47:25 +00:00
parent fbccaad703
commit 6fed6d6bdd
Notes: svn2git 2021-03-31 03:12:20 +00:00
svn path=/head/; revision=29232
2 changed files with 71 additions and 5 deletions

View File

@ -4,7 +4,9 @@ addport - future replacement for easy-import
consistency-check - check whether all your ports are installed properly,
what files have changed, and what new files there are
distclean - compare md5 sums of distfiles in ports/distfiles with currently
installed ports collection in ports/* and prompt to remove
unmatched entries
getpr - downloads a problem report from GNATS and attempts to extract
the patch, shar, uuencoded file from it.
this probably needs to be checked for potential security problems.
@ -41,12 +43,21 @@ getpr, prpatch and prdone are used as so:
<this will attempt to fill out the cvs log message, check in the
port and edit-pr the problem report so you can close it>
NOTE: These scripts need work and are *NOT* safe to use unless you know
what they do. Use at your own risk. Patches would be great, but
I'd prefer they pass through me.
----------------------------------------------------------------------
checksum is a script that allows checking of ports to see if their checksums
match, and if they don't, give a diff against the older version to try and
discover why the checksum didn't match.
----------------------------------------------------------------------
distclean is a script that allows to compare md5 checksums of distfiles in
ports/distfiles with list of all md5 sums listed in "md5" files in the ports
collection. After comparing, utility will prompt to remove distfiles which
doesn't have associated md5 entry (most likely outdated distfiles).
----------------------------------------------------------------------
NOTE: These scripts need work and are *NOT* safe to use unless you know
what they do. Use at your own risk. Patches would be great, but
I'd prefer they pass through me.

55
Tools/scripts/distclean.sh Executable file
View File

@ -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."