#!/bin/sh

# lspkg
# This script lists the "bill of materials"
# for the pkg file specified as a command-line argument.
#
# Cameron Hayne (macdev@hayne.net)  April 2004

if [ $# -lt 1 ]; then
    scriptname=`basename $0`
    echo "Usage: $scriptname pkg_file"
    exit
fi

pkg_path=$1

# We use 'find' to get the .bom files under the .pkg folder
# and then run 'lsbom' on them
# and then use 'sed' to remove the extraneous dot from the start of each line
# and run the results through 'sort | uniq'
# (this is useful since there are often two duplicate bom's in a .pkg)

find "$pkg_path" -name '*.bom' -print0 | xargs -0 lsbom \
    | sed 's/^\.//' \
    | sort | uniq
