Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 07 Mar 2014 12:29:52 -0500
From:      "R. Scott Evans" <freebsd-questions@rsle.net>
To:        freebsd-questions@freebsd.org
Subject:   Re: pkg equivalent of "pkg_info -R"
Message-ID:  <531A0210.3070705@rsle.net>
In-Reply-To: <5319F0B7.3030200@netfence.it>
References:  <53186ABC.5060601@netfence.it> <20140306184030.078a99cedac859b5c5b83e22@embarqmail.com> <53196D17.8000300@FreeBSD.org> <5319F0B7.3030200@netfence.it>

next in thread | previous in thread | raw e-mail | index | archive | help
On 03/07/14 11:15, Andrea Venturoli wrote:
> On 03/07/14 07:54, Matthew Seaman wrote:
>
>> Yes, being able to generate the entire dependency tree would be a
>> desirable option.
>
> Exactly.
>
> In the example I gave, the rationale was, after the vulnerabiliy in 
> gnutls, getting a list of services which needed restarting.
>
>> It's not particularly difficult, but it does require
>> implementing recursive behaviour for such lookups.  That just needs
>> someone to step up and code it...
>
> I was just surprised that some funcionality I very often use was gone.
> Perhaps I'm doing things in a peculiar ways?
> Are there so few people doing this, that it could be overlooked?
>
> Of course, getting back to the previous example, listing the binaries 
> which are linked against gnutls might be another route...
>
>> Until then, you'ld have to write a shell wrapper around pkg query to
>> achieve the same effect.
>
> Ok.
> I'd just hate do duplicate work...
>
>  bye
>     av.
Okay, you got a python solution but here's my bourne shell version (I 
dislike python  :-)

-scott

#!/bin/sh
# Show ALL ports required for a given port.
################################################################################

WORK=`pkg info -r $1 | grep -v ":"`

while [ "X$WORK" != "X" ]; do
         for word in $WORK; do
                 if [ "X$NEW" = "X" ]; then
                        NEW=$word
                 else
                         NEW="$NEW $word"
                 fi

                 CHECK=`pkg info -r $word | grep -v ":"`
                 for new in $CHECK; do
                         testN=`echo "$NEW" | grep -w $new`
                         testW=`echo "$WORK" | grep -w $new`
                         if [ "X$testN" = "X" ] && [ "X$testW" = "X" ]; then
                                 WORK="$WORK $new"
                         fi
                 done

                 WC=`echo $WORK | wc -w | cut -w -f 2`
                 if [ $WC = 1 ]; then
                         WORK=""
                 else
                         WORK=`echo $WORK | cut -d ' ' -f 2-$WC`
                 fi
         done
done

## PRINT ALL RESULTS ON ONE (LONG) LINE
#echo $NEW

## OR THE RESULTS, ONE ENTRY PER LINE (easier to sort)
for X in $NEW; do
         echo $X
done



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?531A0210.3070705>