From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 1CEA3138334 for ; Fri, 3 Jan 2020 10:36:12 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 64FACE0AC2; Fri, 3 Jan 2020 10:36:11 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 3A3E2E0AC2 for ; Fri, 3 Jan 2020 10:36:11 +0000 (UTC) Received: from oystercatcher.gentoo.org (oystercatcher.gentoo.org [148.251.78.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 0D3DB34DE8E for ; Fri, 3 Jan 2020 10:36:10 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id AFB2E3E for ; Fri, 3 Jan 2020 10:36:08 +0000 (UTC) From: "Fabian Groffen" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Fabian Groffen" Message-ID: <1578047691.beb913d65c99d4bd3057c5b7b965ad17001cd04a.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: main.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: beb913d65c99d4bd3057c5b7b965ad17001cd04a X-VCS-Branch: master Date: Fri, 3 Jan 2020 10:36:08 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-Archives-Salt: 1f260d31-20c6-4833-a4c8-f2fd71815aae X-Archives-Hash: 7e4923860f68bd74bd91e6391b856643 commit: beb913d65c99d4bd3057c5b7b965ad17001cd04a Author: Fabian Groffen gentoo org> AuthorDate: Fri Jan 3 10:34:51 2020 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Fri Jan 3 10:34:51 2020 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=beb913d6 main: don't ignore profiles without parents A (major) thinko, profiles without a parent file were not considered, while this is obviously wrong behaviour, resulting in missing values. Signed-off-by: Fabian Groffen gentoo.org> main.c | 87 +++++++++++++++++++++++++++++++----------------------------------- 1 file changed, 41 insertions(+), 46 deletions(-) diff --git a/main.c b/main.c index 9068102..8ac4fa8 100644 --- a/main.c +++ b/main.c @@ -1,5 +1,5 @@ /* - * Copyright 2005-2019 Gentoo Foundation + * Copyright 2005-2020 Gentoo Foundation * Distributed under the terms of the GNU General Public License v2 * * Copyright 2005-2008 Ned Ludd - @@ -373,9 +373,6 @@ read_portage_file(const char *file, enum portage_file_type type, void *data) env_vars *vars = data; set *masks = data; - if (getenv("DEBUG")) - fprintf(stderr, "profile %s\n", file); - if ((dentslen = scandir(file, &dents, NULL, alphasort)) > 0) { int di; struct dirent *d; @@ -513,6 +510,9 @@ read_portage_file(const char *file, enum portage_file_type type, void *data) fclose(fp); done: free(buf); + + if (getenv("DEBUG")) + fprintf(stderr, "read profile %s\n", file); } /* Helper to recursively read stacked make.defaults in profiles */ @@ -539,53 +539,48 @@ read_portage_profile(const char *profile, env_vars vars[], set *masks) * treat parent profiles as defaults, that can be overridden by * *this* profile. */ strcpy(profile_file + profile_len, "parent"); - if (!eat_file(profile_file, &buf, &buf_len)) { - if (buf != NULL) - free(buf); - return; - } - - s = strtok_r(buf, "\n", &saveptr); - while (s) { - /* handle repo: notation (not in PMS, referenced in Wiki only?) */ - if ((p = strchr(s, ':')) != NULL) { - char *overlay; - char *repo_name; - size_t n; - - /* split repo from target */ - *p++ = '\0'; - - /* match the repo */ - repo_name = NULL; - array_for_each(overlays, n, overlay) { - repo_name = xarrayget(overlay_names, n); - if (strcmp(repo_name, s) == 0) { - snprintf(profile_file, sizeof(profile_file), - "%s/profiles/%s/", overlay, p); - break; - } + if (eat_file(profile_file, &buf, &buf_len)) { + s = strtok_r(buf, "\n", &saveptr); + for (; s != NULL; s = strtok_r(NULL, "\n", &saveptr)) { + /* handle repo: notation (not in PMS, referenced in Wiki only?) */ + if ((p = strchr(s, ':')) != NULL) { + char *overlay; + char *repo_name; + size_t n; + + /* split repo from target */ + *p++ = '\0'; + + /* match the repo */ repo_name = NULL; + array_for_each(overlays, n, overlay) { + repo_name = xarrayget(overlay_names, n); + if (strcmp(repo_name, s) == 0) { + snprintf(profile_file, sizeof(profile_file), + "%s/profiles/%s/", overlay, p); + break; + } + repo_name = NULL; + } + if (repo_name == NULL) { + warn("ignoring parent with unknown repo in profile: %s", s); + continue; + } + } else { + snprintf(profile_file + profile_len, + sizeof(profile_file) - profile_len, "%s", s); } - if (repo_name == NULL) { - warn("ignoring parent with unknown repo in profile: %s", s); - s = strtok_r(NULL, "\n", &saveptr); - continue; - } - } else { - snprintf(profile_file + profile_len, - sizeof(profile_file) - profile_len, "%s", s); + read_portage_profile( + realpath(profile_file, rpath) == NULL ? + profile_file : rpath, vars, masks); + /* restore original path in case we were repointed by profile */ + if (p != NULL) + snprintf(profile_file, sizeof(profile_file), "%s/", profile); } - read_portage_profile( - realpath(profile_file, rpath) == NULL ? profile_file : rpath, - vars, masks); - /* restore original path in case we were repointed by profile */ - if (p != NULL) - snprintf(profile_file, sizeof(profile_file), "%s/", profile); - s = strtok_r(NULL, "\n", &saveptr); } - free(buf); + if (buf != NULL) + free(buf); /* now consume *this* profile's make.defaults and package.mask */ strcpy(profile_file + profile_len, "make.defaults");