Summary: how to check what package a file belongs to

From: Joseph Tam <tam_at_math.ubc.ca>
Date: Mon Feb 13 2006 - 20:17:33 EST
> From: "Leiv Jarle Larsen" <leiv.jarle.larsen@ementor.no>
> To: <sunmanagers@sunmanagers.org>
> 
> Thanks to Brett Lymn, Alfredo De Luca, Steve Butterfield and bgl for
> very quck replies
> 
> pkgchk -p -l <full-path-to-file>
> 
> 	Or
> 
> grep filename /var/sadm/install/contents

I frequently have to ask question like

 	1) Which package supplies xxx?
 	2) Which package does xxx belong to?
 	3) Which CD has xxx?
 	4) What is package xxx (that is not installed on a host so I can
 		do pkginfo)?
 	5) What package does xxx depend on?

I found it to handy just to coompile a simple text catalogue derived from
the installation CDs so that I can grep it.  It saved me from lots of man
page reading on little used pkg* commands and mounting/unmounting CDs.

Sample Info entries:
 	1 SUNWatfsu     AutoFS, (Usr) [utilities and a daemon (automountd) for the AutoFS filesystem]
 	1 SUNWauadt     Australasia CDE Support
 	1 SUNWauaow     Australasia OW Support
 	1 SUNWauda      Audio Applications [SunOS audio applications]
 	1 SUNWaudd      Audio Drivers [SunOS audio device drivers using the new audio driver architecture]

Sample Files entries:
 	1 SUNWceuow      openwin/lib/locale/de_AT.ISO8859-15/libs -> ../iso_8859_1/libs
 	1 SUNWceuow      openwin/lib/locale/de_AT.ISO8859-15/print -> ../iso8859-15/print
 	1 SUNWceuow      openwin/lib/locale/de_AT.ISO8859-15/xview/defaults
 	1 SUNWceuow      openwin/lib/locale/de_CH -> ./de_DE.ISO8859-1
 	1 SUNWceuow      openwin/lib/locale/de_CH.ISO8859-1 -> de_DE.ISO8859-1
 	1 SUNWceuow      openwin/lib/locale/de_DE -> ./de_DE.ISO8859-1
 	1 SUNWceuow      openwin/lib/locale/de_DE.ISO8859-1/LC_MESSAGES -> ../de/LC_MESSAGES

Sample Depend entries:
 	SUNWced.u       SUNWcar SUNWkvm SUNWcsr SUNWcsu SUNWcsd
 	SUNWced.us      SUNWcar SUNWkvm SUNWcsr SUNWcsu SUNWcsd
 	SUNWceudt       SUNWdtdte SUNWceuos
 	SUNWceuow       SUNWceuos
 	SUNWcfcl        SUNWcar SUNWcakr SUNWkvm SUNWcsr SUNWckr SUNWcnetr SUNWcsu SUNWcsd SUNWcsl
 	SUNWcfclr       SUNWcar SUNWcakr SUNWkvm SUNWcsr SUNWckr SUNWcnetr SUNWcsu SUNWcsd SUNWcsl SUNWcfcl
 	SUNWcfpl        SUNWcar SUNWcakr SUNWkvm SUNWcsr SUNWckr SUNWcnetr SUNWcsu SUNWcsd SUNWcsl SUNWluxop

Joseph Tam <tam@math.ubc.ca>
--------------------------------------------------------------------------------
Season to taste:
 	This works for Solaris 10 but 8 and 9 follow the same format (Change
 	$DIR).  Pop in one CD after another and run this command. If you pop
 	in a CD twice, you'll get duplicate entries.

#!/bin/sh
#
# Grab package information from Solaris installation CD
#	-> Info: summary of package name and description
#	-> Files: files supplied by each package
#	-> Depend: package dependencies
#
#				-- JT <tam at math dot ubc dot ca>, Jun 2005
#
GREP="/usr/local/bin/grep"
AWK="/usr/local/bin/gawk"
EXPAND="/usr/local/bin/expand"
DIR="/cdrom/Solaris_10/Product"

if [ ! -f "/cdrom/.volume.inf" ]; then
 	echo 1>&2 "Cannot retrive volume information.  Is the Solaris CDROM mounted?"
 	exit 1
fi

#
# Figure out which disk we have
#
VOL=`sed -n -e 's/^.*SOL_10_.*_SPARC\(.*\)"$/\1/p' </cdrom/.volume.inf`
case "$VOL" in
 	"")	VOLNUM=1 ;;
 	"_2")	VOLNUM=2 ;;
 	"_3")	VOLNUM=3 ;;
 	"_4")	VOLNUM=4 ;;
 	*) echo 1>&2 "Unrecognized Solaris volume: `cat /cdrom/.volume.inf`"; exit 1
esac

echo "\nProcessing volume #$VOLNUM\n"

for f in $DIR/*; do
 	PKG=`basename $f`

 	echo 1>&2 " $PKG\c"

 	if [ -f $f/pkginfo ]; then
 		NAME=`sed -n -e 's/^NAME=\(.*\)$/\1/p' <$f/pkginfo`
 		DESC=`sed -n -e 's/^DESC=\(.*\)$/\1/p' <$f/pkginfo`

 		if [ x"$NAME" = x"$DESC" ]; then
 			OUT="$VOLNUM $PKG\t$NAME"
 		else
 			OUT="$VOLNUM $PKG\t$NAME [$DESC]"
 		fi

 		echo "$OUT" | $EXPAND --tabs=16 >>Info
 	else
 		echo 1>&2 "(no pkginfo)\c"
 	fi

 	if [ -f $f/pkgmap ]; then
 		$AWK -v LABEL="$VOLNUM $PKG" < $f/pkgmap '
 			($2=="f") {
 				printf "%-16s %s\n", LABEL, $4
 				next
 			}

 			($2=="l") {
 				printf "%-16s %s\n", LABEL, gensub(/=/," == ",1,$4)
 				next
 			}

 			($2=="s") {
 				printf "%-16s %s\n", LABEL, gensub(/=/," -> ",1,$4)
 				next
 			}' >>Files
 	else
 		echo 1>&2 "(no files)\c"
 	fi

 	if [ -f $f/install/depend ]; then
 		echo "$PKG\t`sed -n -e 's/^P \([^	 ]*\).*$/\1/p' <$f/install/depend | fmt -999`" | $EXPAND --tabs=16 >>Depend
 	else
 		echo 1>&2 "(no depend)\c"
 	fi
done

echo 1>&2 "\n\nDone."
_______________________________________________
sunmanagers mailing list
sunmanagers@sunmanagers.org
http://www.sunmanagers.org/mailman/listinfo/sunmanagers
Received on Mon Feb 13 20:19:22 2006

This archive was generated by hypermail 2.1.8 : Thu Mar 03 2016 - 06:43:55 EST