Re: files<->packages?

Joseph Tam <[email protected]> Mon, 14 Jun 2004 01:59:56 -0700 (PDT)
Newsgroups gmane.comp.security.sun
Message-ID <[email protected]>
On Fri, 11 Jun 2004, Alex Owen wrote:

> On Thu, 10 Jun 2004, Jonathan Burelbach wrote:
> > pkginfo -l <pkgname>  - provide details information on a package.
> > pkgchk -l <pkgname> -  provides the file listing of a package
> > pkgchk -lp <filename>   - tells you what package the file came from
>
> But do these commands tell you about packages you have not yet installed?

No.  I usually compile my own catalogue list by a small awk script from the
Solaris installation CDs.  It's handy to do quick lookups of which packages you
need to if want to install something (or which package to delete if you want
to remove something).

The format is simple if you peruse through it

	/cdrom/Solaris_?/Product/*/pkgmap

This script makes 2 files: Info (compilation of package information) and Files
(files associated with each package.  I used it for Solaris 9.  Season to
taste:

	#!/bin/sh

	#
	# Grab description info for all packages from Solaris installation CD
	#
	GREP="/usr/local/bin/grep -E"
	AWK=/usr/local/bin/gawk
	EXPAND=/usr/local/bin/expand
	DIR=/cdrom/Solaris_9/Product

	if [ -d $DIR/SUNWcsr ]; then
		echo Found SUNWcsr.  Doing disk \#1
		VERSION=1
	else
		echo Did not find SUNWcsr.  Doing disk \#2
		VERSION=2
	fi

	rm -f Info Files

	for f in $DIR/*; do

		PKG=`basename $f`

		if [ -f $f/pkginfo ]; then
			$GREP '^(NAME|DESC)=' $f/pkginfo | \
				sed -e "s,^,$VERSION $PKG	," | \
				expand --tabs=16 >> Info
		fi

		if [ -f $f/pkgmap ]; then
			$AWK -v PKG="$PKG" -v VERSION="$VERSION" < $f/pkgmap '
				$2=="f" {
					printf "%1s %-14s %s\n", VERSION, PKG, $4
				}

				$2=="l" {
					f = gensub(/=/," == ",1,$4)
					printf "%1s %-14s %s\n", VERSION, PKG, f
				}

				$2=="s" {
					f = gensub(/=/," -> ",1,$4)
					printf "%1s %-14s %s\n", VERSION, PKG, f
				}' >> Files
		fi
	done

Joseph Tam <[email protected]>