* David J. Weller-Fahy <[EMAIL PROTECTED]> [2005-02-01 08:24 +0100]:
> * Matt LaPlante <[EMAIL PROTECTED]> [2005-02-01 02:36 +0100]:
> Attached is my script, and my conf file.

Unfortunately, my script got stripped.  Here's the script with a txt
extension.

Regards,
-- 
dave [ please don't CC me ]
#!/bin/sh
# $HOME/bin/rm_leaf.sh
set -e

LETC=/usr/local/etc
PBASE=/usr/ports
RMLFCNF=rm_leaf.conf
SCRFILE=remove_leaf_ports.sh

PKGINFO=`cd /var/db/pkg && find . -type d | sed '/^.$/d;s/^\.\///'`
PKGREQB=`cd /var/db/pkg && ls */+REQUIRED_BY | sed 's/\/+REQUIRED_BY//g'`
NOTLIST=`cat $LETC/$RMLFCNF`

# remove any packages that are required by any other packages
for PKG in $PKGREQB ; do [ -s /var/db/pkg/$PKG/+REQUIRED_BY ] && \
        PKGINFO=`echo $PKGINFO | sed "s/$PKG//"` ; done

# remove any packages that are in the users list of 'to keep' packages
for PKG in $NOTLIST ; do PKGINFO=`echo $PKGINFO | sed "s/$PKG[^ ]*//"` ; done

# if there's nothing left in PKGINFO, exit now
[ -z "$PKGINFO" ] && echo "No packages/ports to remove." && exit

rm -f $SCRFILE # remove the script file (just in case)

# match up packages to origin in the ports tree
for PKG in $PKGINFO ; do RMLIST="${RMLIST:-} $PKG:$PBASE/`pkg_info -o $( echo 
$PKG ) | sed -n '/^Origin:$/{n;p;}'`" ; done

cat > $SCRFILE << EOFA
#!/bin/sh
# script to remove all leaf packages not listed in /usr/local/etc/rm_leaf.list
set -e

EOFA

# create script to remove all selected packages
for PKG in $RMLIST ; do
        PNAME=`echo $PKG | sed 's/:.*$//'`
        PPATH=`echo $PKG | sed 's/^[^:]*://'`
        cat >> $SCRFILE <<-EOFB
        echo "Removing $PNAME in $PPATH:"
        cd $PPATH
        make deinstall clean distclean
        echo "Success!" ; echo ; echo
        EOFB
done

[ -n "${1:-}" ] && cat $SCRFILE && rm $SCRFILE
_______________________________________________
freebsd-questions@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-questions
To unsubscribe, send any mail to "[EMAIL PROTECTED]"

Reply via email to