commit:     b868d22a6c731449ccfec344508458cf9f7a5abf
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 20 17:02:56 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 20 17:02:56 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b868d22a

libq/tree: support FEATURES=binpkg-multi-instance Packages file

Based on the work of genbtc in GitHub PR #16

Add BUILD_ID to atom when parsing and use PATH to get the appropriate
location.

Closes: https://github.com/gentoo/portage-utils/pull/16
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 libq/tree.c | 23 ++++++++++++++++++-----
 libq/tree.h |  4 +++-
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/libq/tree.c b/libq/tree.c
index d71ee74..2a457ce 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -1440,6 +1440,8 @@ tree_foreach_packages(tree_ctx *ctx, tree_pkg_cb 
callback, void *priv)
                                        }
                                        cat->pkg_ctxs = (tree_pkg_ctx **)atom;  
/* for name */
                                }
+                               if (meta.Q_BUILDID != NULL)
+                                       atom->BUILDID = atoi(meta.Q_BUILDID);
                                pkgnamelen = snprintf(pkgname, sizeof(pkgname),
                                                "%s.tbz2", atom->PF);
                                pkgname[pkgnamelen - (sizeof(".tbz2") - 1)] = 
'\0';
@@ -1510,6 +1512,9 @@ tree_foreach_packages(tree_ctx *ctx, tree_pkg_cb 
callback, void *priv)
                match_key(PDEPEND);
                match_key2(REPO, repository);
                match_key(SIZE);
+               match_key(BDEPEND);
+               match_key(PATH);
+               match_key2(BUILD_ID, BUILDID);
 #undef match_key
 #undef match_key2
                }
@@ -1812,11 +1817,19 @@ tree_match_atom(tree_ctx *ctx, const depend_atom 
*query, int flags)
                        n = xzalloc(sizeof(tree_match_ctx)); \
                        n->atom = atom; \
                        n->pkg = pkg_ctx; \
-                       snprintf(n->path, sizeof(n->path), "%s/%s/%s%s", \
-                                       (char *)C->ctx->path, C->name, 
pkg_ctx->name, \
-                                       C->ctx->cachetype == CACHE_EBUILD ? 
".ebuild" : \
-                                       C->ctx->cachetype == CACHE_BINPKGS ? 
".tbz2" : \
-                                       C->ctx->cachetype == CACHE_PACKAGES ? 
".tbz2" : ""); \
+                       if (C->ctx->cachetype == CACHE_PACKAGES && \
+                               pkg_ctx->meta->Q_PATH != NULL) \
+                       { \
+                               /* binpkg-multi-instance has a PATH ready for 
us */ \
+                               snprintf(n->path, sizeof(n->path), "%s/%s", \
+                                                (char *)C->ctx->path, 
pkg_ctx->meta->Q_PATH); \
+                       } else { \
+                               snprintf(n->path, sizeof(n->path), 
"%s/%s/%s%s", \
+                                                (char *)C->ctx->path, C->name, 
pkg_ctx->name, \
+                                                C->ctx->cachetype == 
CACHE_EBUILD   ? ".ebuild" : \
+                                                C->ctx->cachetype == 
CACHE_BINPKGS  ? ".tbz2" : \
+                                                C->ctx->cachetype == 
CACHE_PACKAGES ? ".tbz2" : ""); \
+                       } \
                        if (flags & TREE_MATCH_METADATA) \
                                n->meta = tree_pkg_read(pkg_ctx); \
                        if (C->ctx->cachetype == CACHE_BINPKGS || \

diff --git a/libq/tree.h b/libq/tree.h
index 8279281..2f2c81f 100644
--- a/libq/tree.h
+++ b/libq/tree.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2021 Gentoo Foundation
+ * Copyright 2005-2022 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  */
 
@@ -104,6 +104,8 @@ struct tree_pkg_meta {
        char *Q_CONTENTS;
        char *Q_USE;
        char *Q_EPREFIX;
+       char *Q_PATH;     /* binpkg-multi-instance */
+       char *Q_BUILDID;  /* binpkg-multi-instance */
        char *Q_repository;
        char *Q_MD5;
        char *Q_SHA1;

Reply via email to