Subject: pkg/29749: minor pkg_comp enhancement
To: None <pkg-manager@netbsd.org, gnats-admin@netbsd.org,>
From: None <kre@munnari.OZ.AU>
List: pkgsrc-bugs
Date: 03/20/2005 21:01:00
>Number:         29749
>Category:       pkg
>Synopsis:       minor pkg_comp enhancement
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Sun Mar 20 21:01:00 +0000 2005
>Originator:     Robert Elz
>Release:        NetBSD 2.0.1   (pkgsrc reasonably current)
>Organization:
	Prince of Songkla University
>Environment:
System: NetBSD delta.noi.kre.to 2.0.1 NetBSD 2.0.1 (DELTA-1.11-20050129) #1: Sat Jan 29 15:31:14 ICT 2005 kre@lilac.noi.kre.to:/usr/obj/2.0/kernels/DELTA i386
Architecture: i386
Machine: i386
>Description:
	I find myself doing
		pkg_comp chroot pkg_delete xxx
	or
		pkg_comp chroot pkg_chk ...
	or
		(various similar, pkg_add, ...)
	fairly frequently for one reason or other.

	I know I could do

		pkg_comp chroot

	and leave a shell i the chroot, at which to type
	commands (pkg_delete, ...) but for various reasons that
	isn't always convenient.

	The "chroot" word in the above commands is essentially
	useless, not doing that would be not using pkg_comp at all.

	So, I thoughit I'd see how hard it would be to make the
	chroot optional, when the next command is a pkg_* type
	command (it could be made optional for all unrecognised
	following commands, but that makes it less effective at
	catching common typos, so I thought that may be a bit too far)
>How-To-Repeat:
	Use pkg_comp a lot, get frustrated by keepig forgetting to
	type "chroot" in svery 2nd or third command...
>Fix:
	The patch below adds the functionality I desired.
	The change is trivial.

	There's also a (probably lame) addition to the man page.
	Someone who understands mdoc should check that, I have no
	idea what I'm doing in that macro package.

	And, for good measure, I also corrected a minor typo in the
	man page that I happened to notice while checking.

Index: pkg_comp.8
===================================================================
RCS file: /cvsroot/NetBSD/pkgsrc/pkgtools/pkg_comp/files/pkg_comp.8,v
retrieving revision 1.23
diff -u -r1.23 pkg_comp.8
--- pkg_comp.8	29 Dec 2004 22:16:22 -0000	1.23
+++ pkg_comp.8	20 Mar 2005 20:35:26 -0000
@@ -445,6 +445,11 @@
 If no arguments are given,
 .Va ROOTSHELL
 is executed, otherwise whatever you typed.
+If the arguments begin with a word that begins
+.Li pkg_
+then the
+.Ql chroot
+argument can be omitted (it is implied).
 .It removeroot
 Remove the entire chroot tree.
 You should do it with this target because it
@@ -464,7 +469,7 @@
 .Sy AUTO_PACKAGES
 or pass package names through the command line.
 .Pp
-If the magic work
+If the magic word
 .Ql resume
 is passed as the unique argument to this target,
 .Nm
Index: pkg_comp.sh
===================================================================
RCS file: /cvsroot/NetBSD/pkgsrc/pkgtools/pkg_comp/files/pkg_comp.sh,v
retrieving revision 1.22
diff -u -r1.22 pkg_comp.sh
--- pkg_comp.sh	12 Dec 2004 01:04:27 -0000	1.22
+++ pkg_comp.sh	20 Mar 2005 20:27:22 -0000
@@ -886,8 +886,10 @@
     conffile="$confdir/default.conf"
 fi
 
-target="$1"
-shift
+case "$1" in
+pkg_*)		target=chroot;;
+*)		target="$1"; shift;;
+esac
 args="$*"
 
 # readconf