diff options
author | 2022-05-20 19:02:56 +0200 | |
---|---|---|
committer | 2022-05-20 19:02:56 +0200 | |
commit | b868d22a6c731449ccfec344508458cf9f7a5abf (patch) | |
tree | 8665f5d90ba47351318ab3eb523ab595fcc7b4e5 | |
parent | qlist: print BUILD_ID for binpkgs (if any) (diff) | |
download | portage-utils-b868d22a6c731449ccfec344508458cf9f7a5abf.tar.gz portage-utils-b868d22a6c731449ccfec344508458cf9f7a5abf.tar.bz2 portage-utils-b868d22a6c731449ccfec344508458cf9f7a5abf.zip |
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@gentoo.org>
-rw-r--r-- | libq/tree.c | 23 | ||||
-rw-r--r-- | libq/tree.h | 4 |
2 files changed, 21 insertions, 6 deletions
diff --git a/libq/tree.c b/libq/tree.c index d71ee740..2a457ce9 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 82792819..2f2c81fc 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; |