commit:     61f73a736be7123937a4ce18947aee480cb8cdcb
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Feb  6 19:02:52 2026 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Feb  6 19:02:52 2026 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=61f73a73

libq/tree: remove deprecated APIs

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

 libq/tree.c |  2 +-
 libq/tree.h | 22 +++++-----------------
 q.c         |  6 +++---
 qatom.c     |  2 +-
 qcheck.c    |  8 ++++----
 qdepends.c  | 29 +++++++++++++++--------------
 qfile.c     | 12 ++++++------
 qgrep.c     |  6 +++---
 qkeyword.c  | 14 +++++++-------
 qlist.c     | 16 ++++++++--------
 qmerge.c    | 10 +++++-----
 qpkg.c      | 16 ++++++++--------
 qsearch.c   | 10 +++++-----
 qsize.c     | 17 +++++------------
 quse.c      | 19 ++++++++++---------
 qwhich.c    |  6 +++---
 16 files changed, 89 insertions(+), 106 deletions(-)

diff --git a/libq/tree.c b/libq/tree.c
index bb52fcfb..985f49e2 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -581,7 +581,7 @@ tree_ctx *tree_merge
   tree_ctx *tree2
 )
 {
-  tree_ctx *ret;
+  tree_ctx *ret = NULL;
 
   if (tree1 == NULL ||
       tree2 == NULL)

diff --git a/libq/tree.h b/libq/tree.h
index 838a8756..be45f121 100644
--- a/libq/tree.h
+++ b/libq/tree.h
@@ -86,6 +86,11 @@ void                tree_close(tree_ctx *tree);
 int                 tree_foreach_pkg(tree_ctx *tree, tree_pkg_cb callback,
                                      void *priv, bool sorted,
                                      const atom_ctx *query);
+#define tree_foreach_pkg_fast(ctx, cb, priv, query) \
+       tree_foreach_pkg(ctx, cb, priv, false, query)
+#define tree_foreach_pkg_sorted(ctx, cb, priv, query) \
+       tree_foreach_pkg(ctx, cb, priv, true, query)
+
 array              *tree_match_atom(tree_ctx *tree, const atom_ctx *query,
                                     int flags);
 #define TREE_MATCH_LATEST     (1<<3)
@@ -115,23 +120,6 @@ char               *tree_pkg_get_path(tree_pkg_ctx *pkg);
 int                 tree_pkg_get_portroot_fd(tree_pkg_ctx *pkg);
 enum tree_open_type tree_pkg_get_treetype(tree_pkg_ctx *pkg);
 
-
-/* backwards compat crap */
-#define tree_open(R,P)         tree_new(R,P,TREETYPE_EBUILD,false)
-#define tree_open_vdb(R,P)     tree_new(R,P,TREETYPE_VDB,false)
-#define tree_open_ebuild(R,P)  tree_new(R,P,TREETYPE_EBUILD,false)
-#define tree_open_binpkg(R,P)  tree_new(R,P,TREETYPE_BINPKG,false)
-#define tree_open_gtree(R,P)   tree_new(R,P,TREETYPE_GTREE,false)
-#define tree_get_atom(P,C)     tree_pkg_atom(P,C)
-#define tree_pkg_meta_get(P,X) tree_pkg_meta(P, Q_##X)
-
-#define tree_foreach_pkg_fast(ctx, cb, priv, query) \
-       tree_foreach_pkg(ctx, cb, priv, false, query)
-#define tree_foreach_pkg_sorted(ctx, cb, priv, query) \
-       tree_foreach_pkg(ctx, cb, priv, true, query)
-#define tree_foreach_pkg_cached(ctx, cb, priv, query) \
-       tree_foreach_pkg(ctx, cb, priv, true, query)
-
 #endif
 
 /* vim: set ts=2 sw=2 expandtab cino+=\:0 foldmethod=marker: */

diff --git a/q.c b/q.c
index a694f0b6..086824bb 100644
--- a/q.c
+++ b/q.c
@@ -183,7 +183,7 @@ static int q_build_gtree_cache_pkg(tree_pkg_ctx *pkg, void 
*priv)
        struct q_cache_ctx   *ctx   = priv;
        struct archive       *a     = ctx->archive;
        struct archive_entry *entry;
-       depend_atom          *atom  = tree_get_atom(pkg, false);
+       depend_atom          *atom  = tree_pkg_atom(pkg, false);
        char                  buf[_Q_PATH_MAX];
        char                 *qc;
        size_t                qclen;
@@ -250,7 +250,7 @@ static int q_build_gtree_ebuilds_pkg(tree_pkg_ctx *pkg, 
void *priv)
        struct archive       *a     = ctx->archive;
        struct archive_entry *entry;
        struct stat           st;
-       depend_atom          *atom  = tree_get_atom(pkg, false);
+       depend_atom          *atom  = tree_pkg_atom(pkg, false);
        char                  buf[_Q_PATH_MAX];
        char                 *p;
        size_t                siz;
@@ -818,7 +818,7 @@ int q_main(int argc, char **argv)
                         * tree_open doesn't pick it up */
                        unlink(buf);
 
-                       t = tree_open(portroot, overlay);
+                       t = tree_new(portroot, overlay, TREETYPE_EBUILD, false);
                        if (t == NULL) {
                                warn("could not open overlay at %s", overlay);
                                continue;

diff --git a/qatom.c b/qatom.c
index 0de6b10f..c7361499 100644
--- a/qatom.c
+++ b/qatom.c
@@ -68,7 +68,7 @@ int qatom_main(int argc, char **argv)
                err("compare needs even number of arguments");
 
        if (action == _LOOKUP) {
-               tree = tree_open(portroot, main_overlay);
+               tree = tree_new(portroot, main_overlay, TREETYPE_EBUILD, false);
                if (tree == NULL)
                        err("failed to open tree");
        }

diff --git a/qcheck.c b/qcheck.c
index be077a51..f3af6554 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -94,11 +94,11 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
        int                      portroot_fd;
 
        /* get CONTENTS from meta */
-       line = tree_pkg_meta_get(pkg_ctx, CONTENTS);
+       line = tree_pkg_meta(pkg_ctx, Q_CONTENTS);
        if (line == NULL)
                return EXIT_FAILURE;
 
-       atom        = tree_get_atom(pkg_ctx, false);
+       atom        = tree_pkg_atom(pkg_ctx, false);
        portroot_fd = tree_pkg_get_portroot_fd(pkg_ctx);
 
        qcprintf("%sing %s ...\n",
@@ -128,7 +128,7 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                makeargv(config_protect, &cp_argc, &cp_argv);
                makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
 
-               eprefix = tree_pkg_meta_get(pkg_ctx, EPREFIX);
+               eprefix = tree_pkg_meta(pkg_ctx, Q_EPREFIX);
                if (eprefix != NULL)
                        eprefix_len = strlen(eprefix);
        }
@@ -481,7 +481,7 @@ int qcheck_main(int argc, char **argv)
                        array_append(state.atoms, atom);
        }
 
-       vdb = tree_open_vdb(portroot, portvdb);
+       vdb = tree_new(portroot, portvdb, TREETYPE_VDB, false);
        ret = -1;
        if (vdb != NULL) {
                if (array_cnt(state.atoms) != 0) {

diff --git a/qdepends.c b/qdepends.c
index 3d7dad0a..d4558811 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -138,7 +138,7 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
         * *DEPEND alters the search somewhat and affects results printing.
         */
 
-       datom = tree_get_atom(pkg_ctx, false);
+       datom = tree_pkg_atom(pkg_ctx, false);
        if (datom == NULL)
                return ret;
 
@@ -148,7 +148,7 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                        if (atom->blocker != ATOM_BL_NONE ||
                                        atom->SLOT != NULL ||
                                        atom->REPO != NULL)
-                               datom = tree_get_atom(pkg_ctx, true);
+                               datom = tree_pkg_atom(pkg_ctx, true);
                        if (atom_compare(datom, atom) == EQUAL) {
                                atom = NULL;
                                break;
@@ -161,18 +161,18 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
                ret = 1;
 
-               datom = tree_get_atom(pkg_ctx, true);
+               datom = tree_pkg_atom(pkg_ctx, true);
                printf("%s:", atom_format(state->format, datom));
        }
 
        clear_set(state->udeps);
 
 #define get_depstr(X,Y) \
-       X == QMODE_DEPEND  ? tree_pkg_meta_get(Y, DEPEND)  : \
-       X == QMODE_RDEPEND ? tree_pkg_meta_get(Y, RDEPEND) : \
-       X == QMODE_PDEPEND ? tree_pkg_meta_get(Y, PDEPEND) : \
-       X == QMODE_BDEPEND ? tree_pkg_meta_get(Y, BDEPEND) : \
-                                tree_pkg_meta_get(Y, IDEPEND) ;
+       X == QMODE_DEPEND  ? tree_pkg_meta(Y, Q_DEPEND)  : \
+       X == QMODE_RDEPEND ? tree_pkg_meta(Y, Q_RDEPEND) : \
+       X == QMODE_PDEPEND ? tree_pkg_meta(Y, Q_PDEPEND) : \
+       X == QMODE_BDEPEND ? tree_pkg_meta(Y, Q_BDEPEND) : \
+                                tree_pkg_meta(Y, Q_IDEPEND) ;
 
        dfile = depend_files;
        for (i = QMODE_DEP_FIRST; i <= QMODE_DEP_LAST; i <<= 1, dfile++) {
@@ -224,7 +224,7 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                                        ret = 1;
 
                                        if (!firstmatch) {
-                                               datom = tree_get_atom(pkg_ctx, 
true);
+                                               datom = tree_pkg_atom(pkg_ctx, 
true);
                                                printf("%s:", 
atom_format(state->format, datom));
                                        }
                                        firstmatch = true;
@@ -253,7 +253,7 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                                                ret = 1;
 
                                                if (!firstmatch) {
-                                                       datom = 
tree_get_atom(pkg_ctx, true);
+                                                       datom = 
tree_pkg_atom(pkg_ctx, true);
                                                        printf("%s%s", 
atom_format(state->format, datom),
                                                                        quiet < 
2 ? ":" : "");
                                                }
@@ -388,7 +388,7 @@ int qdepends_main(int argc, char **argv)
        if (state.qmode & QMODE_INSTALLED ||
                verbose)
        {
-               state.vdb = tree_open_vdb(portroot, portvdb);
+               state.vdb = tree_new(portroot, portvdb, TREETYPE_VDB, false);
                if (state.vdb == NULL)
                {
                        free_set(state.udeps);
@@ -404,11 +404,12 @@ int qdepends_main(int argc, char **argv)
                tree_ctx *t;
 
                array_for_each(overlays, n, overlay) {
-                       t = tree_open(portroot, overlay);
+                       t = tree_new(portroot, overlay, TREETYPE_EBUILD, false);
                        if (t != NULL) {
                                state.rtree = NULL;
                                if (state.resolve)
-                                       state.rtree = tree_open(portroot, 
overlay);
+                                       state.rtree = tree_new(portroot, 
overlay,
+                                                                               
   TREETYPE_EBUILD, false);
                                if (!(state.qmode & QMODE_REVERSE) &&
                                        array_cnt(state.atoms) > 0)
                                {
@@ -427,7 +428,7 @@ int qdepends_main(int argc, char **argv)
                }
        } else {  /* INSTALLED */
                if (state.resolve)
-                       state.rtree = tree_open_vdb(portroot, portvdb);
+                       state.rtree = tree_new(portroot, portvdb, TREETYPE_VDB, 
false);
                if (!(state.qmode & QMODE_REVERSE) && array_cnt(state.atoms) > 
0) {
                        array_for_each(state.atoms, i, atom) {
                                ret |= tree_foreach_pkg_fast(state.vdb,

diff --git a/qfile.c b/qfile.c
index c512d948..03634f58 100644
--- a/qfile.c
+++ b/qfile.c
@@ -193,7 +193,7 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                if (state->exclude_atom->CATEGORY &&
                    strcmp(state->exclude_atom->CATEGORY, catname))
                        goto dont_skip_pkg;
-               atom = tree_get_atom(pkg_ctx,
+               atom = tree_pkg_atom(pkg_ctx,
                                state->exclude_atom->SLOT != NULL ||
                                state->exclude_atom->REPO != NULL);
                if (atom_compare(atom, state->exclude_atom) != EQUAL)
@@ -202,13 +202,13 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                if (state->exclude_slot == NULL)
                        goto qlist_done;
                /* retrieve atom, this time with SLOT */
-               atom = tree_get_atom(pkg_ctx, true);
+               atom = tree_pkg_atom(pkg_ctx, true);
                if (strcmp(state->exclude_slot, atom->SLOT) == 0)
                        goto qlist_done; /* "(CAT/)?(PN|PF):SLOT" matches */
        }
  dont_skip_pkg: /* End of the package exclusion tests. */
 
-       line = tree_pkg_meta_get(pkg_ctx, CONTENTS);
+       line = tree_pkg_meta(pkg_ctx, Q_CONTENTS);
        if (line == NULL)
                goto qlist_done;
 
@@ -249,7 +249,7 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                                                 state->real_root, e->name);
                                if (realpath(fullpath, rpath) == NULL) {
                                        if (verbose) {
-                                               atom = tree_get_atom(pkg_ctx, 
false);
+                                               atom = tree_pkg_atom(pkg_ctx, 
false);
                                                warnp("Could not read real path 
of \"%s\" (from %s)",
                                                                fullpath,
                                                                
atom_format("%[CATEGORY]%[PF]", atom));
@@ -312,7 +312,7 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                                continue;
 
                        if (non_orphans == NULL) {
-                               atom = tree_get_atom(pkg_ctx, 
state->need_full_atom);
+                               atom = tree_pkg_atom(pkg_ctx, 
state->need_full_atom);
 
                                printf("%s", atom_format(state->format, atom));
                                if (quiet)
@@ -595,7 +595,7 @@ int qfile_main(int argc, char **argv)
 
        /* Now do the actual `qfile` checking by looking at CONTENTS of all 
pkgs */
        if (nb_of_queries > 0) {
-               tree_ctx *vdb = tree_open_vdb(portroot, portvdb);
+               tree_ctx *vdb = tree_new(portroot, portvdb, TREETYPE_VDB, 
false);
                if (vdb != NULL) {
                        found += tree_foreach_pkg_sorted(vdb, qfile_cb, &state, 
NULL);
                        tree_close(vdb);

diff --git a/qgrep.c b/qgrep.c
index 67371a2a..6a11bdb5 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -383,7 +383,7 @@ qgrep_cb(tree_pkg_ctx *pkg_ctx, void *priv)
        atom_ctx              *patom = NULL;
        char                  *path;
 
-       patom = tree_get_atom(pkg_ctx, true);
+       patom = tree_pkg_atom(pkg_ctx, true);
        if (patom == NULL)
                return EXIT_FAILURE;
 
@@ -646,9 +646,9 @@ int qgrep_main(int argc, char **argv)
                } else { /* do_ebuild || do_installed */
                        tree_ctx *t;
                        if (do_installed) {
-                               t = tree_open_vdb(portroot, portvdb);
+                               t = tree_new(portroot, portvdb, TREETYPE_VDB, 
false);
                        } else {
-                               t = tree_open(portroot, overlay);
+                               t = tree_new(portroot, overlay, 
TREETYPE_EBUILD, false);
                        }
                        if (t != NULL) {
                                status = tree_foreach_pkg_fast(t, qgrep_cb, 
&args, NULL);

diff --git a/qkeyword.c b/qkeyword.c
index 63d2d6e6..f6cbbe18 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -243,7 +243,7 @@ qkeyword_kw(tree_pkg_ctx *pkg_ctx, void *priv, int what)
                size_t n;
                depend_atom *mask;
 
-               atom = tree_get_atom(pkg_ctx, false);
+               atom = tree_pkg_atom(pkg_ctx, false);
                masks = get_set(atom_format("%[CAT]%[PN]", atom), pmasks);
                if (masks != NULL) {
                        array_for_each(masks, n, mask) {
@@ -251,14 +251,14 @@ qkeyword_kw(tree_pkg_ctx *pkg_ctx, void *priv, int what)
                                        if (verbose) {
                                                printf("masked by %s: ", 
atom_to_string(mask));
                                                printf("%s\n", 
atom_format(data->fmt,
-                                                                       
tree_get_atom(pkg_ctx, true)));
+                                                                       
tree_pkg_atom(pkg_ctx, true)));
                                        }
                                        return EXIT_FAILURE;
                                }
                        }
                }
 
-               printf("%s\n", atom_format(data->fmt, tree_get_atom(pkg_ctx, 
true)));
+               printf("%s\n", atom_format(data->fmt, tree_pkg_atom(pkg_ctx, 
true)));
                return EXIT_SUCCESS;
        }
 
@@ -537,7 +537,7 @@ qkeyword_stats(tree_pkg_ctx *pkg_ctx, void *priv)
                numcat++;
        lastcat = tree_pkg_get_cat_name(pkg_ctx);
 
-       atom = tree_get_atom(pkg_ctx, false);
+       atom = tree_pkg_atom(pkg_ctx, false);
        if (atom && strcmp(lastpkg, atom->PN) != 0) {
                for (a = 0; a < archlist_count; a++) {
                        switch (current_package_keywords[a]) {
@@ -656,7 +656,7 @@ qkeyword_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
        tree_metadata_xml *metadata;
        int ret;
 
-       patom = tree_get_atom(pkg_ctx, false);
+       patom = tree_pkg_atom(pkg_ctx, false);
        if (patom == NULL)
                return EXIT_FAILURE;
 
@@ -685,7 +685,7 @@ qkeyword_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
        keywords = data->keywordsbuf;
 
-       if (read_keywords(tree_pkg_meta_get(pkg_ctx, KEYWORDS), keywords) < 0) {
+       if (read_keywords(tree_pkg_meta(pkg_ctx, Q_KEYWORDS), keywords) < 0) {
                if (verbose)
                        warn("Failed to read keywords for %s%s/%s%s%s",
                                BOLD, patom->CATEGORY, BLUE, patom->PF, NORM);
@@ -808,7 +808,7 @@ qkeyword_traverse(tree_pkg_cb func, void *priv)
        data->runfunc = func;
        ret = 0;
        array_for_each(overlays, n, overlay) {
-               tree_ctx *t = tree_open(portroot, overlay);
+               tree_ctx *t = tree_new(portroot, overlay, TREETYPE_EBUILD, 
false);
                if (t != NULL) {
                        ret |= tree_foreach_pkg_sorted(t,
                                        qkeyword_results_cb, priv, data->qatom);

diff --git a/qlist.c b/qlist.c
index 2fa3dd53..858d3695 100644
--- a/qlist.c
+++ b/qlist.c
@@ -115,10 +115,10 @@ umapstr(tree_pkg_ctx *pkg_ctx)
        int u;
        int d;
 
-       use = tree_pkg_meta_get(pkg_ctx, USE);
+       use = tree_pkg_meta(pkg_ctx, Q_USE);
        if (use == NULL || *use == '\0')
                return;
-       iuse = tree_pkg_meta_get(pkg_ctx, IUSE);
+       iuse = tree_pkg_meta(pkg_ctx, Q_IUSE);
        if (iuse == NULL || *iuse == '\0')
                return;
 
@@ -210,7 +210,7 @@ qlist_match(
                pf_len = strlen(name);
        }
 
-       atom = tree_get_atom(pkg_ctx, uslot[0] != '\0' || urepo != NULL);
+       atom = tree_pkg_atom(pkg_ctx, uslot[0] != '\0' || urepo != NULL);
 
        /* maybe they're using a version range */
        switch (name[0]) {
@@ -365,7 +365,7 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                        return 0;
        }
 
-       atom = tree_get_atom(pkg_ctx, state->need_full_atom);
+       atom = tree_pkg_atom(pkg_ctx, state->need_full_atom);
        if (state->just_pkgname) {
                printf("%s", atom_format(state->fmt, atom));
                if (state->show_umap)
@@ -379,7 +379,7 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                printf("%s %sCONTENTS%s:\n",
                                atom_format(state->fmt, atom), DKBLUE, NORM);
 
-       if ((contents = tree_pkg_meta_get(pkg_ctx, CONTENTS)) == NULL)
+       if ((contents = tree_pkg_meta(pkg_ctx, Q_CONTENTS)) == NULL)
                return 1;
 
        while ((line = strtok_r(contents, "\n", &savep)) != NULL) {
@@ -522,7 +522,7 @@ int qlist_main(int argc, char **argv)
                const char *overlay;
 
                array_for_each(overlays, n, overlay) {
-                       vdb = tree_open(portroot, overlay);
+                       vdb = tree_new(portroot, overlay, TREETYPE_EBUILD, 
false);
                        if (vdb != NULL) {
                                ret |= tree_foreach_pkg_sorted(vdb, qlist_cb, 
&state, NULL);
                                tree_close(vdb);
@@ -530,9 +530,9 @@ int qlist_main(int argc, char **argv)
                }
        } else {
                if (state.do_binpkgs)
-                       vdb = tree_open_binpkg(portroot, pkgdir);
+                       vdb = tree_new(portroot, pkgdir, TREETYPE_BINPKG, 
false);
                else
-                       vdb = tree_open_vdb(portroot, portvdb);
+                       vdb = tree_new(portroot, portvdb, TREETYPE_VDB, false);
                if (vdb != NULL) {
                        ret = tree_foreach_pkg_sorted(vdb, qlist_cb, &state, 
NULL);
                        tree_close(vdb);

diff --git a/qmerge.c b/qmerge.c
index 2d35e0e0..83467326 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -326,7 +326,7 @@ best_version(const depend_atom *atom, int mode)
        if (mode & BV_VDB) {
                array *t;
                if (vdb == NULL) {
-                       vdb = tree_open_vdb(portroot, portvdb);
+                       vdb = tree_new(portroot, portvdb, TREETYPE_VDB, true);
                        if (vdb == NULL)
                                return NULL;
                        _qmerge_vdb_tree = vdb;
@@ -342,7 +342,7 @@ best_version(const depend_atom *atom, int mode)
        if (mode & BV_BINPKG) {
                array *t;
                if (binpkg == NULL) {
-                       binpkg = tree_open_binpkg(portroot, pkgdir);
+                       binpkg = tree_new(portroot, pkgdir, TREETYPE_BINPKG, 
true);
                        if (binpkg == NULL) {
                                if (vdb != NULL)
                                        tree_close(vdb);
@@ -1770,7 +1770,7 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, depend_atom *rpkg, set 
*keep,
                }
        }
 
-       eprefix = tree_pkg_meta_get(pkg_ctx, EPREFIX);
+       eprefix = tree_pkg_meta(pkg_ctx, Q_EPREFIX);
        if (eprefix == NULL)
                eprefix_len = 0;
        else
@@ -2151,7 +2151,7 @@ qmerge_unmerge_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 static int
 unmerge_packages(set *todo)
 {
-       tree_ctx *vdb = tree_open_vdb(portroot, portvdb);
+       tree_ctx *vdb = tree_new(portroot, portvdb, TREETYPE_VDB, true);
        int ret = 1;
        if (vdb != NULL) {
                ret = tree_foreach_pkg_fast(vdb, qmerge_unmerge_cb, todo, NULL);
@@ -2227,7 +2227,7 @@ qmerge_add_set(char *buf, set *q)
                return qmerge_add_set_file(CONFIG_EPREFIX, "/var/lib/portage",
                                                                   "world", q);
        } else if (strcmp(buf, "all") == 0) {
-               tree_ctx     *ctx  = tree_open_vdb(portroot, portvdb);
+               tree_ctx     *ctx  = tree_new(portroot, portvdb, TREETYPE_VDB, 
true);
                array        *pkgs = tree_match_atom(ctx, NULL, 
TREE_MATCH_DEFAULT);
                tree_pkg_ctx *w;
                size_t        n;

diff --git a/qpkg.c b/qpkg.c
index 3f483970..5d453ac1 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -94,7 +94,7 @@ qpkg_clean(qpkg_cb_args *args)
                const char *overlay;
 
                array_for_each(overlays, n, overlay) {
-                       t = tree_open(portroot, overlay);
+                       t = tree_new(portroot, overlay, TREETYPE_EBUILD, true);
                        if (t != NULL)
                                array_append(trees, t);
                }
@@ -284,7 +284,7 @@ qgpkg_make(tree_pkg_ctx *pkg, qpkg_cb_args *args)
        int fd;
        int mfd;
        mode_t mask;
-       depend_atom *atom = tree_get_atom(pkg, false);
+       depend_atom *atom = tree_pkg_atom(pkg, false);
        int portroot_fd = tree_pkg_get_portroot_fd(pkg);
        ssize_t len;
 
@@ -296,7 +296,7 @@ qgpkg_make(tree_pkg_ctx *pkg, qpkg_cb_args *args)
                return 0;
        }
 
-       line = tree_pkg_meta_get(pkg, CONTENTS);
+       line = tree_pkg_meta(pkg, Q_CONTENTS);
        if (line == NULL)
                return -1;
 
@@ -687,7 +687,7 @@ qpkg_make(tree_pkg_ctx *pkg, qpkg_cb_args *args)
        char *xpak_argv[2];
        struct stat st;
        mode_t mask;
-       depend_atom *atom = tree_get_atom(pkg, false);
+       depend_atom *atom = tree_pkg_atom(pkg, false);
 
        (void)args;  /* not used yet */
 
@@ -697,7 +697,7 @@ qpkg_make(tree_pkg_ctx *pkg, qpkg_cb_args *args)
                return 0;
        }
 
-       line = tree_pkg_meta_get(pkg, CONTENTS);
+       line = tree_pkg_meta(pkg, Q_CONTENTS);
        if (line == NULL)
                return -1;
 
@@ -827,7 +827,7 @@ qpkg_cb(tree_pkg_ctx *pkg, void *priv)
 
        /* check atoms to compute a build-id */
        if (contains_set("binpkg-multi-instance", features)) {
-               atom_ctx *atom = tree_get_atom(pkg, false);
+               atom_ctx *atom = tree_pkg_atom(pkg, false);
                array    *m    = tree_match_atom(args->binpkg, atom, 
TREE_MATCH_FIRST);
                if (array_cnt(m) > 0) {
                        tree_pkg_ctx *p = array_get(m, 0);
@@ -905,11 +905,11 @@ int qpkg_main(int argc, char **argv)
                                errp("could not chmod(0750) packages directory 
'%s'", bindir);
                close(fd);
        }
-       cb_args.binpkg = tree_open_binpkg(portroot, cb_args.bindir);
+       cb_args.binpkg = tree_new(portroot, cb_args.bindir, TREETYPE_BINPKG, 
false);
        if (cb_args.binpkg == NULL)
                return EXIT_FAILURE;
 
-       cb_args.vdb = tree_open_vdb(portroot, portvdb);
+       cb_args.vdb = tree_new(portroot, portvdb, TREETYPE_VDB, false);
        if (!cb_args.vdb)
        {
                tree_close(cb_args.binpkg);

diff --git a/qsearch.c b/qsearch.c
index 5051d8cb..d80d06b7 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -69,7 +69,7 @@ qsearch_cb(tree_pkg_ctx *pkg_ctx, void *priv)
        char *desc;
        bool match;
 
-       atom = tree_get_atom(pkg_ctx, 0);
+       atom = tree_pkg_atom(pkg_ctx, 0);
        if (atom == NULL)
                return 0;
 
@@ -87,9 +87,9 @@ qsearch_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                        (!match && state->search_desc))
        {
                if (state->show_homepage)
-                       desc = tree_pkg_meta_get(pkg_ctx, HOMEPAGE);
+                       desc = tree_pkg_meta(pkg_ctx, Q_HOMEPAGE);
                else if (state->show_desc)
-                       desc = tree_pkg_meta_get(pkg_ctx, DESCRIPTION);
+                       desc = tree_pkg_meta(pkg_ctx, Q_DESCRIPTION);
        }
 
        if (!match && state->search_desc && desc != NULL &&
@@ -97,7 +97,7 @@ qsearch_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                match = true;
 
        if (match) {
-               atom = tree_get_atom(pkg_ctx, state->need_full_atom);
+               atom = tree_pkg_atom(pkg_ctx, state->need_full_atom);
                printf("%s%s%s\n",
                                atom_format(state->fmt, atom),
                                (state->show_name ? "" : ": "),
@@ -171,7 +171,7 @@ int qsearch_main(int argc, char **argv)
 
        /* use sorted order here so the duplicate reduction works reliably */
        array_for_each(overlays, n, overlay) {
-               tree_ctx *t = tree_open(portroot, overlay);
+               tree_ctx *t = tree_new(portroot, overlay, TREETYPE_EBUILD, 
false);
                if (t != NULL) {
                        ret |= tree_foreach_pkg_sorted(t, qsearch_cb, &state, 
NULL);
                        tree_close(t);

diff --git a/qsize.c b/qsize.c
index fa3c3bd0..2d669574 100644
--- a/qsize.c
+++ b/qsize.c
@@ -116,7 +116,7 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
        size_t cur_uniq = cnt_set(state->uniq_files);
        bool isuniq;
 
-       if ((line = tree_pkg_meta_get(pkg_ctx, CONTENTS)) == NULL)
+       if ((line = tree_pkg_meta(pkg_ctx, Q_CONTENTS)) == NULL)
                return EXIT_SUCCESS;
 
        num_ignored = num_files = num_nonfiles = num_bytes = 0;
@@ -164,7 +164,7 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                char uniqbuf[32];
 
                cur_uniq = cnt_set(state->uniq_files) - cur_uniq;
-               atom = tree_get_atom(pkg_ctx, state->need_full_atom);
+               atom = tree_pkg_atom(pkg_ctx, state->need_full_atom);
 
                if (cur_uniq != num_files)
                        snprintf(uniqbuf, sizeof(uniqbuf), " (%zu unique)", 
cur_uniq);
@@ -248,18 +248,11 @@ int qsize_main(int argc, char **argv)
                        state.fmt = "%[CATEGORY]%[PN]";
        }
 
-       vdb = tree_open_vdb(portroot, portvdb);
+       vdb = tree_new(portroot, portvdb, TREETYPE_VDB, false);
        if (vdb != NULL) {
                if (array_cnt(state.atoms) > 0) {
-                       array_for_each(state.atoms, i, atom) {
-                               if (atom->CATEGORY == NULL &&
-                                       i + 1 < array_cnt(state.atoms))
-                               {
-                                       ret = tree_foreach_pkg_cached(vdb, 
qsize_cb, &state, atom);
-                               } else {
-                                       ret = tree_foreach_pkg_fast(vdb, 
qsize_cb, &state, atom);
-                               }
-                       }
+                       array_for_each(state.atoms, i, atom)
+                               ret = tree_foreach_pkg_fast(vdb, qsize_cb, 
&state, atom);
                } else {
                        ret = tree_foreach_pkg_fast(vdb, qsize_cb, &state, 
NULL);
                }

diff --git a/quse.c b/quse.c
index 28a28df6..b3745800 100644
--- a/quse.c
+++ b/quse.c
@@ -441,13 +441,13 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
        int ret = 0;
 
        if (state->match || state->do_describe) {
-               atom = tree_get_atom(pkg_ctx, false);
+               atom = tree_pkg_atom(pkg_ctx, false);
                if (atom == NULL)
                        return 0;
        }
 
        if (!state->do_licence) {
-               if ((s = tree_pkg_meta_get(pkg_ctx, IUSE)) == NULL)
+               if ((s = tree_pkg_meta(pkg_ctx, Q_IUSE)) == NULL)
                        return 0;
 
                if (state->do_describe) {
@@ -459,7 +459,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                }
 
                /* available when dealing with VDB or binpkgs */
-               if ((p = tree_pkg_meta_get(pkg_ctx, USE)) != NULL) {
+               if ((p = tree_pkg_meta(pkg_ctx, Q_USE)) != NULL) {
                        while ((q = strchr(p, (int)' ')) != NULL) {
                                *q++ = '\0';
                                use = add_set(p, use);
@@ -469,7 +469,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
                                use = add_set(p, use);
                }
        } else {
-               if ((s = tree_pkg_meta_get(pkg_ctx, LICENSE)) == NULL)
+               if ((s = tree_pkg_meta(pkg_ctx, Q_LICENSE)) == NULL)
                        return 0;
        }
 
@@ -541,7 +541,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
        if (match) {
                ret++;
-               atom = tree_get_atom(pkg_ctx, state->need_full_atom);
+               atom = tree_pkg_atom(pkg_ctx, state->need_full_atom);
                if (quiet) {
                        printf("%s\n", atom_format(state->fmt, atom));
                } else if (state->do_describe && !state->do_licence) {
@@ -561,7 +561,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
                        printf("%s\n", atom_format(state->fmt, atom));
 
-                       q = p = tree_pkg_meta_get(pkg_ctx, IUSE);
+                       q = p = tree_pkg_meta(pkg_ctx, Q_IUSE);
                        buf[0] = '\0';
                        v = buf;
                        w = buf + sizeof(buf);
@@ -728,7 +728,8 @@ int quse_main(int argc, char **argv)
                array_for_each(overlays, n, overlay) {
                        tree_ctx *t = NULL;
                        if (state.need_full_atom)
-                               t = tree_open(portroot, overlay);  /* used for 
repo */
+                               t = tree_new(portroot, overlay,
+                                                        TREETYPE_EBUILD, 
false);  /* used for repo */
                        if (t != NULL)
                                state.repo = tree_get_repo_name(t);
                        if (quse_describe_flag(portroot, overlay, &state))
@@ -737,7 +738,7 @@ int quse_main(int argc, char **argv)
                                tree_close(t);
                }
        } else if (state.do_installed) {
-               tree_ctx *t = tree_open_vdb(portroot, portvdb);
+               tree_ctx *t = tree_new(portroot, portvdb, TREETYPE_VDB, false);
                if (t != NULL) {
                        state.overlay = NULL;
                        state.repo = NULL;
@@ -748,7 +749,7 @@ int quse_main(int argc, char **argv)
                }
        } else {
                array_for_each(overlays, n, overlay) {
-                       tree_ctx *t = tree_open(portroot, overlay);
+                       tree_ctx *t = tree_new(portroot, overlay, 
TREETYPE_EBUILD, false);
                        state.overlay = overlay;
                        if (t != NULL) {
                                state.repo =

diff --git a/qwhich.c b/qwhich.c
index eb57ee00..8a468eb1 100644
--- a/qwhich.c
+++ b/qwhich.c
@@ -139,19 +139,19 @@ int qwhich_main(int argc, char **argv)
 
        /* TODO: silence when the path doesn't exist -- reasonable though? */
        if (m.do_vdb) {
-               t = tree_open_vdb(portroot, portvdb);
+               t = tree_new(portroot, portvdb, TREETYPE_VDB, false);
                if (t != NULL)
                        array_append(trees, t);
        }
        if (m.do_binpkg) {
-               t = tree_open_binpkg("/", pkgdir);
+               t = tree_new(portroot, pkgdir, TREETYPE_BINPKG, false);
                if (t != NULL)
                        array_append(trees, t);
        }
 
        if (m.do_tree) {
                array_for_each(overlays, n, overlay) {
-                       t = tree_open(portroot, overlay);
+                       t = tree_new(portroot, overlay, TREETYPE_EBUILD, false);
                        if (t != NULL)
                                array_append(trees, t);
                }

Reply via email to