From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 854FC1382C5 for ; Tue, 1 Jun 2021 19:43:07 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id CB29CE07D7; Tue, 1 Jun 2021 19:43:06 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id A9A17E07A5 for ; Tue, 1 Jun 2021 19:43:06 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id D49DE340FA7 for ; Tue, 1 Jun 2021 19:43:04 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 3340C79D for ; Tue, 1 Jun 2021 19:43:03 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1622576431.43ce14510666e67265dc16f0b0d72bd706074b41.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: qwhich.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 43ce14510666e67265dc16f0b0d72bd706074b41 X-VCS-Branch: master Date: Tue, 1 Jun 2021 19:43:03 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 91eb5920-587f-4e11-a83c-c4a12dd53194 X-Archives-Hash: ff8e88e0c8eadad9d9aea95f2c14723c commit: 43ce14510666e67265dc16f0b0d72bd706074b41 Author: Fabian Groffen gentoo org> AuthorDate: Tue Jun 1 19:40:31 2021 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Tue Jun 1 19:40:31 2021 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=43ce1451 qwhich: better support for binpkgs - don't use ROOT with PKGDIR - print coloured paths/matches for binpkgs - support dirs (-d) for binpkgs Signed-off-by: Fabian Groffen gentoo.org> qwhich.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/qwhich.c b/qwhich.c index 24a9ff0..76b03a8 100644 --- a/qwhich.c +++ b/qwhich.c @@ -82,6 +82,7 @@ int qwhich_main(int argc, char **argv) tree_ctx *t; char *repo; int repolen; + const char *ext; memset(&m, 0, sizeof(m)); @@ -144,7 +145,7 @@ int qwhich_main(int argc, char **argv) xarraypush_ptr(trees, t); } if (m.do_binpkg) { - t = tree_open_binpkg(portroot, pkgdir); + t = tree_open_binpkg("/", pkgdir); if (t != NULL) xarraypush_ptr(trees, t); } @@ -159,7 +160,7 @@ int qwhich_main(int argc, char **argv) /* at least keep the IO constrained to a tree at a time */ array_for_each(trees, j, t) { - if (m.print_repo) { + if (m.print_repo && t->repo != NULL) { repo = t->repo; repolen = strlen(repo); } else { @@ -168,12 +169,24 @@ int qwhich_main(int argc, char **argv) repolen = strlen(t->path) - (sizeof("/metadata/md5-cache") - 1); else if (t->cachetype == CACHE_METADATA_PMS) repolen = strlen(t->path) - (sizeof("/metadata/cache") - 1); - else if (t->cachetype == CACHE_EBUILD) + else if (t->cachetype == CACHE_EBUILD || + t->cachetype == CACHE_BINPKGS || + t->cachetype == CACHE_PACKAGES) repolen = strlen(t->path); else repolen = 0; } + switch (t->cachetype) { + case CACHE_BINPKGS: + case CACHE_PACKAGES: + ext = "tbz2"; + break; + default: + ext = "ebuild"; + break; + } + array_for_each(atoms, i, atom) { tmc = tree_match_atom(t, atom, (m.match_latest ? TREE_MATCH_LATEST : 0 ) | @@ -186,7 +199,9 @@ int qwhich_main(int argc, char **argv) } else { if (t->cachetype == CACHE_METADATA_MD5 || t->cachetype == CACHE_METADATA_PMS || - t->cachetype == CACHE_EBUILD) + t->cachetype == CACHE_EBUILD || + t->cachetype == CACHE_BINPKGS || + t->cachetype == CACHE_PACKAGES) { if (m.print_path) printf("%s%.*s%s%s%s/%s%s%s\n", @@ -196,13 +211,13 @@ int qwhich_main(int argc, char **argv) DKBLUE, tmcw->atom->PN, NORM); else - printf("%s%.*s%s%s%s/%s%s/%s%s%s.ebuild%s\n", + printf("%s%.*s%s%s%s/%s%s/%s%s%s.%s%s\n", DKGREEN, repolen, repo, m.print_repo ? "::" : "/", BOLD, tmcw->atom->CATEGORY, DKBLUE, tmcw->atom->PN, BLUE, tmcw->atom->PF, - DKGREEN, NORM); + DKGREEN, ext, NORM); } else if (t->cachetype == CACHE_VDB && !m.print_path) { printf("%s%s/%s%s%s.ebuild%s\n", DKBLUE, tmcw->path,