52 lines
1.2 KiB
Bash
Executable File
52 lines
1.2 KiB
Bash
Executable File
#!/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
|