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 D9261138334 for ; Mon, 20 May 2019 12:15:15 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id DA07FE07DF; Mon, 20 May 2019 12:15:14 +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 A8812E07DF for ; Mon, 20 May 2019 12:15:14 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (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 21632344537 for ; Mon, 20 May 2019 12:15:13 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id A66215DC for ; Mon, 20 May 2019 12:15:10 +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: <1558354457.2eb21c641333c5c35bd8cf7d6f4da79d29e14fa2.grobian@gentoo> Subject: [gentoo-commits] proj/portage-utils:master commit in: / X-VCS-Repository: proj/portage-utils X-VCS-Files: applets.h main.c q.c X-VCS-Directories: / X-VCS-Committer: grobian X-VCS-Committer-Name: Fabian Groffen X-VCS-Revision: 2eb21c641333c5c35bd8cf7d6f4da79d29e14fa2 X-VCS-Branch: master Date: Mon, 20 May 2019 12:15:10 +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: 7aec7385-71f2-4266-8105-a606ff776e02 X-Archives-Hash: 0a4437d4b3227a20af1b09bed4b2ef61 commit: 2eb21c641333c5c35bd8cf7d6f4da79d29e14fa2 Author: Fabian Groffen gentoo org> AuthorDate: Mon May 20 12:14:17 2019 +0000 Commit: Fabian Groffen gentoo org> CommitDate: Mon May 20 12:14:17 2019 +0000 URL: https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2eb21c64 q: use overlay names from repos.conf if available Signed-off-by: Fabian Groffen gentoo.org> applets.h | 1 + main.c | 8 ++++++-- q.c | 18 ++++++++++++------ 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/applets.h b/applets.h index 71666bb..fbb4e8c 100644 --- a/applets.h +++ b/applets.h @@ -152,6 +152,7 @@ extern char *port_tmpdir; extern char *features; extern char *install_mask; extern DEFINE_ARRAY(overlays); +extern DEFINE_ARRAY(overlay_names); extern char *main_overlay; void no_colors(void); diff --git a/main.c b/main.c index bf86c49..0fdb420 100644 --- a/main.c +++ b/main.c @@ -23,6 +23,7 @@ #include "xasprintf.h" /* variables to control runtime behavior */ +char *main_overlay; char *module_name = NULL; int verbose = 0; int quiet = 0; @@ -39,8 +40,8 @@ char *port_tmpdir; char *features; char *install_mask; DECLARE_ARRAY(overlays); +DECLARE_ARRAY(overlay_names); -static char *main_overlay; static char *portarch; static char *portedb; static char *eprefix; @@ -237,6 +238,7 @@ read_one_repos_conf(const char *repos_conf) path = iniparser_getstring(dict, conf, NULL); if (path) { void *ele = xarraypush_str(overlays, path); + xarraypush_str(overlay_names, repo); if (main_repo && !strcmp(repo, main_repo)) main_overlay = ele; } @@ -735,8 +737,10 @@ initialize_portage_env(void) read_repos_conf(configroot, "/etc/portage/repos.conf"); if (orig_main_overlay != main_overlay) free(orig_main_overlay); - if (array_cnt(overlays) == 0) + if (array_cnt(overlays) == 0) { xarraypush_str(overlays, main_overlay); + xarraypush_str(overlay_names, ""); + } if (getenv("DEBUG")) { for (i = 0; vars_to_read[i].name; ++i) { diff --git a/q.c b/q.c index 5499017..31427f3 100644 --- a/q.c +++ b/q.c @@ -165,18 +165,24 @@ int q_main(int argc, char **argv) size_t n; array_for_each(overlays, n, overlay) { - snprintf(buf, sizeof(buf), "%s/profiles/repo_name", overlay); - if (!eat_file(buf, &repo_name, &repo_name_len)) + repo_name = xarrayget(overlay_names, n); + if (strcmp(repo_name, "") == 0) { repo_name = NULL; - if (repo_name != NULL) - rmspace(repo_name); + snprintf(buf, sizeof(buf), "%s/profiles/repo_name", overlay); + if (!eat_file(buf, &repo_name, &repo_name_len)) + repo_name = NULL; + if (repo_name != NULL) + rmspace(repo_name); + } printf("%s%s%s: %s%s%s%s\n", GREEN, repo_name == NULL ? "?unknown?" : repo_name, NORM, overlay, YELLOW, main_overlay == overlay ? " (main)" : "", NORM); + if (repo_name_len != 0) { + free(repo_name); + repo_name_len = 0; + } } - if (repo_name != NULL) - free(repo_name); return 0; }