From abeaupre@chemcomp.com  Thu Jul 20 09:03:38 2000
Return-Path: <abeaupre@chemcomp.com>
Received: from smtp13.bellglobal.com (smtp13.bellglobal.com [204.101.251.52])
	by hub.freebsd.org (Postfix) with ESMTP id 4266E37B5CF
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 20 Jul 2000 09:03:30 -0700 (PDT)
	(envelope-from abeaupre@chemcomp.com)
Received: from hermes.chemcomp.com (ppp12498.qc.bellglobal.com [206.172.133.11])
	by smtp13.bellglobal.com (8.8.5/8.8.5) with ESMTP id MAA18096
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 20 Jul 2000 12:07:40 -0400 (EDT)
Received: from sky.chemcomp.com (sky.chemcomp.com [192.1.1.62])
	by hermes.chemcomp.com (Postfix) with ESMTP id 96B3C16817
	for <FreeBSD-gnats-submit@freebsd.org>; Thu, 20 Jul 2000 12:03:17 -0400 (EDT)
Received: by sky.chemcomp.com (Postfix, from userid 1111)
	id C0AF3A7; Thu, 20 Jul 2000 12:02:48 -0400 (EDT)
Message-Id: <20000720160248.C0AF3A7@sky.chemcomp.com>
Date: Thu, 20 Jul 2000 12:02:48 -0400 (EDT)
From: abeaupre@chemcomp.com
Reply-To: abeaupre@chemcomp.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: New (?) package management utilities
X-Send-Pr-Version: 3.2

>Number:         20062
>Category:       bin
>Synopsis:       New (?) package management utilities
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Thu Jul 20 09:10:01 PDT 2000
>Closed-Date:    Fri Jul 21 02:18:54 PDT 2000
>Last-Modified:  Fri Jul 21 02:21:25 PDT 2000
>Originator:     Antoine Beaupre
>Release:        FreeBSD 4.0-RELEASE i386
>Organization:
Chemical Computing Group, Inc.
>Environment:

	FreeBSD sky.chemcomp.com 4.0-RELEASE FreeBSD 4.0-RELEASE #7:
	Tue Jun 27 16:42:57 EDT 2000
	root@sky.chemcomp.com:/usr/src/sys/compile/SKY  i386

>Description:

I have "coded" a few shell scripts to help me in the titanic task of
managing packages under FreeBSD, and I think there would be place in
the base system for this.

These are basic shell scripts that make a heavy use of grep and ls and
that are much faster than pkg_info(1) and that (you guessed it!)
support regular expressions (yay!).

Description of utilities:

pkg_find [regexp]
[displays names of matching packages]

pkg_findBin [regexp]
[displays names of packages which +CONTENTS file matches regexp]

pkg_desc [regexp]
[gives +DESC files of matching packages, uses pkg_find]

pkg_plist [regexp]
[idem with +CONTENTS file]

One could add one called pkg_comment or something like that to give
the short description of the package and/or merge the last 2 together
since the code is the same. Only the displayed file is different.

>How-To-Repeat:

$ pkg_find em
movemail-1.0
xemacs-mule-21.1.9
xemacs-mule-common-21.1.9
xemacs-mule-packages-1.1
xemacs-packages-1.1
$ pkg_findBin '\(apache\)\|\(xemacs\)'
File found in:
apache-1.3.12
xemacs-mule-21.1.9
xemacs-mule-common-21.1.9
xemacs-mule-packages-1.1
xemacs-packages-1.1
$ pkg_desc xemacs
...

You get the picture..

>Fix:

Source code (!):

pkg_find (that's a hard one... :)
---- Cut Here ----
#! /bin/sh

ls /var/db/pkg | grep $@
---- Cut Here ----

pkg_findBin:
---- Cut Here ----
#! /bin/sh

pkgDir="/var/db/pkg"

echo "Matching packages:"

for package in `ls $pkgDir`
{
	grep -q $@ $pkgDir/$package/+CONTENTS && \
	echo $package

}
---- Cut Here ----

pkg_desc:
---- Cut Here ----
#! /bin/sh

hits=`pkg_find $@`
if [ ! -z "$hits" ] 
then
    echo "Matches:"
    echo
    echo $hits
    echo 
    echo "To display package(s) description, press ENTER. Ctrl-C to cancel."
    read botch

    for hit in $hits
    do 
	$PAGER /var/db/pkg/$hit/+DESC
	read -p "Press ENTER to continue"
    done
else
    echo No match.
fi
---- Cut Here ----

pkg_plist (could probably be merged with pkg_desc):
---- Cut Here ----
#! /bin/sh

hits=`pkg_find $@`

if [ ! -z "$hits" ] 
then
    echo "Matches:"
    echo
    echo $hits
    echo 
    echo "To display package(s) description, press ENTER. Ctrl-C to cancel."
    read botch

    for hit in $hits
    do 
	$PAGER /var/db/pkg/$hit/+CONTENTS
	read -p "Press ENTER to continue: " botch
    done
else
    echo No match.
fi
---- Cut Here ----

TODO:

- Compatibility with pkg_info commandline and environnement.
- Full pkg_info replacement??
- Merge pkg_desc pkg_plist and potential pkg_comment together

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: sheldonh 
State-Changed-When: Fri Jul 21 02:18:54 PDT 2000 
State-Changed-Why:  
What's really needed is for the _existing_ package management 
tools to be extended as required.  Providing a pantheon of 
management utilities, each of which duplicates in some way 
the functionality of at least one other, is not the way to go. 

However, if you're not up to that task but still think your 
suite of scripts is useful, you should probably submit them 
as a port.  Please see: 

http://www.freebsd.org/porters-handbook/ 

http://www.freebsd.org/cgi/query-pr.cgi?pr=20062 
>Unformatted:
