#!/bin/echo Source me: .
#
# Copyright (c) 2002-2004 by Frederick Bruckman
# All rights reserved.

# Takes <category>/<subdirectory> pairs as arguments; emits
# a list of matching package names to standard out.
#
dir_to_pkg () {
	awk '
		BEGIN {
			for (i = 1; i < ARGC - 1; i++) {
				if (ARGV[i] ~ /\//)
					dirs[ARGV[i]] = 0
				ARGV[i] = ""
			}
		}
		{
			if ($1 in dirs) {
				print $2
				next
			}
		}
	' "$@" "${PKGORDERDIR}"/dir_to_pkgname
}
