#!/bin/sh

# grep_pkg
# This script searches the bom files in /Library/Receipts
# for the component name given as a command line argument.
# It will show the info about that component from the bom file
# followed by the name of the pkg that contained that component
#
# Cameron Hayne (macdev@hayne.net), Sept 2004
#              revised for Leopard, June 2008
 
name=$1
cd /Library/Receipts
if [ -d boms ]; then  # the 'boms' directory is new with Leopard
    for bom in boms/*.bom; do
        lsbom $bom | grep "$name"
        if [ $? = 0 ]; then
            echo "*** $bom ***"
            echo "------------------------------"
        fi
    done
fi
for pkg in *.pkg; do
    find "$pkg" -name '*.bom' -print0 | xargs -0 lsbom | grep "$name"
    if [ $? = 0 ]; then
        echo "*** $pkg ***"
        echo "------------------------------"
    fi
done

