commit: 8e3f15772a0419766690f82bbf0b7c7c9f584bc4 Author: Fabian Groffen <grobian <AT> gentoo <DOT> org> AuthorDate: Wed Dec 31 22:44:10 2025 +0000 Commit: Fabian Groffen <grobian <AT> gentoo <DOT> org> CommitDate: Wed Dec 31 22:44:10 2025 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8e3f1577
libq/atom: parse build_id from binpkg input Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org> libq/atom.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/libq/atom.c b/libq/atom.c index 3cc2100..e32d365 100644 --- a/libq/atom.c +++ b/libq/atom.c @@ -1,5 +1,5 @@ /* - * Copyright 2005-2022 Gentoo Foundation + * Copyright 2005-2025 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 * * Copyright 2005-2008 Ned Ludd - <[email protected]> @@ -119,8 +119,29 @@ atom_explode_cat(const char *atom, const char *cat) /* eat file name crap when given an (autocompleted) path */ if ((ptr = strstr(ret->CATEGORY, ".ebuild")) != NULL || - (ptr = strstr(ret->CATEGORY, ".tbz2")) != NULL) + (ptr = strstr(ret->CATEGORY, ".tbz2")) != NULL || + (ptr = strstr(ret->CATEGORY, ".gpkg.tar")) != NULL) + { *ptr = '\0'; + if (ptr[1] == 't' || + ptr[1] == 'g') + { + bool valid = false; + /* probe for the build-id, it should be a number, but it can + * be optional, which is making it difficult because + * in something like PN-VER.gpkg.tar, VER should not be seen + * as BUILDID, while a PN can also contain dashes */ + while (--ptr > ret->CATEGORY && + isdigit(*ptr)) + valid = true; + if (valid && + *ptr == '-') + { + ret->BUILDID = atoll(&ptr[1]); + *ptr = '\0'; + } + } + } /* chip off the trailing ::REPO as needed */ if ((ptr = strstr(ret->CATEGORY, "::")) != NULL) {
