Gentoo Archives: gentoo-commits

From: Fabian Groffen <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage-utils:master commit in: libq/
Date: Fri, 20 May 2022 17:15:32
Message-Id: 1653066176.b868d22a6c731449ccfec344508458cf9f7a5abf.grobian@gentoo
1 commit: b868d22a6c731449ccfec344508458cf9f7a5abf
2 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org>
3 AuthorDate: Fri May 20 17:02:56 2022 +0000
4 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org>
5 CommitDate: Fri May 20 17:02:56 2022 +0000
6 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b868d22a
7
8 libq/tree: support FEATURES=binpkg-multi-instance Packages file
9
10 Based on the work of genbtc in GitHub PR #16
11
12 Add BUILD_ID to atom when parsing and use PATH to get the appropriate
13 location.
14
15 Closes: https://github.com/gentoo/portage-utils/pull/16
16 Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>
17
18 libq/tree.c | 23 ++++++++++++++++++-----
19 libq/tree.h | 4 +++-
20 2 files changed, 21 insertions(+), 6 deletions(-)
21
22 diff --git a/libq/tree.c b/libq/tree.c
23 index d71ee74..2a457ce 100644
24 --- a/libq/tree.c
25 +++ b/libq/tree.c
26 @@ -1440,6 +1440,8 @@ tree_foreach_packages(tree_ctx *ctx, tree_pkg_cb callback, void *priv)
27 }
28 cat->pkg_ctxs = (tree_pkg_ctx **)atom; /* for name */
29 }
30 + if (meta.Q_BUILDID != NULL)
31 + atom->BUILDID = atoi(meta.Q_BUILDID);
32 pkgnamelen = snprintf(pkgname, sizeof(pkgname),
33 "%s.tbz2", atom->PF);
34 pkgname[pkgnamelen - (sizeof(".tbz2") - 1)] = '\0';
35 @@ -1510,6 +1512,9 @@ tree_foreach_packages(tree_ctx *ctx, tree_pkg_cb callback, void *priv)
36 match_key(PDEPEND);
37 match_key2(REPO, repository);
38 match_key(SIZE);
39 + match_key(BDEPEND);
40 + match_key(PATH);
41 + match_key2(BUILD_ID, BUILDID);
42 #undef match_key
43 #undef match_key2
44 }
45 @@ -1812,11 +1817,19 @@ tree_match_atom(tree_ctx *ctx, const depend_atom *query, int flags)
46 n = xzalloc(sizeof(tree_match_ctx)); \
47 n->atom = atom; \
48 n->pkg = pkg_ctx; \
49 - snprintf(n->path, sizeof(n->path), "%s/%s/%s%s", \
50 - (char *)C->ctx->path, C->name, pkg_ctx->name, \
51 - C->ctx->cachetype == CACHE_EBUILD ? ".ebuild" : \
52 - C->ctx->cachetype == CACHE_BINPKGS ? ".tbz2" : \
53 - C->ctx->cachetype == CACHE_PACKAGES ? ".tbz2" : ""); \
54 + if (C->ctx->cachetype == CACHE_PACKAGES && \
55 + pkg_ctx->meta->Q_PATH != NULL) \
56 + { \
57 + /* binpkg-multi-instance has a PATH ready for us */ \
58 + snprintf(n->path, sizeof(n->path), "%s/%s", \
59 + (char *)C->ctx->path, pkg_ctx->meta->Q_PATH); \
60 + } else { \
61 + snprintf(n->path, sizeof(n->path), "%s/%s/%s%s", \
62 + (char *)C->ctx->path, C->name, pkg_ctx->name, \
63 + C->ctx->cachetype == CACHE_EBUILD ? ".ebuild" : \
64 + C->ctx->cachetype == CACHE_BINPKGS ? ".tbz2" : \
65 + C->ctx->cachetype == CACHE_PACKAGES ? ".tbz2" : ""); \
66 + } \
67 if (flags & TREE_MATCH_METADATA) \
68 n->meta = tree_pkg_read(pkg_ctx); \
69 if (C->ctx->cachetype == CACHE_BINPKGS || \
70
71 diff --git a/libq/tree.h b/libq/tree.h
72 index 8279281..2f2c81f 100644
73 --- a/libq/tree.h
74 +++ b/libq/tree.h
75 @@ -1,5 +1,5 @@
76 /*
77 - * Copyright 2005-2021 Gentoo Foundation
78 + * Copyright 2005-2022 Gentoo Foundation
79 * Distributed under the terms of the GNU General Public License v2
80 */
81
82 @@ -104,6 +104,8 @@ struct tree_pkg_meta {
83 char *Q_CONTENTS;
84 char *Q_USE;
85 char *Q_EPREFIX;
86 + char *Q_PATH; /* binpkg-multi-instance */
87 + char *Q_BUILDID; /* binpkg-multi-instance */
88 char *Q_repository;
89 char *Q_MD5;
90 char *Q_SHA1;