$NetBSD: patch-ab,v 1.1 2005/12/10 16:57:42 ghen Exp $

--- pkg_rmleaves.orig	2005-12-10 17:09:10.000000000 +0100
+++ pkg_rmleaves
@@ -34,6 +34,7 @@
 #	-x: Use Xdialog
 #	-X: Use Xdialog in high compatibility mode
 #	-k: Use kdialog
+#	-a: Act only on automatically installed packages
 
 TMPDIR=`mktemp -dt pkg_rmleaves`	#Directory where i keep the temporary files
 TMPFILE="$TMPDIR/tmp"				#Generic use temporary file
@@ -60,7 +61,7 @@ esci() {
 # update leaf files
 checkLeafs() {
 	find -s /var/db/pkg/ -type d -mindepth 1 | while read i; do
-		if [ ! -s "$i/+REQUIRED_BY" ]; then 
+		if [ ! -s "$i/+REQUIRED_BY" ] && ( [ -z $AUTOMATIC_ONLY ] || [ ! -z `pkg_info -Qautomatic $i` ] ); then
 			basename "$i" >> "$PKGFILE"
 		fi
 	done
@@ -108,7 +109,7 @@ trap "esci \"Ctrl+C Pressed, Program Abo
 # Use dialog as default DIALOG
 DIALOG=dialog
 
-args=`getopt ldxXk $*`
+args=`getopt ldxXka $*`
 set -- $args
 for i; do
 	case "$i" in
@@ -130,6 +131,9 @@ for i; do
 		-k)
 			DIALOG=kdialog
 			break;;
+		-a)
+			AUTOMATIC_ONLY=yes
+			break;;
 	esac
 done
 
