Getting a list of dependencies which have to be installed ?
Eric Schuele
e.schuele at computer.org
Thu Dec 14 11:56:03 PST 2006
On 12/14/2006 12:10, Frank Staals wrote:
> Hey...,
>
> Is there a utility to display the dependencies of a port which have yet
> to be installed ? I know you can get a complete dependency list on
> freebsd.org/ports , pkg_info -r or just looking in the files in the
> ports dir. But is there a command to display only the dependencies which
> haven't been installed on your system yet ? I also looked at pkg_add -n
> but it immediately starts fetching the packages needed. I don't want to
> start downloading the complete package just because I want a list of
> ports I haven't installed yet.
>
> Or is the only way making a diff between the pkg_info -r output and your
> pkg_info -a ? If so : Is there a way to tell pkg_info when using the -r
> flag on a not-yet-installed-port to only get a list of the dependencies
> instead of downloading the complete package ? Or is there just an other
> utility which can display this information which I'm not aware of ?
>
> Thanks in advance,
>
I needed this functionality, so I wrote a script... and sent it to the
list for thoughts and opinions. After a few folks chipped in... this is
what we had.
Try the following (mind any wrapping):
#! /bin/sh
# Script to determine the differences between what is necessary for
# a port, and what is already present on the local machine.
awkprgt='{
count = 0
pkgs = ""
for(i=5; i<=NF-2; i++) {
pkg = $i
# the "if" is here to hack it around when you get:
# This port requires package(s) "" to build.
if (pkg != "\"\"") {
if (index(pkg, "\"") == 1)
{pkg = substr(pkg, 2, length(pkg)-1)}
if (index(pkg, "\"") > 1)
{pkg = substr(pkg, 1, length(pkg)-1)}
if ( system("pkg_info -e " pkg) == 1) {
pkgs = pkgs " " pkg
count++
}
}
}
if ( count ) {
printf "You need the following %d (%typ) perequisites:", count
print pkgs
}
else {
print "All (%typ) prerequisites are present."
}
}
END {
# triggered, eg., by audio/artswrapper (on my box, at least)
if( ! FNR) {
print "Bogus (empty) %s dependency information"
}
}
'
awkit() {
# Resolve "%s"-s via sed is a blunt hack
# but good enough here and thus we don't have
# to care about the number of occurrences
awk "`echo "$awkprgt" | sed s/%typ/$1/g`"
}
make pretty-print-build-depends-list | awkit build
make pretty-print-run-depends-list | awkit run
### End Script
HTH. I use it all the time.
--
Regards,
Eric
More information about the freebsd-questions
mailing list