public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Fabian Groffen" <grobian@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/, /
Date: Sat, 13 Jul 2019 10:04:59 +0000 (UTC)	[thread overview]
Message-ID: <1563012227.264be8b792d2ddd131d1a52cc1773c60c52a1a51.grobian@gentoo> (raw)

commit:     264be8b792d2ddd131d1a52cc1773c60c52a1a51
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jul 13 10:03:47 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jul 13 10:03:47 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=264be8b7

libq/tree: rename tree_get_vdb_atoms to tree_get_atoms

in qmerge take advantage of tree_get_atoms to fold the packages for all
trees (overlays) next to vdb contents into one using the same code that
builds the vdb list

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 libq/tree.c | 20 ++++++++------------
 libq/tree.h |  2 +-
 qmerge.c    | 12 +++++++++---
 qpkg.c      | 28 +++++++++-------------------
 4 files changed, 27 insertions(+), 35 deletions(-)

diff --git a/libq/tree.c b/libq/tree.c
index f4314d0..99e864b 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -1042,14 +1042,14 @@ tree_get_atom(tree_pkg_ctx *pkg_ctx, bool complete)
 	return pkg_ctx->atom;
 }
 
-struct get_vdb_atoms_state {
+struct get_atoms_state {
 	set *cpf;
 	bool fullcpv;
 };
 
-static int tree_get_vdb_atoms_cb(tree_pkg_ctx *pkg_ctx, void *priv)
+static int tree_get_atoms_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 {
-	struct get_vdb_atoms_state *state = (struct get_vdb_atoms_state *)priv;
+	struct get_atoms_state *state = (struct get_atoms_state *)priv;
 	depend_atom *atom = tree_get_atom(pkg_ctx, false);
 
 	if (state->fullcpv) {
@@ -1063,18 +1063,14 @@ static int tree_get_vdb_atoms_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 }
 
 set *
-tree_get_vdb_atoms(const char *sroot, const char *svdb, int fullcpv)
+tree_get_atoms(tree_ctx *ctx, bool fullcpv, set *satoms)
 {
-	tree_ctx *ctx;
-	struct get_vdb_atoms_state state = {
-		.cpf = NULL,
-		.fullcpv = fullcpv != 0
+	struct get_atoms_state state = {
+		.cpf = satoms,
+		.fullcpv = fullcpv
 	};
 
-	ctx = tree_open_vdb(sroot, svdb);
-	if (!ctx)
-		return NULL;
-	tree_foreach_pkg_fast(ctx, tree_get_vdb_atoms_cb, &state, NULL);
+	tree_foreach_pkg_fast(ctx, tree_get_atoms_cb, &state, NULL);
 	tree_close(ctx);
 
 	return state.cpf;

diff --git a/libq/tree.h b/libq/tree.h
index 36554be..c2a30f1 100644
--- a/libq/tree.h
+++ b/libq/tree.h
@@ -135,7 +135,7 @@ int tree_foreach_pkg(tree_ctx *ctx,
 #define tree_foreach_pkg_sorted(ctx, cb, priv) \
 	tree_foreach_pkg(ctx, cb, priv, NULL, true, NULL, NULL);
 struct dirent *tree_get_next_dir(DIR *dir);
-set *tree_get_vdb_atoms(const char *sroot, const char *svdb, int fullcpv);
+set *tree_get_atoms(tree_ctx *ctx, bool fullcpv, set *satoms);
 depend_atom *tree_get_atom(tree_pkg_ctx *pkg_ctx, bool complete);
 
 #endif

diff --git a/qmerge.c b/qmerge.c
index cb4342c..a3686ac 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -2350,9 +2350,15 @@ qmerge_add_set(char *buf, set *q)
 	if (strcmp(buf, "world") == 0)
 		return qmerge_add_set_file(CONFIG_EPREFIX, "/var/lib/portage",
 				"world", q);
-	else if (strcmp(buf, "all") == 0)
-		return tree_get_vdb_atoms(portroot, portvdb, 0);
-	else if (strcmp(buf, "system") == 0)
+	else if (strcmp(buf, "all") == 0) {
+		tree_ctx *ctx = tree_open_vdb(portroot, portvdb);
+		set *ret = NULL;
+		if (ctx != NULL) {
+			ret = tree_get_atoms(ctx, false, NULL);
+			tree_close(ctx);
+		}
+		return ret;
+	} else if (strcmp(buf, "system") == 0)
 		return q_profile_walk("packages", qmerge_add_set_system, q);
 	else if (buf[0] == '@')
 		/* TODO: use configroot */

diff --git a/qpkg.c b/qpkg.c
index 4063af2..2c5a6c3 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -123,21 +123,6 @@ qpkg_clean_dir(char *dirp, set *vdb)
 	return num_all_bytes;
 }
 
-static int
-qpkg_cb(tree_pkg_ctx *pkg_ctx, void *priv)
-{
-	set *vdb = (set *)priv;
-	char buf[_Q_PATH_MAX];
-
-	if (tree_get_atom(pkg_ctx, false) == NULL)
-		return 0;
-
-	snprintf(buf, sizeof(buf), "%s/%s", pkg_ctx->cat_ctx->name, pkg_ctx->name);
-	vdb = add_set(buf, vdb);
-
-	return 1;
-}
-
 /* figure out what dirs we want to process for cleaning and display results. */
 static int
 qpkg_clean(char *dirp)
@@ -146,23 +131,28 @@ qpkg_clean(char *dirp)
 	size_t disp_units = 0;
 	uint64_t num_all_bytes;
 	struct dirent **dnames;
-	set *vdb;
+	set *vdb = NULL;
+	tree_ctx *t;
 
 	if (chdir(dirp) != 0)
 		return 1;
 	if ((count = scandir(".", &dnames, filter_hidden, alphasort)) < 0)
 		return 1;
 
-	vdb = tree_get_vdb_atoms(portroot, portvdb, 1);
+	t = tree_open_vdb(portroot, portvdb);
+	if (t != NULL) {
+		vdb = tree_get_atoms(t, true, vdb);
+		tree_close(t);
+	}
 
 	if (eclean) {
 		size_t n;
 		const char *overlay;
 
 		array_for_each(overlays, n, overlay) {
-			tree_ctx *t = tree_open(portroot, overlay);
+			t = tree_open(portroot, overlay);
 			if (t != NULL) {
-				tree_foreach_pkg_fast(t, qpkg_cb, vdb, NULL);
+				vdb = tree_get_atoms(t, true, vdb);
 				tree_close(t);
 			}
 		}


             reply	other threads:[~2019-07-13 10:05 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-13 10:04 Fabian Groffen [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-06-27 19:19 [gentoo-commits] proj/portage-utils:master commit in: libq/, / Fabian Groffen
2024-03-29 10:57 Fabian Groffen
2024-01-02  7:57 Fabian Groffen
2023-02-07  8:25 Fabian Groffen
2023-02-07  8:10 Fabian Groffen
2021-08-16 13:23 Fabian Groffen
2020-02-21  8:18 Fabian Groffen
2020-01-05 13:28 Fabian Groffen
2020-01-02 11:19 Fabian Groffen
2020-01-01 19:52 Fabian Groffen
2019-12-31  9:05 Fabian Groffen
2019-12-30 17:24 Fabian Groffen
2019-12-29 13:26 Fabian Groffen
2019-12-27 16:57 Fabian Groffen
2019-06-19 10:44 Fabian Groffen
2019-06-05  9:15 Fabian Groffen
2019-05-09 20:19 Fabian Groffen
2019-05-05 18:13 Fabian Groffen
2019-04-28 15:20 Fabian Groffen
2019-03-27 20:18 Fabian Groffen
2019-03-27 10:55 Fabian Groffen
2019-03-22  9:57 Fabian Groffen
2019-03-19 20:32 Fabian Groffen
2019-03-19 20:32 Fabian Groffen
2019-03-09 18:58 Fabian Groffen
2018-03-23 11:56 Fabian Groffen
2016-12-29  2:25 Mike Frysinger
2016-11-26 23:17 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-02-24  1:26 Mike Frysinger

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1563012227.264be8b792d2ddd131d1a52cc1773c60c52a1a51.grobian@gentoo \
    --to=grobian@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox