From 8dd7af16be7d661a9474d7a11baf5a72b5655997 Mon Sep 17 00:00:00 2001 From: karltk Date: Fri, 15 Nov 2002 00:31:44 +0000 Subject: [PATCH] Initial import svn path=/; revision=12 --- trunk/src/distfiles-clean/AUTHORS | 4 ++ trunk/src/distfiles-clean/ChangeLog | 2 + trunk/src/distfiles-clean/TODO | 0 trunk/src/distfiles-clean/distfiles-clean | 78 +++++++++++++++++++++++ 4 files changed, 84 insertions(+) create mode 100644 trunk/src/distfiles-clean/AUTHORS create mode 100644 trunk/src/distfiles-clean/ChangeLog create mode 100644 trunk/src/distfiles-clean/TODO create mode 100644 trunk/src/distfiles-clean/distfiles-clean diff --git a/trunk/src/distfiles-clean/AUTHORS b/trunk/src/distfiles-clean/AUTHORS new file mode 100644 index 0000000..b9121b4 --- /dev/null +++ b/trunk/src/distfiles-clean/AUTHORS @@ -0,0 +1,4 @@ + +José Fonseca + - Wrote all of it. + diff --git a/trunk/src/distfiles-clean/ChangeLog b/trunk/src/distfiles-clean/ChangeLog new file mode 100644 index 0000000..dfe6aa8 --- /dev/null +++ b/trunk/src/distfiles-clean/ChangeLog @@ -0,0 +1,2 @@ +2002-15-11: Karl Trygve Kalleberg + * Imported newest contributions from #10647. diff --git a/trunk/src/distfiles-clean/TODO b/trunk/src/distfiles-clean/TODO new file mode 100644 index 0000000..e69de29 diff --git a/trunk/src/distfiles-clean/distfiles-clean b/trunk/src/distfiles-clean/distfiles-clean new file mode 100644 index 0000000..23af32b --- /dev/null +++ b/trunk/src/distfiles-clean/distfiles-clean @@ -0,0 +1,78 @@ +#!/bin/sh +# +# distfiles-clean +# +# Cleans unused files from Portage's distfiles directory. +# +# José Fonseca + +PROGRAM=`basename "$0"` + +while [ ${#} -gt 0 ] +do + case "$1" in + -h|--help) + USAGE=y + break + ;; + -i|--ignore) + IGNORE="$IGNORE $2" + shift 2 + ;; + -I|--ignore-file) + IGNORE="$IGNORE `cat "$2"`" + shift 2 + ;; + -p|--pretend) + PRETEND=y + shift + ;; + *) + echo "$PROGRAM: Invalid option \'$1\'" 1>&2 + USAGE=y + break + ;; + esac +done + +# For PORTDIR and DISTDIR +. /etc/make.globals +. /etc/make.conf + +if [ "$USAGE" ] +then + echo "Usage: $PROGRAM [-h|--help] [-i|--ignore ] [-I|--ignore-file ] [-p|--pretend]" + echo "Cleans unused files from $DISTDIR directory." + exit +fi + +DBDIR=/var/db/pkg +CACHEDIR=/var/cache/edb/dep + +for DIR in "$PORTDIR" "$DISTDIR" "$DBDIR" "$CACHEDIR" +do + if [ ! -d "$DIR" ] + then + echo "$PROGRAM: \'$DIR\' not found." + exit + fi +done + +TMPFILE=`mktemp /tmp/$PROGRAM.XXXXXX` + +cd "$DISTDIR" + +{ + echo "cvs-src" + [ "$IGNORE" ] && ls -1d $IGNORE + find "$DBDIR" -name '*.ebuild' | sed -n -e "s:^$DBDIR/\([^/]*\)/\([^/]*\)/\([^/]*\)\.ebuild$:$CACHEDIR/\1/\3:p" | xargs sed -s -e '4!d;/^$/d;s/[[:alnum:]]\+?\|(\|)//g;s/\<[^[:space:]]\+\/\ "$TMPFILE" && ls -1 | comm -23 - "$TMPFILE" | { + if [ "$PRETEND" ] + then + cat + else + xargs rm -f + fi +} + +rm "$TMPFILE" -- 2.26.2