#!/bin/sh

if [ -z "$1" ]
then
    echo "usage: $(basename $0) <portsdir>"
    exit 2
fi

if [ ! -d "/usr/ports/$1/pkg" ]
then
    echo "not a ports dir"
    exit 1
fi

cd /usr/ports/$1

make show="COMMENT FULLPKGNAME HOMEPAGE SITES MAINTAINER DESCR" \
    | tr -s " " \
    | awk 'NR == 1 { print "Comment: "$0 } \
    NR == 2 { print "Distname: "$0 } \
    NR == 3 { print "Homepage: "$0 } \
    NR == 5 { print "Maintainer: "$0"\n" } \
    NR == 6 { system("/bin/cat " $0); }'