diff options
Diffstat (limited to 'mk/pkgformat/pkg/register-dependencies')
-rwxr-xr-x | mk/pkgformat/pkg/register-dependencies | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/mk/pkgformat/pkg/register-dependencies b/mk/pkgformat/pkg/register-dependencies new file mode 100755 index 00000000000..148ef8ac340 --- /dev/null +++ b/mk/pkgformat/pkg/register-dependencies @@ -0,0 +1,51 @@ +#!/bin/sh +# +# $NetBSD: register-dependencies,v 1.1 2011/10/15 00:23:09 reed Exp $ +# +###################################################################### +# +# NAME +# register-dependencies -- register package dependencies +# +# SYNOPSIS +# register-dependencies pkgname +# +# DESCRIPTION +# register-dependencies registers a dependency relationship from +# the named package pkgname and the packages passed in via +# standard input. +# +# ENVIRONMENT +# PKG_DBDIR +# This is the package meta-data directory in which the +# packages are registered. By default, this is /var/db/pkg. +# +###################################################################### + +: ${AWK:=awk} +: ${CP:=cp} +: ${ECHO:=echo} +: ${PKG_DBDIR:=/var/db/pkg} +: ${RM:=rm} +: ${TEST:=test} +: ${TOUCH:=touch} +: ${TRUE:=true} + +PKGNAME="$1" + +while read pkg; do + pkgdir="${PKG_DBDIR}/$pkg" + if ${TEST} ! -d "$pkgdir"; then + ${ECHO} 1>&2 "$pkg not found - dependency NOT registered" + continue + fi + req="$pkgdir/+REQUIRED_BY" + tmpreq="$pkgdir/+REQUIRED_BY.$$" + ${TOUCH} $req + ${AWK} -v PKGNAME="${PKGNAME}" \ + 'BEGIN { found = 0 } + $0 == PKGNAME { found = 1 } { print } + END { if (!found) print PKGNAME }' $req > $tmpreq + ${CP} -f $tmpreq $req; ${RM} -f $tmpreq + ${ECHO} "${PKGNAME} requires installed package $pkg" +done |