From owner-freebsd-questions@FreeBSD.ORG Tue Feb 1 14:19:43 2005 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id E5B3616A4CF for ; Tue, 1 Feb 2005 14:19:43 +0000 (GMT) Received: from weller-fahy.com (pD9FFED1D.dip.t-dialin.net [217.255.237.29]) by mx1.FreeBSD.org (Postfix) with ESMTP id D0B2D43D1F for ; Tue, 1 Feb 2005 14:19:42 +0000 (GMT) (envelope-from dave-lists-freebsd-questions@weller-fahy.com) Received: (qmail 38022 invoked by uid 1001); 1 Feb 2005 14:19:36 -0000 Date: Tue, 1 Feb 2005 15:19:36 +0100 From: "David J. Weller-Fahy" To: freebsd-questions@freebsd.org Message-ID: <20050201141914.GC87827@weller-fahy.com> Mail-Followup-To: freebsd-questions@freebsd.org References: <200502010132.j111WhkT007090@smtp3.server.rpi.edu> <20050201072415.GB87827@weller-fahy.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="V88s5gaDVPzZ0KCq" Content-Disposition: inline In-Reply-To: <20050201072415.GB87827@weller-fahy.com> X-URL-Me: http://weller-fahy.com X-Accept-Language: en X-Location: Germany, Gangelt, Hof Grootfeld User-Agent: Mutt/1.5.6i Subject: Re: Cleaning Out Ports? X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 01 Feb 2005 14:19:44 -0000 --V88s5gaDVPzZ0KCq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline * David J. Weller-Fahy [2005-02-01 08:24 +0100]: > * Matt LaPlante [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 ] --V88s5gaDVPzZ0KCq Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="rm_leaf.sh.txt" #!/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 --V88s5gaDVPzZ0KCq--