From owner-freebsd-questions@FreeBSD.ORG Fri Mar 7 17:30:04 2014 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 9CDFB969 for ; Fri, 7 Mar 2014 17:30:04 +0000 (UTC) Received: from mx1.rsle.net (mx1.rsle.net [IPv6:2607:ff40:b0b::4]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 4E9F3959 for ; Fri, 7 Mar 2014 17:30:04 +0000 (UTC) Received: from prometheus.rsle.net (UNKNOWN [206.162.203.14] (may be forged)) (authenticated bits=0) by mx1.rsle.net (8.14.7/8.14.7) with ESMTP id s27HTvLB029988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES128-SHA bits=128 verify=NO); Fri, 7 Mar 2014 12:29:58 -0500 (EST) (envelope-from freebsd-questions@rsle.net) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.98.1 at antivirus.rsle.net Message-ID: <531A0210.3070705@rsle.net> Date: Fri, 07 Mar 2014 12:29:52 -0500 From: "R. Scott Evans" User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:24.0) Gecko/20100101 Thunderbird/24.3.0 MIME-Version: 1.0 To: freebsd-questions@freebsd.org Subject: Re: pkg equivalent of "pkg_info -R" References: <53186ABC.5060601@netfence.it> <20140306184030.078a99cedac859b5c5b83e22@embarqmail.com> <53196D17.8000300@FreeBSD.org> <5319F0B7.3030200@netfence.it> In-Reply-To: <5319F0B7.3030200@netfence.it> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.4.3 (mx1.rsle.net [206.162.201.2]); Fri, 07 Mar 2014 12:29:58 -0500 (EST) X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 07 Mar 2014 17:30:04 -0000 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