X-Original-To: alpine-devel@lists.alpinelinux.org Delivered-To: alpine-devel@mail.alpinelinux.org Received: from out1-smtp.messagingengine.com (out1-smtp.messagingengine.com [66.111.4.25]) (using TLSv1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.alpinelinux.org (Postfix) with ESMTPS id 5A2A9DC047A for ; Tue, 3 Dec 2013 12:17:05 +0000 (UTC) Received: from compute3.internal (compute3.nyi.mail.srv.osa [10.202.2.43]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id BD650214F1 for ; Tue, 3 Dec 2013 07:17:04 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute3.internal (MEProxy); Tue, 03 Dec 2013 07:17:04 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:subject:message-id :references:mime-version:content-type:in-reply-to; s=smtpout; bh=p7KqM0Mojhw4aQoXiff/htS6m+k=; b=tKaNdngf/fkV0cktpyFPzzRWXFpd A0uCXNhQZ9dbt+6me/8c89f08udWwVlxXvA7McpwczQO4rTfJdscuLPfkR+lCN92 FZpaaxbIu44cBJ6zsgD/l94o/vqv9sCGsqZSXJaLF6zwI7fUz+5YF5gDMUiKmtSd FuFVc6kvVPPZMdM= X-Sasl-enc: 6i5dTGY6kCJwB+fjoTM9UAeQlozFSyPfYeJ8VQSfzrvw 1386073024 Received: from localhost (unknown [69.86.161.244]) by mail.messagingengine.com (Postfix) with ESMTPA id 8F649680141 for ; Tue, 3 Dec 2013 07:17:04 -0500 (EST) Date: Tue, 3 Dec 2013 07:17:04 -0500 From: Dubiousjim To: Alpine Subject: Re: [alpine-devel] recursive apk info Message-ID: <20131203121703.GH29236@zen> Mail-Followup-To: Alpine References: <20131203044814.GF29236@zen> X-Mailinglist: alpine-devel Precedence: list List-Id: Alpine Development List-Unsubscribe: List-Post: List-Help: List-Subscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20131203044814.GF29236@zen> User-Agent: Mutt/1.5.22 (2013-10-16) Some fixes/tweaks... #!/bin/sh # We can't use a shebang of /usr/bin/awk -f, because awk may be implemented by gawk, which # will handle an ARGV[1] of -D itself, rather than passing to this script. usage() { echo "Usage: $0 -D/-R packages..." >&2 exit 2 } if [ $# -lt 2 ]; then usage else case $1 in -D|-R) true;; --depends|--rdepends) true;; -r) true;; # deprecated form of -R *) usage;; esac fi awk -f - -- "$@" << "EOF" #!/usr/bin/awk -f function whoowns(f, path, line) { # TODO: grep output of ldconfig -p? if (system("test -f /lib/" f) == 0) path = "/lib/" f else if (system("test -f /usr/lib/" f) == 0) path = "/usr/lib/" f; if (path != "") { "apk info -Wq " path | getline line close("apk info -Wq " path) if (line != "" && line !~ /^ERROR:/) { return line } } printf("Couldn't find %s.\n", f) > "/dev/stderr" exit 1 } function enqueue(f, v) { if (infocmd ~ /^apk info (-[Rr]|--r)/) sub(/-[^-]+-r[0-9]+$/, "", f) else sub(/[<>]?=.*/, "", f) if (!(f in stored)) { queue[nextq++] = f # v is 0 for initial arguments, 1 for dependencies stored[f] = v } } function readone(f, line, rc) { rc = 1 if (infocmd f | getline line) { # we read until first blank line rc = 0 while ((infocmd f | getline line)>0 && line) { if (line ~ /^so:/) line = whoowns(substr(line, 4)) enqueue(line, 1) } } close(infocmd f) if (rc != 0) { printf("No info for %s.\n", f) > "/dev/stderr" exit 1 } } BEGIN { # globals: infocmd nextq queue[] stored[] i infocmd = "apk info " ARGV[1] " " nextq=1 for (i=2; i0) print i | "sort" close("sort") exit 0 } EOF -- dubiousjim@gmail.com --- Unsubscribe: alpine-devel+unsubscribe@lists.alpinelinux.org Help: alpine-devel+help@lists.alpinelinux.org ---