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 841BCDC00B5 for ; Tue, 3 Dec 2013 04:48:15 +0000 (UTC) Received: from compute5.internal (compute5.nyi.mail.srv.osa [10.202.2.45]) by gateway1.nyi.mail.srv.osa (Postfix) with ESMTP id C684921623 for ; Mon, 2 Dec 2013 23:48:14 -0500 (EST) Received: from frontend2 ([10.202.2.161]) by compute5.internal (MEProxy); Mon, 02 Dec 2013 23:48:14 -0500 DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d= messagingengine.com; h=date:from:to:subject:message-id :mime-version:content-type; s=smtpout; bh=qucOf+Ov1SrrQ6dbL8b8FA y3EfU=; b=gZzdnwJr9zcEhUVuMfSSQdXRo9ELOyXiDY4hgFeYGazyD317TjyjaG 2E/wwmTut3fmSEHo17GXadoqhBd9aZnz5HWWXT/bnVjhIcdGZ1ilzbG8TSphHPfa PzDy6iYnPHE2Yo81VPsEVNFwQFTzz930Ca8gMukMCIH2UGB/HWcUo= X-Sasl-enc: 6OFwxvfHjSm+aKOCxYW8KdO3mUxlMQdfRQ3L4iQ16YMp 1386046094 Received: from localhost (unknown [69.86.161.244]) by mail.messagingengine.com (Postfix) with ESMTPA id 973A3680101 for ; Mon, 2 Dec 2013 23:48:14 -0500 (EST) Date: Mon, 2 Dec 2013 23:48:14 -0500 From: Dubiousjim To: Alpine Subject: [alpine-devel] recursive apk info Message-ID: <20131203044814.GF29236@zen> Mail-Followup-To: Alpine 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 User-Agent: Mutt/1.5.22 (2013-10-16) I think there is currently no way to get apk info to recurse when reporting dependencies or (installed) reverse dependencies. The switches --depends and --rdepends just report a single layer. So I wrote the following awk wrapper to get the recursive info occasionally. It's slow, but presumably one won't need this very often. #!/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) { f = substr(f, 4) #printf("who owns <%s>?\n", f) # 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) { sub(/[<>]?=.*/, "", f) if (infocmd == "apk info -R ") sub(/-[^-]+-r[0-9]+$/, "", f) if (!(f in stored)) { queue[nextq] = f nextq++ # v is 0 for initial arguments, 1 for dependencies stored[f] = v } } function readone(f, line, rc) { #printf("running readone(%s)\n", f) rc = 1 if (infocmd f | getline line) { # we read until first blank line rc = 0 while ((infocmd f | getline line)>0 && line) { #printf("read: %s\n", line) if (line ~ /^so:/) line = whoowns(line) enqueue(line, 1) } } close(infocmd f) return rc } 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 ---