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 750F41382C5 for ; Sat, 27 Jun 2020 09:38:13 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id BA463E095D; Sat, 27 Jun 2020 09:38:12 +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 A250EE095D for ; Sat, 27 Jun 2020 09:38:12 +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 A056034F1D5 for ; Sat, 27 Jun 2020 09:38:11 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 554D52B9 for ; Sat, 27 Jun 2020 09:38:10 +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: <1593250645.f6dd53fa56478d3f9e0b6c1f1ecbd2cfc8529184.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: TODO.md qpkg.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: f6dd53fa56478d3f9e0b6c1f1ecbd2cfc8529184 X-VCS-Branch: master Date: Sat, 27 Jun 2020 09:38:10 +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: 8ac45060-4ed0-426d-9929-38f8f5db2031 X-Archives-Hash: c270a5bf8d90c2ffc914a560741851d3 commit: f6dd53fa56478d3f9e0b6c1f1ecbd2cfc8529184 Author: Fabian Groffen gentoo org> AuthorDate: Sat Jun 27 09:37:25 2020 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Sat Jun 27 09:37:25 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f6dd53fa qpkg: fix VDB access method, warn when atoms didn't match anything Signed-off-by: Fabian Groffen gentoo.org> TODO.md | 1 + qpkg.c | 53 +++++++++++++++++++++++++++++++++++------------------ 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/TODO.md b/TODO.md index 86a9e84..8188fe1 100644 --- a/TODO.md +++ b/TODO.md @@ -64,6 +64,7 @@ and qpkg is doing parts of qtbz2's compose - share install\_mask code from qmerge to handle negatives from pkg\_install\_mask too +- make world agument really read world file, add @all? # qgrep - make it use standard xarray instead of its own buf\_list diff --git a/qpkg.c b/qpkg.c index 5e55406..41ac0f5 100644 --- a/qpkg.c +++ b/qpkg.c @@ -395,7 +395,10 @@ int qpkg_main(int argc, char **argv) * to tar when we create the binary package. */ xchdir(portroot); - /* first process any arguments which point to /var/db/pkg */ + /* first process any arguments which point to /var/db/pkg, an + * undocumented method to allow easily tab-completing into vdb as + * arguments, the trailing / needs to be present for this (as tab + * completion would do) */ pkgs_made = 0; s = strlen(portvdb); for (i = optind; i < argc; ++i) { @@ -404,22 +407,31 @@ int qpkg_main(int argc, char **argv) argv[i] = NULL; continue; } - if (argv[i][asize-1] == '/') - argv[i][asize-1] = '\0'; - if (!strncmp(portvdb, argv[i], s)) - memmove(argv[i], argv[i]+s+1, asize-s); - else if (argv[i][0] == '/' && !strncmp(portvdb, argv[i]+1, s)) - memmove(argv[i], argv[i]+s+2, asize-s-1); - else - continue; - - atom = atom_explode(argv[i]); - if (atom) { - if (!qpkg_make(atom)) ++pkgs_made; - atom_implode(atom); - } else - warn("could not explode '%s'", argv[i]); - argv[i] = NULL; + if (asize > s && argv[i][0] == '/' && argv[i][asize - 1] == '/') { + char *path = argv[i]; + + /* chop off trailing / */ + argv[i][asize - 1] = '\0'; + + /* eliminate duplicate leading /, we know it starts with / */ + while (path[1] == '/') + path++; + + if (strncmp(portvdb, path, s) == 0) { + path += s + 1 /* also eat / after portvdb */; + + atom = atom_explode(path); + if (atom) { + if (!qpkg_make(atom)) + pkgs_made++; + atom_implode(atom); + } else + warn("could not explode '%s'", path); + argv[i] = NULL; + } else { + argv[i][asize - 1] = '/'; /* restore, it may be a cat match */ + } + } } /* now try to run through vdb and locate matches for user inputs */ @@ -431,14 +443,19 @@ int qpkg_main(int argc, char **argv) if (argv[i] == NULL) continue; if (strcmp(argv[i], "world") == 0) { - /* we're basically done, this means all */ + /* this is a crude hack, we include all packages for this, + * which isn't exactly @world, but all its deps too */ tree_foreach_pkg_fast(ctx, qpkg_cb, &pkgs_made, NULL); + break; /* no point in continuing since we did everything */ } atom = atom_explode(argv[i]); if (atom == NULL) continue; + s = pkgs_made; tree_foreach_pkg_fast(ctx, qpkg_cb, &pkgs_made, atom); + if (s == pkgs_made) + warn("no match for '%s'", argv[i]); atom_implode(atom); } tree_close(ctx);