public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-11-13 14:27 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-11-13 14:27 UTC (permalink / raw
  To: gentoo-commits

commit:     64a44526703bf371a18ea29397af3d4196069680
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 13 14:26:23 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov 13 14:26:23 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=64a44526

qdepends: only print deps enabled by configured USE-flags

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qdepends.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qdepends.c b/qdepends.c
index 959825b..93b5109 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -196,6 +196,7 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				tree_close_cat(vcat);
 			}
 		} else {
+			dep_prune_use(dep_tree, ev_use);
 			dep_flatten_tree(dep_tree, state->deps);
 		}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2024-07-03 19:44 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2024-07-03 19:44 UTC (permalink / raw
  To: gentoo-commits

commit:     b7acc09ff2d9d2ce176ee131458ad39489b0bbd3
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jul  3 19:42:29 2024 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jul  3 19:42:29 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b7acc09f

main: respect ROOT when reading profiles

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/main.c b/main.c
index 9ea7666..59a1721 100644
--- a/main.c
+++ b/main.c
@@ -443,7 +443,8 @@ read_portage_file(const char *file, enum portage_file_type type, void *data)
 	env_vars *vars = data;
 	set *masks = data;
 
-	if ((dentslen = scandir(file, &dents, NULL, alphasort)) > 0) {
+	snprintf(npath, sizeof(npath), "%s%s", portroot, file);
+	if ((dentslen = scandir(npath, &dents, NULL, alphasort)) > 0) {
 		int di;
 		struct dirent *d;
 
@@ -603,7 +604,7 @@ read_portage_file(const char *file, enum portage_file_type type, void *data)
 	free(buf);
 
 	if (getenv("DEBUG"))
-		fprintf(stderr, "read profile %s\n", file);
+		fprintf(stderr, "read profile %s%s\n", portroot, file);
 }
 
 /* Helper to check if a string starts with a prefix. If so, returns
@@ -883,10 +884,16 @@ read_one_repos_conf(const char *repos_conf, char **primary)
 			void *ele;
 			size_t n;
 			char *overlay;
+			char rootovrl[_Q_PATH_MAX];
 
 			/* try not to get confused by symlinks etc. */
-			if (realpath(e, rrepo) != NULL)
-				e = rrepo;
+			snprintf(rootovrl, sizeof(rootovrl), "%s%s", portroot, e);
+			n = strlen(portroot);
+			if (realpath(rootovrl, rrepo) != NULL &&
+				strncmp(rrepo, portroot, n) == 0)
+				e = rrepo + n;
+			else
+				e = rootovrl + n;
 
 			array_for_each(overlay_names, n, overlay) {
 				if (strcmp(overlay, repo) == 0)
@@ -922,7 +929,7 @@ read_repos_conf(const char *configroot, const char *repos_conf, char **primary)
 	int i, count;
 	struct dirent **confs;
 
-	xasprintf(&top_conf, "%s%s", configroot, repos_conf);
+	xasprintf(&top_conf, "%s%s%s", portroot, configroot, repos_conf);
 	if (getenv("DEBUG"))
 		fprintf(stderr, "repos.conf.d scanner %s\n", top_conf);
 	count = scandir(top_conf, &confs, NULL, alphasort);
@@ -1130,9 +1137,12 @@ initialize_portage_env(void)
 
 		if (strcmp(var->src, STR_DEFAULT) != 0 || array_cnt(overlays) == 0) {
 			char roverlay[_Q_PATH_MAX];
+			char rootovrl[_Q_PATH_MAX];
+			snprintf(rootovrl, sizeof(rootovrl), "%s%s",
+					 portroot, main_overlay);
 			/* get cannonical path, we do so for repos.conf too */
-			if (realpath(main_overlay, roverlay) == NULL)
-				snprintf(roverlay, sizeof(roverlay), "%s", main_overlay);
+			if (realpath(rootovrl, roverlay) == NULL)
+				snprintf(roverlay, sizeof(roverlay), "%s", rootovrl);
 			array_for_each(overlays, i, overlay) {
 				if (strcmp(overlay, roverlay) == 0)
 					break;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2024-06-28 19:51 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2024-06-28 19:51 UTC (permalink / raw
  To: gentoo-commits

commit:     40f8fab17e2cb24ada3ef396248df644ca34d671
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jun 28 19:51:22 2024 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jun 28 19:51:22 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=40f8fab1

fix Coverity issues

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qdepends.c  | 1 +
 qmanifest.c | 8 ++++----
 qpkg.c      | 4 ++--
 3 files changed, 7 insertions(+), 6 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index 1ecfab5..6afcb1c 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -416,6 +416,7 @@ int qdepends_main(int argc, char **argv)
 		array_for_each(overlays, n, overlay) {
 			t = tree_open(portroot, overlay);
 			if (t != NULL) {
+				state.rtree = NULL;
 				if (state.resolve)
 					state.rtree = tree_open(portroot, overlay);
 				if (!(state.qmode & QMODE_REVERSE) && array_cnt(atoms) > 0) {

diff --git a/qmanifest.c b/qmanifest.c
index 5246fc4..555e3c7 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -1357,8 +1357,8 @@ verify_dir(
 			}
 		}
 
-		while (dentrieslen-- > 0)
-			free(dentries[dentrieslen]);
+		for (curdentry = 0; curdentry < dentrieslen; curdentry++)
+			free(dentries[curdentry]);
 		free(dentries);
 
 #pragma omp parallel for shared(ret) private(entry, etpe, slash)
@@ -1497,8 +1497,8 @@ verify_manifest(
 	ret = verify_dir(dir, elems, elemslen, 0, buf + 2, msgs);
 	checked_manifests++;
 
-	while (elemslen-- > 0)
-		free(elems[elemslen]);
+	for (elemssize = 0; elemssize < elemslen; elemssize++)
+		free(elems[elemssize]);
 	free(elems);
 
 	return ret;

diff --git a/qpkg.c b/qpkg.c
index c165989..85dbbcf 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -101,9 +101,9 @@ qpkg_clean(char *dirp)
 	if (known_pkgs != NULL) {
 		/* check which binpkgs exist in the known_pkgs (vdb or trees), such
 		 * that the remainder is what we would clean */
-		array_for_each(bins, n, binatomstr) {
+		array_for_each_rev(bins, n, binatomstr) {
 			if (contains_set(binatomstr, known_pkgs))
-				xarraydelete_ptr(bins, n--);
+				xarraydelete_ptr(bins, n);
 		}
 
 		free_set(known_pkgs);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2024-06-27 19:19 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2024-06-27 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     ea143f7e71376962d8dc210ccb014a2f099d24e6
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 25 20:03:54 2024 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Jun 25 20:03:54 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ea143f7e

qwhich: add -r option to limit search to a repository

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qwhich.c | 31 +++++++++++++++++++++----------
 1 file changed, 21 insertions(+), 10 deletions(-)

diff --git a/qwhich.c b/qwhich.c
index 76b03a8..daae2f5 100644
--- a/qwhich.c
+++ b/qwhich.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2021 Gentoo Foundation
+ * Copyright 2021-2024 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2021-     Fabian Groffen  - <grobian@gentoo.org>
@@ -19,14 +19,15 @@
 #include "atom.h"
 #include "tree.h"
 
-#define QWHICH_FLAGS "IbtpdRflTAF:" COMMON_FLAGS
+#define QWHICH_FLAGS "Ibtpdr:RflTAF:" COMMON_FLAGS
 static struct option const qwhich_long_opts[] = {
 	{"vdb",       no_argument, NULL, 'I'},
 	{"binpkg",    no_argument, NULL, 'b'},
 	{"tree",      no_argument, NULL, 't'},
 	{"pretty",    no_argument, NULL, 'p'},
 	{"dir",       no_argument, NULL, 'd'},
-	{"repo",      no_argument, NULL, 'R'},
+	{"repo",       a_argument, NULL, 'r'},
+	{"printrepo", no_argument, NULL, 'R'},
 	{"first",     no_argument, NULL, 'f'},
 	{"latest",    no_argument, NULL, 'l'},
 	{"novirtual", no_argument, NULL, 'T'},
@@ -40,6 +41,7 @@ static const char * const qwhich_opts_help[] = {
 	"Look in main tree and overlays",
 	"Print (pretty) atom instead of path for use with -F",
 	"Print directory instead of path",
+	"Only look in given repo",
 	"Print repository name instead of path for tree/overlay matches",
 	"Stop searching after first match (implies -l)",
 	"Only return latest version for each match",
@@ -48,7 +50,7 @@ static const char * const qwhich_opts_help[] = {
 	"Print matched using given format string",
 	COMMON_OPTS_HELP
 };
-static const char qwhich_desc[] = "";
+static const char qwhich_desc[] = "Find paths to ebuilds.";
 #define qwhich_usage(ret) \
 	usage(ret, QWHICH_FLAGS, qwhich_long_opts, qwhich_opts_help, qwhich_desc, lookup_applet_idx("qwhich"))
 
@@ -80,7 +82,8 @@ int qwhich_main(int argc, char **argv)
 	size_t n;
 	int ret;
 	tree_ctx *t;
-	char *repo;
+	char *repo = NULL;
+	char *reponam;
 	int repolen;
 	const char *ext;
 
@@ -95,6 +98,7 @@ int qwhich_main(int argc, char **argv)
 			case 't': m.do_tree = true;      break;
 			case 'p': m.print_atom = true;   break;
 			case 'd': m.print_path = true;   break;
+			case 'r': repo = optarg;         break;
 			case 'R': m.print_repo = true;   break;
 			case 'f': m.match_first = true;  break;
 			case 'l': m.match_latest = true; break;
@@ -160,11 +164,18 @@ int qwhich_main(int argc, char **argv)
 
 	/* at least keep the IO constrained to a tree at a time */
 	array_for_each(trees, j, t) {
+		if (repo != NULL &&
+			(t->repo == NULL || strcmp(repo, t->repo) != 0))
+		{
+			tree_close(t);
+			continue;
+		}
+
 		if (m.print_repo && t->repo != NULL) {
-			repo = t->repo;
-			repolen = strlen(repo);
+			reponam = t->repo;
+			repolen = strlen(reponam);
 		} else {
-			repo = t->path;
+			reponam = t->path;
 			if (t->cachetype == CACHE_METADATA_MD5)
 				repolen = strlen(t->path) - (sizeof("/metadata/md5-cache") - 1);
 			else if (t->cachetype == CACHE_METADATA_PMS)
@@ -205,14 +216,14 @@ int qwhich_main(int argc, char **argv)
 					{
 						if (m.print_path)
 							printf("%s%.*s%s%s%s/%s%s%s\n",
-									GREEN, repolen, repo,
+									GREEN, repolen, reponam,
 									m.print_repo ? "::" : "/",
 									BOLD, tmcw->atom->CATEGORY,
 									DKBLUE, tmcw->atom->PN,
 									NORM);
 						else
 							printf("%s%.*s%s%s%s/%s%s/%s%s%s.%s%s\n",
-									DKGREEN, repolen, repo,
+									DKGREEN, repolen, reponam,
 									m.print_repo ? "::" : "/",
 									BOLD, tmcw->atom->CATEGORY,
 									DKBLUE, tmcw->atom->PN,


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2024-04-20 13:05 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2024-04-20 13:05 UTC (permalink / raw
  To: gentoo-commits

commit:     9cee7e77de1fb0d4d685c650e1643f2835d98dfe
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 20 12:56:02 2024 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Apr 20 12:56:02 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9cee7e77

autogen: autoconf-archive was moved from sys-devel to dev-build

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 autogen.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index dc41d69..0c9a8c9 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -9,8 +9,8 @@ if ! qlist -qI dev-libs/gnulib > /dev/null ; then
 	echo "please install dev-libs/gnulib"
 	exit 1
 fi
-if ! qlist -qI sys-devel/autoconf-archive > /dev/null ; then
-	echo "please install sys-devel/autoconf-archive"
+if ! qlist -qI dev-build/autoconf-archive > /dev/null ; then
+	echo "please install dev-build/autoconf-archive"
 	exit 1
 fi
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2024-03-29 11:22 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2024-03-29 11:22 UTC (permalink / raw
  To: gentoo-commits

commit:     cc4de0decf915ee76fcbf4420f15e68e6d10a17a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 29 11:19:52 2024 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 29 11:19:52 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=cc4de0de

qmanifest: avoid out of bounds access in append_list macro

Empty strings, or those being just whitespace were not handled
correctly.  Thanks bstaletic in PR #19 for pointing this out.  Avoid
running under the original string pointer and skip any checks for
strings that are too short to match anything in particular.  This sweeps
an edgecase of just a single whitespace char under the carpet -- which
is just about fine, for it needs not to be handled for any legitimate
case.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qmanifest.c b/qmanifest.c
index 2bb0f11..5246fc4 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -1421,13 +1421,15 @@ verify_manifest(
 #define append_list(STR) \
 	if (strncmp(STR, "TIMESTAMP ", 10) != 0 || strncmp(STR, "DIST ", 5) != 0) {\
 		char *endp = STR + strlen(STR) - 1;\
-		while (isspace(*endp))\
+		while (endp > STR && isspace(*endp))\
 			*endp-- = '\0';\
 		if (elemslen == elemssize) {\
 			elemssize += LISTSZ;\
 			elems = xrealloc(elems, elemssize * sizeof(elems[0]));\
 		}\
-		if (strncmp(STR, "IGNORE ", 7) == 0) {\
+		if (endp - STR < 4) {\
+			/* avoid doing comparisons, none will match */\
+		} else if (strncmp(STR, "IGNORE ", 7) == 0) {\
 			STR[5] = 'I';\
 			elems[elemslen] = xstrdup(STR + 5);\
 			elemslen++;\


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2024-03-29 10:58 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2024-03-29 10:58 UTC (permalink / raw
  To: gentoo-commits

commit:     ad4eb81f3fda3b3df705c48c875c901f814ec74a
Author:     Boris Staletic <boris.staletic <AT> protonmail <DOT> com>
AuthorDate: Thu Mar 28 19:57:26 2024 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 29 10:58:23 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ad4eb81f

qlop: Do not leak avgs array in predict mode

Previously, `values_set(merge_averages, avgs)` would allocate `avgs`,
then it would be used in `array_for_each(atoms, i, atom)`, but a call to
`xarrayfree_int(avgs)` was missing after the loop.

Hopefully, this, along with #26, will solve the issues from #19.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qlop.c b/qlop.c
index cfad246..ae0bc3b 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1324,6 +1324,7 @@ static int do_emerge_log(
 				}
 			}
 		}
+		xarrayfree_int(avgs);
 	}
 
 	{


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2024-03-29 10:57 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2024-03-29 10:57 UTC (permalink / raw
  To: gentoo-commits

commit:     a425c1a91f01dd57f68d25eec3116c9634338d14
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 29 10:54:19 2024 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 29 10:54:27 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a425c1a9

qmerge: add reminder for myself

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/qmerge.c b/qmerge.c
index fba5299..280b0c1 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1481,6 +1481,10 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 
 		cpath = xstrdup("");  /* xrealloced in merge_tree_at */
 
+		/* TODO: use replacing to pass over pervinst->pkg for
+		 * VDB/CONTENTS and respect the config-protect-if-modified flag
+		 * like unmerge does */
+
 		ret = merge_tree_at(AT_FDCWD, "image",
 				AT_FDCWD, portroot, contents, eprefix_len,
 				&objs, &cpath, cp_argc, cp_argv, cpm_argc, cpm_argv);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2024-01-02 13:16 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2024-01-02 13:16 UTC (permalink / raw
  To: gentoo-commits

commit:     e023e57e23cffce91451e64086bb748ce44fbc80
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  2 13:15:34 2024 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Jan  2 13:15:34 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e023e57e

qmerge: sloppily circumvent Coverity 125893

use mkdir_p to avoid Unchecked return value from library

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 8924a37..fba5299 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1224,7 +1224,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	/* Doesn't actually remove $PWD, just everything under it */
 	rm_rf(".");
 
-	mkdir("temp", 0755);
+	mkdir_p("temp", 0755);
 	mkdir_p(portroot, 0755);
 
 	tbz2size = 0;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2024-01-02 13:16 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2024-01-02 13:16 UTC (permalink / raw
  To: gentoo-commits

commit:     af1d54e9a8bf517e566091a8c60762ebfcb534d7
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  2 13:07:45 2024 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Jan  2 13:07:45 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=af1d54e9

qmerge: fix Coverity 190455 Argument cannot be negative

Handle case where image dir somehow could not be opened.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index b16b4b5..8924a37 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1411,10 +1411,12 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 		int imagefd = open("image", O_RDONLY);
 		size_t masklen = strlen(install_mask) + 1 +
 				15 + 1 + 14 + 1 + 14 + 1 + 1;  /* worst case scenario */
-		char *imask = xmalloc(masklen);
+		char *imask;
 		size_t maskp;
 
-		if (fstat(imagefd, &st) == -1) {
+		if (imagefd == -1) {
+			err("Failed to open image dir");
+		} else if (fstat(imagefd, &st) == -1) {
 			close(imagefd);
 			err("Cannot stat image dirfd");
 		} else if (eprefix != NULL && eprefix[0] == '/') {
@@ -1425,6 +1427,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 			}
 		}
 
+		imask = xmalloc(masklen);
 		/* rely on INSTALL_MASK code to remove optional dirs */
 		maskp = snprintf(imask, masklen, "%s ", install_mask);
 		if (contains_set("noinfo", features))


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2024-01-02  7:57 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2024-01-02  7:57 UTC (permalink / raw
  To: gentoo-commits

commit:     d07c7b639103c1dd50851f3f3b974fabfc2a33a2
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  2 07:53:09 2024 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Jan  2 07:53:09 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d07c7b63

buildsys: no longer use OpenSSL for hash implementations

This means, we can always build qtegrity, because we have the required
hash impls on board through gnulib.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 Makefile.am  | 11 ++++-------
 applets.h    |  4 ----
 configure.ac | 27 ---------------------------
 3 files changed, 4 insertions(+), 38 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 7dbcf42..d3ebafc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,6 +22,7 @@ APPLETS = \
 	qsearch \
 	qsize \
 	qtbz2 \
+	qtegrity \
 	quse \
 	qwhich \
 	qxpak \
@@ -42,6 +43,7 @@ dist_man_MANS = \
 	man/qsearch.1 \
 	man/qsize.1 \
 	man/qtbz2.1 \
+	man/qtegrity.1 \
 	man/quse.1 \
 	man/qwhich.1 \
 	man/qxpak.1 \
@@ -64,6 +66,7 @@ q_SOURCES = \
 	qsearch.c \
 	qsize.c \
 	qtbz2.c \
+	qtegrity.c \
 	quse.c \
 	qwhich.c \
 	qxpak.c \
@@ -73,7 +76,6 @@ q_CPPFLAGS = \
 	-I$(top_builddir)/autotools/gnulib \
 	-I$(top_srcdir)/autotools/gnulib \
 	$(OPENMP_CFLAGS) \
-	$(LIBSSL_CFLAGS) \
 	$(LIBBL2_CFLAGS) \
 	$(LIBZ_CFLAGS) \
 	$(NULL)
@@ -81,10 +83,10 @@ q_LDADD = \
 	$(top_builddir)/libq/libq.a \
 	$(top_builddir)/autotools/gnulib/libgnu.a \
 	$(OPENMP_CFLAGS) \
-	$(LIBSSL_LIBS) \
 	$(LIBBL2_LIBS) \
 	$(LIBZ_LIBS) \
 	$(GPGME_LIBS) \
+	$(LIB_CRYPTO) \
 	$(LIB_CLOCK_GETTIME) \
 	$(LIB_EACCESS) \
 	$(SENDFILE_LIBS) \
@@ -97,11 +99,6 @@ q_CPPFLAGS += \
 dist_man_MANS += man/qmanifest.1
 APPLETS += qmanifest
 endif
-if QTEGRITY_ENABLED
-q_SOURCES += qtegrity.c
-dist_man_MANS += man/qtegrity.1
-APPLETS += qtegrity
-endif
 
 
 install-exec-hook:

diff --git a/applets.h b/applets.h
index 16e7d9f..8e78f21 100644
--- a/applets.h
+++ b/applets.h
@@ -88,9 +88,7 @@ static const struct applet_t {
 	{"qsearch",   qsearch_main,   "<regex>",         "search pkgname/desc"},
 	{"qsize",     qsize_main,     "<pkgname>",       "calculate size usage"},
 	{"qtbz2",     qtbz2_main,     "<misc args>",     "manipulate tbz2 packages"},
-#ifdef ENABLE_QTEGRITY
 	{"qtegrity",  qtegrity_main,  "<misc args>",     "verify files with IMA"},
-#endif
 	{"quse",      quse_main,      "<useflag>",       "find pkgs using useflags"},
 	{"qwhich",    qwhich_main,    "<pkg ...>",       "find path to pkg"},
 	{"qxpak",     qxpak_main,     "<misc args>",     "manipulate xpak archives"},
@@ -113,10 +111,8 @@ static const struct applet_t {
 	{"uickpkg",   qpkg_main,      NULL, NULL},
 	/* {"glsa",      qglsa_main,     NULL, NULL}, */
 
-#ifdef ENABLE_QTEGRITY
 	/* alias for qtegrity */
 	{"integrity", qtegrity_main,  NULL, NULL},
-#endif
 
 #ifdef ENABLE_QMANIFEST
 	/* old hashgen */

diff --git a/configure.ac b/configure.ac
index c26848a..7d101c4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,28 +52,6 @@ AC_SUBST([CONFIG_EPREFIX], ["$with_eprefix"])
 
 AC_ARG_ENABLE([qmanifest], [AS_HELP_STRING([--enable-qmanifest],
 			  [support qmanifest applet])])
-AC_ARG_ENABLE([qtegrity], [AS_HELP_STRING([--enable-qtegrity],
-			  [support qtegrity applet])])
-
-AS_IF([test "x${enable_qmanifest}${enable_qtegrity}" != "xnono"], [
-  PKG_CHECK_MODULES([LIBSSL], [libcrypto], [
-    AC_DEFINE([HAVE_SSL], [1], [Define if you have ssl])
-    LIBSSL="yes"
-  ], [
-    AS_IF([test "x${enable_qmanifest}" = "xyes"], [
-      AC_MSG_FAILURE([--enable-qmanifest was given, but libcrypto.pc could not be found])
-    ])
-    AS_IF([test "x${enable_qtegrity}" = "xyes"], [
-      AC_MSG_FAILURE([--enable-qtegrity was given, but libcrypto.pc could not be found])
-    ])
-    LIBSSL="no: missing dependencies"
-  ])
-  AC_MSG_CHECKING([whether to enable qtegrity])
-  AC_MSG_RESULT([${LIBSSL}])
-], [
-  AC_MSG_CHECKING([whether to enable qtegrity])
-  AC_MSG_RESULT([no: disabled by configure argument])
-])
 
 AS_IF([test "x${enable_qmanifest}" != "xno"], [
   PKG_CHECK_MODULES([LIBBL2], [libb2], [
@@ -117,15 +95,10 @@ AS_IF([test "x${enable_qmanifest}" != "xno"], [
 ])
 
 AM_CONDITIONAL([QMANIFEST_ENABLED], [test "x$enable_qmanifest" != xno])
-AM_CONDITIONAL([QTEGRITY_ENABLED], [test "x$enable_qtegrity" != xno])
 if test "x$enable_qmanifest" != xno ; then
 	AC_DEFINE([ENABLE_QMANIFEST], [1],
 			  [Define if qmanifest should be compiled])
 fi
-if test "x$enable_qtegrity" != xno ; then
-	AC_DEFINE([ENABLE_QTEGRITY], [1],
-			  [Define if qtegrity should be compiled])
-fi
 
 AX_CFLAGS_WARN_ALL
 AC_DEFUN([PT_CHECK_CFLAG],[AX_CHECK_COMPILER_FLAGS([$1],[CFLAGS="$CFLAGS $1"])])


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2024-01-01 10:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2024-01-01 10:37 UTC (permalink / raw
  To: gentoo-commits

commit:     13577b18e6ae5f6f1a5abf067d351f2ffc6148cc
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  1 10:33:11 2024 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jan  1 10:36:54 2024 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=13577b18

qlist: avoid truncation of USE-flags in package view

Closes: https://bugs.gentoo.org/921132
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlist.c | 33 +++++++++++----------------------
 1 file changed, 11 insertions(+), 22 deletions(-)

diff --git a/qlist.c b/qlist.c
index 3d09af1..5ca10ca 100644
--- a/qlist.c
+++ b/qlist.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2022 Gentoo Foundation
+ * Copyright 2005-2024 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005 Martin Schlemmer     - <azarah@gentoo.org>
@@ -102,11 +102,9 @@ cmpstringp(const void *p1, const void *p2)
  * -radius -redis -sasl -selinux spf -sqlite -srs ssl -syslog tcpd tpda
  * -X
  */
-static char _umapstr_buf[BUFSIZ];
-static const char *
-umapstr(char display, tree_pkg_ctx *pkg_ctx)
+static void
+umapstr(tree_pkg_ctx *pkg_ctx)
 {
-	char *bufp = _umapstr_buf;
 	char *use = NULL;
 	char *iuse = NULL;
 	int use_argc = 0;
@@ -117,16 +115,12 @@ umapstr(char display, tree_pkg_ctx *pkg_ctx)
 	int u;
 	int d;
 
-	*bufp = '\0';
-	if (!display)
-		return bufp;
-
 	use = tree_pkg_meta_get(pkg_ctx, USE);
 	if (use == NULL || *use == '\0')
-		return bufp;
+		return;
 	iuse = tree_pkg_meta_get(pkg_ctx, IUSE);
 	if (iuse == NULL || *iuse == '\0')
-		return bufp;
+		return;
 
 	/* strip out possible leading +/- flags in IUSE */
 	u = (int)strlen(iuse);
@@ -138,10 +132,6 @@ umapstr(char display, tree_pkg_ctx *pkg_ctx)
 	makeargv(use, &use_argc, &use_argv);
 	makeargv(iuse, &iuse_argc, &iuse_argv);
 
-#define add_to_buf(fmt, Cb, use, Ce) \
-	bufp += snprintf(bufp, sizeof(_umapstr_buf) - (bufp - _umapstr_buf), \
-			" %s" fmt "%s", Cb, use, Ce);
-
 	/* merge join, ensure inputs are sorted (Portage does this, but just
 	 * to be sure) */
 	qsort(&use_argv[1], use_argc - 1, sizeof(char *), cmpstringp);
@@ -161,17 +151,15 @@ umapstr(char display, tree_pkg_ctx *pkg_ctx)
 		}
 
 		if (d == 0) {
-			add_to_buf("%s", RED, iuse_argv[i], NORM);
+			printf(" %s%s%s", RED, iuse_argv[i], NORM);
 			u++;
 		} else if (verbose) {
-			add_to_buf("-%s", DKBLUE, iuse_argv[i], NORM);
+			printf(" %s-%s%s", DKBLUE, iuse_argv[i], NORM);
 		}
 	}
 
 	freeargv(iuse_argc, iuse_argv);
 	freeargv(use_argc, use_argv);
-
-	return _umapstr_buf;
 }
 
 /* forward declaration necessary for misuse from qmerge.c, see HACK there */
@@ -379,9 +367,10 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 	atom = tree_get_atom(pkg_ctx, state->need_full_atom);
 	if (state->just_pkgname) {
-		printf("%s%s\n",
-				atom_format(state->fmt, atom),
-				umapstr(state->show_umap, pkg_ctx));
+		printf("%s", atom_format(state->fmt, atom));
+		if (state->show_umap)
+			umapstr(pkg_ctx);
+		printf("\n");
 
 		return 1;
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2023-12-20 21:32 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2023-12-20 21:32 UTC (permalink / raw
  To: gentoo-commits

commit:     23d47fe0ead50e4a98eb4b1a02f68d350f53a166
Author:     Brian Norris <briannorris <AT> chromium <DOT> org>
AuthorDate: Tue Dec  5 23:19:50 2023 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed Dec 20 21:30:56 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=23d47fe0

qmerge: Send ewarn, etc., to stderr

The PMS specifically calls out that ewarn should not display its message
to stdout. Portage sends all e{log,info,warn,...} to stderr. Imitate
that.

This discrepancy causes problems for ghc-package.eclass users, for one,
as there are instances where that class purposely dumps a warning and
then expects its callers to still use its stdout as a result.

Signed-off-by: Brian Norris <briannorris <AT> chromium.org>
Signed-off-by: Mike Frysinger <vapier <AT> chromium.org>
Signed-off-by: Mike Frysinger <vapier <AT> gentoo.org>

 qmerge.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 246a733..cbf94e6 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -794,8 +794,8 @@ pkg_run_func_at(
 		"has() { hasq \"$@\"; }\n"
 		"hasq() { local h=$1; shift; case \" $* \" in *\" $h \"*) return 0;; *) return 1;; esac; }\n"
 		"hasv() { hasq \"$@\" && echo \"$1\"; }\n"
-		"elog() { printf ' * %%b\\n' \"$*\"; }\n"
-		"einfon() { printf ' * %%b' \"$*\"; }\n"
+		"elog() { printf ' * %%b\\n' \"$*\" >&2; }\n"
+		"einfon() { printf ' * %%b' \"$*\" >&2; }\n"
 		"einfo() { elog \"$@\"; }\n"
 		"ewarn() { elog \"$@\"; }\n"
 		"eqawarn() { elog \"QA: \"\"$@\"; }\n"
@@ -805,8 +805,8 @@ pkg_run_func_at(
 		"fperms() { local f a=$1; shift; for f in \"$@\"; do chmod $a \"${ED}/${f}\"; done; }\n"
 		/* TODO: This should suppress `die` */
 		"nonfatal() { \"$@\"; }\n"
-		"ebegin() { printf ' * %%b ...' \"$*\"; }\n"
-		"eend() { local r=${1:-$?}; [ $# -gt 0 ] && shift; [ $r -eq 0 ] && echo ' [ ok ]' || echo \" $* \"'[ !! ]'; return $r; }\n"
+		"ebegin() { printf ' * %%b ...' \"$*\" >&2; }\n"
+		"eend() { local r=${1:-$?}; [ $# -gt 0 ] && shift; [ $r -eq 0 ] && echo ' [ ok ]' || echo \" $* \"'[ !! ]'; return $r; } >&2\n"
 		"dodir() { mkdir -p \"$@\"; }\n"
 		"keepdir() { dodir \"$@\" && touch \"$@\"/.keep_${CATEGORY}_${PN}-${SLOT%%/*}; }\n"
 		/* TODO: This should be fatal upon error */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2023-07-18  6:28 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2023-07-18  6:28 UTC (permalink / raw
  To: gentoo-commits

commit:     68e1d30bcd977396f1db41be800f0a80ff03467a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Jul 18 06:26:52 2023 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Jul 18 06:26:52 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=68e1d30b

main: init quiet early for repo checks

For as long as we will pre-load all profile information at every q
invocation, respect -q flag so warnings in that code can be suppressed.

Bug: https://bugs.gentoo.org/735134
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 31 +++++++++++++++++++++++--------
 1 file changed, 23 insertions(+), 8 deletions(-)

diff --git a/main.c b/main.c
index 010675e..7225eed 100644
--- a/main.c
+++ b/main.c
@@ -979,14 +979,6 @@ initialize_portage_env(void)
 	const char *configroot = getenv("PORTAGE_CONFIGROOT");
 	char *primary_overlay = NULL;
 
-	/* ensure color strings are initialised, code below here may use
-	 * e.g. warn which uses them */
-	color_clear();
-
-	/* set quiet early in the game, bug #735134 */
-	if (getenv("PORTAGE_QUIET") != NULL)
-		setup_quiet();
-
 	/* initialize all the properties with their default value */
 	for (i = 0; vars_to_read[i].name; ++i) {
 		var = &vars_to_read[i];
@@ -1242,6 +1234,7 @@ int main(int argc, char **argv)
 {
 	struct stat st;
 	struct winsize winsz;
+	int i;
 
 	warnout = stderr;
 	IF_DEBUG(init_coredumps());
@@ -1271,7 +1264,29 @@ int main(int argc, char **argv)
 	}
 	vars_to_read[7].default_value = (char *)nocolor;  /* NOCOLOR */
 
+	/* We can use getopt here, but only in POSIX mode (which stops at
+	 * the first non-option argument) because otherwise argv is
+	 * modified, this basically sulks, because ideally we parse and
+	 * handle the common options here.  Because we are parsing profiles
+	 * and stuff at this point we need -q for bug #735134, so do lame
+	 * matching for that */
+	for (i = 1; i < argc; i++) {
+		if (argv[i] != NULL && argv[i][0] == '-' &&
+			(argv[i][1] == 'q' || strcmp(&argv[i][1], "-quiet") == 0))
+		{
+			setup_quiet();
+		}
+	}
+	/* same for env-based fallback */
+	if (getenv("PORTAGE_QUIET") != NULL)
+		setup_quiet();
+
+	/* ensure color strings are initialised, early code here may use
+	 * e.g. warn which uses them */
+	color_clear();
+
 	initialize_portage_env();
 	optind = 0;
+	quiet  = 0;
 	return q_main(argc, argv);
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2023-07-18  6:28 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2023-07-18  6:28 UTC (permalink / raw
  To: gentoo-commits

commit:     360d18ba7cfbbd285f5ed6d97892778685b8a106
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jul 17 17:29:55 2023 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jul 17 17:29:55 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=360d18ba

initialize_portage_env: init color and quiet defaults early

profile init code may use warn etc so ensure we have colours defined and
quiet setup via fallback

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/main.c b/main.c
index 6ebb9e2..010675e 100644
--- a/main.c
+++ b/main.c
@@ -979,6 +979,14 @@ initialize_portage_env(void)
 	const char *configroot = getenv("PORTAGE_CONFIGROOT");
 	char *primary_overlay = NULL;
 
+	/* ensure color strings are initialised, code below here may use
+	 * e.g. warn which uses them */
+	color_clear();
+
+	/* set quiet early in the game, bug #735134 */
+	if (getenv("PORTAGE_QUIET") != NULL)
+		setup_quiet();
+
 	/* initialize all the properties with their default value */
 	for (i = 0; vars_to_read[i].name; ++i) {
 		var = &vars_to_read[i];
@@ -1221,9 +1229,6 @@ initialize_portage_env(void)
 		}
 	}
 
-	if (getenv("PORTAGE_QUIET") != NULL)
-		setup_quiet();
-
 	if (nocolor) {
 		color_clear();
 		setenv("NOCOLOR", "true", 1);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2023-04-21 19:11 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2023-04-21 19:11 UTC (permalink / raw
  To: gentoo-commits

commit:     b9592db1c04cafcdfaaff8f44ab2d6fc7d6dd5fa
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 21 19:10:23 2023 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Apr 21 19:10:23 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b9592db1

main: silence repo warnings when quiet is set

Bug: https://bugs.gentoo.org/735134
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)

diff --git a/main.c b/main.c
index 111d7ec..6ebb9e2 100644
--- a/main.c
+++ b/main.c
@@ -705,10 +705,13 @@ read_portage_profile(const char *profile, env_vars vars[], set *masks)
 					/* empty repo name means a repo where the profile is */
 					const char* current_overlay = overlay_from_path (profile);
 					if (current_overlay == NULL) {
-						/* bring back the colon to see the ignored parent line */
+						/* bring back the colon to see the ignored
+						 * parent line */
 						*(--p) = ':';
-						warn("could not figure out current repo of profile %s, ignoring parent %s",
-							       profile, s);
+						if (!quiet)
+							warn("could not figure out current repo "
+								 "of profile %s, ignoring parent %s",
+							     profile, s);
 						continue;
 					}
 					snprintf(profile_file, sizeof(profile_file),
@@ -726,10 +729,12 @@ read_portage_profile(const char *profile, env_vars vars[], set *masks)
 						repo_name = NULL;
 					}
 					if (repo_name == NULL) {
-						/* bring back the colon to see the ignored parent line */
+						/* bring back the colon to see the ignored
+						 * parent line */
 						*(--p) = ':';
-						warn("ignoring parent with unknown repo in profile %s: %s",
-								profile, s);
+						if (!quiet)
+							warn("ignoring parent with unknown repo "
+								 "in profile %s: %s", profile, s);
 						continue;
 					}
                                 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2023-03-01 21:00 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2023-03-01 21:00 UTC (permalink / raw
  To: gentoo-commits

commit:     5f5f6983b159b970ad619c4ef53d4b94361d1b5d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Mar  1 20:59:24 2023 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Mar  1 20:59:24 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5f5f6983

main: support NO_COLOR environment variable

NO_COLOR apparently is the more standard version of NOCOLOR.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/main.c b/main.c
index b22d6f4..111d7ec 100644
--- a/main.c
+++ b/main.c
@@ -1052,6 +1052,12 @@ initialize_portage_env(void)
 			set_portage_env_var(var, s, var->name);
 	}
 
+	/* special snowflake, NO_COLOR is apparently some standard now,
+	 * accept it (as override of NOCOLOR) */
+	s = getenv("NO_COLOR");
+	if (s != NULL)
+		set_portage_env_var(&vars_to_read[7], s, "NO_COLOR");
+
 	/* expand any nested variables e.g. PORTDIR=${EPREFIX}/usr/portage */
 	for (i = 0; vars_to_read[i].name; ++i) {
 		char *svar;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2023-02-22 20:06 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2023-02-22 20:06 UTC (permalink / raw
  To: gentoo-commits

commit:     60b48bf693d25a5a7b09199f9756310b5d7209bf
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Feb  7 08:31:42 2023 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Feb  7 08:31:42 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=60b48bf6

main: workaround hypothetical resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 884d6da..b22d6f4 100644
--- a/main.c
+++ b/main.c
@@ -584,12 +584,12 @@ read_portage_file(const char *file, enum portage_file_type type, void *data)
 				void *e;
 				snprintf(npath, sizeof(npath), "%s:%zu:%zu-%zu",
 						file, line, cbeg, cend);
-				p = xstrdup(npath);
 				/* if not necessary, but do it for static code analysers
 				 * which take into accound that add_set_value might
 				 * allocate a new set when masks would be NULL -- a case
 				 * which would never happen */
 				if (masks != NULL) {
+					p = xstrdup(npath);
 					add_set_value(buf, p, &e, masks);
 					if (e != NULL)
 						free(p);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2023-02-07  8:10 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2023-02-07  8:10 UTC (permalink / raw
  To: gentoo-commits

commit:     1102e2e474a24cffa6cab5118ab757b89ebf5be7
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Feb  7 07:32:13 2023 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Feb  7 07:32:13 2023 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1102e2e4

qmerge: add some braindump notes about how things could be

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 94 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 94 insertions(+)

diff --git a/qmerge.c b/qmerge.c
index 18fdbb5..246a733 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -47,6 +47,100 @@
   --noscript                       don't execute pkg_{pre,post}{inst,rm} (if any)
 */
 
+/* How things should work, ideally.  This is not how it currently is
+ * implemented at all.
+ *
+ * invocation: qmerge ... pkg/a pkg/b pkg/c
+ * initial mergeset: pkg/a pkg/b pkg/c
+ * resolving:
+ * - for pkg, get dependencies
+ *   * apply masks
+ *   * extract depend, rdepend, bdepend, etc.
+ *   * filter flags in use (libq/dep)
+ *   * add found pkgs to mergeset if not present in resolvedset
+ * - while mergeset contains pkgs
+ *   * resolve pkg (see above)
+ *   * move from mergeset to resolvedset
+ * here (if all is well) mergeset is empty, and resolvedset contains the
+ * pkgs to be installed.  If for instance pkg/c depends on pkg/b it
+ * won't occur double, for it is a set.
+ *
+ * Technically, because we deal with binpkgs, we don't have
+ * dependencies, but there can be pre/post scripts that actually use
+ * depended on pkgs, and if we would invoke ebuild(5) to compile instead
+ * of unpack, we would respect the order too, so the resolvedset here
+ * needs to be ordered into a list.
+ * While functionally one can re-evaluate the dependencies here,
+ * implementation wise, it probably is easier to build the final merge
+ * order list while resolving.  This can also add the additional
+ * metadata of whether a pkg was requested (cmdline) or pulled in a dep,
+ * and for which package.  That information can be leveraged to draw a
+ * tree (visuals) but also to determine possible parallel installation
+ * paths.
+ *
+ * For example, original invocation could lead to a resolved merge list
+ * of:
+ *   M pkg/a
+ *   m  pkg/d
+ *   R pkg/c
+ *   M  pkg/b
+ *
+ * After this, the pkgs need to be fetched and the pre phases need to be
+ * run.  In interactive mode, a question probably needs to be inserted
+ * after the printing of the resolved merge list.  Then if all checks
+ * out, the unpack and merge to live fs + vdb updates can be performed.
+ * Ideally the unpack (or compile via ebuild(5)) phase is separated from
+ * the final merge to live fs.  The latter always has to be serial, but
+ * the former can run in parallel based on dependencies seen.  For
+ * our example, pkg/d and pkg/b can be unpacked in parallel, merged in
+ * which order finished first, then pkg/a and pkg/c can commence.  So
+ * the start set is pkg/d and pkg/b, and each unlocks pkg/a and pkg/c
+ * respectively, which are not constrained, other than the final merge
+ * logic.
+ *
+ * Errors
+ * There are multiple kinds of errors in multiple stages.  Whether they
+ * are fatal depends on a number of factors.
+ * - resolution error
+ *   Failing to resolve an atom basically makes the tree that that pkg
+ *   is part of unmergable; that is, it needs to be discarded from the
+ *   workset.  In interactive mode after resolving we could ask if the
+ *   user wants to continue (if there's anything else we *can* do),
+ *   non-interactive we could decide to just go ahead with whatever we
+ *   was possible, unless we add a flag that stops at resolution errors.
+ * - USE-dep resolution error
+ *   The state of USE-flags must be respected, and can cause problems,
+ *   in particular cyclic dependencies.  Solution to those is to disable
+ *   USE-flags temporary and re-merge without.  For now, these errors
+ *   are not resolved, but should be detected and treated as resolution
+ *   errors above.
+ * - fetch error
+ *   Either because fetching the binpkg or the source files fails.  This
+ *   discards the atom and its tree.  It may be possible in this case to
+ *   try and re-resolve using an older version of the pkg.  But since
+ *   this kind of error is pretty much in the foundation of the work, it
+ *   seems more logical to exclude the tree the package belongs too,
+ *   because at this point parallel execution happens, it makes no sense
+ *   any more to ask the user to abort.
+ * - unpack or merge error
+ *   Under these errors are the failures in the various pkg checks (run
+ *   phases) and for source-based installs obviously compilation
+ *   failures.  These discard an entire tree, and like fetch errors,
+ *   we don't have a clear opportunity anymore to ask whether or not to
+ *   continue.
+ * - live fs + vdb error
+ *   This should be rare, but most probably filesystem related errors,
+ *   such as running out of diskspace or lacking certain permissions.
+ *   Corrupting the VDB hopefully doesn't happen, but it is possible to
+ *   encounter problems there as well.  Like fetch and unpack errors, we
+ *   should try to continue with whatever we can, but will not roll-back
+ *   already merged packages.  So a failure here, should result in
+ *   dropping all children from the failed pkg.
+ *
+ * After merging qlop -Ev should show whatever was merged successfully,
+ * so qmerge should show what failed to merge (in what stage).
+ */
+
 /* #define BUSYBOX "/bin/busybox" */
 #define BUSYBOX ""
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-12-15  9:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-12-15  9:13 UTC (permalink / raw
  To: gentoo-commits

commit:     25853d2ea35884a7f4cf6fefa2a2c53610fc6164
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 15 09:12:10 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Dec 15 09:12:10 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=25853d2e

qkeyword: gracefully handle case with no found arches

Bug: https://bugs.gentoo.org/885801
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qkeyword.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/qkeyword.c b/qkeyword.c
index f6cdbc2..0989e20 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2020 Gentoo Foundation
+ * Copyright 2005-2022 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2006      Thomas A. Cort - <tcort@gentoo.org>
@@ -785,6 +785,12 @@ qkeyword_traverse(tree_pkg_cb func, void *priv)
 	array_for_each(overlays, n, overlay)
 		qkeyword_load_arches(overlay);
 
+	if (archlist_count == 0 || archlist == NULL) {
+		warnf("no arches could be found in your active overlays (see q -o), "
+			  "do you have profiles/arch.list files present?\n");
+		return EXIT_FAILURE;
+	}
+
 	/* allocate memory (once) for the list used by various funcs */
 	if (archlist_count > data->keywordsbuflen) {
 		data->keywordsbuf = xrealloc(data->keywordsbuf,


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-12-15  9:03 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-12-15  9:03 UTC (permalink / raw
  To: gentoo-commits

commit:     8f7064fdf7aa08e00bb24e5e479c1df4be9ae5e7
Author:     Krzesimir Nowak <knowak <AT> microsoft <DOT> com>
AuthorDate: Wed Dec 14 11:53:33 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Dec 15 09:02:42 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8f7064fd

main: Handle empty repo names in parent files

Empty repo name is documented in portage(5).

Signed-off-by: Krzesimir Nowak <knowak <AT> microsoft.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 105 +++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 89 insertions(+), 16 deletions(-)

diff --git a/main.c b/main.c
index f6a39f9..347a50b 100644
--- a/main.c
+++ b/main.c
@@ -598,6 +598,65 @@ read_portage_file(const char *file, enum portage_file_type type, void *data)
 		fprintf(stderr, "read profile %s\n", file);
 }
 
+/* Helper to check if a string starts with a prefix. If so, returns
+ * true and gets the length of the prefix. Otherwise returns false,
+ * leaving the prefix length unmodified. */
+static bool
+starts_with(const char *str, const char *prefix, size_t *prefix_len)
+{
+	const char *s;
+	const char *p;
+	size_t len;
+
+	if (prefix == NULL) {
+		/* every string starts with a null string */
+		if (prefix_len != NULL)
+			*prefix_len = 0;
+		return true;
+	}
+	if (str == NULL)
+		/* null string only starts with a null string, and prefix isn't null */
+		return false;
+
+	len = 0;
+	for (s = str, p = prefix; *s != '\0' && *p != '\0'; ++s, ++p, ++len) {
+		if (*s != *p)
+			return false;
+	}
+	if (*p == '\0') {
+		if (prefix_len != NULL)
+			*prefix_len = len;
+		return true;
+	}
+	return false;
+}
+
+/* Helper to figure out inside of which overlay a path is. Returns
+ * null if nonesuch is found. */
+static const char *
+overlay_from_path (const char *path)
+{
+	size_t n;
+	char *overlay;
+	size_t max_match = 0;
+	const char *found_overlay = NULL;
+
+	array_for_each(overlays, n, overlay) {
+		size_t overlay_len;
+
+		if (!starts_with(path, overlay, &overlay_len))
+			continue;
+
+		if (overlay_len <= max_match)
+			continue;
+
+		max_match = overlay_len;
+		found_overlay = overlay;
+	}
+
+	return found_overlay;
+}
+
 /* Helper to recursively read stacked make.defaults in profiles */
 static void
 read_portage_profile(const char *profile, env_vars vars[], set *masks)
@@ -634,24 +693,38 @@ read_portage_profile(const char *profile, env_vars vars[], set *masks)
 				/* 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 (s[0] == '\0') {
+					/* empty repo name means a repo where the profile is */
+					const char* current_overlay = overlay_from_path (profile);
+					if (current_overlay == NULL) {
+						/* bring back the colon to see the ignored parent line */
+						*(--p) = ':';
+						warn("could not figure out current repo of profile %s, ignoring parent %s",
+							       profile, s);
+						continue;
 					}
+					snprintf(profile_file, sizeof(profile_file),
+							"%s/profiles/%s", current_overlay, p);
+				} else {
+					/* match the repo */
 					repo_name = NULL;
-				}
-				if (repo_name == NULL) {
-					/* bring back the colon to see the ignored parent line */
-					*(--p) = ':';
-					warn("ignoring parent with unknown repo in profile %s: %s",
-							profile, s);
-					continue;
-				}
+					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) {
+						/* bring back the colon to see the ignored parent line */
+						*(--p) = ':';
+						warn("ignoring parent with unknown repo in profile %s: %s",
+								profile, s);
+						continue;
+					}
+                                }
 			} else {
 				snprintf(profile_file + profile_len,
 						sizeof(profile_file) - profile_len, "%s", s);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-12-15  9:03 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-12-15  9:03 UTC (permalink / raw
  To: gentoo-commits

commit:     9c67a37fc7709c9e314bc56ccdf7727bee02fc92
Author:     Krzesimir Nowak <knowak <AT> microsoft <DOT> com>
AuthorDate: Wed Dec 14 11:52:25 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Dec 15 09:02:33 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9c67a37f

main: Print the ignored parent line in warning

If repo name in the parent line was empty, nothing was printed.

Signed-off-by: Krzesimir Nowak <knowak <AT> microsoft.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/main.c b/main.c
index 809a085..f6a39f9 100644
--- a/main.c
+++ b/main.c
@@ -646,6 +646,8 @@ read_portage_profile(const char *profile, env_vars vars[], set *masks)
 					repo_name = NULL;
 				}
 				if (repo_name == NULL) {
+					/* bring back the colon to see the ignored parent line */
+					*(--p) = ':';
 					warn("ignoring parent with unknown repo in profile %s: %s",
 							profile, s);
 					continue;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-11-16  8:59 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-11-16  8:59 UTC (permalink / raw
  To: gentoo-commits

commit:     72f679853cbec7a34a358e9c67f70b672ee86bee
Author:     sfrolov <sfrolov <AT> google <DOT> com>
AuthorDate: Wed Nov 16 08:53:37 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Nov 16 08:53:37 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=72f67985

qmerge: set EBUILD_PHASE_FUNC

EBUILD_PHASE_FUNC is a variable that contains an exact phase function
name. It was added in https://bugs.gentoo.org/show_bug.cgi?id=390765

Bug: https://bugs.gentoo.org/880867
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qmerge.c b/qmerge.c
index 80affdb..18fdbb5 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -724,6 +724,7 @@ pkg_run_func_at(
 		/* Load the main env */
 		". \"%6$s/environment\"\n"
 		/* Reload env vars that matter to us */
+		"export EBUILD_PHASE_FUNC='%2$s'\n"
 		"export FILESDIR=/.does/not/exist/anywhere\n"
 		"export MERGE_TYPE=binary\n"
 		"export ROOT='%4$s'\n"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-08-29  8:44 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-08-29  8:44 UTC (permalink / raw
  To: gentoo-commits

commit:     65e96f9106c5e74d5943b820fe0643714ca192e2
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 29 08:44:12 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Aug 29 08:44:12 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=65e96f91

build-sys: regenerate

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 config.h.in |  6 ++++++
 configure   | 10 ++++++++++
 2 files changed, 16 insertions(+)

diff --git a/config.h.in b/config.h.in
index a9871ea..da59340 100644
--- a/config.h.in
+++ b/config.h.in
@@ -54,6 +54,12 @@
 /* Define to 1 if // is a file system root distinct from /. */
 #undef DOUBLE_SLASH_IS_DISTINCT_ROOT
 
+/* Define if qmanifest should be compiled */
+#undef ENABLE_QMANIFEST
+
+/* Define if qtegrity should be compiled */
+#undef ENABLE_QTEGRITY
+
 /* Define this to 1 if F_DUPFD behavior does not match POSIX */
 #undef FCNTL_DUPFD_BUGGY
 

diff --git a/configure b/configure
index 32304a1..19ec19c 100755
--- a/configure
+++ b/configure
@@ -32901,6 +32901,16 @@ else
   QTEGRITY_ENABLED_FALSE=
 fi
 
+if test "x$enable_qmanifest" != xno ; then
+
+printf "%s\n" "#define ENABLE_QMANIFEST 1" >>confdefs.h
+
+fi
+if test "x$enable_qtegrity" != xno ; then
+
+printf "%s\n" "#define ENABLE_QTEGRITY 1" >>confdefs.h
+
+fi
 
     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler vendor" >&5
 printf %s "checking for C compiler vendor... " >&6; }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-08-29  8:44 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-08-29  8:44 UTC (permalink / raw
  To: gentoo-commits

commit:     efff7e86cececb54493a2d5f9210ffa72651d8ce
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 29 08:10:08 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Aug 29 08:10:08 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=efff7e86

configure.ac: set ENABLE_QTEGRITY/ENABLE_QMANIFEST again

regression introduced by b81049495052e953941fc21f6936fbb968a3462a

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 configure.ac | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/configure.ac b/configure.ac
index 9f892c6..c26848a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -118,6 +118,14 @@ AS_IF([test "x${enable_qmanifest}" != "xno"], [
 
 AM_CONDITIONAL([QMANIFEST_ENABLED], [test "x$enable_qmanifest" != xno])
 AM_CONDITIONAL([QTEGRITY_ENABLED], [test "x$enable_qtegrity" != xno])
+if test "x$enable_qmanifest" != xno ; then
+	AC_DEFINE([ENABLE_QMANIFEST], [1],
+			  [Define if qmanifest should be compiled])
+fi
+if test "x$enable_qtegrity" != xno ; then
+	AC_DEFINE([ENABLE_QTEGRITY], [1],
+			  [Define if qtegrity should be compiled])
+fi
 
 AX_CFLAGS_WARN_ALL
 AC_DEFUN([PT_CHECK_CFLAG],[AX_CHECK_COMPILER_FLAGS([$1],[CFLAGS="$CFLAGS $1"])])


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-08-28 12:26 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-08-28 12:26 UTC (permalink / raw
  To: gentoo-commits

commit:     b81049495052e953941fc21f6936fbb968a3462a
Author:     David Seifert <soap <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 28 11:40:30 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Aug 28 11:50:42 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b8104949

Use pkg-config for dependencies

Signed-off-by: David Seifert <soap <AT> gentoo.org>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 Makefile.am  |   9 ++--
 configure.ac | 161 ++++++++++++++++++++++++-----------------------------------
 2 files changed, 70 insertions(+), 100 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 90c868b..13a6044 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -73,14 +73,17 @@ q_CPPFLAGS = \
 	-I$(top_builddir)/autotools/gnulib \
 	-I$(top_srcdir)/autotools/gnulib \
 	$(OPENMP_CFLAGS) \
+	$(LIBSSL_CFLAGS) \
+	$(LIBBL2_CFLAGS) \
+	$(LIBZ_CFLAGS) \
 	$(NULL)
 q_LDADD = \
 	$(top_builddir)/libq/libq.la \
 	$(top_builddir)/autotools/gnulib/libgnu.a \
 	$(OPENMP_CFLAGS) \
-	$(LIBSSL) \
-	$(LIBBL2) \
-	$(LIBZ) \
+	$(LIBSSL_LIBS) \
+	$(LIBBL2_LIBS) \
+	$(LIBZ_LIBS) \
 	$(GPGME_LIBS) \
 	$(LIB_CLOCK_GETTIME) \
 	$(LIB_EACCESS) \

diff --git a/configure.ac b/configure.ac
index de9e60c..5378795 100644
--- a/configure.ac
+++ b/configure.ac
@@ -52,104 +52,71 @@ AC_DEFINE_UNQUOTED([CONFIG_EPREFIX], ["$with_eprefix"],
 AC_SUBST([CONFIG_EPREFIX], ["$with_eprefix"])
 
 AC_ARG_ENABLE([qmanifest], [AS_HELP_STRING([--enable-qmanifest],
-			  [support qmanifest applet])],
-			  [], [enable_qmanifest=auto])
+			  [support qmanifest applet])])
 AC_ARG_ENABLE([qtegrity], [AS_HELP_STRING([--enable-qtegrity],
-			  [support qtegrity applet])],
-			  [], [enable_qtegrity=auto])
-LIBSSL=
-LIBBL2=
-LIBZ=
-HASGPGME=
-
-AS_IF([test "x${enable_qmanifest}x${enable_qtegrity}" != xnoxno],
-	  [AC_CHECK_HEADERS([openssl/err.h \
-	                     openssl/ssl.h], [], [LIBSSL=_missing_header])
-	   AC_CHECK_LIB([ssl${LIBSSL}], [SSL_connect],
-					[LIBSSL="-lssl"
-					 AC_DEFINE([HAVE_SSL], [1], [Define if you have ssl])
-					 AC_CHECK_LIB([crypto],
-								  [ERR_reason_error_string],
-								  [LIBSSL="${LIBSSL} -lcrypto"],
-								  [])
-					 AC_SUBST([LIBSSL], ["${LIBSSL}"])
-					],
-					[if test "x$enable_qmanifest" != xauto; then
-					 AC_MSG_FAILURE(
-					   [--enable-qmanifest was given, but test for ssl failed])
-					 fi
-					 if test "x$enable_qtegrity" != xauto; then
-					 AC_MSG_FAILURE(
-					   [--enable-qtegrity was given, but test for ssl failed])
-					 fi
-					 LIBSSL=
-					])
-	   AC_MSG_CHECKING([whether to enable qtegrity])
-	   case "x${LIBSSL}" in
-		   "x-lssl"*)
-				AC_MSG_RESULT([yes])
-				;;
-		   *)
-			   enable_qtegrity=no
-			   AC_MSG_RESULT([no: missing dependencies])
-			   ;;
-	   esac
-	   if test "x$enable_qtegrity" != xno ; then
-		   AC_DEFINE([ENABLE_QTEGRITY], [1],
-					 [Define if qtegrity should be compiled])
-	   fi
-	],
-	[
-	   AC_MSG_CHECKING([whether to enable qtegrity])
-	   AC_MSG_RESULT([no: disabled by configure argument])
-	])
-AS_IF([test "x$enable_qmanifest" != xno],
-	  [AC_CHECK_HEADERS([blake2.h], [], [LIBBL2=_missing_header])
-	   AC_CHECK_LIB([b2${LIBBL2}], [blake2b_update],
-					[LIBBL2="-lb2"
-					 AC_DEFINE([HAVE_BLAKE2B], [1],
-							   [Define if you have blake2b])
-					 AC_SUBST([LIBBL2], ["${LIBBL2}"])
-					],
-					[if test "x$enable_qmanifest" != xauto; then
-					 AC_MSG_FAILURE(
-					   [--enable-qmanifest was given, but test for blake2b failed])
-					 fi
-					 LIBBL2=
-					])
-	   AC_CHECK_HEADERS([zlib.h], [], [LIBZ=_missing_header])
-	   AC_CHECK_LIB([z${LIBZ}], [gzopen],
-					[LIBZ="-lz"
-					 AC_DEFINE([HAVE_LIBZ], [1],
-							   [Define if you have zlib])
-					 AC_SUBST([LIBZ], ["${LIBZ}"])
-					],
-					[if test "x$enable_qmanifest" != xauto; then
-					 AC_MSG_FAILURE(
-					   [--enable-qmanifest was given, but test for libz failed])
-					 fi
-					 LIBZ=
-					])
-	   AM_PATH_GPGME([], [HASGPGME=yes])
-	   AC_MSG_CHECKING([whether to enable qmanifest])
-	   case "x${LIBSSL}${LIBBL2}${LIBZ}-${HASGPGME}" in
-		   "x-lssl"*"-lb2-lz-yes")
-				AC_MSG_RESULT([yes])
-				;;
-		   *)
-			   enable_qmanifest=no
-			   AC_MSG_RESULT([no: missing dependencies])
-			   ;;
-	   esac
-	   if test "x$enable_qmanifest" != xno ; then
-		   AC_DEFINE([ENABLE_QMANIFEST], [1],
-					 [Define if qmanifest should be compiled])
-	   fi
-	],
-	[
-	   AC_MSG_CHECKING([whether to enable qmanifest])
-	   AC_MSG_RESULT([no: disabled by configure argument])
-	])
+			  [support qtegrity applet])])
+
+AS_IF([test "x${enable_qmanifest}${enable_qtegrity}" != "xnono"], [
+  PKG_CHECK_MODULES([LIBSSL], [libcrypto], [
+    AC_DEFINE([HAVE_SSL], [1], [Define if you have ssl])
+    LIBSSL="yes"
+  ], [
+    AS_IF([test "x${enable_qmanifest}" = "xyes"], [
+      AC_MSG_FAILURE([--enable-qmanifest was given, but libcrypto.pc could not be found])
+    ])
+    AS_IF([test "x${enable_qtegrity}" = "xyes"], [
+      AC_MSG_FAILURE([--enable-qtegrity was given, but libcrypto.pc could not be found])
+    ])
+    LIBSSL="no: missing dependencies"
+  ])
+  AC_MSG_CHECKING([whether to enable qtegrity])
+  AC_MSG_RESULT([${LIBSSL}])
+], [
+  AC_MSG_CHECKING([whether to enable qtegrity])
+  AC_MSG_RESULT([no: disabled by configure argument])
+])
+
+AS_IF([test "x${enable_qmanifest}" != "xno"], [
+  PKG_CHECK_MODULES([LIBBL2], [libb2], [
+    AC_DEFINE([HAVE_BLAKE2B], [1], [Define if you have blake2b])
+    LIBBL2="yes"
+  ], [
+    AS_IF([test "x${enable_qmanifest}" = "xyes"], [
+      AC_MSG_FAILURE([--enable-qmanifest was given, but libb2.pc could not be found])
+    ])
+    LIBBL2="no: missing dependencies"
+  ])
+
+  PKG_CHECK_MODULES([LIBZ], [zlib], [
+    AC_DEFINE([HAVE_LIBZ], [1], [Define if you have zlib])
+    LIBZ="yes"
+  ], [
+    AS_IF([test "x${enable_qmanifest}" = "xyes"], [
+      AC_MSG_FAILURE([--enable-qmanifest was given, but zlib.pc could not be found])
+    ])
+    LIBZ="no: missing dependencies"
+  ])
+
+  PKG_CHECK_MODULES([GPGME], [gpgme], [
+    GPGME="yes"
+  ], [
+    AS_IF([test "x${enable_qmanifest}" = "xyes"], [
+      AC_MSG_FAILURE([--enable-qmanifest was given, but gpgme.pc could not be found])
+    ])
+    GPGME="no: missing dependencies"
+  ])
+
+  AC_MSG_CHECKING([whether to enable qmanifest])
+  AS_IF([test "x${LIBBL2}${LIBZ}${GPGME}" = "xyesyesyes"], [
+    AC_MSG_RESULT([yes])
+  ], [
+    AC_MSG_RESULT([no: missing dependencies])
+  ])
+], [
+  AC_MSG_CHECKING([whether to enable qmanifest])
+  AC_MSG_RESULT([no: disabled by configure argument])
+])
+
 AM_CONDITIONAL([QMANIFEST_ENABLED], [test "x$enable_qmanifest" != xno])
 AM_CONDITIONAL([QTEGRITY_ENABLED], [test "x$enable_qtegrity" != xno])
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-08-28 12:26 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-08-28 12:26 UTC (permalink / raw
  To: gentoo-commits

commit:     e2b0dfcb3a678f74454fd2b651dd3aab0b5539ae
Author:     David Seifert <soap <AT> gentoo <DOT> org>
AuthorDate: Sun Aug 28 11:40:29 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Aug 28 11:50:11 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e2b0dfcb

Use Automake in `foreign` mode

* Otherwise we get errors such as
    Makefile.am: error: required file './AUTHORS' not found
    Makefile.am: error: required file './ChangeLog' not found
    Makefile.am: error: required file './NEWS' not found

Signed-off-by: David Seifert <soap <AT> gentoo.org>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 013e831..de9e60c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,7 +6,7 @@
 
 AC_PREREQ([2.71])
 AC_INIT([portage-utils],[git])
-AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip silent-rules -Wall])
+AM_INIT_AUTOMAKE([1.11 dist-xz foreign no-dist-gzip silent-rules -Wall])
 AM_SILENT_RULES([yes]) # AM_INIT_AUTOMAKE([silent-rules]) is broken atm
 AM_MAINTAINER_MODE([enable])
 AC_CONFIG_HEADERS([config.h])


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-06-14  6:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-06-14  6:36 UTC (permalink / raw
  To: gentoo-commits

commit:     2100df5c171029d6c347650fdaf098b67df0f059
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 14 06:35:35 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Jun 14 06:35:35 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2100df5c

main: ensure correct parsing of key-value pairs in ini-files

Ensure the key is terminated when the '=' is adjacent to it (without
whitespace).

Bug: https://bugs.gentoo.org/851138
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/main.c b/main.c
index 1337cb0..809a085 100644
--- a/main.c
+++ b/main.c
@@ -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
  *
  * Copyright 2005-2008 Ned Ludd        - <solar@gentoo.org>
@@ -747,7 +747,8 @@ read_one_repos_conf(const char *repos_conf, char **primary)
 	repo = NULL;
 	for (p = strtok_r(buf, "\n", &s); p != NULL; p = strtok_r(NULL, "\n", &s))
 	{
-		/* trim trailing whitespace, remove comments, locate = */
+		/* trim trailing whitespace, remove comments, locate =, walking
+		 * backwards to the front of the string */
 		do_trim = true;
 		e = NULL;
 		for (r = q = s - 2; q >= p; q--) {
@@ -785,7 +786,7 @@ read_one_repos_conf(const char *repos_conf, char **primary)
 		for (r = e - 1; r >= p && isspace((int)*r); r--)
 			*r = '\0';
 		/* and after the = */
-		for (e++; e < q && isspace((int)*e); e++)
+		for (*e++ = '\0'; e < q && isspace((int)*e); e++)
 			;
 
 		if (is_default && strcmp(p, "main-repo") == 0) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-05-26 14:53 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-05-26 14:53 UTC (permalink / raw
  To: gentoo-commits

commit:     fd7528a6b55e824872bfe79415d2ddae5948ca5e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May 26 14:50:16 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May 26 14:50:16 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=fd7528a6

qdepends: plug Coverity CID 269971 (resource leak)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qdepends.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index bd7c379..f222011 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -199,11 +199,13 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 							             tree_pkg_meta_get(vpkg, BDEPEND);
 					if (depstr != NULL) {
 						dep_node *dep_vdb = dep_grow_tree(depstr);
-						if (dep_vdb != NULL)
+						if (dep_vdb != NULL) {
 							dep_flatten_tree(dep_vdb, state->deps);
-						else
+							dep_burn_tree(dep_vdb);
+						} else {
 							warn("failed to parse VDB depstring from %s\n",
-									atom_to_string(datom));
+								 atom_to_string(datom));
+						}
 					}
 					tree_close_pkg(vpkg);
 				}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-05-20 17:15 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-05-20 17:15 UTC (permalink / raw
  To: gentoo-commits

commit:     4f3a79cc3e9399a723dc0a08c4122ed12e2f1001
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 20 17:02:14 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 20 17:02:14 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4f3a79cc

qlist: print BUILD_ID for binpkgs (if any)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlist.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/qlist.c b/qlist.c
index 318ae3d..3d09af1 100644
--- a/qlist.c
+++ b/qlist.c
@@ -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
  *
  * Copyright 2005 Martin Schlemmer     - <azarah@gentoo.org>
@@ -501,11 +501,15 @@ int qlist_main(int argc, char **argv)
 		}
 		snprintf(qfmt, sizeof(qfmt), "%sCATEGORY%s"
 				"%s%s%s"   /* PN/PF */
+				"%s%s%s"   /* BUILDID */
 				"%s%s%s"   /* SLOT */
 				"%s%s%s"   /* SUBSLOT */
 				"%s%s%s",  /* REPO */
 				l, r,
 				l, verbose ? "PF" : "PN", r,
+				verbose && state.do_binpkgs ? l : "",
+					verbose && state.do_binpkgs ? "BUILDID" : "",
+					verbose && state.do_binpkgs ? r : "",
 				show_slots >= 1 ? l : "",
 					show_slots >= 1 ? "SLOT" : "",
 					show_slots >= 1 ? r : "",


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-04-06 19:31 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-04-06 19:31 UTC (permalink / raw
  To: gentoo-commits

commit:     a9476140700f50fa3d1cae79e7aed8d019591197
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Apr  6 19:20:24 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Apr  6 19:20:24 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a9476140

qdepends: make USE-flag filtering opt-in via -U flag

Filtering deps based on USE-flags defined in the profile is kind of
misleading, especially when doing things like qdepends -t -Q <dep>,
where one would probably not expect the local USE-configuration to
exclude matches.

Bug: https://bugs.gentoo.org/836590
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qdepends.c | 24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index 96a791c..f1bc3ad 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -22,7 +22,7 @@
 #include "xasprintf.h"
 #include "xregex.h"
 
-#define QDEPENDS_FLAGS "drpbQitF:S" COMMON_FLAGS
+#define QDEPENDS_FLAGS "drpbQitUF:S" COMMON_FLAGS
 static struct option const qdepends_long_opts[] = {
 	{"depend",    no_argument, NULL, 'd'},
 	{"rdepend",   no_argument, NULL, 'r'},
@@ -31,6 +31,7 @@ static struct option const qdepends_long_opts[] = {
 	{"query",     no_argument, NULL, 'Q'},
 	{"installed", no_argument, NULL, 'i'},
 	{"tree",      no_argument, NULL, 't'},
+	{"use",       no_argument, NULL, 'U'},
 	{"format",     a_argument, NULL, 'F'},
 	{"pretty",    no_argument, NULL, 'S'},
 	COMMON_LONG_OPTS
@@ -43,6 +44,7 @@ static const char * const qdepends_opts_help[] = {
 	"Query reverse deps",
 	"Search installed packages using VDB",
 	"Search available ebuilds in the tree",
+	"Apply profile USE-flags to conditional deps",
 	"Print matched atom using given format string",
 	"Pretty format specified depend strings",
 	COMMON_OPTS_HELP
@@ -51,7 +53,7 @@ static const char * const qdepends_opts_help[] = {
 
 /* structures / types / etc ... */
 struct qdepends_opt_state {
-	unsigned char qmode;
+	unsigned int qmode;
 	array_t *atoms;
 	array_t *deps;
 	set *udeps;
@@ -68,6 +70,7 @@ struct qdepends_opt_state {
 #define QMODE_INSTALLED  (1<<5)
 #define QMODE_TREE       (1<<6)
 #define QMODE_REVERSE    (1<<7)
+#define QMODE_FILTERUSE  (1<<8)
 
 const char *depend_files[] = {  /* keep *DEPEND aligned with above defines */
 	/* 0 */ "DEPEND",
@@ -171,7 +174,10 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 			continue;
 		}
 
-		if (state->qmode & QMODE_TREE && verbose) {
+		if (state->qmode & QMODE_TREE &&
+			!(state->qmode & QMODE_REVERSE) &&
+			verbose)
+		{
 			/* pull in flags in use if possible */
 			tree_cat_ctx *vcat =
 				tree_open_cat(state->vdb, pkg_ctx->cat_ctx->name);
@@ -196,15 +202,16 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				tree_close_cat(vcat);
 			}
 		} else {
-			dep_prune_use(dep_tree, ev_use);
+			if (state->qmode & QMODE_FILTERUSE)
+				dep_prune_use(dep_tree, ev_use);
 			dep_flatten_tree(dep_tree, state->deps);
 		}
 
 		if (verbose) {
 			if (state->qmode & QMODE_REVERSE) {
-				array_for_each(state->atoms, m, atom) {
-					array_for_each(state->deps, n, fatom) {
-						if (atom_compare(fatom, atom) == EQUAL) {
+				array_for_each(state->deps, m, atom) {
+					array_for_each(state->atoms, n, fatom) {
+						if (atom_compare(atom, fatom) == EQUAL) {
 							fatom = NULL;
 							break;
 						}
@@ -319,6 +326,7 @@ int qdepends_main(int argc, char **argv)
 		case 'Q': state.qmode |= QMODE_REVERSE;   break;
 		case 'i': state.qmode |= QMODE_INSTALLED; break;
 		case 't': state.qmode |= QMODE_TREE;      break;
+		case 'U': state.qmode |= QMODE_FILTERUSE; break;
 		case 'S': do_pretty = true;               break;
 		case 'F': state.format = optarg;          break;
 		}
@@ -336,7 +344,7 @@ int qdepends_main(int argc, char **argv)
 	if (!(state.qmode & QMODE_INSTALLED) && !(state.qmode & QMODE_TREE))
 		state.qmode |= QMODE_INSTALLED;
 
-	/* don't allow both installed and froim tree */
+	/* don't allow both installed and from tree */
 	if (state.qmode & QMODE_INSTALLED && state.qmode & QMODE_TREE) {
 		warn("-i and -t cannot be used together, dropping -i");
 		state.qmode &= ~QMODE_INSTALLED;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-27 12:29 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-27 12:29 UTC (permalink / raw
  To: gentoo-commits

commit:     dce9191f98e008047dec606f606d5f0c6cf093b4
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 27 12:22:40 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Feb 27 12:22:40 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=dce9191f

gitignore: do NOT ignore gnulib files

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .gitignore | 2 --
 1 file changed, 2 deletions(-)

diff --git a/.gitignore b/.gitignore
index 2a20d1d..a30c12d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,8 +30,6 @@ libtool
 stamp-h1
 INSTALL
 Makefile
-/autotools/gnulib/*.h
-/autotools/gnulib/sys
 /tests/init.sh
 /tests/qmanifest/root/.gnupg/random_seed
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-23 11:57 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-23 11:57 UTC (permalink / raw
  To: gentoo-commits

commit:     b59cdb9849c6528922664fcc1c07537ac71e05b1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 23 11:55:55 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Feb 23 11:55:55 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b59cdb98

qlop: fix date parsing of epochs on musl

%s isn't a valid modifier in POSIX for strptime, so parse the number
manually and produce a time out of that.

Bug: https://bugs.gentoo.org/833942
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/qlop.c b/qlop.c
index addb4b3..16bf69f 100644
--- a/qlop.c
+++ b/qlop.c
@@ -126,18 +126,18 @@ parse_date(const char *sdate, time_t *t)
 		 */
 		size_t len = strspn(sdate, "0123456789-:T@");
 		if (sdate[len] == '\0') {
-			const char *fmt;
 			if (sdate[0] == '@') {
-				fmt = "@%s";
+				time_t d = (time_t)strtoll(&sdate[1], (char **)&s, 10);
+				localtime_r(&d, &tm);
 			} else if (strchr(sdate, '-') == NULL) {
-				fmt = "%s";
+				time_t d = (time_t)strtoll(sdate, (char **)&s, 10);
+				localtime_r(&d, &tm);
 			} else if ((s = strchr(sdate, 'T')) == NULL) {
-				fmt = "%Y-%m-%d";
+				s = strptime(sdate, "%Y-%m-%d", &tm);
 			} else {
-				fmt = "%Y-%m-%dT%H:%M:%S";
+				s = strptime(sdate, "%Y-%m-%dT%H:%M:%S", &tm);
 			}
 
-			s = strptime(sdate, fmt, &tm);
 			if (s == NULL || s[0] != '\0')
 				return false;
 		} else {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-23 11:57 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-23 11:57 UTC (permalink / raw
  To: gentoo-commits

commit:     00445c1e96c31fcb6fa5c7c517479473dcaa69dc
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 19 16:14:45 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 19 16:14:45 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=00445c1e

configure.ac: add copyright header

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 configure.ac | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/configure.ac b/configure.ac
index e7defe4..013e831 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,3 +1,9 @@
+# Copyright 2011-2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+#
+# Copyright 2011-2014 Mike Frysinger  - <vapier@gentoo.org>
+# Copyright 2011-     Fabian Groffen  - <grobian@gentoo.org>
+
 AC_PREREQ([2.71])
 AC_INIT([portage-utils],[git])
 AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip silent-rules -Wall])


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-12 18:31 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-12 18:31 UTC (permalink / raw
  To: gentoo-commits

commit:     46c32287c3a4f0905ba051dfbfba93973b81e157
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 12 18:30:37 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 12 18:30:37 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=46c32287

qmanifest: fix Coverity resource leak CID 206540

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qmanifest.c b/qmanifest.c
index a00dbd2..72d6362 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2018-2019 Gentoo Foundation
+ * Copyright 2018-2021 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2018-     Fabian Groffen  - <grobian@gentoo.org>
@@ -438,8 +438,10 @@ generate_dir(const char *dir, enum type_manifest mtype)
 			return NULL;
 		}
 
-		if (list_dir(&dentries, &dentrieslen, dir) != 0)
+		if (list_dir(&dentries, &dentrieslen, dir) != 0) {
+			gzclose(mf);
 			return NULL;
+		}
 
 		for (i = 0; i < dentrieslen; i++) {
 			/* ignore existing Manifests */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-12 18:31 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-12 18:31 UTC (permalink / raw
  To: gentoo-commits

commit:     219ba2dd9f748c6065c6485020f7de56623e1bc9
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 12 18:15:40 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 12 18:15:40 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=219ba2dd

qmerge: fix Coverity file descriptor leak CID 207952

Leak would happen when opening file succeed, but statting it would fail.
Unlikely, but better to take into account anyway.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index a64447e..80affdb 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1693,8 +1693,9 @@ unlink_empty(const char *buf)
 	if (fd != -1 && stat(buf, &st) != -1) {
 		if (st.st_size == 0)
 			ret = unlink(buf);
-		close(fd);
 	}
+	if (fd != -1)
+		close(fd);
 	return ret;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-12 18:31 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-12 18:31 UTC (permalink / raw
  To: gentoo-commits

commit:     618db8bdc8f82972815a9f717a4be0df71f0e52c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 12 18:04:10 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 12 18:04:10 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=618db8bd

qlop: fix Coverity condition always true CID 248869

atom->pfx_op cannot be 2 values at the same time so,
  pfx_op != X || pfx_op != Y
has to be always true

fix it to turn into and condition, which makes more sense in the code
flow

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qlop.c b/qlop.c
index afa4c19..addb4b3 100644
--- a/qlop.c
+++ b/qlop.c
@@ -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
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
@@ -1259,7 +1259,7 @@ static int do_emerge_log(
 								continue;
 							}
 						case NEWER:
-							if (atom->pfx_op != ATOM_OP_NEWER ||
+							if (atom->pfx_op != ATOM_OP_NEWER &&
 									atom->pfx_op != ATOM_OP_NEWER_EQUAL)
 								continue;
 							/* fall through */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-12 17:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-12 17:13 UTC (permalink / raw
  To: gentoo-commits

commit:     84f4920ae807927fc0774b5e468797134903554a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 12 16:58:38 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 12 16:58:38 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=84f4920a

qdepends: resolve Coverity resource leak CID 248875

This is actually a false positive, because state->udeps at this point
can and will never be NULL, so there's no new resource returned that is
leaked.  However, since it is code-wise cleaner to assign the result, do
so.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qdepends.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index 93b5109..96a791c 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2021 Gentoo Authors
+ * Copyright 2005-2022 Gentoo Authors
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
@@ -256,15 +256,17 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 						snprintf(buf, sizeof(buf), "%s%s%s",
 								RED, atom_to_string(atom), NORM);
 						if (quiet < 2)
-							add_set_unique(buf, state->udeps, NULL);
+							state->udeps = add_set_unique(buf,
+														  state->udeps, NULL);
 					} else if (!quiet) {
-						add_set_unique(atom_to_string(atom),
-								state->udeps, NULL);
+						state->udeps = add_set_unique(atom_to_string(atom),
+													  state->udeps, NULL);
 					}
 				}
 			} else {
 				array_for_each(state->deps, m, atom)
-					add_set_unique(atom_to_string(atom), state->udeps, NULL);
+					state->udeps = add_set_unique(atom_to_string(atom),
+												  state->udeps, NULL);
 			}
 		}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-12 17:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-12 17:13 UTC (permalink / raw
  To: gentoo-commits

commit:     48f667375565491d9151ae10137909303cef7685
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 12 16:38:16 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 12 16:38:16 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=48f66737

qmerge: fix Coverity resource leak (previnst) CID 248877

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 501011a..c41b095 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1089,8 +1089,10 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	/* Get a handle on the main vdb repo */
 	vdb = tree_open_vdb(portroot, portvdb);
 	if (vdb == NULL) {
-		if (pretend)
+		if (pretend) {
+			tree_match_close(previnst);
 			return;
+		}
 		/* try to create a vdb if none exists yet */
 		xasprintf(&p, "%s/%s", portroot, portvdb);
 		mkdir_p(p, 0755);
@@ -1103,12 +1105,14 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	if (!cat_ctx) {
 		if (errno != ENOENT) {
 			tree_close(vdb);
+			tree_match_close(previnst);
 			return;
 		}
 		mkdirat(vdb->tree_fd, mpkg->atom->CATEGORY, 0755);
 		cat_ctx = tree_open_cat(vdb, mpkg->atom->CATEGORY);
 		if (!cat_ctx) {
 			tree_close(vdb);
+			tree_match_close(previnst);
 			return;
 		}
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-12 17:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-12 17:13 UTC (permalink / raw
  To: gentoo-commits

commit:     6474196695f7092f7725af8565507fad9b7cf961
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 12 16:21:55 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 12 16:21:55 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=64741966

qmerge: fix Coverity NULL_RETURNS (possibly passing NULL)

CID 248879

buf (EAPI) and phases can be NULL, substitute EAPI, don't run
phase-funcs when no phases are present.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 7b738ee..501011a 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1518,6 +1518,8 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, depend_atom *rpkg, set *keep,
 	 * the replacement package */
 	if (!pretend && rpkg == NULL) {
 		buf = tree_pkg_meta_get(pkg_ctx, EAPI);
+		if (buf == NULL)
+			buf = "0";  /* default */
 		phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
 		if (phases != NULL) {
 			mkdirat(pkg_ctx->fd, "temp", 0755);
@@ -1657,9 +1659,13 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, depend_atom *rpkg, set *keep,
 	if (!pretend) {
 		buf = tree_pkg_meta_get(pkg_ctx, EAPI);
 		phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
-		/* execute the pkg_postrm step */
-		pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_POSTRM,
-				T, T, buf, rpkg == NULL ? "" : rpkg->PVR);
+		if (buf == NULL)
+			buf = "0";  /* default */
+		if (phases != NULL) {
+			/* execute the pkg_postrm step */
+			pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_POSTRM,
+					T, T, buf, rpkg == NULL ? "" : rpkg->PVR);
+		}
 
 		/* finally delete the vdb entry */
 		rm_rf_at(pkg_ctx->fd, ".");


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-12 17:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-12 17:13 UTC (permalink / raw
  To: gentoo-commits

commit:     ea84ef6ee024de6a24e0ee2f0cf557213a05c6b9
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 12 17:08:42 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 12 17:08:42 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ea84ef6e

qmerge: fix Coverity dead code CID 248871

we previously checked rpkg == NULL, so indeed it can never be !NULL
(copy 'n' paste error)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index c41b095..a64447e 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1523,12 +1523,12 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, depend_atom *rpkg, set *keep,
 	if (!pretend && rpkg == NULL) {
 		buf = tree_pkg_meta_get(pkg_ctx, EAPI);
 		if (buf == NULL)
-			buf = "0";  /* default */
+			buf = (char *)"0";  /* default */
 		phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
 		if (phases != NULL) {
 			mkdirat(pkg_ctx->fd, "temp", 0755);
 			pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_PRERM,
-					T, T, buf, rpkg == NULL ? "" : rpkg->PVR);
+							T, T, buf, "");
 		}
 	}
 
@@ -1664,7 +1664,7 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, depend_atom *rpkg, set *keep,
 		buf = tree_pkg_meta_get(pkg_ctx, EAPI);
 		phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
 		if (buf == NULL)
-			buf = "0";  /* default */
+			buf = (char *)"0";  /* default */
 		if (phases != NULL) {
 			/* execute the pkg_postrm step */
 			pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_POSTRM,


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-12 17:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-12 17:13 UTC (permalink / raw
  To: gentoo-commits

commit:     c07a9101354356b531791a29c99f99582962fb9c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 12 16:34:59 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 12 16:34:59 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c07a9101

qtbz2: attempt to fix Coverity taint warning

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qtbz2.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/qtbz2.c b/qtbz2.c
index 7cc0b37..0f26ac4 100644
--- a/qtbz2.c
+++ b/qtbz2.c
@@ -1,9 +1,10 @@
 /*
- * Copyright 2005-2020 Gentoo Foundation
+ * Copyright 2005-2022 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2014 Mike Frysinger  - <vapier@gentoo.org>
+ * Copyright 2020-     Fabian Groffen  - <grobian@gentoo.org>
  */
 
 #include "main.h"
@@ -199,6 +200,17 @@ tbz2_decompose(int dir_fd, const char *tbz2, const char *tarbz2, const char *xpa
 	/* calculate tarbz2's size */
 	tarbz2_size = st.st_size - xpak_size - TBZ2_END_LEN;
 
+	/* attempt to check xpak_size and tarbz2_size for Coverity's taint
+	 * check CID 248878 */
+	if (xpak_size <= 0 || xpak_size >= st.st_size) {
+		warn("%s: invalid xpak size: %ld", tbz2, xpak_size);
+		goto close_in_and_ret;
+	}
+	if (tarbz2_size <= 0) {
+		warn("%s: invalid tar size: %ld", tbz2, tarbz2_size);
+		goto close_in_and_ret;
+	}
+
 	/* reset to the start of the tbz2 */
 	rewind(in);
 	/* dump the tar.bz2 */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-12 16:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-12 16:14 UTC (permalink / raw
  To: gentoo-commits

commit:     fc71a04651ab56b0133c61d839169a0cabf6f092
Author:     Jaak Ristioja <jaak <AT> ristioja <DOT> ee>
AuthorDate: Fri Feb 11 15:31:05 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 12 16:14:11 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=fc71a046

qlop: Fixed --running --verbose returning unknown ETA

It seems that this was broken during the introduction of --predict in commit
13402fbd8c51f7feedcc85f2f0815768ec45ee7a which caused keys of the merge_averages
and unmerge_averages sets to include version information, whereas --running
expects these not to include version information.

Bug: https://bugs.gentoo.org/807975
Signed-off-by: Jaak Ristioja <jaak <AT> ristioja.ee>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/qlop.c b/qlop.c
index b054e58..afa4c19 100644
--- a/qlop.c
+++ b/qlop.c
@@ -797,7 +797,9 @@ static int do_emerge_log(
 							|| flags->do_running)
 					{
 						/* find in list of averages */
-						if (flags->do_predict || verbose) {
+						if (flags->do_predict ||
+							(verbose && !flags->do_running))
+						{
 							snprintf(afmt, sizeof(afmt), "%s/%s",
 									pkgw->atom->CATEGORY, pkgw->atom->PF);
 						} else {
@@ -940,7 +942,9 @@ static int do_emerge_log(
 							|| flags->do_running)
 					{
 						/* find in list of averages */
-						if (flags->do_predict || verbose) {
+						if (flags->do_predict ||
+							(verbose && !flags->do_running))
+						{
 							snprintf(afmt, sizeof(afmt), "%s/%s",
 									pkgw->atom->CATEGORY, pkgw->atom->PF);
 						} else {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-07  7:16 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-07  7:16 UTC (permalink / raw
  To: gentoo-commits

commit:     f162a959f1d34bfdda0252e99d87a64271e1b13f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Feb  7 07:15:48 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Feb  7 07:15:48 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f162a959

README: use github badge for build status

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 README.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 60a2fd9..cb705b0 100644
--- a/README.md
+++ b/README.md
@@ -6,7 +6,7 @@
 | GIT      | https://anongit.gentoo.org/git/proj/portage-utils.git     |
 | VIEWVCS  | https://gitweb.gentoo.org/proj/portage-utils.git/         |
 | GITHUB   | https://github.com/gentoo/portage-utils                   |
-| STATUS   | [![Build Status](https://travis-ci.org/gentoo/portage-utils.svg?branch=master)](https://travis-ci.org/gentoo/portage-utils) [![Coverity Status](https://scan.coverity.com/projects/9213/badge.svg)](https://scan.coverity.com/projects/gentoo-portage-utils) |
+| STATUS   | [![Build Status](https://github.com/gentoo/portage-utils/actions/workflows/build-test-ci.yml/badge.svg)](https://github.com/gentoo/portage-utils/actions/workflows/build-test-ci.yml) [![Coverity Status](https://scan.coverity.com/projects/9213/badge.svg)](https://scan.coverity.com/projects/gentoo-portage-utils) |
 
 portage-utils is a small set of utilities for working with Portage, Gentoo
 ebuilds, Gentoo ebuild overlays, installed packages (vdb), and similar sources


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-06 15:21 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-06 15:21 UTC (permalink / raw
  To: gentoo-commits

commit:     65e6273199327ea2f6b12bc66661dd7959758df4
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Feb  6 15:21:32 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Feb  6 15:21:32 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=65e62731

qmerge: plug leak in pkg_merge when doing dryrun

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 4ce14ae..7b738ee 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1081,8 +1081,10 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 		freeargv(ARGC, ARGV);
 	}
 
-	if (pretend == 100)
+	if (pretend == 100) {
+		tree_match_close(previnst);
 		return;
+	}
 
 	/* Get a handle on the main vdb repo */
 	vdb = tree_open_vdb(portroot, portvdb);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-06 14:51 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-06 14:51 UTC (permalink / raw
  To: gentoo-commits

commit:     71b1d91909da6f5cbbe2ab02e3f9045f58bd499a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Feb  6 14:51:38 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Feb  6 14:51:38 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=71b1d919

qmerge: plug leak in pkg_merge

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index e247a38..4ce14ae 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -133,7 +133,7 @@ fetch(const char *destdir, const char *src)
 	} else
 #endif
 	{
-		char *path;
+		char *path = NULL;
 
 		/* wget -c -q -P <dir> <uri> */
 		const char *argv[] = {
@@ -1021,6 +1021,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 				ATOM_COMP_NOSUBSLOT | ATOM_COMP_NOREPO);
 		replver   = previnst->atom->PVR;
 	}
+	atom_implode(slotatom);
 
 	(void)qprint_tree_node(level, mpkg, previnst, replacing);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-06 14:29 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-06 14:29 UTC (permalink / raw
  To: gentoo-commits

commit:     db6aebe9a1033dc123e69bdacd5ae8d4d2290c4a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Feb  6 14:29:00 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Feb  6 14:29:00 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=db6aebe9

qmerge: free up some resources

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/qmerge.c b/qmerge.c
index a856aaa..e247a38 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1133,6 +1133,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 		if (vdbfd == -1)
 			err("failed to open vdb extraction directory");
 		tbz2size = xpak_extract(mpkg->path, &vdbfd, pkg_extract_xpak_cb);
+		close(vdbfd);
 	}
 	if (tbz2size <= 0)
 		err("%s appears not to be a valid tbz2 file", mpkg->path);
@@ -2062,5 +2063,11 @@ int qmerge_main(int argc, char **argv)
 	ret = qmerge_run(todo);
 	if (todo != NULL)
 		free_set(todo);
+
+	if (_qmerge_binpkg_tree != NULL)
+		tree_close(_qmerge_binpkg_tree);
+	if (_qmerge_vdb_tree != NULL)
+		tree_close(_qmerge_vdb_tree);
+
 	return ret;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-02-06 14:29 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-02-06 14:29 UTC (permalink / raw
  To: gentoo-commits

commit:     d2c96a1459ce9603e4a538492a43accca376617e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Feb  6 14:21:38 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Feb  6 14:21:38 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d2c96a14

qmerge: make use of xsystem instead of DIY

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 45 ++++++++++++++++-----------------------------
 1 file changed, 16 insertions(+), 29 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 21f0863..a856aaa 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2021 Gentoo Authors
+ * Copyright 2005-2022 Gentoo Authors
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
@@ -129,45 +129,32 @@ fetch(const char *destdir, const char *src)
 		char buf[BUFSIZ];
 		snprintf(buf, sizeof(buf), "(export DISTDIR='%s' URI='%s/%s'; %s)",
 			destdir, binhost, src, getenv("FETCHCOMMAND"));
-		xsystem(buf);
+		xsystem(buf, AT_FDCWD);
 	} else
 #endif
 	{
-		pid_t p;
-		int status;
 		char *path;
 
-		xasprintf(&path, "%s/%s", binhost, src);
-
 		/* wget -c -q -P <dir> <uri> */
-		char prog[] = "wget";
-		char *const argv[] = {
-			prog,
-			(char *)"-c",
-			(char *)"-P",
-			(char *)destdir,
+		const char *argv[] = {
+			"echo",
+			"wget",
+			"-c",
+			"-P",
+			destdir,
 			path,
 			quiet ? (char *)"-q" : NULL,
 			NULL,
 		};
-		if (!(force_download || install) && pretend)
-			strcpy(prog, "echo");
-
-		p = vfork();
-		switch (p) {
-		case 0:
-			_exit(execvp(prog, argv));
-		case -1:
-			errp("vfork failed");
-		}
 
-		free(path);
+		xasprintf(&path, "%s/%s", binhost, src);
 
-		waitpid(p, &status, 0);
-#if 0
-		if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
-			return;
-#endif
+		if (!pretend && (force_download || install))
+			xsystemv(&argv[1], AT_FDCWD);  /* skip echo */
+		else
+			xsystemv(argv, AT_FDCWD);
+
+		free(path);
 	}
 
 	fflush(stdout);
@@ -767,7 +754,7 @@ pkg_run_func_at(
 		/*7*/ phase_replacingvers[phaseidx].varname,
 		/*8*/ replacing,
 		/*9*/ debug ? "set -x;" : "");
-	xsystembash(script, dirfd);
+	xsystem(script, dirfd);
 	free(script);
 }
 #define pkg_run_func(...) pkg_run_func_at(AT_FDCWD, __VA_ARGS__)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2022-01-31  8:01 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2022-01-31  8:01 UTC (permalink / raw
  To: gentoo-commits

commit:     b5cb53dedf28648f817da28fdcc288894c8e6e45
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 31 07:59:20 2022 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jan 31 07:59:20 2022 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b5cb53de

qmerge: just show which packages would be installed without --pretend

While pretend shows what would be done, make default mode (interactive)
just list what would be installed, not how.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 3f82d61..21f0863 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1093,6 +1093,9 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 		freeargv(ARGC, ARGV);
 	}
 
+	if (pretend == 100)
+		return;
+
 	/* Get a handle on the main vdb repo */
 	vdb = tree_open_vdb(portroot, portvdb);
 	if (vdb == NULL) {
@@ -1517,9 +1520,6 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, depend_atom *rpkg, set *keep,
 	printf("%s***%s unmerging %s\n", YELLOW, NORM,
 			atom_format("%[CATEGORY]%[PF]", tree_get_atom(pkg_ctx, false)));
 
-	if (pretend == 100)
-		return 0;
-
 	portroot_fd = cat_ctx->ctx->portroot_fd;
 
 	/* execute the pkg_prerm step if we're just unmerging, not when
@@ -1768,7 +1768,6 @@ pkg_fetch(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	if (pretend) {
 		if (!install)
 			install++;
-		/* qprint_tree_node(level, qatom, mpkg); */
 		pkg_merge(level, qatom, mpkg);
 		return;
 	}
@@ -2053,7 +2052,7 @@ int qmerge_main(int argc, char **argv)
 		int save_verbose = verbose;
 		int save_quiet = quiet;
 
-		pretend = 100;
+		pretend = save_pretend ? 10 : 100;
 		verbose = 0;
 		quiet = 1;
 		ret = qmerge_run(todo);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-12-31 15:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-12-31 15:36 UTC (permalink / raw
  To: gentoo-commits

commit:     e0453eace414e6c5d484ee9bdd69ee97904ca47b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 30 18:42:48 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Dec 30 18:42:48 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e0453eac

TODO: update

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/TODO.md b/TODO.md
index e9b6454..d14396a 100644
--- a/TODO.md
+++ b/TODO.md
@@ -4,11 +4,6 @@
 	- -e foo
 	- -r (-R ?) regexp foo.\*
 - make default -e for apps like quse/qdepends/qlist?
-- env vars only get expanded once, so this fails:<br>
-  `ACCEPT_LICENSE="foo"`<br>
-  `ACCEPT_LICENSE="${ACCEPT_LICENSE} bar"`<br>
-  we end up getting just:<br>
-  `ACCEPT_LICENSE=" bar"`
 - tree\_get\_atoms should return atoms iso string set, needs a rewrite
   to use foreach\_pkg and get\_atom -- set is ready for storing objects
   now
@@ -28,8 +23,6 @@
 - make tree\_get\_metadata also retrieve maintainer type, such that
   qlist can query for maintainer email or type, ideally to do
   qlist -Iv $(portageq --repo gentoo --orphaned) in one step (bug 711466#c3)
-- atom\_compare should have a flags argument which specifies how to
-  match, e.g. ignore REPO, SUBSLOT, etc. for use in e.g. qmerge
 
 # tests
 - add test for qsearch to avoid repetitions like


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-12-31 15:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-12-31 15:36 UTC (permalink / raw
  To: gentoo-commits

commit:     8e19c9d7218ebfb5380169df7b7978cbb782310c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 30 18:21:01 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Dec 30 18:21:01 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8e19c9d7

main: move comment to relevant block

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index b3f2f6d..1337cb0 100644
--- a/main.c
+++ b/main.c
@@ -485,10 +485,10 @@ read_portage_file(const char *file, enum portage_file_type type, void *data)
 			continue;
 		}
 
-		/* Handle "source" keyword */
 		if (type == ENV_FILE) {
 			size_t curline = line;
 
+			/* Handle "source" keyword */
 			if (strncmp(buf, "source ", 7) == 0) {
 				const char *sfile = buf + 7;
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-12-31 15:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-12-31 15:36 UTC (permalink / raw
  To: gentoo-commits

commit:     f58042d333d5a658f4ae1ddee322a5de31a55066
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 31 15:34:52 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Dec 31 15:34:52 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f58042d3

qlop: fix default mode of operation (-l)

start_time was changed to default to -1 at some point, which broke
qlop's default to list the last merge.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qlop.c b/qlop.c
index d9b0512..b054e58 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1676,7 +1676,7 @@ int qlop_main(int argc, char **argv)
 		m.do_unmerge = 1;
 		if (array_cnt(atoms) == 0) {
 			m.do_sync = 1;
-			if (start_time == 0)
+			if (start_time == -1)
 				m.show_lastmerge = 1;
 		}
 		m.do_time = 1;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-12-29 12:20 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-12-29 12:20 UTC (permalink / raw
  To: gentoo-commits

commit:     28489559193b543926ce93b95eb5f6f91b5a5574
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 29 12:19:16 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Dec 29 12:19:16 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=28489559

qmerge: drop ugly tree_pkg_meta_get workaround

tree_pkg_meta_get() returned pointers now won't change for as long as
the object exists

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 75f03c0..3f82d61 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1528,7 +1528,6 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, depend_atom *rpkg, set *keep,
 	if (!pretend && rpkg == NULL) {
 		buf = tree_pkg_meta_get(pkg_ctx, EAPI);
 		phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
-		buf = tree_pkg_meta_get(pkg_ctx, EAPI);  /* when phases caused ralloc */
 		if (phases != NULL) {
 			mkdirat(pkg_ctx->fd, "temp", 0755);
 			pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_PRERM,


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-12-27 18:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-12-27 18:13 UTC (permalink / raw
  To: gentoo-commits

commit:     f1c5463c944bb646ac1bdf61dd5a74f64dcaa33b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 27 18:12:06 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Dec 27 18:12:06 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f1c5463c

qmerge: resolve user sets from etc/portage/sets

Based on suggested patch from Barnabás Virágh in bug #816237.  Look
inside sets subdir.  While at it, accept @-prefixed syntax, e.g. @world.

Bug: https://bugs.gentoo.org/816237
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 1ad7179..75f03c0 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1928,10 +1928,14 @@ qmerge_add_set_system(void *data, char *buf)
 static set *
 qmerge_add_set(char *buf, set *q)
 {
-	if (strcmp(buf, "world") == 0)
+	/* accept @world next to just "world" */
+	if (*buf == '@')
+		buf++;
+
+	if (strcmp(buf, "world") == 0) {
 		return qmerge_add_set_file(CONFIG_EPREFIX, "/var/lib/portage",
-				"world", q);
-	else if (strcmp(buf, "all") == 0) {
+								   "world", q);
+	} else if (strcmp(buf, "all") == 0) {
 		tree_ctx *ctx = tree_open_vdb(portroot, portvdb);
 		set *ret = NULL;
 		if (ctx != NULL) {
@@ -1939,12 +1943,13 @@ qmerge_add_set(char *buf, set *q)
 			tree_close(ctx);
 		}
 		return ret;
-	} else if (strcmp(buf, "system") == 0)
+	} else if (strcmp(buf, "system") == 0) {
 		return q_profile_walk("packages", qmerge_add_set_system, q);
-	else if (buf[0] == '@')
+	} else if (buf[0] == '@') {
 		/* TODO: use configroot */
-		return qmerge_add_set_file(CONFIG_EPREFIX, "/etc/portage", buf+1, q);
-	else {
+		return qmerge_add_set_file(CONFIG_EPREFIX,
+								   "/etc/portage/sets", buf+1, q);
+	} else {
 		rmspace(buf);
 		return add_set(buf, q);
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-12-26 13:59 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-12-26 13:59 UTC (permalink / raw
  To: gentoo-commits

commit:     ed8a0a8694de1a83a29041104de162ff63e5f8c6
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 26 13:55:24 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Dec 26 13:55:24 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ed8a0a86

qmerge: support cross-device merges also for VDB #816141

As originally suggested by Barnabás Virágh, but in this implementation
using move_file, which is now shared code between pkg merge and the
putting the vdb in place.

Bug: https://bugs.gentoo.org/816141
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 115 ++++++++++++++++++++-------------------------------------------
 1 file changed, 37 insertions(+), 78 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 091b6e1..1ad7179 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -22,6 +22,7 @@
 
 #include "atom.h"
 #include "copy_file.h"
+#include "move_file.h"
 #include "contents.h"
 #include "eat_file.h"
 #include "hash.h"
@@ -320,16 +321,6 @@ crossmount_rm(const char *fname, const struct stat * const st,
 	rm_rf_at(fd, fname);
 }
 
-static int
-q_merge_filter_self_parent(const struct dirent *de)
-{
-	if (de->d_name[0] == '.' && (de->d_name[1] == '\0' ||
-			 (de->d_name[1] == '.' && de->d_name[2] == '\0')))
-		return 0;
-
-	return 1;
-}
-
 enum inc_exc { INCLUDE = 1, EXCLUDE = 2 };
 
 static void
@@ -353,7 +344,7 @@ install_mask_check_dir(
 #endif
 	char *npth = qpth + strlen(qpth);
 
-	cnt = scandirat(fd, ".", &files, q_merge_filter_self_parent, alphasort);
+	cnt = scandirat(fd, ".", &files, filter_self_parent, alphasort);
 	for (j = 0; j < cnt; j++) {
 		mode = child_mode = parent_mode;
 		for (i = 0; i < maskc; i++) {
@@ -820,7 +811,7 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 	while ((de = readdir(dir)) != NULL) {
 		const char *name = de->d_name;
 
-		if (!strcmp(name, ".") || !strcmp(name, ".."))
+		if (filter_self_parent(de) == 0)
 			continue;
 
 		/* Build up the full path for this entry */
@@ -866,10 +857,8 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 				unlinkat(subfd_dst, name, AT_REMOVEDIR);
 		} else if (S_ISREG(st.st_mode)) {
 			/* Migrate a file */
-			struct timespec times[2];
-			int fd_srcf, fd_dstf;
 			char *hash;
-			const char *tmpname, *dname;
+			const char *dname;
 			char buf[_Q_PATH_MAX * 2];
 			struct stat ignore;
 
@@ -905,66 +894,8 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 			if (pretend)
 				continue;
 
-			/* First try fast path -- src/dst are same device */
-			if (renameat(subfd_src, dname, subfd_dst, name) == 0)
-				continue;
-
-			/* Fall back to slow path -- manual read/write */
-			fd_srcf = openat(subfd_src, name, O_RDONLY|O_CLOEXEC);
-			if (fd_srcf < 0) {
-				warnp("could not read %s", cpath);
-				continue;
-			}
-
-			/* Do not write the file in place ...
-			 * will fail with files that are in use.
-			 * XXX: Should we make this random ?
-			 */
-			tmpname = ".qmerge.update";
-			fd_dstf = openat(subfd_dst, tmpname,
-					O_WRONLY|O_CLOEXEC|O_CREAT|O_TRUNC, st.st_mode);
-			if (fd_dstf < 0) {
-				warnp("could not write %s", cpath);
-				close(fd_srcf);
-				continue;
-			}
-
-			/* Make sure owner/mode is sane before we write out data */
-			if (fchown(fd_dstf, st.st_uid, st.st_gid)) {
-				warnp("could not set ownership (%zu/%zu) for %s",
-						(size_t)st.st_uid, (size_t)st.st_gid, cpath);
-				continue;
-			}
-			if (fchmod(fd_dstf, st.st_mode)) {
-				warnp("could not set permission (%u) for %s",
-						(int)st.st_mode, cpath);
-				continue;
-			}
-
-			/* Do the actual data copy */
-			if (copy_file_fd(fd_srcf, fd_dstf)) {
-				warnp("could not write %s", cpath);
-				if (ftruncate(fd_dstf, 0)) {
-					/* don't care */;
-				}
-				close(fd_srcf);
-				close(fd_dstf);
-				continue;
-			}
-
-			/* Preserve the file times */
-			times[0] = get_stat_mtime(&st);
-			times[1] = get_stat_mtime(&st);
-			futimens(fd_dstf, times);
-
-			close(fd_srcf);
-			close(fd_dstf);
-
-			/* Move the new tmp dst file to the right place */
-			if (renameat(subfd_dst, tmpname, subfd_dst, dname)) {
-				warnp("could not rename %s to %s", tmpname, cpath);
-				continue;
-			}
+			if (move_file(subfd_src, name, subfd_dst, dname, &st) != 0)
+				warnp("failed to move file from %s", cpath);
 		} else if (S_ISLNK(st.st_mode)) {
 			/* Migrate a symlink */
 			size_t len = st.st_size;
@@ -1000,7 +931,7 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 			}
 
 			struct timespec times[2];
-			times[0] = get_stat_mtime(&st);
+			times[0] = get_stat_atime(&st);
 			times[1] = get_stat_mtime(&st);
 			utimensat(subfd_dst, name, times, AT_SYMLINK_NOFOLLOW);
 		} else {
@@ -1520,8 +1451,36 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 		mkdir_p(buf, 0755);
 		strcat(buf, mpkg->atom->PF);
 		rm_rf(buf);  /* get rid of existing dir, empty dir is fine */
-		if (rename("vdb", buf) != 0)
-			warn("failed to move 'vdb' to '%s': %s", buf, strerror(errno));
+		if (rename("vdb", buf) != 0) {
+			struct stat     vst;
+			int             src_fd;
+			int             dst_fd;
+			int             cnt;
+			int             vi;
+			struct dirent **files;
+
+			/* e.g. in case of cross-device rename, try copy+delete */
+			if ((src_fd = open("vdb", O_RDONLY|O_CLOEXEC|O_PATH)) < 0 ||
+				fstat(src_fd, &vst) != 0 ||
+				mkdir_p(buf, vst.st_mode) != 0 ||
+				(dst_fd = open(buf, O_RDONLY|O_CLOEXEC|O_PATH)) < 0 ||
+				(cnt = scandirat(src_fd, ".",
+								 &files, filter_self_parent, NULL)) < 0)
+			{
+				warn("cannot stat 'vdb' or create '%s', huh?", buf);
+			} else {
+				/* for now we assume the VDB is a flat directory, e.g.
+				 * there are no subdirs */
+				for (vi = 0; vi < cnt; vi++) {
+					if (move_file(src_fd, files[vi]->d_name,
+							  	  dst_fd, files[vi]->d_name,
+							  	  NULL) != 0)
+						warn("failed to move 'vdb/%s' to '%s': %s",
+							 files[vi]->d_name, buf, strerror(errno));
+				}
+				scandir_free(files, cnt);
+			}
+		}
 	}
 
 	/* clean up our local temp dir */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-12-25  9:15 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-12-25  9:15 UTC (permalink / raw
  To: gentoo-commits

commit:     f1f616067dff37519ae017696f571bd90a99f55f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 25 09:14:30 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Dec 25 09:14:30 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f1f61606

qlop: fix garbage when using -Ev

Regression since v0.92.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 30 +++++++++++++++++-------------
 1 file changed, 17 insertions(+), 13 deletions(-)

diff --git a/qlop.c b/qlop.c
index 0e381bd..d9b0512 100644
--- a/qlop.c
+++ b/qlop.c
@@ -437,6 +437,7 @@ static int do_emerge_log(
 	size_t i;
 	size_t parallel_emerge = 0;
 	bool all_atoms = false;
+	bool emerge_line;
 	char afmt[BUFSIZ];
 	struct pkg_match *pkg;
 	struct pkg_match *pkgw;
@@ -544,14 +545,21 @@ static int do_emerge_log(
 
 		tstart = atol(buf);
 
+		emerge_line = false;
+		if (((flags->do_running ||
+			  (flags->show_emerge && verbose)) &&
+			 strpfx(p, "  *** emerge ") == 0) ||
+			(flags->do_running &&
+			 (strpfx(p, "  *** exiting ") == 0 ||
+			  strpfx(p, "  *** terminating.") == 0)))
+		{
+			emerge_line = true;
+		}
+
 		/* keeping track of parallel merges needs to be done before
 		 * applying dates, for a subset of the log might show emerge
 		 * finished without knowledge of another instance */
-		if (flags->do_running &&
-				(strpfx(p, "  *** emerge ") == 0 ||
-				 strpfx(p, "  *** exiting ") == 0 ||
-				 strpfx(p, "  *** terminating.") == 0))
-		{
+		if (emerge_line && flags->do_running) {
 			if (p[7] == 'm') {
 				parallel_emerge++;
 			} else if (parallel_emerge > 0) {
@@ -593,8 +601,7 @@ static int do_emerge_log(
 			continue;
 
 		/* are we interested in this line? */
-		if (flags->show_emerge && verbose && p[7] == 'm' /* emerge */)
-		{
+		if (emerge_line && flags->show_emerge && verbose) {
 			char shortopts[8];  /* must hold as many opts converted below */
 			int numopts = 0;
 
@@ -651,14 +658,11 @@ static int do_emerge_log(
 
 				if (strpfx(q, "--") == 0) {
 					printf(" %s%s%s", GREEN, q, NORM);
-				} else if (strcmp(q, "@world") == 0 ||
-						strcmp(q, "@system") == 0)
+				} else if (q[0] == '@' ||
+						   strcmp(q, "world") == 0 ||
+						   strcmp(q, "system") == 0)
 				{
 					printf(" %s%s%s", YELLOW, q, NORM);
-				} else if (strcmp(q, "world") == 0 ||
-						strcmp(q, "system") == 0)
-				{
-					printf(" %s@%s%s", YELLOW, q, NORM);
 				} else {
 					/* this should be an atom */
 					atom = atom_explode(q);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-12-23 12:55 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-12-23 12:55 UTC (permalink / raw
  To: gentoo-commits

commit:     297e49f62a6520fce353b8e82f3bba430f1ea613
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 23 12:53:42 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Dec 23 12:53:42 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=297e49f6

main: ensure default colouring is respected

Introduced in v0.93, a regression on picking up colour default.

We were setting nocolor variable, but before it was acted on, it was
overwritten with a default.  So now instead set the default based on
having a tty or not, and let profiles, env and flags override from
there.

Bug: https://bugs.gentoo.org/829837
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h | 14 +++++++++++---
 main.c    | 13 ++++++++++---
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/applets.h b/applets.h
index 6070fe4..16e7d9f 100644
--- a/applets.h
+++ b/applets.h
@@ -153,8 +153,16 @@ static const struct applet_t {
 	case 'q': setup_quiet(); break; \
 	case 'V': version_barf(); break; \
 	case 'h': applet ## _usage(EXIT_SUCCESS); break; \
-	case 'C': color_clear(); setenv("NOCOLOR", "true", 1); break; \
-	case 0x2: color_remap(); unsetenv("NOCOLOR"); break; \
+	case 'C': if (!nocolor) { \
+				  nocolor = 1; \
+				  color_clear(); \
+				  setenv("NOCOLOR", "true", 1); \
+			  } break; \
+	case 0x2: if (nocolor) { \
+				  nocolor = 0; \
+				  color_remap(); \
+				  setenv("NOCOLOR", "false", 1); \
+			  } break; \
 	default:  applet ## _usage(EXIT_FAILURE); break;
 
 extern char *portarch;
@@ -178,8 +186,8 @@ extern DEFINE_ARRAY(overlay_names);
 extern DEFINE_ARRAY(overlay_src);
 extern char *main_overlay;
 extern int twidth;
+extern bool nocolor;
 
-void no_colors(void);
 void setup_quiet(void);
 void version_barf(void);
 void usage(int status, const char *flags, struct option const opts[],

diff --git a/main.c b/main.c
index 06c52b7..b3f2f6d 100644
--- a/main.c
+++ b/main.c
@@ -30,6 +30,7 @@ char *module_name = NULL;
 int verbose = 0;
 int quiet = 0;
 int twidth;
+bool nocolor;
 char pretend = 0;
 char *portarch;
 char *portroot;
@@ -672,7 +673,6 @@ read_portage_profile(const char *profile, env_vars vars[], set *masks)
 	read_portage_file(profile_file, PMASK_FILE, masks);
 }
 
-static bool nocolor = 0;
 env_vars vars_to_read[] = {
 #define _Q_EV(t, V, set, lset, d) \
 { \
@@ -1091,7 +1091,7 @@ initialize_portage_env(void)
 	}
 
 	/* Make sure ROOT always ends in a slash */
-	var = &vars_to_read[0];
+	var = &vars_to_read[0];  /* ROOT */
 	if (var->value_len == 0 || (*var->value.s)[var->value_len - 1] != '/') {
 		portroot = xrealloc(portroot, var->value_len + 2);
 		portroot[var->value_len] = '/';
@@ -1134,7 +1134,7 @@ initialize_portage_env(void)
 		setenv("NOCOLOR", "true", 1);
 	} else {
 		color_remap();
-		unsetenv("NOCOLOR");
+		setenv("NOCOLOR", "false", 1);
 	}
 }
 
@@ -1151,7 +1151,11 @@ int main(int argc, char **argv)
 	bindtextdomain(argv0, CONFIG_EPREFIX "usr/share/locale");
 	textdomain(argv0);
 
+	/* note: setting nocolor here is pointless, since
+	 * initialize_portage_env is going to re-init nocolor, so make
+	 * sure we modify the default instead. */
 	twidth = 0;
+	nocolor = 0;
 	if (fstat(fileno(stdout), &st) != -1) {
 		if (!isatty(fileno(stdout))) {
 			nocolor = 1;
@@ -1162,7 +1166,10 @@ int main(int argc, char **argv)
 			if (ioctl(0, TIOCGWINSZ, &winsz) == 0 && winsz.ws_col > 0)
 				twidth = (int)winsz.ws_col;
 		}
+	} else {
+		nocolor = 1;
 	}
+	vars_to_read[7].default_value = (char *)nocolor;  /* NOCOLOR */
 
 	initialize_portage_env();
 	optind = 0;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-12-21 11:30 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-12-21 11:30 UTC (permalink / raw
  To: gentoo-commits

commit:     331d3dbb1fa1fdcade0d1debb1fc722ef3b9d1f2
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 21 09:59:30 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Dec 21 09:59:30 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=331d3dbb

autogen: keep our own m4 files around

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 autogen.sh | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/autogen.sh b/autogen.sh
index 1cfb68b..ea564e0 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -14,7 +14,16 @@ if ! qlist -qI sys-devel/autoconf-archive > /dev/null ; then
 	exit 1
 fi
 
-v rm -rf autotools
+# keep this list updated with non-generated M4 files
+keepm4=( ac_check_sendfile.m4 )
+for keepf in "${keepm4[@]}" ; do
+	v mv "${m4dir}/${keepf}" "autotools/"
+done
+v rm -rf autotools/{gnulib,m4}
+v mkdir "${m4dir}"
+for keepf in "${keepm4[@]}" ; do
+	v mv "autotools/${keepf}" "${m4dir}/"
+done
 
 # reload the gnulib code
 PATH=/usr/local/src/gnu/gnulib:${PATH}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-12-13  8:39 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-12-13  8:39 UTC (permalink / raw
  To: gentoo-commits

commit:     caeaa3c9f5c271b4ca02f8d597fcc765fa861a0f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 13 07:23:15 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Dec 13 07:23:15 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=caeaa3c9

qxpak: drop unnecessary include

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qxpak.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/qxpak.c b/qxpak.c
index 92c0dda..7a99df2 100644
--- a/qxpak.c
+++ b/qxpak.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2019 Gentoo Foundation
+ * Copyright 2005-2021 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
@@ -16,7 +16,6 @@
 #include <fcntl.h>
 
 #include "basename.h"
-#include "copy_file.h"
 #include "safe_io.h"
 #include "scandirat.h"
 #include "xpak.h"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-12-13  8:39 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-12-13  8:39 UTC (permalink / raw
  To: gentoo-commits

commit:     7820847b2f9c5fc348dbf1991fcfec9b3b4fb5c4
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 13 07:45:35 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Dec 13 07:45:35 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7820847b

main: turn FEATURES into a set

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h |  2 +-
 main.c    | 56 ++++++++++++++++++++++++++++++++++++--------------------
 2 files changed, 37 insertions(+), 21 deletions(-)

diff --git a/applets.h b/applets.h
index fa53359..6070fe4 100644
--- a/applets.h
+++ b/applets.h
@@ -170,7 +170,7 @@ extern char *pkg_install_mask;
 extern char *binhost;
 extern char *pkgdir;
 extern char *port_tmpdir;
-extern char *features;
+extern set  *features;
 extern set  *ev_use;
 extern char *install_mask;
 extern DEFINE_ARRAY(overlays);

diff --git a/main.c b/main.c
index 1d78f07..37ba036 100644
--- a/main.c
+++ b/main.c
@@ -41,7 +41,7 @@ char *pkg_install_mask;
 char *binhost;
 char *pkgdir;
 char *port_tmpdir;
-char *features;
+set  *features;
 set  *ev_use;
 char *install_mask;
 DECLARE_ARRAY(overlays);
@@ -252,13 +252,27 @@ strincr_var(const char *name, const char *s, char **value, size_t *value_len)
 	char  *p;
 	char  *nv;
 	char   brace;
+	bool   haddashstar;
 
-	len = strlen(s);
-	*value = xrealloc(*value, *value_len + len + 2);
-	nv = &(*value)[*value_len];
-	if (*value_len)
-		*nv++ = ' ';
-	memcpy(nv, s, len + 1);
+	/* find/skip any -* instances */
+	nv = (char *)s;
+	while ((p = strstr(nv, "-*")) != NULL)
+		nv = p + 2;
+
+	haddashstar = nv != (char *)s;
+
+	len = strlen(nv);
+	if (haddashstar && len < *value_len) {
+		p = *value;
+		*p = '\0';  /* in case len == 0 */
+	} else {
+		*value = xrealloc(*value,
+						  (haddashstar ? (*value_len + 1) : 0) + len + 1);
+		p = &(*value)[*value_len];
+		if (*value_len > 0)
+			*p++ = ' ';
+	}
+	memcpy(p, nv, len + 1);
 
 	/* This function is mainly used by the startup code for parsing
 		make.conf and stacking variables remove.
@@ -275,7 +289,6 @@ strincr_var(const char *name, const char *s, char **value, size_t *value_len)
 	*/
 
 	len = strlen(name);
-	p = nv;
 	while ((p = strchr(p, '$')) != NULL) {
 		nv = p;
 		p++;  /* skip $ */
@@ -293,9 +306,6 @@ strincr_var(const char *name, const char *s, char **value, size_t *value_len)
 		}
 	}
 
-	while ((p = strstr(nv, "-*")) != NULL)
-		memset(*value, ' ', p - *value + 2);
-
 	remove_extra_space(*value);
 	*value_len = strlen(*value);
 	/* we should sort here */
@@ -331,13 +341,15 @@ setincr_var(const char *s, set **vals)
 	makeargv(s, &argc, &argv);
 
 	for (i = 1 /* skip executable name */; i < argc; i++) {
-		if (argv[i][0] == '-' && *vals != NULL) {
-			/* handle negation, when the respective value isn't set, we
-			 * simply ignore/drop it */
-			if (argv[i][1] == '*') {
-				clear_set(*vals);
-			} else {
-				del_set(&argv[i][1], *vals, &ignore);
+		if (argv[i][0] == '-') {
+			if (*vals != NULL) {
+				/* handle negation, when the respective value isn't set, we
+				 * simply ignore/drop it */
+				if (argv[i][1] == '*') {
+					clear_set(*vals);
+				} else {
+					del_set(&argv[i][1], *vals, &ignore);
+				}
 			}
 		} else if (argv[i][0] == '$') {
 			/* detect ${var} or $var, simply ignore it completely, for
@@ -368,7 +380,11 @@ set_portage_env_var(env_vars *var, const char *value, const char *src)
 {
 	switch (var->type) {
 	case _Q_BOOL:
-		*var->value.b = 1;
+		*var->value.b = 0;
+		if (strcasecmp(value, "true") == 0 ||
+				strcasecmp(value, "yes") == 0 ||
+				strcmp(value, "1") == 0)
+			*var->value.b = 1;
 		free(var->src);
 		var->src = xstrdup(src);
 		break;
@@ -682,7 +698,7 @@ env_vars vars_to_read[] = {
 	_Q_EVS(ISTR, CONFIG_PROTECT,      config_protect,      "/etc")
 	_Q_EVS(ISTR, CONFIG_PROTECT_MASK, config_protect_mask, "")
 	_Q_EVB(BOOL, NOCOLOR,             nocolor,             0)
-	_Q_EVS(ISTR, FEATURES,            features,            "")
+	_Q_EVT(ISET, FEATURES,            features,            NULL)
 	_Q_EVT(ISET, USE,                 ev_use,              NULL)
 	_Q_EVS(STR,  EPREFIX,             eprefix,             CONFIG_EPREFIX)
 	_Q_EVS(STR,  EMERGE_LOG_DIR,      portlogdir,          CONFIG_EPREFIX "var/log")


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-12-13  8:39 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-12-13  8:39 UTC (permalink / raw
  To: gentoo-commits

commit:     dd51f2543435473120aed9b7f77356d01c354d63
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 13 07:46:16 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Dec 13 07:46:16 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=dd51f254

qmerge: use FEATURES as set

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 6defd5b..091b6e1 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1403,13 +1403,13 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 
 		/* rely on INSTALL_MASK code to remove optional dirs */
 		maskp = snprintf(imask, masklen, "%s ", install_mask);
-		if (strstr(features, "noinfo") != NULL)
+		if (contains_set("noinfo", features))
 			maskp += snprintf(imask + maskp, masklen - maskp,
 					"/usr/share/info ");
-		if (strstr(features, "noman" ) != NULL)
+		if (contains_set("noman", features))
 			maskp += snprintf(imask + maskp, masklen - maskp,
 					"/usr/share/man ");
-		if (strstr(features, "nodoc" ) != NULL)
+		if (contains_set("nodoc", features))
 			maskp += snprintf(imask + maskp, masklen - maskp,
 					"/usr/share/doc ");
 
@@ -1584,7 +1584,7 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, depend_atom *rpkg, set *keep,
 		eprefix_len = strlen(eprefix);
 
 	unmerge_config_protected =
-		strstr(features, "config-protect-if-modified") != NULL;
+		contains_set("config-protect-if-modified", features);
 
 	/* get a handle on the things to clean up */
 	buf = tree_pkg_meta_get(pkg_ctx, CONTENTS);
@@ -2059,7 +2059,7 @@ int qmerge_main(int argc, char **argv)
 	if (!install && !uninstall)
 		install = 1;
 
-	qmerge_strict = (strstr("strict", features) == 0) ? 1 : 0;
+	qmerge_strict = contains_set("strict", features) ? 1 : 0;
 
 	/* Short circut this. */
 	if (install && !pretend) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-11-13 14:27 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-11-13 14:27 UTC (permalink / raw
  To: gentoo-commits

commit:     4dd3b20b0ade46b207f869572a20fbe2ec24a4f1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 13 14:04:49 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov 13 14:04:49 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4dd3b20b

main: parse USE-flags into a set

In order to efficiently, and correctly, get a list of USE-flags that are
in effect, use a SET instead of an "incremental" string which sort of
relies on order.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h |   2 +-
 main.c    | 115 +++++++++++++++++++++++++++++++++++++++++++++++++++-----------
 main.h    |   5 +--
 q.c       |  35 ++++++++++++++++---
 4 files changed, 130 insertions(+), 27 deletions(-)

diff --git a/applets.h b/applets.h
index be5aad6..fa53359 100644
--- a/applets.h
+++ b/applets.h
@@ -171,7 +171,7 @@ extern char *binhost;
 extern char *pkgdir;
 extern char *port_tmpdir;
 extern char *features;
-extern char *ev_use;
+extern set  *ev_use;
 extern char *install_mask;
 extern DEFINE_ARRAY(overlays);
 extern DEFINE_ARRAY(overlay_names);

diff --git a/main.c b/main.c
index 6a79eef..1d78f07 100644
--- a/main.c
+++ b/main.c
@@ -42,7 +42,7 @@ char *binhost;
 char *pkgdir;
 char *port_tmpdir;
 char *features;
-char *ev_use;
+set  *ev_use;
 char *install_mask;
 DECLARE_ARRAY(overlays);
 DECLARE_ARRAY(overlay_names);
@@ -249,8 +249,9 @@ static void
 strincr_var(const char *name, const char *s, char **value, size_t *value_len)
 {
 	size_t len;
-	char *p, *nv;
-	char brace;
+	char  *p;
+	char  *nv;
+	char   brace;
 
 	len = strlen(s);
 	*value = xrealloc(*value, *value_len + len + 2);
@@ -259,9 +260,6 @@ strincr_var(const char *name, const char *s, char **value, size_t *value_len)
 		*nv++ = ' ';
 	memcpy(nv, s, len + 1);
 
-	while ((p = strstr(nv, "-*")) != NULL)
-		memset(*value, ' ', p - *value + 2);
-
 	/* This function is mainly used by the startup code for parsing
 		make.conf and stacking variables remove.
 		variables can be in the form of ${v} or $v
@@ -295,11 +293,64 @@ strincr_var(const char *name, const char *s, char **value, size_t *value_len)
 		}
 	}
 
+	while ((p = strstr(nv, "-*")) != NULL)
+		memset(*value, ' ', p - *value + 2);
+
 	remove_extra_space(*value);
 	*value_len = strlen(*value);
 	/* we should sort here */
 }
 
+static void
+setincr_var(const char *s, set **vals)
+{
+	int    i;
+	int    argc;
+	char **argv;
+	bool   ignore;
+
+	/* This tries to mimick parsing of portage envvars and the stacking
+	 * thereof.  In particular USE and FEATURES, where also negation can
+	 * happen (- prefix).  Variables are supported in form of ${v} or
+	 * $v, but there's no actual replacement happening, we just ignore
+	 * any of such forms.
+	 *  works:
+	 *		FEATURES="${FEATURES} foo"
+	 *		FEATURES="$FEATURES foo"
+	 *		FEATURES="baz bar -* foo"
+	 *
+	 *	wont work:
+	 *		FEATURES="${OTHERVAR} foo"
+	 *		FEATURES="-* ${FEATURES}"
+	 */
+
+	if (s == NULL || *s == '\0')
+		return;
+
+	/* break up input */
+	makeargv(s, &argc, &argv);
+
+	for (i = 1 /* skip executable name */; i < argc; i++) {
+		if (argv[i][0] == '-' && *vals != NULL) {
+			/* handle negation, when the respective value isn't set, we
+			 * simply ignore/drop it */
+			if (argv[i][1] == '*') {
+				clear_set(*vals);
+			} else {
+				del_set(&argv[i][1], *vals, &ignore);
+			}
+		} else if (argv[i][0] == '$') {
+			/* detect ${var} or $var, simply ignore it completely, for
+			 * all of these should be stacked, so re-including whatever
+			 * there is shouldn't make much sense */
+		} else {
+			*vals = add_set_unique(argv[i], *vals, &ignore);
+		}
+	}
+
+	freeargv(argc, argv);
+}
+
 static env_vars *
 get_portage_env_var(env_vars *vars, const char *name)
 {
@@ -329,6 +380,7 @@ set_portage_env_var(env_vars *var, const char *value, const char *src)
 		var->src = xstrdup(src);
 		break;
 	case _Q_ISTR:
+	case _Q_ISET:
 		if (strcmp(var->src, STR_DEFAULT) != 0) {
 			size_t l = strlen(var->src) + 2 + strlen(src) + 1;
 			char *p = xmalloc(sizeof(char) * l);
@@ -342,7 +394,10 @@ set_portage_env_var(env_vars *var, const char *value, const char *src)
 			free(var->src);
 			var->src = xstrdup(src);
 		}
-		strincr_var(var->name, value, var->value.s, &var->value_len);
+		if (var->type == _Q_ISTR)
+			strincr_var(var->name, value, var->value.s, &var->value_len);
+		else
+			setincr_var(value, var->value.t);
 		break;
 	}
 }
@@ -612,10 +667,12 @@ env_vars vars_to_read[] = {
 	.default_value = d, \
 	.src = NULL, \
 },
-#define _Q_EVS(t, V, v, d) \
-	_Q_EV(t, V, .value.s = &v, .value_len = sizeof(d) - 1, d)
-#define _Q_EVB(t, V, v, d) \
-	_Q_EV(t, V, .value.b = &v, .value_len = 0, d)
+#define _Q_EVS(t, V, v, D) \
+	_Q_EV(t, V, .value.s = &v, .value_len = sizeof(D) - 1, D)
+#define _Q_EVB(t, V, v, D) \
+	_Q_EV(t, V, .value.b = &v, .value_len = 0, D)
+#define _Q_EVT(T, V, v, D) \
+	_Q_EV(T, V, .value.t = &v, .value_len = 0, D)
 
 	_Q_EVS(STR,  ROOT,                portroot,            "/")
 	_Q_EVS(STR,  ACCEPT_LICENSE,      accept_license,      "")
@@ -626,7 +683,7 @@ env_vars vars_to_read[] = {
 	_Q_EVS(ISTR, CONFIG_PROTECT_MASK, config_protect_mask, "")
 	_Q_EVB(BOOL, NOCOLOR,             nocolor,             0)
 	_Q_EVS(ISTR, FEATURES,            features,            "")
-	_Q_EVS(ISTR, USE,                 ev_use,              "")
+	_Q_EVT(ISET, USE,                 ev_use,              NULL)
 	_Q_EVS(STR,  EPREFIX,             eprefix,             CONFIG_EPREFIX)
 	_Q_EVS(STR,  EMERGE_LOG_DIR,      portlogdir,          CONFIG_EPREFIX "var/log")
 	_Q_EVS(STR,  PORTDIR,             main_overlay,        CONFIG_EPREFIX "var/db/repos/gentoo")
@@ -819,8 +876,12 @@ initialize_portage_env(void)
 	/* initialize all the properties with their default value */
 	for (i = 0; vars_to_read[i].name; ++i) {
 		var = &vars_to_read[i];
-		if (var->type != _Q_BOOL)
-			*var->value.s = xstrdup(var->default_value);
+		switch (var->type) {
+			case _Q_BOOL:  *var->value.b = var->default_value;           break;
+			case _Q_STR:
+			case _Q_ISTR:  *var->value.s = xstrdup(var->default_value);  break;
+			case _Q_ISET:  *var->value.t = (set *)var->default_value;    break;
+		}
 		var->src = xstrdup(STR_DEFAULT);
 	}
 
@@ -895,7 +956,7 @@ initialize_portage_env(void)
 		char *svar;
 
 		var = &vars_to_read[i];
-		if (var->type == _Q_BOOL)
+		if (var->type != _Q_STR)
 			continue;
 
 		while ((svar = strchr(*var->value.s, '$'))) {
@@ -1023,11 +1084,27 @@ initialize_portage_env(void)
 	if (getenv("DEBUG")) {
 		for (i = 0; vars_to_read[i].name; ++i) {
 			var = &vars_to_read[i];
-			fprintf(stderr, "%s = ", var->name);
 			switch (var->type) {
-			case _Q_BOOL: fprintf(stderr, "%i\n", *var->value.b); break;
-			case _Q_STR:
-			case _Q_ISTR: fprintf(stderr, "%s\n", *var->value.s); break;
+				case _Q_BOOL:
+					fprintf(stderr, "%s = %d\n", var->name, *var->value.b);
+					break;
+				case _Q_STR:
+				case _Q_ISTR:
+					fprintf(stderr, "%s = %s\n", var->name, *var->value.s);
+					break;
+				case _Q_ISET: {
+					DECLARE_ARRAY(vals);
+					size_t n;
+					char  *val;
+
+					fprintf(stderr, "%s = ", var->name);
+					array_set(*var->value.t, vals);
+					array_for_each(vals, n, val) {
+						fprintf(stderr, "%s ", val);
+					}
+					fprintf(stderr, "\n");
+					xarrayfree_int(vals);
+				}	break;
 			}
 		}
 	}

diff --git a/main.h b/main.h
index 35b95ab..a1b2afc 100644
--- a/main.h
+++ b/main.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2019 Gentoo Foundation
+ * Copyright 2005-2021 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
@@ -146,7 +146,7 @@ extern FILE *warnout;
 #define errp(fmt, args...) _err(warnp, fmt , ## args)
 #define errfp(fmt, args...) _err(warnfp, fmt, ## args)
 
-typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR } var_types;
+typedef enum { _Q_BOOL, _Q_STR, _Q_ISTR, _Q_ISET } var_types;
 typedef struct {
 	const char *name;
 	const size_t name_len;
@@ -154,6 +154,7 @@ typedef struct {
 	union {
 		char **s;
 		bool *b;
+		set **t;
 	} value;
 	size_t value_len;
 	const char *default_value;

diff --git a/q.c b/q.c
index e514b0c..c9df5f7 100644
--- a/q.c
+++ b/q.c
@@ -242,10 +242,23 @@ int q_main(int argc, char **argv)
 						printf("%s%s%s",
 								YELLOW, *var->value.b ? "1" : "0", NORM);
 						break;
-				case _Q_STR:
-				case _Q_ISTR:
+					case _Q_STR:
+					case _Q_ISTR:
 						printf("%s\"%s\"%s", RED, *var->value.s, NORM);
 						break;
+					case _Q_ISET: {
+						DECLARE_ARRAY(vals);
+						size_t n;
+						char  *val;
+
+						printf("%s\"", RED);
+						array_set(*var->value.t, vals);
+						array_for_each(vals, n, val) {
+							printf("%s%s", n == 0 ? "" : " ", val);
+						}
+						xarrayfree_int(vals);
+						printf("\"%s", NORM);
+					}	break;
 				}
 				if (verbose)
 					printf(" [%s]\n", var->src);
@@ -264,12 +277,24 @@ int q_main(int argc, char **argv)
 				switch (var->type) {
 					case _Q_BOOL:
 						printf("%s%s%s",
-								YELLOW, *var->value.b ? "1" : "0", NORM);
+							   YELLOW, *var->value.b ? "1" : "0", NORM);
 						break;
-				case _Q_STR:
-				case _Q_ISTR:
+					case _Q_STR:
+					case _Q_ISTR:
 						printf("%s%s%s", RED, *var->value.s, NORM);
 						break;
+					case _Q_ISET: {
+						DECLARE_ARRAY(vals);
+						size_t n;
+						char  *val;
+
+						array_set(*var->value.t, vals);
+						array_for_each(vals, n, val) {
+							printf("%s%s", n == 0 ? RED : " ", val);
+						}
+						xarrayfree_int(vals);
+						printf("%s", NORM);
+					}	break;
 				}
 				if (verbose)
 					printf(" [%s]\n", var->src);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-11-07 10:53 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-11-07 10:53 UTC (permalink / raw
  To: gentoo-commits

commit:     647847ced7d1de713383802b963c74b45a17b577
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Nov  7 10:52:58 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Nov  7 10:52:58 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=647847ce

main: parse/populate USE var

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h | 1 +
 main.c    | 2 ++
 2 files changed, 3 insertions(+)

diff --git a/applets.h b/applets.h
index 8918ff0..be5aad6 100644
--- a/applets.h
+++ b/applets.h
@@ -171,6 +171,7 @@ extern char *binhost;
 extern char *pkgdir;
 extern char *port_tmpdir;
 extern char *features;
+extern char *ev_use;
 extern char *install_mask;
 extern DEFINE_ARRAY(overlays);
 extern DEFINE_ARRAY(overlay_names);

diff --git a/main.c b/main.c
index 01b2542..6a79eef 100644
--- a/main.c
+++ b/main.c
@@ -42,6 +42,7 @@ char *binhost;
 char *pkgdir;
 char *port_tmpdir;
 char *features;
+char *ev_use;
 char *install_mask;
 DECLARE_ARRAY(overlays);
 DECLARE_ARRAY(overlay_names);
@@ -625,6 +626,7 @@ env_vars vars_to_read[] = {
 	_Q_EVS(ISTR, CONFIG_PROTECT_MASK, config_protect_mask, "")
 	_Q_EVB(BOOL, NOCOLOR,             nocolor,             0)
 	_Q_EVS(ISTR, FEATURES,            features,            "")
+	_Q_EVS(ISTR, USE,                 ev_use,              "")
 	_Q_EVS(STR,  EPREFIX,             eprefix,             CONFIG_EPREFIX)
 	_Q_EVS(STR,  EMERGE_LOG_DIR,      portlogdir,          CONFIG_EPREFIX "var/log")
 	_Q_EVS(STR,  PORTDIR,             main_overlay,        CONFIG_EPREFIX "var/db/repos/gentoo")


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-10-09 12:03 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-10-09 12:03 UTC (permalink / raw
  To: gentoo-commits

commit:     1875affac2e397fa5529d05ecd70a0139a544170
Author:     Sam James <sam <AT> gentoo <DOT> org>
AuthorDate: Wed Sep 29 00:54:12 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Oct  9 12:03:18 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1875affa

qmerge: fix typo in output

Signed-off-by: Sam James <sam <AT> gentoo.org>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index aae3e26..6defd5b 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -2067,7 +2067,7 @@ int qmerge_main(int argc, char **argv)
 			install = 0;
 			warn("Using these options are likely to break your "
 					"system at this point. export QMERGE=1; "
-					"if you think you know what your doing.");
+					"if you think you know what you're doing.");
 		}
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-10-03 11:15 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-10-03 11:15 UTC (permalink / raw
  To: gentoo-commits

commit:     62998b38d2dec75a06c1fc551244e1e75831e284
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  3 11:14:55 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct  3 11:14:55 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=62998b38

qmerge: ensure temp dir exists before writing environment to it

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 406121c..aae3e26 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -740,7 +740,8 @@ pkg_run_func_at(
 		/* TODO: This should be fatal upon error */
 		"emake() { ${MAKE:-make} ${MAKEOPTS} \"$@\"; }\n"
 		/* Unpack the env */
-		"{ bzip2 -dc '%1$s/environment.bz2' > \"%6$s/environment\" "
+		"{ mkdir -p \"%6$s\"; "
+		  "bzip2 -dc '%1$s/environment.bz2' > \"%6$s/environment\" "
 		  "|| exit 1; }\n"
 		/* Load the main env */
 		". \"%6$s/environment\"\n"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-10-03  8:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-10-03  8:54 UTC (permalink / raw
  To: gentoo-commits

commit:     a6538b5c52f822dc3d67c53ddcda475cd0610d33
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  3 07:59:59 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct  3 07:59:59 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a6538b5c

qpkg.c: fix crash on empty PKGDIR, bug #815622

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/qpkg.c b/qpkg.c
index 533e05c..7da0263 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -76,6 +76,8 @@ qpkg_clean(char *dirp)
 		return 1;
 
 	bin_pkgs = tree_get_atoms(pkgs, true, bin_pkgs);
+	if (bin_pkgs == NULL)
+		return 1;
 	array_set(bin_pkgs, bins);
 
 	if (eclean) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-09-27 18:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-09-27 18:14 UTC (permalink / raw
  To: gentoo-commits

commit:     0a88e57c8ed363aee8c30a6dd66a50d928cfcbd8
Author:     Joakim Tjernlund <Joakim.Tjernlund <AT> infinera <DOT> com>
AuthorDate: Mon Sep 27 18:12:36 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Sep 27 18:12:36 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0a88e57c

qmerge: run pkg_prerm right before merging files from replacing version

ensure that pkg_prerm can run with the files from the package it was
defined at, that is run it right before any files are replaced

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index cf511ad..406121c 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1428,6 +1428,22 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	makeargv(config_protect, &cp_argc, &cp_argv);
 	makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
 
+	/* call pkg_prerm right before we merge the replacment version such
+	 * that any logic it defines, can use stuff installed by the package */
+	switch (replacing) {
+		case NEWER:
+		case OLDER:
+		case EQUAL:
+			if (!pretend)
+				pkg_run_func("vdb", pm_phases, PKG_PRERM, D, T, eapi, replver);
+			break;
+		default:
+			warn("no idea how we reached here.");
+		case ERROR:
+		case NOT_EQUAL:
+			break;
+	}
+
 	objs = NULL;
 	if ((contents = fopen("vdb/CONTENTS", "w")) == NULL) {
 		errf("could not open vdb/CONTENTS for writing");
@@ -1546,8 +1562,10 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, depend_atom *rpkg, set *keep,
 
 	portroot_fd = cat_ctx->ctx->portroot_fd;
 
-	/* execute the pkg_prerm step */
-	if (!pretend) {
+	/* execute the pkg_prerm step if we're just unmerging, not when
+	 * replacing, pkg_merge will have called prerm right before merging
+	 * the replacement package */
+	if (!pretend && rpkg == NULL) {
 		buf = tree_pkg_meta_get(pkg_ctx, EAPI);
 		phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
 		buf = tree_pkg_meta_get(pkg_ctx, EAPI);  /* when phases caused ralloc */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-07-06  6:43 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-07-06  6:43 UTC (permalink / raw
  To: gentoo-commits

commit:     a7fdc5749013b873ec1df8113d3f28e8e624551d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Jul  6 06:43:28 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Jul  6 06:43:28 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a7fdc574

TODO: update qmerge items

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/TODO.md b/TODO.md
index 8188fe1..e9b6454 100644
--- a/TODO.md
+++ b/TODO.md
@@ -28,6 +28,8 @@
 - make tree\_get\_metadata also retrieve maintainer type, such that
   qlist can query for maintainer email or type, ideally to do
   qlist -Iv $(portageq --repo gentoo --orphaned) in one step (bug 711466#c3)
+- atom\_compare should have a flags argument which specifies how to
+  match, e.g. ignore REPO, SUBSLOT, etc. for use in e.g. qmerge
 
 # tests
 - add test for qsearch to avoid repetitions like
@@ -38,20 +40,16 @@
 - needs safe deleting (merge in place rather than unmerge;merge)
 - multiple binary repos (talk to zmedico)
 - handle compressed Packages file (talk to zmedico)
-- handle binary Packages file (talk to zmedico)
 - gpg sign the packages file (before compression)
 - binary vdb (sqlite) ... talk to zmedico
 - remote vdb
 - parallel fetch tbz2s
-- check order of pkg\_{pre,post}{inst,rm} during install, unmerge, and upgrade
 - env is not saved/restored between pkg\_{pre,post}inst (see portage and REPO\_LAYOUT\_CONF\_WARN)
 - support installing via path to tbz2 package
 - support TTL field in binpkgs file
-- merge duplicate atoms on the CLI (`qmerge -Uq nano nano nano`)
 - unmerging should clean out @world set
 - fixup lame misnaming of force\_download (--fetch/--force) actually
   not-forcing things
-- use xpak.h instead of shelling out to qxpak binary
 
 # qdepends
 - -v should lookup whether packages are installed for || cases/colouring


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-07-05  8:40 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-07-05  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     eb752dfa3135774ddd9e409f007356528fba4391
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jul  5 08:39:24 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jul  5 08:39:24 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=eb752dfa

qmerge: ignore subslot in calculating replacing version

Original patch by Joakim Tjernlund <Joakim.Tjernlund <AT> infinera.com>

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 9cbcc45..a624b89 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1095,13 +1095,23 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 
 	previnst = best_version(slotatom, BV_INSTALLED);
 	if (previnst != NULL) {
-		char *orepo = previnst->atom->REPO;
-		previnst->atom->REPO = NULL;
-		/* drop REPO from query, we don't care about where the
-		 * replacement comes from here */
-		replacing = atom_compare(mpkg->atom, previnst->atom);
-		replver = previnst->atom->PVR;
-		previnst->atom->REPO = orepo;
+		char *orepo;
+		char *osubslot;
+
+		/* drop REPO and SUBSLOT from query, we don't care about where
+		 * the replacement comes from here, SUBSLOT only affects rebuild
+		 * triggering */
+		orepo                   = previnst->atom->REPO;
+		osubslot                = previnst->atom->SUBSLOT;
+		previnst->atom->REPO    = NULL;
+		previnst->atom->SUBSLOT = NULL;
+
+		replacing               = atom_compare(mpkg->atom, previnst->atom);
+		replver                 = previnst->atom->PVR;
+
+		/* restore atom for later printing/handling */
+		previnst->atom->REPO    = orepo;
+		previnst->atom->SUBSLOT = osubslot;
 	}
 
 	(void)qprint_tree_node(level, mpkg, previnst, replacing);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-07-01 10:07 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-07-01 10:07 UTC (permalink / raw
  To: gentoo-commits

commit:     3b1e1439445bb6694d2075043a1ecc2f1a323e7c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  1 10:07:24 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jul  1 10:07:24 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3b1e1439

qmerge: avoid crash when there are no objects

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index bf8dc21..9cbcc45 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1485,7 +1485,8 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	freeargv(cpm_argc, cpm_argv);
 
 	/* Clean up the package state */
-	free_set(objs);
+	if (objs != NULL)
+		free_set(objs);
 	free(D);
 	free(T);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-07-01 10:05 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-07-01 10:05 UTC (permalink / raw
  To: gentoo-commits

commit:     ab6a74c11df188a902c1d2a007661a4334d558bc
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jul  1 10:02:22 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jul  1 10:02:22 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ab6a74c1

qmerge: ignore REPO in version replacement calculation

When we up/downgrade a package, or replace it, we don't care what
repository it comes from.  Since atom_compare checks it when it's in
query, simply drop it for that call.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/qmerge.c b/qmerge.c
index 2323f78..bf8dc21 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1095,8 +1095,13 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 
 	previnst = best_version(slotatom, BV_INSTALLED);
 	if (previnst != NULL) {
+		char *orepo = previnst->atom->REPO;
+		previnst->atom->REPO = NULL;
+		/* drop REPO from query, we don't care about where the
+		 * replacement comes from here */
 		replacing = atom_compare(mpkg->atom, previnst->atom);
 		replver = previnst->atom->PVR;
+		previnst->atom->REPO = orepo;
 	}
 
 	(void)qprint_tree_node(level, mpkg, previnst, replacing);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-30  6:26 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-30  6:26 UTC (permalink / raw
  To: gentoo-commits

commit:     9b169ce0e900cae2ff3112d697d439a3084335e4
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 30 06:26:21 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 30 06:26:21 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9b169ce0

qmerge: allow installing virtual/* and acct-*/*

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index d6532eb..2323f78 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -239,7 +239,8 @@ best_version(const depend_atom *atom, int mode)
 			_qmerge_vdb_tree = vdb;
 		}
 		tmv = tree_match_atom(vdb, atom,
-				TREE_MATCH_LATEST | TREE_MATCH_FIRST);
+				TREE_MATCH_LATEST  | TREE_MATCH_FIRST |
+				TREE_MATCH_VIRTUAL | TREE_MATCH_ACCT);
 	}
 
 	if (mode & BV_BINPKG) {
@@ -255,7 +256,8 @@ best_version(const depend_atom *atom, int mode)
 			_qmerge_binpkg_tree = binpkg;
 		}
 		tmp = tree_match_atom(binpkg, atom,
-				TREE_MATCH_LATEST | TREE_MATCH_FIRST | TREE_MATCH_METADATA);
+				TREE_MATCH_LATEST  | TREE_MATCH_FIRST | TREE_MATCH_METADATA |
+				TREE_MATCH_VIRTUAL | TREE_MATCH_ACCT);
 	}
 
 	if (tmv == NULL && tmp == NULL)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-24  6:44 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-24  6:44 UTC (permalink / raw
  To: gentoo-commits

commit:     f3fe974732b9dc08f07545b713e5a78922af955e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 24 06:44:20 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun 24 06:44:20 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f3fe9747

qmerge: add support for REPLACING_VERSIONS and REPLACED_BY_VERSION

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 57 +++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 41 insertions(+), 16 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index e3be6a2..d6532eb 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -98,7 +98,7 @@ typedef struct llist_char_t llist_char;
 
 static void pkg_fetch(int, const depend_atom *, const tree_match_ctx *);
 static void pkg_merge(int, const depend_atom *, const tree_match_ctx *);
-static int pkg_unmerge(tree_pkg_ctx *, set *, int, char **, int, char **);
+static int pkg_unmerge(tree_pkg_ctx *, depend_atom *, set *, int, char **, int, char **);
 
 static bool
 qmerge_prompt(const char *p)
@@ -652,6 +652,19 @@ static struct {
 	{ PKG_PRERM,    "pkg_prerm",    {1,1,1,1,1,1,1,1,1} },
 	{ PKG_POSTRM,   "pkg_postrm",   {1,1,1,1,1,1,1,1,1} }
 };
+static struct {
+	enum pkg_phases phase;
+	const char     *varname;
+} phase_replacingvers[] = {
+	{ 0,            NULL                  },   /* align */
+	/* phase        varname                  PMS 11.1.2 */
+	{ PKG_PRETEND,  "REPLACING_VERSIONS"  },
+	{ PKG_SETUP,    "REPLACING_VERSIONS"  },
+	{ PKG_PREINST,  "REPLACING_VERSIONS"  },
+	{ PKG_POSTINST, "REPLACING_VERSIONS"  },
+	{ PKG_PRERM,    "REPLACED_BY_VERSION" },
+	{ PKG_POSTRM,   "REPLACED_BY_VERSION" }
+};
 
 static void
 pkg_run_func_at(
@@ -661,7 +674,8 @@ pkg_run_func_at(
 		enum pkg_phases phaseidx,
 		const char     *D,
 		const char     *T,
-		const char     *EAPI)
+		const char     *EAPI,
+		const char     *replacing)
 {
 	const char *func;
 	const char *phase;
@@ -743,8 +757,11 @@ pkg_run_func_at(
 		/* we do not support preserve-libs yet, so force
 		 * preserve_old_lib instead */
 		"export FEATURES=\"${FEATURES/preserve-libs/}\"\n"
+		/* replacing versions: we ignore EAPI availability, for it will
+		 * never hurt */
+		"export %7$s=\"%8$s\"\n"
 		/* Finally run the func */
-		"%7$s%2$s\n"
+		"%9$s%2$s\n"
 		/* Ignore func return values (not exit values) */
 		":",
 		/*1*/ vdb_path,
@@ -753,7 +770,9 @@ pkg_run_func_at(
 		/*4*/ portroot,
 		/*5*/ D,
 		/*6*/ T,
-		/*7*/ debug ? "set -x;" : "");
+		/*7*/ phase_replacingvers[phaseidx].varname,
+		/*8*/ replacing,
+		/*9*/ debug ? "set -x;" : "");
 	xsystembash(script, dirfd);
 	free(script);
 }
@@ -1052,7 +1071,8 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	char          **cp_argv;
 	char          **cpm_argv;
 	int             tbz2size;
-	int             replacing     = 0;
+	const char     *replver       = "";
+	int             replacing     = NOT_EQUAL;
 	char           *eprefix       = NULL;
 	size_t          eprefix_len   = 0;
 	char           *pm_phases     = NULL;
@@ -1072,8 +1092,10 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	slotatom = atom_explode(buf);
 
 	previnst = best_version(slotatom, BV_INSTALLED);
-	if (previnst != NULL)
-		replacing = atom_compare(mpkg->atom, slotatom);
+	if (previnst != NULL) {
+		replacing = atom_compare(mpkg->atom, previnst->atom);
+		replver = previnst->atom->PVR;
+	}
 
 	(void)qprint_tree_node(level, mpkg, previnst, replacing);
 
@@ -1349,9 +1371,9 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	eat_file("vdb/DEFINED_PHASES", &pm_phases, &pm_phases_len);
 
 	if (!pretend) {
-		pkg_run_func("vdb", pm_phases, PKG_PRETEND, D, T, eapi);
-		pkg_run_func("vdb", pm_phases, PKG_SETUP,   D, T, eapi);
-		pkg_run_func("vdb", pm_phases, PKG_PREINST, D, T, eapi);
+		pkg_run_func("vdb", pm_phases, PKG_PRETEND, D, T, eapi, replver);
+		pkg_run_func("vdb", pm_phases, PKG_SETUP,   D, T, eapi, replver);
+		pkg_run_func("vdb", pm_phases, PKG_PREINST, D, T, eapi, replver);
 	}
 
 	{
@@ -1429,7 +1451,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 		case EQUAL:
 			/* We need to really set this unmerge pending after we
 			 * look at contents of the new pkg */
-			pkg_unmerge(previnst->pkg, objs,
+			pkg_unmerge(previnst->pkg, mpkg->atom, objs,
 					cp_argc, cp_argv, cpm_argc, cpm_argv);
 			break;
 		default:
@@ -1441,7 +1463,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 
 	/* run postinst */
 	if (!pretend)
-		pkg_run_func("vdb", pm_phases, PKG_POSTINST, D, T, eapi);
+		pkg_run_func("vdb", pm_phases, PKG_POSTINST, D, T, eapi, replver);
 
 	if (eprefix != NULL)
 		free(eprefix);
@@ -1492,7 +1514,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 }
 
 static int
-pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
+pkg_unmerge(tree_pkg_ctx *pkg_ctx, depend_atom *rpkg, set *keep,
 		int cp_argc, char **cp_argv, int cpm_argc, char **cpm_argv)
 {
 	tree_cat_ctx *cat_ctx = pkg_ctx->cat_ctx;
@@ -1524,7 +1546,8 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 		buf = tree_pkg_meta_get(pkg_ctx, EAPI);  /* when phases caused ralloc */
 		if (phases != NULL) {
 			mkdirat(pkg_ctx->fd, "temp", 0755);
-			pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_PRERM, T, T, buf);
+			pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_PRERM,
+					T, T, buf, rpkg == NULL ? "" : rpkg->PVR);
 		}
 	}
 
@@ -1660,7 +1683,8 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 		buf = tree_pkg_meta_get(pkg_ctx, EAPI);
 		phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
 		/* execute the pkg_postrm step */
-		pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_POSTRM, T, T, buf);
+		pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_POSTRM,
+				T, T, buf, rpkg == NULL ? "" : rpkg->PVR);
 
 		/* finally delete the vdb entry */
 		rm_rf_at(pkg_ctx->fd, ".");
@@ -1837,7 +1861,8 @@ qmerge_unmerge_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	(void)list_set(priv, &todo);
 	for (p = todo; *p != NULL; p++) {
 		if (qlist_match(pkg_ctx, *p, NULL, true, false))
-			pkg_unmerge(pkg_ctx, NULL, cp_argc, cp_argv, cpm_argc, cpm_argv);
+			pkg_unmerge(pkg_ctx, NULL, NULL,
+					cp_argc, cp_argv, cpm_argc, cpm_argv);
 	}
 
 	free(todo);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-23  7:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-23  7:14 UTC (permalink / raw
  To: gentoo-commits

commit:     08894d7dedab849f27145f2f3d3fe5dee6796d21
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 23 07:13:35 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 23 07:13:35 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=08894d7d

quse: make return code reflect whether a match was made

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 quse.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/quse.c b/quse.c
index 5105638..400339a 100644
--- a/quse.c
+++ b/quse.c
@@ -400,23 +400,26 @@ quse_search_profiles_desc(
 	return ret;
 }
 
-static void
+static bool
 quse_describe_flag(const char *root, const char *overlay,
 		struct quse_state *state)
 {
 	char buf[_Q_PATH_MAX];
 	int portdirfd;
+	bool ret = false;
 
 	snprintf(buf, sizeof(buf), "%s/%s", root, overlay);
 	portdirfd = open(buf, O_RDONLY|O_CLOEXEC|O_PATH);
 	if (portdirfd == -1)
-		return;
+		return false;
 
-	quse_search_use_desc(portdirfd, state);
-	quse_search_use_local_desc(portdirfd, state);
-	quse_search_profiles_desc(portdirfd, state);
+	ret |= quse_search_use_desc(portdirfd, state);
+	ret |= quse_search_use_local_desc(portdirfd, state);
+	ret |= quse_search_profiles_desc(portdirfd, state);
 
 	close(portdirfd);
+
+	return ret;
 }
 
 static int
@@ -437,6 +440,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	int maxlen;
 	int cnt;
 	int portdirfd = -1;  /* pacify compiler */
+	int ret = 0;
 
 	if (state->match || state->do_describe) {
 		atom = tree_get_atom(pkg_ctx, false);
@@ -538,6 +542,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	}
 
 	if (match) {
+		ret++;
 		atom = tree_get_atom(pkg_ctx, state->need_full_atom);
 		if (quiet) {
 			printf("%s\n", atom_format(state->fmt, atom));
@@ -648,12 +653,13 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	if (state->do_describe && !state->do_licence)
 		close(portdirfd);
 
-	return EXIT_SUCCESS;
+	return ret;
 }
 
 int quse_main(int argc, char **argv)
 {
 	int i;
+	int ret;
 	size_t n;
 	const char *overlay;
 	char *match = NULL;
@@ -719,6 +725,7 @@ int quse_main(int argc, char **argv)
 				state.fmt = "%[CATEGORY]%[PN]";
 	}
 
+	ret = EXIT_FAILURE;
 	if (state.do_describe && state.match == NULL) {
 		array_for_each(overlays, n, overlay) {
 			tree_ctx *t = NULL;
@@ -726,7 +733,8 @@ int quse_main(int argc, char **argv)
 				t = tree_open(portroot, overlay);  /* used for repo */
 			if (t != NULL)
 				state.repo = t->repo;
-			quse_describe_flag(portroot, overlay, &state);
+			if (quse_describe_flag(portroot, overlay, &state))
+				ret = EXIT_SUCCESS;
 			if (t != NULL)
 				tree_close(t);
 		}
@@ -735,7 +743,9 @@ int quse_main(int argc, char **argv)
 		if (t != NULL) {
 			state.overlay = NULL;
 			state.repo = NULL;
-			tree_foreach_pkg_sorted(t, quse_results_cb, &state, state.match);
+			if (tree_foreach_pkg_sorted(t, quse_results_cb,
+						&state, state.match) > 0)
+				ret = EXIT_SUCCESS;
 			tree_close(t);
 		}
 	} else {
@@ -744,8 +754,9 @@ int quse_main(int argc, char **argv)
 			state.overlay = overlay;
 			if (t != NULL) {
 				state.repo = state.need_full_atom ? t->repo : NULL;
-				tree_foreach_pkg_sorted(t, quse_results_cb,
-						&state, state.match);
+				if (tree_foreach_pkg_sorted(t, quse_results_cb,
+							&state, state.match) > 0)
+					ret = EXIT_SUCCESS;
 				tree_close(t);
 			}
 		}
@@ -760,5 +771,5 @@ int quse_main(int argc, char **argv)
 	if (state.match != NULL)
 		atom_implode(state.match);
 
-	return EXIT_SUCCESS;
+	return ret;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-21 20:04 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-21 20:04 UTC (permalink / raw
  To: gentoo-commits

commit:     85ca62da1e01820085da6cd0cb053c1f1a299dac
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 21 20:04:02 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 21 20:04:02 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=85ca62da

qmerge: check phase funcs against PMS whether they should be run

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++-------------
 1 file changed, 72 insertions(+), 17 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index a9dbe4b..1f1bb1e 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -627,15 +627,61 @@ qprint_tree_node(
 	return c;
 }
 
+/* PMS 9.2 Call order */
+enum pkg_phases {
+	PKG_PRETEND  = 1,
+	PKG_SETUP    = 2,
+	/* skipping src_* */
+	PKG_PREINST  = 3,
+	PKG_POSTINST = 4,
+	PKG_PRERM    = 5,
+	PKG_POSTRM   = 6
+};
+#define MAX_EAPI  8
+static struct {
+	enum pkg_phases phase;
+	const char     *phasestr;
+	unsigned char   eapi[1 + MAX_EAPI];
+} phase_table[] = {
+	{ 0,            NULL,           {0,0,0,0,0,0,0,0,0} },   /* align */
+	/* phase                   EAPI: 0 1 2 3 4 5 6 7 8 */
+	{ PKG_PRETEND,  "pkg_pretend",  {0,0,0,0,1,1,1,1,1} },   /* table 9.3 */
+	{ PKG_SETUP,    "pkg_setup",    {1,1,1,1,1,1,1,1,1} },
+	{ PKG_PREINST,  "pkg_preinst",  {1,1,1,1,1,1,1,1,1} },
+	{ PKG_POSTINST, "pkg_postinst", {1,1,1,1,1,1,1,1,1} },
+	{ PKG_PRERM,    "pkg_prerm",    {1,1,1,1,1,1,1,1,1} },
+	{ PKG_POSTRM,   "pkg_postrm",   {1,1,1,1,1,1,1,1,1} }
+};
+
 static void
-pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char *func, const char *D, const char *T)
+pkg_run_func_at(
+		int             dirfd,
+		const char     *vdb_path,
+		const char     *phases,
+		enum pkg_phases phaseidx,
+		const char     *D,
+		const char     *T,
+		const char     *EAPI)
 {
+	const char *func;
 	const char *phase;
-	char *script;
+	char       *script;
+	int         eapi;
+
+	/* EAPI officially is a string, but since the official ones are only
+	 * numbers, we'll just go with the numbers */
+	eapi = (int)strtol(EAPI, NULL, 10);
+	if (eapi > MAX_EAPI)
+		eapi = MAX_EAPI;  /* let's hope latest known EAPI is closest */
+
+	/* see if this function should be run for the EAPI */
+	if (!phase_table[phaseidx].eapi[eapi])
+		return;
 
 	/* This assumes no func is a substring of another func.
 	 * Today, that assumption is valid for all funcs ...
 	 * The phases are the func with the "pkg_" chopped off. */
+	func = phase_table[phaseidx].phasestr;
 	phase = func + 4;
 	if (strstr(phases, phase) == NULL) {
 		qprintf("--- %s\n", func);
@@ -978,8 +1024,6 @@ pkg_extract_xpak_cb(
 }
 
 /* oh shit getting into pkg mgt here. FIXME: write a real dep resolver. */
-static char  *pm_phases;
-static size_t pm_phases_len;
 static void
 pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 {
@@ -991,8 +1035,6 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	depend_atom    *slotatom;
 	FILE           *fp;
 	FILE           *contents;
-	char           *eprefix = NULL;
-	size_t          eprefix_len = 0;
 	char            buf[1024];
 	char           *p;
 	char           *D;
@@ -1009,7 +1051,13 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	char          **cp_argv;
 	char          **cpm_argv;
 	int             tbz2size;
-	int             replacing = 0;
+	int             replacing     = 0;
+	char           *eprefix       = NULL;
+	size_t          eprefix_len   = 0;
+	char           *pm_phases     = NULL;
+	size_t          pm_phases_len = 0;
+	char           *eapi          = NULL;
+	size_t          eapi_len      = 0;
 
 	if (!install || !mpkg || !qatom)
 		return;
@@ -1292,16 +1340,16 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 
 	fflush(stdout);
 
+	eat_file("vdb/EPREFIX", &eprefix, &eprefix_len);
+	eat_file("vdb/EAPI", &eapi, &eapi_len);
 	eat_file("vdb/DEFINED_PHASES", &pm_phases, &pm_phases_len);
+
 	if (!pretend) {
-		pkg_run_func("vdb", pm_phases, "pkg_pretend", D, T);
-		pkg_run_func("vdb", pm_phases, "pkg_setup", D, T);
-		pkg_run_func("vdb", pm_phases, "pkg_preinst", D, T);
+		pkg_run_func("vdb", pm_phases, PKG_PRETEND, D, T, eapi);
+		pkg_run_func("vdb", pm_phases, PKG_SETUP,   D, T, eapi);
+		pkg_run_func("vdb", pm_phases, PKG_PREINST, D, T, eapi);
 	}
 
-	if (!eat_file("vdb/EPREFIX", &eprefix, &eprefix_len))
-		eprefix_len = 0;
-
 	{
 		int imagefd = open("image", O_RDONLY);
 		size_t masklen = strlen(install_mask) + 1 +
@@ -1312,7 +1360,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 		if (fstat(imagefd, &st) == -1) {
 			close(imagefd);
 			err("Cannot stat image dirfd");
-		} else if (eprefix_len > 0) {
+		} else if (eprefix != NULL && eprefix[0] == '/') {
 			int imagepfx = openat(imagefd, eprefix + 1, O_RDONLY);
 			if (imagepfx != -1) {
 				close(imagefd);
@@ -1374,7 +1422,12 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 
 	/* run postinst */
 	if (!pretend)
-		pkg_run_func("vdb", pm_phases, "pkg_postinst", D, T);
+		pkg_run_func("vdb", pm_phases, PKG_POSTINST, D, T, eapi);
+
+	if (eapi != NULL)
+		free(eapi);
+	if (pm_phases != NULL)
+		free(pm_phases);
 
 	/* XXX: hmm, maybe we'll want to strip more ? */
 	unlink("vdb/environment");
@@ -1466,10 +1519,11 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 
 	/* execute the pkg_prerm step */
 	if (!pretend) {
+		buf = tree_pkg_meta_get(pkg_ctx, EAPI);
 		phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
 		if (phases != NULL) {
 			mkdirat(pkg_ctx->fd, "temp", 0755);
-			pkg_run_func_at(pkg_ctx->fd, ".", phases, "pkg_prerm", T, T);
+			pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_PRERM, T, T, buf);
 		}
 	}
 
@@ -1602,9 +1656,10 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 	}
 
 	if (!pretend) {
+		buf = tree_pkg_meta_get(pkg_ctx, EAPI);
 		phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
 		/* execute the pkg_postrm step */
-		pkg_run_func_at(pkg_ctx->fd, ".", phases, "pkg_postrm", T, T);
+		pkg_run_func_at(pkg_ctx->fd, ".", phases, PKG_POSTRM, T, T, buf);
 
 		/* finally delete the vdb entry */
 		rm_rf_at(pkg_ctx->fd, ".");


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-17  6:27 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-17  6:27 UTC (permalink / raw
  To: gentoo-commits

commit:     855622160f515a4d4208ccabecae54c00a5b42cf
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 17 06:26:50 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun 17 06:26:50 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=85562216

qmerge: define BROOT, SYSROOT and ESYSROOT for phase running

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/qmerge.c b/qmerge.c
index 768877f..a9dbe4b 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -686,6 +686,10 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 		"export MERGE_TYPE=binary\n"
 		"export ROOT='%4$s'\n"
 		"export EROOT=\"${ROOT%%/}${EPREFIX%%/}/\"\n"
+		/* BROOT, SYSROOT, ESYSROOT: PMS table 8.3 Prefix values for DEPEND */
+		"export BROOT=\n"
+		"export SYSROOT=\"${ROOT}\"\n"
+		"export ESYSROOT=\"${EROOT}\"\n"
 		"export D=\"%5$s\"\n"
 		"export ED=\"${D%%/}${EPREFIX%%/}/\"\n"
 		"export T=\"%6$s\"\n"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-16 20:11 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-16 20:11 UTC (permalink / raw
  To: gentoo-commits

commit:     19211108eb68865b9ba155003f69f073775e3be6
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 16 20:08:24 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 16 20:11:11 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=19211108

qmerge: slightly re-order tree_pkg_meta_get calls for validity

previous calls to tree_pkg_meta_get might be invalidated on a next call,
so try to keep validity of pointers within tree_pkg_meta_get calls

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 43f537a..768877f 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1108,7 +1108,8 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	}
 
 	/* Set up our temp dir to unpack this stuff   FIXME p -> builddir */
-	xasprintf(&p, "%s/qmerge/%s/%s", port_tmpdir, mpkg->atom->CATEGORY, mpkg->atom->PF);
+	xasprintf(&p, "%s/qmerge/%s/%s", port_tmpdir,
+			mpkg->atom->CATEGORY, mpkg->atom->PF);
 	mkdir_p(p, 0755);
 	xchdir(p);
 	xasprintf(&D, "%s/image", p);
@@ -1457,14 +1458,9 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 	if (pretend == 100)
 		return 0;
 
-	/* First get a handle on the things to clean up */
-	buf = tree_pkg_meta_get(pkg_ctx, CONTENTS);
-	if (buf == NULL)
-		return 1;
-
 	portroot_fd = cat_ctx->ctx->portroot_fd;
 
-	/* Then execute the pkg_prerm step */
+	/* execute the pkg_prerm step */
 	if (!pretend) {
 		phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
 		if (phases != NULL) {
@@ -1482,6 +1478,11 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 	unmerge_config_protected =
 		strstr(features, "config-protect-if-modified") != NULL;
 
+	/* get a handle on the things to clean up */
+	buf = tree_pkg_meta_get(pkg_ctx, CONTENTS);
+	if (buf == NULL)
+		return 1;
+
 	for (; (buf = strtok_r(buf, "\n", &savep)) != NULL; buf = NULL) {
 		bool            del;
 		contents_entry *e;
@@ -1597,14 +1598,15 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 	}
 
 	if (!pretend) {
-		/* Then execute the pkg_postrm step */
+		phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
+		/* execute the pkg_postrm step */
 		pkg_run_func_at(pkg_ctx->fd, ".", phases, "pkg_postrm", T, T);
 
-		/* Finally delete the vdb entry */
+		/* finally delete the vdb entry */
 		rm_rf_at(pkg_ctx->fd, ".");
 		unlinkat(cat_ctx->fd, pkg_ctx->name, AT_REMOVEDIR);
 
-		/* And prune the category if it's empty */
+		/* and prune the category if it's empty */
 		unlinkat(cat_ctx->ctx->tree_fd, cat_ctx->name, AT_REMOVEDIR);
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-16 19:21 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-16 19:21 UTC (permalink / raw
  To: gentoo-commits

commit:     137025a3bb18195b6e2dd57a4ec52af6db352a51
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Wed Jun 16 14:43:13 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 16 19:19:43 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=137025a3

qmerge: fix type for NULL SLOTs

Use SLOT="0" if no SLOT exists, not the other way around

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 0e7ada4..3b74426 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1015,7 +1015,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	snprintf(buf, sizeof(buf), "%s/%s:%s",
 			mpkg->atom->CATEGORY,
 			mpkg->atom->PN,
-			mpkg->atom->SLOT != NULL ? "0" : mpkg->atom->SLOT);
+			mpkg->atom->SLOT == NULL ? "0" : mpkg->atom->SLOT);
 	slotatom = atom_explode(buf);
 
 	previnst = best_version(slotatom, BV_INSTALLED);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-16 19:21 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-16 19:21 UTC (permalink / raw
  To: gentoo-commits

commit:     70e1dcf3fb72456518484103d5148c59d3c0f27a
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Wed Jun 16 14:43:12 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 16 19:19:44 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=70e1dcf3

qmerge: do not run pkg_pretend/pkg_setup/pkg_preinst if pretend

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index ac7ce6d..583a27e 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1288,9 +1288,11 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	fflush(stdout);
 
 	eat_file("vdb/DEFINED_PHASES", &pm_phases, &pm_phases_len);
-	pkg_run_func("vdb", pm_phases, "pkg_pretend", D, T);
-	pkg_run_func("vdb", pm_phases, "pkg_setup", D, T);
-	pkg_run_func("vdb", pm_phases, "pkg_preinst", D, T);
+	if (!pretend) {
+		pkg_run_func("vdb", pm_phases, "pkg_pretend", D, T);
+		pkg_run_func("vdb", pm_phases, "pkg_setup", D, T);
+		pkg_run_func("vdb", pm_phases, "pkg_preinst", D, T);
+	}
 
 	if (!eat_file("vdb/EPREFIX", &eprefix, &eprefix_len))
 		eprefix_len = 0;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-16 19:21 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-16 19:21 UTC (permalink / raw
  To: gentoo-commits

commit:     2d3465b19eafb2577974cb9fa48a3938cdb38925
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Wed Jun 16 14:53:00 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 16 19:19:44 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2d3465b1

qmerge: Protect against another NULL hash

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 583a27e..43f537a 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -804,7 +804,7 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 			hash = hash_file_at(subfd_src, name, HASH_MD5);
 			if (!pretend)
 				fprintf(contents, "obj %s %s %zu""\n",
-						cpath, hash, (size_t)st.st_mtime);
+					cpath, hash ? hash : "xxx", (size_t)st.st_mtime);
 
 			/* Check CONFIG_PROTECT */
 			if (config_protected(cpath + eprefix_len,


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-16 19:21 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-16 19:21 UTC (permalink / raw
  To: gentoo-commits

commit:     a1c3e594cd2cbf49f8eacac038e1b8f8cfb64199
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Wed Jun 16 14:52:59 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 16 19:19:43 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a1c3e594

qmerge: Use same image dir. name as portage

atom_to_string(mpkg->atom) will attach ::gentoo to name which is
different from portage.

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 3b74426..ac7ce6d 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1108,7 +1108,7 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 	}
 
 	/* Set up our temp dir to unpack this stuff   FIXME p -> builddir */
-	xasprintf(&p, "%s/qmerge/%s", port_tmpdir, atom_to_string(mpkg->atom));
+	xasprintf(&p, "%s/qmerge/%s/%s", port_tmpdir, mpkg->atom->CATEGORY, mpkg->atom->PF);
 	mkdir_p(p, 0755);
 	xchdir(p);
 	xasprintf(&D, "%s/image", p);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-16 19:21 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-16 19:21 UTC (permalink / raw
  To: gentoo-commits

commit:     bf39c0fefdd990da681cd31376e556006e62cb10
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 16 19:03:08 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 16 19:19:43 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bf39c0fe

qmerge: add comment about hash == NULL

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 7b42956..0e7ada4 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1514,7 +1514,7 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 					char *hash = hash_file_at(portroot_fd,
 							e->name + 1, HASH_MD5);
 					protected = 0;
-					if (hash)
+					if (hash != NULL)  /* if file was not removed */
 						protected = strcmp(e->digest, (const char *)hash);
 				}
 				break;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-16 19:21 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-16 19:21 UTC (permalink / raw
  To: gentoo-commits

commit:     860ace7e297f4f79b1cd52c7bbee48a5a1ed78ce
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Wed Jun 16 14:43:11 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 16 19:19:43 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=860ace7e

qmerge: Protect against NULL ptr

hash will be NULL if file does not exist.

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 2e8730e..7b42956 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1513,7 +1513,9 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 					/* If the file wasn't modified, unmerge it */
 					char *hash = hash_file_at(portroot_fd,
 							e->name + 1, HASH_MD5);
-					protected = strcmp(e->digest, (const char *)hash);
+					protected = 0;
+					if (hash)
+						protected = strcmp(e->digest, (const char *)hash);
 				}
 				break;
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-16 19:19 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-16 19:19 UTC (permalink / raw
  To: gentoo-commits

commit:     809f7239aef0651297970fe08f85d708aec7c202
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 16 19:18:58 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 16 19:18:58 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=809f7239

qmerge: drop outdated comment

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index f5386f2..2e8730e 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1374,7 +1374,6 @@ pkg_merge(int level, const depend_atom *qatom, const tree_match_ctx *mpkg)
 
 	/* Unmerge any stray pieces from the older version which we didn't
 	 * replace */
-	/* TODO: Should see about merging with unmerge_packages() */
 	switch (replacing) {
 		case NEWER:
 		case OLDER:


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-01 19:43 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-01 19:43 UTC (permalink / raw
  To: gentoo-commits

commit:     419b78c837ff3355e0e1d0652a56678e303bcf6b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  1 18:30:24 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Jun  1 18:30:24 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=419b78c8

qlist: don't use ROOT with PKGDIR

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlist.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qlist.c b/qlist.c
index a6bcc43..48f7707 100644
--- a/qlist.c
+++ b/qlist.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2020 Gentoo Foundation
+ * Copyright 2005-2021 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005 Martin Schlemmer     - <azarah@gentoo.org>
@@ -536,7 +536,7 @@ int qlist_main(int argc, char **argv)
 		}
 	} else {
 		if (state.do_binpkgs)
-			vdb = tree_open_binpkg(portroot, pkgdir);
+			vdb = tree_open_binpkg("/", pkgdir);
 		else
 			vdb = tree_open_vdb(portroot, portvdb);
 		if (vdb != NULL) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-06-01 19:43 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-06-01 19:43 UTC (permalink / raw
  To: gentoo-commits

commit:     43ce14510666e67265dc16f0b0d72bd706074b41
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Jun  1 19:40:31 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Jun  1 19:40:31 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=43ce1451

qwhich: better support for binpkgs

- don't use ROOT with PKGDIR
- print coloured paths/matches for binpkgs
- support dirs (-d) for binpkgs

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qwhich.c | 27 +++++++++++++++++++++------
 1 file changed, 21 insertions(+), 6 deletions(-)

diff --git a/qwhich.c b/qwhich.c
index 24a9ff0..76b03a8 100644
--- a/qwhich.c
+++ b/qwhich.c
@@ -82,6 +82,7 @@ int qwhich_main(int argc, char **argv)
 	tree_ctx *t;
 	char *repo;
 	int repolen;
+	const char *ext;
 
 	memset(&m, 0, sizeof(m));
 
@@ -144,7 +145,7 @@ int qwhich_main(int argc, char **argv)
 			xarraypush_ptr(trees, t);
 	}
 	if (m.do_binpkg) {
-		t = tree_open_binpkg(portroot, pkgdir);
+		t = tree_open_binpkg("/", pkgdir);
 		if (t != NULL)
 			xarraypush_ptr(trees, t);
 	}
@@ -159,7 +160,7 @@ int qwhich_main(int argc, char **argv)
 
 	/* at least keep the IO constrained to a tree at a time */
 	array_for_each(trees, j, t) {
-		if (m.print_repo) {
+		if (m.print_repo && t->repo != NULL) {
 			repo = t->repo;
 			repolen = strlen(repo);
 		} else {
@@ -168,12 +169,24 @@ int qwhich_main(int argc, char **argv)
 				repolen = strlen(t->path) - (sizeof("/metadata/md5-cache") - 1);
 			else if (t->cachetype == CACHE_METADATA_PMS)
 				repolen = strlen(t->path) - (sizeof("/metadata/cache") - 1);
-			else if (t->cachetype == CACHE_EBUILD)
+			else if (t->cachetype == CACHE_EBUILD ||
+					t->cachetype == CACHE_BINPKGS ||
+					t->cachetype == CACHE_PACKAGES)
 				repolen = strlen(t->path);
 			else
 				repolen = 0;
 		}
 
+		switch (t->cachetype) {
+			case CACHE_BINPKGS:
+			case CACHE_PACKAGES:
+				ext = "tbz2";
+				break;
+			default:
+				ext = "ebuild";
+				break;
+		}
+
 		array_for_each(atoms, i, atom) {
 			tmc = tree_match_atom(t, atom,
 					(m.match_latest ? TREE_MATCH_LATEST : 0 ) |
@@ -186,7 +199,9 @@ int qwhich_main(int argc, char **argv)
 				} else {
 					if (t->cachetype == CACHE_METADATA_MD5 ||
 							t->cachetype == CACHE_METADATA_PMS ||
-							t->cachetype == CACHE_EBUILD)
+							t->cachetype == CACHE_EBUILD ||
+							t->cachetype == CACHE_BINPKGS ||
+							t->cachetype == CACHE_PACKAGES)
 					{
 						if (m.print_path)
 							printf("%s%.*s%s%s%s/%s%s%s\n",
@@ -196,13 +211,13 @@ int qwhich_main(int argc, char **argv)
 									DKBLUE, tmcw->atom->PN,
 									NORM);
 						else
-							printf("%s%.*s%s%s%s/%s%s/%s%s%s.ebuild%s\n",
+							printf("%s%.*s%s%s%s/%s%s/%s%s%s.%s%s\n",
 									DKGREEN, repolen, repo,
 									m.print_repo ? "::" : "/",
 									BOLD, tmcw->atom->CATEGORY,
 									DKBLUE, tmcw->atom->PN,
 									BLUE, tmcw->atom->PF,
-									DKGREEN, NORM);
+									DKGREEN, ext, NORM);
 					} else if (t->cachetype == CACHE_VDB && !m.print_path) {
 						printf("%s%s/%s%s%s.ebuild%s\n",
 								DKBLUE, tmcw->path,


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-05-31 19:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-05-31 19:14 UTC (permalink / raw
  To: gentoo-commits

commit:     e5dfd95c6425ff55b59803eeb13dbcad3af140fb
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 31 19:12:05 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 31 19:12:05 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e5dfd95c

qmerge: some silencing

- create root/vdb if it doesn't exist (instead of barking up random trees)
- avoid some duplicate slashes

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 27 ++++++++++++++++++---------
 1 file changed, 18 insertions(+), 9 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 08ce812..8f1ca3d 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -684,9 +684,9 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 		"FILESDIR=/.does/not/exist/anywhere\n"
 		"MERGE_TYPE=binary\n"
 		"ROOT='%4$s'\n"
-		"EROOT=\"/${ROOT#/}/${EPREFIX%%/}/\"\n"
+		"EROOT=\"${ROOT%%/}${EPREFIX%%/}/\"\n"
 		"D=\"%5$s\"\n"
-		"ED=\"${D%%/}/${EPREFIX%%/}/\"\n"
+		"ED=\"${D%%/}${EPREFIX%%/}/\"\n"
 		"T=\"%6$s\"\n"
 		/* we do not support preserve-libs yet, so force
 		 * preserve_old_lib instead */
@@ -1092,8 +1092,17 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 
 	/* Get a handle on the main vdb repo */
 	vdb = tree_open_vdb(portroot, portvdb);
-	if (!vdb)
-		return;
+	if (vdb == NULL) {
+		if (pretend)
+			return;
+		/* try to create a vdb if none exists yet */
+		xasprintf(&p, "%s/%s", portroot, portvdb);
+		mkdir_p(p, 0755);
+		free(p);
+		vdb = tree_open_vdb(portroot, portvdb);
+	}
+	if (vdb == NULL)
+		errf("need access to root, check permissions to access %s", portroot);
 	cat_ctx = tree_open_cat(vdb, pkg->CATEGORY);
 	if (!cat_ctx) {
 		if (errno != ENOENT) {
@@ -1347,11 +1356,10 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	makeargv(config_protect, &cp_argc, &cp_argv);
 	makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
 
-	if ((contents = fopen("vdb/CONTENTS", "w")) == NULL)
-		errf("come on wtf?");
-
 	objs = NULL;
-	{
+	if ((contents = fopen("vdb/CONTENTS", "w")) == NULL) {
+		errf("could not open vdb/CONTENTS for writing");
+	} else {
 		char *cpath;
 		int ret;
 
@@ -1365,8 +1373,9 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 
 		if (ret != 0)
 			errp("failed to merge to %s", portroot);
+
+		fclose(contents);
 	}
-	fclose(contents);
 
 	/* run postinst */
 	if (!pretend)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-05-15 12:19 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-05-15 12:19 UTC (permalink / raw
  To: gentoo-commits

commit:     13402fbd8c51f7feedcc85f2f0815768ec45ee7a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May 15 12:18:54 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May 15 12:18:54 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=13402fbd

qlop: add predict (-p) mode

Predict should be a better estimator than average, and become the new
source for estimating remaining times (with -r).

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 227 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 210 insertions(+), 17 deletions(-)

diff --git a/qlop.c b/qlop.c
index 2d01689..4783528 100644
--- a/qlop.c
+++ b/qlop.c
@@ -27,11 +27,12 @@
 
 #define QLOP_DEFAULT_LOGFILE "emerge.log"
 
-#define QLOP_FLAGS "ctaHMmuUsElerd:f:w:F:" COMMON_FLAGS
+#define QLOP_FLAGS "ctapHMmuUsElerd:f:w:F:" COMMON_FLAGS
 static struct option const qlop_long_opts[] = {
 	{"summary",   no_argument, NULL, 'c'},
 	{"time",      no_argument, NULL, 't'},
 	{"average",   no_argument, NULL, 'a'},
+	{"predict",   no_argument, NULL, 'p'},
 	{"human",     no_argument, NULL, 'H'},
 	{"machine",   no_argument, NULL, 'M'},
 	{"merge",     no_argument, NULL, 'm'},
@@ -52,6 +53,7 @@ static const char * const qlop_opts_help[] = {
 	"Print summary of average merges (implies -a)",
 	"Print time taken to complete action",
 	"Print average time taken to complete action",
+	"Print prediction of time it takes to complete action",
 	"Print elapsed time in human readable format (use with -t or -a)",
 	"Print start/elapsed time as seconds with no formatting",
 	"Show merge history",
@@ -85,6 +87,7 @@ struct qlop_mode {
 	char do_sync:1;
 	char do_running:1;
 	char do_average:1;
+	char do_predict:1;
 	char do_summary:1;
 	char do_human:1;
 	char do_machine:1;
@@ -361,6 +364,47 @@ portage never got interrupted in a way where it could not write its
 interruption to the log.  Unfortunately these scenarios happen a lot.
 As such, we can try to remedy this somewhat by using a rule of thumb
 that currently merging packages need to be withinin the last 10 days.
+
+Averages
+Compile time of packages typically changes over time (assuming the
+machine stays the same).  New major releases introduce extra code, or
+improve stuff considerably.  New compilers might take more or less time
+compiling the code.  The environment (like the toolchain) we cannot take
+into account, packages themselves, we could do something with.
+Portage unfortunately does not record the SLOT of the package it
+emerges, so we cannot use SLOT.
+- Gentoo revisions (-rX) typically do not change the code a lot
+- minor and below revisions usually are part of the same code branch
+- major revisions typically indicate a next generation of the code
+So when there is a running emerge:
+1. we value most an identical version, minus Gentoo revisions
+2. we look for merges with the same major version
+3. when there's still not enough (or anything) to balance an average
+   off, we look at merges for the same package (older major versions)
+Think of this value system as something like the weight of 1 is 5x, 2 is
+3x and 3 is just 1x.
+While this might sound really cool, it often results in the same average
+as a normal average, and so it is useless.  In particular: the best
+prediction is the most recent matching version.  If there is no exact
+match (ignoring Gentoo revisions), a projection of runtimes for previous
+merges is the next best thing, ignoring major or minor revisions, e.g.
+for GCC major versions would hold very well, but for binutils, the
+minors differ a lot (for it's on major version 2 for ages).
+
+So it seems what it boils down to, is that prediction of the simplest
+kind is probably the best here.  What we do, is we order the merge
+history of the package, and try to extrapolate the growth between the
+two last merges, e.g. 10 and 12 becomes 12 + (12 - 10) = 14.
+Now if there is only one point of history here, there's nothing to
+predict, and we best just take the value and add a 10% fuzz.
+There's two cases in this setup:
+1. predict for a version that we already have merge history for,
+   ignoring revisions, or
+2. predict for a version that's different from what we've seen before
+In case of 1. we only look at the same versions, and apply extrapolation
+based on the revisions, e.g. -r2 -> -r4.  In case of 2. we only look at
+versions that are older than the version we're predicting for.  This to
+deal with e.g. merging python-3.6 with 3.9 installed as well.
 */
 static int do_emerge_log(
 		const char *log,
@@ -653,7 +697,8 @@ static int do_emerge_log(
 				if ((q = strchr(p, '\n')) != NULL)
 					*q = '\0';
 
-				if (flags->do_average || flags->do_running)
+				if (flags->do_predict || flags->do_average ||
+						flags->do_running)
 				{
 					sync_cnt++;
 					sync_time += elapsed;
@@ -708,11 +753,15 @@ static int do_emerge_log(
 				/* see if we need this atom */
 				atomw = NULL;
 				if (atomset == NULL) {
+					int orev = atom->PR_int;
+					if (flags->do_predict)
+						atom->PR_int = 0;  /* allow matching a revision */
 					array_for_each(atoms, i, atomw) {
 						if (atom_compare(atom, atomw) == EQUAL)
 							break;
 						atomw = NULL;
 					}
+					atom->PR_int = orev;
 				} else {
 					snprintf(afmt, sizeof(afmt), "%s/%s",
 							atom->CATEGORY, atom->PN);
@@ -738,15 +787,16 @@ static int do_emerge_log(
 					/* found, do report */
 					elapsed = tstart - pkgw->tbegin;
 
-					if (flags->do_average || flags->do_running)
+					if (flags->do_average || flags->do_predict
+							|| flags->do_running)
 					{
 						/* find in list of averages */
-						if (!verbose || flags->do_running) {
+						if (flags->do_predict || verbose) {
 							snprintf(afmt, sizeof(afmt), "%s/%s",
-								pkgw->atom->CATEGORY, pkgw->atom->PN);
+									pkgw->atom->CATEGORY, pkgw->atom->PF);
 						} else {
 							snprintf(afmt, sizeof(afmt), "%s/%s",
-								pkgw->atom->CATEGORY, pkgw->atom->PF);
+									pkgw->atom->CATEGORY, pkgw->atom->PN);
 						}
 
 						pkg = add_set_value(afmt, pkgw, merge_averages);
@@ -880,15 +930,16 @@ static int do_emerge_log(
 					/* found, do report */
 					elapsed = tstart - pkgw->tbegin;
 
-					if (flags->do_average || flags->do_running)
+					if (flags->do_average || flags->do_predict
+							|| flags->do_running)
 					{
 						/* find in list of averages */
-						if (!verbose || flags->do_running) {
+						if (flags->do_predict || verbose) {
 							snprintf(afmt, sizeof(afmt), "%s/%s",
-								pkgw->atom->CATEGORY, pkgw->atom->PN);
+									pkgw->atom->CATEGORY, pkgw->atom->PF);
 						} else {
 							snprintf(afmt, sizeof(afmt), "%s/%s",
-								pkgw->atom->CATEGORY, pkgw->atom->PF);
+									pkgw->atom->CATEGORY, pkgw->atom->PN);
 						}
 
 						pkg = add_set_value(afmt, pkgw, unmerge_averages);
@@ -1149,6 +1200,119 @@ static int do_emerge_log(
 						GREEN, sync_cnt, NORM, sync_cnt == 1 ? "" : "s");
 			printf("\n");
 		}
+	} else if (flags->do_predict) {
+		DECLARE_ARRAY(avgs);
+		enum { P_INIT = 0, P_SREV, P_SRCH } pkgstate;
+		size_t j;
+		time_t ptime;
+		char found;
+
+		values_set(merge_averages, avgs);
+		xarraysort(avgs, pkg_sort_cb);
+		xarraysort(atoms, atom_compar_cb);
+
+		/* each atom has its own matches in here, but since it's all
+		 * sorted, we basically can go around here jumping from CAT-PN
+		 * to CAT-PN (yes this means python-3.6 python-3.9 will result
+		 * in a single record) */
+		array_for_each(atoms, i, atom) {
+			pkgstate = P_INIT;
+			pkgw = NULL;
+			found = 0;
+
+			/* we added "<=" to the atoms in main() to make sure we
+			 * would collect version ranges, but here we want to know if
+			 * the atom is equal or newer, older, etc. so strip it off
+			 * again */
+			if (atom->pfx_op == ATOM_OP_OLDER_EQUAL)
+				atom->pfx_op = ATOM_OP_NONE;
+
+			array_for_each(avgs, j, pkg) {
+				if (pkgstate == P_INIT) {
+					int orev = pkg->atom->PR_int;
+					atom_equality eq;
+					pkg->atom->PR_int = 0;
+					eq = atom_compare(pkg->atom, atom);
+					pkg->atom->PR_int = orev;
+					switch (eq) {
+						case EQUAL:
+							/* version-less atoms equal any versioned
+							 * atom, so check if atom (user input) was
+							 * versioned */
+							if (atom->PV != NULL)
+							{
+								/* 100% match, there's no better
+								 * prediction */
+								found = 1;
+								ptime = pkg->time / pkg->cnt;
+								break;
+							} else {
+								pkgstate = P_SRCH;
+								pkgw = pkg;
+								continue;
+							}
+						case NEWER:
+							if (atom->pfx_op != ATOM_OP_NEWER ||
+									atom->pfx_op != ATOM_OP_NEWER_EQUAL)
+								continue;
+							/* fall through */
+						case OLDER:
+							if (atom->PV != NULL && pkg->atom->PV != NULL &&
+									strcmp(atom->PV, pkg->atom->PV) == 0)
+								pkgstate = P_SREV;
+							else
+								pkgstate = P_SRCH;
+							pkgw = pkg;
+							continue;
+						default:
+							continue;
+					}
+				} else { /* P_SREV, P_SRCH */
+					if (atom_compare(pkg->atom, pkgw->atom) == OLDER) {
+						if (pkgstate == P_SREV) {
+							/* in here, we only compute a diff if we
+							 * have another (previous) revision,
+							 * else we stick to the version we have,
+							 * because we're compiling a new
+							 * revision, so likely to be the same */
+							if (pkg->atom->PV != NULL &&
+									pkgw->atom->PV != NULL &&
+									strcmp(pkg->atom->PV,
+										pkgw->atom->PV) == 0)
+							{
+								time_t wtime;
+								/* take diff with previous revision */
+								wtime = pkgw->time / pkgw->cnt;
+								ptime = pkg->time / pkg->cnt;
+								ptime = wtime + (wtime - ptime);
+							} else {
+								ptime = pkgw->time / pkgw->cnt;
+							}
+						} else {
+							time_t wtime;
+							/* we got another version, just compute
+							 * the diff, and return it */
+							wtime = pkgw->time / pkgw->cnt;
+							ptime = pkg->time / pkg->cnt;
+							ptime = wtime + (wtime - ptime);
+						}
+						found = 1;
+					} else {
+						/* it cannot be newer (because we
+						 * applied sort) and it cannot be equal
+						 * (because it comes from a set) */
+						break;
+					}
+				}
+
+				if (found) {
+					printf("%s: prediction %s\n",
+							atom_format(flags->fmt, atom),
+							fmt_elapsedtime(flags, ptime));
+					break;
+				}
+			}
+		}
 	}
 
 	{
@@ -1406,6 +1570,7 @@ int qlop_main(int argc, char **argv)
 	m.do_sync = 0;
 	m.do_running = 0;
 	m.do_average = 0;
+	m.do_predict = 0;
 	m.do_summary = 0;
 	m.do_human = 0;
 	m.do_machine = 0;
@@ -1431,6 +1596,7 @@ int qlop_main(int argc, char **argv)
 			case 'r': m.do_running = 1;
 					  runningmode++;        break;
 			case 'a': m.do_average = 1;     break;
+			case 'p': m.do_predict = 1;     break;
 			case 'c': m.do_summary = 1;     break;
 			case 'H': m.do_human = 1;       break;
 			case 'M': m.do_machine = 1;     break;
@@ -1499,6 +1665,7 @@ int qlop_main(int argc, char **argv)
 			m.do_sync == 0 &&
 			m.do_running == 0 &&
 			m.do_average == 0 &&
+			m.do_predict == 0 &&
 			m.do_summary == 0
 		)
 	{
@@ -1516,16 +1683,23 @@ int qlop_main(int argc, char **argv)
 	if (m.do_summary)
 		m.do_average = 1;
 
-	/* handle -a / -t conflict */
-	if (m.do_average && m.do_time) {
-		warn("-a (or -c) and -t cannot be used together, dropping -t");
+	/* handle -a / -p conflict */
+	if (m.do_average && m.do_predict) {
+		warn("-a and -p cannot be used together, dropping -a");
+		m.do_average = 0;
+	}
+
+	/* handle -a / -p / -t conflict */
+	if ((m.do_average || m.do_predict) && m.do_time) {
+		warn("-a/-p (or -c) and -t cannot be used together, dropping -t");
 		m.do_time = 0;
 	}
 
 	/* handle -a / -r conflict */
-	if (m.do_average && m.do_running) {
-		warn("-a (or -c) and -r cannot be used together, dropping -a");
+	if ((m.do_average || m.do_predict) && m.do_running) {
+		warn("-a/-p (or -c) and -r cannot be used together, dropping -a/-p");
 		m.do_average = 0;
+		m.do_predict = 0;
 	}
 
 	/* handle -H / -M conflict */
@@ -1541,6 +1715,12 @@ int qlop_main(int argc, char **argv)
 		m.do_sync = 0;
 	}
 
+	/* handle -p without atoms */
+	if (m.do_predict && array_cnt(atoms) == 0) {
+		err("-p requires at least one atom");
+		return EXIT_FAILURE;
+	}
+
 	/* handle -l / -d conflict */
 	if (start_time != -1 && m.show_lastmerge) {
 		if (!m.show_emerge)
@@ -1548,8 +1728,8 @@ int qlop_main(int argc, char **argv)
 		m.show_lastmerge = 0;
 	}
 
-	/* set default for -t, -a or -r */
-	if ((m.do_average || m.do_time || m.do_running) &&
+	/* set default for -t, -a, -p or -r */
+	if ((m.do_average || m.do_predict || m.do_time || m.do_running) &&
 			!(m.do_merge || m.do_unmerge || m.do_autoclean || m.do_sync))
 	{
 		m.do_merge = 1;
@@ -1588,6 +1768,19 @@ int qlop_main(int argc, char **argv)
 		/* NOTE: new_atoms == atoms when new_atoms != NULL */
 	}
 
+	if (m.do_predict) {
+		/* turn non-ranged atoms into a <= match such that the
+		 * prediction magic has something to compare against when a
+		 * version is listed */
+		array_for_each(atoms, i, atom) {
+			if (atom->pfx_op == ATOM_OP_NONE ||
+					atom->pfx_op == ATOM_OP_EQUAL ||
+					atom->pfx_op == ATOM_OP_PV_EQUAL ||
+					atom->pfx_op == ATOM_OP_STAR)
+				atom->pfx_op = ATOM_OP_OLDER_EQUAL;
+		}
+	}
+
 	if (start_time < LONG_MAX)
 		do_emerge_log(logfile, &m, atoms, start_time, end_time);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-05-10  9:16 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-05-10  9:16 UTC (permalink / raw
  To: gentoo-commits

commit:     03c2d27602bc94aaa1660da7b084d40a9cf70f5d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 10 09:12:43 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 10 09:12:43 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=03c2d276

main: add global option --color to force colour output

allow override for colouring to be enabled, this reorganises the code a
bit because argument handling is done by the applets, and not by the
main process, e.g. total colour handling can unfortunately not be done
in a single place.

Bug: https://bugs.gentoo.org/769929
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h | 10 +++++++---
 main.c    | 23 +++++++++--------------
 2 files changed, 16 insertions(+), 17 deletions(-)

diff --git a/applets.h b/applets.h
index 956ab67..8918ff0 100644
--- a/applets.h
+++ b/applets.h
@@ -1,9 +1,10 @@
 /*
- * Copyright 2005-2019 Gentoo Foundation
+ * Copyright 2005-2021 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2014 Mike Frysinger  - <vapier@gentoo.org>
+ * Copyright 2019-     Fabian Groffen  - <grobian@gentoo.org>
  */
 
 #ifndef _APPLETS_H_
@@ -133,6 +134,7 @@ static const struct applet_t {
 	{"verbose",   no_argument, NULL, 'v'}, \
 	{"quiet",     no_argument, NULL, 'q'}, \
 	{"nocolor",   no_argument, NULL, 'C'}, \
+	{"color",     no_argument, NULL, 0x2}, \
 	{"help",      no_argument, NULL, 'h'}, \
 	{"version",   no_argument, NULL, 'V'}, \
 	{NULL,        no_argument, NULL, 0x0}
@@ -141,6 +143,7 @@ static const struct applet_t {
 	"Report full package versions, emit more elaborate output", \
 	"Tighter output; suppress warnings", \
 	"Don't output color", \
+	"Force color in output", \
 	"Print this help and exit", \
 	"Print version and exit", \
 	NULL
@@ -150,8 +153,9 @@ static const struct applet_t {
 	case 'q': setup_quiet(); break; \
 	case 'V': version_barf(); break; \
 	case 'h': applet ## _usage(EXIT_SUCCESS); break; \
-	case 'C': no_colors(); break; \
-	default: applet ## _usage(EXIT_FAILURE); break;
+	case 'C': color_clear(); setenv("NOCOLOR", "true", 1); break; \
+	case 0x2: color_remap(); unsetenv("NOCOLOR"); break; \
+	default:  applet ## _usage(EXIT_FAILURE); break;
 
 extern char *portarch;
 extern char *portroot;

diff --git a/main.c b/main.c
index ceab587..01b2542 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2020 Gentoo Foundation
+ * Copyright 2005-2021 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2008 Ned Ludd        - <solar@gentoo.org>
@@ -70,14 +70,6 @@ init_coredumps(void)
 }
 #endif
 
-void
-no_colors(void)
-{
-	BOLD = NORM = BLUE = DKBLUE = CYAN = GREEN = DKGREEN = \
-		   MAGENTA = RED = YELLOW = BRYELLOW = WHITE = "";
-	setenv("NOCOLOR", "true", 1);
-}
-
 void
 setup_quiet(void)
 {
@@ -1041,10 +1033,13 @@ initialize_portage_env(void)
 	if (getenv("PORTAGE_QUIET") != NULL)
 		setup_quiet();
 
-	if (nocolor)
-		no_colors();
-	else
+	if (nocolor) {
+		color_clear();
+		setenv("NOCOLOR", "true", 1);
+	} else {
 		color_remap();
+		unsetenv("NOCOLOR");
+	}
 }
 
 int main(int argc, char **argv)
@@ -1063,11 +1058,11 @@ int main(int argc, char **argv)
 	twidth = 0;
 	if (fstat(fileno(stdout), &st) != -1) {
 		if (!isatty(fileno(stdout))) {
-			no_colors();
+			nocolor = 1;
 		} else {
 			if ((getenv("TERM") == NULL) ||
 					(strcmp(getenv("TERM"), "dumb") == 0))
-				no_colors();
+				nocolor = 1;
 			if (ioctl(0, TIOCGWINSZ, &winsz) == 0 && winsz.ws_col > 0)
 				twidth = (int)winsz.ws_col;
 		}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-05-02 11:32 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-05-02 11:32 UTC (permalink / raw
  To: gentoo-commits

commit:     0c0717395305ed5ddd6dbf2e841b437efc5af423
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May  2 11:32:10 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May  2 11:32:10 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0c071739

qmerge: silence style check

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 9d524f1..08ce812 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -666,8 +666,8 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 		"eqawarn() { elog \"QA: \"\"$@\"; }\n"
 		"eerror() { elog \"$@\"; }\n"
 		"die() { eerror \"$@\"; exit 1; }\n"
-		"fowners() { local f a=$1; shift; for f in \"$@\" ; do chown $a \"${ED}/${f}\" ; done ; }\n"
-		"fperms() { local f a=$1; shift; for f in \"$@\" ; do chmod $a \"${ED}/${f}\" ; done ; }\n"
+		"fowners() { local f a=$1; shift; for f in \"$@\"; do chown $a \"${ED}/${f}\"; done; }\n"
+		"fperms() { local f a=$1; shift; for f in \"$@\"; do chmod $a \"${ED}/${f}\"; done; }\n"
 		/* TODO: This should suppress `die` */
 		"nonfatal() { \"$@\"; }\n"
 		"ebegin() { printf ' * %%b ...' \"$*\"; }\n"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-05-02 11:25 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-05-02 11:25 UTC (permalink / raw
  To: gentoo-commits

commit:     b985ace619b34ff457fa4119e8dabe084695c932
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May  2 10:57:43 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May  2 10:57:43 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b985ace6

qdepends: fix return status when using multiple repos

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qdepends.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index 865605e..9e2ea0b 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2020 Gentoo Authors
+ * Copyright 2005-2021 Gentoo Authors
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
@@ -366,6 +366,7 @@ int qdepends_main(int argc, char **argv)
 
 	if (state.qmode & QMODE_INSTALLED || verbose)
 		state.vdb = tree_open_vdb(portroot, portvdb);
+	ret = 0;
 	if (state.qmode & QMODE_TREE) {
 		char *overlay;
 		size_t n;
@@ -376,11 +377,11 @@ int qdepends_main(int argc, char **argv)
 			if (t != NULL) {
 				if (!(state.qmode & QMODE_REVERSE) && array_cnt(atoms) > 0) {
 					array_for_each(atoms, i, atom) {
-						ret = tree_foreach_pkg_sorted(t,
+						ret |= tree_foreach_pkg_sorted(t,
 								qdepends_results_cb, &state, atom);
 					}
 				} else {
-					ret = tree_foreach_pkg_sorted(t,
+					ret |= tree_foreach_pkg_sorted(t,
 							qdepends_results_cb, &state, NULL);
 				}
 				tree_close(t);
@@ -389,11 +390,11 @@ int qdepends_main(int argc, char **argv)
 	} else {
 		if (!(state.qmode & QMODE_REVERSE) && array_cnt(atoms) > 0) {
 			array_for_each(atoms, i, atom) {
-				ret = tree_foreach_pkg_fast(state.vdb,
+				ret |= tree_foreach_pkg_fast(state.vdb,
 						qdepends_results_cb, &state, atom);
 			}
 		} else {
-			ret = tree_foreach_pkg_fast(state.vdb,
+			ret |= tree_foreach_pkg_fast(state.vdb,
 					qdepends_results_cb, &state, NULL);
 		}
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-05-02 11:25 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-05-02 11:25 UTC (permalink / raw
  To: gentoo-commits

commit:     8f2ad078dfc9b9645ce5dd92a689a802e6c35aa6
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May  2 11:15:25 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May  2 11:15:25 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8f2ad078

qdepends: report which ebuild had dep-parsing errors

Bug: https://bugs.gentoo.org/787602
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qdepends.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/qdepends.c b/qdepends.c
index 9e2ea0b..959825b 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -166,8 +166,10 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 		if (depstr == NULL)
 			continue;
 		dep_tree = dep_grow_tree(depstr);
-		if (dep_tree == NULL)
+		if (dep_tree == NULL) {
+			warn("failed to parse depstring from %s\n", atom_to_string(datom));
 			continue;
+		}
 
 		if (state->qmode & QMODE_TREE && verbose) {
 			/* pull in flags in use if possible */
@@ -185,6 +187,9 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 						dep_node *dep_vdb = dep_grow_tree(depstr);
 						if (dep_vdb != NULL)
 							dep_flatten_tree(dep_vdb, state->deps);
+						else
+							warn("failed to parse VDB depstring from %s\n",
+									atom_to_string(datom));
 					}
 					tree_close_pkg(vpkg);
 				}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-05-01 19:32 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-05-01 19:32 UTC (permalink / raw
  To: gentoo-commits

commit:     583632d80a17c80d29eee2aec42d91cd05405fa3
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May  1 19:30:55 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May  1 19:30:55 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=583632d8

qmerge: provide emulations for fowners and fperms

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index e439a7d..9d524f1 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2020 Gentoo Authors
+ * Copyright 2005-2021 Gentoo Authors
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
@@ -666,6 +666,8 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 		"eqawarn() { elog \"QA: \"\"$@\"; }\n"
 		"eerror() { elog \"$@\"; }\n"
 		"die() { eerror \"$@\"; exit 1; }\n"
+		"fowners() { local f a=$1; shift; for f in \"$@\" ; do chown $a \"${ED}/${f}\" ; done ; }\n"
+		"fperms() { local f a=$1; shift; for f in \"$@\" ; do chmod $a \"${ED}/${f}\" ; done ; }\n"
 		/* TODO: This should suppress `die` */
 		"nonfatal() { \"$@\"; }\n"
 		"ebegin() { printf ' * %%b ...' \"$*\"; }\n"
@@ -1895,7 +1897,7 @@ grab_binpkg_info(depend_atom *atom)
 	/* reuse previously opened tree, so we really employ the cache
 	 * from libq/tree */
 	if (tree == NULL) {
-		snprintf(path, sizeof(path), "%s/portage/Packages", port_tmpdir);
+		snprintf(path, sizeof(path), "%s/portage/%s", port_tmpdir, Packages);
 		/* we don't use ROOT on package tree here, operating on ROOT
 		 * should be for package merges/unmerges, but be able to pull
 		 * binpkgs from current system */
@@ -2100,7 +2102,9 @@ int qmerge_main(int argc, char **argv)
 	if (install && !pretend) {
 		if (follow_rdepends && getenv("QMERGE") == NULL) {
 			install = 0;
-			warn("Using these options are likely to break your system at this point. export QMERGE=1; if you think you know what your doing.");
+			warn("Using these options are likely to break your "
+					"system at this point. export QMERGE=1; "
+					"if you think you know what your doing.");
 		}
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-05-01  8:40 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-05-01  8:40 UTC (permalink / raw
  To: gentoo-commits

commit:     2ec2e13a5bbf0b36ec632d9a1306786953c4d66f
Author:     Marien Zwart <marien.zwart <AT> gmail <DOT> com>
AuthorDate: Sat May  1 08:38:05 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May  1 08:38:05 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2ec2e13a

qwhich: fix locations for revisioned ebuilds in the tree and vdb

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qwhich.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qwhich.c b/qwhich.c
index 05ea064..24a9ff0 100644
--- a/qwhich.c
+++ b/qwhich.c
@@ -201,12 +201,12 @@ int qwhich_main(int argc, char **argv)
 									m.print_repo ? "::" : "/",
 									BOLD, tmcw->atom->CATEGORY,
 									DKBLUE, tmcw->atom->PN,
-									BLUE, tmcw->atom->P,
+									BLUE, tmcw->atom->PF,
 									DKGREEN, NORM);
 					} else if (t->cachetype == CACHE_VDB && !m.print_path) {
 						printf("%s%s/%s%s%s.ebuild%s\n",
 								DKBLUE, tmcw->path,
-								BLUE, tmcw->atom->P,
+								BLUE, tmcw->atom->PF,
 								DKGREEN, NORM);
 					} else {
 						printf("%s%s%s\n", DKBLUE, tmcw->path, NORM);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-03-13 20:32 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-03-13 20:32 UTC (permalink / raw
  To: gentoo-commits

commit:     2d99010506d521b7712fef8a85fd4d151e84c2e7
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 13 16:53:01 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Mar 13 16:53:01 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2d990105

main: add line and comment section numbers for masks/envvars

Basically, allow to easily retrieve the comment that belongs to a
certain mask or var setting.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 46 ++++++++++++++++++++++++++++++++--------------
 1 file changed, 32 insertions(+), 14 deletions(-)

diff --git a/main.c b/main.c
index 816cd6c..a68af63 100644
--- a/main.c
+++ b/main.c
@@ -369,6 +369,10 @@ read_portage_file(const char *file, enum portage_file_type type, void *data)
 	char *buf = NULL;
 	size_t buflen = 0;
 	size_t line;
+	bool incomment;
+	size_t cbeg;
+	size_t cend;
+	char npath[_Q_PATH_MAX * 2];
 	int i;
 	env_vars *vars = data;
 	set *masks = data;
@@ -376,7 +380,6 @@ read_portage_file(const char *file, enum portage_file_type type, void *data)
 	if ((dentslen = scandir(file, &dents, NULL, alphasort)) > 0) {
 		int di;
 		struct dirent *d;
-		char npath[_Q_PATH_MAX * 2];
 
 		/* recurse through all files */
 		for (di = 0; di < dentslen; di++) {
@@ -396,17 +399,32 @@ read_portage_file(const char *file, enum portage_file_type type, void *data)
 		goto done;
 
 	line = 0;
+	incomment = false;
+	cbeg = 0;
+	cend = 0;
 	while (getline(&buf, &buflen, fp) != -1) {
 		line++;
 		rmspace(buf);
-		if (*buf == '#' || *buf == '\0')
+		if (*buf == '#') {
+			if (!incomment)
+				cbeg = cend = line;
+			else
+				cend = line;
+			incomment = true;
 			continue;
+		}
+		incomment = false;
+		if (*buf == '\0') {
+			cbeg = cend = 0;
+			continue;
+		}
 
 		/* Handle "source" keyword */
 		if (type == ENV_FILE) {
+			size_t curline = line;
+
 			if (strncmp(buf, "source ", 7) == 0) {
 				const char *sfile = buf + 7;
-				char npath[_Q_PATH_MAX * 2];
 
 				if (sfile[0] != '/') {
 					/* handle relative paths */
@@ -455,6 +473,7 @@ read_portage_file(const char *file, enum portage_file_type type, void *data)
 
 						abuf = NULL;
 						while (getline(&abuf, &abuflen, fp) != -1) {
+							line++;
 							buf = xrealloc(buf, buflen + abuflen);
 							endq = strchr(abuf, q);
 							if (endq)
@@ -483,25 +502,23 @@ read_portage_file(const char *file, enum portage_file_type type, void *data)
 					s[off] = '\0';
 				}
 
-				set_portage_env_var(&vars[i], s, file);
+				snprintf(npath, sizeof(npath), "%s:%zu:%zu-%zu",
+						file, curline, cbeg, cend);
+				set_portage_env_var(&vars[i], s, npath);
 			}
 		} else if (type == PMASK_FILE) {
-			/* trim leading space */
-			for (s = buf; isspace((int)*s); s++)
-				;
-			if (*s == '\0')
-				continue;
-			if (*s == '-') {
+			if (*buf == '-') {
 				/* negation/removal, lookup and drop mask if it exists;
 				 * note that this only supports exact matches (PMS
 				 * 5.2.5) so we don't even have to parse and use
 				 * atom-compare here */
-				s++;
-				if ((p = del_set(s, masks, NULL)) != NULL)
+				if ((p = del_set(buf + 1, masks, NULL)) != NULL)
 					free(p);
 			} else {
-				p = xstrdup(file);
-				if (add_set_value(s, p, masks) != NULL)
+				snprintf(npath, sizeof(npath), "%s:%zu:%zu-%zu",
+						file, line, cbeg, cend);
+				p = xstrdup(npath);
+				if (add_set_value(buf, p, masks) != NULL)
 					free(p);
 			}
 		}
@@ -660,6 +677,7 @@ read_one_repos_conf(const char *repos_conf, char **primary)
 
 	main_repo = NULL;
 	repo = NULL;
+	line = 0;
 	for (p = strtok_r(buf, "\n", &s); p != NULL; p = strtok_r(NULL, "\n", &s))
 	{
 		/* trim trailing whitespace, remove comments, locate = */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-02-20 12:06 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-02-20 12:06 UTC (permalink / raw
  To: gentoo-commits

commit:     530f841aa8f7f38a72f4577863a3dcad8a21961f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 20 12:05:30 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 20 12:05:30 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=530f841a

qwhich: add options to skip virtual and acct-* categories

This allows to make an alias like this sort of working:
cd $(qwhich -dTA <pkg>)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qwhich.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/qwhich.c b/qwhich.c
index 2119466..05ea064 100644
--- a/qwhich.c
+++ b/qwhich.c
@@ -19,17 +19,19 @@
 #include "atom.h"
 #include "tree.h"
 
-#define QWHICH_FLAGS "IbtpdRflF:" COMMON_FLAGS
+#define QWHICH_FLAGS "IbtpdRflTAF:" COMMON_FLAGS
 static struct option const qwhich_long_opts[] = {
-	{"vdb",      no_argument, NULL, 'I'},
-	{"binpkg",   no_argument, NULL, 'b'},
-	{"tree",     no_argument, NULL, 't'},
-	{"pretty",   no_argument, NULL, 'p'},
-	{"dir",      no_argument, NULL, 'd'},
-	{"repo",     no_argument, NULL, 'R'},
-	{"first",    no_argument, NULL, 'f'},
-	{"latest",   no_argument, NULL, 'l'},
-	{"format",    a_argument, NULL, 'F'},
+	{"vdb",       no_argument, NULL, 'I'},
+	{"binpkg",    no_argument, NULL, 'b'},
+	{"tree",      no_argument, NULL, 't'},
+	{"pretty",    no_argument, NULL, 'p'},
+	{"dir",       no_argument, NULL, 'd'},
+	{"repo",      no_argument, NULL, 'R'},
+	{"first",     no_argument, NULL, 'f'},
+	{"latest",    no_argument, NULL, 'l'},
+	{"novirtual", no_argument, NULL, 'T'},
+	{"noacct",    no_argument, NULL, 'A'},
+	{"format",     a_argument, NULL, 'F'},
 	COMMON_LONG_OPTS
 };
 static const char * const qwhich_opts_help[] = {
@@ -41,6 +43,8 @@ static const char * const qwhich_opts_help[] = {
 	"Print repository name instead of path for tree/overlay matches",
 	"Stop searching after first match (implies -l)",
 	"Only return latest version for each match",
+	"Skip virtual category",
+	"Skip acct-user and acct-group categories",
 	"Print matched using given format string",
 	COMMON_OPTS_HELP
 };
@@ -57,6 +61,8 @@ struct qwhich_mode {
 	char print_repo:1;
 	char match_first:1;
 	char match_latest:1;
+	char skip_virtual:1;
+	char skip_acct:1;
 	const char *fmt;
 };
 
@@ -91,6 +97,8 @@ int qwhich_main(int argc, char **argv)
 			case 'R': m.print_repo = true;   break;
 			case 'f': m.match_first = true;  break;
 			case 'l': m.match_latest = true; break;
+			case 'T': m.skip_virtual = true; break;
+			case 'A': m.skip_acct = true;    break;
 			case 'F': m.fmt = optarg;        break;
 		}
 	}
@@ -167,9 +175,11 @@ int qwhich_main(int argc, char **argv)
 		}
 
 		array_for_each(atoms, i, atom) {
-			tmc = tree_match_atom(t, atom, TREE_MATCH_DEFAULT |
-					(m.match_latest ? TREE_MATCH_LATEST : 0) |
-					(m.match_first  ? TREE_MATCH_FIRST  : 0));
+			tmc = tree_match_atom(t, atom,
+					(m.match_latest ? TREE_MATCH_LATEST : 0 ) |
+					(m.match_first  ? TREE_MATCH_FIRST  : 0 ) |
+					(m.skip_virtual ? 0 : TREE_MATCH_VIRTUAL) |
+					(m.skip_acct    ? 0 : TREE_MATCH_ACCT   ));
 			for (tmcw = tmc; tmcw != NULL; tmcw = tmcw->next) {
 				if (m.print_atom) {
 					printf("%s\n", atom_format(m.fmt, tmcw->atom));


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-02-20 11:44 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-02-20 11:44 UTC (permalink / raw
  To: gentoo-commits

commit:     d71bb2b7a1360ea49cb1e4d02fec15f9a9c18422
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 20 11:43:31 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 20 11:43:31 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d71bb2b7

qwhich: allow shortening paths by using repo name

e.g. return something like:
gentoo::app-shells/dash/dash-X.Y.ebuild

(repo lookup can be performed through q -o)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qwhich.c | 40 ++++++++++++++++++++++++++++------------
 1 file changed, 28 insertions(+), 12 deletions(-)

diff --git a/qwhich.c b/qwhich.c
index b55b6e4..2119466 100644
--- a/qwhich.c
+++ b/qwhich.c
@@ -19,13 +19,14 @@
 #include "atom.h"
 #include "tree.h"
 
-#define QWHICH_FLAGS "IbtpdflF:" COMMON_FLAGS
+#define QWHICH_FLAGS "IbtpdRflF:" COMMON_FLAGS
 static struct option const qwhich_long_opts[] = {
 	{"vdb",      no_argument, NULL, 'I'},
 	{"binpkg",   no_argument, NULL, 'b'},
 	{"tree",     no_argument, NULL, 't'},
 	{"pretty",   no_argument, NULL, 'p'},
 	{"dir",      no_argument, NULL, 'd'},
+	{"repo",     no_argument, NULL, 'R'},
 	{"first",    no_argument, NULL, 'f'},
 	{"latest",   no_argument, NULL, 'l'},
 	{"format",    a_argument, NULL, 'F'},
@@ -37,6 +38,7 @@ static const char * const qwhich_opts_help[] = {
 	"Look in main tree and overlays",
 	"Print (pretty) atom instead of path for use with -F",
 	"Print directory instead of path",
+	"Print repository name instead of path for tree/overlay matches",
 	"Stop searching after first match (implies -l)",
 	"Only return latest version for each match",
 	"Print matched using given format string",
@@ -52,6 +54,7 @@ struct qwhich_mode {
 	char do_tree:1;
 	char print_atom:1;
 	char print_path:1;
+	char print_repo:1;
 	char match_first:1;
 	char match_latest:1;
 	const char *fmt;
@@ -71,6 +74,7 @@ int qwhich_main(int argc, char **argv)
 	size_t n;
 	int ret;
 	tree_ctx *t;
+	char *repo;
 	int repolen;
 
 	memset(&m, 0, sizeof(m));
@@ -84,6 +88,7 @@ int qwhich_main(int argc, char **argv)
 			case 't': m.do_tree = true;      break;
 			case 'p': m.print_atom = true;   break;
 			case 'd': m.print_path = true;   break;
+			case 'R': m.print_repo = true;   break;
 			case 'f': m.match_first = true;  break;
 			case 'l': m.match_latest = true; break;
 			case 'F': m.fmt = optarg;        break;
@@ -146,12 +151,20 @@ int qwhich_main(int argc, char **argv)
 
 	/* at least keep the IO constrained to a tree at a time */
 	array_for_each(trees, j, t) {
-		if (t->cachetype == CACHE_METADATA_MD5)
-			repolen = strlen(t->path) - (sizeof("/metadata/md5-cache") - 1);
-		else if (t->cachetype == CACHE_METADATA_PMS)
-			repolen = strlen(t->path) - (sizeof("/metadata/cache") - 1);
-		else
-			repolen = 0;
+		if (m.print_repo) {
+			repo = t->repo;
+			repolen = strlen(repo);
+		} else {
+			repo = t->path;
+			if (t->cachetype == CACHE_METADATA_MD5)
+				repolen = strlen(t->path) - (sizeof("/metadata/md5-cache") - 1);
+			else if (t->cachetype == CACHE_METADATA_PMS)
+				repolen = strlen(t->path) - (sizeof("/metadata/cache") - 1);
+			else if (t->cachetype == CACHE_EBUILD)
+				repolen = strlen(t->path);
+			else
+				repolen = 0;
+		}
 
 		array_for_each(atoms, i, atom) {
 			tmc = tree_match_atom(t, atom, TREE_MATCH_DEFAULT |
@@ -162,17 +175,20 @@ int qwhich_main(int argc, char **argv)
 					printf("%s\n", atom_format(m.fmt, tmcw->atom));
 				} else {
 					if (t->cachetype == CACHE_METADATA_MD5 ||
-							t->cachetype == CACHE_METADATA_PMS)
+							t->cachetype == CACHE_METADATA_PMS ||
+							t->cachetype == CACHE_EBUILD)
 					{
 						if (m.print_path)
-							printf("%s%.*s/%s%s/%s%s%s\n",
-									GREEN, repolen, t->path,
+							printf("%s%.*s%s%s%s/%s%s%s\n",
+									GREEN, repolen, repo,
+									m.print_repo ? "::" : "/",
 									BOLD, tmcw->atom->CATEGORY,
 									DKBLUE, tmcw->atom->PN,
 									NORM);
 						else
-							printf("%s%.*s/%s%s/%s%s/%s%s%s.ebuild%s\n",
-									DKGREEN, repolen, t->path,
+							printf("%s%.*s%s%s%s/%s%s/%s%s%s.ebuild%s\n",
+									DKGREEN, repolen, repo,
+									m.print_repo ? "::" : "/",
 									BOLD, tmcw->atom->CATEGORY,
 									DKBLUE, tmcw->atom->PN,
 									BLUE, tmcw->atom->P,


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-02-20 11:44 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-02-20 11:44 UTC (permalink / raw
  To: gentoo-commits

commit:     b8c3bbcde2425b2b6160c1fc865eeebe705417c2
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 20 10:56:41 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 20 10:56:41 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b8c3bbcd

qwhich: add option for latest version match, print ebuild for vdb matches

- add -l to match latest version per package, e.g. query for dash would
  return both app-shells/dash as well as app-emacs/dash
- for vdb matches, return the path to the (cached) ebuild in there,
  unless -d is given, of course, then print path

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qwhich.c | 40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/qwhich.c b/qwhich.c
index 3a0c791..b55b6e4 100644
--- a/qwhich.c
+++ b/qwhich.c
@@ -19,7 +19,7 @@
 #include "atom.h"
 #include "tree.h"
 
-#define QWHICH_FLAGS "IbtpdfF:" COMMON_FLAGS
+#define QWHICH_FLAGS "IbtpdflF:" COMMON_FLAGS
 static struct option const qwhich_long_opts[] = {
 	{"vdb",      no_argument, NULL, 'I'},
 	{"binpkg",   no_argument, NULL, 'b'},
@@ -27,6 +27,7 @@ static struct option const qwhich_long_opts[] = {
 	{"pretty",   no_argument, NULL, 'p'},
 	{"dir",      no_argument, NULL, 'd'},
 	{"first",    no_argument, NULL, 'f'},
+	{"latest",   no_argument, NULL, 'l'},
 	{"format",    a_argument, NULL, 'F'},
 	COMMON_LONG_OPTS
 };
@@ -36,7 +37,8 @@ static const char * const qwhich_opts_help[] = {
 	"Look in main tree and overlays",
 	"Print (pretty) atom instead of path for use with -F",
 	"Print directory instead of path",
-	"Stop searching after first match",
+	"Stop searching after first match (implies -l)",
+	"Only return latest version for each match",
 	"Print matched using given format string",
 	COMMON_OPTS_HELP
 };
@@ -51,6 +53,7 @@ struct qwhich_mode {
 	char print_atom:1;
 	char print_path:1;
 	char match_first:1;
+	char match_latest:1;
 	const char *fmt;
 };
 
@@ -76,28 +79,29 @@ int qwhich_main(int argc, char **argv)
 		switch (ret) {
 			COMMON_GETOPTS_CASES(qwhich)
 
-			case 'I': m.do_vdb = true;      break;
-			case 'b': m.do_binpkg = true;   break;
-			case 't': m.do_tree = true;     break;
-			case 'p': m.print_atom = true;  break;
-			case 'd': m.print_path = true;  break;
-			case 'f': m.match_first = true; break;
-			case 'F': m.fmt = optarg;       break;
+			case 'I': m.do_vdb = true;       break;
+			case 'b': m.do_binpkg = true;    break;
+			case 't': m.do_tree = true;      break;
+			case 'p': m.print_atom = true;   break;
+			case 'd': m.print_path = true;   break;
+			case 'f': m.match_first = true;  break;
+			case 'l': m.match_latest = true; break;
+			case 'F': m.fmt = optarg;        break;
 		}
 	}
 
-	/* defaults: no options at all, enable first match,
+	/* defaults: no options at all, enable latest match,
 	 *           no selectors, enable tree + overlays */
 	if (!m.do_vdb && !m.do_binpkg && !m.do_tree) {
 		if (!m.print_atom && !m.print_path && !m.match_first && m.fmt == NULL)
-			m.match_first = true;
+			m.match_latest = true;
 		m.do_tree = true;
 	}
 
 	/* when printing path, we better just match the first, else we get a
 	 * lot of dups */
-	if (m.print_path)
-		m.match_first = true;
+	if (m.print_path || m.match_first)
+		m.match_latest = true;
 
 	/* set format if none given */
 	if (m.fmt == NULL) {
@@ -150,8 +154,9 @@ int qwhich_main(int argc, char **argv)
 			repolen = 0;
 
 		array_for_each(atoms, i, atom) {
-			tmc = tree_match_atom(t, atom,
-					m.match_first ? TREE_MATCH_FIRST : TREE_MATCH_DEFAULT);
+			tmc = tree_match_atom(t, atom, TREE_MATCH_DEFAULT |
+					(m.match_latest ? TREE_MATCH_LATEST : 0) |
+					(m.match_first  ? TREE_MATCH_FIRST  : 0));
 			for (tmcw = tmc; tmcw != NULL; tmcw = tmcw->next) {
 				if (m.print_atom) {
 					printf("%s\n", atom_format(m.fmt, tmcw->atom));
@@ -172,6 +177,11 @@ int qwhich_main(int argc, char **argv)
 									DKBLUE, tmcw->atom->PN,
 									BLUE, tmcw->atom->P,
 									DKGREEN, NORM);
+					} else if (t->cachetype == CACHE_VDB && !m.print_path) {
+						printf("%s%s/%s%s%s.ebuild%s\n",
+								DKBLUE, tmcw->path,
+								BLUE, tmcw->atom->P,
+								DKGREEN, NORM);
 					} else {
 						printf("%s%s%s\n", DKBLUE, tmcw->path, NORM);
 					}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2021-02-17 20:23 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2021-02-17 20:23 UTC (permalink / raw
  To: gentoo-commits

commit:     d5eeb8c6f9d455fba2356de43f35d88c1321504b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 17 20:18:37 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Feb 17 20:18:37 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d5eeb8c6

qkeyword: take advantage of new atom_explode_cat

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qkeyword.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/qkeyword.c b/qkeyword.c
index 7a60022..f6cdbc2 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -855,12 +855,9 @@ int qkeyword_main(int argc, char **argv)
 		qkeyword_usage(EXIT_FAILURE);
 
 	if (cat != NULL) {
-		char buf[_Q_PATH_MAX];
-
-		snprintf(buf, sizeof(buf), "%s/%s", cat, pkg == NULL ? "" : pkg);
-		data.qatom = atom_explode(buf);
+		data.qatom = atom_explode_cat(pkg == NULL ? "" : pkg, cat);
 		if (data.qatom == NULL) {
-			warnf("invalid cat/pkg: %s\n", buf);
+			warnf("invalid cat/pkg: %s/%s\n", cat, pkg == NULL ? "" : pkg);
 			return EXIT_FAILURE;
 		}
 	} else if (pkg != NULL) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-11-29  9:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-11-29  9:13 UTC (permalink / raw
  To: gentoo-commits

commit:     b377edf73ec277e2d85d102a325f789663720142
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 29 09:12:41 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Nov 29 09:12:41 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b377edf7

main: fix alignment wrt qmanifest applet, bug #757540

Bug: https://bugs.gentoo.org/757540
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index c8b0429..816cd6c 100644
--- a/main.c
+++ b/main.c
@@ -109,7 +109,7 @@ usage(int status, const char *flags, struct option const opts[],
 		fprintf(fp, "%scurrently defined applets:%s\n", GREEN, NORM);
 		for (i = 0; applets[i].desc; ++i)
 			if (applets[i].func)
-				fprintf(fp, " %s%8s%s %s%-16s%s%s:%s %s\n",
+				fprintf(fp, " %s%9s%s %s%-16s%s%s:%s %s\n",
 					YELLOW, applets[i].name, NORM,
 					DKBLUE, applets[i].opts, NORM,
 					RED, NORM, _(applets[i].desc));


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-11-21 10:53 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-11-21 10:53 UTC (permalink / raw
  To: gentoo-commits

commit:     8acb5968a74837cc1434a48ff89c1255c2c1676d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 21 10:53:40 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov 21 10:53:40 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8acb5968

travis: try newer macOS image

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 6ab918f..af1504c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -4,6 +4,7 @@
 language: c
 dist: focal
 os: linux
+osx_image: xcode11.3.1
 
 jobs:
   include:
@@ -60,7 +61,6 @@ addons:
     - coreutils
     - bash
     - libressl
-      #update: true   # working around unknown bundle command
 
 before_install:
   - ./travis/install-blake2.sh


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-11-21 10:45 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-11-21 10:45 UTC (permalink / raw
  To: gentoo-commits

commit:     4e83d6875843dd52842ed9a591e91a036693dd9a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 21 10:45:37 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov 21 10:45:37 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4e83d687

travis: disable homebrew update, it seems to recompile everything

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 2a908f0..6ab918f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -60,7 +60,7 @@ addons:
     - coreutils
     - bash
     - libressl
-    update: true   # working around unknown bundle command
+      #update: true   # working around unknown bundle command
 
 before_install:
   - ./travis/install-blake2.sh


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-11-21 10:00 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-11-21 10:00 UTC (permalink / raw
  To: gentoo-commits

commit:     e74c54552cb6d13770ee85985a7d69b70e31c320
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 21 10:00:06 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov 21 10:00:31 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e74c5455

travis: try all available arches at Travis CI

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 2201fef..2a908f0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -8,14 +8,24 @@ os: linux
 jobs:
   include:
     - compiler: gcc
+      arch: amd64
+    - compiler: gcc
+      arch: arm64
+    - compiler: gcc
+      arch: ppc64le
+    - compiler: gcc
+      arch: s390x
     - compiler: clang
+      arch: amd64
     - compiler: coverity
+      arch: amd64
       env:
         - COVERITY_SCAN_PROJECT_NAME="$TRAVIS_REPO_SLUG"
         - COVERITY_SCAN_BRANCH_PATTERN="master"
         - COVERITY_SCAN_NOTIFICATION_EMAIL="grobian@gentoo.org"
         - COVERITY_SCAN_BUILD_COMMAND="make"
     - compiler: valgrind
+      arch: amd64
       env:
         - CFLAGS="-g"
         - Q_RUN_WITH_VALGRIND=1
@@ -26,10 +36,6 @@ jobs:
         - CPPFLAGS="-I/usr/local/opt/libressl/include"
         - PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:$PATH"
         - PATH="$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH"
-    - compiler: gcc
-      arch: arm64-graviton2
-      virt: lxd
-      group: edge
 
 env:
   global:


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-11-21  9:53 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-11-21  9:53 UTC (permalink / raw
  To: gentoo-commits

commit:     41674ff4508c0d7b0194e658b6854c20d427b4a9
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 21 09:52:38 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov 21 09:52:49 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=41674ff4

travis: try new Ubuntu Focal (20.04) and the AWS Graviton2 cluster

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index f435dc6..2201fef 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,7 +2,7 @@
 # https://docs.travis-ci.com/
 
 language: c
-dist: bionic
+dist: focal
 os: linux
 
 jobs:
@@ -26,6 +26,10 @@ jobs:
         - CPPFLAGS="-I/usr/local/opt/libressl/include"
         - PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:$PATH"
         - PATH="$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH"
+    - compiler: gcc
+      arch: arm64-graviton2
+      virt: lxd
+      group: edge
 
 env:
   global:


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-11-21  8:53 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-11-21  8:53 UTC (permalink / raw
  To: gentoo-commits

commit:     ca5054171ebd47939a451f600d62e762a51b7d27
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 21 08:52:45 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov 21 08:52:45 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ca505417

qmerge: report relevant errors on binpkg unpacks

Thanks Peter Stuge for noticing.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 73efcb6..e439a7d 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1258,7 +1258,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 			rd = fread(iobuf, 1, n, tbz2f);
 			if (0 == rd) {
 				if ((err = ferror(tbz2f)) != 0)
-					err("reading %s failed: %s", tbz2, strerror(errno));
+					err("reading %s failed: %s", tbz2, strerror(err));
 
 				if (feof(tbz2f))
 					err("unexpected EOF in %s: corrupted binpkg", tbz2);
@@ -1268,7 +1268,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 				n = fwrite(iobuf + wr, 1, rd - wr, tarpipe);
 				if (n != rd - wr) {
 					if ((err = ferror(tarpipe)) != 0)
-						err("failed to unpack binpkg: %s", strerror(errno));
+						err("failed to unpack binpkg: %s", strerror(err));
 
 					if (feof(tarpipe))
 						err("unexpected EOF trying to unpack binpkg");


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-11-14 17:06 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-11-14 17:06 UTC (permalink / raw
  To: gentoo-commits

commit:     0b59c2de6f0390260c1313823c0c044bfffb48b0
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 14 17:06:24 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov 14 17:06:24 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0b59c2de

qmerge: adapt style after previous commit

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 42 ++++++++++++++++++++++--------------------
 1 file changed, 22 insertions(+), 20 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 6d98329..73efcb6 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1231,56 +1231,58 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	 * Since some tools (e.g. zstd) complain about the .bz2
 	 * extension, we feed the tool by input redirection. */
 	snprintf(buf, sizeof(buf),
-		BUSYBOX " sh -c '%s%s"
-		"tar -x%sf - -C image/'",
+		BUSYBOX " sh -c '%s%star -x%sf - -C image/'",
 		compr, compr[0] == '\0' ? "" : " | ",
 		((verbose > 1) ? "v" : ""));
 
 	/* start the tar pipe and copy tbz2size binpkg bytes into it
 	 * "manually" rather than depending on dd or head */
 	{
-		FILE *tarpipe, *tbz2f;
+		FILE *tarpipe;
+		FILE *tbz2f;
 		unsigned char iobuf[8192];
 		int piped = 0;
-		size_t n, rd, wr;
+		int err;
+		size_t n;
+		size_t rd;
+		size_t wr;
 
-		tarpipe = popen(buf, "w");
-		if (NULL == tarpipe)
-			errp("popen(%s)", buf);
+		if ((tarpipe = popen(buf, "w")) == NULL)
+			errp("failed to start %s", buf);
 
-		tbz2f = fopen(tbz2, "r");
-		if (NULL == tbz2f)
-			errp("fopen(%s)", tbz2);
+		if ((tbz2f = fopen(tbz2, "r")) == NULL)
+			errp("failed to open %s for reading", tbz2);
 
 		for (piped = wr = 0; piped < tbz2size; piped += wr) {
 			n = MIN(tbz2size - piped, (ssize_t)sizeof iobuf);
 			rd = fread(iobuf, 1, n, tbz2f);
 			if (0 == rd) {
-				errno = ferror(tbz2f);
-				if (errno)
-					errp("fread(%s)", tbz2);
+				if ((err = ferror(tbz2f)) != 0)
+					err("reading %s failed: %s", tbz2, strerror(errno));
 
 				if (feof(tbz2f))
-					err("%s: unexpected EOF; corrupted binpkg", tbz2);
+					err("unexpected EOF in %s: corrupted binpkg", tbz2);
 			}
 
 			for (wr = n = 0; wr < rd; wr += n) {
 				n = fwrite(iobuf + wr, 1, rd - wr, tarpipe);
 				if (n != rd - wr) {
-					errno = ferror(tarpipe);
-					if (errno)
-						errp("fwrite(%s)", buf);
+					if ((err = ferror(tarpipe)) != 0)
+						err("failed to unpack binpkg: %s", strerror(errno));
 
 					if (feof(tarpipe))
-						err("%s pipe: unexpected EOF", buf);
+						err("unexpected EOF trying to unpack binpkg");
 				}
 			}
 		}
 
 		fclose(tbz2f);
 
-		if (-1 == pclose(tarpipe))
-			errp("pclose(%s)", buf);
+		err = pclose(tarpipe);
+		if (err > 0)
+			err("finishing unpack binpkg exited with status %d", err);
+		else if (err < 0)
+			errp("finishing unpack binpkg unsuccessful");
 	}
 
 	free(tbz2);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-11-14 17:06 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-11-14 17:06 UTC (permalink / raw
  To: gentoo-commits

commit:     77a0017b2ea736670eba1f3923201dc1c2858feb
Author:     Peter Stuge <peter <AT> stuge <DOT> se>
AuthorDate: Tue Nov 10 19:01:44 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov 14 16:44:47 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=77a0017b

qmerge: copy tbz2 archive into decompressor/tar pipe ourselves

We have nothing to do while tar is running so let's copy the tbz2
archive part into a popen():ed tar pipe ourselves, rather than depend
on an external program.

Doing so also fixes a possible shell injection vulnerability and
improves performance.

Fixes: 7171479f ("qmerge: unpack tbz2 file without splitting it first", 2020-05-17)
Signed-off-by: Peter Stuge <peter <AT> stuge.se>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 49 insertions(+), 3 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 36d3596..6d98329 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1231,13 +1231,59 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	 * Since some tools (e.g. zstd) complain about the .bz2
 	 * extension, we feed the tool by input redirection. */
 	snprintf(buf, sizeof(buf),
-		BUSYBOX " sh -c 'dd status=none if=%s bs=1 count=%d %s%s | "
+		BUSYBOX " sh -c '%s%s"
 		"tar -x%sf - -C image/'",
-		tbz2, tbz2size, compr[0] == '\0' ? "" : "| ", compr,
+		compr, compr[0] == '\0' ? "" : " | ",
 		((verbose > 1) ? "v" : ""));
 
+	/* start the tar pipe and copy tbz2size binpkg bytes into it
+	 * "manually" rather than depending on dd or head */
+	{
+		FILE *tarpipe, *tbz2f;
+		unsigned char iobuf[8192];
+		int piped = 0;
+		size_t n, rd, wr;
+
+		tarpipe = popen(buf, "w");
+		if (NULL == tarpipe)
+			errp("popen(%s)", buf);
+
+		tbz2f = fopen(tbz2, "r");
+		if (NULL == tbz2f)
+			errp("fopen(%s)", tbz2);
+
+		for (piped = wr = 0; piped < tbz2size; piped += wr) {
+			n = MIN(tbz2size - piped, (ssize_t)sizeof iobuf);
+			rd = fread(iobuf, 1, n, tbz2f);
+			if (0 == rd) {
+				errno = ferror(tbz2f);
+				if (errno)
+					errp("fread(%s)", tbz2);
+
+				if (feof(tbz2f))
+					err("%s: unexpected EOF; corrupted binpkg", tbz2);
+			}
+
+			for (wr = n = 0; wr < rd; wr += n) {
+				n = fwrite(iobuf + wr, 1, rd - wr, tarpipe);
+				if (n != rd - wr) {
+					errno = ferror(tarpipe);
+					if (errno)
+						errp("fwrite(%s)", buf);
+
+					if (feof(tarpipe))
+						err("%s pipe: unexpected EOF", buf);
+				}
+			}
+		}
+
+		fclose(tbz2f);
+
+		if (-1 == pclose(tarpipe))
+			errp("pclose(%s)", buf);
+	}
+
 	free(tbz2);
-	xsystem(buf);
 	fflush(stdout);
 
 	eat_file("vdb/DEFINED_PHASES", &phases, &phases_len);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-11-13  9:32 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-11-13  9:32 UTC (permalink / raw
  To: gentoo-commits

commit:     4622c79b0a1bad6dd0c741f3d10fbc987e4f565e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 13 09:30:53 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Nov 13 09:30:53 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4622c79b

qmerge: don't call zstd with --long=31 on 32-bits platforms

32-bits recent versions of zstd do not grok this argument, so just drop
it for those platforms

Bug: https://bugs.gentoo.org/754102
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 configure.ac | 10 ++++++++++
 qmerge.c     | 11 ++++++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 0efdf3e..989a34f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -18,6 +18,16 @@ AM_PROG_AR
 LT_INIT
 AC_SUBST([LIBTOOL_DEPS])
 
+headers='#ifdef HAVE_STDDEF_H
+#include <stddef.h>
+#endif
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+'
+AC_CHECK_HEADERS([stddef.h unistd.h])
+AC_COMPILE_CHECK_SIZEOF([size_t], [${headers}])
+
 AC_CHECK_FUNCS_ONCE(m4_flatten([
 	   fmemopen
 	   scandirat

diff --git a/qmerge.c b/qmerge.c
index 143c4f3..36d3596 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1191,8 +1191,17 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 				 * --long=xx where xx>27. The option is "safe" in the sense
 				 * that not more memory is allocated than what is really
 				 * needed to decompress the file. See
-				 * https://bugs.gentoo.org/show_bug.cgi?id=634980 */
+				 * https://bugs.gentoo.org/show_bug.cgi?id=634980,
+				 * however, on 32-bits arches this yields an parameter
+				 * out of bound error:
+				 * https://bugs.gentoo.org/show_bug.cgi?id=710444
+				 * https://bugs.gentoo.org/show_bug.cgi?id=754102
+				 * so only do this on 64-bits systems */
+#if SIZEOF_SIZE_T >= 8
 				compr = "zstd --long=31 -dc";
+#else
+				compr = "zstd -dc";
+#endif
 				/* If really tar -I would be used we would have to quote:
 				 * compr = "I \"zstd --long=31\"";
 				 * But actually we use a pipe (see below) */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-10-04 19:30 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-10-04 19:30 UTC (permalink / raw
  To: gentoo-commits

commit:     d5579e07d763403aa8ac770a97e3c36c96f6540a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  4 19:28:06 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct  4 19:28:06 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d5579e07

qlop: adapt terminating/exiting logic somewhat

It seems that exiting doesn't always come immediately (= the same
second) after terminating, so allow a small window (4s) for these to
come in sequence to treat them as a single termination.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qlop.c b/qlop.c
index 762523f..5045d17 100644
--- a/qlop.c
+++ b/qlop.c
@@ -508,7 +508,7 @@ static int do_emerge_log(
 			if (p[7] == 'm') {
 				parallel_emerge++;
 			} else if (parallel_emerge > 0) {
-				if (p[7] != 'e' || tstart != last_exit)
+				if (p[7] != 'e' || (tstart - 4) <= last_exit)
 					parallel_emerge--;
 				if (p[7] == 'x')
 					last_exit = tstart;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-10-04 19:06 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-10-04 19:06 UTC (permalink / raw
  To: gentoo-commits

commit:     1f26829eb69625e86babfdf301d1f1d3afbdaf36
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  4 19:05:34 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct  4 19:05:34 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1f26829e

qlop: slightly increase the average when computing ETA

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qlop.c b/qlop.c
index ad16d55..762523f 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1002,6 +1002,9 @@ static int do_emerge_log(
 			pkg = get_set(afmt, merge_averages);
 			if (pkg != NULL) {
 				maxtime = pkg->time / pkg->cnt;
+				/* add 14% of the diff between avg and max, to avoid
+				 * frequently swapping to maxtime */
+				maxtime += (pkg->tbegin - maxtime) / 7;
 				if (elapsed >= maxtime) {
 					maxtime = pkg->tbegin;
 					if (elapsed >= maxtime)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-10-04 18:46 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-10-04 18:46 UTC (permalink / raw
  To: gentoo-commits

commit:     10d8cc211d638832c70517f132d66c21380293d2
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  4 18:45:32 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct  4 18:45:54 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=10d8cc21

qlop: drop accidential debug print from probe_proc

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/qlop.c b/qlop.c
index 24b154c..ad16d55 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1368,7 +1368,6 @@ static array_t *probe_proc(array_t *atoms)
 		atom->PV = NULL;
 		atom->PVR = NULL;
 		atom->PR_int = 0;
-		printf("proc: %s\n", atom_to_string(atom));
 		xarraypush_ptr(atoms, atom);
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-10-04 18:44 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-10-04 18:44 UTC (permalink / raw
  To: gentoo-commits

commit:     e2cb3938176e97b6e41d1873838db35a017cf7d9
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  4 18:43:17 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct  4 18:43:17 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e2cb3938

qlop: fix fix for #731122, also make it work without packages specified

Bug: https://bugs.gentoo.org/745798
Bug: https://bugs.gentoo.org/731122
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/qlop.c b/qlop.c
index a5d8678..24b154c 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1353,12 +1353,6 @@ static array_t *probe_proc(array_t *atoms)
 					xarraydelete_ptr(ret_atoms, j);
 					atom_implode(atomr);
 					break;
-				} else {
-					/* bug #731122: match running packages without
-					 * version */
-					atomr->PV = NULL;
-					atomr->PVR = NULL;
-					atomr->PR_int = 0;
 				}
 			}
 			atom_implode(atom);
@@ -1369,7 +1363,14 @@ static array_t *probe_proc(array_t *atoms)
 	/* ret_atoms is allocated on the stack, so copy into atoms which is
 	 * empty at this point */
 	array_for_each(ret_atoms, i, atom)
+	{
+		/* bug #731122: match running packages without version */
+		atom->PV = NULL;
+		atom->PVR = NULL;
+		atom->PR_int = 0;
+		printf("proc: %s\n", atom_to_string(atom));
 		xarraypush_ptr(atoms, atom);
+	}
 
 	xarrayfree_int(ret_atoms);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-10-04 12:33 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-10-04 12:33 UTC (permalink / raw
  To: gentoo-commits

commit:     8b01bccbd469e034736f4d88f595a61e6ef6f7b4
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  4 12:32:00 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct  4 12:32:00 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8b01bccb

qlop: treat either terminating or exiting or both as a termination of Portage

It seems Portage is very inconsistent sometimes terminating, sometimes
exiting, most of the time exiting and terminating.  Deal with it.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 49 +++++++++++++++++++++++++++----------------------
 1 file changed, 27 insertions(+), 22 deletions(-)

diff --git a/qlop.c b/qlop.c
index dce46f2..a5d8678 100644
--- a/qlop.c
+++ b/qlop.c
@@ -374,6 +374,7 @@ static int do_emerge_log(
 	time_t tlast = tbegin;
 	time_t tstart_emerge = 0;
 	time_t last_merge = 0;
+	time_t last_exit = 0;
 	time_t sync_start = 0;
 	time_t sync_time = 0;
 	size_t sync_cnt = 0;
@@ -392,6 +393,7 @@ static int do_emerge_log(
 	char afmt[BUFSIZ];
 	struct pkg_match *pkg;
 	struct pkg_match *pkgw;
+#define strpfx(X, Y)  strncmp(X, Y, sizeof(Y) - 1)
 
 	/* support relative path in here and now, when using ROOT, stick to
 	 * it, turning relative into a moot point */
@@ -420,14 +422,14 @@ static int do_emerge_log(
 				continue;
 
 			if (flags->show_lastmerge) {
-				if (strncmp(p, "  *** emerge ", 13) == 0)
+				if (strpfx(p, "  *** emerge ") == 0)
 					tstart_emerge = tstart;
 				if (!all_atoms)
 					continue;
 			}
 
 			atom = NULL;
-			if (strncmp(p, "  >>> emerge ", 13) == 0 &&
+			if (strpfx(p, "  >>> emerge ") == 0 &&
 					(q = strchr(p + 13, ')')) != NULL)
 			{
 				p = q + 2;
@@ -436,8 +438,8 @@ static int do_emerge_log(
 					*q = '\0';
 					atom = atom_explode(p);
 				}
-			} else if (strncmp(p, "  === Unmerging... (", 20) == 0 ||
-					strncmp(p, " === Unmerging... (", 19) == 0)
+			} else if (strpfx(p, "  === Unmerging... (") == 0 ||
+					strpfx(p, " === Unmerging... (") == 0)
 			{
 				if (p[1] == ' ')
 					p++;
@@ -493,17 +495,23 @@ static int do_emerge_log(
 			continue;
 		*p++ = '\0';
 
+		tstart = atol(buf);
+
 		/* keeping track of parallel merges needs to be done before
 		 * applying dates, for a subset of the log might show emerge
 		 * finished without knowledge of another instance */
 		if (flags->do_running &&
-				(strncmp(p, "  *** emerge ", 13) == 0 ||
-				 strncmp(p, "  *** terminating.", 18) == 0))
+				(strpfx(p, "  *** emerge ") == 0 ||
+				 strpfx(p, "  *** exiting ") == 0 ||
+				 strpfx(p, "  *** terminating.") == 0))
 		{
 			if (p[7] == 'm') {
 				parallel_emerge++;
 			} else if (parallel_emerge > 0) {
-				parallel_emerge--;
+				if (p[7] != 'e' || tstart != last_exit)
+					parallel_emerge--;
+				if (p[7] == 'x')
+					last_exit = tstart;
 			}
 
 			/* for bug #687508, this cannot be in the else if case
@@ -531,7 +539,6 @@ static int do_emerge_log(
 			}
 		}
 
-		tstart = atol(buf);
 		if (tstart < tlast)
 			continue;
 		tlast = tstart;
@@ -539,15 +546,14 @@ static int do_emerge_log(
 			continue;
 
 		/* are we interested in this line? */
-		if (flags->show_emerge && verbose && (
-					strncmp(p, "  *** emerge ", 13) == 0))
+		if (flags->show_emerge && verbose && (strpfx(p, "  *** emerge ") == 0))
 		{
 			char shortopts[8];  /* must hold as many opts converted below */
 			int numopts = 0;
 
 			printf("%semerge%s", DKBLUE, NORM);
 			for (p += 13; (q = strtok(p, " \n")) != NULL; p = NULL) {
-				if (strncmp(q, "--", 2) == 0) {
+				if (strpfx(q, "--") == 0) {
 					/* portage seems to normalise options given into
 					 * their long forms always; I don't want to keep a
 					 * mapping table to short forms here, but it's
@@ -596,7 +602,7 @@ static int do_emerge_log(
 					continue;
 				}
 
-				if (strncmp(q, "--", 2) == 0) {
+				if (strpfx(q, "--") == 0) {
 					printf(" %s%s%s", GREEN, q, NORM);
 				} else if (strcmp(q, "@world") == 0 ||
 						strcmp(q, "@system") == 0)
@@ -622,7 +628,7 @@ static int do_emerge_log(
 			}
 			printf("\n");
 		} else if (flags->do_sync && (
-					strncmp(p, " === Sync completed ", 20) == 0 ||
+					strpfx(p, " === Sync completed ") == 0 ||
 					strcmp(p, "  === sync\n") == 0))
 		{
 			/* sync start or stop, we have nothing to detect parallel
@@ -636,7 +642,7 @@ static int do_emerge_log(
 				elapsed = tstart - sync_start;
 
 				p += 20;
-				if (strncmp(p, "for ", 4) == 0) {
+				if (strpfx(p, "for ") == 0) {
 					p += 4;
 				} else {  /* "with " */
 					p += 5;
@@ -670,8 +676,8 @@ static int do_emerge_log(
 				sync_start = 0;  /* reset */
 			}
 		} else if (flags->do_merge && (
-					strncmp(p, "  >>> emerge (", 14) == 0 ||
-					strncmp(p, "  ::: completed emerge (", 24) == 0))
+					strpfx(p, "  >>> emerge (") == 0 ||
+					strpfx(p, "  ::: completed emerge (") == 0))
 		{
 			/* merge start/stop (including potential unmerge of old pkg) */
 			if (p[3] == '>') {  /* >>> emerge */
@@ -810,11 +816,11 @@ static int do_emerge_log(
 			}
 		} else if (
 				(flags->do_unmerge &&
-				 strncmp(p, " === Unmerging... (", 19) == 0) ||
+				 strpfx(p, " === Unmerging... (") == 0) ||
 				(flags->do_autoclean &&
-				 strncmp(p, "  === Unmerging... (", 20) == 0) ||
+				 strpfx(p, "  === Unmerging... (") == 0) ||
 				((flags->do_unmerge || flags->do_autoclean) &&
-				 strncmp(p, "  >>> unmerge success: ", 23) == 0))
+				 strpfx(p, "  >>> unmerge success: ") == 0))
 		{
 			/* unmerge action */
 			if (p[2] == '=') {
@@ -1230,7 +1236,7 @@ static array_t *probe_proc(array_t *atoms)
 			if (eat_file(npath, &cmdline, &cmdlinesize)) {
 				if (cmdlinesize > 0 && cmdline[0] == '[' &&
 						(p = strchr(cmdline, ']')) != NULL &&
-						strncmp(p, "] sandbox", sizeof("] sandbox") - 1) == 0)
+						strpfx(p, "] sandbox") == 0)
 				{
 					*p = '\0';
 					atom = atom_explode(cmdline + 1);
@@ -1268,8 +1274,7 @@ static array_t *probe_proc(array_t *atoms)
 					if ((size_t)rpathlen > sizeof(".log.gz") &&
 							(p = strrchr(rpath, '.')) != NULL &&
 							p - (sizeof(".log") - 1) > rpath &&
-							strncmp(p - (sizeof(".log") - 1), ".log",
-								sizeof(".log") - 1) == 0)
+							strpfx(p - (sizeof(".log") - 1), ".log") == 0)
 					{
 						*p = '\0';
 						rpathlen -= rpath - p;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-10-04 11:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-10-04 11:54 UTC (permalink / raw
  To: gentoo-commits

commit:     a29346b666decbba87f1d9cf56f7f72de485c343
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  4 11:52:13 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct  4 11:52:13 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a29346b6

qlop: return sandbox piggybacking method of finding running merges

Because sandbox doesn't seem as dead as it was pronounced a while ago,
bring back support in qlop, since it is the easiest way to detect
running merges without any special privileges necessary.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/qlop.c b/qlop.c
index 316c9b0..dce46f2 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1197,6 +1197,8 @@ static array_t *probe_proc(array_t *atoms)
 	depend_atom *atom;
 	DECLARE_ARRAY(ret_atoms);
 	size_t i;
+	char *cmdline = NULL;
+	size_t cmdlinesize = 0;
 
 	/* /proc/<pid>/path/<[0-9]+link>
 	 * /proc/<pid>/fd/<[0-9]+link> */
@@ -1218,6 +1220,33 @@ static array_t *probe_proc(array_t *atoms)
 			}
 
 			pid = d->d_name;
+
+			/* first try old-fashioned (good old) sandbox approach; this
+			 * one may not have a long life in Gentoo any more, but for
+			 * now it's still being used quite a lot, and the advantage
+			 * is that it doesn't require root access, for cmdline can
+			 * be read by anyone */
+			snprintf(npath, sizeof(npath), "/proc/%s/cmdline", pid);
+			if (eat_file(npath, &cmdline, &cmdlinesize)) {
+				if (cmdlinesize > 0 && cmdline[0] == '[' &&
+						(p = strchr(cmdline, ']')) != NULL &&
+						strncmp(p, "] sandbox", sizeof("] sandbox") - 1) == 0)
+				{
+					*p = '\0';
+					atom = atom_explode(cmdline + 1);
+
+					if (atom != NULL) {
+						if (atom->CATEGORY == NULL || atom->P == NULL) {
+							atom_implode(atom);
+						} else {
+							xarraypush_ptr(ret_atoms, atom);
+							continue;
+						}
+					}
+				}
+			}
+
+			/* now try and see if Portage opened a build log somewhere */
 			snprintf(npath, sizeof(npath), "/proc/%s/%s", pid, subdir);
 			if ((linkslen = scandir(npath, &links, NULL, NULL)) > 0) {
 				for (li = 0; li < linkslen; li++) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-10-04 11:31 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-10-04 11:31 UTC (permalink / raw
  To: gentoo-commits

commit:     83325e68514d4d55554bff9439b61c03f12d4d8b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  4 11:29:43 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct  4 11:29:43 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=83325e68

qlop: deal with optionally compressed buildlogs in probe_proc

Bug: https://bugs.gentoo.org/745798
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/qlop.c b/qlop.c
index f8248d4..316c9b0 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1232,6 +1232,20 @@ static array_t *probe_proc(array_t *atoms)
 						continue;
 					rpath[rpathlen] = '\0';
 
+					/* in bug #745798, it seems Portage optionally
+					 * compresses the buildlog -- to make matching below
+					 * here easier, strip such compression extension off
+					 * first here, leaving .log */
+					if ((size_t)rpathlen > sizeof(".log.gz") &&
+							(p = strrchr(rpath, '.')) != NULL &&
+							p - (sizeof(".log") - 1) > rpath &&
+							strncmp(p - (sizeof(".log") - 1), ".log",
+								sizeof(".log") - 1) == 0)
+					{
+						*p = '\0';
+						rpathlen -= rpath - p;
+					}
+
 					/* check if this points to a portage build:
 					 * <somepath>/portage/<cat>/<pf>/temp/build.log
 					 * <somepath>/<cat>:<pf>:YYYYMMDD-HHMMSS.log */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-10-04 11:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-10-04 11:09 UTC (permalink / raw
  To: gentoo-commits

commit:     a1e44dbf5cec055ce0300249d6d14c58f961062f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct  4 11:08:57 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct  4 11:08:57 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a1e44dbf

qlop: ensure running merges are calculated of off package names #731122

Bug: https://bugs.gentoo.org/731122
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/qlop.c b/qlop.c
index 385613a..f8248d4 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1305,6 +1305,12 @@ static array_t *probe_proc(array_t *atoms)
 					xarraydelete_ptr(ret_atoms, j);
 					atom_implode(atomr);
 					break;
+				} else {
+					/* bug #731122: match running packages without
+					 * version */
+					atomr->PV = NULL;
+					atomr->PVR = NULL;
+					atomr->PR_int = 0;
 				}
 			}
 			atom_implode(atom);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-08-17 14:34 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-08-17 14:34 UTC (permalink / raw
  To: gentoo-commits

commit:     e55f582c4c129ece9037575135a95f98a91a210f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 17 14:31:16 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Aug 17 14:31:16 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e55f582c

qlop: work around Coverity complaints

Check/search once for colons, it is a bit brittle to assume a colon was
found, even though in this case it should have always succeeded.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 19 +++++++++----------
 1 file changed, 9 insertions(+), 10 deletions(-)

diff --git a/qlop.c b/qlop.c
index 47ef83d..385613a 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1249,27 +1249,26 @@ static array_t *probe_proc(array_t *atoms)
 					} else if ((size_t)rpathlen > sizeof(".log") &&
 							strcmp(rpath + rpathlen -
 								(sizeof(".log") - 1), ".log") == 0 &&
-							(p = strchr(rpath, ':')) != NULL &&
-							(p = strchr(p + 1, ':')) != NULL &&
 							(p = strrchr(rpath, '/')) != NULL)
 					{
 						char *q;
 
 						p++;  /* skip / */
-						q = strchr(p, ':');  /* checked above to exist */
-						*q++ = '/';
-						q = strchr(q, ':');  /* checked above to exist */
-						*q = '\0';
-
-						atom = atom_explode(p);
+						if ((q = strchr(p, ':')) != NULL) {
+							*q++ = '/';
+							if ((q = strchr(q, ':')) != NULL) {
+								*q = '\0';
+								atom = atom_explode(p);
+							}
+						}
 					}
 
+					if (atom == NULL)
+						continue;
 					if (atom->CATEGORY == NULL || atom->P == NULL) {
 						atom_implode(atom);
 						continue;
 					}
-					if (atom == NULL)
-						continue;
 
 					xarraypush_ptr(ret_atoms, atom);
 				}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-08-17 13:08 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-08-17 13:08 UTC (permalink / raw
  To: gentoo-commits

commit:     345bb718f59c65823722e8ae94ac7ae9f9060dd1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 17 12:50:52 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Aug 17 12:50:52 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=345bb718

qlop: recognise logfile naming when PORTAGE_LOGDIR is set, bug #711896

Bug: https://bugs.gentoo.org/711896
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 40 ++++++++++++++++++++++++++++++----------
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/qlop.c b/qlop.c
index a5761d7..47ef83d 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1231,10 +1231,13 @@ static array_t *probe_proc(array_t *atoms)
 					if (rpathlen <= 0)
 						continue;
 					rpath[rpathlen] = '\0';
+
 					/* check if this points to a portage build:
-					 * <somepath>/portage/<cat>/<pf>/temp/build.log */
+					 * <somepath>/portage/<cat>/<pf>/temp/build.log
+					 * <somepath>/<cat>:<pf>:YYYYMMDD-HHMMSS.log */
+					atom = NULL;
 					if ((size_t)rpathlen > sizeof("/temp/build.log") &&
-								strcmp(rpath + rpathlen -
+							strcmp(rpath + rpathlen -
 								(sizeof("/temp/build.log") - 1),
 								"/temp/build.log") == 0 &&
 							(p = strstr(rpath, "/portage/")) != NULL)
@@ -1243,15 +1246,32 @@ static array_t *probe_proc(array_t *atoms)
 						rpath[rpathlen - (sizeof("/temp/build.log") - 1)] =
 							'\0';
 						atom = atom_explode(p);
-						if (atom == NULL ||
-								atom->CATEGORY == NULL || atom->P == NULL)
-						{
-							if (atom != NULL)
-								atom_implode(atom);
-							continue;
-						}
-						xarraypush_ptr(ret_atoms, atom);
+					} else if ((size_t)rpathlen > sizeof(".log") &&
+							strcmp(rpath + rpathlen -
+								(sizeof(".log") - 1), ".log") == 0 &&
+							(p = strchr(rpath, ':')) != NULL &&
+							(p = strchr(p + 1, ':')) != NULL &&
+							(p = strrchr(rpath, '/')) != NULL)
+					{
+						char *q;
+
+						p++;  /* skip / */
+						q = strchr(p, ':');  /* checked above to exist */
+						*q++ = '/';
+						q = strchr(q, ':');  /* checked above to exist */
+						*q = '\0';
+
+						atom = atom_explode(p);
 					}
+
+					if (atom->CATEGORY == NULL || atom->P == NULL) {
+						atom_implode(atom);
+						continue;
+					}
+					if (atom == NULL)
+						continue;
+
+					xarraypush_ptr(ret_atoms, atom);
 				}
 				scandir_free(links, linkslen);
 			}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-08-17 13:08 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-08-17 13:08 UTC (permalink / raw
  To: gentoo-commits

commit:     48cbbded273c08965cd33a74048596339f6d61be
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 17 12:30:21 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Aug 17 12:30:21 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=48cbbded

qmerge: force FEATURES=-preserve-libs, bug #698462

We do not support/implement preserve-libs feature (we could), so drop
it from FEATURES such that preserve_old_libs kicks in for some of the
crucial libs around.

Bug: https://bugs.gentoo.org/698462
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qmerge.c b/qmerge.c
index 2c24bfb..143c4f3 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -686,6 +686,9 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 		"D=\"%5$s\"\n"
 		"ED=\"${D%%/}/${EPREFIX%%/}/\"\n"
 		"T=\"%6$s\"\n"
+		/* we do not support preserve-libs yet, so force
+		 * preserve_old_lib instead */
+		"FEATURES=\"${FEATURES/preserve-libs/disabled}\"\n"
 		/* Finally run the func */
 		"%7$s%2$s\n"
 		/* Ignore func return values (not exit values) */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-08-14 10:44 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-08-14 10:44 UTC (permalink / raw
  To: gentoo-commits

commit:     e5a915ca4e9760ffd3b4c2dc4d6b22dd78b8b352
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 14 10:41:10 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Aug 14 10:41:10 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e5a915ca

qlist: Coverity 212181: guard against NULL-pointers

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlist.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qlist.c b/qlist.c
index 3652c0a..a6bcc43 100644
--- a/qlist.c
+++ b/qlist.c
@@ -529,8 +529,10 @@ int qlist_main(int argc, char **argv)
 
 		array_for_each(overlays, n, overlay) {
 			vdb = tree_open(portroot, overlay);
-			ret |= tree_foreach_pkg_sorted(vdb, qlist_cb, &state, NULL);
-			tree_close(vdb);
+			if (vdb != NULL) {
+				ret |= tree_foreach_pkg_sorted(vdb, qlist_cb, &state, NULL);
+				tree_close(vdb);
+			}
 		}
 	} else {
 		if (state.do_binpkgs)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-08-14 10:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-08-14 10:09 UTC (permalink / raw
  To: gentoo-commits

commit:     d188469068509cc3f802b2f9f916b0f4daa911ac
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Aug 14 10:09:15 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Aug 14 10:09:15 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d1884690

qmerge: fix syntax error introduced in bafe11f5e8beb6ee1fe5e344aba517a22bc0cf9f

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index d407cd7..2c24bfb 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -651,7 +651,7 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 		"debug-print-section() { :; }\n"
 		/* Not quite right */
 		"has_version() { [ -n \"$(qlist -ICqe \"$1\")\" ]; }\n"
-		"best_version() { qlist -ICqev \"$1\" }\n"
+		"best_version() { qlist -ICqev \"$1\"; }\n"
 		"use() { useq \"$@\"; }\n"
 		"usex() { useq \"$1\" && echo \"${2-yes}$4\" || echo \"${3-no}$5\"; }\n"
 		"useq() { hasq \"$1\" ${USE}; }\n"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-08-14  9:35 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-08-14  9:35 UTC (permalink / raw
  To: gentoo-commits

commit:     bafe11f5e8beb6ee1fe5e344aba517a22bc0cf9f
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Tue Aug 11 14:45:21 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Aug 14 09:35:21 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bafe11f5

qmerge: Impl. best_version()

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 80c34a0..2b1d082 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -651,7 +651,7 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 		"debug-print-section() { :; }\n"
 		/* Not quite right */
 		"has_version() { [ -n \"$(qlist -ICqe \"$1\")\" ]; }\n"
-		/* best_version() */
+		"best_version() { qlist -ICqev \"$1\" }\n"
 		"use() { useq \"$@\"; }\n"
 		"usex() { useq \"$1\" && echo \"${2-yes}$4\" || echo \"${3-no}$5\"; }\n"
 		"useq() { hasq \"$1\" ${USE}; }\n"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-08-14  9:35 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-08-14  9:35 UTC (permalink / raw
  To: gentoo-commits

commit:     21c96ac89e6cb397565c25430034edd222c73c5c
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Tue Aug 11 14:45:22 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Aug 14 09:35:23 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=21c96ac8

qmerge: Impl. einfon()

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qmerge.c b/qmerge.c
index 2b1d082..f246e57 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -660,6 +660,7 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 		"hasq() { local h=$1; shift; case \" $* \" in *\" $h \"*) return 0;; *) return 1;; esac; }\n"
 		"hasv() { hasq \"$@\" && echo \"$1\"; }\n"
 		"elog() { printf ' * %%b\\n' \"$*\"; }\n"
+		"einfon() { printf ' * %%b' \"$*\"; }\n"
 		"einfo() { elog \"$@\"; }\n"
 		"ewarn() { elog \"$@\"; }\n"
 		"eqawarn() { elog \"QA: \"\"$@\"; }\n"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-08-02  7:39 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-08-02  7:39 UTC (permalink / raw
  To: gentoo-commits

commit:     61ac8ae9168b7262a6f68a07da312659181647a0
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Aug  2 07:37:51 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Aug  2 07:37:51 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=61ac8ae9

read_portage_profile: adapt warning to point to which profile

When we fail to resolve a repo match, give the user a better hint by
pointing to the profile we were reading.

Bug: https://bugs.gentoo.org/735134
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index d2a452c..c8b0429 100644
--- a/main.c
+++ b/main.c
@@ -563,7 +563,8 @@ read_portage_profile(const char *profile, env_vars vars[], set *masks)
 					repo_name = NULL;
 				}
 				if (repo_name == NULL) {
-					warn("ignoring parent with unknown repo in profile: %s", s);
+					warn("ignoring parent with unknown repo in profile %s: %s",
+							profile, s);
 					continue;
 				}
 			} else {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-07-08  8:12 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-07-08  8:12 UTC (permalink / raw
  To: gentoo-commits

commit:     bee2b445ae583187d2b8218a5b1429828f872663
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jul  8 08:11:38 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jul  8 08:11:38 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bee2b445

qlop: fix crash when encountering a long option with -E -v

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/qlop.c b/qlop.c
index 5048b1e..a5761d7 100644
--- a/qlop.c
+++ b/qlop.c
@@ -545,7 +545,7 @@ static int do_emerge_log(
 			char shortopts[8];  /* must hold as many opts converted below */
 			int numopts = 0;
 
-			printf("emerge");
+			printf("%semerge%s", DKBLUE, NORM);
 			for (p += 13; (q = strtok(p, " \n")) != NULL; p = NULL) {
 				if (strncmp(q, "--", 2) == 0) {
 					/* portage seems to normalise options given into
@@ -556,24 +556,31 @@ static int do_emerge_log(
 					q += 2;
 					if (strcmp(q, "ask") == 0) {
 						shortopts[numopts++] = 'a';
+						q = NULL;
 					} else if (strcmp(q, "verbose") == 0) {
 						shortopts[numopts++] = 'v';
+						q = NULL;
 					} else if (strcmp(q, "oneshot") == 0) {
 						shortopts[numopts++] = '1';
+						q = NULL;
 					} else if (strcmp(q, "deep") == 0) {
 						shortopts[numopts++] = 'D';
+						q = NULL;
 					} else if (strcmp(q, "update") == 0) {
 						shortopts[numopts++] = 'u';
+						q = NULL;
 					} else if (strcmp(q, "depclean") == 0) {
 						shortopts[numopts++] = 'c';
+						q = NULL;
 					} else if (strcmp(q, "unmerge") == 0) {
 						shortopts[numopts++] = 'C';
-					} else {
 						q = NULL;
+					} else {
+						q -= 2;
 					}
 
 					/* process next token */
-					if (q != NULL)
+					if (q == NULL)
 						continue;
 				}
 
@@ -590,7 +597,7 @@ static int do_emerge_log(
 				}
 
 				if (strncmp(q, "--", 2) == 0) {
-					printf(" %s--%s%s", GREEN, q, NORM);
+					printf(" %s%s%s", GREEN, q, NORM);
 				} else if (strcmp(q, "@world") == 0 ||
 						strcmp(q, "@system") == 0)
 				{


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-06-28 19:11 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-06-28 19:11 UTC (permalink / raw
  To: gentoo-commits

commit:     662850519f77c11367c4a05caf6f45bbc5cf3885
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 28 19:09:34 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jun 28 19:09:34 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=66285051

qpkg: replace allocated buf with stack version

now we don't use anything that would realloc buf, just stick to a buffer
on the stack so we don't have ensure we free it either

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 40 ++++++++++------------------------------
 1 file changed, 10 insertions(+), 30 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 8faa6ea..533e05c 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -174,11 +174,10 @@ qpkg_make(tree_pkg_ctx *pkg)
 	char tmpdir[BUFSIZE];
 	char filelist[BUFSIZE + 32];
 	char tbz2[BUFSIZE + 32];
-	size_t buflen;
+	char buf[BUFSIZE * 4];
 	size_t xpaksize;
 	char *line;
 	char *savep;
-	char *buf;
 	int i;
 	char *xpak_argv[2];
 	struct stat st;
@@ -191,9 +190,6 @@ qpkg_make(tree_pkg_ctx *pkg)
 		return 0;
 	}
 
-	buflen = _Q_PATH_MAX;
-	buf = xmalloc(buflen);
-
 	line = tree_pkg_meta_get(pkg, CONTENTS);
 	if (line == NULL)
 		return -1;
@@ -202,22 +198,16 @@ qpkg_make(tree_pkg_ctx *pkg)
 	mask = umask(0077);
 	i = mkstemp(tmpdir);
 	umask(mask);
-	if (i == -1) {
-		free(buf);
+	if (i == -1)
 		return -2;
-	}
 	close(i);
 	unlink(tmpdir);
-	if (mkdir(tmpdir, 0750)) {
-		free(buf);
+	if (mkdir(tmpdir, 0750))
 		return -3;
-	}
 
 	snprintf(filelist, sizeof(filelist), "%s/filelist", tmpdir);
-	if ((out = fopen(filelist, "w")) == NULL) {
-		free(buf);
+	if ((out = fopen(filelist, "w")) == NULL)
 		return -4;
-	}
 
 	for (; (line = strtok_r(line, "\n", &savep)) != NULL; line = NULL) {
 		contents_entry *e;
@@ -244,18 +234,14 @@ qpkg_make(tree_pkg_ctx *pkg)
 	fflush(stdout);
 
 	snprintf(tbz2, sizeof(tbz2), "%s/bin.tbz2", tmpdir);
-	if (snprintf(buf, buflen, "tar jcf '%s' --files-from='%s' "
-			"--no-recursion >/dev/null 2>&1", tbz2, filelist) > (int)buflen ||
-			(fp = popen(buf, "r")) == NULL)
-	{
-		free(buf);
+	if (snprintf(buf, sizeof(buf), "tar jcf '%s' --files-from='%s' "
+			"--no-recursion >/dev/null 2>&1", tbz2, filelist) >
+			(int)sizeof(buf) || (fp = popen(buf, "r")) == NULL)
 		return 2;
-	}
 	pclose(fp);
 
 	if ((i = open(tbz2, O_WRONLY)) < 0) {
 		warnp("failed to open '%s': %s", tbz2, strerror(errno));
-		free(buf);
 		return 1;
 	}
 
@@ -263,12 +249,11 @@ qpkg_make(tree_pkg_ctx *pkg)
 	if (fstat(i, &st) == -1) {
 		warnp("could not stat '%s': %s", tbz2, strerror(errno));
 		close(i);
-		free(buf);
 		return 1;
 	}
 	xpaksize = st.st_size;
 
-	snprintf(buf, buflen, "%s%s/%s/%s",
+	snprintf(buf, sizeof(buf), "%s%s/%s/%s",
 			portroot, portvdb, atom->CATEGORY, atom->PF);
 	xpak_argv[0] = buf;
 	xpak_argv[1] = NULL;
@@ -278,7 +263,6 @@ qpkg_make(tree_pkg_ctx *pkg)
 	if (fstat(i, &st) == -1) {
 		warnp("could not stat '%s': %s", tbz2, strerror(errno));
 		close(i);
-		free(buf);
 		return 1;
 	}
 	xpaksize = st.st_size - xpaksize;
@@ -287,7 +271,6 @@ qpkg_make(tree_pkg_ctx *pkg)
 	if ((fp = fdopen(i, "a")) == NULL) {
 		warnp("could not open '%s': %s", tbz2, strerror(errno));
 		close(i);
-		free(buf);
 		return 1;
 	}
 
@@ -299,14 +282,13 @@ qpkg_make(tree_pkg_ctx *pkg)
 	unlink(filelist);
 
 	/* create dirs, if necessary */
-	snprintf(buf, buflen, "%s/%s", qpkg_bindir, atom->CATEGORY);
+	snprintf(buf, sizeof(buf), "%s/%s", qpkg_bindir, atom->CATEGORY);
 	mkdir_p(buf, 0755);
 
-	snprintf(buf, buflen, "%s/%s/%s.tbz2",
+	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2",
 			qpkg_bindir, atom->CATEGORY, atom->PF);
 	if (rename(tbz2, buf)) {
 		warnp("could not move '%s' to '%s'", tbz2, buf);
-		free(buf);
 		return 1;
 	}
 
@@ -314,14 +296,12 @@ qpkg_make(tree_pkg_ctx *pkg)
 
 	if (stat(buf, &st) == -1) {
 		warnp("could not stat '%s': %s", buf, strerror(errno));
-		free(buf);
 		return 1;
 	}
 
 	printf("%s%s%s KiB\n",
 			RED, make_human_readable_str(st.st_size, 1, KILOBYTE), NORM);
 
-	free(buf);
 	return 0;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-06-28 15:58 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-06-28 15:58 UTC (permalink / raw
  To: gentoo-commits

commit:     7a9bfc5db85d0dab0dbce60f05903b7c4e227192
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jun 28 15:56:44 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jun 28 15:56:44 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7a9bfc5d

qpkg: use tree_pkg_meta_get instead of direct VDB read

qpkg failed to create packages from a different ROOT because the
CONTENTS from vdb was read without ROOT support.  Avoid this by using
tree-based functions that properly use ROOT.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 47 ++++++++++++++++++-----------------------------
 1 file changed, 18 insertions(+), 29 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 41ac0f5..8faa6ea 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -167,19 +167,23 @@ check_pkg_install_mask(char *name)
 }
 
 static int
-qpkg_make(depend_atom *atom)
+qpkg_make(tree_pkg_ctx *pkg)
 {
-	FILE *fp, *out;
+	FILE *out;
+	FILE *fp;
 	char tmpdir[BUFSIZE];
 	char filelist[BUFSIZE + 32];
 	char tbz2[BUFSIZE + 32];
 	size_t buflen;
 	size_t xpaksize;
+	char *line;
+	char *savep;
 	char *buf;
 	int i;
 	char *xpak_argv[2];
 	struct stat st;
 	mode_t mask;
+	depend_atom *atom = tree_get_atom(pkg, false);
 
 	if (pretend) {
 		printf(" %s-%s %s:\n",
@@ -190,40 +194,34 @@ qpkg_make(depend_atom *atom)
 	buflen = _Q_PATH_MAX;
 	buf = xmalloc(buflen);
 
-	snprintf(buf, buflen, "%s/%s/%s/CONTENTS",
-			portvdb, atom->CATEGORY, atom->PF);
-	if ((fp = fopen(buf, "r")) == NULL) {
-		free(buf);
+	line = tree_pkg_meta_get(pkg, CONTENTS);
+	if (line == NULL)
 		return -1;
-	}
 
 	snprintf(tmpdir, sizeof(tmpdir), "%s/qpkg.XXXXXX", qpkg_bindir);
 	mask = umask(0077);
 	i = mkstemp(tmpdir);
 	umask(mask);
 	if (i == -1) {
-		fclose(fp);
 		free(buf);
 		return -2;
 	}
 	close(i);
 	unlink(tmpdir);
 	if (mkdir(tmpdir, 0750)) {
-		fclose(fp);
 		free(buf);
 		return -3;
 	}
 
 	snprintf(filelist, sizeof(filelist), "%s/filelist", tmpdir);
 	if ((out = fopen(filelist, "w")) == NULL) {
-		fclose(fp);
 		free(buf);
 		return -4;
 	}
 
-	while (getline(&buf, &buflen, fp) != -1) {
+	for (; (line = strtok_r(line, "\n", &savep)) != NULL; line = NULL) {
 		contents_entry *e;
-		e = contents_parse_line(buf);
+		e = contents_parse_line(line);
 		if (!e || e->type == CONTENTS_DIR)
 			continue;
 		if (check_pkg_install_mask(e->name) != 0)
@@ -240,7 +238,6 @@ qpkg_make(depend_atom *atom)
 	}
 
 	fclose(out);
-	fclose(fp);
 
 	printf(" %s-%s %s: ", GREEN, NORM,
 			atom_format("%[CATEGORY]%[PF]", atom));
@@ -271,8 +268,8 @@ qpkg_make(depend_atom *atom)
 	}
 	xpaksize = st.st_size;
 
-	snprintf(buf, buflen, "%s/%s/%s",
-			portvdb, atom->CATEGORY, atom->PF);
+	snprintf(buf, buflen, "%s%s/%s/%s",
+			portroot, portvdb, atom->CATEGORY, atom->PF);
 	xpak_argv[0] = buf;
 	xpak_argv[1] = NULL;
 	xpak_create(AT_FDCWD, tbz2, 1, xpak_argv, 1, verbose);
@@ -333,7 +330,7 @@ qpkg_cb(tree_pkg_ctx *pkg, void *priv)
 {
 	size_t *pkgs_made = priv;
 
-	if (qpkg_make(tree_get_atom(pkg, false)) == 0)
+	if (qpkg_make(pkg) == 0)
 		(*pkgs_made)++;
 
 	return 0;
@@ -395,6 +392,10 @@ int qpkg_main(int argc, char **argv)
 	 * to tar when we create the binary package. */
 	xchdir(portroot);
 
+	ctx = tree_open_vdb(portroot, portvdb);
+	if (!ctx)
+		return EXIT_FAILURE;
+
 	/* first process any arguments which point to /var/db/pkg, an
 	 * undocumented method to allow easily tab-completing into vdb as
 	 * arguments, the trailing / needs to be present for this (as tab
@@ -419,15 +420,7 @@ int qpkg_main(int argc, char **argv)
 
 			if (strncmp(portvdb, path, s) == 0) {
 				path += s + 1 /* also eat / after portvdb */;
-
-				atom = atom_explode(path);
-				if (atom) {
-					if (!qpkg_make(atom))
-						pkgs_made++;
-					atom_implode(atom);
-				} else
-					warn("could not explode '%s'", path);
-				argv[i] = NULL;
+				argv[i] = path;
 			} else {
 				argv[i][asize - 1] = '/';  /* restore, it may be a cat match */
 			}
@@ -435,10 +428,6 @@ int qpkg_main(int argc, char **argv)
 	}
 
 	/* now try to run through vdb and locate matches for user inputs */
-	ctx = tree_open_vdb(portroot, portvdb);
-	if (!ctx)
-		return EXIT_FAILURE;
-
 	for (i = optind; i < argc; ++i) {
 		if (argv[i] == NULL)
 			continue;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-06-27  9:38 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-06-27  9:38 UTC (permalink / raw
  To: gentoo-commits

commit:     f6dd53fa56478d3f9e0b6c1f1ecbd2cfc8529184
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 27 09:37:25 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jun 27 09:37:25 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f6dd53fa

qpkg: fix VDB access method, warn when atoms didn't match anything

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md |  1 +
 qpkg.c  | 53 +++++++++++++++++++++++++++++++++++------------------
 2 files changed, 36 insertions(+), 18 deletions(-)

diff --git a/TODO.md b/TODO.md
index 86a9e84..8188fe1 100644
--- a/TODO.md
+++ b/TODO.md
@@ -64,6 +64,7 @@
   and qpkg is doing parts of qtbz2's compose
 - share install\_mask code from qmerge to handle negatives from
   pkg\_install\_mask too
+- make world agument really read world file, add @all?
 
 # qgrep
 - make it use standard xarray instead of its own buf\_list

diff --git a/qpkg.c b/qpkg.c
index 5e55406..41ac0f5 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -395,7 +395,10 @@ int qpkg_main(int argc, char **argv)
 	 * to tar when we create the binary package. */
 	xchdir(portroot);
 
-	/* first process any arguments which point to /var/db/pkg */
+	/* first process any arguments which point to /var/db/pkg, an
+	 * undocumented method to allow easily tab-completing into vdb as
+	 * arguments, the trailing / needs to be present for this (as tab
+	 * completion would do) */
 	pkgs_made = 0;
 	s = strlen(portvdb);
 	for (i = optind; i < argc; ++i) {
@@ -404,22 +407,31 @@ int qpkg_main(int argc, char **argv)
 			argv[i] = NULL;
 			continue;
 		}
-		if (argv[i][asize-1] == '/')
-			argv[i][asize-1] = '\0';
-		if (!strncmp(portvdb, argv[i], s))
-			memmove(argv[i], argv[i]+s+1, asize-s);
-		else if (argv[i][0] == '/' && !strncmp(portvdb, argv[i]+1, s))
-			memmove(argv[i], argv[i]+s+2, asize-s-1);
-		else
-			continue;
-
-		atom = atom_explode(argv[i]);
-		if (atom) {
-			if (!qpkg_make(atom)) ++pkgs_made;
-			atom_implode(atom);
-		} else
-			warn("could not explode '%s'", argv[i]);
-		argv[i] = NULL;
+		if (asize > s && argv[i][0] == '/' && argv[i][asize - 1] == '/') {
+			char *path = argv[i];
+
+			/* chop off trailing / */
+			argv[i][asize - 1] = '\0';
+
+			/* eliminate duplicate leading /, we know it starts with / */
+			while (path[1] == '/')
+				path++;
+
+			if (strncmp(portvdb, path, s) == 0) {
+				path += s + 1 /* also eat / after portvdb */;
+
+				atom = atom_explode(path);
+				if (atom) {
+					if (!qpkg_make(atom))
+						pkgs_made++;
+					atom_implode(atom);
+				} else
+					warn("could not explode '%s'", path);
+				argv[i] = NULL;
+			} else {
+				argv[i][asize - 1] = '/';  /* restore, it may be a cat match */
+			}
+		}
 	}
 
 	/* now try to run through vdb and locate matches for user inputs */
@@ -431,14 +443,19 @@ int qpkg_main(int argc, char **argv)
 		if (argv[i] == NULL)
 			continue;
 		if (strcmp(argv[i], "world") == 0) {
-			/* we're basically done, this means all */
+			/* this is a crude hack, we include all packages for this,
+			 * which isn't exactly @world, but all its deps too */
 			tree_foreach_pkg_fast(ctx, qpkg_cb, &pkgs_made, NULL);
+			break;  /* no point in continuing since we did everything */
 		}
 		atom = atom_explode(argv[i]);
 		if (atom == NULL)
 			continue;
 
+		s = pkgs_made;
 		tree_foreach_pkg_fast(ctx, qpkg_cb, &pkgs_made, atom);
+		if (s == pkgs_made)
+			warn("no match for '%s'", argv[i]);
 		atom_implode(atom);
 	}
 	tree_close(ctx);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-06-27  9:38 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-06-27  9:38 UTC (permalink / raw
  To: gentoo-commits

commit:     958909e44147a89d77fb1e416f20aaa51148a550
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jun 27 08:59:02 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jun 27 08:59:02 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=958909e4

qpkg: don't fail when pkgdir doesn't exist yet

When we implicitly created pkgdir, also try to chmod it, instead of
failing on permissions later.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 1494b45..5e55406 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -382,14 +382,14 @@ int qpkg_main(int argc, char **argv)
 			(fd != -1 && (fstat(fd, &st) == -1 || !S_ISDIR(st.st_mode))))
 	{
 		errp("could not create temp bindir '%s'", qpkg_bindir);
-	} else {
+	}
+	if (fd >= 0) {
 		/* fd is valid, pointing to a directory */
 		if (!restrict_chmod)
 			if (fchmod(fd, 0750) < 0)
 				errp("could not chmod(0750) temp bindir '%s'", qpkg_bindir);
-	}
-	if (fd >= 0)
 		close(fd);
+	}
 
 	/* we have to change to the root so that we can feed the full paths
 	 * to tar when we create the binary package. */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-25 19:01 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-25 19:01 UTC (permalink / raw
  To: gentoo-commits

commit:     7793cc35e369c2278e99cb618c9df25917fd0b11
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 25 18:53:23 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 25 18:53:23 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7793cc35

travis: install compressors we test

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index 44431cc..f435dc6 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -37,6 +37,11 @@ addons:
     - libgpgme11-dev
     - gnupg2
     - valgrind
+    - liblz4-tool
+    - lzop
+    - zstd
+    - lzip
+    - brotli
   homebrew:
     packages:
     - gpgme


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-25 18:29 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-25 18:29 UTC (permalink / raw
  To: gentoo-commits

commit:     a12931c44302f1bed0dd4ade0a6fa7b0002fe9aa
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 25 18:29:19 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 25 18:29:19 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a12931c4

qmerge: drop unused argument to pkg_verify_checksums

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 7d801b4..80c34a0 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1587,7 +1587,6 @@ static int
 pkg_verify_checksums(
 		char *fname,
 		const struct pkg_t *pkg,
-		const depend_atom *atom,
 		int strict,
 		int display)
 {
@@ -1669,7 +1668,7 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	if (force_download && (access(buf, R_OK) == 0) &&
 			(pkg->SHA1[0] || pkg->MD5[0]))
 	{
-		if (pkg_verify_checksums(buf, pkg, atom, 0, 0) != 0)
+		if (pkg_verify_checksums(buf, pkg, 0, 0) != 0)
 			if (getenv("QMERGE") == NULL)
 				unlink(buf);
 	}
@@ -1678,7 +1677,7 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 			warn("No checksum data for %s (try `emaint binhost --fix`)", buf);
 			return;
 		} else {
-			if (pkg_verify_checksums(buf, pkg, atom, qmerge_strict, !quiet)
+			if (pkg_verify_checksums(buf, pkg, qmerge_strict, !quiet)
 					== 0)
 			{
 				pkg_merge(0, atom, pkg);
@@ -1716,7 +1715,7 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 
 	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2",
 			pkgdir, atom->CATEGORY, pkg->PF);
-	if (pkg_verify_checksums(buf, pkg, atom, qmerge_strict, !quiet) == 0) {
+	if (pkg_verify_checksums(buf, pkg, qmerge_strict, !quiet) == 0) {
 		pkg_merge(0, atom, pkg);
 		return;
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-25 18:25 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-25 18:25 UTC (permalink / raw
  To: gentoo-commits

commit:     c683b6e428600a528aef425518b7c7e9b78158cd
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 25 18:25:38 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 25 18:25:38 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c683b6e4

qmerge: kill whitespace

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index f330a00..7d801b4 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1852,7 +1852,6 @@ grab_binpkg_info(depend_atom *atom)
 			return NULL;
 	}
 
-
 	tpkg = tree_match_atom(tree, atom,
 			TREE_MATCH_FIRST | TREE_MATCH_VIRTUAL | TREE_MATCH_METADATA);
 	if (tpkg != NULL) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-25 18:08 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-25 18:08 UTC (permalink / raw
  To: gentoo-commits

commit:     9644dda59e3604ab831a35bdc5700ba0304a1d9d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 25 18:07:56 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 25 18:07:56 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9644dda5

qmerge: fix package names

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 51fe6de..f330a00 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1599,11 +1599,11 @@ pkg_verify_checksums(
 	if (hash_multiple_file(fname, md5, sha1, NULL, NULL, NULL, NULL,
 			&flen, HASH_MD5 | HASH_SHA1) == -1)
 		errf("failed to compute hashes for %s/%s: %s\n",
-				atom->CATEGORY, pkg->PF, strerror(errno));
+				pkg->CATEGORY, pkg->PF, strerror(errno));
 
 	if (flen != pkg->SIZE) {
 		warn("filesize %zu doesn't match requested size %zu for %s/%s\n",
-				flen, pkg->SIZE, atom->CATEGORY, pkg->PF);
+				flen, pkg->SIZE, pkg->CATEGORY, pkg->PF);
 		ret++;
 	}
 
@@ -1611,11 +1611,11 @@ pkg_verify_checksums(
 		if (strcmp(md5, pkg->MD5) == 0) {
 			if (display)
 				printf("MD5:  [%sOK%s] %s %s/%s\n",
-						GREEN, NORM, md5, atom->CATEGORY, pkg->PF);
+						GREEN, NORM, md5, pkg->CATEGORY, pkg->PF);
 		} else {
 			if (display)
 				warn("MD5:  [%sER%s] (%s) != (%s) %s/%s",
-						RED, NORM, md5, pkg->MD5, atom->CATEGORY, pkg->PF);
+						RED, NORM, md5, pkg->MD5, pkg->CATEGORY, pkg->PF);
 			ret++;
 		}
 	}
@@ -1624,11 +1624,11 @@ pkg_verify_checksums(
 		if (strcmp(sha1, pkg->SHA1) == 0) {
 			if (display)
 				qprintf("SHA1: [%sOK%s] %s %s/%s\n",
-						GREEN, NORM, sha1, atom->CATEGORY, pkg->PF);
+						GREEN, NORM, sha1, pkg->CATEGORY, pkg->PF);
 		} else {
 			if (display)
 				warn("SHA1: [%sER%s] (%s) != (%s) %s/%s",
-						RED, NORM, sha1, pkg->SHA1, atom->CATEGORY, pkg->PF);
+						RED, NORM, sha1, pkg->SHA1, pkg->CATEGORY, pkg->PF);
 			ret++;
 		}
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-25 18:05 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-25 18:05 UTC (permalink / raw
  To: gentoo-commits

commit:     95bb690a18dfae9a405992074f73b0f559a896f8
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 25 18:03:51 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 25 18:03:51 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=95bb690a

qmerge: avoid invalid (double) fclose

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 49c4b5d..51fe6de 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1206,7 +1206,6 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 			{
 				compr = "lzop -dc";
 			}
-			fclose(mfd);
 		}
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-25 11:20 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-25 11:20 UTC (permalink / raw
  To: gentoo-commits

commit:     650ad6f9415e229d3ac8680ca8f8c6c12a3f43c4
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 25 11:17:29 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 25 11:17:29 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=650ad6f9

qmerge: fix Coverity 210533

ensure todo != NULL when attempting to turn into a list

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 554e3dc..49c4b5d 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1975,7 +1975,7 @@ qmerge_run(set *todo)
 	if (uninstall) {
 		return unmerge_packages(todo);
 	} else {
-		if (todo == NULL && search_pkgs) {
+		if (todo == NULL || search_pkgs) {
 			/* disputable, this should be qlist -kIv or something */
 			warn("please use qlist -kI");
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-25 11:12 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-25 11:12 UTC (permalink / raw
  To: gentoo-commits

commit:     354eeb489a936ee4ff02248c5d431aba216b1e37
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 25 11:11:38 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 25 11:11:38 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=354eeb48

README: fix bugzilla auto-url

also, simplify PORTDIR retrieval example
and add qlop -E hint

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 README.md | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 1a08603..60a2fd9 100644
--- a/README.md
+++ b/README.md
@@ -37,8 +37,8 @@ There's also a [HACKING](./HACKING.md) doc to help you get started.
 * find orphan files not owned by any package in /lib and /usr/lib<br>
   `qfile -o {,/usr}/lib/*`
 	
-* get PORTDIR<br>
-  `env DEBUG=: q -Ch 2>&1 | grep ^PORTDIR | awk '{print $3}`
+* get PORTDIR and see where it is defined<br>
+  `q -ev PORTDIR`
 
 * verify all packages<br>
   `qcheck`
@@ -46,12 +46,15 @@ There's also a [HACKING](./HACKING.md) doc to help you get started.
 * check validity of the Manifest files for the main tree<br>
   `qmanifest`
 
+* get an overview of what the last emerge call did<br>
+  `qlop -E`
+
 ## Contact
 
 ### Bugs
 
 Please file bugs at:
-	https://bugs.gentoo.org/enter_bug.cgi?product=Portage%20Development&component=Tools&format=guided
+	https://bugs.gentoo.org/enter_bug.cgi?product=Portage%20Development&component=Unclassified&assigned_to=portage-utils@gentoo.org&format=guided
 
 ### Developers
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-25 10:43 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-25 10:43 UTC (permalink / raw
  To: gentoo-commits

commit:     f2e63b4a1280d0a2c18cb1a66ceffd9699d1b9ac
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 25 10:39:05 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 25 10:39:05 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f2e63b4a

qmerge: use libq/tree for binpkg/Packages needs

Instead of manual parsing of Packages file and traversing binpkgs, use
the functionality provided by libq/tree, most notably tree_match_atom().

This is just phase one, where we replace the custom code with libq/tree
code and then fill in the Pkg structure.  In a next phase we should skip
this and directly use tree_match_ctx, with atom and meta in there.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 596 +++++++++++++--------------------------------------------------
 1 file changed, 116 insertions(+), 480 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 087c5f2..554e3dc 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -120,8 +120,7 @@ typedef struct llist_char_t llist_char;
 static void pkg_fetch(int, const depend_atom *, const struct pkg_t *);
 static void pkg_merge(int, const depend_atom *, const struct pkg_t *);
 static int pkg_unmerge(tree_pkg_ctx *, set *, int, char **, int, char **);
-static struct pkg_t *grab_binpkg_info(const char *);
-static char *find_binpkg(const char *);
+static struct pkg_t *grab_binpkg_info(depend_atom *);
 
 static bool
 prompt(const char *p)
@@ -129,12 +128,12 @@ prompt(const char *p)
 	printf("%s? [Y/n] ", p);
 	fflush(stdout);
 	switch (getc(stdin)) {
-	case '\n':
-	case 'y':
-	case 'Y':
-		return true;
-	default:
-		return false;
+		case '\n':
+		case 'y':
+		case 'Y':
+			return true;
+		default:
+			return false;
 	}
 }
 
@@ -579,7 +578,7 @@ qprint_tree_node(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	} else {
 		depend_atom *subatom = atom_explode(p);
 		if (subatom != NULL) {
-			ret = atom_compare(atom, subatom);
+			ret = atom_compare(subatom, atom);
 			switch (ret) {
 				case EQUAL: c = 'R'; break;
 				case NEWER: c = 'U'; break;
@@ -1009,7 +1008,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		if (((c == 'R') || (c == 'D')) && update_only)
 			return;
 
-	if (pkg->RDEPEND[0] && follow_rdepends) {
+	if (pkg->RDEPEND[0] != '\0' && follow_rdepends) {
 		const char *rdepend;
 
 		IF_DEBUG(fprintf(stderr, "\n+Parent: %s/%s\n", pkg->CATEGORY, pkg->PF));
@@ -1040,30 +1039,17 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 				case '\0':
 					break;
 				default:
-					if (*name == '~') {
-						name = ARGV[i] + 1;
-						/* warn("newname = %s", name); */
-					}
 					if ((subatom = atom_explode(name)) != NULL) {
 						struct pkg_t *subpkg;
-						char *resolved = NULL;
-
-						resolved = find_binpkg(name);
 
-						IF_DEBUG(fprintf(stderr,
-									"+Atom: argv0(%s) resolved(%s)\n",
-									name, resolved));
-
-						if (strlen(resolved) < 1) {
-							warn("Cant find a binpkg for %s from rdepend(%s)",
+						subpkg = grab_binpkg_info(subatom); /* free me later */
+						if (subpkg == NULL) {
+							warn("Cannot find a binpkg for %s from rdepend(%s)",
 									name, pkg->RDEPEND);
 							atom_implode(subatom);
 							continue;
 						}
 
-						/* ratom = atom_explode(resolved); */
-						subpkg = grab_binpkg_info(resolved); /* free me later */
-
 						assert(subpkg != NULL);
 						IF_DEBUG(fprintf(stderr, "+Subpkg: %s/%s\n",
 									subpkg->CATEGORY, subpkg->PF));
@@ -1182,7 +1168,8 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 			} else if (mlen == 257+6 &&
 					magic[257] == 'u' && magic[258] == 's' &&
 					magic[259] == 't' && magic[260] == 'a' &&
-					magic[261] == 'r' && magic[262] == '\0')
+					magic[261] == 'r' &&
+					(magic[262] == '\0' || magic[262] == ' '))
 			{
 				compr = "";
 			} else if (mlen >= 4 &&
@@ -1399,7 +1386,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	rmdir("../qmerge");
 
 	printf("%s>>>%s %s%s%s/%s%s%s\n",
-			YELLOW, NORM, WHITE, atom->CATEGORY, NORM, CYAN, pkg->PF, NORM);
+			YELLOW, NORM, WHITE, pkg->CATEGORY, NORM, CYAN, pkg->PF, NORM);
 
 	tree_close_cat(cat_ctx);
 	tree_close(vdb);
@@ -1622,7 +1609,7 @@ pkg_verify_checksums(
 	}
 
 	if (pkg->MD5[0]) {
-		if (md5 != NULL && strcmp(md5, pkg->MD5) == 0) {
+		if (strcmp(md5, pkg->MD5) == 0) {
 			if (display)
 				printf("MD5:  [%sOK%s] %s %s/%s\n",
 						GREEN, NORM, md5, atom->CATEGORY, pkg->PF);
@@ -1634,7 +1621,7 @@ pkg_verify_checksums(
 		}
 	}
 
-	if (sha1 != NULL && pkg->SHA1[0]) {
+	if (pkg->SHA1[0]) {
 		if (strcmp(sha1, pkg->SHA1) == 0) {
 			if (display)
 				qprintf("SHA1: [%sOK%s] %s %s/%s\n",
@@ -1663,7 +1650,8 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 
 	/* qmerge -pv patch */
 	if (pretend) {
-		if (!install) install++;
+		if (!install)
+			install++;
 		/* qprint_tree_node(level, atom, pkg); */
 		pkg_merge(level, atom, pkg);
 		return;
@@ -1679,13 +1667,12 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		return;
 	}
 
-	/* XXX: should do a size check here for partial downloads */
-
 	if (force_download && (access(buf, R_OK) == 0) &&
 			(pkg->SHA1[0] || pkg->MD5[0]))
 	{
 		if (pkg_verify_checksums(buf, pkg, atom, 0, 0) != 0)
-			unlink(buf);
+			if (getenv("QMERGE") == NULL)
+				unlink(buf);
 	}
 	if (access(buf, R_OK) == 0) {
 		if (!pkg->SHA1[0] && !pkg->MD5[0]) {
@@ -1742,7 +1729,7 @@ print_Pkg(int full, const depend_atom *atom, const struct pkg_t *pkg)
 	char *p = NULL;
 	char buf[512];
 
-	printf("%s%s/%s%s:%s%s%s%s%s\n", BOLD, atom->CATEGORY, BLUE, pkg->PF, pkg->SLOT, NORM,
+	printf("%s%s%s%s\n", atom_format("%[CAT]%[PF]%[SLOT]", atom),
 		!quiet ? " [" : "",
 		!quiet ? make_human_readable_str(pkg->SIZE, 1, KILOBYTE) : "",
 		!quiet ? " KiB]" : "");
@@ -1757,7 +1744,8 @@ print_Pkg(int full, const depend_atom *atom, const struct pkg_t *pkg)
 	if (pkg->MD5[0])
 		printf(" %sMd5%s:%s %s\n", DKGREEN, YELLOW, NORM, pkg->MD5);
 	if (!pkg->MD5[0] && !pkg->SHA1[0])
-		printf(" %sSums%s:%s %s(MISSING!)%s\n", DKGREEN, YELLOW, NORM, RED, NORM);
+		printf(" %sSums%s:%s %s(MISSING!)%s\n",
+				DKGREEN, YELLOW, NORM, RED, NORM);
 	if (pkg->SLOT[0])
 		printf(" %sSlot%s:%s %s\n", DKGREEN, YELLOW, NORM, pkg->SLOT);
 	if (pkg->LICENSE[0])
@@ -1781,7 +1769,8 @@ print_Pkg(int full, const depend_atom *atom, const struct pkg_t *pkg)
 				case OLDER: icolor = BLUE;   break;
 				default:    icolor = NORM;   break;
 			}
-			printf(" %sInstalled%s:%s %s%s%s\n", DKGREEN, YELLOW, NORM, icolor, p, NORM);
+			printf(" %sInstalled%s:%s %s%s%s\n",
+					DKGREEN, YELLOW, NORM, icolor, p, NORM);
 		}
 	}
 }
@@ -1833,453 +1822,70 @@ unmerge_packages(set *todo)
 	return ret;
 }
 
-static FILE *
-open_binpkg_index(void)
-{
-	FILE *fp;
-	char *path;
-
-	xasprintf(&path, "%s/portage/%s", port_tmpdir, Packages);
-	fp = fopen(path, "r");
-	if (fp)
-		goto done;
-	free(path);
-
-	xasprintf(&path, "%s/%s", pkgdir, Packages);
-	fp = fopen(path, "r");
-	if (fp)
-		goto done;
-
-	/* This is normal when installing from local repo only. */
-	warnp("Unable to open package file %s in %s/portage or %s",
-		Packages, port_tmpdir, pkgdir);
-	warn("Attempting to manually regen via `emaint binhost`");
-
-	pid_t p;
-	int status;
-
-	char argv_emaint[] = "emaint";
-	char argv_binhost[] = "binhost";
-	char argv_fix[] = "--fix";
-	char *argv[] = {
-		argv_emaint,
-		argv_binhost,
-		argv_fix,
-		NULL,
-	};
-
-	p = vfork();
-	switch (p) {
-	case 0:
-		_exit(execvp(argv[0], argv));
-	case -1:
-		errp("vfork failed");
-	}
-	waitpid(p, &status, 0);
-
-	fp = fopen(path, "r");
-
- done:
-	free(path);
-	return fp;
-}
-
+static tree_ctx *_grab_binpkg_info_tree = NULL;
 static struct pkg_t *
-grab_binpkg_info(const char *name)
-{
-	FILE *fp;
-	char buf[BUFSIZ];
-	char *p;
-	depend_atom *atom;
-
-	struct pkg_t Pkg;
-	struct pkg_t *pkg = xzalloc(sizeof(struct pkg_t));
-	struct pkg_t *rpkg = xzalloc(sizeof(struct pkg_t));
-
-	static char best_match[sizeof(Pkg.PF)+2+sizeof(Pkg.CATEGORY)];
-
-	best_match[0] = 0;
-	strcpy(pkg->SLOT,"0");
-
-	fp = open_binpkg_index();
-
-	while (fgets(buf, sizeof(buf), fp) != NULL) {
-		if (*buf == '\n') {
-			if (pkg->PF[0] && pkg->CATEGORY[0]) {
-				int ret;
-
-				snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF);
-				if (strstr(buf, name) != NULL) {
-					if (!best_match[0])
-						snprintf(best_match, sizeof(best_match), "%.*s",
-								(int)sizeof(best_match) - 1, buf);
-
-					atom = atom_explode(buf);
-					if (atom->PR_int) {
-						snprintf(buf, sizeof(buf), "%s/%s-%s-r%i",
-								atom->CATEGORY, atom->PN,
-								atom->PV, atom->PR_int);
-					} else {
-						snprintf(buf, sizeof(buf), "%s/%s-%s",
-								atom->CATEGORY, atom->PN, atom->PV);
-					}
-					ret = atom_compare_str(name, buf);
-					IF_DEBUG(fprintf(stderr,
-								"=== atom_compare(%s, %s) = %d %s\n",
-								name, buf, ret, booga[ret]));
-					/* buf(%s) depend(%s)\n", ret, pkg->CATEGORY,
-					 * pkg->PF, name, pkg->RDEPEND); */
-					switch (ret) {
-						case EQUAL:
-						case NEWER:
-							snprintf(buf, sizeof(buf), "%s/%s",
-									pkg->CATEGORY, pkg->PF);
-							ret = atom_compare_str(buf, best_match);
-							if (ret == NEWER || ret == EQUAL) {
-								snprintf(best_match, sizeof(best_match), "%.*s",
-										(int)sizeof(best_match) - 1, buf);
-								memcpy(rpkg, pkg, sizeof(struct pkg_t));
-								IF_DEBUG(fprintf(stderr,
-											"--- %s/%s depend(%s)\n",
-											rpkg->CATEGORY, rpkg->PF,
-											rpkg->RDEPEND));
-							}
-						case OLDER: break;
-						default:
-							break;
-					}
-					atom_implode(atom);
-				}
-				memset(pkg, 0, sizeof(struct pkg_t));
-				strcpy(pkg->SLOT,"0");
-			}
-			continue;
-		}
-
-		if ((p = strchr(buf, '\n')) != NULL)
-			*p = 0;
-		if ((p = strchr(buf, ':')) == NULL)
-			continue;
-		if (p[1] != ' ')
-			continue;
-		*p = 0;
-		p += 2;
-
-		if (*buf) {
-			/* we dont need all the info */
-			if (strcmp(buf, "RDEPEND") == 0)
-				snprintf(pkg->RDEPEND, sizeof(Pkg.RDEPEND), "%.*s",
-						(int)sizeof(Pkg.RDEPEND) - 1, p);
-			if (strcmp(buf, "PF") == 0)
-				snprintf(pkg->PF, sizeof(Pkg.PF), "%.*s",
-						(int)sizeof(Pkg.PF) - 1, p);
-			if (strcmp(buf, "CATEGORY") == 0)
-				snprintf(pkg->CATEGORY, sizeof(Pkg.CATEGORY), "%.*s",
-						(int)sizeof(Pkg.CATEGORY) - 1, p);
-			if (strcmp(buf, "REPO") == 0)
-				snprintf(pkg->REPO, sizeof(Pkg.REPO), "%.*s",
-						(int)sizeof(Pkg.REPO) - 1, p);
-
-			if (strcmp(buf, "CPV") == 0) {
-				if ((atom = atom_explode(p)) != NULL) {
-					if (atom->PR_int) {
-						snprintf(buf, sizeof(buf), "%s-%s-r%i",
-								atom->PN, atom->PV, atom->PR_int);
-					} else {
-						snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
-					}
-					snprintf(pkg->PF, sizeof(Pkg.PF), "%.*s",
-							(int)sizeof(Pkg.PF) - 1, buf);
-					snprintf(pkg->CATEGORY, sizeof(Pkg.CATEGORY), "%.*s",
-							(int)sizeof(Pkg.CATEGORY) - 1, atom->CATEGORY);
-					atom_implode(atom);
-				}
-			}
-			if (strcmp(buf, "SLOT") == 0)
-				snprintf(pkg->SLOT, sizeof(Pkg.SLOT), "%.*s",
-						(int)sizeof(Pkg.SLOT) - 1, p);
-			if (strcmp(buf, "USE") == 0)
-				snprintf(pkg->USE, sizeof(Pkg.USE), "%.*s",
-						(int)sizeof(Pkg.USE) - 1, p);
-			/* checksums. We must have 1 or the other unless --*/
-			if (strcmp(buf, "MD5") == 0)
-				snprintf(pkg->MD5, sizeof(Pkg.MD5), "%.*s",
-						(int)sizeof(Pkg.MD5) - 1, p);
-			if (strcmp(buf, "SHA1") == 0)
-				snprintf(pkg->SHA1, sizeof(Pkg.SHA1), "%.*s",
-						(int)sizeof(Pkg.SHA1) - 1, p);
-		}
-	}
-	fclose(fp);
-	free(pkg);
-	return rpkg;
-}
-
-static char *
-find_binpkg(const char *name)
+grab_binpkg_info(depend_atom *atom)
 {
-	FILE *fp;
-	char buf[BUFSIZ];
-	char *p;
-	struct pkg_t Pkg;
-	char PF[sizeof(Pkg.PF)];
-	char CATEGORY[sizeof(Pkg.CATEGORY)];
-
-	static char best_match[sizeof(Pkg.PF)+2+sizeof(Pkg.CATEGORY)];
-
-	best_match[0] = 0;
-	if (NULL == name)
-		return best_match;
-
-	fp = open_binpkg_index();
-	PF[0] = CATEGORY[0] = '\0';
-
-	while (fgets(buf, sizeof(buf), fp) != NULL) {
-		if (*buf == '\n') {
-			if (PF[0] && CATEGORY[0]) {
-				int ret;
-				snprintf(buf, sizeof(buf), "%s/%s", CATEGORY, PF);
-				if (strstr(buf, name) != NULL) {
-					depend_atom *atom;
-
-					if (!best_match[0])
-						snprintf(best_match, sizeof(best_match), "%.*s",
-								(int)sizeof(best_match) - 1, buf);
-
-					atom = atom_explode(buf);
-					snprintf(buf, sizeof(buf), "%s/%s",
-							atom->CATEGORY, atom->PN);
-					ret = atom_compare_str(name, buf);
-					switch (ret) {
-						case OLDER: break;
-						case NEWER:
-						case EQUAL:
-							snprintf(buf, sizeof(buf), "%s/%s", CATEGORY, PF);
-							ret = atom_compare_str(buf, best_match);
-							if (ret == NEWER || ret == EQUAL)
-								snprintf(best_match, sizeof(best_match), "%.*s",
-										(int)sizeof(best_match) - 1, buf);
-							/* printf("[%s == %s] = %d; %s/%s\n",
-							 * name, buf, ret, CATEGORY, PF); */
-						default:
-							break;
-					}
-					atom_implode(atom);
-				}
-			}
-			continue;
-		}
-
-		if ((p = strchr(buf, '\n')) != NULL)
-			*p = 0;
-		if ((p = strchr(buf, ':')) == NULL)
-			continue;
-		if (p[1] != ' ')
-			continue;
-		*p = 0;
-		p += 2;
-
-		if (*buf) {
-			if (strcmp(buf, "CPV") == 0) {
-				depend_atom *atom;
-				if ((atom = atom_explode(p)) != NULL) {
-					if (atom->PR_int) {
-						snprintf(buf, sizeof(buf), "%s-%s-r%i",
-								atom->PN, atom->PV, atom->PR_int);
-					} else {
-						snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
-					}
-					snprintf(PF, sizeof(PF), "%.*s", (int)sizeof(PF) - 1, buf);
-					snprintf(CATEGORY, sizeof(CATEGORY), "%.*s",
-							(int)sizeof(CATEGORY) - 1, atom->CATEGORY);
-					atom_implode(atom);
-				}
-			}
-			if (strcmp(buf, "PF") == 0)
-				snprintf(PF, sizeof(PF), "%.*s", (int)sizeof(PF) - 1, p);
-			if (strcmp(buf, "CATEGORY") == 0)
-				snprintf(CATEGORY, sizeof(CATEGORY), "%.*s",
-						(int)sizeof(CATEGORY) - 1, p);
-		}
-	}
-	fclose(fp);
-	return best_match;
-}
-
-static int
-parse_packages(set *todo)
-{
-	FILE *fp;
-	int linelen;
-	size_t buflen;
-	char *buf, *p;
-	struct pkg_t Pkg;
-	depend_atom *pkg_atom;
-	char repo[sizeof(Pkg.REPO)];
-	depend_atom **todo_atoms = NULL;
-	size_t todo_cnt = 0;
-	size_t i;
-
-	fp = open_binpkg_index();
-	if (fp == NULL)
-		return EXIT_FAILURE;
-
-	buf = NULL;
-	buflen = 0;  /* make getline allocate */
-	repo[0] = '\0';
-
-	/* First consume the header with the common data. */
-	while ((linelen = getline(&buf, &buflen, fp)) >= 0) {
-		rmspace_len(buf, (size_t)linelen);
-		if (buf[0] == '\0')
-			break;
-
-		if ((p = strchr(buf, ':')) == NULL)
-			continue;
-		if (p[1] != ' ')
-			continue;
-		*p = 0;
-		p += 2;
-
-		switch (*buf) {
-		case 'R':
-			if (!strcmp(buf, "REPO"))
-				snprintf(repo, sizeof(repo), "%.*s", (int)sizeof(repo) - 1, p);
-			break;
+	tree_ctx *tree = _grab_binpkg_info_tree;
+	tree_match_ctx *tpkg;
+	struct pkg_t *pkg = NULL;
+	char path[BUFSIZ];
+	FILE *d;
+
+	/* reuse previously opened tree, so we really employ the cache
+	 * from libq/tree */
+	if (tree == NULL) {
+		snprintf(path, sizeof(path), "%s/portage/Packages", port_tmpdir);
+		/* we don't use ROOT on package tree here, operating on ROOT
+		 * should be for package merges/unmerges, but be able to pull
+		 * binpkgs from current system */
+		if ((d = fopen(path, "r")) != NULL) {
+			fclose(d);
+			snprintf(path, sizeof(path), "%s/portage", port_tmpdir);
+			tree = tree_open_binpkg("/", path);
+		} else {
+			tree = tree_open_binpkg("/", pkgdir);
 		}
-	}
+		_grab_binpkg_info_tree = tree;
 
-	pkg_atom = NULL;
-	memset(&Pkg, 0, sizeof(Pkg));
-	strcpy(Pkg.SLOT, "0");
-
-	/* build list with exploded atoms for each access below */
-	if (todo != NULL) {
-		char **todo_strs;
-		todo_cnt = list_set(todo, &todo_strs);
-		todo_atoms = xmalloc(sizeof(*todo_atoms) * todo_cnt);
-		for (i = 0; i < todo_cnt; i++)
-			todo_atoms[i] = atom_explode(todo_strs[i]);
-		free(todo_strs);
+		/* if opening the tree failed somehow, we can't return anything */
+		if (tree == NULL)
+			return NULL;
 	}
 
-	/* Then walk all the package entries. */
-	while (getline(&buf, &buflen, fp) != -1) {
-		if (*buf == '\n') {
-			if (pkg_atom) {
-				if (search_pkgs && !todo) {
-					print_Pkg(verbose, pkg_atom, &Pkg);
-				} else {
-					for (i = 0; i < todo_cnt; i++) {
-						pkg_atom->REPO = todo_atoms[i]->REPO ? Pkg.REPO : NULL;
-						pkg_atom->SLOT = todo_atoms[i]->SLOT ? Pkg.SLOT : NULL;
-						if (atom_compare(pkg_atom, todo_atoms[i]) == EQUAL) {
-							if (search_pkgs)
-								print_Pkg(verbose, pkg_atom, &Pkg);
-							else
-								pkg_fetch(0, pkg_atom, &Pkg);
-						}
-					}
-				}
 
-				atom_implode(pkg_atom);
-				pkg_atom = NULL;
-			}
-			memset(&Pkg, 0, sizeof(Pkg));
-			strcpy(Pkg.SLOT, "0");
-			strcpy(Pkg.REPO, repo);
-			continue;
-		}
-
-		if ((p = strchr(buf, '\n')) != NULL)
-			*p = 0;
-		if ((p = strchr(buf, ':')) == NULL)
-			continue;
-		if (p[1] != ' ')
-			continue;
-		*p = 0;
-		p += 2;
-
-		switch (*buf) {
-			case 'U':
-				if (strcmp(buf, "USE") == 0)
-					snprintf(Pkg.USE, sizeof(Pkg.USE), "%.*s",
-							(int)sizeof(Pkg.USE) - 1, p);
-				break;
-			case 'P':
-				if (strcmp(buf, "PF") == 0)
-					snprintf(Pkg.PF, sizeof(Pkg.PF), "%.*s",
-							(int)sizeof(Pkg.PF) - 1, p);
-				break;
-			case 'S':
-				if (strcmp(buf, "SIZE") == 0)
-					Pkg.SIZE = atol(p);
-				if (strcmp(buf, "SLOT") == 0)
-					snprintf(Pkg.SLOT, sizeof(Pkg.SLOT), "%.*s",
-							(int)sizeof(Pkg.SLOT) - 1, p);
-				if (strcmp(buf, "SHA1") == 0)
-					snprintf(Pkg.SHA1, sizeof(Pkg.SHA1), "%.*s",
-							(int)sizeof(Pkg.SHA1) - 1, p);
-				break;
-			case 'M':
-				if (strcmp(buf, "MD5") == 0)
-					snprintf(Pkg.MD5, sizeof(Pkg.MD5), "%.*s",
-							(int)sizeof(Pkg.MD5) - 1, p);
-				break;
-			case 'R':
-				if (strcmp(buf, "REPO") == 0)
-					snprintf(Pkg.REPO, sizeof(Pkg.REPO), "%.*s",
-							(int)sizeof(Pkg.REPO) - 1, p);
-				if (strcmp(buf, "RDEPEND") == 0)
-					snprintf(Pkg.RDEPEND, sizeof(Pkg.RDEPEND), "%.*s",
-							(int)sizeof(Pkg.RDEPEND) - 1, p);
-				break;
-			case 'L':
-				if (strcmp(buf, "LICENSE") == 0)
-					snprintf(Pkg.LICENSE, sizeof(Pkg.LICENSE), "%.*s",
-							(int)sizeof(Pkg.LICENSE) - 1, p);
-				break;
-			case 'C':
-				if (strcmp(buf, "CATEGORY") == 0)
-					snprintf(Pkg.CATEGORY, sizeof(Pkg.CATEGORY), "%.*s",
-							(int)sizeof(Pkg.CATEGORY) - 1, p);
-				if (strcmp(buf, "CPV") == 0) {
-					if (pkg_atom != NULL)  /* hypothetical Coverity case */
-						atom_implode(pkg_atom);
-					if ((pkg_atom = atom_explode(p)) != NULL) {
-						if (pkg_atom->PR_int)
-							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s-r%i",
-									pkg_atom->PN, pkg_atom->PV,
-									pkg_atom->PR_int);
-						else
-							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s",
-									pkg_atom->PN, pkg_atom->PV);
-						snprintf(Pkg.CATEGORY, sizeof(Pkg.CATEGORY),
-								"%.*s", (int)sizeof(Pkg.CATEGORY) - 1,
-								pkg_atom->CATEGORY);
-					}
-				}
-				break;
-			case 'D':
-				if (strcmp(buf, "DESC") == 0)
-					snprintf(Pkg.DESC, sizeof(Pkg.DESC), "%.*s",
-							(int)sizeof(Pkg.DESC) - 1, p);
-				break;
-			default:
-				break;
-		}
+	tpkg = tree_match_atom(tree, atom,
+			TREE_MATCH_FIRST | TREE_MATCH_VIRTUAL | TREE_MATCH_METADATA);
+	if (tpkg != NULL) {
+		depend_atom *tatom = tpkg->atom;
+		tree_pkg_meta *meta = tpkg->meta;
+		pkg = xzalloc(sizeof(struct pkg_t));
+
+		snprintf(pkg->PF, sizeof(pkg->PF), "%s", tatom->PF);
+		snprintf(pkg->CATEGORY, sizeof(pkg->CATEGORY), "%s", tatom->CATEGORY);
+		if (meta->Q_DESCRIPTION != NULL)
+			snprintf(pkg->DESC, sizeof(pkg->DESC), "%s", meta->Q_DESCRIPTION);
+		if (meta->Q_LICENSE != NULL)
+			snprintf(pkg->LICENSE, sizeof(pkg->LICENSE), "%s", meta->Q_LICENSE);
+		if (meta->Q_RDEPEND != NULL)
+			snprintf(pkg->RDEPEND, sizeof(pkg->RDEPEND), "%s", meta->Q_RDEPEND);
+		if (meta->Q_MD5 != NULL)
+			snprintf(pkg->MD5, sizeof(pkg->MD5), "%s", meta->Q_MD5);
+		if (meta->Q_SHA1 != NULL)
+			snprintf(pkg->SHA1, sizeof(pkg->SHA1), "%s", meta->Q_SHA1);
+		if (meta->Q_USE != NULL)
+			snprintf(pkg->USE, sizeof(pkg->USE), "%s", meta->Q_USE);
+		if (meta->Q_repository != NULL)
+			snprintf(pkg->REPO, sizeof(pkg->REPO), "%s", meta->Q_repository);
+		if (meta->Q_SLOT != NULL)
+			snprintf(pkg->REPO, sizeof(pkg->REPO), "%s", meta->Q_SLOT);
+		if (meta->Q_SIZE != NULL)
+			pkg->SIZE = atoi(meta->Q_SIZE);
+
+		tree_match_close(tpkg);
 	}
 
-	free(buf);
-	fclose(fp);
-	if (pkg_atom)
-		atom_implode(pkg_atom);
-
-	for (i = 0; i < todo_cnt; i++)
-		atom_implode(todo_atoms[i]);
-	free(todo_atoms);
-
-	return EXIT_SUCCESS;
+	return pkg;
 }
 
 static set *
@@ -2366,10 +1972,40 @@ qmerge_add_set(char *buf, set *q)
 static int
 qmerge_run(set *todo)
 {
-	if (uninstall)
+	if (uninstall) {
 		return unmerge_packages(todo);
-	else
-		return parse_packages(todo);
+	} else {
+		if (todo == NULL && search_pkgs) {
+			/* disputable, this should be qlist -kIv or something */
+			warn("please use qlist -kI");
+
+			return EXIT_SUCCESS;
+		} else {
+			char **todo_strs;
+			size_t todo_cnt = list_set(todo, &todo_strs);
+			size_t i;
+			depend_atom *atom;
+			struct pkg_t *pkg;
+			int ret = EXIT_FAILURE;
+
+			for (i = 0; i < todo_cnt; i++) {
+				atom = atom_explode(todo_strs[i]);
+				pkg = grab_binpkg_info(atom);
+				if (pkg != NULL) {
+					if (search_pkgs)
+						print_Pkg(verbose, atom, pkg);
+					else
+						pkg_fetch(0, atom, pkg);
+					free(pkg);
+					ret = EXIT_SUCCESS;
+				}
+				atom_implode(atom);
+			}
+			free(todo_strs);
+
+			return ret;
+		}
+	}
 }
 
 int qmerge_main(int argc, char **argv)
@@ -2437,10 +2073,10 @@ int qmerge_main(int argc, char **argv)
 
 		if (uninstall) {
 			if (!prompt("OK to unmerge these packages"))
-				return 0;
+				return EXIT_FAILURE;
 		} else {
 			if (!prompt("OK to merge these packages"))
-				return 0;
+				return EXIT_FAILURE;
 		}
 
 		pretend = save_pretend;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-25 10:43 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-25 10:43 UTC (permalink / raw
  To: gentoo-commits

commit:     53cf6891705c4b953074b5f4bc94b0d53ad9422a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 25 10:37:13 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 25 10:37:13 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=53cf6891

qatom: adjust to changed tree_match_atom interface

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qatom.c | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)

diff --git a/qatom.c b/qatom.c
index 1c1c50e..a076c49 100644
--- a/qatom.c
+++ b/qatom.c
@@ -122,12 +122,18 @@ int qatom_main(int argc, char **argv)
 			break;
 		case _LOOKUP:
 			{
-				tree_pkg_ctx *pkg = tree_match_atom(tree, atom);
+				tree_match_ctx *pkg = tree_match_atom(tree, atom,
+						TREE_MATCH_DEFAULT);
 				if (pkg != NULL) {
-					atomc = tree_get_atom(pkg, true);
-					if (!quiet)
-						printf("%s: ", atom_to_string(atom));
-					printf("%s\n", atom_format(format, atomc));
+					tree_match_ctx *w;
+
+					for (w = pkg; w != NULL; w = w->next) {
+						if (!quiet)
+							printf("%s: ", atom_to_string(atom));
+						printf("%s\n", atom_format(format, w->atom));
+					}
+
+					tree_match_close(pkg);
 				}
 			}
 		}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-21 11:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-21 11:13 UTC (permalink / raw
  To: gentoo-commits

commit:     9935434aa78f4458f45fe2daf9292a3534cb370c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May 21 11:12:54 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May 21 11:12:54 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9935434a

qlop: fix inversed logic

introduced in 20844dc943700cca72bbb6896f42adcd30de41e3, the intention
was to suppress the warning, not raise it.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qlop.c b/qlop.c
index d5ace83..5048b1e 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1457,7 +1457,7 @@ int qlop_main(int argc, char **argv)
 
 	/* handle -l / -d conflict */
 	if (start_time != 0 && m.show_lastmerge) {
-		if (m.show_emerge)
+		if (!m.show_emerge)
 			warn("-l and -d cannot be used together, dropping -l");
 		m.show_lastmerge = 0;
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-17 12:35 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-17 12:35 UTC (permalink / raw
  To: gentoo-commits

commit:     501cba59e415cf47a00b99ce5d7c4daf0c386264
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 10:05:50 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May 17 10:05:50 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=501cba59

qxpak: reflect changed return value from xpak_process

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qxpak.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qxpak.c b/qxpak.c
index 272a8e1..92c0dda 100644
--- a/qxpak.c
+++ b/qxpak.c
@@ -154,8 +154,9 @@ int qxpak_main(int argc, char **argv)
 		ret = xpak_create(cbctx.dir_fd, xpak, argc, argv, 0, verbose);
 		break;
 	default:
-		ret = EXIT_FAILURE;
+		ret = -1;
 	}
+	ret = ret < 0 ? EXIT_FAILURE : 0;
 
 	if (cbctx.dir_fd != AT_FDCWD)
 		close(cbctx.dir_fd);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-17 12:35 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-17 12:35 UTC (permalink / raw
  To: gentoo-commits

commit:     89e8e0b1285739ca70922afab048c803f125df30
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 12:02:06 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May 17 12:02:06 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=89e8e0b1

qtbz2: drop warning about archive not being bz2 compressed

Since we support many compression formats, and Portage is switching to
zstd compression by default, it makes no sense to warn about the
compression format used.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qtbz2.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/qtbz2.c b/qtbz2.c
index a02b477..7cc0b37 100644
--- a/qtbz2.c
+++ b/qtbz2.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-2010 Ned Ludd        - <solar@gentoo.org>
@@ -83,8 +83,6 @@ tbz2_compose(int dir_fd, const char *tarbz2, const char *xpak, const char *tbz2)
 		fclose(out);
 		return ret;
 	}
-	if (pread(fd, buf, 3, 0) != 3 || memcmp(buf, "BZh", 3))
-			warn("%s: does not appear to be a .tar.bz2", tarbz2);
 	in_tarbz2 = fdopen(fd, "r");
 	if (in_tarbz2 == NULL) {
 		fclose(out);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-17 12:35 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-17 12:35 UTC (permalink / raw
  To: gentoo-commits

commit:     65ffc8ca7cb62140e281ce80918d19e9cc64a43e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 12:34:16 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May 17 12:34:16 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=65ffc8ca

qmerge: calculate MD5/SHA1 hashes possibly in parallel

take advantage of libq/hash's interface to parallelise hash computation
if possible

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 45 +++++++++++++++++++++++++++++++--------------
 1 file changed, 31 insertions(+), 14 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index e86ce00..087c5f2 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1598,34 +1598,51 @@ unlink_empty(const char *buf)
 }
 
 static int
-pkg_verify_checksums(char *fname, const struct pkg_t *pkg, const depend_atom *atom,
-                     int strict, int display)
+pkg_verify_checksums(
+		char *fname,
+		const struct pkg_t *pkg,
+		const depend_atom *atom,
+		int strict,
+		int display)
 {
-	char *hash = NULL;
 	int ret = 0;
+	char md5[32+1];
+	char sha1[40+1];
+	size_t flen;
+
+	if (hash_multiple_file(fname, md5, sha1, NULL, NULL, NULL, NULL,
+			&flen, HASH_MD5 | HASH_SHA1) == -1)
+		errf("failed to compute hashes for %s/%s: %s\n",
+				atom->CATEGORY, pkg->PF, strerror(errno));
+
+	if (flen != pkg->SIZE) {
+		warn("filesize %zu doesn't match requested size %zu for %s/%s\n",
+				flen, pkg->SIZE, atom->CATEGORY, pkg->PF);
+		ret++;
+	}
 
 	if (pkg->MD5[0]) {
-		if ((hash = hash_file(fname, HASH_MD5)) == NULL) {
-			errf("hash is NULL for %s", fname);
-		}
-		if (strcmp(hash, pkg->MD5) == 0) {
+		if (md5 != NULL && strcmp(md5, pkg->MD5) == 0) {
 			if (display)
-				printf("MD5:  [%sOK%s] %s %s/%s\n", GREEN, NORM, hash, atom->CATEGORY, pkg->PF);
+				printf("MD5:  [%sOK%s] %s %s/%s\n",
+						GREEN, NORM, md5, atom->CATEGORY, pkg->PF);
 		} else {
 			if (display)
-				warn("MD5:  [%sER%s] (%s) != (%s) %s/%s", RED, NORM, hash, pkg->MD5, atom->CATEGORY, pkg->PF);
+				warn("MD5:  [%sER%s] (%s) != (%s) %s/%s",
+						RED, NORM, md5, pkg->MD5, atom->CATEGORY, pkg->PF);
 			ret++;
 		}
 	}
 
-	if (pkg->SHA1[0]) {
-		hash = hash_file(fname, HASH_SHA1);
-		if (strcmp(hash, pkg->SHA1) == 0) {
+	if (sha1 != NULL && pkg->SHA1[0]) {
+		if (strcmp(sha1, pkg->SHA1) == 0) {
 			if (display)
-				qprintf("SHA1: [%sOK%s] %s %s/%s\n", GREEN, NORM, hash, atom->CATEGORY, pkg->PF);
+				qprintf("SHA1: [%sOK%s] %s %s/%s\n",
+						GREEN, NORM, sha1, atom->CATEGORY, pkg->PF);
 		} else {
 			if (display)
-				warn("SHA1: [%sER%s] (%s) != (%s) %s/%s", RED, NORM, hash, pkg->SHA1, atom->CATEGORY, pkg->PF);
+				warn("SHA1: [%sER%s] (%s) != (%s) %s/%s",
+						RED, NORM, sha1, pkg->SHA1, atom->CATEGORY, pkg->PF);
 			ret++;
 		}
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-17 12:35 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-17 12:35 UTC (permalink / raw
  To: gentoo-commits

commit:     7171479f13f69e119feda1a0cd9b71d07aa7069c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 10:06:33 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May 17 10:06:33 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7171479f

qmerge: unpack tbz2 file without splitting it first

To save space, and also gain speed, unpack the archive and xpak contents
directly off of the tbz2 file.  This prevents us from having to shell
out to qxpak and to simply spool the relevant part of the tbz2 file to
the decompressor/tar.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 134 ++++++++++++++++++++++++++++-----------------------------------
 1 file changed, 59 insertions(+), 75 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 103f615..e86ce00 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -34,6 +34,7 @@
 #include "xasprintf.h"
 #include "xchdir.h"
 #include "xmkdir.h"
+#include "xpak.h"
 #include "xsystem.h"
 
 #ifndef GLOB_BRACE
@@ -137,46 +138,6 @@ prompt(const char *p)
 	}
 }
 
-static int run_applet_l(const char *arg, ...)
-{
-	int (*applet)(int, char **);
-	va_list ap;
-	int ret, optind_saved, argc;
-	char **argv;
-	const char *argv0_saved;
-
-	optind_saved = optind;
-	argv0_saved = argv0;
-
-	applet = lookup_applet(arg);
-	if (!applet)
-		return -1;
-
-	/* This doesn't NULL terminate argv, but you should be using argc */
-	va_start(ap, arg);
-	argc = 0;
-	argv = NULL;
-	while (arg) {
-		argv = xrealloc(argv, sizeof(*argv) * ++argc);
-		argv[argc - 1] = xstrdup(arg);
-		arg = va_arg(ap, const char *);
-	}
-	va_end(ap);
-
-	optind = 0;
-	argv0 = argv[0];
-	ret = applet(argc, argv);
-
-	while (argc--)
-		free(argv[argc]);
-	free(argv);
-
-	optind = optind_saved;
-	argv0 = argv0_saved;
-
-	return ret;
-}
-
 static void
 fetch(const char *destdir, const char *src)
 {
@@ -980,6 +941,32 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 	return ret;
 }
 
+static void
+pkg_extract_xpak_cb(
+	void *ctx,
+	char *pathname,
+	int pathname_len,
+	int data_offset,
+	int data_len,
+	char *data)
+{
+	FILE *out;
+	int *destdirfd = (int *)ctx;
+	(void)pathname_len;
+
+	int fd = openat(*destdirfd, pathname,
+			O_WRONLY | O_CLOEXEC | O_CREAT | O_TRUNC, 0644);
+	if (fd < 0)
+		return;
+	out = fdopen(fd, "w");
+	if (!out)
+		return;
+
+	fwrite(data + data_offset, 1, data_len, out);
+
+	fclose(out);
+}
+
 /* oh shit getting into pkg mgt here. FIXME: write a real dep resolver. */
 static void
 pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
@@ -1006,6 +993,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	int cpm_argc;
 	char **cp_argv;
 	char **cpm_argv;
+	int tbz2size;
 
 	if (!install || !pkg || !atom)
 		return;
@@ -1142,24 +1130,23 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	mkdir("temp", 0755);
 	mkdir_p(portroot, 0755);
 
-	/* XXX: maybe some day we should have this step operate on the
-	 *      tarball directly rather than unpacking it first. */
-
-	/* split the tbz and xpak data */
 	xasprintf(&tbz2, "%s/%s/%s.tbz2", pkgdir, pkg->CATEGORY, pkg->PF);
-	if (run_applet_l("qtbz2", "-s", tbz2, NULL) != 0)
-		err("`qtbz2 -s %s` failed", tbz2);
+	tbz2size = 0;
 
 	mkdir("vdb", 0755);
-	sprintf(tbz2, "%s.xpak", pkg->PF);
-	if (run_applet_l("qxpak", "-d", "vdb", "-x", tbz2, NULL) != 0)
-		err("`qxpak -d vdb -x %s` failed", tbz2);
+	{
+		int vdbfd = open("vdb", O_RDONLY);
+		if (vdbfd == -1)
+			err("failed to open vdb extraction directory");
+		tbz2size = xpak_extract(tbz2, &vdbfd, pkg_extract_xpak_cb);
+	}
+	if (tbz2size <= 0)
+		err("%s appears not to be a valid tbz2 file", tbz2);
 
 	/* figure out if the data is compressed differently from what the
 	 * name suggests, bug #660508, usage of BINPKG_COMPRESS,
 	 * due to the minimal nature of where we run, we cannot rely on file
 	 * or GNU tar, so have to do some laymans MAGIC hunting ourselves */
-	compr = "I brotli"; /* default: brotli; has no magic header */
 	{
 		/* bz2: 3-byte: 'B' 'Z' 'h'              at byte 0
 		 * gz:  2-byte:  1f  8b                  at byte 0
@@ -1173,7 +1160,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		unsigned char magic[257+6];
 		FILE *mfd;
 
-		sprintf(tbz2, "%s.tar.bz2", pkg->PF);
+		compr = "brotli -dc"; /* default: brotli; has no magic header */
 		mfd = fopen(tbz2, "r");
 		if (mfd != NULL) {
 			size_t mlen = fread(magic, 1, sizeof(magic), mfd);
@@ -1182,16 +1169,16 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 			if (mlen >= 3 && magic[0] == 'B' && magic[1] == 'Z' &&
 					magic[2] == 'h')
 			{
-				compr = "j";
+				compr = "bzip2 -dc";
 			} else if (mlen >= 2 &&
 					magic[0] == 037 && magic[1] == 0213)
 			{
-				compr = "z";
+				compr = "gzip -dc";
 			} else if (mlen >= 5 &&
 					magic[1] == '7' && magic[2] == 'z' &&
 					magic[3] == 'X' && magic[4] == 'Z')
 			{
-				compr = "J";
+				compr = "xz -dc";
 			} else if (mlen == 257+6 &&
 					magic[257] == 'u' && magic[258] == 's' &&
 					magic[259] == 't' && magic[260] == 'a' &&
@@ -1202,7 +1189,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 					magic[0] == 0x04 && magic[1] == 0x22 &&
 					magic[2] == 0x4D && magic[3] == 0x18)
 			{
-				compr = "I lz4";
+				compr = "lz4 -dc";
 			} else if (mlen >= 4 &&
 					magic[0] >= 0x22 && magic[0] <= 0x28 &&
 					magic[1] == 0xB5 && magic[2] == 0x2F &&
@@ -1214,7 +1201,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 				 * that not more memory is allocated than what is really
 				 * needed to decompress the file. See
 				 * https://bugs.gentoo.org/show_bug.cgi?id=634980 */
-				compr = "I zstd --long=31";
+				compr = "zstd --long=31 -dc";
 				/* If really tar -I would be used we would have to quote:
 				 * compr = "I \"zstd --long=31\"";
 				 * But actually we use a pipe (see below) */
@@ -1222,7 +1209,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 					magic[0] == 'L' && magic[1] == 'Z' &&
 					magic[2] == 'I' && magic[3] == 'P')
 			{
-				compr = "I lzip";
+				compr = "lzip -dc";
 			} else if (mlen >= 9 &&
 					magic[0] == 0x89 && magic[1] == 'L' &&
 					magic[2] == 'Z' && magic[3] == 'O' &&
@@ -1230,30 +1217,27 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 					magic[6] == 0x0A && magic[7] == 0x1A &&
 					magic[8] == 0x0A)
 			{
-				compr = "I lzop";
+				compr = "lzop -dc";
 			}
+			fclose(mfd);
 		}
 	}
 
-	free(tbz2);
-
 	/* extract the binary package data */
 	mkdir("image", 0755);
-	if (compr[0] != 'I') {
-		snprintf(buf, sizeof(buf),
-			BUSYBOX " tar -x%s%s -f %s.tar.bz2 -C image/",
-			((verbose > 1) ? "v" : ""), compr, pkg->PF);
-	} else {
-		/* busybox's tar has no -I option. Thus, although we possibly
-		 * use busybox's shell and tar, we thus pipe, expecting the
-		 * corresponding (de)compression tool to be in PATH; if not,
-		 * a failure will occur.
-		 * Since some tools (e.g. zstd) complain about the .bz2
-		 * extension, we feed the tool by input redirection. */
-		snprintf(buf, sizeof(buf),
-			BUSYBOX " sh -c '%s -dc <%s.tar.bz2 | tar -x%sf - -C image/'",
-			compr + 2, pkg->PF, ((verbose > 1) ? "v" : ""));
-	}
+	/* busybox's tar has no -I option. Thus, although we possibly
+	 * use busybox's shell and tar, we thus pipe, expecting the
+	 * corresponding (de)compression tool to be in PATH; if not,
+	 * a failure will occur.
+	 * Since some tools (e.g. zstd) complain about the .bz2
+	 * extension, we feed the tool by input redirection. */
+	snprintf(buf, sizeof(buf),
+		BUSYBOX " sh -c 'dd status=none if=%s bs=1 count=%d %s%s | "
+		"tar -x%sf - -C image/'",
+		tbz2, tbz2size, compr[0] == '\0' ? "" : "| ", compr,
+		((verbose > 1) ? "v" : ""));
+
+	free(tbz2);
 	xsystem(buf);
 	fflush(stdout);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-17  8:27 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-17  8:27 UTC (permalink / raw
  To: gentoo-commits

commit:     d67ae6ccc650f378b43582e8d43ad276cf5b3dc7
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 08:25:15 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May 17 08:27:10 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d67ae6cc

travis: address build config validation issues

root: deprecated key sudo (The key `sudo` has no effect anymore.)
root: missing dist, using the default xenial
root: missing os, using the default linux
root: key matrix is an alias for jobs, using jobs

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index b32c12f..f0c180c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,26 +2,20 @@
 # https://docs.travis-ci.com/
 
 language: c
-sudo: false
+dist: bionic
+os: linux
 
-matrix:
+jobs:
   include:
     - compiler: gcc
-      os: linux
-      dist: bionic
     - compiler: clang
-      os: linux
-      dist: bionic
     - compiler: coverity
-      os: linux
-      dist: bionic
       env:
         - COVERITY_SCAN_PROJECT_NAME="$TRAVIS_REPO_SLUG"
         - COVERITY_SCAN_BRANCH_PATTERN="master"
         - COVERITY_SCAN_NOTIFICATION_EMAIL="grobian@gentoo.org"
         - COVERITY_SCAN_BUILD_COMMAND="make"
     - compiler: valgrind
-      os: linux
       dist: xenial
       env:
         - CFLAGS="-g"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-17  8:27 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-17  8:27 UTC (permalink / raw
  To: gentoo-commits

commit:     33ba7463d53df75ab790a3b907f25de0bd1a48cb
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 08:17:56 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May 17 08:26:58 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=33ba7463

travis: try default/stable ubuntu for valgrind run

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 8d73619..b32c12f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -22,7 +22,7 @@ matrix:
         - COVERITY_SCAN_BUILD_COMMAND="make"
     - compiler: valgrind
       os: linux
-      dist: bionic
+      dist: xenial
       env:
         - CFLAGS="-g"
         - Q_RUN_WITH_VALGRIND=1


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-17  8:15 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-17  8:15 UTC (permalink / raw
  To: gentoo-commits

commit:     2f5a42a9d667ac3625be33ae90faf650d4f51912
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May 17 08:14:00 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May 17 08:14:00 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2f5a42a9

main: replace another instance of strlen with sizoef() - 1

As pointed out by Guillermo D. H. there was another instance of strlen
used on a constant.

Bug: https://bugs.gentoo.org/723422
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index aa7eae2..d2a452c 100644
--- a/main.c
+++ b/main.c
@@ -594,7 +594,7 @@ env_vars vars_to_read[] = {
 #define _Q_EV(t, V, set, lset, d) \
 { \
 	.name = #V, \
-	.name_len = strlen(#V), \
+	.name_len = sizeof(#V) - 1, \
 	.type = _Q_##t, \
 	set, \
 	lset, \
@@ -626,6 +626,8 @@ env_vars vars_to_read[] = {
 	{ NULL, 0, _Q_BOOL, { NULL }, 0, NULL, NULL, }
 
 #undef _Q_EV
+#undef _Q_EVS
+#undef _Q_EVB
 };
 set *package_masks = NULL;
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-16 18:51 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-16 18:51 UTC (permalink / raw
  To: gentoo-commits

commit:     b71b21d13405857d95cff02551558fed0c4d356e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May 16 18:50:19 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May 16 18:50:19 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b71b21d1

main: use sizeof iso strlen to enforce compile-time constants

Bug: https://bugs.gentoo.org/723422
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c
index 76a6ffb..aa7eae2 100644
--- a/main.c
+++ b/main.c
@@ -601,8 +601,10 @@ env_vars vars_to_read[] = {
 	.default_value = d, \
 	.src = NULL, \
 },
-#define _Q_EVS(t, V, v, d) _Q_EV(t, V, .value.s = &v, .value_len = strlen(d), d)
-#define _Q_EVB(t, V, v, d) _Q_EV(t, V, .value.b = &v, .value_len = 0, d)
+#define _Q_EVS(t, V, v, d) \
+	_Q_EV(t, V, .value.s = &v, .value_len = sizeof(d) - 1, d)
+#define _Q_EVB(t, V, v, d) \
+	_Q_EV(t, V, .value.b = &v, .value_len = 0, d)
 
 	_Q_EVS(STR,  ROOT,                portroot,            "/")
 	_Q_EVS(STR,  ACCEPT_LICENSE,      accept_license,      "")


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-16 14:30 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-16 14:30 UTC (permalink / raw
  To: gentoo-commits

commit:     36a1c566e177e8af5d05b5406b8834d299652173
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May 16 14:18:39 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May 16 14:18:39 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=36a1c566

quse: Coverity rightly pointed out state->match may be NULL

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 quse.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/quse.c b/quse.c
index 1e39ce0..5105638 100644
--- a/quse.c
+++ b/quse.c
@@ -141,7 +141,8 @@ quse_search_use_local_desc(int portdirfd, struct quse_state *state)
 				continue;
 
 			atom->REPO = (char *)state->repo;
-			atom->SLOT = state->match->SLOT;  /* fake match */
+			if (state->match != NULL)
+				atom->SLOT = state->match->SLOT;  /* fake match */
 			if (state->match == NULL ||
 					atom_compare(atom, state->match) == EQUAL)
 			{


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-16 13:06 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-16 13:06 UTC (permalink / raw
  To: gentoo-commits

commit:     27b795f79cec4d2a86f94df8c650e9d3a1b84755
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May 16 12:07:17 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May 16 12:07:17 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=27b795f7

quse: make -R flag work with -D

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 quse.c | 26 +++++++++++++++++++++-----
 1 file changed, 21 insertions(+), 5 deletions(-)

diff --git a/quse.c b/quse.c
index 2db628d..bcbb620 100644
--- a/quse.c
+++ b/quse.c
@@ -57,6 +57,7 @@ struct quse_state {
 	char **argv;
 	char **retv;
 	const char *overlay;
+	const char *repo;
 	bool do_all:1;
 	bool do_regex:1;
 	bool do_describe:1;
@@ -139,6 +140,7 @@ quse_search_use_local_desc(int portdirfd, struct quse_state *state)
 			if ((atom = atom_explode(buf)) == NULL)
 				continue;
 
+			atom->REPO = (char *)state->repo;
 			if (state->match == NULL ||
 					atom_compare(atom, state->match) == EQUAL)
 			{
@@ -228,8 +230,10 @@ quse_search_use_desc(int portdirfd, struct quse_state *state)
 			if (state->do_list) {
 				state->retv[i] = xstrdup(p);
 			} else {
-				printf("%sglobal%s[%s%s%s] %s\n",
-						BOLD, NORM, MAGENTA, buf, NORM, p);
+				printf("%sglobal%s%s%s%s[%s%s%s] %s\n",
+						BOLD, NORM,
+						GREEN, state->repo == NULL ? "" : state->repo, NORM,
+						MAGENTA, buf, NORM, p);
 			}
 
 			ret = true;
@@ -366,8 +370,10 @@ quse_search_profiles_desc(
 						*s++ = (char)toupper((int)*r);
 					} while (++r < (de->d_name + namelen));
 					*s = '\0';
-					printf("%s%s%s[%s%s%s] %s\n",
-							BOLD, ubuf, NORM, MAGENTA, buf, NORM, p);
+					printf("%s%s%s%s%s%s[%s%s%s] %s\n",
+							BOLD, ubuf, NORM,
+							GREEN, state->repo == NULL ? "" : state->repo, NORM,
+							MAGENTA, buf, NORM, p);
 				}
 
 				ret = true;
@@ -710,12 +716,21 @@ int quse_main(int argc, char **argv)
 	}
 
 	if (state.do_describe && state.match == NULL) {
-		array_for_each(overlays, n, overlay)
+		array_for_each(overlays, n, overlay) {
+			tree_ctx *t = NULL;
+			if (state.need_full_atom)
+				t = tree_open(portroot, overlay);  /* used for repo */
+			if (t != NULL)
+				state.repo = t->repo;
 			quse_describe_flag(portroot, overlay, &state);
+			if (t != NULL)
+				tree_close(t);
+		}
 	} else if (state.do_installed) {
 		tree_ctx *t = tree_open_vdb(portroot, portvdb);
 		if (t != NULL) {
 			state.overlay = NULL;
+			state.repo = NULL;
 			tree_foreach_pkg_sorted(t, quse_results_cb, &state, state.match);
 			tree_close(t);
 		}
@@ -724,6 +739,7 @@ int quse_main(int argc, char **argv)
 			tree_ctx *t = tree_open(portroot, overlay);
 			state.overlay = overlay;
 			if (t != NULL) {
+				state.repo = state.need_full_atom ? t->repo : NULL;
 				tree_foreach_pkg_sorted(t, quse_results_cb,
 						&state, state.match);
 				tree_close(t);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-16 13:06 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-16 13:06 UTC (permalink / raw
  To: gentoo-commits

commit:     8b113397cda725a0d94782811913a1a03f5e6d46
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May 16 13:04:04 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May 16 13:04:04 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8b113397

quse: fix interaction of -R with -D

ensure descriptions can be retrieved when -R is in effect

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 quse.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/quse.c b/quse.c
index bcbb620..1e39ce0 100644
--- a/quse.c
+++ b/quse.c
@@ -141,12 +141,14 @@ quse_search_use_local_desc(int portdirfd, struct quse_state *state)
 				continue;
 
 			atom->REPO = (char *)state->repo;
+			atom->SLOT = state->match->SLOT;  /* fake match */
 			if (state->match == NULL ||
 					atom_compare(atom, state->match) == EQUAL)
 			{
 				if (state->do_list) {
 					state->retv[i] = xstrdup(q);
 				} else {
+					atom->SLOT = NULL;  /* reset fake slot */
 					printf("%s[%s%s%s] %s\n",
 							atom_format(state->fmt, atom),
 							MAGENTA, p, NORM, q);
@@ -546,6 +548,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				.do_describe = false,
 				.do_list = true,
 				.match = atom,
+				.repo = state->repo,
 				.argc = cnt,
 				.argv = xmalloc(sizeof(char *) * cnt),
 				.retv = xzalloc(sizeof(char *) * cnt),


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-05-02  8:45 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-05-02  8:45 UTC (permalink / raw
  To: gentoo-commits

commit:     3080e828810d81a292c97226b115f390f487f370
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May  2 08:43:23 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May  2 08:45:42 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3080e828

qlop: show unmerged packages also in pseudo emerge format with -E

Packages unmerged (e.g. emerge -c) or unmerged in a blocker situation
showed up in -E mode in the normal way, e.g.:

2020-04-30T20:03:51 <<< www-servers/nginx-1.17.10

Make it show like in pseudo emerge output:

D    www-servers/nginx-1.17.10

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/qlop.c b/qlop.c
index 3e38adf..69133bb 100644
--- a/qlop.c
+++ b/qlop.c
@@ -825,6 +825,22 @@ static int do_emerge_log(
 								flags->do_time ? ": " : "",
 								flags->do_time ?
 									fmt_elapsedtime(flags, elapsed) : "");
+					} else if (flags->show_emerge) {
+						/* emerge never lists packages it unmerges, only
+						 * when part of installation of another package,
+						 * so there is nothing to follow here.  We could
+						 * use D(elete), R(emove) or (U)nmerge here,
+						 * which all three are already in use.  I've
+						 * chosen to use D in the first column here,
+						 * because D is only used together with U, so it
+						 * is the only distinquishable choice, appearing
+						 * in the place of N(ew). */
+						printf("%sD%s    %s", RED, NORM,
+								atom_format(flags->fmt, pkgw->atom));
+						if (flags->do_time)
+							printf(": %s\n", fmt_elapsedtime(flags, elapsed));
+						else
+							printf("\n");
 					} else if (flags->do_time) {
 						printf("%s <<< %s: %s\n",
 								fmt_date(flags, pkgw->tbegin, tstart),


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-04-27  7:46 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-04-27  7:46 UTC (permalink / raw
  To: gentoo-commits

commit:     4377832758b48538af852ce4470a3e030bd33ad0
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 27 07:46:09 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Apr 27 07:46:09 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=43778327

TODO: add item about metadata queries for maintainer type

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/TODO.md b/TODO.md
index 43c4d6a..86a9e84 100644
--- a/TODO.md
+++ b/TODO.md
@@ -25,6 +25,9 @@
   - cached, such that repeated matches for the same thing are served off
     the cache (set), as frequently happens in dependency calculations
   - tree\_{open,close}\_cat can be made static afterwards
+- make tree\_get\_metadata also retrieve maintainer type, such that
+  qlist can query for maintainer email or type, ideally to do
+  qlist -Iv $(portageq --repo gentoo --orphaned) in one step (bug 711466#c3)
 
 # tests
 - add test for qsearch to avoid repetitions like


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-02-21  8:50 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-02-21  8:50 UTC (permalink / raw
  To: gentoo-commits

commit:     90a925d28a38ee976ad6911a7424af119d347964
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 21 08:49:28 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Feb 21 08:49:28 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=90a925d2

travis: update homebrew tree as workaround for bundle problem

https://travis-ci.community/t/macos-build-fails-because-of-homebrew-bundle-unknown-command/7296/10

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index bc12463..8d73619 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -52,7 +52,7 @@ addons:
     - coreutils
     - bash
     - libressl
-    #update: true
+    update: true   # working around unknown bundle command
 
 before_install:
   - ./travis/install-blake2.sh


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-02-21  8:18 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-02-21  8:18 UTC (permalink / raw
  To: gentoo-commits

commit:     570a944b6db950bd27faf62b6aa63aef8b69b379
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 10 19:02:50 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Feb 10 19:02:50 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=570a944b

TODO: add note aboute qsearch test

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/TODO.md b/TODO.md
index fc10f26..2cce64a 100644
--- a/TODO.md
+++ b/TODO.md
@@ -26,6 +26,10 @@
     the cache (set), as frequently happens in dependency calculations
   - tree\_{open,close}\_cat can be made static afterwards
 
+# tests
+- add test for qsearch to avoid repetitions like
+  https://bugs.gentoo.org/701470
+
 # qmerge
 - dep resolver needs spanktastic love.
 - needs safe deleting (merge in place rather than unmerge;merge)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-31 14:45 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-31 14:45 UTC (permalink / raw
  To: gentoo-commits

commit:     749ad1d7d40276594a2bb69c4d71da33b6abecbd
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 31 14:43:48 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jan 31 14:43:48 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=749ad1d7

qsize: solve theoretical key conflict for dev/inode

Jan Ziak pointed out that it is possible to generate the same key for
two different files.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsize.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qsize.c b/qsize.c
index e54f714..c78a35f 100644
--- a/qsize.c
+++ b/qsize.c
@@ -112,7 +112,7 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	uint64_t num_bytes;
 	struct stat st;
 	bool ok = false;
-	char ikey[2 * (sizeof(size_t) * 2) + 1];  /* hex rep */
+	char ikey[2 * (sizeof(size_t) * 2) + 1 + 1];  /* hex rep */
 	size_t cur_uniq = cnt_set(state->uniq_files);
 	bool isuniq;
 
@@ -143,7 +143,7 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 			if (fstatat(pkg_ctx->cat_ctx->ctx->portroot_fd,
 						e->name + 1, &st, AT_SYMLINK_NOFOLLOW) == 0)
 			{
-				snprintf(ikey, sizeof(ikey), "%zx%zx",
+				snprintf(ikey, sizeof(ikey), "%zx:%zx",
 						(size_t)st.st_dev, (size_t)st.st_ino);
 				state->uniq_files =
 					add_set_unique(ikey, state->uniq_files, &isuniq);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-31 13:26 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-31 13:26 UTC (permalink / raw
  To: gentoo-commits

commit:     214fac0f5b899dbb40f7932f903a2aad4d42f161
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 31 13:26:26 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jan 31 13:26:26 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=214fac0f

make-tarball: ensure up-to-date manpages

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 make-tarball.sh | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/make-tarball.sh b/make-tarball.sh
index f1cfb15..22ab910 100755
--- a/make-tarball.sh
+++ b/make-tarball.sh
@@ -27,9 +27,12 @@ git) ver="HEAD" ;;
 	;;
 esac
 p="${TMPDIR:-/var/tmp}/portage-utils-${ver#v}"
+pb=${p}_build
 
 rm -rf "${p}"
 mkdir "${p}"
+rm -rf "${pb}"
+mkdir "${pb}"
 
 einfo "Checking out clean git sources ..."
 git archive "${ver}" | tar xf - -C "${p}"
@@ -42,23 +45,24 @@ sed -i "/^AM_MAINTAINER_MODE/s:(.*)$::" configure.ac
 rm -rf autom4te.cache
 popd >/dev/null
 
-einfo "Generating tarball ..."
-pushd "${p%/*}" >/dev/null
-tar --numeric-owner -cf - "${p##*/}" | xz > "${p}".tar.xz
-popd >/dev/null
-rm -r "${p}"
-
-einfo "Checking tarball ..."
-pushd "${p%/*}" >/dev/null
-tar xf "${p}".tar.*
-popd >/dev/null
-pushd "${p}" >/dev/null
+einfo "Checking sources ..."
+pushd "${pb}" >/dev/null
+tar cf - -C "${p}" . | tar xf -
 v ./configure -q
 v ${MAKE} -s
 v ${MAKE} -s check
 v ${MAKE} -s DESTDIR="${PWD}"/install install
+v ./man/mkman.py
+# ensure the tar contains up-to-date manpages
+cp -a man/*.1 "${p}"/man
 popd >/dev/null
-rm -rf "${p}"
+rm -rf "${pb}"
+
+einfo "Generating tarball ..."
+pushd "${p%/*}" >/dev/null
+tar --numeric-owner -cf - "${p##*/}" | xz > "${p}".tar.xz
+popd >/dev/null
+rm -r "${p}"
 
 echo
 einfo "All ready for distribution!"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-31 13:26 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-31 13:26 UTC (permalink / raw
  To: gentoo-commits

commit:     029cf600be9203e944180bcd0fd4da714052457c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 31 13:08:59 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jan 31 13:08:59 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=029cf600

qmerge: fix Coverity 207952 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index fc20f10..5eec188 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1604,14 +1604,15 @@ unlink_empty(const char *buf)
 {
 	struct stat st;
 	int fd;
+	int ret = -1;
 
 	fd = open(buf, O_RDONLY);
 	if (fd != -1 && stat(buf, &st) != -1) {
 		if (st.st_size == 0)
-			return unlink(buf);
+			ret = unlink(buf);
 		close(fd);
 	}
-	return -1;
+	return ret;
 }
 
 static int


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-31 13:26 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-31 13:26 UTC (permalink / raw
  To: gentoo-commits

commit:     fafb4fcd0de20133cf61b5c92fdf1649568b3949
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 31 13:06:58 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jan 31 13:06:58 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=fafb4fcd

qsize: fix Coverity 207953 Resource leak

no leak can really be leaked here, because input set is never NULL, but
it won't hurt (or cause problems in the future), so let's do it

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsize.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qsize.c b/qsize.c
index 1a1b40e..e54f714 100644
--- a/qsize.c
+++ b/qsize.c
@@ -145,7 +145,8 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 			{
 				snprintf(ikey, sizeof(ikey), "%zx%zx",
 						(size_t)st.st_dev, (size_t)st.st_ino);
-				add_set_unique(ikey, state->uniq_files, &isuniq);
+				state->uniq_files =
+					add_set_unique(ikey, state->uniq_files, &isuniq);
 				if (isuniq)
 					num_bytes +=
 						state->fs_size ? st.st_blocks * S_BLKSIZE : st.st_size;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-31 10:49 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-31 10:49 UTC (permalink / raw
  To: gentoo-commits

commit:     01b7a90b59097201a3316ee10f2cb512a1db852d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 31 10:47:48 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jan 31 10:47:48 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=01b7a90b

qsize: don't count hardlinked files double, #11

While ensuring hardlinked files are counted only once, also report on
the amount of real unique files, if different from file count.

This is an alternative take to the work of Jan Ziak.

Closes: PR #11
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsize.c | 65 +++++++++++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 49 insertions(+), 16 deletions(-)

diff --git a/qsize.c b/qsize.c
index aa5e1d1..1a1b40e 100644
--- a/qsize.c
+++ b/qsize.c
@@ -93,7 +93,10 @@ struct qsize_opt_state {
 	const char *fmt;
 	bool need_full_atom:1;
 
-	size_t num_all_files, num_all_nonfiles, num_all_ignored;
+	set *uniq_files;
+	size_t num_all_files;
+	size_t num_all_nonfiles;
+	size_t num_all_ignored;
 	uint64_t num_all_bytes;
 };
 
@@ -107,6 +110,11 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	char *savep;
 	size_t num_files, num_nonfiles, num_ignored;
 	uint64_t num_bytes;
+	struct stat st;
+	bool ok = false;
+	char ikey[2 * (sizeof(size_t) * 2) + 1];  /* hex rep */
+	size_t cur_uniq = cnt_set(state->uniq_files);
+	bool isuniq;
 
 	if ((line = tree_pkg_meta_get(pkg_ctx, CONTENTS)) == NULL)
 		return EXIT_SUCCESS;
@@ -115,8 +123,8 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	for (; (line = strtok_r(line, "\n", &savep)) != NULL; line = NULL) {
 		contents_entry *e;
 		regex_t *regex;
-		int ok = 0;
 
+		ok = false;
 		e = contents_parse_line(line);
 		if (!e)
 			continue;
@@ -124,21 +132,27 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 		array_for_each(state->ignore_regexp, i, regex) {
 			if (!regexec(regex, e->name, 0, NULL, 0)) {
 				num_ignored++;
-				ok = 1;
+				ok = true;
 			}
 		}
 		if (ok)
 			continue;
 
 		if (e->type == CONTENTS_OBJ || e->type == CONTENTS_SYM) {
-			struct stat st;
-			++num_files;
-			if (!fstatat(pkg_ctx->cat_ctx->ctx->portroot_fd,
-						e->name + 1, &st, AT_SYMLINK_NOFOLLOW))
-				num_bytes +=
-					state->fs_size ? st.st_blocks * S_BLKSIZE : st.st_size;
-		} else
-			++num_nonfiles;
+			num_files++;
+			if (fstatat(pkg_ctx->cat_ctx->ctx->portroot_fd,
+						e->name + 1, &st, AT_SYMLINK_NOFOLLOW) == 0)
+			{
+				snprintf(ikey, sizeof(ikey), "%zx%zx",
+						(size_t)st.st_dev, (size_t)st.st_ino);
+				add_set_unique(ikey, state->uniq_files, &isuniq);
+				if (isuniq)
+					num_bytes +=
+						state->fs_size ? st.st_blocks * S_BLKSIZE : st.st_size;
+			}
+		} else {
+			num_nonfiles++;
+		}
 	}
 	state->num_all_bytes += num_bytes;
 	state->num_all_files += num_files;
@@ -146,10 +160,19 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	state->num_all_ignored += num_ignored;
 
 	if (!state->summary_only) {
+		char uniqbuf[32];
+
+		cur_uniq = cnt_set(state->uniq_files) - cur_uniq;
 		atom = tree_get_atom(pkg_ctx, state->need_full_atom);
-		printf("%s: %zu files, %zu non-files, ",
+
+		if (cur_uniq != num_files)
+			snprintf(uniqbuf, sizeof(uniqbuf), " (%zu unique)", cur_uniq);
+		else
+			uniqbuf[0] = '\0';
+
+		printf("%s: %zu files%s, %zu non-files, ",
 				atom_format(state->fmt, atom),
-				num_files, num_nonfiles);
+				num_files, uniqbuf, num_nonfiles);
 		if (num_ignored)
 			printf("%zu names-ignored, ", num_ignored);
 		printf("%s %s\n",
@@ -177,10 +200,11 @@ int qsize_main(int argc, char **argv)
 		.disp_units = 0,
 		.str_disp_units = NULL,
 		.ignore_regexp = ignore_regexp,
-		.num_all_bytes = 0,
+		.uniq_files = create_set(),
 		.num_all_files = 0,
 		.num_all_nonfiles = 0,
 		.num_all_ignored = 0,
+		.num_all_bytes = 0,
 		.need_full_atom = false,
 		.fmt = NULL,
 	};
@@ -238,8 +262,16 @@ int qsize_main(int argc, char **argv)
 	}
 
 	if (state.summary) {
-		printf(" %sTotals%s: %zu files, %zu non-files, ", BOLD, NORM,
-		       state.num_all_files, state.num_all_nonfiles);
+		char uniqbuf[32];
+		size_t uniq_files = cnt_set(state.uniq_files);
+
+		if (uniq_files != state.num_all_files)
+			snprintf(uniqbuf, sizeof(uniqbuf), " (%zu unique)", uniq_files);
+		else
+			uniqbuf[0] = '\0';
+
+		printf(" %sTotals%s: %zu files%s, %zu non-files, ", BOLD, NORM,
+		       state.num_all_files, uniqbuf, state.num_all_nonfiles);
 		if (state.num_all_ignored)
 			printf("%zu names-ignored, ", state.num_all_ignored);
 		printf("%s %s\n",
@@ -252,6 +284,7 @@ int qsize_main(int argc, char **argv)
 		atom_implode(atom);
 	xarrayfree_int(state.atoms);
 	xarrayfree(state.ignore_regexp);
+	free_set(state.uniq_files);
 
 	return ret;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-31 10:49 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-31 10:49 UTC (permalink / raw
  To: gentoo-commits

commit:     32421ec602705b4b21bdeb2a26c069ad6736f119
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 26 19:38:34 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 26 19:38:34 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=32421ec6

qmerge: fix Coverity 125937 Time of check time of use

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 15017c1..156f262 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1603,9 +1603,14 @@ static int
 unlink_empty(const char *buf)
 {
 	struct stat st;
-	if (stat(buf, &st) != -1)
+	int fd;
+
+	fd = open(buf, O_RDONLY);
+	if (fd != -1 && stat(buf, &st) != -1) {
 		if (st.st_size == 0)
 			return unlink(buf);
+		close(fd);
+	}
 	return -1;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-31 10:49 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-31 10:49 UTC (permalink / raw
  To: gentoo-commits

commit:     9ae224a10bb95117e7d153353cd552a6471cb878
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 26 19:47:45 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 26 19:47:45 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9ae224a1

qmerge: reformat

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 156f262..fc20f10 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1711,7 +1711,8 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		snprintf(buf, sizeof(buf), "%s/%s.tbz2", atom->CATEGORY, pkg->PF);
 		fetch(str, buf);
 	}
-	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, atom->CATEGORY, pkg->PF);
+	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2",
+			pkgdir, atom->CATEGORY, pkg->PF);
 	if (access(buf, R_OK) != 0) {
 		snprintf(buf, sizeof(buf), "%s.tbz2", pkg->PF);
 		fetch(str, buf);
@@ -1719,7 +1720,8 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	}
 
 	/* verify the pkg exists now. unlink if zero bytes */
-	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, atom->CATEGORY, pkg->PF);
+	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2",
+			pkgdir, atom->CATEGORY, pkg->PF);
 	unlink_empty(buf);
 
 	if (access(buf, R_OK) != 0) {
@@ -1728,7 +1730,8 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		return;
 	}
 
-	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2", pkgdir, atom->CATEGORY, pkg->PF);
+	snprintf(buf, sizeof(buf), "%s/%s/%s.tbz2",
+			pkgdir, atom->CATEGORY, pkg->PF);
 	if (pkg_verify_checksums(buf, pkg, atom, qmerge_strict, !quiet) == 0) {
 		pkg_merge(0, atom, pkg);
 		return;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-26 19:31 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-26 19:31 UTC (permalink / raw
  To: gentoo-commits

commit:     d16c14190cac7e757f87402a95f2d4a1c12281e1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 26 18:25:09 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 26 18:25:09 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d16c1419

qmanifest: fix Coverity 206540 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qmanifest.c b/qmanifest.c
index cc4e380..a00dbd2 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -542,6 +542,7 @@ generate_dir(const char *dir, enum type_manifest mtype)
 			if (gzwrite(mf, path, len) == 0) {
 				fprintf(stderr, "failed to write to file '%s/%s': %s\n",
 						dir, str_manifest_gz, strerror(errno));
+				gzclose(mf);
 				return NULL;
 			}
 		}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-25 12:20 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-25 12:20 UTC (permalink / raw
  To: gentoo-commits

commit:     3dcb44ca2b8d53a9afbeee447ca37ef6f8ba43a8
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 25 12:18:12 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan 25 12:18:12 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3dcb44ca

qpkg: change smiley in comment not to upset rediculous style check

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qpkg.c b/qpkg.c
index 1b654a6..79245d0 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -376,7 +376,7 @@ int qpkg_main(int argc, char **argv)
 	if (qpkg_bindir[0] != '/')
 		err("'%s' is not a valid package destination", qpkg_bindir);
 	/* brute force just unlink any file or symlink, if this fails, it's
-	 * actually good ;) */
+	 * actually good :) */
 	unlink(qpkg_bindir);
 	fd = open(qpkg_bindir, O_RDONLY);
 	if ((fd == -1 && mkdir(qpkg_bindir, 0750) == -1) ||


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-25 12:20 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-25 12:20 UTC (permalink / raw
  To: gentoo-commits

commit:     169ad2331b0a84f8a960402b04077ece57bb35e2
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 25 12:19:25 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan 25 12:19:25 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=169ad233

qpkg: fix Coverity 207883 Error handling issues

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qpkg.c b/qpkg.c
index 79245d0..14e51ce 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -389,7 +389,8 @@ int qpkg_main(int argc, char **argv)
 			if (fchmod(fd, 0750) < 0)
 				errp("could not chmod(0750) temp bindir '%s'", qpkg_bindir);
 	}
-	close(fd);
+	if (fd >= 0)
+		close(fd);
 
 	/* we have to change to the root so that we can feed the full paths
 	 * to tar when we create the binary package. */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-25 12:11 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-25 12:11 UTC (permalink / raw
  To: gentoo-commits

commit:     e612f0db4ea58be77ffd7b953ee3363831b61a59
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 25 12:10:21 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan 25 12:10:21 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e612f0db

qpkg: try to fix Coverity 125940 Time of check time of use

first perform the unlink, then open the object, and perform stat + chmod
on it, if necessary

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 28 +++++++++++++++-------------
 1 file changed, 15 insertions(+), 13 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 3602acf..1b654a6 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -349,6 +349,7 @@ int qpkg_main(int argc, char **argv)
 	depend_atom *atom;
 	int restrict_chmod = 0;
 	int qclean = 0;
+	int fd;
 
 	qpkg_bindir = pkgdir;
 	while ((i = GETOPT_LONG(QPKG, qpkg, "")) != -1) {
@@ -374,20 +375,21 @@ int qpkg_main(int argc, char **argv)
 	/* setup temp dirs */
 	if (qpkg_bindir[0] != '/')
 		err("'%s' is not a valid package destination", qpkg_bindir);
-	for (i = 0; i <= 1; i++) {
-		if (mkdir(qpkg_bindir, 0750) == -1) {
-			if (lstat(qpkg_bindir, &st) == 0 && !S_ISDIR(st.st_mode)) {
-				unlink(qpkg_bindir);
-				continue;
-			}
-			if (!restrict_chmod)
-				if (chmod(qpkg_bindir, 0750))
-					errp("could not chmod(0750) temp bindir '%s'", qpkg_bindir);
-		}
-		break;
-	}
-	if (i == 2)
+	/* brute force just unlink any file or symlink, if this fails, it's
+	 * actually good ;) */
+	unlink(qpkg_bindir);
+	fd = open(qpkg_bindir, O_RDONLY);
+	if ((fd == -1 && mkdir(qpkg_bindir, 0750) == -1) ||
+			(fd != -1 && (fstat(fd, &st) == -1 || !S_ISDIR(st.st_mode))))
+	{
 		errp("could not create temp bindir '%s'", qpkg_bindir);
+	} else {
+		/* fd is valid, pointing to a directory */
+		if (!restrict_chmod)
+			if (fchmod(fd, 0750) < 0)
+				errp("could not chmod(0750) temp bindir '%s'", qpkg_bindir);
+	}
+	close(fd);
 
 	/* we have to change to the root so that we can feed the full paths
 	 * to tar when we create the binary package. */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-25 10:01 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-25 10:01 UTC (permalink / raw
  To: gentoo-commits

commit:     adedae3b3673d3797ba2ba381acf04c24c38b309
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 25 10:01:03 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan 25 10:01:03 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=adedae3b

qpkg: try 2 at Coverity 206549 Time of check time of use

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 6aa5f76..3602acf 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -257,9 +257,16 @@ qpkg_make(depend_atom *atom)
 	}
 	pclose(fp);
 
+	if ((i = open(tbz2, O_WRONLY)) < 0) {
+		warnp("failed to open '%s': %s", tbz2, strerror(errno));
+		free(buf);
+		return 1;
+	}
+
 	/* get offset where xpak will start */
-	if (stat(tbz2, &st) == -1) {
+	if (fstat(i, &st) == -1) {
 		warnp("could not stat '%s': %s", tbz2, strerror(errno));
+		close(i);
 		free(buf);
 		return 1;
 	}
@@ -271,12 +278,6 @@ qpkg_make(depend_atom *atom)
 	xpak_argv[1] = NULL;
 	xpak_create(AT_FDCWD, tbz2, 1, xpak_argv, 1, verbose);
 
-	if ((i = open(tbz2, O_WRONLY | O_APPEND)) < 0) {
-		warnp("failed to open '%s': %s", tbz2, strerror(errno));
-		free(buf);
-		return 1;
-	}
-
 	/* calculate the number of bytes taken by the xpak archive */
 	if (fstat(i, &st) == -1) {
 		warnp("could not stat '%s': %s", tbz2, strerror(errno));


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-25  9:45 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-25  9:45 UTC (permalink / raw
  To: gentoo-commits

commit:     db5cb274ad76778091619b8c7e38a7c0134d5a04
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 25 09:44:18 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan 25 09:44:18 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=db5cb274

qpkg: try to fix Coverity 206549 Time of check, time of use

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 1535f05..6aa5f76 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -271,17 +271,25 @@ qpkg_make(depend_atom *atom)
 	xpak_argv[1] = NULL;
 	xpak_create(AT_FDCWD, tbz2, 1, xpak_argv, 1, verbose);
 
+	if ((i = open(tbz2, O_WRONLY | O_APPEND)) < 0) {
+		warnp("failed to open '%s': %s", tbz2, strerror(errno));
+		free(buf);
+		return 1;
+	}
+
 	/* calculate the number of bytes taken by the xpak archive */
-	if (stat(tbz2, &st) == -1) {
+	if (fstat(i, &st) == -1) {
 		warnp("could not stat '%s': %s", tbz2, strerror(errno));
+		close(i);
 		free(buf);
 		return 1;
 	}
 	xpaksize = st.st_size - xpaksize;
 
 	/* save tbz2 tail: OOOOSTOP */
-	if ((fp = fopen(tbz2, "a")) == NULL) {
+	if ((fp = fdopen(i, "a")) == NULL) {
 		warnp("could not open '%s': %s", tbz2, strerror(errno));
+		close(i);
 		free(buf);
 		return 1;
 	}
@@ -294,8 +302,7 @@ qpkg_make(depend_atom *atom)
 	unlink(filelist);
 
 	/* create dirs, if necessary */
-	snprintf(buf, buflen, "%s/%s",
-			qpkg_bindir, atom->CATEGORY);
+	snprintf(buf, buflen, "%s/%s", qpkg_bindir, atom->CATEGORY);
 	mkdir_p(buf, 0755);
 
 	snprintf(buf, buflen, "%s/%s/%s.tbz2",


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-25  9:11 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-25  9:11 UTC (permalink / raw
  To: gentoo-commits

commit:     fcc1c2cc371eb122b958cf98eee7cb767ac14cb1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 25 09:04:30 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan 25 09:04:30 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=fcc1c2cc

qmanifest: fix Coverity 206559 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qmanifest.c b/qmanifest.c
index 308aee7..cc4e380 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -472,6 +472,9 @@ generate_dir(const char *dir, enum type_manifest mtype)
 						fprintf(stderr, "generating Manifest for %s failed!\n",
 								path);
 						gzclose(mf);
+						for (; i < dentrieslen; i++)
+							free(dentries[i]);
+						free(dentries);
 						return NULL;
 					}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-25  9:11 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-25  9:11 UTC (permalink / raw
  To: gentoo-commits

commit:     74cf35199330b4ab163c8a9b5261bba1708737d8
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 25 09:10:50 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan 25 09:10:50 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=74cf3519

qpkg: fix syntax error

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qpkg.c b/qpkg.c
index 7929018..1535f05 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -309,7 +309,7 @@ qpkg_make(depend_atom *atom)
 	rmdir(tmpdir);
 
 	if (stat(buf, &st) == -1) {
-		warnp("could not stat '%s': %s", buf strerror(errno));
+		warnp("could not stat '%s': %s", buf, strerror(errno));
 		free(buf);
 		return 1;
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-25  9:03 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-25  9:03 UTC (permalink / raw
  To: gentoo-commits

commit:     c1c13ec718ee8e1b36082b84e861cda0e961e5a6
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 24 19:10:21 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jan 24 19:10:21 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c1c13ec7

qtegrity: fix Coverity 206558 Unchecked return value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qtegrity.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qtegrity.c b/qtegrity.c
index c2fc221..19fd509 100644
--- a/qtegrity.c
+++ b/qtegrity.c
@@ -442,7 +442,9 @@ int qtegrity_main(int argc, char **argv)
 				skip = ((recorded_digest_size == SHA256_DIGEST_LENGTH) ||
 						(recorded_digest_size == SHA512_DIGEST_LENGTH)) ?
 					recorded_digest_size+6+8 : recorded_digest_size+6+6;
-				fseek(fp_qtegrity_custom, -skip-strlen(fname), SEEK_CUR);
+				if (fseek(fp_qtegrity_custom,
+							-skip-strlen(fname), SEEK_CUR) == -1)
+					err("seek failed: %s\n", strerror(errno));
 				free(fname);
 				break;
 			}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-25  9:03 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-25  9:03 UTC (permalink / raw
  To: gentoo-commits

commit:     9fc55602841eb9592b7bbef9cdd2040e1fd07910
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 24 18:56:31 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jan 24 18:56:31 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9fc55602

qmanifest: fix Coverity 206540 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qmanifest.c b/qmanifest.c
index 84fd25d..308aee7 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -434,6 +434,7 @@ generate_dir(const char *dir, enum type_manifest mtype)
 		if (gzwrite(mf, path, len) == 0) {
 			fprintf(stderr, "failed to write to file '%s/%s': %s\n",
 					dir, str_manifest_files_gz, strerror(errno));
+			gzclose(mf);
 			return NULL;
 		}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-25  9:03 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-25  9:03 UTC (permalink / raw
  To: gentoo-commits

commit:     813b219d06e950f44d47d60d401d0e8c11073631
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 24 18:41:13 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jan 24 18:41:13 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=813b219d

qmanifest: fix Coverity 206540 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qmanifest.c b/qmanifest.c
index b4057bb..2a6d9b5 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -582,8 +582,10 @@ generate_dir(const char *dir, enum type_manifest mtype)
 			return NULL;
 		}
 
-		if (list_dir(&dentries, &dentrieslen, dir) != 0)
+		if (list_dir(&dentries, &dentrieslen, dir) != 0) {
+			gzclose(mf);
 			return NULL;
+		}
 
 		for (i = 0; i < dentrieslen; i++) {
 			/* ignore existing Manifests */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-25  9:03 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-25  9:03 UTC (permalink / raw
  To: gentoo-commits

commit:     5c74386bd7c9112df90a7e38fcc14db7ea721e55
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 24 18:44:36 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jan 24 18:44:36 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5c74386b

qpkg: fix Coverity 125896 Unchecked return value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/qpkg.c b/qpkg.c
index eaca37b..7929018 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -308,7 +308,12 @@ qpkg_make(depend_atom *atom)
 
 	rmdir(tmpdir);
 
-	stat(buf, &st);
+	if (stat(buf, &st) == -1) {
+		warnp("could not stat '%s': %s", buf strerror(errno));
+		free(buf);
+		return 1;
+	}
+
 	printf("%s%s%s KiB\n",
 			RED, make_human_readable_str(st.st_size, 1, KILOBYTE), NORM);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-25  9:03 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-25  9:03 UTC (permalink / raw
  To: gentoo-commits

commit:     12f14a40b3311f557d746856ff472a5a06337bc1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 24 18:52:42 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jan 24 18:52:42 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=12f14a40

qmanifest: fix Coverity 206530 Explicit null dereferenced

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmanifest.c b/qmanifest.c
index 2a6d9b5..84fd25d 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -1495,7 +1495,7 @@ verify_manifest(
 	 * - Manifest at top-level, needs to be igored as it only points to
 	 *   the larger Manifest.files.gz
 	 */
-	if (compare_elems > 1)
+	if (elemslen > 1)
 		qsort(elems, elemslen, sizeof(elems[0]), compare_elems);
 	snprintf(buf, sizeof(buf), "%s/%s", dir, manifest);
 	ret = verify_dir(dir, elems, elemslen, 0, buf + 2, msgs);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 20:11 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 20:11 UTC (permalink / raw
  To: gentoo-commits

commit:     9bcc67d7155a2fa2287d1f2600d3ca2419b51e09
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 20:05:57 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 20:05:57 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9bcc67d7

qmanifest: fix Coverity 206530 Explicit null dereferenced

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qmanifest.c b/qmanifest.c
index bead1c9..31c4696 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -1489,7 +1489,8 @@ verify_manifest(
 	 * - Manifest at top-level, needs to be igored as it only points to
 	 *   the larger Manifest.files.gz
 	 */
-	qsort(elems, elemslen, sizeof(elems[0]), compare_elems);
+	if (compare_elems > 1)
+		qsort(elems, elemslen, sizeof(elems[0]), compare_elems);
 	snprintf(buf, sizeof(buf), "%s/%s", dir, manifest);
 	ret = verify_dir(dir, elems, elemslen, 0, buf + 2, msgs);
 	checked_manifests++;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 20:11 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 20:11 UTC (permalink / raw
  To: gentoo-commits

commit:     bdda53e4e914c44b1c278c6df1e726ba5170cff0
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 20:09:07 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 20:09:07 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bdda53e4

qmanifest: fix Coverity 206535 Unchecked return value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/qmanifest.c b/qmanifest.c
index 31c4696..b4057bb 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -690,7 +690,11 @@ generate_dir(const char *dir, enum type_manifest mtype)
 		fclose(m);
 
 		snprintf(path, sizeof(path), "%s/%s", dir, str_manifest);
-		rename(newmanifest, path);
+		if (rename(newmanifest, path) == -1) {
+			fprintf(stderr, "failed to rename file '%s' to '%s': %s\n",
+					newmanifest, path, strerror(errno));
+			return NULL;
+		}
 
 		if (tv[0].tv_sec != 0) {
 			/* set Manifest and dir mtime to most recent file we found */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 20:11 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 20:11 UTC (permalink / raw
  To: gentoo-commits

commit:     1c0191cf3ffe4142c512fbd72f4fdd6e0260cb82
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 20:10:35 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 20:10:35 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1c0191cf

qsize: fix Coverity 206536 Invalid printf format string

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsize.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qsize.c b/qsize.c
index 36b4d64..aa5e1d1 100644
--- a/qsize.c
+++ b/qsize.c
@@ -238,10 +238,10 @@ int qsize_main(int argc, char **argv)
 	}
 
 	if (state.summary) {
-		printf(" %sTotals%s: %'zu files, %'zu non-files, ", BOLD, NORM,
+		printf(" %sTotals%s: %zu files, %zu non-files, ", BOLD, NORM,
 		       state.num_all_files, state.num_all_nonfiles);
 		if (state.num_all_ignored)
-			printf("%'zu names-ignored, ", state.num_all_ignored);
+			printf("%zu names-ignored, ", state.num_all_ignored);
 		printf("%s %s\n",
 			   make_human_readable_str(
 				   state.num_all_bytes, 1, state.disp_units),


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 20:04 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 20:04 UTC (permalink / raw
  To: gentoo-commits

commit:     899cea94f06283fc56b5c6672e14b64d28bd44f6
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 20:04:28 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 20:04:28 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=899cea94

qmerge: ignore already existing directory

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 2fabd15..15017c1 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1671,7 +1671,7 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	unlink_empty(buf);
 
 	snprintf(str, sizeof(str), "%s/%s", pkgdir, pkg->CATEGORY);
-	if (mkdir(str, 0755) == -1) {
+	if (mkdir(str, 0755) == -1 && errno != EEXIST) {
 		warn("Failed to create %s", str);
 		return;
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 20:04 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 20:04 UTC (permalink / raw
  To: gentoo-commits

commit:     16b15959d455864eebb4d07e7b846bcb618e5bf1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 20:01:22 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 20:01:22 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=16b15959

qmerge: fix Coverity 125935 Time of check time of use

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qmerge.c b/qmerge.c
index f2ef84d..2fabd15 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -2026,6 +2026,7 @@ find_binpkg(const char *name)
 		return best_match;
 
 	fp = open_binpkg_index();
+	PF[0] = CATEGORY[0] = '\0';
 
 	while (fgets(buf, sizeof(buf), fp) != NULL) {
 		if (*buf == '\n') {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 20:04 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 20:04 UTC (permalink / raw
  To: gentoo-commits

commit:     b268821fa9a1731e4c092dffb1e9334456df31d0
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 19:56:45 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 19:56:45 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b268821f

main: fix Coverity 125929 Sizeof not portable

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index cfaa9af..87fc751 100644
--- a/main.c
+++ b/main.c
@@ -243,7 +243,7 @@ makeargv(const char *string, int *argc, char ***argv)
 
 		if (*argc == curc) {
 			curc *= 2;
-			(*argv) = xrealloc(*argv, sizeof(char **) * curc);
+			(*argv) = xrealloc(*argv, sizeof(char *) * curc);
 		}
 		(*argv)[*argc] = xstrdup(str);
 		(*argc)++;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 20:04 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 20:04 UTC (permalink / raw
  To: gentoo-commits

commit:     6f43aebb16c94a02a61bc476a368990efc6b167c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 19:58:21 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 19:58:21 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6f43aebb

main: fix Coverity 125930 Sizeof not portable

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 87fc751..76a6ffb 100644
--- a/main.c
+++ b/main.c
@@ -220,7 +220,7 @@ makeargv(const char *string, int *argc, char ***argv)
 {
 	int curc = 2;
 	char *q, *p, *str;
-	(*argv) = xmalloc(sizeof(char **) * curc);
+	(*argv) = xmalloc(sizeof(char *) * curc);
 
 	*argc = 1;
 	(*argv)[0] = xstrdup(argv0);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 19:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 19:54 UTC (permalink / raw
  To: gentoo-commits

commit:     2a819a2ff765005b4e6dbda35f794443c27522ee
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 19:53:01 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 19:53:01 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2a819a2f

qpkg: fix Coverity 125928 Insecure temporary file

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/qpkg.c b/qpkg.c
index 948d564..eaca37b 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -179,6 +179,7 @@ qpkg_make(depend_atom *atom)
 	int i;
 	char *xpak_argv[2];
 	struct stat st;
+	mode_t mask;
 
 	if (pretend) {
 		printf(" %s-%s %s:\n",
@@ -197,7 +198,10 @@ qpkg_make(depend_atom *atom)
 	}
 
 	snprintf(tmpdir, sizeof(tmpdir), "%s/qpkg.XXXXXX", qpkg_bindir);
-	if ((i = mkstemp(tmpdir)) == -1) {
+	mask = umask(0077);
+	i = mkstemp(tmpdir);
+	umask(mask);
+	if (i == -1) {
 		fclose(fp);
 		free(buf);
 		return -2;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 19:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 19:54 UTC (permalink / raw
  To: gentoo-commits

commit:     107a164f604fd8ead594b3eaeea1840a3c84a157
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 19:18:12 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 19:18:12 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=107a164f

qmerge: fix Coverity 125890 Unchecked return value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 6988285..f2ef84d 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1671,7 +1671,10 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	unlink_empty(buf);
 
 	snprintf(str, sizeof(str), "%s/%s", pkgdir, pkg->CATEGORY);
-	mkdir(str, 0755);
+	if (mkdir(str, 0755) == -1) {
+		warn("Failed to create %s", str);
+		return;
+	}
 
 	/* XXX: should do a size check here for partial downloads */
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 19:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 19:54 UTC (permalink / raw
  To: gentoo-commits

commit:     40335ce6a4577e520a612d7061dadf5c9b2e8b01
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 19:37:53 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 19:37:53 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=40335ce6

qpkg: fix Coverity 125897 Unchecked return value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 4519e9c..7835cd7 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -356,8 +356,7 @@ int qpkg_main(int argc, char **argv)
 		err("'%s' is not a valid package destination", qpkg_bindir);
 	for (i = 0; i <= 1; i++) {
 		if (mkdir(qpkg_bindir, 0750) == -1) {
-			lstat(qpkg_bindir, &st);
-			if (!S_ISDIR(st.st_mode)) {
+			if (lstat(qpkg_bindir, &st) == 0 && !S_ISDIR(st.st_mode)) {
 				unlink(qpkg_bindir);
 				continue;
 			}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 19:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 19:54 UTC (permalink / raw
  To: gentoo-commits

commit:     d99cc22a91b06d53cc3ef3ff159f25c71d62e750
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 19:49:59 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 19:49:59 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d99cc22a

qpkg: fix Coverity 125923 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qpkg.c b/qpkg.c
index 7835cd7..948d564 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -198,18 +198,21 @@ qpkg_make(depend_atom *atom)
 
 	snprintf(tmpdir, sizeof(tmpdir), "%s/qpkg.XXXXXX", qpkg_bindir);
 	if ((i = mkstemp(tmpdir)) == -1) {
+		fclose(fp);
 		free(buf);
 		return -2;
 	}
 	close(i);
 	unlink(tmpdir);
 	if (mkdir(tmpdir, 0750)) {
+		fclose(fp);
 		free(buf);
 		return -3;
 	}
 
 	snprintf(filelist, sizeof(filelist), "%s/filelist", tmpdir);
 	if ((out = fopen(filelist, "w")) == NULL) {
+		fclose(fp);
 		free(buf);
 		return -4;
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 19:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 19:54 UTC (permalink / raw
  To: gentoo-commits

commit:     1c0e24930af5f445d8c633791eb3ea2317b82b68
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 19:36:02 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 19:36:02 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1c0e2493

qpkg: fix Coverity 125896 Unchecked return value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 419456c..4519e9c 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -251,7 +251,11 @@ qpkg_make(depend_atom *atom)
 	pclose(fp);
 
 	/* get offset where xpak will start */
-	stat(tbz2, &st);
+	if (stat(tbz2, &st) == -1) {
+		warnp("could not stat '%s': %s", tbz2, strerror(errno));
+		free(buf);
+		return 1;
+	}
 	xpaksize = st.st_size;
 
 	snprintf(buf, buflen, "%s/%s/%s",
@@ -260,7 +264,12 @@ qpkg_make(depend_atom *atom)
 	xpak_argv[1] = NULL;
 	xpak_create(AT_FDCWD, tbz2, 1, xpak_argv, 1, verbose);
 
-	stat(tbz2, &st);
+	/* calculate the number of bytes taken by the xpak archive */
+	if (stat(tbz2, &st) == -1) {
+		warnp("could not stat '%s': %s", tbz2, strerror(errno));
+		free(buf);
+		return 1;
+	}
 	xpaksize = st.st_size - xpaksize;
 
 	/* save tbz2 tail: OOOOSTOP */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 19:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 19:54 UTC (permalink / raw
  To: gentoo-commits

commit:     661eac117591a59761b046f259972dc1802d5314
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 19:13:44 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 19:13:44 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=661eac11

qtbz2: fix Coverity 125889 Unchecked return value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qtbz2.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qtbz2.c b/qtbz2.c
index 314eecd..a02b477 100644
--- a/qtbz2.c
+++ b/qtbz2.c
@@ -139,7 +139,8 @@ _tbz2_write_file(FILE *src, int dir_fd, const char *dst, size_t len)
 	FILE *out;
 
 	if (!dst) {
-		fseek(src, len, SEEK_CUR);
+		if (fseek(src, len, SEEK_CUR) == -1)
+			errp("cannot seek to pos %zd: %s", len, strerror(errno));
 		return;
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-22 19:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-22 19:54 UTC (permalink / raw
  To: gentoo-commits

commit:     7b239af630a92184d7e7e024904b3c66ff08c381
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 22 19:47:21 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan 22 19:47:21 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7b239af6

qlop: fix Coverity 125912 Out-of-bounds access

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qlop.c b/qlop.c
index 8c166e2..cbe3b58 100644
--- a/qlop.c
+++ b/qlop.c
@@ -138,7 +138,7 @@ parse_date(const char *sdate, time_t *t)
 			/* Handle the formats:
 			 * <#> <day|week|month|year>[s] [ago]
 			 */
-			len = strlen(sdate);
+			len = strlen(sdate) + 1;
 
 			unsigned long num;
 			char dur[len];


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-20 19:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-20 19:54 UTC (permalink / raw
  To: gentoo-commits

commit:     70cf788ec5d4f493c099c34c28fb5fdabcd91eac
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 20 19:37:33 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jan 20 19:37:33 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=70cf788e

qtegrity: fix Coverity 185976 Dereference before null check

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qtegrity.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/qtegrity.c b/qtegrity.c
index 0d23a7f..c2fc221 100644
--- a/qtegrity.c
+++ b/qtegrity.c
@@ -306,14 +306,13 @@ int qtegrity_main(int argc, char **argv)
 			get_digest_from_line(buffered_line, recorded_digest,
 					recorded_digest_size, 50);
 
-			if (recorded_fname == NULL || recorded_digest == NULL) {
+			if (recorded_fname == NULL || *recorded_digest == '\0') {
 				printf("Empty recorded filename: %s\n", line);
 
 				if (recorded_fname != NULL)
 					free(recorded_fname);
 
-				if (recorded_digest != NULL)
-					free(recorded_digest);
+				free(recorded_digest);
 
 				continue;
 			}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:36 UTC (permalink / raw
  To: gentoo-commits

commit:     8c5afc9d1818826c8ed30bd5f8f364a2121e57e9
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 19:28:26 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 19:28:26 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8c5afc9d

quse: fix Coverity 206533 Dereference null return value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 quse.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/quse.c b/quse.c
index 723391c..2db628d 100644
--- a/quse.c
+++ b/quse.c
@@ -714,9 +714,11 @@ int quse_main(int argc, char **argv)
 			quse_describe_flag(portroot, overlay, &state);
 	} else if (state.do_installed) {
 		tree_ctx *t = tree_open_vdb(portroot, portvdb);
-		state.overlay = NULL;
-		tree_foreach_pkg_sorted(t, quse_results_cb, &state, state.match);
-		tree_close(t);
+		if (t != NULL) {
+			state.overlay = NULL;
+			tree_foreach_pkg_sorted(t, quse_results_cb, &state, state.match);
+			tree_close(t);
+		}
 	} else {
 		array_for_each(overlays, n, overlay) {
 			tree_ctx *t = tree_open(portroot, overlay);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:36 UTC (permalink / raw
  To: gentoo-commits

commit:     36a4fa02b2315b117b320139e8cac25f31930219
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 19:34:39 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 19:34:39 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=36a4fa02

qmerge: fix Coverity 206531 Double close

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index e22f22f..6988285 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -767,7 +767,8 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 		return ret;
 	}
 
-	dir = fdopendir(subfd_src);
+	i = dup(subfd_src);  /* fdopendir closes its argument */
+	dir = fdopendir(i);
 	if (!dir)
 		goto done;
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:36 UTC (permalink / raw
  To: gentoo-commits

commit:     b5b5d2a2302d6110a3df6bf9ed53226306c8da07
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 19:23:20 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 19:23:20 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b5b5d2a2

qfile: fix Coverity 206537 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qfile.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qfile.c b/qfile.c
index 3036be0..d104848 100644
--- a/qfile.c
+++ b/qfile.c
@@ -143,6 +143,7 @@ static int qfile_check_plibreg(void *priv)
 
 	if (line)
 		free(line);
+	fclose(fp_plibreg);
 
 	return found;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:36 UTC (permalink / raw
  To: gentoo-commits

commit:     a3704712617d3a6d4810e5dba596f36a11a95196
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 19:16:33 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 19:16:33 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a3704712

qmanifest: fix Coverity 206540 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qmanifest.c b/qmanifest.c
index bd04b96..f1bc82d 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -541,8 +541,10 @@ generate_dir(const char *dir, enum type_manifest mtype)
 			}
 		}
 
-		if (list_dir(&dentries, &dentrieslen, dir) != 0)
+		if (list_dir(&dentries, &dentrieslen, dir) != 0) {
+			gzclose(mf);
 			return NULL;
+		}
 
 		for (i = 0; i < dentrieslen; i++) {
 			/* ignore existing Manifests */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:36 UTC (permalink / raw
  To: gentoo-commits

commit:     6ac211da306deccd42717e05ebf132f3da61e053
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 19:14:44 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 19:14:44 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6ac211da

qpkg: fix Coverity 206541 Explicit null dereference

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 1eee7b1..419456c 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -96,14 +96,16 @@ qpkg_clean(char *dirp)
 		}
 	}
 
-	/* check which binpkgs exist in the known_pkgs (vdb or trees), such
-	 * that the remainder is what we would clean */
-	array_for_each(bins, n, binatomstr) {
-		if (contains_set(binatomstr, known_pkgs))
-			xarraydelete_ptr(bins, n--);
-	}
+	if (known_pkgs != NULL) {
+		/* check which binpkgs exist in the known_pkgs (vdb or trees), such
+		 * that the remainder is what we would clean */
+		array_for_each(bins, n, binatomstr) {
+			if (contains_set(binatomstr, known_pkgs))
+				xarraydelete_ptr(bins, n--);
+		}
 
-	free_set(known_pkgs);
+		free_set(known_pkgs);
+	}
 
 	array_for_each(bins, n, binatomstr) {
 		snprintf(buf, sizeof(buf), "%s/%s.tbz2", dirp, binatomstr);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:36 UTC (permalink / raw
  To: gentoo-commits

commit:     7c09a69e30ae73633155194c474d866203f39374
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 19:25:33 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 19:25:33 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7c09a69e

qmanifest: fix Coverity 206534 Explicit null dereference

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qmanifest.c b/qmanifest.c
index f1bc82d..bead1c9 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -159,7 +159,8 @@ list_dir(char ***retlist, size_t *retcnt, const char *path)
 		}
 		closedir(d);
 
-		qsort(rlist, rlen, sizeof(rlist[0]), compare_strings);
+		if (rlen > 1)
+			qsort(rlist, rlen, sizeof(rlist[0]), compare_strings);
 
 		*retlist = rlist;
 		*retcnt = rlen;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:09 UTC (permalink / raw
  To: gentoo-commits

commit:     d0f60bc07a3db42e5ee78709e974e31440b176b3
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 18:47:13 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 18:47:13 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d0f60bc0

qmerge: address Coverity 206546 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/qmerge.c b/qmerge.c
index ffde1ee..e22f22f 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -2233,6 +2233,8 @@ parse_packages(set *todo)
 					snprintf(Pkg.CATEGORY, sizeof(Pkg.CATEGORY), "%.*s",
 							(int)sizeof(Pkg.CATEGORY) - 1, p);
 				if (strcmp(buf, "CPV") == 0) {
+					if (pkg_atom != NULL)  /* hypothetical Coverity case */
+						atom_implode(pkg_atom);
 					if ((pkg_atom = atom_explode(p)) != NULL) {
 						if (pkg_atom->PR_int)
 							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s-r%i",


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:09 UTC (permalink / raw
  To: gentoo-commits

commit:     4398c48f77ef4d1c3034549ebf5150f1173341f8
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 18:53:52 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 18:53:52 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4398c48f

qpkg: fix Coverity 206544 Dereference null return value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/qpkg.c b/qpkg.c
index 562f9af..1eee7b1 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -262,7 +262,12 @@ qpkg_make(depend_atom *atom)
 	xpaksize = st.st_size - xpaksize;
 
 	/* save tbz2 tail: OOOOSTOP */
-	fp = fopen(tbz2, "a");
+	if ((fp = fopen(tbz2, "a")) == NULL) {
+		warnp("could not open '%s': %s", tbz2, strerror(errno));
+		free(buf);
+		return 1;
+	}
+
 	WRITE_BE_INT32(buf, xpaksize);
 	fwrite(buf, 1, 4, fp);
 	fwrite("STOP", 1, 4, fp);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:09 UTC (permalink / raw
  To: gentoo-commits

commit:     8939326fab56353f5f7f7f49dcf3854fbea44f64
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 18:01:01 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 18:01:01 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8939326f

quse: fix Coverity 206554 Double close

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 quse.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/quse.c b/quse.c
index f88e298..723391c 100644
--- a/quse.c
+++ b/quse.c
@@ -304,7 +304,6 @@ quse_search_profiles_desc(
 
 		f = fdopen(dfd, "r");
 		if (f == NULL) {
-			close(fd);
 			ret = false;
 			break;
 		}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:09 UTC (permalink / raw
  To: gentoo-commits

commit:     fc1acee1100c0ab16501c0afbfed498b7cc91260
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 18:11:09 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 18:11:09 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=fc1acee1

qsize: fix Coverity 206552 Invalid printf format string

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsize.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qsize.c b/qsize.c
index a25ce78..36b4d64 100644
--- a/qsize.c
+++ b/qsize.c
@@ -147,11 +147,11 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 	if (!state->summary_only) {
 		atom = tree_get_atom(pkg_ctx, state->need_full_atom);
-		printf("%s: %'zu files, %'zu non-files, ",
+		printf("%s: %zu files, %zu non-files, ",
 				atom_format(state->fmt, atom),
 				num_files, num_nonfiles);
 		if (num_ignored)
-			printf("%'zu names-ignored, ", num_ignored);
+			printf("%zu names-ignored, ", num_ignored);
 		printf("%s %s\n",
 			   make_human_readable_str(num_bytes, 1, state->disp_units),
 			   state->disp_units ? state->str_disp_units : "");


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:09 UTC (permalink / raw
  To: gentoo-commits

commit:     85355e52d5adaf79c8c69ae5dc46ebc62a2c8cde
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 17:56:41 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 17:56:41 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=85355e52

qlist: fix Coverity 206555 Out-of-bounds read

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlist.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qlist.c b/qlist.c
index 506e3e5..cd60083 100644
--- a/qlist.c
+++ b/qlist.c
@@ -277,9 +277,9 @@ qlist_match(
 
 		/* let's try exact matching w/out the PV */
 		i = snprintf(buf, sizeof(buf), "%s/%s", atom->CATEGORY, atom->PN);
-		if (uslot[0] != '\0' && i <= (int)sizeof(buf))
+		if (uslot[0] != '\0' && i < (int)sizeof(buf))
 			i += snprintf(buf + i, sizeof(buf) - i, ":%s", atom->SLOT);
-		if (urepo && i <= (int)sizeof(buf))
+		if (urepo && i < (int)sizeof(buf))
 			i += snprintf(buf + i, sizeof(buf) - i, "::%s", atom->REPO);
 
 		/* exact match: CAT/PN[:SLOT][::REPO] */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:09 UTC (permalink / raw
  To: gentoo-commits

commit:     4bcd96dfe33a44dd90549510528db1310cfb1266
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 18:38:00 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 18:38:00 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4bcd96df

qlop: fix Coverity 206547 Out-of-bounds write

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qlop.c b/qlop.c
index 9fa1387..8c166e2 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1129,7 +1129,7 @@ static array_t *probe_proc(array_t *atoms)
 						continue;
 					snprintf(npath, sizeof(npath), "/proc/%s/%s/%s",
 							pid, subdir, d->d_name);
-					rpathlen = readlink(npath, rpath, sizeof(rpath));
+					rpathlen = readlink(npath, rpath, sizeof(rpath) - 1);
 					if (rpathlen <= 0)
 						continue;
 					rpath[rpathlen] = '\0';


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:09 UTC (permalink / raw
  To: gentoo-commits

commit:     84559890f05ae01e3360922c05cafca2fa8d23ea
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 18:06:37 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 18:06:37 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=84559890

qdepends: fix Coverity 206553 Logically dead code

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qdepends.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index 6f580a9..865605e 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -162,7 +162,7 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 		depstr = i == 1<<0 ? tree_pkg_meta_get(pkg_ctx, DEPEND) :
 				 i == 1<<1 ? tree_pkg_meta_get(pkg_ctx, RDEPEND) :
 				 i == 1<<2 ? tree_pkg_meta_get(pkg_ctx, PDEPEND) :
-				 i == 1<<3 ? tree_pkg_meta_get(pkg_ctx, BDEPEND) : NULL;
+				             tree_pkg_meta_get(pkg_ctx, BDEPEND);
 		if (depstr == NULL)
 			continue;
 		dep_tree = dep_grow_tree(depstr);
@@ -180,8 +180,7 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 					depstr = i == 1<<0 ? tree_pkg_meta_get(vpkg, DEPEND) :
 							 i == 1<<1 ? tree_pkg_meta_get(vpkg, RDEPEND) :
 							 i == 1<<2 ? tree_pkg_meta_get(vpkg, PDEPEND) :
-							 i == 1<<3 ? tree_pkg_meta_get(vpkg, BDEPEND) :
-							 NULL;
+							             tree_pkg_meta_get(vpkg, BDEPEND);
 					if (depstr != NULL) {
 						dep_node *dep_vdb = dep_grow_tree(depstr);
 						if (dep_vdb != NULL)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 19:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 19:09 UTC (permalink / raw
  To: gentoo-commits

commit:     852a86fca809389e7bd0b2812dd12760aea3ce38
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 19:01:44 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 19:01:44 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=852a86fc

qkeyword: fix Coverity 206543 Sizeof not portable

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qkeyword.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qkeyword.c b/qkeyword.c
index 9c76858..7a60022 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -765,7 +765,7 @@ qkeyword_load_arches(const char *overlay)
 	list_set(archs, &archlist);
 
 	/* sort so the output makes more 'sense' */
-	qsort(archlist, archlist_count, sizeof(char **), keyword_sort);
+	qsort(archlist, archlist_count, sizeof(archlist[0]), keyword_sort);
 
 	fclose(fp);
  done:


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 16:40 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 16:40 UTC (permalink / raw
  To: gentoo-commits

commit:     68e6854a19a5a42b7b1ac62e6ea3b96baaaf5699
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 16:40:24 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 16:40:24 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=68e6854a

qmanifest: fix Coverity 206557 Argument cannot be negative

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qmanifest.c b/qmanifest.c
index de4bf9b..bd04b96 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -1770,8 +1770,10 @@ qmanifest_main(int argc, char **argv)
 		}
 	}
 
-	if ((curdirfd = open(".", O_RDONLY)) < 0)
+	if ((curdirfd = open(".", O_RDONLY)) < 0) {
 		warn("cannot open current directory?!? %s\n", strerror(errno));
+		return EXIT_FAILURE;
+	}
 
 	ret = EXIT_SUCCESS;
 	argc -= optind;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 16:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 16:37 UTC (permalink / raw
  To: gentoo-commits

commit:     5996186e46b4ae4156b2b9bf4ebc022e7039a02f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 16:36:56 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 16:36:56 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5996186e

qmanifest: fix Coverity 206559 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/qmanifest.c b/qmanifest.c
index d9452a4..de4bf9b 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -570,6 +570,7 @@ generate_dir(const char *dir, enum type_manifest mtype)
 	} else if (mtype == CATEGORY_MANIFEST) {
 		const char *mfest;
 		gzFile mf;
+		const char *ret = str_manifest_gz;
 
 		snprintf(path, sizeof(path), "%s/%s", dir, str_manifest_gz);
 		if ((mf = gzopen(path, "wb9")) == NULL) {
@@ -596,13 +597,13 @@ generate_dir(const char *dir, enum type_manifest mtype)
 					if (mfest == NULL) {
 						fprintf(stderr, "generating Manifest for %s failed!\n",
 								path);
-						gzclose(mf);
-						return NULL;
+						tv[0].tv_sec = 0;
+						ret = NULL;
+					} else {
+						snprintf(path, sizeof(path), "%s/%s",
+								dentries[i], mfest);
+						write_hashes(tv, dir, path, "MANIFEST", NULL, mf);
 					}
-
-					snprintf(path, sizeof(path), "%s/%s",
-							dentries[i], mfest);
-					write_hashes(tv, dir, path, "MANIFEST", NULL, mf);
 				} else if (s.st_mode & S_IFREG) {
 					write_hashes(tv, dir, dentries[i], "DATA", NULL, mf);
 				} /* ignore other "things" (like symlinks) as they
@@ -624,7 +625,7 @@ generate_dir(const char *dir, enum type_manifest mtype)
 			utimes(dir, tv);
 		}
 
-		return str_manifest_gz;
+		return ret;
 	} else if (mtype == EBUILD_MANIFEST) {
 		char newmanifest[8192];
 		FILE *m;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 16:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 16:37 UTC (permalink / raw
  To: gentoo-commits

commit:     1ebb60136546f233982386df561f4a83cb4d434c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 16:00:34 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 16:00:34 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1ebb6013

qmanifest: fix Coverity 206565 Unchecked return value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/qmanifest.c b/qmanifest.c
index 597357b..d9452a4 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -220,8 +220,8 @@ write_hashes(
 
 	if (m != NULL)
 		fwrite(data, len, 1, m);
-	if (gm != NULL)
-		gzwrite(gm, data, len);
+	if (gm != NULL && gzwrite(gm, data, len) == 0)
+		fprintf(stderr, "failed to write to compressed stream\n");
 }
 
 /**
@@ -430,7 +430,11 @@ generate_dir(const char *dir, enum type_manifest mtype)
 				"IGNORE lost+found\n"
 				"IGNORE packages\n"
 				"IGNORE snapshots\n");
-		gzwrite(mf, path, len);
+		if (gzwrite(mf, path, len) == 0) {
+			fprintf(stderr, "failed to write to file '%s/%s': %s\n",
+					dir, str_manifest_files_gz, strerror(errno));
+			return NULL;
+		}
 
 		if (list_dir(&dentries, &dentrieslen, dir) != 0)
 			return NULL;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 12:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 12:37 UTC (permalink / raw
  To: gentoo-commits

commit:     701bb91531e33d6683b1eff35992e188f687ed54
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 12:05:28 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 12:05:28 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=701bb915

qpkg: fix Coverity 206566 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qpkg.c b/qpkg.c
index b210b09..562f9af 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -123,6 +123,7 @@ qpkg_clean(char *dirp)
 			if (!pretend)
 				unlink(buf);
 		}
+		atom_implode(atom);
 	}
 
 	xarrayfree_int(bins);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 12:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 12:37 UTC (permalink / raw
  To: gentoo-commits

commit:     f47f9880d7266d2e87b2530ea777e4a104ee1a71
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 12:20:54 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 12:20:54 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f47f9880

main.h: attempt fix for Coverity 206563 Unintended sign extension

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/main.h b/main.h
index a7fe725..35b95ab 100644
--- a/main.h
+++ b/main.h
@@ -64,10 +64,10 @@ extern const char *argv0;
 #endif
 
 #define READ_BE_INT32(P) \
-	((((unsigned char *)(P))[0] << 24) | \
-	 (((unsigned char *)(P))[1] << 16) | \
-	 (((unsigned char *)(P))[2] << 8 ) | \
-	 (((unsigned char *)(P))[3]))
+	(((unsigned int)((unsigned char *)(P))[0] << 24) | \
+	 ((unsigned int)((unsigned char *)(P))[1] << 16) | \
+	 ((unsigned int)((unsigned char *)(P))[2] << 8 ) | \
+	 ((unsigned int)((unsigned char *)(P))[3]))
 #define WRITE_BE_INT32(P,I) \
 { \
 	((unsigned char *)(P))[0] = (I & 0xff000000) >> 24; \


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 12:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 12:37 UTC (permalink / raw
  To: gentoo-commits

commit:     ea744763eb0df6693068d85ea24fa47577c0da0f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 12:14:44 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 12:14:44 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ea744763

quse: fix Coverity 206564 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 quse.c | 15 ++++++++++-----
 1 file changed, 10 insertions(+), 5 deletions(-)

diff --git a/quse.c b/quse.c
index 4a8b89b..f88e298 100644
--- a/quse.c
+++ b/quse.c
@@ -289,19 +289,24 @@ quse_search_profiles_desc(
 			continue;
 
 		namelen = strlen(de->d_name);
-		if (namelen <= 5 || strcmp(de->d_name + namelen - 5, ".desc") != 0)
-			return false;
+		if (namelen <= 5 || strcmp(de->d_name + namelen - 5, ".desc") != 0) {
+			ret = false;
+			break;
+		}
 
 		snprintf(_quse_getline_buf, _quse_getline_buflen,
 				"profiles/desc/%s", de->d_name);
 		dfd = openat(portdirfd, _quse_getline_buf, O_RDONLY | O_CLOEXEC);
-		if (dfd == -1)
-			return false;
+		if (dfd == -1) {
+			ret = false;
+			break;
+		}
 
 		f = fdopen(dfd, "r");
 		if (f == NULL) {
 			close(fd);
-			return false;
+			ret = false;
+			break;
 		}
 
 		/* remove trailing .desc */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 12:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 12:37 UTC (permalink / raw
  To: gentoo-commits

commit:     940bf3ddfd092d479edb68e4875dee20d3812459
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 12:23:38 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 12:23:38 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=940bf3dd

qmerge: fix Coverity 206561 Resource leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qmerge.c b/qmerge.c
index e0efc17..ffde1ee 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1069,6 +1069,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 						if (strlen(resolved) < 1) {
 							warn("Cant find a binpkg for %s from rdepend(%s)",
 									name, pkg->RDEPEND);
+							atom_implode(subatom);
 							continue;
 						}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 12:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 12:37 UTC (permalink / raw
  To: gentoo-commits

commit:     733c84b716edf64e700011795266cfa6d57ce311
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 12:02:31 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 12:02:31 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=733c84b7

qmanifest: fix Coverity 206567 Unused value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/qmanifest.c b/qmanifest.c
index bfc5e55..c1477cb 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -365,7 +365,6 @@ parse_layout_conf(const char *path)
 			last_nl++;  /* skip \n */
 			len = last_nl - buf;
 			memmove(buf, last_nl, len);
-			last_nl = buf;
 		} else {
 			/* skip too long line */
 			len = 0;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 12:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 12:37 UTC (permalink / raw
  To: gentoo-commits

commit:     2706d0f789d2980bb8f82ab677957b1d32d0dfad
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 12:10:25 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 12:10:25 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2706d0f7

qmanifest: fix Coverity 206565 Unchecked return value

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/qmanifest.c b/qmanifest.c
index c1477cb..597357b 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -530,7 +530,11 @@ generate_dir(const char *dir, enum type_manifest mtype)
 					"IGNORE timestamp.chk\n"
 					"IGNORE timestamp.commit\n"
 					"IGNORE timestamp.x\n");
-			gzwrite(mf, path, len);
+			if (gzwrite(mf, path, len) == 0) {
+				fprintf(stderr, "failed to write to file '%s/%s': %s\n",
+						dir, str_manifest_gz, strerror(errno));
+				return NULL;
+			}
 		}
 
 		if (list_dir(&dentries, &dentrieslen, dir) != 0)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 12:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 12:37 UTC (permalink / raw
  To: gentoo-commits

commit:     6375888fb82710a5f158dd84383a0b1e8d41299f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 12:00:17 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 12:00:17 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6375888f

qgrep: fix Coverity 206568 Logically dead code

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qgrep.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/qgrep.c b/qgrep.c
index 019b0b6..699f35b 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -240,10 +240,7 @@ qgrep_grepat(int fd, const char *file, const char *label,
 		return status;
 
 	count = 0;
-	/* if there have been some matches already, then a
-	 * separator will be needed */
-	need_separator =
-		!status && (a->num_lines_before || a->num_lines_after);
+	need_separator = 0;
 	/* whatever is in the circular buffers list is no more a
 	 * valid context */
 	qgrep_buf_list_invalidate(a->buf_list);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-19 12:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-19 12:37 UTC (permalink / raw
  To: gentoo-commits

commit:     06458fcdfeb3d0b267b18dba043028d6accf3b0d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan 19 11:42:05 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan 19 11:42:05 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=06458fcd

qcheck: address Coverity 206997 Insecure temporary file

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcheck.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/qcheck.c b/qcheck.c
index 1d8521a..72a68a9 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -105,7 +105,12 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	/* Open contents_update, if needed */
 	if (state->qc_update) {
 		char tempfile[] = "qcheck-tmp-XXXXXX";
-		int fd = mkstemp(tempfile);
+		mode_t mask;
+		int fd;
+
+		mask = umask(0077);
+		fd = mkstemp(tempfile);
+		umask(mask);
 		if (fd == -1 || (fp_contents_update = fdopen(fd, "w+")) == NULL) {
 			if (fd >= 0)
 				close(fd);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-18 13:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-18 13:09 UTC (permalink / raw
  To: gentoo-commits

commit:     318b6d73490e7c3b9392922bcb643bb83548d269
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 18 13:08:07 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan 18 13:08:07 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=318b6d73

main: avoid matching commented out lines in ini-files

When a = is present in a commented out part of a line, ignore it.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/main.c b/main.c
index 8ac4fa8..cfaa9af 100644
--- a/main.c
+++ b/main.c
@@ -667,6 +667,7 @@ read_one_repos_conf(const char *repos_conf, char **primary)
 			} else if (*q == '#') {
 				do_trim = true;
 				*q = '\0';
+				e = NULL;
 				r = q - 1;
 			} else {
 				if (*q == '=')


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-06  8:03 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-06  8:03 UTC (permalink / raw
  To: gentoo-commits

commit:     0e6d9d14f58fc388b4dca9ce19845f69a553b957
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  6 08:02:31 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jan  6 08:02:31 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0e6d9d14

quse: fix new Coverity complaints

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 quse.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/quse.c b/quse.c
index dca2f1c..4a8b89b 100644
--- a/quse.c
+++ b/quse.c
@@ -432,7 +432,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	}
 
 	if (!state->do_licence) {
-		if ((q = tree_pkg_meta_get(pkg_ctx, IUSE)) == NULL)
+		if ((s = tree_pkg_meta_get(pkg_ctx, IUSE)) == NULL)
 			return 0;
 
 		if (state->do_describe) {
@@ -454,14 +454,14 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				use = add_set(p, use);
 		}
 	} else {
-		if ((q = tree_pkg_meta_get(pkg_ctx, LICENSE)) == NULL)
+		if ((s = tree_pkg_meta_get(pkg_ctx, LICENSE)) == NULL)
 			return 0;
 	}
 
 	maxlen = 0;
 	cnt = 0;
 	match = false;
-	p = q;  /* set to IUSE or LICENSE above */
+	p = q = s;  /* set to IUSE or LICENSE above */
 	buf[0] = '\0';
 	v = buf;
 	w = buf + sizeof(buf);
@@ -631,7 +631,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 	if (use != NULL)
 		free_set(use);
-	if (state->do_describe)
+	if (state->do_describe && !state->do_licence)
 		close(portdirfd);
 
 	return EXIT_SUCCESS;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-06  7:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-06  7:36 UTC (permalink / raw
  To: gentoo-commits

commit:     b7a9406bec657d4929b85c322d50440b48220fcf
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jan  6 07:35:38 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jan  6 07:35:38 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b7a9406b

qcheck/quse: address Coverity concerns

- it considers tmpfile() unsafe (?)
- help it to see a variable was checked for NULL before

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcheck.c | 9 +++++++--
 quse.c   | 7 +++----
 2 files changed, 10 insertions(+), 6 deletions(-)

diff --git a/qcheck.c b/qcheck.c
index 65cc2d1..1d8521a 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -104,11 +104,16 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 	/* Open contents_update, if needed */
 	if (state->qc_update) {
-		fp_contents_update = tmpfile();
-		if (fp_contents_update == NULL) {
+		char tempfile[] = "qcheck-tmp-XXXXXX";
+		int fd = mkstemp(tempfile);
+		if (fd == -1 || (fp_contents_update = fdopen(fd, "w+")) == NULL) {
+			if (fd >= 0)
+				close(fd);
 			warnp("unable to temp file");
 			return EXIT_FAILURE;
 		}
+		/* like tmpfile() does, but Coverity thinks it is unsafe */
+		unlink(tempfile);
 	}
 
 	if (!state->chk_config_protect) {

diff --git a/quse.c b/quse.c
index 358d9e0..dca2f1c 100644
--- a/quse.c
+++ b/quse.c
@@ -432,7 +432,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	}
 
 	if (!state->do_licence) {
-		if (tree_pkg_meta_get(pkg_ctx, IUSE) == NULL)
+		if ((q = tree_pkg_meta_get(pkg_ctx, IUSE)) == NULL)
 			return 0;
 
 		if (state->do_describe) {
@@ -454,15 +454,14 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				use = add_set(p, use);
 		}
 	} else {
-		if (tree_pkg_meta_get(pkg_ctx, LICENSE) == NULL)
+		if ((q = tree_pkg_meta_get(pkg_ctx, LICENSE)) == NULL)
 			return 0;
 	}
 
 	maxlen = 0;
 	cnt = 0;
 	match = false;
-	q = p = state->do_licence ?
-		tree_pkg_meta_get(pkg_ctx, LICENSE) : tree_pkg_meta_get(pkg_ctx, IUSE);
+	p = q;  /* set to IUSE or LICENSE above */
 	buf[0] = '\0';
 	v = buf;
 	w = buf + sizeof(buf);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-05 16:08 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-05 16:08 UTC (permalink / raw
  To: gentoo-commits

commit:     dbccc4073df47013409eec4e333f32aca80383c4
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  5 14:03:27 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan  5 14:03:27 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=dbccc407

qlist: use tree_pkg_meta_get iso tree_pkg_vdb_eat

tree_pkg_meta_get also works for binpkgs (-k)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlist.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/qlist.c b/qlist.c
index cc4c6be..506e3e5 100644
--- a/qlist.c
+++ b/qlist.c
@@ -104,8 +104,6 @@ umapstr(char display, tree_pkg_ctx *pkg_ctx)
 	char *bufp = _umapstr_buf;
 	char *use = NULL;
 	char *iuse = NULL;
-	size_t use_len;
-	size_t iuse_len;
 	int use_argc = 0;
 	int iuse_argc = 0;
 	char **use_argv = NULL;
@@ -118,11 +116,11 @@ umapstr(char display, tree_pkg_ctx *pkg_ctx)
 	if (!display)
 		return bufp;
 
-	tree_pkg_vdb_eat(pkg_ctx, "USE", &use, &use_len);
-	if (!use[0])
+	use = tree_pkg_meta_get(pkg_ctx, USE);
+	if (use == NULL || *use == '\0')
 		return bufp;
-	tree_pkg_vdb_eat(pkg_ctx, "IUSE", &iuse, &iuse_len);
-	if (!iuse[0])
+	iuse = tree_pkg_meta_get(pkg_ctx, IUSE);
+	if (iuse == NULL || *iuse == '\0')
 		return bufp;
 
 	/* strip out possible leading +/- flags in IUSE */
@@ -167,8 +165,6 @@ umapstr(char display, tree_pkg_ctx *pkg_ctx)
 
 	freeargv(iuse_argc, iuse_argv);
 	freeargv(use_argc, use_argv);
-	free(iuse);
-	free(use);
 
 	return _umapstr_buf;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-05 16:08 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-05 16:08 UTC (permalink / raw
  To: gentoo-commits

commit:     1be0564bc86096d1d000a4a04ddc5e8444a3f3fb
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  5 15:20:00 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan  5 15:59:23 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1be0564b

qcheck: move away from tree_pkg_vdb_eat, make CONTENTS updating cleaner

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcheck.c | 89 +++++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 49 insertions(+), 40 deletions(-)

diff --git a/qcheck.c b/qcheck.c
index 59f35e2..65cc2d1 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -17,6 +17,7 @@
 
 #include "atom.h"
 #include "contents.h"
+#include "copy_file.h"
 #include "md5_sha1_sum.h"
 #include "prelink.h"
 #include "tree.h"
@@ -73,33 +74,39 @@ static int
 qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 {
 	struct qcheck_opt_state *state = priv;
-	FILE *fp_contents, *fp_contents_update;
-	size_t num_files, num_files_ok, num_files_unknown, num_files_ignored;
-	char *buffer, *line;
-	size_t linelen;
-	struct stat st, cst;
-	int cp_argc, cpm_argc;
-	char **cp_argv, **cpm_argv;
+	FILE *fp_contents_update;
+	size_t num_files;
+	size_t num_files_ok;
+	size_t num_files_unknown;
+	size_t num_files_ignored;
+	struct stat st;
+	char *buffer;
+	char *line;
+	char *savep;
+	int cp_argc;
+	int cpm_argc;
+	char **cp_argv;
+	char **cpm_argv;
 	depend_atom *atom;
 
 	fp_contents_update = NULL;
 
 	/* Open contents */
-	fp_contents = tree_pkg_vdb_fopenat_ro(pkg_ctx, "CONTENTS");
-	if ((fp_contents = tree_pkg_vdb_fopenat_ro(pkg_ctx, "CONTENTS")) == NULL)
-		return EXIT_SUCCESS;
+	line = tree_pkg_meta_get(pkg_ctx, CONTENTS);
+	if (line == NULL)
+		return EXIT_FAILURE;
 
-	/* Open contents_update, if needed */
 	atom = tree_get_atom(pkg_ctx, false);
 	num_files = num_files_ok = num_files_unknown = num_files_ignored = 0;
 	qcprintf("%sing %s ...\n",
 		(state->qc_update ? "Updat" : "Check"),
 		atom_format(state->fmt, atom));
+
+	/* Open contents_update, if needed */
 	if (state->qc_update) {
-		fp_contents_update = tree_pkg_vdb_fopenat_rw(pkg_ctx, "CONTENTS~");
+		fp_contents_update = tmpfile();
 		if (fp_contents_update == NULL) {
-			fclose(fp_contents);
-			warnp("unable to fopen(%s/%s, w)", atom->P, "CONTENTS~");
+			warnp("unable to temp file");
 			return EXIT_FAILURE;
 		}
 	}
@@ -109,14 +116,13 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 		makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
 	}
 
-	buffer = line = NULL;
-	while (getline(&line, &linelen, fp_contents) != -1) {
+	buffer = NULL;
+	for (; (line = strtok_r(line, "\n", &savep)) != NULL; line = NULL) {
 		contents_entry *entry;
 		free(buffer);
 		buffer = xstrdup(line);
 
 		entry = contents_parse_line(line);
-
 		if (!entry)
 			continue;
 
@@ -148,7 +154,7 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				--num_files;
 				++num_files_ignored;
 				if (state->qc_update)
-					fputs(buffer, fp_contents_update);
+					fprintf(fp_contents_update, "%s\n", buffer);
 			}
 			continue;
 		}
@@ -179,7 +185,7 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 			--num_files;
 			++num_files_ignored;
 			if (state->qc_update)
-				fputs(buffer, fp_contents_update);
+				fprintf(fp_contents_update, "%s\n", buffer);
 
 			continue;
 		}
@@ -211,7 +217,7 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 					--num_files;
 					++num_files_ignored;
 					if (state->qc_update)
-						fputs(buffer, fp_contents_update);
+						fprintf(fp_contents_update, "%s\n", buffer);
 				}
 				continue;
 			}
@@ -229,7 +235,7 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				free(f_digest);
 
 				if (state->qc_update)
-					fputs(buffer, fp_contents_update);
+					fprintf(fp_contents_update, "%s\n", buffer);
 
 				if (verbose)
 					qcprintf(" %sPERM %4o%s: %s\n",
@@ -264,7 +270,7 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 					--num_files;
 					++num_files_ignored;
 					if (state->qc_update)
-						fputs(buffer, fp_contents_update);
+						fprintf(fp_contents_update, "%s\n", buffer);
 				}
 
 				free(f_digest);
@@ -299,11 +305,10 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 		/* Success! */
 		if (state->qc_update)
-			fputs(buffer, fp_contents_update);
+			fprintf(fp_contents_update, "%s\n", buffer);
 
 		num_files_ok++;
 	}
-	free(line);
 	free(buffer);
 
 	if (!state->chk_config_protect) {
@@ -312,27 +317,31 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	}
 
 	if (state->qc_update) {
-		int fd_contents = fileno(fp_contents);
-		int fd_update = fileno(fp_contents_update);
+		int fd_contents;
+		FILE *fp_contents;
 
-		/* copy original ownership and mode */
-		if (fstat(fd_contents, &cst) == 0) {
-			if (fchown(fd_update, cst.st_uid, cst.st_gid)) {
-				/* meh */;
-			}
-			if (fchmod(fd_update, cst.st_mode)) {
-				/* meh */;
-			}
+		/* O_TRUNC truncates, but file owner and mode are unchanged */
+		fd_contents = openat(pkg_ctx->fd, "CONTENTS", O_WRONLY | O_TRUNC);
+		if (fd_contents < 0 ||
+				(fp_contents = fdopen(fd_contents, "w")) == NULL)
+		{
+			fclose(fp_contents_update);
+			warn("could not open CONTENTS for writing");
+			return EXIT_FAILURE;
 		}
+
+		/* rewind tempfile */
+		fseek(fp_contents_update, 0, SEEK_SET);
+
+		copy_file(fp_contents_update, fp_contents);
+
 		fclose(fp_contents_update);
-		if (renameat(pkg_ctx->fd, "CONTENTS~", pkg_ctx->fd, "CONTENTS"))
-			unlinkat(pkg_ctx->fd, "CONTENTS~", 0);
-		if (!verbose) {
-			fclose(fp_contents);
+		fclose(fp_contents);
+
+		if (!verbose)
 			return EXIT_SUCCESS;
-		}
 	}
-	fclose(fp_contents);
+
 	if (state->bad_only && num_files_ok != num_files)
 		printf("%s\n", atom_format(state->fmt, atom));
 	qcprintf("  %2$s*%1$s %3$s%4$zu%1$s out of %3$s%5$zu%1$s file%6$s are good",


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-05 16:08 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-05 16:08 UTC (permalink / raw
  To: gentoo-commits

commit:     a2f018de47c7c42d469667fb4325374ce9f2fe6a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  5 14:20:52 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan  5 15:22:09 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a2f018de

qmerge: move away from tree_pkg_vdb_eat in favour of tree_pkg_meta_get

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 44 +++++++++++++++++++-------------------------
 1 file changed, 19 insertions(+), 25 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 464f45f..e0efc17 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1425,19 +1425,16 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 		int cp_argc, char **cp_argv, int cpm_argc, char **cpm_argv)
 {
 	tree_cat_ctx *cat_ctx = pkg_ctx->cat_ctx;
-	size_t buflen;
-	static char *phases;
-	static size_t phases_len;
-	char *eprefix = NULL;
-	size_t eprefix_len = 0;
+	char *phases;
+	char *eprefix;
+	size_t eprefix_len;
 	const char *T;
 	char *buf;
-	FILE *fp;
-	int ret, portroot_fd;
+	char *savep;
+	int portroot_fd;
 	llist_char *dirs = NULL;
 	bool unmerge_config_protected;
 
-	ret = 1;
 	buf = phases = NULL;
 	T = "${PWD}/temp";
 
@@ -1448,28 +1445,31 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 		return 0;
 
 	/* First get a handle on the things to clean up */
-	fp = tree_pkg_vdb_fopenat_ro(pkg_ctx, "CONTENTS");
-	if (fp == NULL)
-		return ret;
+	buf = tree_pkg_meta_get(pkg_ctx, CONTENTS);
+	if (buf == NULL)
+		return 1;
 
 	portroot_fd = cat_ctx->ctx->portroot_fd;
 
 	/* Then execute the pkg_prerm step */
 	if (!pretend) {
-		tree_pkg_vdb_eat(pkg_ctx, "DEFINED_PHASES", &phases, &phases_len);
-		mkdirat(pkg_ctx->fd, "temp", 0755);
-		pkg_run_func_at(pkg_ctx->fd, ".", phases, "pkg_prerm", T, T);
+		phases = tree_pkg_meta_get(pkg_ctx, DEFINED_PHASES);
+		if (phases != NULL) {
+			mkdirat(pkg_ctx->fd, "temp", 0755);
+			pkg_run_func_at(pkg_ctx->fd, ".", phases, "pkg_prerm", T, T);
+		}
 	}
 
-	if (!tree_pkg_vdb_eat(pkg_ctx, "EPREFIX", &eprefix, &eprefix_len))
+	eprefix = tree_pkg_meta_get(pkg_ctx, EPREFIX);
+	if (eprefix == NULL)
 		eprefix_len = 0;
-	if (eprefix != NULL)
-		free(eprefix);
+	else
+		eprefix_len = strlen(eprefix);
 
 	unmerge_config_protected =
 		strstr(features, "config-protect-if-modified") != NULL;
 
-	while (getline(&buf, &buflen, fp) != -1) {
+	for (; (buf = strtok_r(buf, "\n", &savep)) != NULL; buf = NULL) {
 		bool del;
 		contents_entry *e;
 		char zing[20];
@@ -1567,8 +1567,6 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 		}
 	}
 
-	fclose(fp);
-
 	/* Then remove all dirs in reverse order */
 	while (dirs != NULL) {
 		llist_char *list = dirs;
@@ -1596,11 +1594,7 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 		unlinkat(cat_ctx->ctx->tree_fd, cat_ctx->name, AT_REMOVEDIR);
 	}
 
-	ret = 0;
-	free(phases);
-	free(buf);
-
-	return ret;
+	return 0;
 }
 
 static int


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-05 13:28 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-05 13:28 UTC (permalink / raw
  To: gentoo-commits

commit:     578aa007d1a1517bc4f96910ea97464b4f4c1fe4
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jan  5 13:25:40 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jan  5 13:25:40 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=578aa007

TODO: add libq/tree item

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/TODO.md b/TODO.md
index ded7553..f6326b8 100644
--- a/TODO.md
+++ b/TODO.md
@@ -17,6 +17,12 @@
 - check timestamps in libq/tree for choosing which method to take:
 	- ignore metadata when ebuild is modified
 	- add some method to skip these checks and assume everything is right
+- add interface to retrieve a list/set of atoms from a tree
+  - pkg\_ctx for each found match, NULL otherwise
+  - more efficient than traversing the entire tree every time (scandir
+    or parsing Packages)
+  - cached, such that repeated matches for the same thing are served off
+    the cache (set), as frequently happens in dependency calculations
 
 # qmerge
 - dep resolver needs spanktastic love.


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-04 20:02 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-04 20:02 UTC (permalink / raw
  To: gentoo-commits

commit:     c7403dd14a376e143e03ad61654e843a05f3f69a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  4 20:02:10 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan  4 20:02:10 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c7403dd1

main: try to work around different mtime/mtim struct stat fields

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.h | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/main.h b/main.h
index 68b9795..a7fe725 100644
--- a/main.h
+++ b/main.h
@@ -56,6 +56,13 @@ extern const char *argv0;
 # define MAX(x, y) ((x) < (y) ? (y) : (x))
 #endif
 
+#ifdef HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC
+# define st_mtim st_mtimespec
+#endif
+#ifdef HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC
+# define st_mtim st_mtim.st__tim
+#endif
+
 #define READ_BE_INT32(P) \
 	((((unsigned char *)(P))[0] << 24) | \
 	 (((unsigned char *)(P))[1] << 16) | \


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-04 19:48 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-04 19:48 UTC (permalink / raw
  To: gentoo-commits

commit:     123d916b0ce9eaeb53c2d06ad6504729af8688ee
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  4 13:39:53 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan  4 13:39:53 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=123d916b

qkeyword: avoid NULL derefence if strtok_r's initial call returns NULL

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qkeyword.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/qkeyword.c b/qkeyword.c
index 0078fda..9c76858 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -190,13 +190,13 @@ read_keywords(char *s, int *keywords)
 	if (!slen)
 		return 0;
 
-	arch = strtok_r(s, delim, &savep);
-	do {
+	while ((arch = strtok_r(s, delim, &savep)) != NULL) {
+		s = NULL;  /* for strtok_r */
 		i = decode_arch(arch);
 		if (i == -1)
 			continue;
 		keywords[i] = decode_status(arch[0]);
-	} while ((arch = strtok_r(NULL, delim, &savep)));
+	}
 
 	return 0;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-04 13:28 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-04 13:28 UTC (permalink / raw
  To: gentoo-commits

commit:     2742f0e06c9d79af720231968dfd91bad5c69a73
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  4 13:28:25 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan  4 13:28:25 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2742f0e0

qkeyword/qlist: replace strtok by strtok_r

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md    | 5 +++--
 qkeyword.c | 8 +++++---
 qlist.c    | 5 +++--
 3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/TODO.md b/TODO.md
index e401123..1de8b5f 100644
--- a/TODO.md
+++ b/TODO.md
@@ -12,8 +12,6 @@
 - tree\_get\_atoms should return atoms iso string set, needs a rewrite
   to use foreach\_pkg and get\_atom -- set is ready for storing objects
   now
-- replace all strtok by strtok\_r, because the latter is already used,
-  so we can
 - parse package.accept\_keywords such that we can provide the latest
   "available" version like Portage
 - check timestamps in libq/tree for choosing which method to take:
@@ -78,3 +76,6 @@
   guestimate alternative to current time jumping
 - multiple files support -- current opinion: don't do it
 - compressed file support, use guessing support from qmerge?
+
+# qfile
+- stop searching when absolute path argument was found?

diff --git a/qkeyword.c b/qkeyword.c
index 2121d51..0078fda 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -169,7 +169,9 @@ print_keywords(const char *category, const char *ebuild, int *keywords)
 static int
 read_keywords(char *s, int *keywords)
 {
-	char *arch, delim[2] = { ' ', '\0' };
+	char *arch;
+	char delim[2] = { ' ', '\0' };
+	char *savep;
 	size_t slen;
 	size_t a;
 	int i;
@@ -188,13 +190,13 @@ read_keywords(char *s, int *keywords)
 	if (!slen)
 		return 0;
 
-	arch = strtok(s, delim);
+	arch = strtok_r(s, delim, &savep);
 	do {
 		i = decode_arch(arch);
 		if (i == -1)
 			continue;
 		keywords[i] = decode_status(arch[0]);
-	} while ((arch = strtok(NULL, delim)));
+	} while ((arch = strtok_r(NULL, delim, &savep)));
 
 	return 0;
 }

diff --git a/qlist.c b/qlist.c
index 12d63f8..cc4c6be 100644
--- a/qlist.c
+++ b/qlist.c
@@ -334,6 +334,7 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	int i;
 	char *contents;
 	char *line;
+	char *savep;
 	depend_atom *atom;
 
 	/* see if this cat/pkg is requested */
@@ -362,10 +363,10 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	if ((contents = tree_pkg_meta_get(pkg_ctx, CONTENTS)) == NULL)
 		return 1;
 
-	while ((line = strtok(contents, "\n")) != NULL) {
+	while ((line = strtok_r(contents, "\n", &savep)) != NULL) {
 		contents_entry *e;
 
-		contents = NULL;  /* for strtok */
+		contents = NULL;  /* for strtok_r */
 
 		e = contents_parse_line(line);
 		if (!e)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-04 10:44 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-04 10:44 UTC (permalink / raw
  To: gentoo-commits

commit:     911922f8c776ac079c660244e3678e94837c2f1e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  4 10:44:23 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan  4 10:44:23 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=911922f8

travis: follow libressl activation instructions on macOS

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index 577c2b0..bc12463 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -29,6 +29,8 @@ matrix:
     - compiler: clang
       os: osx
       env:
+        - LDFLAGS="-L/usr/local/opt/libressl/lib"
+        - CPPFLAGS="-I/usr/local/opt/libressl/include"
         - PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:$PATH"
         - PATH="$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH"
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-04 10:38 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-04 10:38 UTC (permalink / raw
  To: gentoo-commits

commit:     6ef0d9acaef2f0bccebc0d6047bfdd4cb3a158e4
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  4 10:37:54 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan  4 10:37:54 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6ef0d9ac

travis: install libressl on macOS to build qmanifest

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index aafcffb..577c2b0 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -49,6 +49,7 @@ addons:
     - gnu-sed
     - coreutils
     - bash
+    - libressl
     #update: true
 
 before_install:


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-04 10:27 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-04 10:27 UTC (permalink / raw
  To: gentoo-commits

commit:     47ecc9a4f9e21b51d82efc42ee9cc7cca23209c3
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  4 10:26:06 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan  4 10:26:06 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=47ecc9a4

travis: try installing bash on macOS

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index d9d0c22..aafcffb 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -48,6 +48,7 @@ addons:
     - gnupg
     - gnu-sed
     - coreutils
+    - bash
     #update: true
 
 before_install:


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-04 10:20 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-04 10:20 UTC (permalink / raw
  To: gentoo-commits

commit:     e2f8178c436c471d2d7bda819c15fb73e263146a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jan  4 10:20:36 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jan  4 10:20:36 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e2f8178c

travis: add coreutils to path on macOS

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index 054958b..d9d0c22 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -30,6 +30,7 @@ matrix:
       os: osx
       env:
         - PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:$PATH"
+        - PATH="$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH"
 
 env:
   global:


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-03 15:05 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-03 15:05 UTC (permalink / raw
  To: gentoo-commits

commit:     2b76d24d2b793ebd859bd3103b48fd3601067c91
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  3 15:04:15 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jan  3 15:04:15 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2b76d24d

travis: install GNU coreutils on macOS for sane touch

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index 33f84ed..054958b 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -46,6 +46,7 @@ addons:
     - gpgme
     - gnupg
     - gnu-sed
+    - coreutils
     #update: true
 
 before_install:


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-03 14:58 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-03 14:58 UTC (permalink / raw
  To: gentoo-commits

commit:     7fb16f32ac1c00be434828a218b826b07c527017
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  3 14:58:16 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jan  3 14:58:16 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7fb16f32

travis: get GNU sed on macOS

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.travis.yml b/.travis.yml
index 981cd4d..33f84ed 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -28,6 +28,8 @@ matrix:
         - Q_RUN_WITH_VALGRIND=1
     - compiler: clang
       os: osx
+      env:
+        - PATH="$(brew --prefix)/opt/gnu-sed/libexec/gnubin:$PATH"
 
 env:
   global:
@@ -43,6 +45,7 @@ addons:
     packages:
     - gpgme
     - gnupg
+    - gnu-sed
     #update: true
 
 before_install:


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-03 10:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-03 10:36 UTC (permalink / raw
  To: gentoo-commits

commit:     beb913d65c99d4bd3057c5b7b965ad17001cd04a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jan  3 10:34:51 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> 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 <grobian <AT> 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        - <solar@gentoo.org>
@@ -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");


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-02 20:27 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-02 20:27 UTC (permalink / raw
  To: gentoo-commits

commit:     deec7fe6c3159a04e6d65b1823bbe39c923ddd17
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 20:27:45 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 20:27:45 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=deec7fe6

main: try to clear a warning on Travis platform

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index c6ef973..9068102 100644
--- a/main.c
+++ b/main.c
@@ -641,7 +641,7 @@ read_one_repos_conf(const char *repos_conf, char **primary)
 	char *repo;
 	char *buf = NULL;
 	size_t buf_len = 0;
-	char *s;
+	char *s = NULL;  /* pacify compiler */
 	char *p;
 	char *q;
 	char *r;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-02 20:00 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-02 20:00 UTC (permalink / raw
  To: gentoo-commits

commit:     465f6695232b0f99af3fa57b8ce1141b116e9575
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 20:00:11 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 20:00:11 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=465f6695

qmerge: add closedir to plug leak

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qmerge.c b/qmerge.c
index 6d9439f..588b868 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -970,6 +970,7 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 		}
 	}
 
+	closedir(dir);
 	ret = 0;
 
  done:


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-02 15:32 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-02 15:32 UTC (permalink / raw
  To: gentoo-commits

commit:     7f610741388d8543d3d7652de4625eaa7caa6dfd
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 15:32:37 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 15:32:37 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7f610741

qcheck: fix use after free

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcheck.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qcheck.c b/qcheck.c
index 1217a8a..59f35e2 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -305,7 +305,6 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	}
 	free(line);
 	free(buffer);
-	fclose(fp_contents);
 
 	if (!state->chk_config_protect) {
 		freeargv(cp_argc, cp_argv);
@@ -328,9 +327,12 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 		fclose(fp_contents_update);
 		if (renameat(pkg_ctx->fd, "CONTENTS~", pkg_ctx->fd, "CONTENTS"))
 			unlinkat(pkg_ctx->fd, "CONTENTS~", 0);
-		if (!verbose)
+		if (!verbose) {
+			fclose(fp_contents);
 			return EXIT_SUCCESS;
+		}
 	}
+	fclose(fp_contents);
 	if (state->bad_only && num_files_ok != num_files)
 		printf("%s\n", atom_format(state->fmt, atom));
 	qcprintf("  %2$s*%1$s %3$s%4$zu%1$s out of %3$s%5$zu%1$s file%6$s are good",


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-02 15:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-02 15:09 UTC (permalink / raw
  To: gentoo-commits

commit:     e2cb79946feea84f095b5c2aef6821fc5653b6bc
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 14:10:05 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 14:10:05 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e2cb7994

qsize: update copyright

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsize.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qsize.c b/qsize.c
index 5cf7dae..617b50b 100644
--- a/qsize.c
+++ b/qsize.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-2010 Ned Ludd        - <solar@gentoo.org>


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-02 15:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-02 15:09 UTC (permalink / raw
  To: gentoo-commits

commit:     5d0261aabae596a7beb9b6879201c43a064be800
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 14:59:24 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 14:59:24 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5d0261aa

qpkg: make use of tree being able to traverse binpkg trees

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 172 ++++++++++++++++++++++++++---------------------------------------
 1 file changed, 69 insertions(+), 103 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 771241c..b210b09 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -54,115 +54,79 @@ extern char pretend;
 static char *qpkg_bindir = NULL;
 static int eclean = 0;
 
-/* checks to make sure this is a .tbz2 file. used by scandir() */
-static int
-filter_tbz2(const struct dirent *dentry)
-{
-	if (dentry->d_name[0] == '.')
-		return 0;
-	if (strlen(dentry->d_name) < 6)
-		return 0;
-	return !strcmp(".tbz2", dentry->d_name + strlen(dentry->d_name) - 5);
-}
-
-/* process a single dir for cleaning. dir can be a $PKGDIR, $PKGDIR/All/, $PKGDIR/$CAT */
-static uint64_t
-qpkg_clean_dir(char *dirp, set *vdb)
-{
-	set *ll = NULL;
-	struct dirent **fnames;
-	int i, count;
-	char buf[_Q_PATH_MAX * 2];
-	struct stat st;
-	uint64_t num_all_bytes = 0;
-	size_t disp_units = 0;
-	char **t;
-	bool ignore;
-
-	if (dirp == NULL)
-		return 0;
-	if (chdir(dirp) != 0)
-		return 0;
-	if ((count = scandir(".", &fnames, filter_tbz2, alphasort)) < 0)
-		return 0;
-
-	/* create copy of vdb with only basenames */
-	for ((void)list_set(vdb, &t); *t != NULL; t++)
-		ll = add_set_unique(basename(*t), ll, &ignore);
-
-	for (i = 0; i < count; i++) {
-		fnames[i]->d_name[strlen(fnames[i]->d_name)-5] = 0;
-		if (contains_set(fnames[i]->d_name, ll))
-			continue;
-		snprintf(buf, sizeof(buf), "%s.tbz2", fnames[i]->d_name);
-		if (lstat(buf, &st) != -1) {
-			if (S_ISREG(st.st_mode)) {
-				disp_units = KILOBYTE;
-				if ((st.st_size / KILOBYTE) > 1000)
-					disp_units = MEGABYTE;
-				num_all_bytes += st.st_size;
-				qprintf(" %s[%s %3s %s %s] %s%s%s\n",
-						DKBLUE, GREEN,
-						make_human_readable_str(st.st_size, 1, disp_units),
-						disp_units == MEGABYTE ? "MiB" : "KiB",
-						DKBLUE, BLUE, fnames[i]->d_name, NORM);
-			}
-			if (!pretend)
-				unlink(buf);
-		}
-	}
-
-	free_set(ll);
-	scandir_free(fnames, count);
-
-	return num_all_bytes;
-}
-
 /* figure out what dirs we want to process for cleaning and display results. */
 static int
 qpkg_clean(char *dirp)
 {
-	int i, count;
+	size_t n;
 	size_t disp_units = 0;
-	uint64_t num_all_bytes;
-	struct dirent **dnames;
-	set *vdb = NULL;
+	uint64_t num_all_bytes = 0;
+	set *known_pkgs = NULL;
+	set *bin_pkgs = NULL;
+	DECLARE_ARRAY(bins);
 	tree_ctx *t;
+	tree_ctx *pkgs;
+	char *binatomstr;
+	depend_atom *atom;
+	char buf[_Q_PATH_MAX];
+	struct stat st;
 
-	if (chdir(dirp) != 0)
-		return 1;
-	if ((count = scandir(".", &dnames, filter_hidden, alphasort)) < 0)
+	pkgs = tree_open_binpkg(portroot, dirp);
+	if (pkgs == NULL)
 		return 1;
 
+	bin_pkgs = tree_get_atoms(pkgs, true, bin_pkgs);
+	array_set(bin_pkgs, bins);
+
 	if (eclean) {
-		size_t n;
 		const char *overlay;
 
 		array_for_each(overlays, n, overlay) {
 			t = tree_open(portroot, overlay);
 			if (t != NULL) {
-				vdb = tree_get_atoms(t, true, vdb);
+				known_pkgs = tree_get_atoms(t, true, known_pkgs);
 				tree_close(t);
 			}
 		}
 	} else {
 		t = tree_open_vdb(portroot, portvdb);
 		if (t != NULL) {
-			vdb = tree_get_atoms(t, true, vdb);
+			known_pkgs = tree_get_atoms(t, true, known_pkgs);
 			tree_close(t);
 		}
 	}
 
-	num_all_bytes = qpkg_clean_dir(dirp, vdb);
+	/* check which binpkgs exist in the known_pkgs (vdb or trees), such
+	 * that the remainder is what we would clean */
+	array_for_each(bins, n, binatomstr) {
+		if (contains_set(binatomstr, known_pkgs))
+			xarraydelete_ptr(bins, n--);
+	}
+
+	free_set(known_pkgs);
 
-	for (i = 0; i < count; i++) {
-		char buf[_Q_PATH_MAX * 2];
-		snprintf(buf, sizeof(buf), "%s/%s", dirp, dnames[i]->d_name);
-		num_all_bytes += qpkg_clean_dir(buf, vdb);
+	array_for_each(bins, n, binatomstr) {
+		snprintf(buf, sizeof(buf), "%s/%s.tbz2", dirp, binatomstr);
+		atom = atom_explode(binatomstr);
+		if (lstat(buf, &st) != -1) {
+			if (S_ISREG(st.st_mode)) {
+				disp_units = KILOBYTE;
+				if ((st.st_size / KILOBYTE) > 1000)
+					disp_units = MEGABYTE;
+				num_all_bytes += st.st_size;
+				qprintf(" %s[%s %3s %s %s]%s %s\n",
+						DKBLUE, GREEN,
+						make_human_readable_str(st.st_size, 1, disp_units),
+						disp_units == MEGABYTE ? "MiB" : "KiB",
+						DKBLUE, NORM, atom_format("%[CAT]/%[PF]", atom));
+			}
+			if (!pretend)
+				unlink(buf);
+		}
 	}
-	scandir_free(dnames, count);
 
-	free_set(vdb);
+	xarrayfree_int(bins);
+	free_set(bin_pkgs);
 
 	disp_units = KILOBYTE;
 	if ((num_all_bytes / KILOBYTE) > 1000)
@@ -328,15 +292,23 @@ qpkg_make(depend_atom *atom)
 	return 0;
 }
 
+static int
+qpkg_cb(tree_pkg_ctx *pkg, void *priv)
+{
+	size_t *pkgs_made = priv;
+
+	if (qpkg_make(tree_get_atom(pkg, false)) == 0)
+		(*pkgs_made)++;
+
+	return 0;
+}
+
 int qpkg_main(int argc, char **argv)
 {
 	tree_ctx *ctx;
-	tree_cat_ctx *cat_ctx;
-	tree_pkg_ctx *pkg_ctx;
 	size_t s, pkgs_made;
 	int i;
 	struct stat st;
-	char buf[BUFSIZE];
 	depend_atom *atom;
 	int restrict_chmod = 0;
 	int qclean = 0;
@@ -417,27 +389,21 @@ int qpkg_main(int argc, char **argv)
 	if (!ctx)
 		return EXIT_FAILURE;
 
-	/* scan all the categories */
-	while ((cat_ctx = tree_next_cat(ctx))) {
-		/* scan all the packages in this category */
-		while ((pkg_ctx = tree_next_pkg(cat_ctx))) {
-			/* see if user wants any of these packages */
-			atom = tree_get_atom(pkg_ctx, false);
-			snprintf(buf, sizeof(buf), "%s/%s", atom->CATEGORY, atom->PN);
-			for (i = optind; i < argc; ++i) {
-				if (argv[i] == NULL)
-					continue;
-
-				if (!strcmp(argv[i], atom->PN) ||
-						!strcmp(argv[i], atom->P) ||
-						!strcmp(argv[i], buf) ||
-						!strcmp(argv[i], "world"))
-					if (!qpkg_make(atom))
-						++pkgs_made;
-			}
-			tree_close_pkg(pkg_ctx);
+	for (i = optind; i < argc; ++i) {
+		if (argv[i] == NULL)
+			continue;
+		if (strcmp(argv[i], "world") == 0) {
+			/* we're basically done, this means all */
+			tree_foreach_pkg_fast(ctx, qpkg_cb, &pkgs_made, NULL);
 		}
+		atom = atom_explode(argv[i]);
+		if (atom == NULL)
+			continue;
+
+		tree_foreach_pkg_fast(ctx, qpkg_cb, &pkgs_made, atom);
+		atom_implode(atom);
 	}
+	tree_close(ctx);
 
 	if (pkgs_made)
 		qprintf(" %s*%s Packages can be found in %s\n",


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-02 14:07 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-02 14:07 UTC (permalink / raw
  To: gentoo-commits

commit:     c7d98c2f2c2d98f8296139b19fd3920bc9e5c3fb
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 14:06:35 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 14:06:35 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c7d98c2f

quse: push search atom down to tree_foreach_pkg when applicable

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 quse.c | 14 ++++----------
 1 file changed, 4 insertions(+), 10 deletions(-)

diff --git a/quse.c b/quse.c
index a8585be..358d9e0 100644
--- a/quse.c
+++ b/quse.c
@@ -426,16 +426,9 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	int portdirfd = -1;  /* pacify compiler */
 
 	if (state->match || state->do_describe) {
-		atom = tree_get_atom(pkg_ctx, 0);
+		atom = tree_get_atom(pkg_ctx, false);
 		if (atom == NULL)
 			return 0;
-
-		if (state->match) {
-			match = atom_compare(atom, state->match) == EQUAL;
-
-			if (!match)
-				return 0;
-		}
 	}
 
 	if (!state->do_licence) {
@@ -719,14 +712,15 @@ int quse_main(int argc, char **argv)
 	} else if (state.do_installed) {
 		tree_ctx *t = tree_open_vdb(portroot, portvdb);
 		state.overlay = NULL;
-		tree_foreach_pkg_sorted(t, quse_results_cb, &state, NULL);
+		tree_foreach_pkg_sorted(t, quse_results_cb, &state, state.match);
 		tree_close(t);
 	} else {
 		array_for_each(overlays, n, overlay) {
 			tree_ctx *t = tree_open(portroot, overlay);
 			state.overlay = overlay;
 			if (t != NULL) {
-				tree_foreach_pkg_sorted(t, quse_results_cb, &state, NULL);
+				tree_foreach_pkg_sorted(t, quse_results_cb,
+						&state, state.match);
 				tree_close(t);
 			}
 		}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-02 14:07 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-02 14:07 UTC (permalink / raw
  To: gentoo-commits

commit:     d0d205c64d76c416eb83422828e30aea544f4591
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 13:34:16 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 13:34:16 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d0d205c6

qsize: push query atoms down to tree_foreach_pkg

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsize.c | 24 +++++++-----------------
 1 file changed, 7 insertions(+), 17 deletions(-)

diff --git a/qsize.c b/qsize.c
index 1f1dfc9..5cf7dae 100644
--- a/qsize.c
+++ b/qsize.c
@@ -109,22 +109,6 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	FILE *fp;
 	size_t num_files, num_nonfiles, num_ignored;
 	uint64_t num_bytes;
-	bool showit = false;
-
-	/* see if this cat/pkg is requested */
-	if (array_cnt(state->atoms)) {
-		depend_atom *qatom;
-
-		qatom = tree_get_atom(pkg_ctx, 0);
-		array_for_each(state->atoms, i, atom)
-			if (atom_compare(qatom, atom) == EQUAL) {
-				showit = true;
-				break;
-			}
-	} else
-		showit = true;
-	if (!showit)
-		return EXIT_SUCCESS;
 
 	if ((fp = tree_pkg_vdb_fopenat_ro(pkg_ctx, "CONTENTS")) == NULL)
 		return EXIT_SUCCESS;
@@ -248,7 +232,13 @@ int qsize_main(int argc, char **argv)
 
 	vdb = tree_open_vdb(portroot, portvdb);
 	if (vdb != NULL) {
-		ret = tree_foreach_pkg_fast(vdb, qsize_cb, &state, NULL);
+		if (array_cnt(atoms) > 0) {
+			array_for_each(atoms, i, atom) {
+				ret = tree_foreach_pkg_fast(vdb, qsize_cb, &state, atom);
+			}
+		} else {
+			ret = tree_foreach_pkg_fast(vdb, qsize_cb, &state, NULL);
+		}
 		tree_close(vdb);
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-02 14:07 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-02 14:07 UTC (permalink / raw
  To: gentoo-commits

commit:     2d78938f5d4c3be536e7484c0f23be64b124db05
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 13:23:35 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 13:23:35 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2d78938f

qdepends: use tree_foreach_pkg query selection on forward queries

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qdepends.c | 22 ++++++++++++++++++----
 1 file changed, 18 insertions(+), 4 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index 44821b6..6f580a9 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -375,14 +375,28 @@ int qdepends_main(int argc, char **argv)
 		array_for_each(overlays, n, overlay) {
 			t = tree_open(portroot, overlay);
 			if (t != NULL) {
-				ret = tree_foreach_pkg_sorted(t,
-						qdepends_results_cb, &state, NULL);
+				if (!(state.qmode & QMODE_REVERSE) && array_cnt(atoms) > 0) {
+					array_for_each(atoms, i, atom) {
+						ret = tree_foreach_pkg_sorted(t,
+								qdepends_results_cb, &state, atom);
+					}
+				} else {
+					ret = tree_foreach_pkg_sorted(t,
+							qdepends_results_cb, &state, NULL);
+				}
 				tree_close(t);
 			}
 		}
 	} else {
-		ret = tree_foreach_pkg_fast(state.vdb,
-				qdepends_results_cb, &state, NULL);
+		if (!(state.qmode & QMODE_REVERSE) && array_cnt(atoms) > 0) {
+			array_for_each(atoms, i, atom) {
+				ret = tree_foreach_pkg_fast(state.vdb,
+						qdepends_results_cb, &state, atom);
+			}
+		} else {
+			ret = tree_foreach_pkg_fast(state.vdb,
+					qdepends_results_cb, &state, NULL);
+		}
 	}
 
 	if (state.vdb != NULL)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-02 14:07 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-02 14:07 UTC (permalink / raw
  To: gentoo-commits

commit:     2e8bca1ee3fd0a3cf9c489a1b661245d20f808af
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 12:49:34 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 12:49:34 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2e8bca1e

qcheck: pass package atoms down to tree_foreach_pkg

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcheck.c | 39 ++++++++++-----------------------------
 1 file changed, 10 insertions(+), 29 deletions(-)

diff --git a/qcheck.c b/qcheck.c
index 66a4ee7..e8db1b8 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -70,8 +70,9 @@ struct qcheck_opt_state {
 };
 
 static int
-qcheck_process_contents(tree_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
+qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 {
+	struct qcheck_opt_state *state = priv;
 	FILE *fp_contents, *fp_contents_update;
 	size_t num_files, num_files_ok, num_files_unknown, num_files_ignored;
 	char *buffer, *line;
@@ -334,7 +335,7 @@ qcheck_process_contents(tree_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 		printf("%s\n", atom_format(state->fmt, atom));
 	qcprintf("  %2$s*%1$s %3$s%4$zu%1$s out of %3$s%5$zu%1$s file%6$s are good",
 		NORM, BOLD, BLUE, num_files_ok, num_files,
-		(num_files > 1 ? "s" : ""));
+		(num_files != 1 ? "s" : ""));
 	if (num_files_unknown)
 		qcprintf(" (Unable to digest %2$s%3$zu%1$s file%4$s)",
 			NORM, BLUE, num_files_unknown,
@@ -351,32 +352,6 @@ qcheck_process_contents(tree_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 		return EXIT_SUCCESS;
 }
 
-static int
-qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
-{
-	struct qcheck_opt_state *state = priv;
-	bool showit = false;
-
-	/* see if this cat/pkg is requested */
-	if (array_cnt(state->atoms)) {
-		size_t i;
-		depend_atom *qatom;
-		depend_atom *atom;
-
-		qatom = tree_get_atom(pkg_ctx, false);
-		array_for_each(state->atoms, i, atom) {
-			if (atom_compare(qatom, atom) == EQUAL) {
-				showit = true;
-				break;
-			}
-		}
-	} else {
-		showit = true;
-	}
-
-	return showit ? qcheck_process_contents(pkg_ctx, priv) : 0;
-}
-
 int qcheck_main(int argc, char **argv)
 {
 	size_t i;
@@ -434,7 +409,13 @@ int qcheck_main(int argc, char **argv)
 	vdb = tree_open_vdb(portroot, portvdb);
 	ret = -1;
 	if (vdb != NULL) {
-		ret = tree_foreach_pkg_sorted(vdb, qcheck_cb, &state, NULL);
+		if (array_cnt(atoms) != 0) {
+			array_for_each(atoms, i, atom) {
+				ret |= tree_foreach_pkg_sorted(vdb, qcheck_cb, &state, atom);
+			}
+		} else {
+			ret = tree_foreach_pkg_sorted(vdb, qcheck_cb, &state, NULL);
+		}
 		tree_close(vdb);
 	}
 	if (array_cnt(regex_arr) > 0) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-02 11:55 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-02 11:55 UTC (permalink / raw
  To: gentoo-commits

commit:     91c71f0ddcdca7991f35621c629fa06a348d4a00
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 11:54:22 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 11:54:22 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=91c71f0d

qkeyword: pass atom restriction (-p/-c) down to tree_foreach_pkg

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qkeyword.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qkeyword.c b/qkeyword.c
index f777960..2121d51 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -799,7 +799,8 @@ qkeyword_traverse(tree_pkg_cb func, void *priv)
 	array_for_each(overlays, n, overlay) {
 		tree_ctx *t = tree_open(portroot, overlay);
 		if (t != NULL) {
-			ret |= tree_foreach_pkg_sorted(t, qkeyword_results_cb, priv, NULL);
+			ret |= tree_foreach_pkg_sorted(t,
+					qkeyword_results_cb, priv, data->qatom);
 			tree_close(t);
 		}
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-02  9:47 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-02  9:47 UTC (permalink / raw
  To: gentoo-commits

commit:     56a4f36cf6325323068397b0b510b8e8340c25d9
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jan  2 09:44:33 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jan  2 09:44:33 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=56a4f36c

qlop: improve description for -c, fix -E

-c could use a bit better explanation
-E included installed packages for no good reason

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md |  5 +++++
 qpkg.c  | 16 ++++++++--------
 2 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/TODO.md b/TODO.md
index 602d17a..d89dda1 100644
--- a/TODO.md
+++ b/TODO.md
@@ -18,6 +18,10 @@
   so we can
 - parse package.accept\_keywords such that we can provide the latest
   "available" version like Portage
+- check timestamps in libq/tree for choosing which method to take:
+	- ignore Packages when it is older than the last directory change
+	- ignore metadata when ebuild is modified
+	- add some method to skip these checks and assume everything is right
 
 # qmerge
 - dep resolver needs spanktastic love.
@@ -65,6 +69,7 @@
 # qmanifest
 - use openat in most places
 - parse timestamps and print in local timezone
+- implement python module for gemato interface (to use with Portage)
 
 # qlop
 - guestimate runtime based on best-matching pkg (e.g. with gcc)

diff --git a/qpkg.c b/qpkg.c
index 9d2d82a..771241c 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -41,8 +41,8 @@ static struct option const qpkg_long_opts[] = {
 	COMMON_LONG_OPTS
 };
 static const char * const qpkg_opts_help[] = {
-	"clean pkgdir of unused binary files",
-	"clean pkgdir of files not in the tree anymore (slow)",
+	"clean pkgdir of files that are not installed",
+	"clean pkgdir of files that are not in the tree anymore",
 	"pretend only",
 	"alternate package directory",
 	COMMON_OPTS_HELP
@@ -134,12 +134,6 @@ qpkg_clean(char *dirp)
 	if ((count = scandir(".", &dnames, filter_hidden, alphasort)) < 0)
 		return 1;
 
-	t = tree_open_vdb(portroot, portvdb);
-	if (t != NULL) {
-		vdb = tree_get_atoms(t, true, vdb);
-		tree_close(t);
-	}
-
 	if (eclean) {
 		size_t n;
 		const char *overlay;
@@ -151,6 +145,12 @@ qpkg_clean(char *dirp)
 				tree_close(t);
 			}
 		}
+	} else {
+		t = tree_open_vdb(portroot, portvdb);
+		if (t != NULL) {
+			vdb = tree_get_atoms(t, true, vdb);
+			tree_close(t);
+		}
 	}
 
 	num_all_bytes = qpkg_clean_dir(dirp, vdb);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2020-01-01 19:57 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2020-01-01 19:57 UTC (permalink / raw
  To: gentoo-commits

commit:     11b025f82503b0043a6ec171ae75b65dc19c507c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jan  1 19:57:03 2020 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jan  1 19:57:03 2020 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=11b025f8

TODO: remove finished items

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 16 ----------------
 1 file changed, 16 deletions(-)

diff --git a/TODO.md b/TODO.md
index 191e91c..602d17a 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,32 +1,25 @@
 # Common
-
 - unify match behavior:
 	- default \*foo\*
 	- -e foo
 	- -r (-R ?) regexp foo.\*
 - make default -e for apps like quse/qdepends/qlist?
-
 - env vars only get expanded once, so this fails:<br>
   `ACCEPT_LICENSE="foo"`<br>
   `ACCEPT_LICENSE="${ACCEPT_LICENSE} bar"`<br>
   we end up getting just:<br>
   `ACCEPT_LICENSE=" bar"`
-
 - tree\_foreach\_pkg should have variant that takes an atom (or just
   cat?) to reduce search space
-
 - tree\_get\_atoms should return atoms iso string set, needs a rewrite
   to use foreach\_pkg and get\_atom -- set is ready for storing objects
   now
-
 - replace all strtok by strtok\_r, because the latter is already used,
   so we can
-
 - parse package.accept\_keywords such that we can provide the latest
   "available" version like Portage
 
 # qmerge
-
 - dep resolver needs spanktastic love.
 - needs safe deleting (merge in place rather than unmerge;merge)
 - multiple binary repos (talk to zmedico)
@@ -47,11 +40,9 @@
   not-forcing things
 
 # qdepends
-
 - -v should lookup whether packages are installed for || cases/colouring
 
 # qpkg
-
 - add a verbose output that describes why a package is cleaned
 	- newer binpkgs available
 	- newer installed version available
@@ -59,13 +50,8 @@
   and qpkg is doing parts of qtbz2's compose
 
 # qgrep
-
 - make it use standard xarray instead of its own buf\_list
 
-# qlist
-- have -F for use with -I so one can do things like print SLOT for
-  package X
-
 # quse
 - make -v only print requested USE-flag when flags given
 - list each package only once (e.g. quse -e lz4)
@@ -84,7 +70,5 @@
 - guestimate runtime based on best-matching pkg (e.g. with gcc)
 - calculate or take some "smooth" factor just added on top of the
   guestimate alternative to current time jumping
-- display excess time (+12:05) when overrunning guestimate to indicate
-  longer run than last guestimate
 - multiple files support -- current opinion: don't do it
 - compressed file support, use guessing support from qmerge?


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-12-31  9:10 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-12-31  9:10 UTC (permalink / raw
  To: gentoo-commits

commit:     377cb6c04d5638c3ade82605ceead9b6f8750847
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 31 09:09:39 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Dec 31 09:09:39 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=377cb6c0

buildsys: drop -liniparser

don't link against a non-used library

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 Makefile.am | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index d85a4f9..3107bda 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -73,7 +73,6 @@ q_CPPFLAGS = \
 q_LDADD = \
 	$(top_builddir)/libq/libq.la \
 	$(top_builddir)/autotools/gnulib/libgnu.a \
-	-liniparser \
 	$(LIBSSL) \
 	$(LIBBL2) \
 	$(LIBZ) \


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-12-31  9:05 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-12-31  9:05 UTC (permalink / raw
  To: gentoo-commits

commit:     7499c74abb529d49a3d6800c610c3aba7e85ad41
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 31 07:41:26 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Dec 31 07:41:26 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7499c74a

TODO: add qkeywords entry before I forget

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/TODO.md b/TODO.md
index b0bac64..00ccdea 100644
--- a/TODO.md
+++ b/TODO.md
@@ -79,6 +79,9 @@
 
 # qkeyword
 - drop -c argument? it can be fully expressed using -p cat/
+- add mode to list which packages needs to be keyworded (deps), talk to
+  Kent Fredric on details, 20191229000543.001631d9@katipo2.lan
+  Re: [gentoo-dev] Keywordreqs and slacking arch team
 
 # qmanifest
 - use openat in most places


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-12-29 12:35 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-12-29 12:35 UTC (permalink / raw
  To: gentoo-commits

commit:     10729f3630faaf79d2e4eaf77ea4bc957fa8c8aa
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 29 12:27:21 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Dec 29 12:27:21 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=10729f36

qlist: add support for listing contents from binpkgs

Read CONTENTS straight out of the xpak archive to provide the same
listing capabilities as for VDB.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 configure.ac |  3 ++-
 qlist.c      | 68 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++----
 2 files changed, 66 insertions(+), 5 deletions(-)

diff --git a/configure.ac b/configure.ac
index 0577d07..0efdf3e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -19,7 +19,8 @@ LT_INIT
 AC_SUBST([LIBTOOL_DEPS])
 
 AC_CHECK_FUNCS_ONCE(m4_flatten([
-       scandirat
+	   fmemopen
+	   scandirat
 ]))
 
 AC_ARG_WITH([eprefix], [AS_HELP_STRING([--with-eprefix], [path for Gentoo/Prefix project])])

diff --git a/qlist.c b/qlist.c
index 30c0c6f..3f20ced 100644
--- a/qlist.c
+++ b/qlist.c
@@ -19,6 +19,7 @@
 #include "atom.h"
 #include "contents.h"
 #include "tree.h"
+#include "xpak.h"
 #include "xregex.h"
 
 #define QLIST_FLAGS "IkSRUcDedosF:" COMMON_FLAGS
@@ -315,6 +316,7 @@ struct qlist_opt_state {
 	depend_atom **atoms;
 	bool exact:1;
 	bool all:1;
+	bool do_binpkgs:1;
 	bool just_pkgname:1;
 	bool show_dir:1;
 	bool show_obj:1;
@@ -327,6 +329,33 @@ struct qlist_opt_state {
 	const char *fmt;
 };
 
+struct qlist_xpakcbctx {
+	const char *key;
+	char *retdata;
+	size_t retlen;
+};
+
+static void
+_qlist_xpakcb(
+	void *ctx,
+	char *pathname,
+	int pathname_len,
+	int data_offset,
+	int data_len,
+	char *data)
+{
+	struct qlist_xpakcbctx *xctx = ctx;
+	(void)pathname_len;
+
+	/* see if this path matches what we're looking for */
+	if (strcmp(pathname, xctx->key) != 0)
+		return;
+
+	xctx->retdata = xrealloc(xctx->retdata, data_len + 1);
+	memcpy(xctx->retdata, data + data_offset, data_len + 1);
+	xctx->retlen = data_len;
+}
+
 static int
 qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 {
@@ -334,6 +363,11 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	int i;
 	FILE *fp;
 	depend_atom *atom;
+	struct qlist_xpakcbctx cbctx = {
+		.key = "CONTENTS",
+		.retdata = NULL,
+		.retlen = 0,
+	};
 
 	/* see if this cat/pkg is requested */
 	if (!state->all) {
@@ -358,7 +392,31 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 		printf("%s %sCONTENTS%s:\n",
 				atom_format(state->fmt, atom), DKBLUE, NORM);
 
-	fp = tree_pkg_vdb_fopenat_ro(pkg_ctx, "CONTENTS");
+	if (state->do_binpkgs) {
+		char xpak[_Q_PATH_MAX];
+		int ret;
+		snprintf(xpak, sizeof(xpak), "%s/%s/%s/%s-%s.tbz2",
+				portroot, pkgdir, atom->CATEGORY, atom->PN,
+				atom->PR_int > 0 ? atom->PVR : atom->PV);
+		ret = xpak_extract(xpak, &cbctx, &_qlist_xpakcb);
+		if (ret != 0 || cbctx.retdata == NULL)
+			fp = NULL;
+		else
+#ifdef HAVE_FMEMOPEN
+			fp = fmemopen(cbctx.retdata, cbctx.retlen, "r");
+#else
+		{
+			/* resort to writing a file in tmpspace */
+			fp = tmpfile();
+			if (fp != NULL) {
+				fwrite(cbctx.retdata, 1, cbctx.retlen, fp);
+				fseek(fp, 0, SEEK_SET);
+			}
+		}
+#endif
+	} else {
+		fp = tree_pkg_vdb_fopenat_ro(pkg_ctx, "CONTENTS");
+	}
 	if (fp == NULL)
 		return 1;
 
@@ -398,6 +456,8 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 		}
 	}
 	fclose(fp);
+	if (state->do_binpkgs && cbctx.retdata != NULL)
+		free(cbctx.retdata);
 
 	return 1;
 }
@@ -410,13 +470,13 @@ int qlist_main(int argc, char **argv)
 	int show_slots = 0;
 	bool show_repo = false;
 	bool do_columns = false;
-	bool do_binpkgs = false;
 	char qfmt[128];
 	struct qlist_opt_state state = {
 		.argc = argc,
 		.argv = argv,
 		.exact = false,
 		.all = false,
+		.do_binpkgs = false,
 		.just_pkgname = false,
 		.show_dir = false,
 		.show_obj = false,
@@ -432,7 +492,7 @@ int qlist_main(int argc, char **argv)
 		switch (i) {
 		COMMON_GETOPTS_CASES(qlist)
 		case 'I': state.just_pkgname = true;                    break;
-		case 'k': do_binpkgs = true;                            break;
+		case 'k': state.do_binpkgs = true;                      break;
 		case 'S': state.just_pkgname = true; show_slots++;      break;
 		case 'R': state.just_pkgname = show_repo = true;        break;
 		case 'U': state.just_pkgname = state.show_umap = true;  break;
@@ -488,7 +548,7 @@ int qlist_main(int argc, char **argv)
 	state.buf = xmalloc(state.buflen);
 	state.atoms = xcalloc(argc - optind, sizeof(*state.atoms));
 	ret = 1;
-	if (do_binpkgs)
+	if (state.do_binpkgs)
 		vdb = tree_open_binpkg(portroot, pkgdir);
 	else
 		vdb = tree_open_vdb(portroot, portvdb);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-12-29  9:57 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-12-29  9:57 UTC (permalink / raw
  To: gentoo-commits

commit:     7cdf692beb93c596b4bf4f5f7b5bb8bcc69a27ea
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 29 09:54:28 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Dec 29 09:54:28 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7cdf692b

q: improve applet searching somewhat, change warn app name

- use a single loop iteration to match an applet
- set full name of applet (qlop iso lop) in argv0 for warn() to match
  the running command
- use name of aliased applet when invoked by an alias (belongs -> qfile)

Bug: https://bugs.gentoo.org/701968
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h |  1 -
 q.c       | 37 +++++++++++++++++++++++++++----------
 2 files changed, 27 insertions(+), 11 deletions(-)

diff --git a/applets.h b/applets.h
index ea4eece..4625fde 100644
--- a/applets.h
+++ b/applets.h
@@ -102,7 +102,6 @@ static const struct applet_t {
 	/*"glsa"*/
 	{"hasuse",    quse_main,      NULL, NULL},
 	/*"list"*/
-	{"size",      qsize_main,     NULL, NULL},
 	/*"stats"*/
 	/*"uses"*/
 	/*"which"*/

diff --git a/q.c b/q.c
index 4a2fd62..6d7eced 100644
--- a/q.c
+++ b/q.c
@@ -48,24 +48,41 @@ APPLET lookup_applet(const char *applet)
 	if (strlen(applet) < 1)
 		return NULL;
 
-	for (i = 0; applets[i].name; ++i) {
-		if (strcmp(applets[i].name, applet) == 0) {
+	if (applet[0] == 'q')
+		applet++;
+
+	/* simple case, e.g. something like "qlop" or "q lop" both being "lop"  */
+	for (i = 0; applets[i].desc != NULL; i++) {
+		if (strcmp(applets[i].name + 1, applet) == 0) {
 			argv0 = applets[i].name;
-			if (i && applets[i].desc != NULL)
-				++argv0; /* chop the leading 'q' */
 			return applets[i].func;
 		}
 	}
 
-	/* No applet found? Search by shortname then... */
-	for (i = 1; applets[i].desc != NULL; ++i) {
-		if (strcmp(applets[i].name + 1, applet) == 0) {
-			argv0 = applets[i].name + 1;
-			return applets[i].func;
+	/* this is possibly an alias like "belongs"
+	 * NOTE: we continue where the previous loop left, e.g. on the first
+	 * alias (desc == NULL) */
+	for ( ; applets[i].name != NULL; i++) {
+		if (strcmp(applets[i].name, applet) == 0) {
+			unsigned int j;
+
+			/* lookup the real name for this alias */
+			for (j = 1; applets[j].desc != NULL; j++) {
+				if (applets[j].func == applets[i].func) {
+					argv0 = applets[j].name;
+					return applets[j].func;
+				}
+			}
+
+			/* this shouldn't happen and means our array from applets.h
+			 * is inconsistent */
+			warn("invalid applet alias '%s': target applet unknown", applet);
+			return NULL;
 		}
 	}
+
 	/* still nothing ?  those bastards ... */
-	warn("Unknown applet '%s'", applet);
+	warn("unknown applet: %s", applet);
 	return NULL;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-12-27 21:45 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-12-27 21:45 UTC (permalink / raw
  To: gentoo-commits

commit:     eddd1df90bc5d27e726c02e8aac8cfa9484ed3a8
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 27 21:44:46 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Dec 27 21:44:46 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=eddd1df9

qfile: make qfile_check_plibreg not trigger on an empty file (/)

This really is an edge case, as result of a misinterpretation of the -R
option.

Bug: https://bugs.gentoo.org/699558
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qfile.c b/qfile.c
index 6c2ebb8..b1aab8d 100644
--- a/qfile.c
+++ b/qfile.c
@@ -119,7 +119,7 @@ static int qfile_check_plibreg(void *priv)
 	}
 
 	for (i = 0; i < args->length; i++) {
-		if (base_names[i] == NULL)
+		if (base_names[i] == NULL || base_names[i][0] == '\0')
 			continue;
 		if (non_orphans && non_orphans[i])
 			continue;
@@ -534,7 +534,7 @@ int qfile_main(int argc, char **argv)
 		 * (this one is just for qfile(...) output) */
 		size_t lastc = strlen(portroot) - 1;
 		state.root = xstrdup(portroot);
-		if (state.root[lastc] == '/')
+		if (lastc > 0 && state.root[lastc] == '/')
 			state.root[lastc] = '\0';
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-12-27 21:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-12-27 21:14 UTC (permalink / raw
  To: gentoo-commits

commit:     a7269e48f4961afcc8bc5f0b2d426f645612e973
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 27 21:13:59 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Dec 27 21:13:59 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a7269e48

qlop: report running over estimated time

basically try saying something useful, instead of unknown

Bug: https://bugs.gentoo.org/701386
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 36 +++++++++++++++++++++++-------------
 1 file changed, 23 insertions(+), 13 deletions(-)

diff --git a/qlop.c b/qlop.c
index 634431a..3120d85 100644
--- a/qlop.c
+++ b/qlop.c
@@ -903,7 +903,9 @@ static int do_emerge_log(
 			if (pkg != NULL) {
 				maxtime = pkg->time / pkg->cnt;
 				if (elapsed >= maxtime) {
-					maxtime = elapsed >= pkg->tbegin ? 0 : pkg->tbegin;
+					maxtime = pkg->tbegin;
+					if (elapsed >= maxtime)
+						maxtime -= elapsed;
 					isMax = true;
 				}
 			}
@@ -928,12 +930,15 @@ static int do_emerge_log(
 						fmt_date(flags, pkgw->tbegin, 0),
 						atom_format(flags->fmt, pkgw->atom));
 			}
-			printf("...%s ETA: %s%s\n",
-					p == NULL ? "" : p,
-					maxtime == 0 ? "unknown" :
-						fmt_elapsedtime(flags, maxtime - elapsed),
-					maxtime > 0 && verbose ?
-						isMax ? " (longest run)" : " (average run)" : "");
+			if (maxtime < 0)
+				printf("... +%s\n", fmt_elapsedtime(flags, -maxtime));
+			else
+				printf("...%s ETA: %s%s\n",
+						p == NULL ? "" : p,
+						maxtime == 0 ? "unknown" :
+							fmt_elapsedtime(flags, maxtime - elapsed),
+						maxtime > 0 && verbose ?
+							isMax ? " (longest run)" : " (average run)" : "");
 		}
 		clear_set(pkgs_seen);
 		array_for_each(unmerge_matches, i, pkgw) {
@@ -957,7 +962,9 @@ static int do_emerge_log(
 			if (pkg != NULL) {
 				maxtime = pkg->time / pkg->cnt;
 				if (elapsed >= maxtime) {
-					maxtime = elapsed >= pkg->tbegin ? 0 : pkg->tbegin;
+					maxtime = pkg->tbegin;
+					if (elapsed >= maxtime)
+						maxtime -= elapsed;
 					isMax = true;
 				}
 			}
@@ -972,11 +979,14 @@ static int do_emerge_log(
 						fmt_date(flags, pkgw->tbegin, 0),
 						atom_format(flags->fmt, pkgw->atom));
 			}
-			printf("... ETA: %s%s\n",
-					maxtime == 0 ? "unknown" :
-					fmt_elapsedtime(flags, maxtime - elapsed),
-					maxtime > 0 && verbose ?
-						isMax ? " (longest run)" : " (average run)" : "");
+			if (maxtime < 0)
+				printf("... +%s\n", fmt_elapsedtime(flags, -maxtime));
+			else
+				printf("... ETA: %s%s\n",
+						maxtime == 0 ? "unknown" :
+							fmt_elapsedtime(flags, maxtime - elapsed),
+						maxtime > 0 && verbose ?
+							isMax ? " (longest run)" : " (average run)" : "");
 		}
 		free_set(pkgs_seen);
 	} else if (flags->do_average) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-12-27 19:16 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-12-27 19:16 UTC (permalink / raw
  To: gentoo-commits

commit:     5e5cba1176c8bfa39405b5cf29dcf50c08f8fc66
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 27 17:25:28 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Dec 27 17:25:28 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5e5cba11

main: use cannonical repo paths for repos.conf and PORTDIR

Make sure we compare the same locations by using realpath()

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c
index b5404cb..f0a8841 100644
--- a/main.c
+++ b/main.c
@@ -639,7 +639,10 @@ read_one_repos_conf(const char *repos_conf, char **primary)
 {
 	int nsec;
 	char *conf;
-	const char *main_repo, *repo, *path;
+	char rrepo[_Q_PATH_MAX];
+	const char *main_repo;
+	const char *repo;
+	const char *path;
 	dictionary *dict;
 
 	if (getenv("DEBUG"))
@@ -662,6 +665,10 @@ read_one_repos_conf(const char *repos_conf, char **primary)
 			size_t n;
 			char *overlay;
 
+			/* try not to get confused by symlinks etc. */
+			if (realpath(path, rrepo) != NULL)
+				path = rrepo;
+
 			array_for_each(overlay_names, n, overlay) {
 				if (strcmp(overlay, repo) == 0)
 					break;
@@ -906,12 +913,18 @@ initialize_portage_env(void)
 		var = &vars_to_read[11];  /* PORTDIR */
 
 		if (strcmp(var->src, STR_DEFAULT) != 0 || array_cnt(overlays) == 0) {
+			char roverlay[_Q_PATH_MAX];
+			/* get cannonical path, we do so for repos.conf too */
+			if (realpath(main_overlay, roverlay) == NULL)
+				snprintf(roverlay, sizeof(roverlay), "%s", main_overlay);
 			array_for_each(overlays, i, overlay) {
-				if (strcmp(overlay, main_overlay) == 0)
+				if (strcmp(overlay, roverlay) == 0)
 					break;
 				overlay = NULL;
 			}
 			if (overlay == NULL) {  /* add PORTDIR to overlays */
+				free(main_overlay);
+				main_overlay = xstrdup(roverlay);
 				xarraypush_ptr(overlays, main_overlay);
 				xarraypush_str(overlay_names, "<PORTDIR>");
 				xarraypush_str(overlay_src, var->src);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-12-14 17:01 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-12-14 17:01 UTC (permalink / raw
  To: gentoo-commits

commit:     7967115a80957a456b53748820019ba7f484f4c9
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 14 15:58:51 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Dec 14 15:58:51 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7967115a

qkeyword: sort keywords

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qkeyword.c | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/qkeyword.c b/qkeyword.c
index b329068..4c6c759 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -650,6 +650,29 @@ qkeyword_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	return EXIT_SUCCESS;
 }
 
+static int
+keyword_sort(const void *l, const void *r)
+{
+	const char **ls = (const char **)l;
+	const char **rs = (const char **)r;
+	char *ld = strchr(*ls, '-');
+	char *rd = strchr(*rs, '-');
+
+	printf("%s vs %s\n", *ls, *rs);
+	if (ld == NULL && rd != NULL)
+		return -1;
+	else if (ld != NULL && rd == NULL)
+		return 1;
+	else if (ld == NULL)
+		return strcmp(*ls, *rs);
+	else {
+		int ret = strcmp(ld + 1, rd + 1);
+		if (ret == 0)
+			ret = strcmp(*ls, *rs);
+		return ret;
+	}
+}
+
 static void
 qkeyword_load_arches(const char *overlay)
 {
@@ -690,6 +713,9 @@ qkeyword_load_arches(const char *overlay)
 		free(archlist);
 	list_set(archs, &archlist);
 
+	/* sort so the output makes more 'sense' */
+	qsort(archlist, archlist_count, sizeof(char **), keyword_sort);
+
 	fclose(fp);
  done:
 	free(filename);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-12-14 17:01 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-12-14 17:01 UTC (permalink / raw
  To: gentoo-commits

commit:     9284822a7e38ffa6533ac3b048a7ea1d2110b14f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 14 15:10:56 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Dec 14 15:10:56 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9284822a

qkeyword: default to ARCH when no arch given

By default just operate on the arch specified by the selected profile.
This is probably going to be useful in the majority of the cases.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h  | 1 +
 main.c     | 2 +-
 qkeyword.c | 8 ++++----
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/applets.h b/applets.h
index e7b81f4..ea4eece 100644
--- a/applets.h
+++ b/applets.h
@@ -152,6 +152,7 @@ static const struct applet_t {
 	case 'C': no_colors(); break; \
 	default: applet ## _usage(EXIT_FAILURE); break;
 
+extern char *portarch;
 extern char *portroot;
 extern int verbose;
 extern int quiet;

diff --git a/main.c b/main.c
index e0b2b9c..869bf31 100644
--- a/main.c
+++ b/main.c
@@ -31,6 +31,7 @@ int verbose = 0;
 int quiet = 0;
 int twidth;
 char pretend = 0;
+char *portarch;
 char *portroot;
 char *config_protect;
 char *config_protect_mask;
@@ -46,7 +47,6 @@ DECLARE_ARRAY(overlays);
 DECLARE_ARRAY(overlay_names);
 DECLARE_ARRAY(overlay_src);
 
-static char *portarch;
 static char *portedb;
 static char *eprefix;
 static char *accept_license;

diff --git a/qkeyword.c b/qkeyword.c
index 9c7187e..b329068 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -762,11 +762,12 @@ int qkeyword_main(int argc, char **argv)
 		}
 	}
 
-	data.arch = NULL;
+	data.arch = portarch;
 	if (optind < argc)
 		data.arch = argv[optind];
 
-	if ((data.arch == NULL && action != 's') || optind + 1 < argc)
+	if (((data.arch == NULL || *data.arch == '\0') && action != 's') ||
+			optind + 1 < argc)
 		qkeyword_usage(EXIT_FAILURE);
 
 	if (cat != NULL) {
@@ -803,8 +804,7 @@ int qkeyword_main(int argc, char **argv)
 				  i = qkeyword_dropped(NULL, NULL);                     break;
 		case 't': i = qkeyword_traverse(qkeyword_testing_only, &data);
 				  i = qkeyword_testing_only(NULL, NULL);                break;
-		case 's': data.arch = "amd64";  /* doesn't matter, need to be set */
-				  i = qkeyword_traverse(qkeyword_stats, &data);
+		case 's': i = qkeyword_traverse(qkeyword_stats, &data);
 				  i = qkeyword_stats(NULL, NULL);                       break;
 		case 'a': i = qkeyword_traverse(qkeyword_all, &data);           break;
 		case 'n': i = qkeyword_traverse(qkeyword_not, &data);           break;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-12-14 17:01 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-12-14 17:01 UTC (permalink / raw
  To: gentoo-commits

commit:     90f9598b63f684966a0e3a063d8cfd6b125ea065
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Dec 14 15:17:28 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Dec 14 15:17:28 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=90f9598b

qlop: fix signedness warning

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qlop.c b/qlop.c
index d8e1d58..7cc8f44 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1109,7 +1109,7 @@ static array_t *probe_proc(array_t *atoms)
 					rpath[rpathlen] = '\0';
 					/* check if this points to a portage build:
 					 * <somepath>/portage/<cat>/<pf>/temp/build.log */
-					if (rpathlen > sizeof("/temp/build.log") &&
+					if ((size_t)rpathlen > sizeof("/temp/build.log") &&
 								strcmp(rpath + rpathlen -
 								(sizeof("/temp/build.log") - 1),
 								"/temp/build.log") == 0 &&


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-12-08 11:53 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-12-08 11:53 UTC (permalink / raw
  To: gentoo-commits

commit:     6e4fe103d8372c951f678e9972e546124e5eb41b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Dec  8 11:52:31 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Dec  8 11:52:31 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6e4fe103

main: try to make repo handling safer

Parse PORTDIR and repos separately, then afterwards add PORTDIR as repo
when defined.

Bug: https://bugs.gentoo.org/701402
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c      | 112 +++++++++++++++++++++++++++++++-----------------------------
 q.c         |   4 ++-
 qmanifest.c |   4 +++
 3 files changed, 64 insertions(+), 56 deletions(-)

diff --git a/main.c b/main.c
index d6bbacf..e0b2b9c 100644
--- a/main.c
+++ b/main.c
@@ -601,7 +601,7 @@ env_vars vars_to_read[] = {
 
 /* Handle a single file in the repos.conf format. */
 static void
-read_one_repos_conf(const char *repos_conf)
+read_one_repos_conf(const char *repos_conf, char **primary)
 {
 	int nsec;
 	char *conf;
@@ -643,14 +643,11 @@ read_one_repos_conf(const char *repos_conf)
 				ele = array_get_elem(overlays, n) = xstrdup(path);
 			} else {
 				ele = xarraypush_str(overlays, path);
-				xarraypush_str(overlay_names, repo);
+				overlay = xarraypush_str(overlay_names, repo);
 				xarraypush_str(overlay_src, repos_conf);
 			}
-			if (main_repo && strcmp(repo, main_repo) == 0) {
-				main_overlay = ele;
-				free(vars_to_read[11 /* PORTDIR */].src);
-				vars_to_read[11 /* PORTDIR */].src = xstrdup(repos_conf);
-			}
+			if (main_repo && strcmp(repo, main_repo) == 0)
+				*primary = overlay;
 		}
 		free(conf);
 	}
@@ -660,7 +657,7 @@ read_one_repos_conf(const char *repos_conf)
 
 /* Handle a possible directory of files. */
 static void
-read_repos_conf(const char *configroot, const char *repos_conf)
+read_repos_conf(const char *configroot, const char *repos_conf, char **primary)
 {
 	char *top_conf, *sub_conf;
 	int i, count;
@@ -672,7 +669,7 @@ read_repos_conf(const char *configroot, const char *repos_conf)
 	count = scandir(top_conf, &confs, NULL, alphasort);
 	if (count == -1) {
 		if (errno == ENOTDIR)
-			read_one_repos_conf(top_conf);
+			read_one_repos_conf(top_conf, primary);
 	} else {
 		for (i = 0; i < count; ++i) {
 			const char *name = confs[i]->d_name;
@@ -704,7 +701,7 @@ read_repos_conf(const char *configroot, const char *repos_conf)
 				}
 			}
 
-			read_one_repos_conf(sub_conf);
+			read_one_repos_conf(sub_conf, primary);
 			free(sub_conf);
 		}
 		scandir_free(confs, count);
@@ -720,7 +717,7 @@ initialize_portage_env(void)
 	env_vars *var;
 	char pathbuf[_Q_PATH_MAX];
 	const char *configroot = getenv("PORTAGE_CONFIGROOT");
-	char *orig_main_overlay;
+	char *primary_overlay = NULL;
 
 	/* initialize all the strings with their default value */
 	for (i = 0; vars_to_read[i].name; ++i) {
@@ -741,49 +738,10 @@ initialize_portage_env(void)
 
 	/* read overlays first so we can resolve repo references in profile
 	 * parent files */
-	orig_main_overlay = main_overlay;
 	snprintf(pathbuf, sizeof(pathbuf), "%.*s", (int)i, configroot);
-	read_repos_conf(pathbuf, "/usr/share/portage/config/repos.conf");
-	read_repos_conf(pathbuf, "/etc/portage/repos.conf");
-	/* special handling of PORTDIR envvar, else it comes too late, see
-	 * also below where we handle the environment */
-	if ((s = getenv("PORTDIR")) != NULL) {
-		char *overlay;
-
-		array_for_each(overlays, i, overlay) {
-			if (strcmp(overlay, s) == 0)
-				break;
-			overlay = NULL;
-		}
-		if (overlay == NULL) {
-			main_overlay = xarraypush_str(overlays, s);
-			xarraypush_str(overlay_names, "<PORTDIR>");
-			xarraypush_str(overlay_src, "PORTDIR");
-		} else {
-			free(array_get_elem(overlay_src, i));
-			array_get_elem(overlay_src, i) = xstrdup("PORTDIR");
-			main_overlay = overlay;
-		}
-		free(vars_to_read[11 /* PORTDIR */].src);
-		vars_to_read[11 /* PORTDIR */].src = xstrdup("PORTDIR");
-	}
-	if (orig_main_overlay != main_overlay) {
-		free(orig_main_overlay);
-	} else {
-		if (array_cnt(overlays) == 0) {
-			xarraypush_ptr(overlays, main_overlay);
-			xarraypush_str(overlay_names, "<PORTDIR>");
-			xarraypush_str(overlay_src, STR_DEFAULT);
-		} else {
-			/* if no explicit overlay was flagged as main, take the
-			 * first one */
-			free(orig_main_overlay);
-			main_overlay = array_get_elem(overlays, 0);
-			free(vars_to_read[11 /* PORTDIR */].src);
-			vars_to_read[11 /* PORTDIR */].src =
-				xstrdup((char *)array_get_elem(overlay_src, 0));
-		}
-	}
+	read_repos_conf(pathbuf, "/usr/share/portage/config/repos.conf",
+			&primary_overlay);
+	read_repos_conf(pathbuf, "/etc/portage/repos.conf", &primary_overlay);
 
 	/* consider Portage's defaults */
 	snprintf(pathbuf, sizeof(pathbuf),
@@ -811,8 +769,7 @@ initialize_portage_env(void)
 	for (i = 0; vars_to_read[i].name; i++) {
 		var = &vars_to_read[i];
 		s = getenv(var->name);
-		/* PORTDIR was already added to overlays above, ignore it */
-		if (s != NULL && strcmp(var->name, "PORTDIR") != 0)
+		if (s != NULL)
 			set_portage_env_var(var, s, var->name);
 	}
 
@@ -887,6 +844,51 @@ initialize_portage_env(void)
 		}
 	}
 
+	/* handle PORTDIR and primary_overlay to get a unified
+	 * administration in overlays */
+	{
+		char *overlay;
+		var = &vars_to_read[11];  /* PORTDIR */
+
+		if (strcmp(var->src, STR_DEFAULT) != 0 || array_cnt(overlays) == 0) {
+			array_for_each(overlays, i, overlay) {
+				if (strcmp(overlay, main_overlay) == 0)
+					break;
+				overlay = NULL;
+			}
+			if (overlay == NULL) {  /* add PORTDIR to overlays */
+				xarraypush_ptr(overlays, main_overlay);
+				xarraypush_str(overlay_names, "<PORTDIR>");
+				xarraypush_str(overlay_src, var->src);
+			} else {
+				/* ignore make.conf and/or env setting origin if defined by
+				 * repos.conf since the former are deprecated */
+				free(main_overlay);
+			}
+			main_overlay = NULL;  /* now added to overlays */
+		} else {
+			free(main_overlay);
+		}
+
+		/* set main_overlay to the one pointed to by repos.conf, if any */
+		i = 0;
+		if (primary_overlay != NULL) {
+			array_for_each(overlay_names, i, overlay) {
+				if (overlay == primary_overlay)
+					break;
+				overlay = NULL;
+			}
+			/* if no explicit overlay was flagged as main, take the
+			 * first one */
+			if (overlay == NULL)
+				i = 0;
+		}
+		main_overlay = array_get_elem(overlays, i);
+		/* set source for PORTDIR var */
+		free(var->src);
+		var->src = xstrdup((char *)array_get_elem(overlay_src, i));
+	}
+
 	/* Make sure ROOT always ends in a slash */
 	var = &vars_to_read[0];
 	if (var->value_len == 0 || (*var->value.s)[var->value_len - 1] != '/') {

diff --git a/q.c b/q.c
index a974df8..f137b04 100644
--- a/q.c
+++ b/q.c
@@ -174,8 +174,10 @@ int q_main(int argc, char **argv)
 			if (strcmp(repo_name, "<PORTDIR>") == 0) {
 				repo_name = NULL;
 				snprintf(buf, sizeof(buf), "%s/profiles/repo_name", overlay);
-				if (!eat_file(buf, &repo_name, &repo_name_len))
+				if (!eat_file(buf, &repo_name, &repo_name_len)) {
+					free(repo_name);
 					repo_name = NULL;
+				}
 				if (repo_name != NULL)
 					rmspace(repo_name);
 			}

diff --git a/qmanifest.c b/qmanifest.c
index c4c1322..bfc5e55 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -1749,10 +1749,14 @@ qmanifest_main(int argc, char **argv)
 		array_for_each(overlays, n, overlay) {
 			repo = xarrayget(overlay_names, n);
 			if (strcmp(repo, "<PORTDIR>") == 0) {
+				repo = NULL;
+				repolen = 0;
 				snprintf(path, sizeof(path), "%s/profiles/repo_name", overlay);
 				if (eat_file(path, &repo, &repolen)) {
 					free(array_get_elem(overlays, n));
 					array_get_elem(overlays, n) = repo;
+				} else {
+					free(repo);
 				}
 			}
 		}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-29 13:56 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-29 13:56 UTC (permalink / raw
  To: gentoo-commits

commit:     784f3743879ec97e08197d3b21ccec54ffce914d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 29 13:55:34 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Nov 29 13:55:34 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=784f3743

main: fix memleak for main_overlay in the correct way

the previous fix introduced a double free, the real problem is that the
original main_overlay pointer was taken before its default value was
assigned

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/main.c b/main.c
index 1f20b38..ba15c8c 100644
--- a/main.c
+++ b/main.c
@@ -617,7 +617,7 @@ read_one_repos_conf(const char *repos_conf)
 	nsec = iniparser_getnsec(dict);
 	while (nsec-- > 0) {
 		repo = iniparser_getsecname(dict, nsec);
-		if (!strcmp(repo, "DEFAULT"))
+		if (strcmp(repo, "DEFAULT") == 0)  /* already handled above */
 			continue;
 
 		xasprintf(&conf, "%s:location", repo);
@@ -646,7 +646,6 @@ read_one_repos_conf(const char *repos_conf)
 				xarraypush_str(overlay_src, repos_conf);
 			}
 			if (main_repo && strcmp(repo, main_repo) == 0) {
-				free(main_overlay);
 				main_overlay = ele;
 				free(vars_to_read[11 /* PORTDIR */].src);
 				vars_to_read[11 /* PORTDIR */].src = xstrdup(repos_conf);
@@ -720,7 +719,7 @@ initialize_portage_env(void)
 	env_vars *var;
 	char pathbuf[_Q_PATH_MAX];
 	const char *configroot = getenv("PORTAGE_CONFIGROOT");
-	char *orig_main_overlay = main_overlay;
+	char *orig_main_overlay;
 
 	/* initialize all the strings with their default value */
 	for (i = 0; vars_to_read[i].name; ++i) {
@@ -741,6 +740,7 @@ initialize_portage_env(void)
 
 	/* read overlays first so we can resolve repo references in profile
 	 * parent files */
+	orig_main_overlay = main_overlay;
 	snprintf(pathbuf, sizeof(pathbuf), "%.*s", (int)i, configroot);
 	read_repos_conf(pathbuf, "/usr/share/portage/config/repos.conf");
 	read_repos_conf(pathbuf, "/etc/portage/repos.conf");
@@ -752,6 +752,7 @@ initialize_portage_env(void)
 		xarraypush_str(overlay_src, STR_DEFAULT);
 	} else if (orig_main_overlay == main_overlay) {
 		/* if no explicit overlay was flagged as main, take the first one */
+		free(orig_main_overlay);
 		main_overlay = array_get_elem(overlays, 0);
 		set_portage_env_var(&vars_to_read[11] /* PORTDIR */, main_overlay,
 				(char *)array_get_elem(overlay_src, 0));


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-29 13:22 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-29 13:22 UTC (permalink / raw
  To: gentoo-commits

commit:     8febe8d3aae1033a3e9a63793ab46053860d18cf
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 29 13:20:26 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Nov 29 13:20:26 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8febe8d3

main/qsearch: plug some minor memleaks

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c    | 6 +++++-
 qsearch.c | 1 +
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 056e09c..1f20b38 100644
--- a/main.c
+++ b/main.c
@@ -510,8 +510,11 @@ read_portage_profile(const char *profile, env_vars vars[])
 	 * 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) == 0)
+	if (eat_file(profile_file, &buf, &buf_len) == 0) {
+		if (buf != NULL)
+			free(buf);
 		return;
+	}
 
 	s = strtok_r(buf, "\n", &saveptr);
 	while (s) {
@@ -643,6 +646,7 @@ read_one_repos_conf(const char *repos_conf)
 				xarraypush_str(overlay_src, repos_conf);
 			}
 			if (main_repo && strcmp(repo, main_repo) == 0) {
+				free(main_overlay);
 				main_overlay = ele;
 				free(vars_to_read[11 /* PORTDIR */].src);
 				vars_to_read[11 /* PORTDIR */].src = xstrdup(repos_conf);

diff --git a/qsearch.c b/qsearch.c
index 8245383..d6470f6 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -187,5 +187,6 @@ int qsearch_main(int argc, char **argv)
 		}
 	}
 
+	regfree(&state.search_expr);
 	return ret;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-25 19:51 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-25 19:51 UTC (permalink / raw
  To: gentoo-commits

commit:     4df5c3e4cd84692da9b6cdcc04315fa37b8dddea
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 25 19:50:53 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Nov 25 19:50:53 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4df5c3e4

read_portage_profile: process in order as specified by PMS 5.2.1

Ensure that value overrides work as intended.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/main.c b/main.c
index 6033429..5ffe0ba 100644
--- a/main.c
+++ b/main.c
@@ -494,9 +494,6 @@ read_portage_profile(const char *profile, env_vars vars[])
 	size_t buf_len = 0;
 	char *saveptr;
 
-	if (getenv("DEBUG"))
-		fprintf(stderr, "profile %s\n", profile);
-
 	/* create mutable/appendable copy */
 	profile_len = snprintf(profile_file, sizeof(profile_file), "%s/", profile);
 
@@ -504,11 +501,9 @@ read_portage_profile(const char *profile, env_vars vars[])
 	if (sizeof(profile_file) - profile_len < sizeof("make.defaults"))
 		return;
 
-	/* first consume the profile's make.defaults */
-	strcpy(profile_file + profile_len, "make.defaults");
-	read_portage_env_file(profile_file, vars);
-
-	/* now walk all the parents */
+	/* first walk all the parents, PMS 5.2.1 defines that it should
+	 * 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) == 0)
 		return;
@@ -552,6 +547,10 @@ read_portage_profile(const char *profile, env_vars vars[])
 	}
 
 	free(buf);
+
+	/* now consume *this* profile's make.defaults */
+	strcpy(profile_file + profile_len, "make.defaults");
+	read_portage_env_file(profile_file, vars);
 }
 
 static bool nocolor = 0;
@@ -749,6 +748,12 @@ initialize_portage_env(void)
 				(char *)array_get_elem(overlay_src, 0));
 	}
 
+	/* consider Portage's defaults */
+	snprintf(pathbuf, sizeof(pathbuf),
+			"%.*s/usr/share/portage/config/make.globals",
+			(int)i, configroot);
+	read_portage_env_file(pathbuf, vars_to_read);
+
 	/* walk all the stacked profiles */
 	snprintf(pathbuf, sizeof(pathbuf), "%.*s/etc/make.profile",
 			(int)i, configroot);
@@ -758,10 +763,6 @@ initialize_portage_env(void)
 	read_portage_profile(pathbuf, vars_to_read);
 
 	/* now read all the config files */
-	snprintf(pathbuf, sizeof(pathbuf),
-			"%.*s/usr/share/portage/config/make.globals",
-			(int)i, configroot);
-	read_portage_env_file(pathbuf, vars_to_read);
 	snprintf(pathbuf, sizeof(pathbuf), "%.*s/etc/make.conf",
 			(int)i, configroot);
 	read_portage_env_file(pathbuf, vars_to_read);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-25 19:39 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-25 19:39 UTC (permalink / raw
  To: gentoo-commits

commit:     0cea31fbdca8097a9d7d6ae431d09c7d7130a6e7
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 25 19:39:30 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Nov 25 19:39:30 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0cea31fb

main: properly track origin of PORTDIR variable

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index fb2340b..6033429 100644
--- a/main.c
+++ b/main.c
@@ -638,8 +638,11 @@ read_one_repos_conf(const char *repos_conf)
 				xarraypush_str(overlay_names, repo);
 				xarraypush_str(overlay_src, repos_conf);
 			}
-			if (main_repo && strcmp(repo, main_repo) == 0)
+			if (main_repo && strcmp(repo, main_repo) == 0) {
 				main_overlay = ele;
+				free(vars_to_read[11 /* PORTDIR */].src);
+				vars_to_read[11 /* PORTDIR */].src = xstrdup(repos_conf);
+			}
 		}
 		free(conf);
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-19 20:28 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-19 20:28 UTC (permalink / raw
  To: gentoo-commits

commit:     2fd5891051cb756d8299747cc7fbe01bb0382c2c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 19 20:27:50 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Nov 19 20:27:50 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2fd58910

qfile: include sys/stat.h because we use fstat

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qfile.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qfile.c b/qfile.c
index 8fa6eb4..6c2ebb8 100644
--- a/qfile.c
+++ b/qfile.c
@@ -13,6 +13,7 @@
 #include <xalloc.h>
 #include <sys/types.h>
 #include <fcntl.h>
+#include <sys/stat.h>
 
 #include "atom.h"
 #include "basename.h"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-19 20:28 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-19 20:28 UTC (permalink / raw
  To: gentoo-commits

commit:     9ffee655057ba300f4a8fb5bfdb91a42baad9c74
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 19 20:26:22 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Nov 19 20:26:22 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9ffee655

main: fix read_portage_profile to traverse ALL parents

Due to multiple thinkos and fails we never searched beyond the first
profile listed in the parent file.  Shame!

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/main.c b/main.c
index f8ba7af..e236934 100644
--- a/main.c
+++ b/main.c
@@ -570,9 +570,12 @@ read_portage_profile(const char *configroot, const char *profile, env_vars vars[
 	size_t configroot_len, profile_len, sub_len;
 	char *profile_file, *sub_file;
 	char *s;
+	char *buf = NULL;
+	size_t buf_len = 0;
+	char *saveptr;
 
-	static char *buf;
-	static size_t buf_len;
+	if (getenv("DEBUG"))
+		fprintf(stderr, "profile %s/%s\n", configroot, profile);
 
 	/* initialize the base profile path */
 	configroot_len = strlen(configroot);
@@ -593,13 +596,12 @@ read_portage_profile(const char *configroot, const char *profile, env_vars vars[
 	strcpy(sub_file, "parent");
 	if (eat_file(profile_file, &buf, &buf_len) == 0)
 		goto done;
-	rmspace(buf);
 
-	s = strtok(buf, "\n");
+	s = strtok_r(buf, "\n", &saveptr);
 	while (s) {
 		strncpy(sub_file, s, sub_len);
 		read_portage_profile("", profile_file, vars);
-		s = strtok(NULL, "\n");
+		s = strtok_r(NULL, "\n", &saveptr);
 	}
 
  done:


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-17 15:12 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-17 15:12 UTC (permalink / raw
  To: gentoo-commits

commit:     99f0dfe5e074dcd41155cdcd7b1c2e8abe825f50
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 17 15:05:51 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Nov 17 15:05:51 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=99f0dfe5

qpkg: drop misleading and incorrect message about unmatched packages

there is no relationship between input arguments and output packages
made (e.g. slots, sub-matches, etc.)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 7a1baae..f5e8168 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -430,7 +430,8 @@ int qpkg_main(int argc, char **argv)
 			atom = tree_get_atom(pkg_ctx, false);
 			snprintf(buf, sizeof(buf), "%s/%s", atom->CATEGORY, atom->PN);
 			for (i = optind; i < argc; ++i) {
-				if (!argv[i]) continue;
+				if (argv[i] == NULL)
+					continue;
 
 				if (!strcmp(argv[i], atom->PN) ||
 						!strcmp(argv[i], atom->P) ||
@@ -443,10 +444,6 @@ int qpkg_main(int argc, char **argv)
 		}
 	}
 
-	s = (argc - optind) - pkgs_made;
-	if (s && !pretend)
-		printf(" %s*%s %i package%s could not be matched :/\n",
-				RED, NORM, (int)s, (s > 1 ? "s" : ""));
 	if (pkgs_made)
 		qprintf(" %s*%s Packages can be found in %s\n",
 				GREEN, NORM, qpkg_bindir);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-17 15:12 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-17 15:12 UTC (permalink / raw
  To: gentoo-commits

commit:     f6458d94102bfba392d0f44ba158d1fe766cb6b5
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 17 15:12:27 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Nov 17 15:12:27 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f6458d94

qxpak: fix verbosity for extract

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qxpak.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qxpak.c b/qxpak.c
index c08b793..272a8e1 100644
--- a/qxpak.c
+++ b/qxpak.c
@@ -80,7 +80,7 @@ _xpak_callback(
 		printf("%.*s: %d byte%s\n",
 				pathname_len, pathname,
 				data_len, (data_len > 1 ? "s" : ""));
-	else
+	else if (verbose != 0)
 		printf("%.*s: %d byte%s @ offset byte %d\n",
 				pathname_len, pathname,
 				data_len, (data_len > 1 ? "s" : ""), data_offset);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-17 15:12 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-17 15:12 UTC (permalink / raw
  To: gentoo-commits

commit:     64dbab476d3a9d287b4d114f66923f0872a08774
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 17 11:51:58 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Nov 17 11:51:58 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=64dbab47

qlist: fix -a option

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlist.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/qlist.c b/qlist.c
index e0a8a07..a97111d 100644
--- a/qlist.c
+++ b/qlist.c
@@ -336,23 +336,22 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	depend_atom *atom;
 
 	/* see if this cat/pkg is requested */
-	for (i = optind; i < state->argc; ++i)
-		if (qlist_match(pkg_ctx, state->argv[i],
-					&state->atoms[i - optind], state->exact))
-			break;
-	if ((i == state->argc) && (state->argc != optind))
-		return 0;
+	if (!state->all) {
+		for (i = optind; i < state->argc; ++i)
+			if (qlist_match(pkg_ctx, state->argv[i],
+						&state->atoms[i - optind], state->exact))
+				break;
+		if (i == state->argc)
+			return 0;
+	}
 
 	atom = tree_get_atom(pkg_ctx, state->need_full_atom);
 	if (state->just_pkgname) {
-		if ((state->all + state->just_pkgname) < 2) {
-			printf("%s%s\n",
-					atom_format(state->fmt, atom),
-					umapstr(state->show_umap, pkg_ctx));
-		}
+		printf("%s%s\n",
+				atom_format(state->fmt, atom),
+				umapstr(state->show_umap, pkg_ctx));
 
-		if (!state->all)
-			return 1;
+		return 1;
 	}
 
 	if (verbose)
@@ -449,7 +448,7 @@ int qlist_main(int argc, char **argv)
 	/* default to showing syms and objs */
 	if (!state.show_dir && !state.show_obj && !state.show_sym)
 		state.show_obj = state.show_sym = true;
-	if (argc == optind && !state.just_pkgname)
+	if (argc == optind && !state.all)
 		qlist_usage(EXIT_FAILURE);
 
 	if (state.fmt == NULL) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-17 15:12 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-17 15:12 UTC (permalink / raw
  To: gentoo-commits

commit:     ff143361fe3b5eb7befefea5ab45440a6b8716db
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 17 14:22:11 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Nov 17 14:22:11 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ff143361

main: ensure READ/WRITE_BE_INT32 operate on the expected bytes

we want to work on unsigned bytes such that we don't get sudden
unintended operations due to negative value handling

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.h | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/main.h b/main.h
index ad1467b..03c3bd2 100644
--- a/main.h
+++ b/main.h
@@ -56,13 +56,16 @@ extern const char *argv0;
 #endif
 
 #define READ_BE_INT32(P) \
-	(((P)[0] << 24) | ((P)[1] << 16) | ((P)[2] << 8 ) | (P)[3])
+	((((unsigned char *)(P))[0] << 24) | \
+	 (((unsigned char *)(P))[1] << 16) | \
+	 (((unsigned char *)(P))[2] << 8 ) | \
+	 (((unsigned char *)(P))[3]))
 #define WRITE_BE_INT32(P,I) \
 { \
-	(P)[0] = (I & 0xff000000) >> 24; \
-	(P)[1] = (I & 0x00ff0000) >> 16; \
-	(P)[2] = (I & 0x0000ff00) >> 8; \
-	(P)[3] = (I & 0x000000ff); \
+	((unsigned char *)(P))[0] = (I & 0xff000000) >> 24; \
+	((unsigned char *)(P))[1] = (I & 0x00ff0000) >> 16; \
+	((unsigned char *)(P))[2] = (I & 0x0000ff00) >> 8; \
+	((unsigned char *)(P))[3] = (I & 0x000000ff); \
 }
 
 /* Easy enough to glue to older versions */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-17 15:12 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-17 15:12 UTC (permalink / raw
  To: gentoo-commits

commit:     c0f8d886914471a05a53679b4345070360fea242
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 17 12:30:33 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Nov 17 12:30:33 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c0f8d886

qxpak: fix list mode (forgotten newline)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qxpak.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qxpak.c b/qxpak.c
index fd0ec5d..c08b793 100644
--- a/qxpak.c
+++ b/qxpak.c
@@ -75,7 +75,7 @@ _xpak_callback(
 	}
 
 	if (verbose == 0 + (xctx->extract ? 1 : 0))
-		printf("%.*s", pathname_len, pathname);
+		printf("%.*s\n", pathname_len, pathname);
 	else if (verbose == 1 + (xctx->extract ? 1 : 0))
 		printf("%.*s: %d byte%s\n",
 				pathname_len, pathname,


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-15 13:52 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-15 13:52 UTC (permalink / raw
  To: gentoo-commits

commit:     2c58dc24df8cccf41d4126bb51e5cea8abaabb0f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 14 12:39:02 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Nov 14 12:39:02 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2c58dc24

qpkg: drop binpkgs in CATEGORY subdir for compliance

emaint doesn't get a pile of binpkgs, so stash them where it expects
them

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/qpkg.c b/qpkg.c
index 947ff84..7a1baae 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -29,6 +29,7 @@
 #include "xarray.h"
 #include "xasprintf.h"
 #include "xchdir.h"
+#include "xmkdir.h"
 #include "xpak.h"
 
 #define QPKG_FLAGS "cEpP:" COMMON_FLAGS
@@ -309,7 +310,13 @@ qpkg_make(depend_atom *atom)
 
 	unlink(filelist);
 
-	snprintf(buf, buflen, "%s/%s.tbz2", qpkg_bindir, atom_to_pvr(atom));
+	/* create dirs, if necessary */
+	snprintf(buf, buflen, "%s/%s",
+			qpkg_bindir, atom->CATEGORY);
+	mkdir_p(buf, 0755);
+
+	snprintf(buf, buflen, "%s/%s/%s.tbz2",
+			qpkg_bindir, atom->CATEGORY, atom_to_pvr(atom));
 	if (rename(tbz2, buf)) {
 		warnp("could not move '%s' to '%s'", tbz2, buf);
 		free(buf);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-13 18:19 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-13 18:19 UTC (permalink / raw
  To: gentoo-commits

commit:     2c99796e26485e2e838f4c36fc58e9f6b9267db0
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Wed Nov 13 18:18:55 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Nov 13 18:18:55 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2c99796e

qmerge: allow -s without arguments to list available packages

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 1196e67..c7b234e 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -2123,8 +2123,8 @@ parse_packages(set *todo)
 	struct pkg_t Pkg;
 	depend_atom *pkg_atom;
 	char repo[sizeof(Pkg.REPO)];
-	depend_atom **todo_atoms;
-	size_t todo_cnt;
+	depend_atom **todo_atoms = NULL;
+	size_t todo_cnt = 0;
 	size_t i;
 
 	fp = open_binpkg_index();
@@ -2161,7 +2161,7 @@ parse_packages(set *todo)
 	strcpy(Pkg.SLOT, "0");
 
 	/* build list with exploded atoms for each access below */
-	{
+	if (todo != NULL) {
 		char **todo_strs;
 		todo_cnt = list_set(todo, &todo_strs);
 		todo_atoms = xmalloc(sizeof(*todo_atoms) * todo_cnt);
@@ -2419,7 +2419,7 @@ int qmerge_main(int argc, char **argv)
 	for (i = optind; i < argc; ++i)
 		todo = qmerge_add_set(argv[i], todo);
 
-	if (todo == NULL) {
+	if (search_pkgs == 0 && todo == NULL) {
 		warn("need package names to work with");
 		return EXIT_FAILURE;
 	}
@@ -2454,6 +2454,7 @@ int qmerge_main(int argc, char **argv)
 	}
 
 	ret = qmerge_run(todo);
-	free_set(todo);
+	if (todo != NULL)
+		free_set(todo);
 	return ret;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-13 12:59 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-13 12:59 UTC (permalink / raw
  To: gentoo-commits

commit:     7698b3a4e1bdd309a77f075e430e9ef2b00d2daa
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 13 12:58:27 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Nov 13 12:58:27 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7698b3a4

qlop: avoid reporting bogus dates in fmt_elapsedtime

when the calculated seconds are negative, we probably had a corrupt log,
so just garbage in/garbage out without trying to interpret it or
something

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qlop.c b/qlop.c
index 95cd64b..dcf1d47 100644
--- a/qlop.c
+++ b/qlop.c
@@ -225,7 +225,7 @@ static char *fmt_elapsedtime(struct qlop_mode *flags, time_t e)
 	time_t ss;
 	size_t bufpos = 0;
 
-	if (flags->do_machine) {
+	if (flags->do_machine || e < 0) {
 		snprintf(_elapsed_buf, sizeof(_elapsed_buf),
 				"%s%zd%s",
 				GREEN, (size_t)e, NORM);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-13 12:53 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-13 12:53 UTC (permalink / raw
  To: gentoo-commits

commit:     7ba3ab567aee55dfae0779a3d76c535fea2023d1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 13 12:52:20 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Nov 13 12:52:20 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7ba3ab56

qlop: check return from localtime in fmt_date

bogus input can result in NULL, crashing strftime

Thanks Agostino Sarubbo

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/qlop.c b/qlop.c
index 601ad87..95cd64b 100644
--- a/qlop.c
+++ b/qlop.c
@@ -204,13 +204,14 @@ static char _date_buf[48];
 static char *fmt_date(struct qlop_mode *flags, time_t ts, time_t te)
 {
 	time_t t = flags->do_endtime ? te : ts;
+	struct tm lt;
 
-	if (flags->do_machine)
+	if (flags->do_machine || localtime_r(&t, &lt) == NULL)
 		snprintf(_date_buf, sizeof(_date_buf),
 				"%zd", (size_t)t);
 	else
 		strftime(_date_buf, sizeof(_date_buf),
-				"%Y-%m-%dT%H:%M:%S", localtime(&t));
+				"%Y-%m-%dT%H:%M:%S", &lt);
 
 	return _date_buf;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-13 12:53 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-13 12:53 UTC (permalink / raw
  To: gentoo-commits

commit:     b063fed2887ffb9702752de902de51c7828b92d2
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Nov 13 12:44:48 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Nov 13 12:44:48 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b063fed2

qlop: fix crash due to unwanted side-effect in conditional

Thanks Agostino Sarubbo for reporting

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qlop.c b/qlop.c
index 7083ea7..601ad87 100644
--- a/qlop.c
+++ b/qlop.c
@@ -426,9 +426,9 @@ static int do_emerge_log(
 
 			atom = NULL;
 			if (strncmp(p, "  >>> emerge ", 13) == 0 &&
-					(p = strchr(p + 13, ')')) != NULL)
+					(q = strchr(p + 13, ')')) != NULL)
 			{
-				p += 2;
+				p = q + 2;
 				q = strchr(p, ' ');
 				if (q != NULL) {
 					*q = '\0';


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-11-09 10:35 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-11-09 10:35 UTC (permalink / raw
  To: gentoo-commits

commit:     f41839e844ee2854c7300646cacd656f0d53afd7
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Sat Nov  9 10:33:49 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Nov  9 10:33:49 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f41839e8

qmerge: traverse VDB instead of metadata/ebuild tree as intended

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 5d5ee27..1196e67 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1133,7 +1133,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	}
 
 	/* Get a handle on the main vdb repo */
-	vdb = tree_open(portroot, portvdb);
+	vdb = tree_open_vdb(portroot, portvdb);
 	if (!vdb)
 		return;
 	cat_ctx = tree_open_cat(vdb, pkg->CATEGORY);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-10-27 12:23 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-10-27 12:23 UTC (permalink / raw
  To: gentoo-commits

commit:     c5d4a1fe049ecab12f0d99e1ae6d61477f2ac8bf
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 27 12:23:35 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct 27 12:23:35 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c5d4a1fe

TODO: remove done qlop task

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 2 --
 1 file changed, 2 deletions(-)

diff --git a/TODO.md b/TODO.md
index 619c7d1..f4775eb 100644
--- a/TODO.md
+++ b/TODO.md
@@ -95,7 +95,5 @@
   guestimate alternative to current time jumping
 - display excess time (+12:05) when overrunning guestimate to indicate
   longer run than last guestimate
-- read tail of file fro last merge/running?
 - multiple files support -- current opinion: don't do it
 - compressed file support, use guessing support from qmerge?
-- make -r use /proc where available to find real running merges


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-10-20 10:11 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-10-20 10:11 UTC (permalink / raw
  To: gentoo-commits

commit:     64d7723fba4740e0ba80e97f534a8b04500cabbf
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 20 10:10:58 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Oct 20 10:10:58 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=64d7723f

qmerge: fix up comment

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index a3686ac..5d5ee27 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1237,8 +1237,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 				 * needed to decompress the file. See
 				 * https://bugs.gentoo.org/show_bug.cgi?id=634980 */
 				compr = "I zstd --long=31";
-				/*
-				 * If really tar -I would be used we would have to quote:
+				/* If really tar -I would be used we would have to quote:
 				 * compr = "I \"zstd --long=31\"";
 				 * But actually we use a pipe (see below) */
 			} else if (mlen >= 4 &&


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-10-12 12:47 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-10-12 12:47 UTC (permalink / raw
  To: gentoo-commits

commit:     b9eca954b9f0518916f390039b43eff46f0ee67e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Oct 12 12:43:19 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Oct 12 12:43:19 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b9eca954

qfile: fix matching of full paths, bug #697094

- properly handle trailing slashes, this is necessary because we use a
  custom basename that doesn't strip it
- fix bug in creating realpath of dirname, resulting in one path
  component short
- cleanup some match conditions

Bug: https://bugs.gentoo.org/697094
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qfile.c | 72 ++++++++++++++++++++++++++++++++---------------------------------
 1 file changed, 36 insertions(+), 36 deletions(-)

diff --git a/qfile.c b/qfile.c
index 63b47da..8fa6eb4 100644
--- a/qfile.c
+++ b/qfile.c
@@ -171,6 +171,7 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	short *non_orphans = args->non_orphans;
 	int *results = args->results;
 	int found = 0;
+	size_t len;
 
 	/* If exclude_pkg is not NULL, check it.  We are looking for files
 	 * collisions, and must exclude one package. */
@@ -223,23 +224,22 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 			if (non_orphans != NULL && non_orphans[i])
 				continue;
 
-			/* For optimization of qfile(), we also give it an array of
-			 * the first char of each basename.  This way we avoid
-			 * numerous strcmp() calls. */
+			/* Try to avoid numerous strcmp() calls. */
 			if (base[0] != base_names[i][0] || strcmp(base, base_names[i]) != 0)
 				continue;
 
 			path_ok = false;
 
-			if (dir_names[i] &&
-					strncmp(e->name, dir_names[i], dirname_len) == 0 &&
-					dir_names[i][dirname_len] == '\0')
+			if (dir_names[i] && (len = strlen(dir_names[i])) > 0 &&
+					len == dirname_len &&
+					memcmp(e->name, dir_names[i], len) == 0)
 			{
 				/* dir_name == dirname(CONTENTS) */
 				path_ok = true;
 			} else if (real_dir_names[i] &&
-					strncmp(e->name, real_dir_names[i], dirname_len) == 0 &&
-					real_dir_names[i][dirname_len] == '\0')
+					(len = strlen(real_dir_names[i])) > 0 &&
+					len == dirname_len &&
+					memcmp(e->name, real_dir_names[i], len) == 0)
 			{
 				/* real_dir_name == dirname(CONTENTS) */
 				path_ok = true;
@@ -276,19 +276,19 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				}
 			}
 
-			if (!path_ok && state->basename) {
+			if (!path_ok && state->basename)
 				path_ok = true;
-			}
 
 			if (!path_ok && state->pwd && dir_names[i] == NULL) {
 				/* try to match file in current directory */
-				if (strncmp(e->name, state->pwd, dirname_len) == 0 &&
-						state->pwd[dirname_len] == '\0')
+				if ((len = strlen(state->pwd)) > 0 &&
+						len == dirname_len &&
+						memcmp(e->name, state->pwd, len) == 0)
 					path_ok = true;
 			}
 
 			if (!path_ok && dir_names[i] == NULL && real_dir_names[i] == NULL) {
-				/* try basename match */
+				/* basename match */
 				if (e->type != CONTENTS_DIR)
 					path_ok = true;
 			}
@@ -357,7 +357,7 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 	char **realdirnames = NULL;
 	int *results = NULL;
 	char tmppath[_Q_PATH_MAX];
-	char abspath[_Q_PATH_MAX];
+	char abspath[_Q_PATH_MAX * 2];
 
 	/* For each argument, we store its basename, its absolute dirname,
 	 * and the realpath of its dirname.  Dirnames and their realpaths
@@ -370,11 +370,15 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 	results = xcalloc(argc, sizeof(int));
 
 	for (i = 0; i < argc; ++i) {
-		/* Record basename, but if it is ".", ".." or "/" */
-		/* copy so that "argv" can be "const" */
-		snprintf(tmppath, sizeof(tmppath), "%s", argv[i]);
+		/* copy so that "argv" can be "const", but skip trailing /
+		 * because our basename doesn't modify its input */
+		len = strlen(argv[i]);
+		if (len > 1 && argv[i][len - 1] == '/')
+			len--;
+		snprintf(tmppath, sizeof(tmppath), "%.*s", (int)len, argv[i]);
 		p = basename(tmppath);
-		len = strlen(p);
+
+		/* record basename, but if it is ".", ".." or "/" */
 		if ((len > 2) ||
 		    (strncmp(tmppath, "..", len) != 0 &&
 		     strncmp(tmppath, "/", len) != 0))
@@ -388,15 +392,15 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 
 		/* Make sure we have an absolute path available (with
 		 * "realpath(ROOT)" prefix) */
-		if (argv[i][0] == '/') {
+		if (tmppath[0] == '/') {
 			snprintf(abspath, sizeof(abspath), "%s%s",
-					state->assume_root_prefix ? "" : real_root, argv[i]);
+					state->assume_root_prefix ? "" : real_root, tmppath);
 		} else if (pwd) {
 			if (state->assume_root_prefix)
-				snprintf(abspath, sizeof(abspath), "%s/%s", pwd, argv[i]);
+				snprintf(abspath, sizeof(abspath), "%s/%s", pwd, tmppath);
 			else
 				snprintf(abspath, sizeof(abspath), "%s%s/%s",
-						real_root, pwd, argv[i]);
+						real_root, pwd, tmppath);
 		} else {
 			warn("$PWD was not found in environment, "
 					"or is not an absolute path");
@@ -424,11 +428,8 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 						tmppath, abspath);
 				goto skip_query_item;
 			}
-			snprintf(tmppath, sizeof(tmppath), "%s%s",
-					dirname(abspath),
-					abspath[real_root_len] == '\0' ? "/" : "");
-			if (strcmp(dirnames[i], tmppath + real_root_len))
-				realdirnames[i] = xstrdup(tmppath + real_root_len);
+			if (strcmp(dirnames[i], abspath + real_root_len))
+				realdirnames[i] = xstrdup(abspath + real_root_len);
 		} else {
 			/* No basename means we are looking for something like "/foo/bar/.."
 			 * Dirname is meaningless here, we can only get realpath of the full
@@ -442,8 +443,7 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 						abspath, tmppath);
 				goto skip_query_item;
 			}
-			snprintf(abspath, sizeof(abspath), "%s", tmppath);
-			basenames[i] = xstrdup(basename(abspath));
+			basenames[i] = xstrdup(basename(tmppath));
 			snprintf(abspath, sizeof(abspath), "%s%s",
 					dirname(tmppath),
 					tmppath[real_root_len] == '\0' ? "/" : "");
@@ -451,13 +451,13 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 		}
 		continue;
 
-		skip_query_item:
-			--nb_of_queries;
-			warn("Skipping query item \"%s\".", argv[i]);
-			free(basenames[i]);
-			free(dirnames[i]);
-			free(realdirnames[i]);
-			basenames[i] = dirnames[i] = realdirnames[i] = NULL;
+ skip_query_item:
+		--nb_of_queries;
+		warn("Skipping query item \"%s\".", argv[i]);
+		free(basenames[i]);
+		free(dirnames[i]);
+		free(realdirnames[i]);
+		basenames[i] = dirnames[i] = realdirnames[i] = NULL;
 	}
 
 	args->basenames = basenames;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-10-03 11:50 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-10-03 11:50 UTC (permalink / raw
  To: gentoo-commits

commit:     3d88c2912ee04e9bb9d2359e3a62ee9f22056447
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Oct  3 11:49:48 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Oct  3 11:49:48 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3d88c291

qgrep: fix matching revisioned ebuilds

Bug: https://bugs.gentoo.org/696078
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 1 +
 qgrep.c | 7 ++++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/TODO.md b/TODO.md
index 299cf17..3db00f7 100644
--- a/TODO.md
+++ b/TODO.md
@@ -32,6 +32,7 @@
   foo-(1234)\_alpha(56789)
 - these limits should not be an issue for all practical purposes
 - remove zalloc from atom explode (just initialise what needs to)
+- make PVR match PMS https://dev.gentoo.org/~ulm/pms/head/pms.html#x1-10800011
 
 # qmerge
 

diff --git a/qgrep.c b/qgrep.c
index 1f6d0de..2a64d1b 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -416,14 +416,15 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	}
 
 	/* cat/pkg/pkg-ver.ebuild */
-	snprintf(buf, sizeof(buf), "%s/%s/%s.ebuild",
-			patom->CATEGORY, patom->PN, patom->P);
+	snprintf(buf, sizeof(buf), "%s/%s/%s-%s.ebuild",
+			patom->CATEGORY, patom->PN, patom->PN,
+			patom->PR_int > 0 ? patom->PVR : patom->PV);
 
 	label = NULL;
 	if (data->show_name) {
 		if (data->show_repo)
 			patom = tree_get_atom(pkg_ctx, true);
-		atom_format_r(name, sizeof(name), "%[CATEGORY]%[P]%[REPO]", patom);
+		atom_format_r(name, sizeof(name), "%[CATEGORY]%[PF]%[REPO]", patom);
 		label = name;
 	} else if (data->show_filename) {
 		label = buf;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-09-29 12:18 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-09-29 12:18 UTC (permalink / raw
  To: gentoo-commits

commit:     f05c78008b1754a79e31e793a67d07ed8f5d11bc
Author:     sbesl <sambesselink <AT> planet <DOT> nl>
AuthorDate: Fri Aug  9 22:31:57 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Sep 29 12:13:18 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f05c7800

Make qfile also check the prune lib registry

Modifications by Fabian Groffen <grobian <AT> gentoo.org>:
- indentation fixes
- declarations go on top
- no C99 features
- adapt style to 0.80 release

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qfile.c | 105 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 103 insertions(+), 2 deletions(-)

diff --git a/qfile.c b/qfile.c
index bc5c9ac..63b47da 100644
--- a/qfile.c
+++ b/qfile.c
@@ -20,7 +20,7 @@
 #include "rmspace.h"
 #include "tree.h"
 
-#define QFILE_FLAGS "F:doRx:S" COMMON_FLAGS
+#define QFILE_FLAGS "F:doRx:SP" COMMON_FLAGS
 static struct option const qfile_long_opts[] = {
 	{"format",       a_argument, NULL, 'F'},
 	{"slots",       no_argument, NULL, 'S'},
@@ -28,6 +28,7 @@ static struct option const qfile_long_opts[] = {
 	{"dir",         no_argument, NULL, 'd'},
 	{"orphans",     no_argument, NULL, 'o'},
 	{"exclude",      a_argument, NULL, 'x'},
+	{"skip-plibreg",no_argument, NULL, 'P'},
 	COMMON_LONG_OPTS
 };
 static const char * const qfile_opts_help[] = {
@@ -37,6 +38,7 @@ static const char * const qfile_opts_help[] = {
 	"Also match directories for single component arguments",
 	"List orphan files",
 	"Don't look in package <arg> (used with --orphans)",
+	"Don't look in the prunelib registry",
 	COMMON_OPTS_HELP
 };
 #define qfile_usage(ret) usage(ret, QFILE_FLAGS, qfile_long_opts, qfile_opts_help, NULL, lookup_applet_idx("qfile"))
@@ -53,6 +55,7 @@ typedef struct {
 	char **dirnames;
 	char **realdirnames;
 	short *non_orphans;
+	int *results;
 } qfile_args_t;
 
 struct qfile_opt_state {
@@ -69,10 +72,88 @@ struct qfile_opt_state {
 	bool basename;
 	bool orphans;
 	bool assume_root_prefix;
+	bool skip_plibreg;
 	const char *format;
 	bool need_full_atom;
 };
 
+/*
+ * As a final step, check if file is in the plib_reg
+ */
+static int qfile_check_plibreg(void *priv)
+{
+	struct qfile_opt_state *state = priv;
+
+	char fn_plibreg[_Q_PATH_MAX];
+	int fd_plibreg;
+	FILE *fp_plibreg;
+	struct stat cst;
+
+	char file[_Q_PATH_MAX];
+	char *line = NULL;
+	size_t len = 0;
+	int found = 0;
+	int i;
+
+	qfile_args_t *args = &state->args;
+	char **base_names = args->basenames;
+	char **dir_names = args->dirnames;
+	short *non_orphans = args->non_orphans;
+	int *results = args->results;
+
+	/* Open plibreg */
+	snprintf(fn_plibreg, _Q_PATH_MAX, "%s%s",
+			CONFIG_EPREFIX, "var/lib/portage/preserved_libs_registry");
+	fp_plibreg = NULL;
+	fd_plibreg = open(fn_plibreg, O_RDONLY|O_CLOEXEC, 0);
+	if (fd_plibreg == -1)
+		return 0;
+	if (fstat(fd_plibreg, &cst)) {
+		close(fd_plibreg);
+		return 0;
+	}
+	if ((fp_plibreg = fdopen(fd_plibreg, "r")) == NULL) {
+		close(fd_plibreg);
+		return 0;
+	}
+
+	for (i = 0; i < args->length; i++) {
+		if (base_names[i] == NULL)
+			continue;
+		if (non_orphans && non_orphans[i])
+			continue;
+		if (results[i] == 1)
+			continue;
+
+		if (dir_names[i] != NULL)
+			snprintf(file, sizeof(file), "%s/%s", dir_names[i], base_names[i]);
+		else
+			snprintf(file, sizeof(file), "%s", base_names[i]);
+
+		while (getline(&line, &len, fp_plibreg) != -1)
+			if (strstr(line, file) != NULL) {
+				found++;
+				if (!quiet)
+					printf("%splib_registry%s\n", BLUE, NORM);
+				else
+					printf("%splib_registry%s: %s\n", BLUE, NORM, file);
+			}
+	}
+
+	if (line)
+		free(line);
+
+	return found;
+}
+
+/*
+ * 1. Do package exclusion tests
+ * 2. Run through CONTENTS file, perform tests and fail-by-continue
+ * 3. On success bump and return retvalue 'found'
+ *
+ * We assume the people calling us have chdir(/var/db/pkg) and so
+ * we use relative paths throughout here.
+ */
 static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 {
 	struct qfile_opt_state *state = priv;
@@ -88,6 +169,7 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	char **dir_names = args->dirnames;
 	char **real_dir_names = args->realdirnames;
 	short *non_orphans = args->non_orphans;
+	int *results = args->results;
 	int found = 0;
 
 	/* If exclude_pkg is not NULL, check it.  We are looking for files
@@ -116,6 +198,7 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	if (fp == NULL)
 		goto qlist_done;
 
+	/* Run through CONTENTS file */
 	while (getline(&state->buf, &state->buflen, fp) != -1) {
 		size_t dirname_len;
 		contents_entry *e;
@@ -224,6 +307,9 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 			} else {
 				non_orphans[i] = 1;
 			}
+
+			/* Success */
+			results[i] = 1;
 			found++;
 		}
 	}
@@ -250,6 +336,7 @@ static void destroy_qfile_args(qfile_args_t *qfile_args)
 	free(qfile_args->dirnames);
 	free(qfile_args->realdirnames);
 	free(qfile_args->non_orphans);
+	free(qfile_args->results);
 
 	memset(qfile_args, 0, sizeof(qfile_args_t));
 }
@@ -268,6 +355,7 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 	char **basenames = NULL;
 	char **dirnames = NULL;
 	char **realdirnames = NULL;
+	int *results = NULL;
 	char tmppath[_Q_PATH_MAX];
 	char abspath[_Q_PATH_MAX];
 
@@ -279,6 +367,7 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 	basenames = xcalloc(argc, sizeof(char*));
 	dirnames = xcalloc(argc, sizeof(char*));
 	realdirnames = xcalloc(argc, sizeof(char*));
+	results = xcalloc(argc, sizeof(int));
 
 	for (i = 0; i < argc; ++i) {
 		/* Record basename, but if it is ".", ".." or "/" */
@@ -375,6 +464,7 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 	args->dirnames = dirnames;
 	args->realdirnames = realdirnames;
 	args->length = argc;
+	args->results = results;
 
 	if (state->orphans)
 		args->non_orphans = xcalloc(argc, sizeof(short));
@@ -390,6 +480,7 @@ int qfile_main(int argc, char **argv)
 		.basename = false,
 		.orphans = false,
 		.assume_root_prefix = false,
+		.skip_plibreg = false,
 		.format = NULL,
 	};
 	int i, nb_of_queries, found = 0;
@@ -403,6 +494,7 @@ int qfile_main(int argc, char **argv)
 			case 'd': state.basename = true;            break;
 			case 'o': state.orphans = true;             break;
 			case 'R': state.assume_root_prefix = true;  break;
+			case 'P': state.skip_plibreg = true;        break;
 			case 'x':
 				if (state.exclude_pkg)
 					err("--exclude can only be used once.");
@@ -471,7 +563,8 @@ int qfile_main(int argc, char **argv)
 
 	/* Prepare the qfile(...) arguments structure */
 	nb_of_queries = prepare_qfile_args(argc, (const char **) argv, &state);
-	/* Now do the actual `qfile` checking */
+
+	/* Now do the actual `qfile` checking by looking at CONTENTS of all pkgs */
 	if (nb_of_queries > 0) {
 		tree_ctx *vdb = tree_open_vdb(portroot, portvdb);
 		if (vdb != NULL) {
@@ -480,6 +573,14 @@ int qfile_main(int argc, char **argv)
 		}
 	}
 
+	/* Also check the prune lib registry.
+	 * But only for files we otherwise couldn't account for. If we'd
+	 * check plib_reg for all files, we would get duplicate messages for
+	 * files that were re-added to CONTENTS files after a version
+	 * upgrade (which are also recorded in plib_reg). */
+	if (nb_of_queries > 0 && !state.skip_plibreg)
+		found += qfile_check_plibreg(&state);
+
 	if (state.args.non_orphans) {
 		/* display orphan files */
 		for (i = 0; i < state.args.length; i++) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-09-28 13:28 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-09-28 13:28 UTC (permalink / raw
  To: gentoo-commits

commit:     e68e90f5eee468a5523b2daee3902578de43cf15
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 28 13:27:51 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Sep 28 13:27:51 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e68e90f5

TODO: update with new ideas and things done

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 20 +++++++++++++++-----
 1 file changed, 15 insertions(+), 5 deletions(-)

diff --git a/TODO.md b/TODO.md
index 8e12c0d..299cf17 100644
--- a/TODO.md
+++ b/TODO.md
@@ -4,9 +4,7 @@
 	- default \*foo\*
 	- -e foo
 	- -r (-R ?) regexp foo.\*
-- make default -e for apps like quse/qdepends?
-
-- make set.c to array (xarray) instead of C-array (list)
+- make default -e for apps like quse/qdepends/qlist?
 
 - env vars only get expanded once, so this fails:<br>
   `ACCEPT_LICENSE="foo"`<br>
@@ -18,7 +16,14 @@
   cat?) to reduce search space
 
 - tree\_get\_atoms should return atoms iso string set, needs a rewrite
-  to use foreach\_pkg and get\_atom
+  to use foreach\_pkg and get\_atom -- set is ready for storing objects
+  now
+
+- implement our own iniparser so we *can* be dep-free
+
+- add applet/functionality to view latest version of package in tree
+  (functionality necessary for upgrade in qmerge, easy printing would
+  also allow to use q instead of eix from Puppet provider)
 
 # Atoms
 
@@ -58,10 +63,11 @@
 
 # qpkg
 
-- fix "would be freed" message when --pretend is *not* active
 - add a verbose output that describes why a package is cleaned
 	- newer binpkgs available
 	- newer installed version available
+- integrate qxpak and qtbz2 with this package (the latter are confusing,
+  and qpkg is doing parts of qtbz2's compose
 
 # qgrep
 
@@ -73,6 +79,7 @@
 
 # quse
 - make -v only print requested USE-flag when flags given
+- list each package only once (e.g. quse -e lz4)
 
 # qkeyword
 - drop -c argument? it can be fully expressed using -p cat/
@@ -87,3 +94,6 @@
   guestimate alternative to current time jumping
 - display excess time (+12:05) when overrunning guestimate to indicate
   longer run than last guestimate
+- read tail of file fro last merge/running?
+- multiple files support -- current opinion: don't do it
+- compressed file support, use guessing support from qmerge?


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-09-28 13:06 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-09-28 13:06 UTC (permalink / raw
  To: gentoo-commits

commit:     03912c73fb68cdfe6f45f26fc4f5efd099e41262
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 28 13:05:13 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Sep 28 13:05:13 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=03912c73

qpkg: fix tbz2 xpak generation

The xpak footer was missing causing files not to contain their metadata
(even though present in the file).

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 85e0940..0ac6e92 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -105,12 +105,11 @@ qpkg_clean_dir(char *dirp, set *vdb)
 				if ((st.st_size / KILOBYTE) > 1000)
 					disp_units = MEGABYTE;
 				num_all_bytes += st.st_size;
-				qprintf(" %s[%s%s %3s %s %s%s]%s %s%s/%s%s\n",
-						DKBLUE, NORM, GREEN,
+				qprintf(" %s[%s %3s %s %s] %s%s%s\n",
+						DKBLUE, GREEN,
 						make_human_readable_str(st.st_size, 1, disp_units),
-						disp_units == MEGABYTE ? "M" : "K",
-						NORM, DKBLUE, NORM, CYAN,
-						basename(dirp), fnames[i]->d_name, NORM);
+						disp_units == MEGABYTE ? "MiB" : "KiB",
+						DKBLUE, BLUE, fnames[i]->d_name, NORM);
 			}
 			if (!pretend)
 				unlink(buf);
@@ -211,6 +210,7 @@ qpkg_make(depend_atom *atom)
 	char filelist[BUFSIZE + 32];
 	char tbz2[BUFSIZE + 32];
 	size_t buflen;
+	size_t xpaksize;
 	char *buf;
 	int i;
 	char *xpak_argv[2];
@@ -286,12 +286,25 @@ qpkg_make(depend_atom *atom)
 	}
 	pclose(fp);
 
+	/* get offset where xpak will start */
+	stat(tbz2, &st);
+	xpaksize = st.st_size;
+
 	snprintf(buf, buflen, "%s/%s/%s",
 			portvdb, atom->CATEGORY, atom_to_pvr(atom));
 	xpak_argv[0] = buf;
 	xpak_argv[1] = NULL;
 	xpak_create(AT_FDCWD, tbz2, 1, xpak_argv, 1, verbose);
 
+	stat(tbz2, &st);
+
+	/* save tbz2 tail: OOOOSTOP */
+	fp = fopen(tbz2, "a");
+	WRITE_BE_INT32(buf, st.st_size - xpaksize);
+	fwrite(buf, 1, 4, fp);
+	fwrite("STOP", 1, 4, fp);
+	fclose(fp);
+
 	unlink(filelist);
 
 	snprintf(buf, buflen, "%s/%s.tbz2", qpkg_bindir, atom_to_pvr(atom));


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-09-26 19:28 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-09-26 19:28 UTC (permalink / raw
  To: gentoo-commits

commit:     e25a88e643669be1b04b89f760ca3ffe99ccb92d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 26 19:28:26 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Sep 26 19:28:26 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e25a88e6

qmanifest: squash warning about extra tokens after ifdef directive

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmanifest.c b/qmanifest.c
index 10cd39c..fee0151 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -91,7 +91,7 @@ char verify_manifest(const char *dir, const char *manifest, verify_msg **msgs);
 static inline void
 update_times(struct timeval *tv, struct stat *s)
 {
-#ifdef __MACH__ && defined __APPLE__
+#if defined (__MACH__) && defined __APPLE__
 # define st_mtim st_mtimespec
 # define st_atim st_atimespec
 #endif


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-09-26 19:28 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-09-26 19:28 UTC (permalink / raw
  To: gentoo-commits

commit:     9d36886cbbececda954d7de41a59bf1e8733ed1c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 26 19:26:55 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Sep 26 19:26:55 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9d36886c

qpkg: drop weird location choice for binpkgs

If someone wants to put packages in /var/tmp or $HOME, then -P should be
used.  Ignoring portage-config pkgdir is odd, if one can't write there,
-P is there to the rescue.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 61 ++++++++++++++++++++++++-------------------------------------
 1 file changed, 24 insertions(+), 37 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 29265f2..85e0940 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -173,27 +173,13 @@ qpkg_clean(char *dirp)
 	if ((num_all_bytes / KILOBYTE) > 1000)
 		disp_units = MEGABYTE;
 	qprintf(" %s*%s Total space that would be freed in packages "
-			"directory: %s%s %c%s\n", GREEN, NORM, RED,
+			"directory: %s%s %ciB%s\n", GREEN, NORM, RED,
 			make_human_readable_str(num_all_bytes, 1, disp_units),
 			disp_units == MEGABYTE ? 'M' : 'K', NORM);
 
 	return 0;
 }
 
-static const char *
-qpkg_get_bindir(void)
-{
-	if (qpkg_bindir != NULL)
-		return qpkg_bindir;
-	if (getuid() == 0)
-		return "/var/tmp/binpkgs";
-	if (getenv("HOME") == NULL)
-		errp("Your $HOME env var isn't set, aborting");
-	xasprintf(&qpkg_bindir, "%s/binpkgs", getenv("HOME"));
-
-	return qpkg_bindir;
-}
-
 static int
 check_pkg_install_mask(char *name)
 {
@@ -246,7 +232,7 @@ qpkg_make(depend_atom *atom)
 		return -1;
 	}
 
-	snprintf(tmpdir, sizeof(tmpdir), "%s/qpkg.XXXXXX", qpkg_get_bindir());
+	snprintf(tmpdir, sizeof(tmpdir), "%s/qpkg.XXXXXX", qpkg_bindir);
 	if ((i = mkstemp(tmpdir)) == -1) {
 		free(buf);
 		return -2;
@@ -308,7 +294,7 @@ qpkg_make(depend_atom *atom)
 
 	unlink(filelist);
 
-	snprintf(buf, buflen, "%s/%s.tbz2", qpkg_get_bindir(), atom_to_pvr(atom));
+	snprintf(buf, buflen, "%s/%s.tbz2", qpkg_bindir, atom_to_pvr(atom));
 	if (rename(tbz2, buf)) {
 		warnp("could not move '%s' to '%s'", tbz2, buf);
 		free(buf);
@@ -318,7 +304,7 @@ qpkg_make(depend_atom *atom)
 	rmdir(tmpdir);
 
 	stat(buf, &st);
-	printf("%s%s%s kB\n",
+	printf("%s%s%s KiB\n",
 			RED, make_human_readable_str(st.st_size, 1, KILOBYTE), NORM);
 
 	free(buf);
@@ -334,11 +320,11 @@ int qpkg_main(int argc, char **argv)
 	int i;
 	struct stat st;
 	char buf[BUFSIZE];
-	const char *bindir;
 	depend_atom *atom;
 	int restrict_chmod = 0;
 	int qclean = 0;
 
+	qpkg_bindir = pkgdir;
 	while ((i = GETOPT_LONG(QPKG, qpkg, "")) != -1) {
 		switch (i) {
 		case 'E': eclean = qclean = 1; break;
@@ -346,8 +332,7 @@ int qpkg_main(int argc, char **argv)
 		case 'p': pretend = 1; break;
 		case 'P':
 			restrict_chmod = 1;
-			free(qpkg_bindir);
-			qpkg_bindir = xstrdup(optarg);
+			qpkg_bindir = optarg;
 			if (access(qpkg_bindir, W_OK) != 0)
 				errp("%s", qpkg_bindir);
 			break;
@@ -355,28 +340,29 @@ int qpkg_main(int argc, char **argv)
 		}
 	}
 	if (qclean)
-		return qpkg_clean(qpkg_bindir == NULL ? pkgdir : qpkg_bindir);
+		return qpkg_clean(qpkg_bindir);
 
 	if (argc == optind)
 		qpkg_usage(EXIT_FAILURE);
 
 	/* setup temp dirs */
-	i = 0;
-	bindir = qpkg_get_bindir();
-	if (*bindir != '/')
-		err("'%s' is not a valid package destination", bindir);
-retry_mkdir:
-	if (mkdir(bindir, 0750) == -1) {
-		lstat(bindir, &st);
-		if (!S_ISDIR(st.st_mode)) {
-			unlink(bindir);
-			if (!i++) goto retry_mkdir;
-			errp("could not create temp bindir '%s'", bindir);
+	if (qpkg_bindir[0] != '/')
+		err("'%s' is not a valid package destination", qpkg_bindir);
+	for (i = 0; i <= 1; i++) {
+		if (mkdir(qpkg_bindir, 0750) == -1) {
+			lstat(qpkg_bindir, &st);
+			if (!S_ISDIR(st.st_mode)) {
+				unlink(qpkg_bindir);
+				continue;
+			}
+			if (!restrict_chmod)
+				if (chmod(qpkg_bindir, 0750))
+					errp("could not chmod(0750) temp bindir '%s'", qpkg_bindir);
 		}
-		if (!restrict_chmod)
-			if (chmod(bindir, 0750))
-				errp("could not chmod(0750) temp bindir '%s'", bindir);
+		break;
 	}
+	if (i == 2)
+		errp("could not create temp bindir '%s'", qpkg_bindir);
 
 	/* we have to change to the root so that we can feed the full paths
 	 * to tar when we create the binary package. */
@@ -440,7 +426,8 @@ retry_mkdir:
 		printf(" %s*%s %i package%s could not be matched :/\n",
 				RED, NORM, (int)s, (s > 1 ? "s" : ""));
 	if (pkgs_made)
-		qprintf(" %s*%s Packages can be found in %s\n", GREEN, NORM, bindir);
+		qprintf(" %s*%s Packages can be found in %s\n",
+				GREEN, NORM, qpkg_bindir);
 
 	return (pkgs_made ? EXIT_SUCCESS : EXIT_FAILURE);
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-09-26 14:06 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-09-26 14:06 UTC (permalink / raw
  To: gentoo-commits

commit:     10bf7790021c157173c4a0294f417eb81aae3842
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 26 13:23:03 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Sep 26 13:23:03 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=10bf7790

qlop: make -v consider revisions as significant too (for -a)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/qlop.c b/qlop.c
index fcaf973..b75988a 100644
--- a/qlop.c
+++ b/qlop.c
@@ -613,10 +613,15 @@ static int do_emerge_log(
 					if (flags->do_average || flags->do_running)
 					{
 						/* find in list of averages */
-						snprintf(afmt, sizeof(afmt), "%s/%s",
-								pkgw->atom->CATEGORY,
-								(!verbose || flags->do_running) ?
-								pkgw->atom->PN : pkgw->atom->P);
+						if (!verbose || flags->do_running) {
+							snprintf(afmt, sizeof(afmt), "%s/%s",
+								pkgw->atom->CATEGORY, pkgw->atom->PN);
+						} else {
+							snprintf(afmt, sizeof(afmt), "%s/%s-%s",
+								pkgw->atom->CATEGORY, pkgw->atom->PN,
+								pkgw->atom->PR_int > 0 ?
+								pkgw->atom->PVR : pkgw->atom->PV);
+						}
 
 						pkg = add_set_value(afmt, pkgw, merge_averages);
 						if (pkg != NULL) {
@@ -752,10 +757,15 @@ static int do_emerge_log(
 					if (flags->do_average || flags->do_running)
 					{
 						/* find in list of averages */
-						snprintf(afmt, sizeof(afmt), "%s/%s",
-								pkgw->atom->CATEGORY,
-								(!verbose || flags->do_running) ?
-								pkgw->atom->PN : pkgw->atom->P);
+						if (!verbose || flags->do_running) {
+							snprintf(afmt, sizeof(afmt), "%s/%s",
+								pkgw->atom->CATEGORY, pkgw->atom->PN);
+						} else {
+							snprintf(afmt, sizeof(afmt), "%s/%s-%s",
+								pkgw->atom->CATEGORY, pkgw->atom->PN,
+								pkgw->atom->PR_int > 0 ?
+								pkgw->atom->PVR : pkgw->atom->PV);
+						}
 
 						pkg = add_set_value(afmt, pkgw, unmerge_averages);
 						if (pkg != NULL) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-09-26 14:06 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-09-26 14:06 UTC (permalink / raw
  To: gentoo-commits

commit:     ae999cf28829aad734b43255941b2c4449fc951b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Sep 26 13:54:22 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Sep 26 13:54:22 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ae999cf2

qlop: sort average output before display

sort the package lists using atom order for some consistency after set
usage

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 29 +++++++++++++++++++++--------
 1 file changed, 21 insertions(+), 8 deletions(-)

diff --git a/qlop.c b/qlop.c
index b75988a..4347699 100644
--- a/qlop.c
+++ b/qlop.c
@@ -279,6 +279,25 @@ static char *fmt_elapsedtime(struct qlop_mode *flags, time_t e)
 	return _elapsed_buf;
 }
 
+struct pkg_match {
+	char id[BUFSIZ];
+	depend_atom *atom;
+	time_t tbegin;
+	time_t time;
+	size_t cnt;
+};
+
+static int
+pkg_sort_cb(const void *l, const void *r)
+{
+	struct pkg_match *pl = *(struct pkg_match **)l;
+	struct pkg_match *pr = *(struct pkg_match **)r;
+	depend_atom *al = pl->atom;
+	depend_atom *ar = pr->atom;
+
+	return atom_compar_cb(al, ar);
+}
+
 /* The format of the sync log has changed over time.
 
 Old format:
@@ -348,14 +367,6 @@ static int do_emerge_log(
 	size_t parallel_emerge = 0;
 	bool all_atoms = false;
 	char afmt[BUFSIZ];
-
-	struct pkg_match {
-		char id[BUFSIZ];
-		depend_atom *atom;
-		time_t tbegin;
-		time_t time;
-		size_t cnt;
-	};
 	struct pkg_match *pkg;
 	struct pkg_match *pkgw;
 
@@ -917,6 +928,7 @@ static int do_emerge_log(
 		DECLARE_ARRAY(avgs);
 
 		values_set(merge_averages, avgs);
+		xarraysort(avgs, pkg_sort_cb);
 		array_for_each(avgs, i, pkg) {
 			printf("%s: %s average for %s%zd%s merge%s\n",
 					atom_format(flags->fmt, pkg->atom),
@@ -928,6 +940,7 @@ static int do_emerge_log(
 		xarrayfree_int(avgs);
 
 		values_set(unmerge_averages, avgs);
+		xarraysort(avgs, pkg_sort_cb);
 		array_for_each(avgs, i, pkg) {
 			printf("%s: %s average for %s%zd%s unmerge%s\n",
 					atom_format(flags->fmt, pkg->atom),


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-09-21 20:23 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-09-21 20:23 UTC (permalink / raw
  To: gentoo-commits

commit:     909489d4317eb4d1dddc1da95d08f365e39dc7b7
Author:     Matija Skala <mskala <AT> gmx <DOT> com>
AuthorDate: Mon Sep 16 20:51:59 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Sep 21 20:21:22 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=909489d4

fix compile on hurd

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 q.c         | 4 ++--
 qmanifest.c | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/q.c b/q.c
index 3dd49f7..c03fd66 100644
--- a/q.c
+++ b/q.c
@@ -15,7 +15,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
-#if defined(__MACH__)
+#if defined(__MACH__) && defined(__APPLE__)
 #include <libproc.h>
 #endif
 
@@ -113,7 +113,7 @@ int q_main(int argc, char **argv)
 		if (!quiet)
 			printf("Installing symlinks:\n");
 
-#if defined(__MACH__)
+#if defined(__MACH__) && defined(__APPLE__)
 		rret = proc_pidpath(getpid(), buf, sizeof(buf));
 		if (rret != -1)
 			rret = strlen(buf);

diff --git a/qmanifest.c b/qmanifest.c
index 41faa4c..10cd39c 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -91,7 +91,7 @@ char verify_manifest(const char *dir, const char *manifest, verify_msg **msgs);
 static inline void
 update_times(struct timeval *tv, struct stat *s)
 {
-#ifdef __MACH__
+#ifdef __MACH__ && defined __APPLE__
 # define st_mtim st_mtimespec
 # define st_atim st_atimespec
 #endif


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-09-21 20:17 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-09-21 20:17 UTC (permalink / raw
  To: gentoo-commits

commit:     de23ef44734dd428fd6de70d2d2d6d40b7768fff
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 21 20:16:46 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Sep 21 20:16:46 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=de23ef44

qlop: fix last merge timeframe detection

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/qlop.c b/qlop.c
index 63a40a8..fcaf973 100644
--- a/qlop.c
+++ b/qlop.c
@@ -373,6 +373,8 @@ static int do_emerge_log(
 
 	all_atoms = array_cnt(atoms) == 0;
 	if (all_atoms || flags->show_lastmerge) {
+		atomset = create_set();
+
 		/* assemble list of atoms */
 		while (fgets(buf, sizeof(buf), fp) != NULL) {
 			if ((p = strchr(buf, ':')) == NULL)
@@ -422,9 +424,6 @@ static int do_emerge_log(
 				atom->PR_int = 0;
 				snprintf(afmt, sizeof(afmt), "%s/%s", atom->CATEGORY, atom->PN);
 
-				if (atomset == NULL)
-					atomset = create_set();
-
 				/* now we found a package, register this merge as a
 				 * "valid" one, such that dummy emerge calls (e.g.
 				 * emerge -pv foo) are ignored */
@@ -435,7 +434,9 @@ static int do_emerge_log(
 					array_for_each(&vals, i, atomw)
 						atom_implode(atomw);
 					xarrayfree_int(&vals);
+
 					clear_set(atomset);
+					last_merge = tstart_emerge;
 				}
 
 				atomw = add_set_value(afmt, atom, atomset);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-09-21 19:53 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-09-21 19:53 UTC (permalink / raw
  To: gentoo-commits

commit:     18ceb0276719b34a769aa4bc8ef8556776967090
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Sep 21 19:50:06 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Sep 21 19:50:06 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=18ceb027

qlop: improve performance for -a (and thus -r), bug #694972

Bring down runtime for -a or -f (without atoms) from ~4s to ~0.6s.

Bug: https://bugs.gentoo.org/694972
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md |   1 +
 qlop.c  | 191 ++++++++++++++++++++++++++++++++--------------------------------
 2 files changed, 97 insertions(+), 95 deletions(-)

diff --git a/TODO.md b/TODO.md
index a319492..8e12c0d 100644
--- a/TODO.md
+++ b/TODO.md
@@ -26,6 +26,7 @@
 - only 64bit values are supported in any individual version component
   foo-(1234)\_alpha(56789)
 - these limits should not be an issue for all practical purposes
+- remove zalloc from atom explode (just initialise what needs to)
 
 # qmerge
 

diff --git a/qlop.c b/qlop.c
index 3cc3367..63a40a8 100644
--- a/qlop.c
+++ b/qlop.c
@@ -19,6 +19,7 @@
 
 #include "atom.h"
 #include "eat_file.h"
+#include "set.h"
 #include "xarray.h"
 #include "xasprintf.h"
 
@@ -339,12 +340,14 @@ static int do_emerge_log(
 	depend_atom *atomw;
 	depend_atom *upgrade_atom = NULL;
 	DECLARE_ARRAY(merge_matches);
-	DECLARE_ARRAY(merge_averages);
+	set *merge_averages = create_set();
 	DECLARE_ARRAY(unmerge_matches);
-	DECLARE_ARRAY(unmerge_averages);
+	set *unmerge_averages = create_set();
+	set *atomset = NULL;
 	size_t i;
 	size_t parallel_emerge = 0;
 	bool all_atoms = false;
+	char afmt[BUFSIZ];
 
 	struct pkg_match {
 		char id[BUFSIZ];
@@ -417,28 +420,27 @@ static int do_emerge_log(
 				atom->PV = NULL;
 				atom->PVR = NULL;
 				atom->PR_int = 0;
+				snprintf(afmt, sizeof(afmt), "%s/%s", atom->CATEGORY, atom->PN);
+
+				if (atomset == NULL)
+					atomset = create_set();
 
 				/* now we found a package, register this merge as a
 				 * "valid" one, such that dummy emerge calls (e.g.
 				 * emerge -pv foo) are ignored */
 				if (last_merge != tstart_emerge) {
-					last_merge = tstart_emerge;
-					array_for_each(atoms, i, atomw)
+					array_t vals;
+
+					values_set(atomset, &vals);
+					array_for_each(&vals, i, atomw)
 						atom_implode(atomw);
-					xarrayfree_int(atoms);
+					xarrayfree_int(&vals);
+					clear_set(atomset);
 				}
 
-				atomw = NULL;
-				array_for_each(atoms, i, atomw) {
-					if (atom_compare(atom, atomw) == EQUAL)
-						break;
-					atomw = NULL;
-				}
-				if (atomw == NULL) {
-					xarraypush_ptr(atoms, atom);
-				} else {
+				atomw = add_set_value(afmt, atom, atomset);
+				if (atomw != NULL)
 					atom_implode(atom);
-				}
 			}
 		}
 
@@ -576,10 +578,16 @@ static int do_emerge_log(
 
 				/* see if we need this atom */
 				atomw = NULL;
-				array_for_each(atoms, i, atomw) {
-					if (atom_compare(atom, atomw) == EQUAL)
-						break;
-					atomw = NULL;
+				if (atomset == NULL) {
+					array_for_each(atoms, i, atomw) {
+						if (atom_compare(atom, atomw) == EQUAL)
+							break;
+						atomw = NULL;
+					}
+				} else {
+					snprintf(afmt, sizeof(afmt), "%s/%s",
+							atom->CATEGORY, atom->PN);
+					atomw = get_set(afmt, atomset);
 				}
 				if (atomw == NULL) {
 					atom_implode(atom);
@@ -604,34 +612,26 @@ static int do_emerge_log(
 					if (flags->do_average || flags->do_running)
 					{
 						/* find in list of averages */
-						size_t n;
-
-						pkg = NULL;
-						array_for_each(merge_averages, n, pkg) {
-							if (atom_compare(pkg->atom, pkgw->atom) == EQUAL) {
-								pkg->cnt++;
-								pkg->time += elapsed;
-								/* store max time for do_running */
-								if (elapsed > pkg->tbegin)
-									pkg->tbegin = elapsed;
-								atom_implode(pkgw->atom);
-								xarraydelete(merge_matches, i);
-								break;
-							}
-							pkg = NULL;
-						}
-						if (pkg == NULL) {  /* push new entry */
-							if (!verbose || flags->do_running) {
-								/* strip off version info */
-								pkgw->atom->PV = NULL;
-								pkgw->atom->PVR = NULL;
-								pkgw->atom->PR_int = 0;
-							}
+						snprintf(afmt, sizeof(afmt), "%s/%s",
+								pkgw->atom->CATEGORY,
+								(!verbose || flags->do_running) ?
+								pkgw->atom->PN : pkgw->atom->P);
+
+						pkg = add_set_value(afmt, pkgw, merge_averages);
+						if (pkg != NULL) {
+							pkg->cnt++;
+							pkg->time += elapsed;
+							/* store max time for do_running */
+							if (elapsed > pkg->tbegin)
+								pkg->tbegin = elapsed;
+							atom_implode(pkgw->atom);
+							xarraydelete(merge_matches, i);
+						} else {
+							/* new entry */
 							pkgw->id[0] = '\0';
 							pkgw->cnt = 1;
 							pkgw->time = elapsed;
 							pkgw->tbegin = elapsed;
-							xarraypush_ptr(merge_averages, pkgw);
 							xarraydelete_ptr(merge_matches, i);
 						}
 						break;
@@ -717,10 +717,16 @@ static int do_emerge_log(
 
 				/* see if we need this atom */
 				atomw = NULL;
-				array_for_each(atoms, i, atomw) {
-					if (atom_compare(atom, atomw) == EQUAL)
-						break;
-					atomw = NULL;
+				if (atomset == NULL) {
+					array_for_each(atoms, i, atomw) {
+						if (atom_compare(atom, atomw) == EQUAL)
+							break;
+						atomw = NULL;
+					}
+				} else {
+					snprintf(afmt, sizeof(afmt), "%s/%s",
+							atom->CATEGORY, atom->PN);
+					atomw = get_set(afmt, atomset);
 				}
 				if (atomw == NULL) {
 					atom_implode(atom);
@@ -745,34 +751,26 @@ static int do_emerge_log(
 					if (flags->do_average || flags->do_running)
 					{
 						/* find in list of averages */
-						size_t n;
-
-						pkg = NULL;
-						array_for_each(unmerge_averages, n, pkg) {
-							if (atom_compare(pkg->atom, pkgw->atom) == EQUAL) {
-								pkg->cnt++;
-								pkg->time += elapsed;
-								/* store max time for do_running */
-								if (elapsed > pkg->tbegin)
-									pkg->tbegin = elapsed;
-								atom_implode(pkgw->atom);
-								xarraydelete(unmerge_matches, i);
-								break;
-							}
-							pkg = NULL;
-						}
-						if (pkg == NULL) {  /* push new entry */
-							if (!verbose || flags->do_running) {
-								/* strip off version info */
-								pkgw->atom->PV = NULL;
-								pkgw->atom->PVR = NULL;
-								pkgw->atom->PR_int = 0;
-							}
+						snprintf(afmt, sizeof(afmt), "%s/%s",
+								pkgw->atom->CATEGORY,
+								(!verbose || flags->do_running) ?
+								pkgw->atom->PN : pkgw->atom->P);
+
+						pkg = add_set_value(afmt, pkgw, unmerge_averages);
+						if (pkg != NULL) {
+							pkg->cnt++;
+							pkg->time += elapsed;
+							/* store max time for do_running */
+							if (elapsed > pkg->tbegin)
+								pkg->tbegin = elapsed;
+							atom_implode(pkgw->atom);
+							xarraydelete(unmerge_matches, i);
+						} else {
+							/* new entry */
 							pkgw->id[0] = '\0';
 							pkgw->cnt = 1;
 							pkgw->time = elapsed;
 							pkgw->tbegin = elapsed;
-							xarraypush_ptr(unmerge_averages, pkgw);
 							xarraydelete_ptr(unmerge_matches, i);
 						}
 						break;
@@ -825,22 +823,20 @@ static int do_emerge_log(
 			}
 		}
 		array_for_each(merge_matches, i, pkgw) {
-			size_t j;
 			time_t maxtime = 0;
 			bool isMax = false;
 
+			snprintf(afmt, sizeof(afmt), "%s/%s",
+					pkgw->atom->CATEGORY, pkgw->atom->PN);
+
 			elapsed = tstart - pkgw->tbegin;
-			pkg = NULL;
-			array_for_each(merge_averages, j, pkg) {
-				if (atom_compare(pkg->atom, pkgw->atom) == EQUAL) {
-					maxtime = pkg->time / pkg->cnt;
-					if (elapsed >= maxtime) {
-						maxtime = elapsed >= pkg->tbegin ? 0 : pkg->tbegin;
-						isMax = true;
-					}
-					break;
+			pkg = get_set(afmt, merge_averages);
+			if (pkg != NULL) {
+				maxtime = pkg->time / pkg->cnt;
+				if (elapsed >= maxtime) {
+					maxtime = elapsed >= pkg->tbegin ? 0 : pkg->tbegin;
+					isMax = true;
 				}
-				pkg = NULL;
 			}
 
 			/* extract (X of Y) from id, bug #442406 */
@@ -871,22 +867,20 @@ static int do_emerge_log(
 						isMax ? " (longest run)" : " (average run)" : "");
 		}
 		array_for_each(unmerge_matches, i, pkgw) {
-			size_t j;
 			time_t maxtime = 0;
 			bool isMax = false;
 
+			snprintf(afmt, sizeof(afmt), "%s/%s",
+					pkgw->atom->CATEGORY, pkgw->atom->PN);
+
 			elapsed = tstart - pkgw->tbegin;
-			pkg = NULL;
-			array_for_each(unmerge_averages, j, pkg) {
-				if (atom_compare(pkg->atom, pkgw->atom) == EQUAL) {
-					maxtime = pkg->time / pkg->cnt;
-					if (elapsed >= maxtime) {
-						maxtime = elapsed >= pkg->tbegin ? 0 : pkg->tbegin;
-						isMax = true;
-					}
-					break;
+			pkg = get_set(afmt, unmerge_averages);
+			if (pkg != NULL) {
+				maxtime = pkg->time / pkg->cnt;
+				if (elapsed >= maxtime) {
+					maxtime = elapsed >= pkg->tbegin ? 0 : pkg->tbegin;
+					isMax = true;
 				}
-				pkg = NULL;
 			}
 
 			if (flags->do_time) {
@@ -909,8 +903,10 @@ static int do_emerge_log(
 		size_t total_merges = 0;
 		size_t total_unmerges = 0;
 		time_t total_time = (time_t)0;
+		DECLARE_ARRAY(avgs);
 
-		array_for_each(merge_averages, i, pkg) {
+		values_set(merge_averages, avgs);
+		array_for_each(avgs, i, pkg) {
 			printf("%s: %s average for %s%zd%s merge%s\n",
 					atom_format(flags->fmt, pkg->atom),
 					fmt_elapsedtime(flags, pkg->time / pkg->cnt),
@@ -918,7 +914,10 @@ static int do_emerge_log(
 			total_merges += pkg->cnt;
 			total_time += pkg->time;
 		}
-		array_for_each(unmerge_averages, i, pkg) {
+		xarrayfree_int(avgs);
+
+		values_set(unmerge_averages, avgs);
+		array_for_each(avgs, i, pkg) {
 			printf("%s: %s average for %s%zd%s unmerge%s\n",
 					atom_format(flags->fmt, pkg->atom),
 					fmt_elapsedtime(flags, pkg->time / pkg->cnt),
@@ -926,6 +925,8 @@ static int do_emerge_log(
 			total_unmerges += pkg->cnt;
 			total_time += pkg->time;
 		}
+		xarrayfree_int(avgs);
+
 		if (sync_cnt > 0) {
 			printf("%ssync%s: %s average for %s%zd%s sync%s\n",
 					BLUE, NORM, fmt_elapsedtime(flags, sync_time / sync_cnt),


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-09-10 18:25 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-09-10 18:25 UTC (permalink / raw
  To: gentoo-commits

commit:     c697c786bd4f24b0ec5c5aa1300fa9d8433062d6
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 10 18:17:58 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Sep 10 18:17:58 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c697c786

qlop: ignore empty runs for -l (lastrun)

doing something like emerge -pv blah will generate a run where nothing
is merged or unmerged, so ignore it.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/qlop.c b/qlop.c
index 7acb855..243c8b6 100644
--- a/qlop.c
+++ b/qlop.c
@@ -326,6 +326,7 @@ static int do_emerge_log(
 	char *p;
 	char *q;
 	time_t tstart = LONG_MAX;
+	time_t tstart_emerge = 0;
 	time_t last_merge = 0;
 	time_t sync_start = 0;
 	time_t sync_time = 0;
@@ -376,12 +377,8 @@ static int do_emerge_log(
 				continue;
 
 			if (flags->show_lastmerge) {
-				if (strncmp(p, "  *** emerge ", 13) == 0) {
-					last_merge = tstart;
-					array_for_each(atoms, i, atomw)
-						atom_implode(atomw);
-					xarrayfree_int(atoms);
-				}
+				if (strncmp(p, "  *** emerge ", 13) == 0)
+					tstart_emerge = tstart;
 				if (!all_atoms)
 					continue;
 			}
@@ -417,6 +414,16 @@ static int do_emerge_log(
 				atom->PVR = NULL;
 				atom->PR_int = 0;
 
+				/* now we found a package, register this merge as a
+				 * "valid" one, such that dummy emerge calls (e.g.
+				 * emerge -pv foo) are ignored */
+				if (last_merge != tstart_emerge) {
+					last_merge = tstart_emerge;
+					array_for_each(atoms, i, atomw)
+						atom_implode(atomw);
+					xarrayfree_int(atoms);
+				}
+
 				atomw = NULL;
 				array_for_each(atoms, i, atomw) {
 					if (atom_compare(atom, atomw) == EQUAL)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-08-17  8:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-08-17  8:37 UTC (permalink / raw
  To: gentoo-commits

commit:     74219ab70d2a5bcad327c3795f5fa9b881d433ad
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Aug 17 08:35:39 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Aug 17 08:35:39 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=74219ab7

qlop: add ROOT support, bug #692224

Respect ROOT when set, to ease scripting of qlop interaction with
chroots.

Bug: https://bugs.gentoo.org/692224
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/qlop.c b/qlop.c
index fce0f69..7acb855 100644
--- a/qlop.c
+++ b/qlop.c
@@ -351,7 +351,14 @@ static int do_emerge_log(
 	struct pkg_match *pkg;
 	struct pkg_match *pkgw;
 
-	if ((fp = fopen(log, "r")) == NULL) {
+	/* support relative path in here and now, when using ROOT, stick to
+	 * it, turning relative into a moot point */
+	if (portroot[1] == '\0')
+		snprintf(buf, sizeof(buf), "%s", log);
+	else
+		snprintf(buf, sizeof(buf), "%s%s", portroot, log);
+	if ((fp = fopen(buf, "r")) == NULL)
+	{
 		warnp("Could not open logfile '%s'", log);
 		return 1;
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-07-18 17:55 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-07-18 17:55 UTC (permalink / raw
  To: gentoo-commits

commit:     573a93e0ddccfa316cf3b37b3d25717e0a639def
Author:     Philipp Ammann <philipp.ammann <AT> posteo <DOT> de>
AuthorDate: Thu Jul 18 17:54:28 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jul 18 17:54:28 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=573a93e0

applets: properly disable qtegrity when requested

This fixes the final linking stage due to undefined references to
qtegrity_main.

Bug: https://bugs.gentoo.org/689896
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/applets.h b/applets.h
index 999cf7a..520ff23 100644
--- a/applets.h
+++ b/applets.h
@@ -86,7 +86,9 @@ static const struct applet_t {
 	{"qsearch",   qsearch_main,   "<regex>",         "search pkgname/desc"},
 	{"qsize",     qsize_main,     "<pkgname>",       "calculate size usage"},
 	{"qtbz2",     qtbz2_main,     "<misc args>",     "manipulate tbz2 packages"},
+#ifdef ENABLE_QTEGRITY
 	{"qtegrity",  qtegrity_main,  "<misc args>",     "verify files with IMA"},
+#endif
 	{"quse",      quse_main,      "<useflag>",       "find pkgs using useflags"},
 	{"qxpak",     qxpak_main,     "<misc args>",     "manipulate xpak archives"},
 
@@ -109,8 +111,10 @@ static const struct applet_t {
 	{"uickpkg",   qpkg_main,      NULL, NULL},
 	/* {"glsa",      qglsa_main,     NULL, NULL}, */
 
+#ifdef ENABLE_QTEGRITY
 	/* alias for qtegrity */
 	{"integrity", qtegrity_main,  NULL, NULL},
+#endif
 
 #ifdef ENABLE_QMANIFEST
 	/* old hashgen */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-07-14 18:51 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-07-14 18:51 UTC (permalink / raw
  To: gentoo-commits

commit:     60c7329b2fbf153b14596e290721322b0626eee1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 18:43:34 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jul 14 18:43:34 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=60c7329b

buildsys: regen

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 Makefile.in | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index 6166e5f..ec8d83f 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1596,13 +1596,12 @@ SUBDIRS = \
 	$(NULL)
 
 APPLETS = q qatom qcheck qdepends qfile qgrep qkeyword qlist qlop \
-	qmerge qpkg qsearch qsize qtbz2 qtegrity quse qxpak $(NULL) \
+	qmerge qpkg qsearch qsize qtbz2 quse qxpak $(NULL) \
 	$(am__append_5) $(am__append_10)
 dist_man_MANS = man/q.1 man/qatom.1 man/qcheck.1 man/qdepends.1 \
 	man/qfile.1 man/qgrep.1 man/qkeyword.1 man/qlist.1 man/qlop.1 \
 	man/qmerge.1 man/qpkg.1 man/qsearch.1 man/qsize.1 man/qtbz2.1 \
-	man/qtegrity.1 man/quse.1 man/qxpak.1 $(NULL) $(am__append_4) \
-	$(am__append_9)
+	man/quse.1 man/qxpak.1 $(NULL) $(am__append_4) $(am__append_9)
 q_SOURCES = main.c q.c qatom.c qcheck.c qdepends.c qfile.c qgrep.c \
 	qkeyword.c qlist.c qlop.c qmerge.c qpkg.c qsearch.c qsize.c \
 	qtbz2.c quse.c qxpak.c $(NULL) $(am__append_1) $(am__append_6)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-07-14 16:27 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-07-14 16:27 UTC (permalink / raw
  To: gentoo-commits

commit:     0dd39748418826e925d8ce3d24449a0f13de1a2d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 16:21:16 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jul 14 16:21:16 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0dd39748

Makefile: don't try to install qtegrity twice

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 Makefile.am | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 9f56d27..d85a4f9 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -22,7 +22,6 @@ APPLETS = \
 	qsearch \
 	qsize \
 	qtbz2 \
-	qtegrity \
 	quse \
 	qxpak \
 	$(NULL)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-07-14 16:27 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-07-14 16:27 UTC (permalink / raw
  To: gentoo-commits

commit:     356066951043c7f8317b90754dd17890a66a1e91
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 16:12:48 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jul 14 16:12:48 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=35606695

make-tarball: also test install target

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 make-tarball.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/make-tarball.sh b/make-tarball.sh
index 489ce4b..f1cfb15 100755
--- a/make-tarball.sh
+++ b/make-tarball.sh
@@ -56,6 +56,7 @@ pushd "${p}" >/dev/null
 v ./configure -q
 v ${MAKE} -s
 v ${MAKE} -s check
+v ${MAKE} -s DESTDIR="${PWD}"/install install
 popd >/dev/null
 rm -rf "${p}"
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-07-14 16:00 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-07-14 16:00 UTC (permalink / raw
  To: gentoo-commits

commit:     2c304b178bd9e62d67ccc593ea5f83725eae218d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 15:59:50 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jul 14 15:59:50 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2c304b17

nuildsys: don't install qtegrity manpage twice

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 Makefile.am | 1 -
 1 file changed, 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index e8b11f8..9f56d27 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -42,7 +42,6 @@ dist_man_MANS = \
 	man/qsearch.1 \
 	man/qsize.1 \
 	man/qtbz2.1 \
-	man/qtegrity.1 \
 	man/quse.1 \
 	man/qxpak.1 \
 	$(NULL)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-07-14 13:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-07-14 13:09 UTC (permalink / raw
  To: gentoo-commits

commit:     60232a12416e58fdae27d97cf9c62d95659a7db4
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 11:47:55 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jul 14 11:47:55 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=60232a12

qatom: fix atom matching wrt command line arguments

ensure we match things without category or with expressions

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsize.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qsize.c b/qsize.c
index ce4acc1..10aadc8 100644
--- a/qsize.c
+++ b/qsize.c
@@ -113,7 +113,7 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 		qatom = tree_get_atom(pkg_ctx, 0);
 		array_for_each(state->atoms, i, atom)
-			if (atom_compare(atom, qatom) == EQUAL) {
+			if (atom_compare(qatom, atom) == EQUAL) {
 				showit = true;
 				break;
 			}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-07-14 13:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-07-14 13:09 UTC (permalink / raw
  To: gentoo-commits

commit:     d2bbdf1064d9f718da68a9784ad8dab320edb431
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 10:38:32 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jul 14 10:38:32 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d2bbdf10

qpkg: use atom_format and tree_get_atom where possible

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 20 +++++---------------
 1 file changed, 5 insertions(+), 15 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 2c5a6c3..29265f2 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -231,8 +231,8 @@ qpkg_make(depend_atom *atom)
 	struct stat st;
 
 	if (pretend) {
-		printf(" %s-%s %s/%s:\n",
-				GREEN, NORM, atom->CATEGORY, atom_to_pvr(atom));
+		printf(" %s-%s %s:\n",
+				GREEN, NORM, atom_format("%[CATEGORY]%[PF]", atom));
 		return 0;
 	}
 
@@ -286,7 +286,8 @@ qpkg_make(depend_atom *atom)
 	fclose(out);
 	fclose(fp);
 
-	printf(" %s-%s %s/%s: ", GREEN, NORM, atom->CATEGORY, atom_to_pvr(atom));
+	printf(" %s-%s %s: ", GREEN, NORM,
+			atom_format("%[CATEGORY]%[PF]", atom));
 	fflush(stdout);
 
 	snprintf(tbz2, sizeof(tbz2), "%s/bin.tbz2", tmpdir);
@@ -416,17 +417,9 @@ retry_mkdir:
 	/* scan all the categories */
 	while ((cat_ctx = tree_next_cat(ctx))) {
 		/* scan all the packages in this category */
-		const char *catname = cat_ctx->name;
 		while ((pkg_ctx = tree_next_pkg(cat_ctx))) {
-			const char *pkgname = pkg_ctx->name;
-
 			/* see if user wants any of these packages */
-			snprintf(buf, sizeof(buf), "%s/%s", catname, pkgname);
-			atom = atom_explode(buf);
-			if (!atom) {
-				warn("could not explode '%s'", buf);
-				goto next_pkg;
-			}
+			atom = tree_get_atom(pkg_ctx, false);
 			snprintf(buf, sizeof(buf), "%s/%s", atom->CATEGORY, atom->PN);
 			for (i = optind; i < argc; ++i) {
 				if (!argv[i]) continue;
@@ -438,9 +431,6 @@ retry_mkdir:
 					if (!qpkg_make(atom))
 						++pkgs_made;
 			}
-			atom_implode(atom);
-
- next_pkg:
 			tree_close_pkg(pkg_ctx);
 		}
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-07-14  8:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-07-14  8:37 UTC (permalink / raw
  To: gentoo-commits

commit:     339297b3247c8850194a48edf1ce03dbfdef337a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jul 14 08:34:31 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jul 14 08:34:31 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=339297b3

main: rework terminal-based settings somewhat

As pointed out by slyfox, the result from ioctl was ignored and its
result used anyway.  While at it to fix this, rework the logic somewhat,
such that terminal width and colours are always disabled when we're not
dealing with a TTY.

Bug: https://bugs.gentoo.org/689290#c14
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/main.c b/main.c
index c5cc4b4..bdbb2a7 100644
--- a/main.c
+++ b/main.c
@@ -780,9 +780,6 @@ int main(int argc, char **argv)
 	struct stat st;
 	struct winsize winsz;
 
-	ioctl(0, TIOCGWINSZ, &winsz);
-	twidth = winsz.ws_col > 0 ? (int)winsz.ws_col : 80;
-
 	warnout = stderr;
 	IF_DEBUG(init_coredumps());
 	argv0 = argv[0];
@@ -791,13 +788,18 @@ int main(int argc, char **argv)
 	bindtextdomain(argv0, CONFIG_EPREFIX "usr/share/locale");
 	textdomain(argv0);
 
-	if (fstat(fileno(stdout), &st) != -1)
+	twidth = 0;
+	if (fstat(fileno(stdout), &st) != -1) {
 		if (!isatty(fileno(stdout))) {
 			no_colors();
-			twidth = 0;
+		} else {
+			if ((getenv("TERM") == NULL) ||
+					(strcmp(getenv("TERM"), "dumb") == 0))
+				no_colors();
+			if (ioctl(0, TIOCGWINSZ, &winsz) == 0 && winsz.ws_col > 0)
+				twidth = (int)winsz.ws_col;
 		}
-	if ((getenv("TERM") == NULL) || (strcmp(getenv("TERM"), "dumb") == 0))
-		no_colors();
+	}
 
 	initialize_portage_env();
 	optind = 0;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-27  8:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-27  8:54 UTC (permalink / raw
  To: gentoo-commits

commit:     9836a593874dd3459c8ec1035635ede29d3afbfa
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 27 08:52:49 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun 27 08:52:49 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9836a593

main: default main_overlay to first overlay

If no overlay was explicitly marked as MAIN, assume the first to be, if
any were set.  Else the builtin default location is used.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/main.c b/main.c
index fd4a60b..c5cc4b4 100644
--- a/main.c
+++ b/main.c
@@ -749,6 +749,9 @@ initialize_portage_env(void)
 	if (array_cnt(overlays) == 0) {
 		xarraypush_ptr(overlays, main_overlay);
 		xarraypush_str(overlay_names, "<PORTDIR>");
+	} else if (orig_main_overlay == main_overlay) {
+		/* if no explicit overlay was flagged as main, take the first one */
+		main_overlay = array_get_elem(overlays, 0);
 	}
 
 	if (getenv("DEBUG")) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-26 19:32 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-26 19:32 UTC (permalink / raw
  To: gentoo-commits

commit:     6be83e89c43dd6bcc7f2a8b71ccf772842689694
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 26 19:31:27 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 26 19:31:27 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6be83e89

main: push pointer for static object main_overlay

In `q -o` we compare check the main overlay by checking the pointers,
which won't work if we made a copy of it.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index f9dfb6d..fd4a60b 100644
--- a/main.c
+++ b/main.c
@@ -747,7 +747,7 @@ initialize_portage_env(void)
 	if (orig_main_overlay != main_overlay)
 		free(orig_main_overlay);
 	if (array_cnt(overlays) == 0) {
-		xarraypush_str(overlays, main_overlay);
+		xarraypush_ptr(overlays, main_overlay);
 		xarraypush_str(overlay_names, "<PORTDIR>");
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-19 10:44 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-19 10:44 UTC (permalink / raw
  To: gentoo-commits

commit:     0ce7155b9dc53235350696a6c8c62b006d0fe72d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 19 09:43:21 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 19 09:43:21 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0ce7155b

TODO: drop implemented items

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 9 ---------
 1 file changed, 9 deletions(-)

diff --git a/TODO.md b/TODO.md
index 61f1c98..f9a713b 100644
--- a/TODO.md
+++ b/TODO.md
@@ -6,12 +6,6 @@
 	- -r (-R ?) regexp foo.\*
 - make default -e for apps like quse/qdepends?
 
-- disable color when tty = NULL; may break less?
-
-- standardize/unify/clean up misc handling of colors (atom\_format)
-  define rules:
-    BOLD CATEGORY/ BLUE PKG CYAN -VER YELLOW :SLOT GREEN ::REPO NORM [ MAGENTA USE NORM ]
-
 - remove odd rmspace for each string in libq/set.c (allows a lot less
   malloc/frees)
 
@@ -29,8 +23,6 @@
 - tree\_get\_atoms should return atoms iso string set, needs a rewrite
   to use foreach\_pkg and get\_atom
 
-- remove odd pverbose argument to atom\_format
-
 # Atoms
 
 - only 32bit values are supported for revision (-r#)
@@ -83,7 +75,6 @@
 
 # quse
 - make -v only print requested USE-flag when flags given
-- read VDB on -v to print details about current USE-flag status, bug #656550
 
 # qkeyword
 - drop -c argument? it can be fully expressed using -p cat/


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-13 10:52 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-13 10:52 UTC (permalink / raw
  To: gentoo-commits

commit:     b4e37543f21958c5e5981c2b3694213d150d5bcd
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 13 10:51:56 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun 13 10:51:56 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b4e37543

main: disable word wrapping when stdout is not a terminal

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c      | 5 +++--
 qmanifest.c | 2 +-
 quse.c      | 8 ++++++--
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/main.c b/main.c
index f5f7b57..f9dfb6d 100644
--- a/main.c
+++ b/main.c
@@ -778,7 +778,6 @@ int main(int argc, char **argv)
 	struct winsize winsz;
 
 	ioctl(0, TIOCGWINSZ, &winsz);
-	if (winsz.ws_col > 0)
 	twidth = winsz.ws_col > 0 ? (int)winsz.ws_col : 80;
 
 	warnout = stderr;
@@ -790,8 +789,10 @@ int main(int argc, char **argv)
 	textdomain(argv0);
 
 	if (fstat(fileno(stdout), &st) != -1)
-		if (!isatty(fileno(stdout)))
+		if (!isatty(fileno(stdout))) {
 			no_colors();
+			twidth = 0;
+		}
 	if ((getenv("TERM") == NULL) || (strcmp(getenv("TERM"), "dumb") == 0))
 		no_colors();
 

diff --git a/qmanifest.c b/qmanifest.c
index 7ca2b40..21254c3 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -1505,7 +1505,7 @@ format_line(const char *pfx, const char *msg)
 	if (*pfx == '-') {
 		fprintf(stdout, "%s%s%s%s\n", pfx, RED, msg, NORM);
 	} else {
-		if (!verbose && msglen > (size_t)twidth) {
+		if (!verbose && twidth > 0 && msglen > (size_t)twidth) {
 			int to_remove = 3 + (msglen - twidth);
 			int first_half = msglen / 2 - to_remove / 2;
 			int remainder = msglen / 2 + (to_remove + 1) / 2;

diff --git a/quse.c b/quse.c
index f1d52ae..8a9f78a 100644
--- a/quse.c
+++ b/quse.c
@@ -600,8 +600,12 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 					quse_search_profiles_desc(portdirfd, &us);
 
 			/* calculate available space in the terminal to print
-			 * descriptions */
-			len = twidth - maxlen - 2 - 1 - 2;
+			 * descriptions, assume this makes sense from 10 chars */
+			if (twidth > maxlen + 2 + 1 + 2 + 10) {
+				len = twidth - maxlen - 2 - 1 - 2;
+			} else {
+				len = 0;
+			}
 
 			for (i = 0; i < cnt; i++) {
 				match = use != NULL && contains_set(us.argv[i], use);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-13  9:28 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-13  9:28 UTC (permalink / raw
  To: gentoo-commits

commit:     a7a3f52bf768546f5f57bfded6d9a60749593162
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 13 09:28:38 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun 13 09:28:38 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a7a3f52b

main/qmanifest: fix compilation on Linux

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c      | 1 +
 qmanifest.c | 8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/main.c b/main.c
index 8325c44..f5f7b57 100644
--- a/main.c
+++ b/main.c
@@ -17,6 +17,7 @@
 #include <sys/time.h>
 #include <limits.h>
 #include <termios.h>
+#include <sys/ioctl.h>
 
 #include "eat_file.h"
 #include "rmspace.h"

diff --git a/qmanifest.c b/qmanifest.c
index d7f90b8..7ca2b40 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -25,10 +25,10 @@
 #include <dirent.h>
 #include <time.h>
 #include <errno.h>
+#include <termios.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/time.h>
-#include <sys/ioctl.h>
 #include <openssl/sha.h>
 #include <openssl/whrlpool.h>
 #include <blake2.h>
@@ -1498,7 +1498,7 @@ verify_timestamp(const char *ts)
 }
 
 static void
-format_line(const char *pfx, const char *msg, int twidth)
+format_line(const char *pfx, const char *msg)
 {
 	size_t msglen = strlen(pfx) + strlen(msg);
 
@@ -1644,11 +1644,11 @@ process_dir_vrfy(void)
 				msgline = msg;
 				while ((msgline = strchr(msgline, '\n')) != NULL) {
 					*msgline++ = '\0';
-					format_line(pfx, msg, twidth);
+					format_line(pfx, msg);
 					pfx = "  ";
 					msg = msgline;
 				}
-				format_line(pfx, msg, twidth);
+				format_line(pfx, msg);
 			}
 		}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-13  8:41 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-13  8:41 UTC (permalink / raw
  To: gentoo-commits

commit:     e75a1a31fa0d05ab0db3548d848ddb602038ce01
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jun 13 08:36:53 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun 13 08:36:53 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e75a1a31

quse: improve per package USE-flag output somewhat

- add asterisk at the end of USE-flag instead of at the start of the
  line to mark currently enabled flag (installed package)
- colour such enabled flags green so they stand out better
- wrap descriptions when they don't fit on the terminal screen

example:

app-portage/portage-utils-0.80_pre20190610
  nls*        Add Native Language Support (using gettext - GNU locale utilities)
  static      !!do not set this during bootstrap!! Causes binaries to be
              statically linked instead of dynamically
  openmp      Build support for the OpenMP (support parallel computing),
              requires >=sys-devel/gcc-4.2 built with USE="openmp"
 +qmanifest*  Build qmanifest applet, this adds additional dependencies for GPG,
              OpenSSL and BLAKE2B hashing
  libressl*   Use dev-libs/libressl instead of dev-libs/openssl when applicable
              (see also the ssl useflag)

Bug: https://bugs.gentoo.org/656550
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h   |  1 +
 main.c      |  8 ++++++++
 qmanifest.c |  7 -------
 quse.c      | 40 +++++++++++++++++++++++++++++++++++++---
 4 files changed, 46 insertions(+), 10 deletions(-)

diff --git a/applets.h b/applets.h
index fbb21aa..acc85da 100644
--- a/applets.h
+++ b/applets.h
@@ -165,6 +165,7 @@ extern char *install_mask;
 extern DEFINE_ARRAY(overlays);
 extern DEFINE_ARRAY(overlay_names);
 extern char *main_overlay;
+extern int twidth;
 
 void no_colors(void);
 void setup_quiet(void);

diff --git a/main.c b/main.c
index 1f51542..8325c44 100644
--- a/main.c
+++ b/main.c
@@ -16,6 +16,7 @@
 #include <ctype.h>
 #include <sys/time.h>
 #include <limits.h>
+#include <termios.h>
 
 #include "eat_file.h"
 #include "rmspace.h"
@@ -27,6 +28,7 @@ char *main_overlay;
 char *module_name = NULL;
 int verbose = 0;
 int quiet = 0;
+int twidth;
 char pretend = 0;
 char *portroot;
 char *config_protect;
@@ -772,6 +774,12 @@ initialize_portage_env(void)
 int main(int argc, char **argv)
 {
 	struct stat st;
+	struct winsize winsz;
+
+	ioctl(0, TIOCGWINSZ, &winsz);
+	if (winsz.ws_col > 0)
+	twidth = winsz.ws_col > 0 ? (int)winsz.ws_col : 80;
+
 	warnout = stderr;
 	IF_DEBUG(init_coredumps());
 	argv0 = argv[0];

diff --git a/qmanifest.c b/qmanifest.c
index de68569..d7f90b8 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -25,7 +25,6 @@
 #include <dirent.h>
 #include <time.h>
 #include <errno.h>
-#include <termios.h>
 #include <sys/stat.h>
 #include <sys/types.h>
 #include <sys/time.h>
@@ -1531,12 +1530,6 @@ process_dir_vrfy(void)
 	verify_msg topmsg;
 	verify_msg *walk = &topmsg;
 	gpg_sig *gs;
-	struct winsize winsz;
-	int twidth = 80;
-
-	ioctl(0, TIOCGWINSZ, &winsz);
-	if (winsz.ws_col > 0)
-		twidth = (int)winsz.ws_col;
 
 	gettimeofday(&startt, NULL);
 

diff --git a/quse.c b/quse.c
index 751f767..f1d52ae 100644
--- a/quse.c
+++ b/quse.c
@@ -559,6 +559,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 			printf("%s\n", atom_format(qfmt, atom, 0));
 		} else if (verbose && !state->do_licence) {
 			/* multi-line result, printing USE-flags with their descs */
+			size_t desclen;
 			struct quse_state us = {
 				.do_regex = false,
 				.do_describe = false,
@@ -598,17 +599,50 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				if (!quse_search_use_desc(portdirfd, &us))
 					quse_search_profiles_desc(portdirfd, &us);
 
+			/* calculate available space in the terminal to print
+			 * descriptions */
+			len = twidth - maxlen - 2 - 1 - 2;
+
 			for (i = 0; i < cnt; i++) {
 				match = use != NULL && contains_set(us.argv[i], use);
-				printf("%s%c%s%s%s%*s  %s\n",
-						match ? "*" : " ",
+				desclen = us.retv[i] != NULL ? strlen(us.retv[i]) : 0;
+				p = NULL;
+				if (desclen > (size_t)len) {  /* need to wrap */
+					for (p = &us.retv[i][len]; p > us.retv[i]; p--)
+						if (isspace((int)*p))
+							break;
+					if (p > us.retv[i]) {
+						*p++ = '\0';
+						desclen -= p - us.retv[i];
+					} else {
+						p = NULL;
+					}
+				}
+				printf(" %c%s%s%s%c%*s  %s\n",
 						us.argv[i][-1],
-						/* selected ? RED : NORM */ MAGENTA,
+						match ? GREEN : MAGENTA,
 						us.argv[i],
 						NORM,
+						match ? '*' : ' ',
 						(int)(maxlen - strlen(us.argv[i])), "",
 						us.retv[i] == NULL ? "<no description found>" :
 							us.retv[i]);
+				while (p != NULL) {  /* continue wrapped description */
+					q = p;
+					p = NULL;
+					if ((size_t)len < desclen) {
+						for (p = q + len; p > q; p--)
+							if (isspace((int)*p))
+								break;
+						if (p > q) {
+							*p++ = '\0';
+							desclen -= p - q;
+						} else {
+							p = NULL;
+						}
+					}
+					printf("  %*s   %s\n", maxlen, "", q);
+				}
 				if (us.retv[i] != NULL)
 					free(us.retv[i]);
 			}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-11 17:55 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-11 17:55 UTC (permalink / raw
  To: gentoo-commits

commit:     5814aa774f60baef3f6dc3286d5b582f90cac03d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 11 17:55:05 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Jun 11 17:55:05 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5814aa77

qcheck: fix atom_compare call

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcheck.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qcheck.c b/qcheck.c
index a26b25d..efbb191 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -369,7 +369,7 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 		qatom = tree_get_atom(pkg_ctx, false);
 		array_for_each(state->atoms, i, atom) {
-			if (atom_compare(atom, qatom) == EQUAL) {
+			if (atom_compare(qatom, atom) == EQUAL) {
 				showit = true;
 				break;
 			}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-10 18:38 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-10 18:38 UTC (permalink / raw
  To: gentoo-commits

commit:     4977ffabe0b76de0c2618a6cab36ae0fdfcf83f9
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 10 18:38:02 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 10 18:38:02 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4977ffab

main: fix makeargv behaviour on empty input

Found on Ubuntu where obviously no Portage config exists, this made
qmerge test fail because paths were incorrectly never seen as protected.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/main.c b/main.c
index 56a05d3..1f51542 100644
--- a/main.c
+++ b/main.c
@@ -194,6 +194,12 @@ makeargv(const char *string, int *argc, char ***argv)
 	q = xstrdup(string);
 	str = q;
 
+	/* shortcut empty strings */
+	while (isspace((int)*string))
+		string++;
+	if (*string == '\0')
+		return;
+
 	remove_extra_space(str);
 	rmspace(str);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-10 15:29 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-10 15:29 UTC (permalink / raw
  To: gentoo-commits

commit:     1610679b5ad27ec4dcab56e2eb598edfeda4f8aa
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 10 15:27:36 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 10 15:27:36 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1610679b

qmerge: rework config_protected

faccessat does not support AT_SYMLINK_NOFOLLOW according to the
specification, hopefully this is the problem Travis runs into

try to clear up the EPREFIX mess somewhat by calling config_protected
with a non-Prefixed path, and doing the existance checking in merge
itself only

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 49 ++++++++++++++++++++++++++-----------------------
 1 file changed, 26 insertions(+), 23 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 8644ddc..c48ecd2 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -355,12 +355,6 @@ config_protected(const char *buf, int cp_argc, char **cp_argv,
                  int cpm_argc, char **cpm_argv)
 {
 	int i;
-	char dest[_Q_PATH_MAX];
-	snprintf(dest, sizeof(dest), "%s%s", portroot, buf);
-
-	/* config protect paths don't carry EPREFIX */
-	if (strncmp(buf, CONFIG_EPREFIX, strlen(CONFIG_EPREFIX) - 1) == 0)
-		buf += strlen(CONFIG_EPREFIX) - 1;
 
 	/* Check CONFIG_PROTECT_MASK */
 	for (i = 1; i < cpm_argc; ++i)
@@ -370,8 +364,7 @@ config_protected(const char *buf, int cp_argc, char **cp_argv,
 	/* Check CONFIG_PROTECT */
 	for (i = 1; i < cp_argc; ++i)
 		if (strncmp(cp_argv[i], buf, strlen(cp_argv[i])) == 0)
-			if (access(dest, R_OK) == 0)
-				return 1;
+			return 1;
 
 	/* this would probably be bad */
 	if (strcmp(CONFIG_EPREFIX "bin/sh", buf) == 0)
@@ -777,7 +770,7 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 /* Copy one tree (the single package) to another tree (ROOT) */
 static int
 merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
-              FILE *contents, set **objs, char **cpathp,
+              FILE *contents, size_t eprefix_len, set **objs, char **cpathp,
               int cp_argc, char **cp_argv, int cpm_argc, char **cpm_argv)
 {
 	int i, ret, subfd_src, subfd_dst;
@@ -847,8 +840,9 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 			qprintf("%s>>>%s %s%s%s/\n", GREEN, NORM, DKBLUE, cpath, NORM);
 
 			/* Copy all of these contents */
-			merge_tree_at(subfd_src, name, subfd_dst, name, contents, objs,
-					cpathp, cp_argc, cp_argv, cpm_argc, cpm_argv);
+			merge_tree_at(subfd_src, name,
+					subfd_dst, name, contents, eprefix_len,
+					objs, cpathp, cp_argc, cp_argv, cpm_argc, cpm_argv);
 			cpath = *cpathp;
 			mnlen = 0;
 
@@ -862,6 +856,7 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 			unsigned char *hash;
 			const char *tmpname, *dname;
 			char buf[_Q_PATH_MAX * 2];
+			struct stat ignore;
 
 			/* syntax: obj filename hash mtime */
 			hash = hash_file_at(subfd_src, name, HASH_MD5);
@@ -871,7 +866,10 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 			free(hash);
 
 			/* Check CONFIG_PROTECT */
-			if (config_protected(cpath, cp_argc, cp_argv, cpm_argc, cpm_argv)) {
+			if (config_protected(cpath + eprefix_len,
+						cp_argc, cp_argv, cpm_argc, cpm_argv) &&
+					fstatat(subfd_dst, name, &ignore, AT_SYMLINK_NOFOLLOW) == 0)
+			{
 				/* ._cfg####_ */
 				char *num;
 				dname = buf;
@@ -880,7 +878,7 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 				for (i = 0; i < 10000; ++i) {
 					sprintf(num, "%04i", i);
 					num[4] = '_';
-					if (faccessat(subfd_dst, dname, F_OK, AT_SYMLINK_NOFOLLOW))
+					if (fstatat(subfd_dst, dname, &ignore, AT_SYMLINK_NOFOLLOW))
 						break;
 				}
 				qprintf("%s>>>%s %s (%s)\n", GREEN, NORM, cpath, dname);
@@ -1288,7 +1286,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	pkg_run_func("vdb", phases, "pkg_preinst", D, T);
 
 	if (!eat_file("vdb/EPREFIX", &eprefix, &eprefix_len))
-		eprefix = NULL;
+		eprefix_len = 0;
 
 	{
 		int imagefd = open("image", O_RDONLY);
@@ -1300,7 +1298,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		if (fstat(imagefd, &st) == -1) {
 			close(imagefd);
 			err("Cannot stat image dirfd");
-		} else if (eprefix != NULL) {
+		} else if (eprefix_len > 0) {
 			int imagepfx = openat(imagefd, eprefix + 1, O_RDONLY);
 			if (imagepfx != -1) {
 				close(imagefd);
@@ -1333,7 +1331,6 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		close(imagefd);
 	}
 
-	/* TODO: merge_tree_at should use this, and use chpathtool code? */
 	if (eprefix != NULL)
 		free(eprefix);
 
@@ -1350,8 +1347,9 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 
 		cpath = xstrdup("");  /* xrealloced in merge_tree_at */
 
-		ret = merge_tree_at(AT_FDCWD, "image", AT_FDCWD, portroot, contents,
-					&objs, &cpath, cp_argc, cp_argv, cpm_argc, cpm_argv);
+		ret = merge_tree_at(AT_FDCWD, "image",
+				AT_FDCWD, portroot, contents, eprefix_len,
+				&objs, &cpath, cp_argc, cp_argv, cpm_argc, cpm_argv);
 
 		free(cpath);
 
@@ -1450,11 +1448,11 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 		int cp_argc, char **cp_argv, int cpm_argc, char **cpm_argv)
 {
 	tree_cat_ctx *cat_ctx = pkg_ctx->cat_ctx;
-	const char *cat = cat_ctx->name;
-	const char *pkgname = pkg_ctx->name;
 	size_t buflen;
 	static char *phases;
 	static size_t phases_len;
+	char *eprefix = NULL;
+	size_t eprefix_len = 0;
 	const char *T;
 	char *buf;
 	FILE *fp;
@@ -1466,8 +1464,8 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 	buf = phases = NULL;
 	T = "${PWD}/temp";
 
-	printf("%s<<<%s %s%s%s/%s%s%s\n",
-			YELLOW, NORM, WHITE, cat, NORM, CYAN, pkgname, NORM);
+	printf("%s<<<%s %s\n", YELLOW, NORM,
+			atom_format("%[CATEGORY]%[PF]", tree_get_atom(pkg_ctx, false), 0));
 
 	if (pretend == 100)
 		return 0;
@@ -1486,6 +1484,11 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 		pkg_run_func_at(pkg_ctx->fd, ".", phases, "pkg_prerm", T, T);
 	}
 
+	if (!tree_pkg_vdb_eat(pkg_ctx, "EPREFIX", &eprefix, &eprefix_len))
+		eprefix_len = 0;
+	if (eprefix != NULL)
+		free(eprefix);
+
 	unmerge_config_protected =
 		strstr(features, "config-protect-if-modified") != NULL;
 
@@ -1500,7 +1503,7 @@ pkg_unmerge(tree_pkg_ctx *pkg_ctx, set *keep,
 		if (!e)
 			continue;
 
-		protected = config_protected(e->name,
+		protected = config_protected(e->name + eprefix_len,
 				cp_argc, cp_argv, cpm_argc, cpm_argv);
 
 		/* This should never happen ... */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-10 13:31 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-10 13:31 UTC (permalink / raw
  To: gentoo-commits

commit:     edcb8e142ee18f19f8e9aa9ab7bbccab39fc63c1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 10 13:29:52 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 10 13:29:52 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=edcb8e14

qmerge: avoid nested vdb entries

while writing a new vdb dir, ensure we removed any existing one, for
rename will only overwrite an empty directory.  This also means the `mv`
fallback is pointless, because rename now no longer will fail, and mv no
longer will put the vdb dir inside the target dir.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index ce45628..8644ddc 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1342,6 +1342,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 
 	if ((contents = fopen("vdb/CONTENTS", "w")) == NULL)
 		errf("come on wtf?");
+
 	objs = NULL;
 	{
 		char *cpath;
@@ -1415,6 +1416,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	free(T);
 
 	/* Update the magic counter */
+	/* FIXME: check Portage's get_counter_tick_core */
 	if ((fp = fopen("vdb/COUNTER", "w")) != NULL) {
 		fputs("0", fp);
 		fclose(fp);
@@ -1426,11 +1428,9 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 				portroot, portvdb, pkg->CATEGORY);
 		mkdir_p(buf, 0755);
 		strcat(buf, pkg->PF);
-		if (rename("vdb", buf)) {
-			xasprintf(&p, "mv vdb '%s'", buf);
-			xsystem(p);
-			free(p);
-		}
+		rm_rf(buf);  /* get rid of existing dir, empty dir is fine */
+		if (rename("vdb", buf) != 0)
+			warn("failed to move 'vdb' to '%s': %s", buf, strerror(errno));
 	}
 
 	/* clean up our local temp dir */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-10 12:50 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-10 12:50 UTC (permalink / raw
  To: gentoo-commits

commit:     9b2b2827eda8720928d1657e0c0d1bfcf48f58eb
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 10 12:49:29 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 10 12:49:29 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9b2b2827

qmerge: consider the correct EPREFIX (from binpkg)

It's wrong to assume binpkg has same EPREFIX (if at all), and its wrong
to assume it doesn't have it either, so read from binpkg.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 5a28544..ce45628 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1015,6 +1015,8 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	FILE *fp, *contents;
 	static char *phases;
 	static size_t phases_len;
+	char *eprefix = NULL;
+	size_t eprefix_len = 0;
 	char buf[1024];
 	char *tbz2, *p, *D, *T;
 	int i;
@@ -1285,8 +1287,11 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	pkg_run_func("vdb", phases, "pkg_setup", D, T);
 	pkg_run_func("vdb", phases, "pkg_preinst", D, T);
 
+	if (!eat_file("vdb/EPREFIX", &eprefix, &eprefix_len))
+		eprefix = NULL;
+
 	{
-		int imagefd = open("image" CONFIG_EPREFIX, O_RDONLY);
+		int imagefd = open("image", O_RDONLY);
 		size_t masklen = strlen(install_mask) + 1 +
 				15 + 1 + 14 + 1 + 14 + 1 + 1;  /* worst case scenario */
 		char *imask = xmalloc(masklen);
@@ -1295,6 +1300,12 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		if (fstat(imagefd, &st) == -1) {
 			close(imagefd);
 			err("Cannot stat image dirfd");
+		} else if (eprefix != NULL) {
+			int imagepfx = openat(imagefd, eprefix + 1, O_RDONLY);
+			if (imagepfx != -1) {
+				close(imagefd);
+				imagefd = imagepfx;
+			}
 		}
 
 		/* rely on INSTALL_MASK code to remove optional dirs */
@@ -1322,6 +1333,10 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		close(imagefd);
 	}
 
+	/* TODO: merge_tree_at should use this, and use chpathtool code? */
+	if (eprefix != NULL)
+		free(eprefix);
+
 	makeargv(config_protect, &cp_argc, &cp_argv);
 	makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-10 10:12 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-10 10:12 UTC (permalink / raw
  To: gentoo-commits

commit:     33f093218ac4c0c401ff38e1f0326ec9b708915a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 10 10:12:11 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 10 10:12:11 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=33f09321

Revert "qmerge: fix imagefd path"

This reverts commit 2b9dfb7df57a83092c8491b61ff9bcdc84e7f47b.

this was a thinko, the problem laid elsewhere

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index b36d709..5a28544 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1286,7 +1286,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	pkg_run_func("vdb", phases, "pkg_preinst", D, T);
 
 	{
-		int imagefd = open(".", O_RDONLY);
+		int imagefd = open("image" CONFIG_EPREFIX, O_RDONLY);
 		size_t masklen = strlen(install_mask) + 1 +
 				15 + 1 + 14 + 1 + 14 + 1 + 1;  /* worst case scenario */
 		char *imask = xmalloc(masklen);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-10 10:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-10 10:09 UTC (permalink / raw
  To: gentoo-commits

commit:     77562c57f97eb621d3f777f1302073e7ba95ec04
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 10 10:00:10 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 10 10:00:10 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=77562c57

main: CONFIG_PROTECT should not be prefixed

CONFIG_PROTECT and CONFIG_PROTECT_MASK come from profiles, and therefore
cannot hold EPREFIX.  The consuming code has to deal with that, so don't
add EPREFIX to the default value.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index b07eb5a..56a05d3 100644
--- a/main.c
+++ b/main.c
@@ -609,7 +609,7 @@ initialize_portage_env(void)
 		_Q_EVS(ISTR, INSTALL_MASK,        install_mask,        "")
 		_Q_EVS(ISTR, PKG_INSTALL_MASK,    pkg_install_mask,    "")
 		_Q_EVS(STR,  ARCH,                portarch,            "")
-		_Q_EVS(ISTR, CONFIG_PROTECT,      config_protect,      CONFIG_EPREFIX "etc")
+		_Q_EVS(ISTR, CONFIG_PROTECT,      config_protect,      "/etc")
 		_Q_EVS(ISTR, CONFIG_PROTECT_MASK, config_protect_mask, "")
 		_Q_EVB(BOOL, NOCOLOR,             nocolor,             0)
 		_Q_EVS(ISTR, FEATURES,            features,            "")


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-10 10:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-10 10:09 UTC (permalink / raw
  To: gentoo-commits

commit:     e8360704665353948cc9d7011ea9eb47a7b4a2ea
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 10 07:57:30 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 10 07:57:30 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e8360704

qmerge: don't crash when no arguments are given

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/qmerge.c b/qmerge.c
index a558701..c11856b 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -2388,6 +2388,11 @@ int qmerge_main(int argc, char **argv)
 	for (i = optind; i < argc; ++i)
 		todo = qmerge_add_set(argv[i], todo);
 
+	if (todo == NULL) {
+		warn("need package names to work with");
+		return EXIT_FAILURE;
+	}
+
 	if (!uninstall)
 		qmerge_initialize();
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-10 10:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-10 10:09 UTC (permalink / raw
  To: gentoo-commits

commit:     2b9dfb7df57a83092c8491b61ff9bcdc84e7f47b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 10 10:03:10 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 10 10:03:10 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2b9dfb7d

qmerge: fix imagefd path

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 31a9648..aa10d9c 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1286,7 +1286,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	pkg_run_func("vdb", phases, "pkg_preinst", D, T);
 
 	{
-		int imagefd = open("image" CONFIG_EPREFIX, O_RDONLY);
+		int imagefd = open(".", O_RDONLY);
 		size_t masklen = strlen(install_mask) + 1 +
 				15 + 1 + 14 + 1 + 14 + 1 + 1;  /* worst case scenario */
 		char *imask = xmalloc(masklen);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-10 10:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-10 10:09 UTC (permalink / raw
  To: gentoo-commits

commit:     7a25088dd562bfc9a0db68944e85913aa90fa178
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 10 10:04:47 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 10 10:04:47 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7a25088d

qmerge: fix atom_compare call, make sure user argument is query

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index aa10d9c..b36d709 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -2163,7 +2163,7 @@ parse_packages(set *todo)
 					for (i = 0; i < todo_cnt; i++) {
 						pkg_atom->REPO = todo_atoms[i]->REPO ? Pkg.REPO : NULL;
 						pkg_atom->SLOT = todo_atoms[i]->SLOT ? Pkg.SLOT : NULL;
-						if (atom_compare(todo_atoms[i], pkg_atom) == EQUAL) {
+						if (atom_compare(pkg_atom, todo_atoms[i]) == EQUAL) {
 							if (search_pkgs)
 								print_Pkg(verbose, pkg_atom, &Pkg);
 							else


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-10 10:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-10 10:09 UTC (permalink / raw
  To: gentoo-commits

commit:     18886e6e1c037ea95a05ff200a8a5097df80d9fe
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 10 10:01:35 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jun 10 10:01:35 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=18886e6e

qmerge: fix some issues regarding EPREFIX usage

- EROOT and ED don't have EPREFIX prefixed, but postfixed
- config_protect should expect the checked paths not to have EPREFIX

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index c11856b..31a9648 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -358,6 +358,10 @@ config_protected(const char *buf, int cp_argc, char **cp_argv,
 	char dest[_Q_PATH_MAX];
 	snprintf(dest, sizeof(dest), "%s%s", portroot, buf);
 
+	/* config protect paths don't carry EPREFIX */
+	if (strncmp(buf, CONFIG_EPREFIX, strlen(CONFIG_EPREFIX) - 1) == 0)
+		buf += strlen(CONFIG_EPREFIX) - 1;
+
 	/* Check CONFIG_PROTECT_MASK */
 	for (i = 1; i < cpm_argc; ++i)
 		if (strncmp(cpm_argv[i], buf, strlen(cpm_argv[i])) == 0)
@@ -370,7 +374,7 @@ config_protected(const char *buf, int cp_argc, char **cp_argv,
 				return 1;
 
 	/* this would probably be bad */
-	if (strcmp("/bin/sh", buf) == 0)
+	if (strcmp(CONFIG_EPREFIX "bin/sh", buf) == 0)
 		return 1;
 
 	return 0;
@@ -750,9 +754,9 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 		"FILESDIR=/.does/not/exist/anywhere\n"
 		"MERGE_TYPE=binary\n"
 		"ROOT='%4$s'\n"
-		"EROOT=\"${EPREFIX%%/}/${ROOT#/}/\"\n"
+		"EROOT=\"/${ROOT#/}/${EPREFIX%%/}/\"\n"
 		"D=\"%5$s\"\n"
-		"ED=\"${EPREFIX%%/}/${D#/}/\"\n"
+		"ED=\"${D%%/}/${EPREFIX%%/}/\"\n"
 		"T=\"%6$s\"\n"
 		/* Finally run the func */
 		"%7$s%2$s\n"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-09  9:23 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-09  9:23 UTC (permalink / raw
  To: gentoo-commits

commit:     b5f3c8c0e052faf2971ebc161545abd84af64486
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Jun  9 09:22:48 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Jun  9 09:22:48 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b5f3c8c0

qfile: fix atom_compare invocation and input

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qfile.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/qfile.c b/qfile.c
index 421c850..1480789 100644
--- a/qfile.c
+++ b/qfile.c
@@ -92,15 +92,16 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	int found = 0;
 
 	/* If exclude_pkg is not NULL, check it.  We are looking for files
-	 * collisions, and must exclude one package.
-	 */
+	 * collisions, and must exclude one package. */
 	if (state->exclude_pkg) {
 		/* see if CATEGORY matches */
 		if (state->exclude_atom->CATEGORY &&
 		    strcmp(state->exclude_atom->CATEGORY, catname))
 			goto dont_skip_pkg;
-		atom = tree_get_atom(pkg_ctx, false);
-		if (atom_compare(state->exclude_atom, atom) != EQUAL)
+		atom = tree_get_atom(pkg_ctx,
+				state->exclude_atom->SLOT != NULL ||
+				state->exclude_atom->REPO != NULL);
+		if (atom_compare(atom, state->exclude_atom) != EQUAL)
 			goto dont_skip_pkg;
 		/* "(CAT/)?(PN|PF)" matches, and no SLOT specified */
 		if (state->exclude_slot == NULL)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-08 18:42 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-08 18:42 UTC (permalink / raw
  To: gentoo-commits

commit:     a12c799e0df591ec90814328fd6f6e90bca772ae
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jun  8 18:42:18 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jun  8 18:42:18 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a12c799e

qgrep: plug filedescritor leak

Bug: https://bugs.gentoo.org/687640
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qgrep.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qgrep.c b/qgrep.c
index 2db61df..dff959b 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -430,6 +430,7 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	}
 
 	ret = qgrep_grepat(pfd, buf, label, data);
+	close(pfd);
 
 	return ret;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-08 18:25 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-08 18:25 UTC (permalink / raw
  To: gentoo-commits

commit:     73e948da651ff5b25ce0eb9dc38e1f5adcc5ccbb
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jun  8 18:24:12 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jun  8 18:24:12 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=73e948da

applets.h: fix qmanifest conditional

it's not HAVE_QMANIFEST but ENABLE_QMANIFEST

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/applets.h b/applets.h
index 68bf7f6..fbb21aa 100644
--- a/applets.h
+++ b/applets.h
@@ -46,7 +46,7 @@ DECLARE_APPLET(qgrep)
 DECLARE_APPLET(qkeyword)
 DECLARE_APPLET(qlist)
 DECLARE_APPLET(qlop)
-#ifdef HAVE_QMANIFEST
+#ifdef ENABLE_QMANIFEST
 DECLARE_APPLET(qmanifest)
 #endif
 DECLARE_APPLET(qmerge)
@@ -78,7 +78,7 @@ static const struct applet_t {
 	{"qkeyword",  qkeyword_main,  "<action> <args>", "list packages based on keywords"},
 	{"qlist",     qlist_main,     "<pkgname>",       "list files owned by pkgname"},
 	{"qlop",      qlop_main,      "<pkgname>",       "emerge log analyzer"},
-#ifdef HAVE_QMANIFEST
+#ifdef ENABLE_QMANIFEST
 	{"qmanifest", qmanifest_main, "<misc args>",     "verify or generate thick Manifest files"},
 #endif
 	{"qmerge",    qmerge_main,    "<pkgnames>",      "fetch and merge binary package"},
@@ -112,7 +112,7 @@ static const struct applet_t {
 	/* alias for qtegrity */
 	{"integrity", qtegrity_main,  NULL, NULL},
 
-#ifdef HAVE_QMANIFEST
+#ifdef ENABLE_QMANIFEST
 	/* old hashgen */
 	{"hashgen",   qmanifest_main, NULL, NULL},
 	{"hashverify",qmanifest_main, NULL, NULL},


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-08 18:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-08 18:13 UTC (permalink / raw
  To: gentoo-commits

commit:     f245321bdbc9e068ed24d5693db7de33586cab9b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jun  8 18:07:52 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jun  8 18:07:52 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f245321b

autogen: hard require dev-libs/gnulib and sys-devel/autoconf-archive

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 autogen.sh | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index 8a59e9d..1cfb68b 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -4,9 +4,19 @@ v() { echo "$@"; "$@"; }
 
 m4dir="autotools/m4"
 
+# check for dependencies
+if ! qlist -qI dev-libs/gnulib > /dev/null ; then
+	echo "please install dev-libs/gnulib"
+	exit 1
+fi
+if ! qlist -qI sys-devel/autoconf-archive > /dev/null ; then
+	echo "please install sys-devel/autoconf-archive"
+	exit 1
+fi
+
 v rm -rf autotools
 
-# reload the gnulib code if possible
+# reload the gnulib code
 PATH=/usr/local/src/gnu/gnulib:${PATH}
 mods="
 	dirent
@@ -37,12 +47,5 @@ v gnulib-tool \
 	--no-vc-files \
 	${mods}
 
-# not everyone has sys-devel/autoconf-archive installed
-for macro in $(grep -o '\<AX[A-Z_]*\>' configure.ac | sort -u) ; do
-	if m4=$(grep -rl "\[${macro}\]" /usr/share/aclocal/) ; then
-		v cp $m4 ${m4dir}/
-	fi
-done
-
 export AUTOMAKE="automake --foreign"
 v autoreconf -i -f


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-08 18:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-08 18:13 UTC (permalink / raw
  To: gentoo-commits

commit:     0c0ad25287d0f2c74c4fbfa7c72281f6169c72f7
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  7 18:00:01 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jun  7 18:00:01 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0c0ad252

qlist: fix crash in qlist_match when atom->SUBSLOT is absent

when the query has a subslot, but the package in question doesn't, don't
try to match it

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlist.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qlist.c b/qlist.c
index 52ae77d..0299d54 100644
--- a/qlist.c
+++ b/qlist.c
@@ -245,7 +245,8 @@ qlist_match(
 		if (strcmp(atom->SLOT, uslot) != 0)
 			return false;
 
-		if (usslot != NULL && strcmp(atom->SUBSLOT, usslot) != 0)
+		if (usslot != NULL &&
+				(atom->SUBSLOT == NULL || strcmp(atom->SUBSLOT, usslot) != 0))
 			return false;
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-08 18:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-08 18:13 UTC (permalink / raw
  To: gentoo-commits

commit:     dd5b9a8f11448ba8a644d0d352416ead0eb066bf
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  7 17:57:02 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jun  7 17:57:02 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=dd5b9a8f

main: update default locations for PORTDIR and PKGDIR

  /usr/portage -> /var/db/repos/gentoo
  /usr/portage/packages -> /var/cache/binpkgs

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c
index 0fdb420..b07eb5a 100644
--- a/main.c
+++ b/main.c
@@ -615,10 +615,10 @@ initialize_portage_env(void)
 		_Q_EVS(ISTR, FEATURES,            features,            "")
 		_Q_EVS(STR,  EPREFIX,             eprefix,             CONFIG_EPREFIX)
 		_Q_EVS(STR,  EMERGE_LOG_DIR,      portlogdir,          CONFIG_EPREFIX "var/log")
-		_Q_EVS(STR,  PORTDIR,             main_overlay,        CONFIG_EPREFIX "usr/portage")
+		_Q_EVS(STR,  PORTDIR,             main_overlay,        CONFIG_EPREFIX "var/db/repos/gentoo")
 		_Q_EVS(STR,  PORTAGE_BINHOST,     binhost,             DEFAULT_PORTAGE_BINHOST)
 		_Q_EVS(STR,  PORTAGE_TMPDIR,      port_tmpdir,         CONFIG_EPREFIX "var/tmp/portage/")
-		_Q_EVS(STR,  PKGDIR,              pkgdir,              CONFIG_EPREFIX "usr/portage/packages/")
+		_Q_EVS(STR,  PKGDIR,              pkgdir,              CONFIG_EPREFIX "var/cache/binpkgs/")
 		_Q_EVS(STR,  Q_VDB,               portvdb,             CONFIG_EPREFIX "var/db/pkg")
 		_Q_EVS(STR,  Q_EDB,               portedb,             CONFIG_EPREFIX "var/cache/edb")
 		{ NULL, 0, _Q_BOOL, { NULL }, 0, NULL, }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-08 18:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-08 18:13 UTC (permalink / raw
  To: gentoo-commits

commit:     5c78c3c3681d5651efc568f73f4a7b719006700d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Jun  8 18:08:53 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Jun  8 18:08:53 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5c78c3c3

buildsys: fix build when qmanifest is not enabled

- don't refer to qmanifest_main
- don't overlink to needless libs, even when found (like openmp)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 Makefile.am | 8 +++++---
 applets.h   | 6 ++++++
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 25afc1b..fc0619c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -69,14 +69,11 @@ q_SOURCES = \
 	qxpak.c \
 	$(NULL)
 q_CPPFLAGS = \
-	$(OPENMP_CFLAGS) \
-	$(GPGME_CFLAGS) \
 	-I$(top_srcdir)/libq \
 	-I$(top_builddir)/autotools/gnulib \
 	-I$(top_srcdir)/autotools/gnulib \
 	$(NULL)
 q_LDADD = \
-	$(OPENMP_CFLAGS) \
 	$(top_builddir)/libq/libq.la \
 	$(top_builddir)/autotools/gnulib/libgnu.a \
 	-liniparser \
@@ -90,6 +87,11 @@ q_LDADD = \
 
 if QMANIFEST_ENABLED
 q_SOURCES += qmanifest.c
+q_CPPFLAGS += \
+	$(OPENMP_CFLAGS) \
+	$(GPGME_CFLAGS)
+q_LDADD += \
+	$(OPENMP_CFLAGS)
 dist_man_MANS += man/qmanifest.1
 APPLETS += qmanifest
 endif

diff --git a/applets.h b/applets.h
index d8383d4..68bf7f6 100644
--- a/applets.h
+++ b/applets.h
@@ -46,7 +46,9 @@ DECLARE_APPLET(qgrep)
 DECLARE_APPLET(qkeyword)
 DECLARE_APPLET(qlist)
 DECLARE_APPLET(qlop)
+#ifdef HAVE_QMANIFEST
 DECLARE_APPLET(qmanifest)
+#endif
 DECLARE_APPLET(qmerge)
 DECLARE_APPLET(qpkg)
 DECLARE_APPLET(qsearch)
@@ -76,7 +78,9 @@ static const struct applet_t {
 	{"qkeyword",  qkeyword_main,  "<action> <args>", "list packages based on keywords"},
 	{"qlist",     qlist_main,     "<pkgname>",       "list files owned by pkgname"},
 	{"qlop",      qlop_main,      "<pkgname>",       "emerge log analyzer"},
+#ifdef HAVE_QMANIFEST
 	{"qmanifest", qmanifest_main, "<misc args>",     "verify or generate thick Manifest files"},
+#endif
 	{"qmerge",    qmerge_main,    "<pkgnames>",      "fetch and merge binary package"},
 	{"qpkg",      qpkg_main,      "<misc args>",     "manipulate Gentoo binpkgs"},
 	{"qsearch",   qsearch_main,   "<regex>",         "search pkgname/desc"},
@@ -108,9 +112,11 @@ static const struct applet_t {
 	/* alias for qtegrity */
 	{"integrity", qtegrity_main,  NULL, NULL},
 
+#ifdef HAVE_QMANIFEST
 	/* old hashgen */
 	{"hashgen",   qmanifest_main, NULL, NULL},
 	{"hashverify",qmanifest_main, NULL, NULL},
+#endif
 
 	{NULL, NULL, NULL, NULL}
 };


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-07 12:20 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-07 12:20 UTC (permalink / raw
  To: gentoo-commits

commit:     3b00486fb75941e66bcc829d4e0481d6a349cc82
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Jun  7 12:19:32 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Jun  7 12:19:32 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3b00486f

applets.h: loose __weak__ attribute stuff

defining this attribute breaks Cygwin, but more importantly it is not
necessary with the current (much more normal) way of building and
linking q.

Bug: https://bugs.gentoo.org/687560
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/applets.h b/applets.h
index 902e664..d8383d4 100644
--- a/applets.h
+++ b/applets.h
@@ -35,8 +35,7 @@ extern int	getopt_long(int, char * const *, const char *,
 /* applet prototypes */
 typedef int (*APPLET)(int, char **);
 
-#define DECLARE_APPLET(applet) \
-	extern int applet##_main(int, char **) __attribute__((weak));
+#define DECLARE_APPLET(applet) extern int applet##_main(int, char **);
 DECLARE_APPLET(q)
 DECLARE_APPLET(qatom)
 DECLARE_APPLET(qcheck)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-06 13:52 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-06 13:52 UTC (permalink / raw
  To: gentoo-commits

commit:     53728f13f533d18ec7ed39f318fd601cb945ce6d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  6 13:51:47 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun  6 13:51:47 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=53728f13

qlop: fix whitespace

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qlop.c b/qlop.c
index c356e6b..2aa14a5 100644
--- a/qlop.c
+++ b/qlop.c
@@ -451,7 +451,7 @@ static int do_emerge_log(
 			} else if (parallel_emerge > 0) {
 				parallel_emerge--;
 			}
-			
+
 			/* for bug #687508, this cannot be in the else if case
 			 * above, if the log is truncated somehow, the leading
 			 * *** emerge might be missing, but a termination in that


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-06 13:46 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-06 13:46 UTC (permalink / raw
  To: gentoo-commits

commit:     3c6670dbfa4b54c859d5423c95538b3f054b0dd0
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  6 10:53:37 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun  6 10:53:37 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3c6670db

qmanifest: terminate error line

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmanifest.c b/qmanifest.c
index 551f54c..de68569 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -960,7 +960,7 @@ verify_gpg_sig(const char *path, verify_msg **msgs)
 				free(ret);
 				ret = NULL;
 				printf("the signature could not be verified due to a "
-						"missing key for:\n  %s", buf);
+						"missing key for:\n  %s\n", buf);
 				break;
 			default:
 				free(ret);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-06 13:46 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-06 13:46 UTC (permalink / raw
  To: gentoo-commits

commit:     ca7402e12d1e149a7f2a3dee985c4e17dde6e28e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  6 13:44:23 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun  6 13:44:23 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ca7402e1

qlop: prune running packages list more often

When we don't have proof that Portage started, but we see it finishing,
prune the entire list of unfinished packages, in order to deal with
truncated/rotated logs.

Bug: https://bugs.gentoo.org/687508
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 40 +++++++++++++++++++++++-----------------
 1 file changed, 23 insertions(+), 17 deletions(-)

diff --git a/qlop.c b/qlop.c
index a3b4d53..c356e6b 100644
--- a/qlop.c
+++ b/qlop.c
@@ -450,23 +450,29 @@ static int do_emerge_log(
 				parallel_emerge++;
 			} else if (parallel_emerge > 0) {
 				parallel_emerge--;
-				if (parallel_emerge == 0) {
-					/* we just finished the only emerge we found to be
-					 * running, so if there were "running" (unfinished)
-					 * merges, they must have been terminated */
-					sync_start = 0;
-					while ((i = array_cnt(merge_matches)) > 0) {
-						i--;
-						pkgw = xarrayget(merge_matches, i);
-						atom_implode(pkgw->atom);
-						xarraydelete(merge_matches, i);
-					}
-					while ((i = array_cnt(unmerge_matches)) > 0) {
-						i--;
-						pkgw = xarrayget(unmerge_matches, i);
-						atom_implode(pkgw->atom);
-						xarraydelete(unmerge_matches, i);
-					}
+			}
+			
+			/* for bug #687508, this cannot be in the else if case
+			 * above, if the log is truncated somehow, the leading
+			 * *** emerge might be missing, but a termination in that
+			 * case better means we forget about everything that was
+			 * unfinished not to keep reporting some packages forever */
+			if (parallel_emerge == 0) {
+				/* we just finished the only emerge we found to be
+				 * running, so if there were "running" (unfinished)
+				 * merges, they must have been terminated */
+				sync_start = 0;
+				while ((i = array_cnt(merge_matches)) > 0) {
+					i--;
+					pkgw = xarrayget(merge_matches, i);
+					atom_implode(pkgw->atom);
+					xarraydelete(merge_matches, i);
+				}
+				while ((i = array_cnt(unmerge_matches)) > 0) {
+					i--;
+					pkgw = xarrayget(unmerge_matches, i);
+					atom_implode(pkgw->atom);
+					xarraydelete(unmerge_matches, i);
 				}
 			}
 		}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-06  8:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-06  8:14 UTC (permalink / raw
  To: gentoo-commits

commit:     0ccae5a9f063ed2dc112340e70f4593d696aa0a5
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Jun  6 08:10:48 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun  6 08:10:48 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0ccae5a9

qmanifest: improve verification error descriptions

try and report fingerprint being checked (which can be copy/pasted into
gpg --list-keys) and use gpgme_strerror in case we don't handle the
specific error, such that we still throw a possible hint at the user

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md     |  1 +
 qmanifest.c | 16 +++++++++++-----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/TODO.md b/TODO.md
index 14bd6eb..61f1c98 100644
--- a/TODO.md
+++ b/TODO.md
@@ -90,6 +90,7 @@
 
 # qmanifest
 - use openat in most places
+- parse timestamps and print in local timezone
 
 # qlop
 - guestimate runtime based on best-matching pkg (e.g. with gcc)

diff --git a/qmanifest.c b/qmanifest.c
index 541ab34..551f54c 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -899,13 +899,18 @@ verify_gpg_sig(const char *path, verify_msg **msgs)
 	if ((sig = vres->signatures) != NULL) {
 		ret = xmalloc(sizeof(gpg_sig));
 
-		if (sig->status != GPG_ERR_NO_PUBKEY) {
-			ret->algo = xstrdup(gpgme_pubkey_algo_name(sig->pubkey_algo));
+		if (sig->fpr != NULL) {
 			snprintf(buf, sizeof(buf),
 					"%.4s %.4s %.4s %.4s %.4s  %.4s %.4s %.4s %.4s %.4s",
 					sig->fpr +  0, sig->fpr +  4, sig->fpr +  8, sig->fpr + 12,
 					sig->fpr + 16, sig->fpr + 20, sig->fpr + 24, sig->fpr + 28,
 					sig->fpr + 32, sig->fpr + 36);
+		} else {
+			snprintf(buf, sizeof(buf), "<fingerprint not found>");
+		}
+
+		if (sig->status != GPG_ERR_NO_PUBKEY) {
+			ret->algo = xstrdup(gpgme_pubkey_algo_name(sig->pubkey_algo));
 			ret->fingerprint = xstrdup(buf);
 			ret->isgood = sig->status == GPG_ERR_NO_ERROR ? 1 : 0;
 			ctime = gmtime((time_t *)&sig->timestamp);
@@ -955,13 +960,14 @@ verify_gpg_sig(const char *path, verify_msg **msgs)
 				free(ret);
 				ret = NULL;
 				printf("the signature could not be verified due to a "
-						"missing key\n");
+						"missing key for:\n  %s", buf);
 				break;
 			default:
 				free(ret);
 				ret = NULL;
-				printf("there was some other error which prevented the "
-						"signature verification\n");
+				printf("there was some error which prevented the "
+						"signature verification:\n  %s: %s\n",
+						buf, gpgme_strerror(sig->status));
 				break;
 		}
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-06-05  7:57 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-06-05  7:57 UTC (permalink / raw
  To: gentoo-commits

commit:     d79b3814bebca3a23c4e4e850047381b7a2b7d65
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  5 07:51:54 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun  5 07:51:54 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d79b3814

TODO: add some things/ideas

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md    | 9 +++++++++
 qdepends.c | 2 +-
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/TODO.md b/TODO.md
index e32cbfe..14bd6eb 100644
--- a/TODO.md
+++ b/TODO.md
@@ -63,6 +63,8 @@
 
 - add -S/-v/-R behavior like qlist #574934
 - bring back -k?  (but seems solved by using qlist -IF%{SLOT} pkg)
+- -Qt acts weird (if not, incorrect)
+- -v should lookup whether packages are installed for || cases/colouring
 
 # qpkg
 
@@ -88,3 +90,10 @@
 
 # qmanifest
 - use openat in most places
+
+# qlop
+- guestimate runtime based on best-matching pkg (e.g. with gcc)
+- calculate or take some "smooth" factor just added on top of the
+  guestimate alternative to current time jumping
+- display excess time (+12:05) when overrunning guestimate to indicate
+  longer run than last guestimate

diff --git a/qdepends.c b/qdepends.c
index 4e6fd43..f2ae111 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -322,7 +322,7 @@ int qdepends_main(int argc, char **argv)
 	}
 
 	if ((state.qmode & ~(QMODE_REVERSE | QMODE_INSTALLED | QMODE_TREE)) == 0) {
-		/* default mode of operation: -qau (also for just -Q) */
+		/* default mode of operation: -drpb (also for just -Q) */
 		state.qmode |= QMODE_DEPEND  |
 					   QMODE_RDEPEND |
 					   QMODE_PDEPEND |


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-30 10:23 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-30 10:23 UTC (permalink / raw
  To: gentoo-commits

commit:     44b1c34cd0d02e03ca549a163a41a9d6fc74e580
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May 30 10:20:32 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May 30 10:20:32 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=44b1c34c

qlop: fix -U and -t interaction

-t, -a or -r checks for -m, -u or -s, make it also check for -U

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qlop.c b/qlop.c
index ab5dc10..a3b4d53 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1045,7 +1045,7 @@ int qlop_main(int argc, char **argv)
 
 	/* set default for -t, -a or -r */
 	if ((m.do_average || m.do_time || m.do_running) &&
-			!(m.do_merge || m.do_unmerge || m.do_sync))
+			!(m.do_merge || m.do_unmerge || m.do_autoclean || m.do_sync))
 	{
 		m.do_merge = 1;
 		m.do_unmerge = 1;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-30 10:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-30 10:09 UTC (permalink / raw
  To: gentoo-commits

commit:     ca08ed2aea1532dfd3d970f5a657abfc9e9e6f6f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May 30 09:50:39 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May 30 10:09:29 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ca08ed2a

make-tarball: update/fix for latest autotools build

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 make-tarball.sh | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/make-tarball.sh b/make-tarball.sh
index 2052985..489ce4b 100755
--- a/make-tarball.sh
+++ b/make-tarball.sh
@@ -1,8 +1,8 @@
-#!/bin/bash
+#!/bin/env bash
 
 set -e
 
-if ! . /etc/init.d/functions.sh 2>/dev/null ; then
+if ! .  ${EPREFIX}/lib/gentoo/functions.sh 2>/dev/null ; then
 	einfo() { printf ' * %b\n' "$*"; }
 	eerror() { einfo "$@" 1>&2; }
 fi
@@ -26,38 +26,32 @@ git) ver="HEAD" ;;
 	fi
 	;;
 esac
-p="portage-utils-${ver#v}"
+p="${TMPDIR:-/var/tmp}/portage-utils-${ver#v}"
 
 rm -rf "${p}"
 mkdir "${p}"
 
 einfo "Checking out clean git sources ..."
 git archive "${ver}" | tar xf - -C "${p}"
-cd "${p}"
+pushd "${p}" >/dev/null
 
 einfo "Building autotools ..."
 sed -i "/^AC_INIT/s:git:${ver#v}:" configure.ac
 sed -i "/^AM_MAINTAINER_MODE/s:(.*)$::" configure.ac
-sed -i "1iPV := ${ver#v}" Makefile
-LC_ALL=C ${MAKE} -s autotools >/dev/null
+./autogen.sh
 rm -rf autom4te.cache
-cd ..
+popd >/dev/null
 
 einfo "Generating tarball ..."
-tar --numeric-owner -cf - "${p}" | xz > "${p}".tar.xz
+pushd "${p%/*}" >/dev/null
+tar --numeric-owner -cf - "${p##*/}" | xz > "${p}".tar.xz
+popd >/dev/null
 rm -r "${p}"
-du -b "${p}".tar.*
 
-einfo "Checking tarball (simple) ..."
+einfo "Checking tarball ..."
+pushd "${p%/*}" >/dev/null
 tar xf "${p}".tar.*
-pushd "${p}" >/dev/null
-v ${MAKE} -s
-v ${MAKE} -s check
 popd >/dev/null
-rm -rf "${p}"
-
-einfo "Checking tarball (autotools) ..."
-tar xf "${p}".tar.*
 pushd "${p}" >/dev/null
 v ./configure -q
 v ${MAKE} -s
@@ -67,6 +61,7 @@ rm -rf "${p}"
 
 echo
 einfo "All ready for distribution!"
-du -b "${p}".tar.*
+mv "${p}".tar.* .
+du -b "${p##*/}".tar.*
 
 exit 0


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-30  8:55 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-30  8:55 UTC (permalink / raw
  To: gentoo-commits

commit:     6f159efc1ab01535a1857e93f9180b71d8016f75
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May 30 08:50:22 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May 30 08:55:08 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6f159efc

qfile: fix regression introduced in 55ad84ae

inversion of assume_root_prefix lead to unusable qfile with ROOT

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qfile.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qfile.c b/qfile.c
index d321a59..421c850 100644
--- a/qfile.c
+++ b/qfile.c
@@ -137,7 +137,7 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 		for (i = 0; i < args->length; i++) {
 			if (base_names[i] == NULL)
 				continue;
-			if (non_orphans && non_orphans[i])
+			if (non_orphans != NULL && non_orphans[i])
 				continue;
 
 			/* For optimization of qfile(), we also give it an array of
@@ -316,7 +316,7 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 		 * "realpath(ROOT)" prefix) */
 		if (argv[i][0] == '/') {
 			snprintf(abspath, sizeof(abspath), "%s%s",
-					state->assume_root_prefix ? real_root : "", argv[i]);
+					state->assume_root_prefix ? "" : real_root, argv[i]);
 		} else if (pwd) {
 			if (state->assume_root_prefix)
 				snprintf(abspath, sizeof(abspath), "%s/%s", pwd, argv[i]);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-25 16:04 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-25 16:04 UTC (permalink / raw
  To: gentoo-commits

commit:     d03baf897ec8ecf9cb73ea618821d65822bd3e62
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May 25 16:03:25 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May 25 16:03:25 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d03baf89

travis: perhaps getting gnupg2 helps

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index b72a165..2a51c0d 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -23,7 +23,7 @@ addons:
   apt:
     packages:
     - libgpgme11-dev
-    - gnupg
+    - gnupg2
 
 before_install:
   - ./travis/install-iniparser.sh


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-25 14:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-25 14:54 UTC (permalink / raw
  To: gentoo-commits

commit:     fdca7717ed3b76a8b2a018f40ecc45346bbced3f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May 25 14:54:42 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May 25 14:54:42 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=fdca7717

travis: try switching to a more recent ubuntu

 .travis.yml | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 1dae592..b72a165 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -13,6 +13,7 @@ sudo: false
 # Order here matters; see compiler comment above.
 os:
   - linux
+dist: xenial
 
 env:
   global:
@@ -21,9 +22,10 @@ env:
 addons:
   apt:
     packages:
+    - libgpgme11-dev
+    - gnupg
 
 before_install:
   - ./travis/install-iniparser.sh
   - ./travis/install-blake2.sh
-  - sudo apt-get install libgpgme11-dev gnupg
 script: ./travis/main.sh


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-25 14:04 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-25 14:04 UTC (permalink / raw
  To: gentoo-commits

commit:     44395ff4428c9fd741ac7848f2c507f645a96daa
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May 25 14:03:34 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May 25 14:03:34 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=44395ff4

travis: try to install gnupg

perhaps gpg isn't there causing key retrieval to fail

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 801bb4e..1dae592 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,5 +25,5 @@ addons:
 before_install:
   - ./travis/install-iniparser.sh
   - ./travis/install-blake2.sh
-  - sudo apt-get install libgpgme11-dev
+  - sudo apt-get install libgpgme11-dev gnupg
 script: ./travis/main.sh


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-25 12:19 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-25 12:19 UTC (permalink / raw
  To: gentoo-commits

commit:     52033f4ef3e633a1743de398b49a46ddd1564c99
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May 25 12:19:03 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May 25 12:19:03 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=52033f4e

qmanifest: silence warnings on Linux

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/qmanifest.c b/qmanifest.c
index b5bbd79..541ab34 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -1772,8 +1772,12 @@ qmanifest_main(int argc, char **argv)
 		if (*overlay != '/') {
 			if (portroot[1] == '\0') {
 				/* resolve the path */
-				(void)fchdir(curdirfd);
-				(void)realpath(overlay, path);
+				if (fchdir(curdirfd) != 0)
+					continue;  /* this shouldn't happen */
+				if (realpath(overlay, path) == NULL && *path == '\0') {
+					warn("could not resolve %s", overlay);
+					continue;  /* very unlikely */
+				}
 			} else {
 				snprintf(path, sizeof(path), "./%s", overlay);
 			}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-24 12:26 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-24 12:26 UTC (permalink / raw
  To: gentoo-commits

commit:     9af436a8630bee312c03502d7b754b9cd167e211
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 24 12:10:18 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 24 12:10:18 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9af436a8

gitignore: ignore all applets and gnupg stuff

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .gitignore | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/.gitignore b/.gitignore
index 47c12c7..2a20d1d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,6 +33,7 @@ Makefile
 /autotools/gnulib/*.h
 /autotools/gnulib/sys
 /tests/init.sh
+/tests/qmanifest/root/.gnupg/random_seed
 
 /*.old.c
 /q
@@ -45,10 +46,12 @@ Makefile
 /qkeyword
 /qlist
 /qlop
+/qmanifest
 /qmerge
 /qpkg
 /qsearch
 /qsize
+/qtbz2
 /qtegrity
 /quse
 /qxpak


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-22  8:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-22  8:54 UTC (permalink / raw
  To: gentoo-commits

commit:     6a8cdab3e66f5f8e4db837f3a70c2c9a915a5301
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed May 22 08:54:23 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed May 22 08:54:23 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6a8cdab3

README: add note about qmanifest (hashverify)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 README.md | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 2ad3226..1a08603 100644
--- a/README.md
+++ b/README.md
@@ -40,9 +40,12 @@ There's also a [HACKING](./HACKING.md) doc to help you get started.
 * get PORTDIR<br>
   `env DEBUG=: q -Ch 2>&1 | grep ^PORTDIR | awk '{print $3}`
 
-* Verify all packages<br>
+* verify all packages<br>
   `qcheck`
 
+* check validity of the Manifest files for the main tree<br>
+  `qmanifest`
+
 ## Contact
 
 ### Bugs


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-21 14:42 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-21 14:42 UTC (permalink / raw
  To: gentoo-commits

commit:     302d3918f7eede3cfbe2601db0901fa37e31a012
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue May 21 14:42:31 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue May 21 14:42:31 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=302d3918

travis: attempt to install gpgme11

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.travis.yml b/.travis.yml
index 2f6677a..801bb4e 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,5 +25,5 @@ addons:
 before_install:
   - ./travis/install-iniparser.sh
   - ./travis/install-blake2.sh
-  - sudo apt-get install libgpgme-dev
+  - sudo apt-get install libgpgme11-dev
 script: ./travis/main.sh


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-21 14:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-21 14:37 UTC (permalink / raw
  To: gentoo-commits

commit:     9acafbe153c79dfd17aff982593e5661e137e97b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue May 21 14:37:51 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue May 21 14:37:51 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9acafbe1

travis: attempt to install gpgme

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .travis.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.travis.yml b/.travis.yml
index 5e788a8..2f6677a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -25,4 +25,5 @@ addons:
 before_install:
   - ./travis/install-iniparser.sh
   - ./travis/install-blake2.sh
+  - sudo apt-get install libgpgme-dev
 script: ./travis/main.sh


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-21 14:12 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-21 14:12 UTC (permalink / raw
  To: gentoo-commits

commit:     db094136bfe35f5a03db850a6cb20dead18c25db
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue May 21 14:04:16 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue May 21 14:04:16 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=db094136

build-sys: conditionally build qmanifest

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 Makefile.am  | 9 ++++++---
 configure.ac | 1 +
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index f28a073..25afc1b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -17,7 +17,6 @@ APPLETS = \
 	qkeyword \
 	qlist \
 	qlop \
-	qmanifest \
 	qmerge \
 	qpkg \
 	qsearch \
@@ -38,7 +37,6 @@ dist_man_MANS = \
 	man/qkeyword.1 \
 	man/qlist.1 \
 	man/qlop.1 \
-	man/qmanifest.1 \
 	man/qmerge.1 \
 	man/qpkg.1 \
 	man/qsearch.1 \
@@ -61,7 +59,6 @@ q_SOURCES = \
 	qkeyword.c \
 	qlist.c \
 	qlop.c \
-	qmanifest.c \
 	qmerge.c \
 	qpkg.c \
 	qsearch.c \
@@ -91,6 +88,12 @@ q_LDADD = \
 	$(LIB_EACCESS) \
 	$(NULL)
 
+if QMANIFEST_ENABLED
+q_SOURCES += qmanifest.c
+dist_man_MANS += man/qmanifest.1
+APPLETS += qmanifest
+endif
+
 install-exec-hook:
 	cd $(DESTDIR)$(bindir); \
 	for applet in $(APPLETS) ; do \

diff --git a/configure.ac b/configure.ac
index 2a39df8..c0284be 100644
--- a/configure.ac
+++ b/configure.ac
@@ -103,6 +103,7 @@ AS_IF([test "x$enable_qmanifest" != xno],
 	   AC_MSG_CHECKING([whether to enable qmanifest])
 	   AC_MSG_RESULT([no: disabled by configure argument])
 	])
+AM_CONDITIONAL([QMANIFEST_ENABLED], [test "x$enable_qmanifest" != xno])
 
 AX_CFLAGS_WARN_ALL
 AC_DEFUN([PT_CHECK_CFLAG],[AX_CHECK_COMPILER_FLAGS([$1],[CFLAGS="$CFLAGS $1"])])


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-21 14:12 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-21 14:12 UTC (permalink / raw
  To: gentoo-commits

commit:     3b56114bdf1c4a014b93cc92a8fa34a3d8e8bd5e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue May 21 14:10:01 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue May 21 14:10:01 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3b56114b

qmanifest: use xmalloc functions, fix some warnings

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmanifest.c | 52 ++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 36 insertions(+), 16 deletions(-)

diff --git a/qmanifest.c b/qmanifest.c
index 09e7881..88352fa 100644
--- a/qmanifest.c
+++ b/qmanifest.c
@@ -138,7 +138,7 @@ list_dir(char ***retlist, size_t *retcnt, const char *path)
 
 			if (rlen == rsize) {
 				rsize += LISTSZ;
-				rlist = realloc(rlist,
+				rlist = xrealloc(rlist,
 						rsize * sizeof(rlist[0]));
 				if (rlist == NULL) {
 					fprintf(stderr, "out of memory\n");
@@ -691,11 +691,11 @@ generate_dir(const char *dir, enum type_manifest mtype)
 static const char *
 process_dir_gen(const char *dir)
 {
-	char path[8192];
+	char path[_Q_PATH_MAX];
 	int newhashes;
 	int curdirfd;
 
-	snprintf(path, sizeof(path), "%s/metadata/layout.conf", dir);
+	snprintf(path, sizeof(path), "%s%s/metadata/layout.conf", portroot, dir);
 	if ((newhashes = parse_layout_conf(path)) != 0) {
 		hashes = newhashes;
 	} else {
@@ -706,7 +706,8 @@ process_dir_gen(const char *dir)
 		fprintf(stderr, "cannot open current directory?!? %s\n",
 				strerror(errno));
 	}
-	if (chdir(dir) != 0) {
+	snprintf(path, sizeof(path), "%s%s", portroot, dir);
+	if (chdir(path) != 0) {
 		fprintf(stderr, "cannot chdir() to %s: %s\n", dir, strerror(errno));
 		return "not a directory";
 	}
@@ -715,7 +716,8 @@ process_dir_gen(const char *dir)
 		return "generation failed";
 
 	/* return to where we were before we called this function */
-	fchdir(curdirfd);
+	if (fchdir(curdirfd) != 0 && verbose > 1)
+		warn("could not move back to original directory");
 	close(curdirfd);
 
 	return NULL;
@@ -1154,7 +1156,7 @@ verify_dir(
 
 				if (subdirlen == subdirsize) {
 					subdirsize += LISTSZ;
-					subdir = realloc(subdir,
+					subdir = xrealloc(subdir,
 							subdirsize * sizeof(subdir[0]));
 					if (subdir == NULL) {
 						msgs_add(msgs, mfest, NULL, "out of memory allocating "
@@ -1434,8 +1436,7 @@ process_dir_vrfy(const char *dir)
 
 	gettimeofday(&startt, NULL);
 
-	fprintf(stdout, "verifying %s...\n", dir);
-	snprintf(buf, sizeof(buf), "%s/metadata/layout.conf", dir);
+	snprintf(buf, sizeof(buf), "%s%s/metadata/layout.conf", portroot,  dir);
 	if ((newhashes = parse_layout_conf(buf)) != 0) {
 		hashes = newhashes;
 	} else {
@@ -1446,7 +1447,8 @@ process_dir_vrfy(const char *dir)
 		fprintf(stderr, "cannot open current directory?!? %s\n",
 				strerror(errno));
 	}
-	if (chdir(dir) != 0) {
+	snprintf(buf, sizeof(buf), "%s%s", portroot, dir);
+	if (chdir(buf) != 0) {
 		fprintf(stderr, "cannot chdir() to %s: %s\n", dir, strerror(errno));
 		return "not a directory";
 	}
@@ -1574,7 +1576,8 @@ process_dir_vrfy(const char *dir)
 	gettimeofday(&finisht, NULL);
 
 	/* return to where we were before we called this function */
-	fchdir(curdirfd);
+	if (fchdir(curdirfd) != 0 && verbose > 1)
+		warn("could not move back to original directory");
 	close(curdirfd);
 
 	etime = ((double)((finisht.tv_sec - startt.tv_sec) * 1000000 +
@@ -1589,11 +1592,12 @@ qmanifest_main(int argc, char **argv)
 {
 	char *prog;
 	const char *(*runfunc)(const char *);
-	int ret = 0;
+	int ret;
 	const char *rsn;
 	bool isdir = false;
 	bool isoverlay = false;
 	char *overlay;
+	char path[_Q_PATH_MAX];
 	size_t n;
 	int i;
 
@@ -1634,15 +1638,14 @@ qmanifest_main(int argc, char **argv)
 	gpgme_check_version(NULL);
 
 	if (isoverlay || (!isdir && !isoverlay)) {
-		char buf[_Q_PATH_MAX];
 		char *repo;
 		size_t repolen;
 
 		array_for_each(overlays, n, overlay) {
 			repo = xarrayget(overlay_names, n);
 			if (strcmp(repo, "<PORTDIR>") == 0) {
-				snprintf(buf, sizeof(buf), "%s/profiles/repo_name", overlay);
-				if (eat_file(buf, &repo, &repolen)) {
+				snprintf(path, sizeof(path), "%s/profiles/repo_name", overlay);
+				if (eat_file(path, &repo, &repolen)) {
 					free(array_get_elem(overlays, n));
 					array_get_elem(overlays, n) = repo;
 				}
@@ -1650,6 +1653,7 @@ qmanifest_main(int argc, char **argv)
 		}
 	}
 
+	ret = EXIT_SUCCESS;
 	argc -= optind;
 	argv += optind;
 	for (i = 0; i < argc; i++) {
@@ -1669,23 +1673,39 @@ qmanifest_main(int argc, char **argv)
 
 		if (isoverlay && overlay == NULL) {
 			warn("no such overlay: %s", argv[i]);
+			ret |= 1;
 			continue;
 		}
 		if (isdir || (!isoverlay && overlay == NULL)) /* !isdir && !isoverlay */
 			overlay = argv[i];
 
+		if (runfunc == process_dir_vrfy)
+			printf("verifying %s%s%s...\n", BOLD, overlay, NORM);
+
+		if (*overlay != '/') {
+			if (portroot[1] == '\0') {
+				/* resolve the path */
+				(void)realpath(overlay, path);
+			} else {
+				snprintf(path, sizeof(path), "./%s", overlay);
+			}
+			overlay = path;
+		}
+
 		rsn = runfunc(overlay);
 		if (rsn != NULL) {
 			printf("%s%s%s\n", RED, rsn, NORM);
-			ret |= 1;
+			ret |= 2;
 		}
 	}
 
 	if (i == 0) {
+		if (runfunc == process_dir_vrfy)
+			printf("verifying %s%s%s...\n", BOLD, main_overlay, NORM);
 		rsn = runfunc(main_overlay);
 		if (rsn != NULL) {
 			printf("%s%s%s\n", RED, rsn, NORM);
-			ret |= 1;
+			ret |= 2;
 		}
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-20 12:15 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-20 12:15 UTC (permalink / raw
  To: gentoo-commits

commit:     2eb21c641333c5c35bd8cf7d6f4da79d29e14fa2
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 20 12:14:17 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> 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 <grobian <AT> 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, "<PORTDIR>");
+	}
 
 	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, "<PORTDIR>") == 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;
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-20 10:46 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-20 10:46 UTC (permalink / raw
  To: gentoo-commits

commit:     36787132c31d986bda2ad8fa82ebf107c38c5654
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 20 10:45:28 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 20 10:45:28 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=36787132

q: add option -o to print available overlays

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 applets.h |  1 +
 q.c       | 41 ++++++++++++++++++++++++++++++++++++-----
 2 files changed, 37 insertions(+), 5 deletions(-)

diff --git a/applets.h b/applets.h
index f183dca..71666bb 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 char *main_overlay;
 
 void no_colors(void);
 void setup_quiet(void);

diff --git a/q.c b/q.c
index 6307658..5499017 100644
--- a/q.c
+++ b/q.c
@@ -20,14 +20,18 @@
 #endif
 
 #include "basename.h"
+#include "eat_file.h"
+#include "rmspace.h"
 
-#define Q_FLAGS "i" COMMON_FLAGS
+#define Q_FLAGS "io" COMMON_FLAGS
 static struct option const q_long_opts[] = {
 	{"install",       no_argument, NULL, 'i'},
+	{"overlays",      no_argument, NULL, 'o'},
 	COMMON_LONG_OPTS
 };
 static const char * const q_opts_help[] = {
 	"Install symlinks for applets",
+	"Print available overlays (read from repos.conf)",
 	COMMON_OPTS_HELP
 };
 #define q_usage(ret) usage(ret, Q_FLAGS, q_long_opts, q_opts_help, NULL, lookup_applet_idx("q"))
@@ -71,7 +75,9 @@ int lookup_applet_idx(const char *applet)
 
 int q_main(int argc, char **argv)
 {
-	int i, install;
+	int i;
+	bool install;
+	bool print_overlays;
 	const char *p;
 	APPLET func;
 
@@ -88,12 +94,13 @@ int q_main(int argc, char **argv)
 	if (argc == 1)
 		q_usage(EXIT_FAILURE);
 
-	install = 0;
-
+	install = false;
+	print_overlays = false;
 	while ((i = GETOPT_LONG(Q, q, "+")) != -1) {
 		switch (i) {
 		COMMON_GETOPTS_CASES(q)
-		case 'i': install = 1; break;
+		case 'i': install = true;        break;
+		case 'o': print_overlays = true; break;
 		}
 	}
 
@@ -150,6 +157,30 @@ int q_main(int argc, char **argv)
 		return ret;
 	}
 
+	if (print_overlays) {
+		char *overlay;
+		char *repo_name = NULL;
+		size_t repo_name_len = 0;
+		char buf[_Q_PATH_MAX];
+		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 = 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 != NULL)
+			free(repo_name);
+
+		return 0;
+	}
+
 	if (argc == optind)
 		q_usage(EXIT_FAILURE);
 	if ((func = lookup_applet(argv[optind])) == NULL)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-16 17:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-16 17:13 UTC (permalink / raw
  To: gentoo-commits

commit:     5544fab691201cfc20e478cb5037e29173e57343
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May 16 16:48:46 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May 16 16:48:46 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5544fab6

qmerge: minor style

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 088e3b7..f32d669 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -243,6 +243,8 @@ fetch(const char *destdir, const char *src)
 static void
 qmerge_initialize(void)
 {
+	char *buf;
+
 	if (strlen(BUSYBOX))
 		if (access(BUSYBOX, X_OK) != 0)
 			err(BUSYBOX " must be installed");
@@ -258,7 +260,6 @@ qmerge_initialize(void)
 			errp("could not setup PKGDIR: %s", pkgdir);
 	}
 
-	char *buf;
 	xasprintf(&buf, "%s/portage/", port_tmpdir);
 	mkdir_p(buf, 0755);
 	xchdir(buf);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-16 17:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-16 17:13 UTC (permalink / raw
  To: gentoo-commits

commit:     8a5215917d1d1a40d7a127c9218fa1c2166954de
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Tue May 14 16:58:19 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May 16 17:12:31 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8a521591

qmerge: make qlist_match more sensical about SLOT and REPO matches

make exact match skip : and :: for SLOT resp. REPO when NULL

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlist.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qlist.c b/qlist.c
index 9219108..52ae77d 100644
--- a/qlist.c
+++ b/qlist.c
@@ -258,13 +258,15 @@ qlist_match(
 	if (exact) {
 		int i;
 
-		snprintf(buf, sizeof(buf), "%s/%s-%s:%s%s%s::%s",
+		snprintf(buf, sizeof(buf), "%s/%s-%s%s%s%s%s%s%s",
 			atom->CATEGORY,
 			atom->PN,
 			atom->PVR,
+			atom->SLOT != NULL ? ":" : "",
 			atom->SLOT != NULL ? atom->SLOT : "",
 			atom->SUBSLOT != NULL ? "/" : "",
 			atom->SUBSLOT != NULL ? atom->SUBSLOT : "",
+			atom->REPO != NULL ? "::" : "",
 			atom->REPO != NULL ? atom->REPO : "");
 
 		/* exact match: CAT/PN-PVR[:SLOT][::REPO] */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-16 17:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-16 17:13 UTC (permalink / raw
  To: gentoo-commits

commit:     012fc848e1026049d69d24c5f8f5dc0509004b6a
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Tue May 14 16:58:16 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May 16 17:02:15 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=012fc848

qmerge: improve messages somewhat

print SLOT in print_Pkg
print PF in status messages

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index f32d669..9ff7f28 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1378,7 +1378,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 				goto next_pkg;
 		}
 
-		qprintf("%s+++%s %s/%s %s %s/%s\n",
+		printf("%s+++%s %s/%s %s %s/%s\n",
 				GREEN, NORM, atom->CATEGORY, pkg->PF,
 				booga[ret], cat_ctx->name, pkg_ctx->name);
 
@@ -1421,7 +1421,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	rmdir("../qmerge");
 
 	printf("%s>>>%s %s%s%s/%s%s%s\n",
-			YELLOW, NORM, WHITE, atom->CATEGORY, NORM, CYAN, atom->PN, NORM);
+			YELLOW, NORM, WHITE, atom->CATEGORY, NORM, CYAN, pkg->PF, NORM);
 
 	tree_close(vdb);
 }
@@ -1738,7 +1738,7 @@ print_Pkg(int full, const depend_atom *atom, const struct pkg_t *pkg)
 	char *p = NULL;
 	char buf[512];
 
-	printf("%s%s/%s%s%s%s%s%s\n", BOLD, atom->CATEGORY, BLUE, pkg->PF, NORM,
+	printf("%s%s/%s%s:%s%s%s%s%s\n", BOLD, atom->CATEGORY, BLUE, pkg->PF, pkg->SLOT, NORM,
 		!quiet ? " [" : "",
 		!quiet ? make_human_readable_str(pkg->SIZE, 1, KILOBYTE) : "",
 		!quiet ? " KiB]" : "");


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-16 17:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-16 17:13 UTC (permalink / raw
  To: gentoo-commits

commit:     4dc16c6cfcf2c3a4d2a439ee93999a4cd1864af2
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Tue May 14 16:58:18 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May 16 17:10:37 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4dc16c6c

qmerge: ensure we respect SLOT while finding candidate package to unmerge

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 9ff7f28..a558701 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1358,12 +1358,12 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		pkg_ctx = tree_next_pkg(cat_ctx);
 		if (!pkg_ctx)
 			break;
-
-		old_atom = atom_explode(pkg_ctx->name);
-		/* This cast sucks, but we know for now the field isn't modified */
-		old_atom->CATEGORY = (char *)cat_ctx->name;
+		old_atom = tree_get_atom(pkg_ctx, 1);  /* retrieve SLOT */
+		if (!old_atom)
+			goto next_pkg;
+		old_atom->SUBSLOT = NULL;  /* just match SLOT */
+		old_atom->REPO = NULL;     /* REPO never matters, TODO atom_compare */
 		ret = atom_compare(atom, old_atom);
-		atom_implode(old_atom);
 		switch (ret) {
 			case NEWER:
 			case OLDER:


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-16 13:18 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-16 13:18 UTC (permalink / raw
  To: gentoo-commits

commit:     a35afe72151294ff48f234ad551297402215b173
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May 16 13:17:25 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May 16 13:17:25 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a35afe72

qlop: don't default to lastmerge when atoms are given

When an atom is given, one likely wants to see full history for that, so
show it.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/qlop.c b/qlop.c
index 11bbbc3..ab5dc10 100644
--- a/qlop.c
+++ b/qlop.c
@@ -1000,11 +1000,12 @@ int qlop_main(int argc, char **argv)
 	{
 		m.do_merge = 1;
 		m.do_unmerge = 1;
-		if (array_cnt(atoms) == 0)
+		if (array_cnt(atoms) == 0) {
 			m.do_sync = 1;
+			if (start_time == 0)
+				m.show_lastmerge = 1;
+		}
 		m.do_time = 1;
-		if (start_time == 0)
-			m.show_lastmerge = 1;
 	}
 
 	/* handle deps */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-15  9:42 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-15  9:42 UTC (permalink / raw
  To: gentoo-commits

commit:     114e15337d3297577887297734ac83fcdbde74f1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed May 15 09:39:19 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed May 15 09:39:19 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=114e1533

qmerge: only fetch Packages when -f is specified

-F used to prevent fetching Packages
-f used to force fetching Packages
   default was to fetch Packages if not found

with this commit

-F prevents fetching Packages
-f forces fetching Packages
   default does no fetching

(which still misnames the options, but honestly one or both should go
to fix this odd situation)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md  |  2 ++
 qmerge.c | 10 ++++------
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/TODO.md b/TODO.md
index 88d232f..99078d5 100644
--- a/TODO.md
+++ b/TODO.md
@@ -56,6 +56,8 @@
 - merge duplicate atoms on the CLI (`qmerge -Uq nano nano nano`)
 - unmerging should clean out @world set
 - test should work on local vdb (so TRAVIS can test it too)
+- fixup lame misnaming of force\_download (--fetch/--force) actually
+  not-forcing things
 
 # qdepends
 

diff --git a/qmerge.c b/qmerge.c
index a144805..088e3b7 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -263,13 +263,11 @@ qmerge_initialize(void)
 	mkdir_p(buf, 0755);
 	xchdir(buf);
 
-	if (force_download != 2) {
-		if (force_download)
-			unlink(Packages);
-
-		if (access(Packages, R_OK) != 0)
-			fetch(buf, Packages);
+	if (force_download == 1 /* -f: fetch */) {
+		unlink(Packages);
+		fetch(buf, Packages);
 	}
+
 	free(buf);
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-13 13:39 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-13 13:39 UTC (permalink / raw
  To: gentoo-commits

commit:     089084d36a4fe398cc26948ba25cd50ca1ab1fed
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May 13 13:19:27 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May 13 13:19:27 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=089084d3

qsync: drop

qsync is a shell script which isn't distributed and also is out of date
simply drop it

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md |  4 ----
 qsync   | 48 ------------------------------------------------
 2 files changed, 52 deletions(-)

diff --git a/TODO.md b/TODO.md
index 58ea4c5..f410f54 100644
--- a/TODO.md
+++ b/TODO.md
@@ -71,10 +71,6 @@
 	- newer binpkgs available
 	- newer installed version available
 
-# qsync
-
-- rewrite to use new repos.conf standard
-
 # qgrep
 
 - make it use standard xarray instead of its own buf\_list

diff --git a/qsync b/qsync
deleted file mode 100755
index 838d997..0000000
--- a/qsync
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/bash
-
-get_portage_var() {
-	local var=$1 val
-	[[ -n ${!var} ]] && return 0
-	val=$( (
-		source /etc/make.globals
-		source /etc/make.conf
-		source /etc/portage/make.conf
-		echo ${!var}
-	) 2>/dev/null )
-	[[ -n ${val} ]] && export ${var}=${val} && return
-	export ${var}=$(portageq envvar ${var})
-	[[ -z ${!var} ]] && export ${var}=$2
-}
-get_portage_var PORTDIR /usr/portage
-get_portage_var RSYNC_TIMEOUT 300
-get_portage_var RSYNC_EXCLUDEFROM
-get_portage_var SYNC
-[[ -z ${SYNC} ]] && echo could not get SYNC var && exit 1
-
-add() { RSYNC_OPTS="${RSYNC_OPTS} $@" ; }
-RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress 
---force --whole-file --delete --delete-after --stats --timeout=${RSYNC_TIMEOUT}
---exclude=/distfiles --exclude=/local --exclude=/packages --progress"
-[[ -n ${RSYNC_EXCLUDEFROM} ]] && add --exclude-from="${RSYNC_EXCLUDEFROM}"
-
-METADATA_ONLY=0
-while [[ -n $1 ]] ; do
-	x=$1
-	shift
-	case ${x} in
-	-v|--verbose) add --verbose ;;
-	-q|--quiet)   add --quiet ;;
-	--metadata)   METADATA_ONLY=1 ;;
-	--)           break ;;
-	*) echo unknown opt "${x}" ; exit 1 ;;
-	esac
-done
-
-set -x
-if [[ ${METADATA_ONLY} -eq 1 ]] ; then
-	#echo /usr/bin/rsync ${RSYNC_OPTS} "$@" ${SYNC}/profiles ${PORTDIR}
-	/usr/bin/rsync ${RSYNC_OPTS} "$@" ${SYNC}/metadata/ ${PORTDIR}/metadata/
-else
-	/usr/bin/rsync ${RSYNC_OPTS} "$@" ${SYNC} ${PORTDIR} || exit 1
-	/usr/bin/rsync --progress -a ${PORTDIR}/metadata/cache/ /var/cache/edb/dep${PORTDIR}/
-fi


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-12  9:58 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-12  9:58 UTC (permalink / raw
  To: gentoo-commits

commit:     27909fa5a6d0a8d8fd59ba3c917425fca34e2ee8
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May 12 09:23:25 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May 12 09:23:25 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=27909fa5

qsearch: use tree_get_atom

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsearch.c | 25 ++++++++++++-------------
 1 file changed, 12 insertions(+), 13 deletions(-)

diff --git a/qsearch.c b/qsearch.c
index f52a5ff..1b953ac 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -63,22 +63,17 @@ qsearch_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 	struct qsearch_state *state = (struct qsearch_state *)priv;
 	depend_atom *atom;
-	char buf[_Q_PATH_MAX];
 	tree_pkg_meta *meta;
 	char *desc;
-	char *repo;
 	bool match;
 
-	snprintf(buf, sizeof(buf), "%s/%s", pkg_ctx->cat_ctx->name, pkg_ctx->name);
-	atom = atom_explode(buf);
+	atom = tree_get_atom(pkg_ctx, 0);
 	if (atom == NULL)
 		return 0;
 
 	/* skip duplicate packages (we never report version) */
-	if (last_atom != NULL && strcmp(last_atom->PN, atom->PN) == 0) {
-		atom_implode(atom);
+	if (last_atom != NULL && strcmp(last_atom->PN, atom->PN) == 0)
 		return 0;
-	}
 
 	match = false;
 	if (state->search_name &&
@@ -103,13 +98,16 @@ qsearch_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 			regexec(&state->search_expr, desc, 0, NULL, 0) == 0)
 		match = true;
 
-	repo = NULL;
 	if (match) {
-		if (state->show_repo)
-			repo = pkg_ctx->repo;
-		printf("%s%s/%s%s%s%s%s%s%s%s\n", BOLD, atom->CATEGORY,
-				BLUE, atom->PN,
-				GREEN, (repo ? "::" : ""), (repo ? repo : ""), NORM,
+		const char *qfmt;
+		if (state->show_repo) {
+			atom = tree_get_atom(pkg_ctx, 1);
+			qfmt = "%[CATEGORY]%[PN]%[REPO]";
+		} else {
+			qfmt = "%[CATEGORY]%[PN]";
+		}
+		printf("%s%s%s\n",
+				atom_format(qfmt, atom, 0),
 				(state->show_name ? "" : " "),
 				(state->show_name ? "" : desc ? desc : ""));
 	}
@@ -120,6 +118,7 @@ qsearch_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	if (last_atom != NULL)
 		atom_implode(last_atom);
 	last_atom = atom;
+	pkg_ctx->atom = NULL;  /* we stole the atom, make sure it won't get freed */
 
 	return EXIT_SUCCESS;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-12  9:58 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-12  9:58 UTC (permalink / raw
  To: gentoo-commits

commit:     0dd41363d51b4d49fd5db414a4680d30ec78edd2
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May 12 09:58:24 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May 12 09:58:24 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0dd41363

quse: use tree_get_atom and atom_format

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 quse.c | 32 ++++++++++++--------------------
 1 file changed, 12 insertions(+), 20 deletions(-)

diff --git a/quse.c b/quse.c
index 6def799..c7fbe81 100644
--- a/quse.c
+++ b/quse.c
@@ -420,16 +420,12 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	int portdirfd = -1;  /* pacify compiler */
 
 	if (state->match || verbose) {
-		snprintf(buf, sizeof(buf), "%s/%s",
-				pkg_ctx->cat_ctx->name, pkg_ctx->name);
-		atom = atom_explode(buf);
+		atom = tree_get_atom(pkg_ctx, 0);
 		if (atom == NULL)
 			return 0;
 
 		if (state->match) {
 			match = atom_compare(atom, state->match) == EQUAL;
-			if (!verbose || !match)
-				atom_implode(atom);
 
 			if (!match)
 				return 0;
@@ -517,13 +513,17 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	}
 
 	if (match) {
-		char *repo = state->do_repo ? pkg_ctx->repo : NULL;
+		const char *qfmt;
+
+		atom = tree_get_atom(pkg_ctx, state->do_repo);
+		if (state->do_repo) {
+			qfmt = "%[CATEGORY]%[PF]%[REPO]";
+		} else {
+			qfmt = "%[CATEGORY]%[PF]";
+		}
 
 		if (quiet) {
-			printf("%s%s/%s%s%s%s%s%s\n", BOLD, pkg_ctx->cat_ctx->name,
-					BLUE, pkg_ctx->name,
-					repo ? RED : "", repo ? "::" : "", repo ? repo : "",
-					NORM);
+			printf("%s\n", atom_format(qfmt, atom, 0));
 		} else if (verbose && !state->do_licence) {
 			/* multi-line result, printing USE-flags with their descs */
 			struct quse_state us = {
@@ -537,10 +537,7 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				.overlay = NULL,
 			};
 
-			printf("%s%s/%s%s%s%s%s%s\n", BOLD, pkg_ctx->cat_ctx->name,
-					BLUE, pkg_ctx->name,
-					repo ? RED : "", repo ? "::" : "", repo ? repo : "",
-					NORM);
+			printf("%s\n", atom_format(qfmt, atom, 0));
 
 			q = p = meta->IUSE;
 			buf[0] = '\0';
@@ -584,16 +581,11 @@ quse_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 			free(us.retv);
 			free(us.argv);
 		} else {
-			printf("%s%s/%s%s%s%s%s%s: %s\n", BOLD, pkg_ctx->cat_ctx->name,
-					BLUE, pkg_ctx->name,
-					repo ? RED : "", repo ? "::" : "", repo ? repo : "",
-					NORM, v);
+			printf("%s: %s\n", atom_format(qfmt, atom, 0), v);
 		}
 	}
 
 	tree_close_meta(meta);
-	if (state->match && verbose)
-		atom_implode(atom);
 	if (verbose)
 		close(portdirfd);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-12  9:58 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-12  9:58 UTC (permalink / raw
  To: gentoo-commits

commit:     4f72dc4273f0b0ed5dcf7960ddf5c492b39b0df9
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun May 12 09:38:06 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May 12 09:38:06 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4f72dc42

qsize: use tree_get_atom

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsize.c | 13 +++++--------
 1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/qsize.c b/qsize.c
index 1ae942d..5e9daaa 100644
--- a/qsize.c
+++ b/qsize.c
@@ -100,8 +100,6 @@ static int
 qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 {
 	struct qsize_opt_state *state = priv;
-	const char *catname = pkg_ctx->cat_ctx->name;
-	const char *pkgname = pkg_ctx->name;
 	size_t i;
 	depend_atom *atom;
 	FILE *fp;
@@ -113,14 +111,12 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	if (array_cnt(state->atoms)) {
 		depend_atom *qatom;
 
-		snprintf(state->buf, state->buflen, "%s/%s", catname, pkgname);
-		qatom = atom_explode(state->buf);
+		qatom = tree_get_atom(pkg_ctx, 0);
 		array_for_each(state->atoms, i, atom)
 			if (atom_compare(atom, qatom) == EQUAL) {
 				showit = true;
 				break;
 			}
-		atom_implode(qatom);
 	} else
 		showit = true;
 	if (!showit)
@@ -164,9 +160,10 @@ qsize_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	state->num_all_ignored += num_ignored;
 
 	if (!state->summary_only) {
-		printf("%s%s/%s%s%s: %'zu files, %'zu non-files, ", BOLD,
-		       catname, BLUE, pkgname, NORM,
-		       num_files, num_nonfiles);
+		atom = tree_get_atom(pkg_ctx, 0);
+		printf("%s: %'zu files, %'zu non-files, ",
+				atom_format("%[CATEGORY]%[PF]", atom, 0),
+				num_files, num_nonfiles);
 		if (num_ignored)
 			printf("%'zu names-ignored, ", num_ignored);
 		printf("%s %s\n",


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-11 11:11 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-11 11:11 UTC (permalink / raw
  To: gentoo-commits

commit:     76a1156271195be5d243f015269de35ab0ec9043
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May 11 11:10:32 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May 11 11:10:32 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=76a11562

qlist: simplify qlist_match somewhat reusing autom parsing

qlist_match should go eventually, but this brings it into a little less
redundant mode

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md |   2 +
 qlist.c | 147 ++++++++++++++++++++++++++++++++--------------------------------
 2 files changed, 75 insertions(+), 74 deletions(-)

diff --git a/TODO.md b/TODO.md
index 768c435..7df8983 100644
--- a/TODO.md
+++ b/TODO.md
@@ -29,6 +29,8 @@
 - tree\_get\_atoms should return atoms iso string set, needs a rewrite
   to use foreach\_pkg and get\_atom
 
+- remove odd pverbose argument to atom\_format
+
 # Atoms
 
 - only 32bit values are supported for revision (-r#)

diff --git a/qlist.c b/qlist.c
index 32c87b4..9219108 100644
--- a/qlist.c
+++ b/qlist.c
@@ -184,34 +184,39 @@ qlist_match(
 		depend_atom **name_atom,
 		bool exact)
 {
-	const char *catname = pkg_ctx->cat_ctx->name;
-	const char *pkgname = pkg_ctx->name;
 	char buf[_Q_PATH_MAX];
-	char swap[_Q_PATH_MAX];
-	const char *uslot;
-	size_t uslot_len = 0;
+	char uslot[32];
+	char *usslot = NULL;
 	const char *urepo;
-	size_t urepo_len = 0;
+	size_t pf_len;
 	depend_atom *atom;
 	depend_atom *_atom = NULL;
 
-	uslot = strchr(name, ':');
-	if (uslot != NULL) {
-		if (*++uslot == ':')
-			uslot = NULL;
-		else {
-			uslot_len = strlen(uslot);
+	uslot[0] = '\0';
+	urepo = strchr(name, ':');
+	if (urepo != NULL) {
+		pf_len = urepo - name;
+		if (*++urepo == ':') {
+			uslot[0] = '\0';
+			urepo++;
+		} else {
+			usslot = (char *)urepo;
+			urepo = strstr(urepo, "::");
+			if (urepo != NULL) {
+				snprintf(uslot, sizeof(uslot), "%.*s",
+						(int)(urepo - usslot), usslot);
+				urepo += 2;
+			} else {
+				snprintf(uslot, sizeof(uslot), "%s", usslot);
+			}
+			if ((usslot = strchr(uslot, '/')) != NULL)
+				*usslot++ = '\0';
 		}
+	} else {
+		pf_len = strlen(name);
 	}
 
-	urepo = strstr(name, "::");
-	if (urepo != NULL) {
-		urepo += 2;
-		urepo_len = strlen(urepo);
-
-		if (uslot_len)
-			uslot_len -= (urepo_len + 2);
-	}
+	atom = tree_get_atom(pkg_ctx, uslot[0] != '\0' || urepo != NULL);
 
 	/* maybe they're using a version range */
 	switch (name[0]) {
@@ -219,8 +224,6 @@ qlist_match(
 	case '>':
 	case '<':
 	case '~':
-		atom = tree_get_atom(pkg_ctx, uslot != NULL || urepo != NULL);
-
 		if (!name_atom)
 			name_atom = &_atom;
 		if (!*name_atom) {
@@ -233,26 +236,36 @@ qlist_match(
 		return atom_compare(atom, *name_atom) == EQUAL;
 	}
 
-	if (uslot) {
+	if (uslot[0] != '\0') {
+		if (pkg_ctx->slot == NULL)
+			return false;
+
 		/* Require exact match on SLOTs.  If the user didn't include a
 		 * subslot, then ignore it when checking the package's value. */
-		if (strncmp(pkg_ctx->slot, uslot, uslot_len) != 0 ||
-		    (pkg_ctx->slot[uslot_len] != '\0' &&
-		     pkg_ctx->slot[uslot_len] != '/'))
+		if (strcmp(atom->SLOT, uslot) != 0)
+			return false;
+
+		if (usslot != NULL && strcmp(atom->SUBSLOT, usslot) != 0)
 			return false;
 	}
 
 	if (urepo) {
 		/* require exact match on repositories */
-		if (strcmp(pkg_ctx->repo, urepo) != 0)
+		if (strcmp(atom->REPO, urepo) != 0)
 			return false;
 	}
 
 	if (exact) {
 		int i;
 
-		snprintf(buf, sizeof(buf), "%s/%s:%s::%s",
-			catname, pkgname, pkg_ctx->slot, pkg_ctx->repo);
+		snprintf(buf, sizeof(buf), "%s/%s-%s:%s%s%s::%s",
+			atom->CATEGORY,
+			atom->PN,
+			atom->PVR,
+			atom->SLOT != NULL ? atom->SLOT : "",
+			atom->SUBSLOT != NULL ? "/" : "",
+			atom->SUBSLOT != NULL ? atom->SUBSLOT : "",
+			atom->REPO != NULL ? atom->REPO : "");
 
 		/* exact match: CAT/PN-PVR[:SLOT][::REPO] */
 		if (strcmp(name, buf) == 0)
@@ -262,37 +275,29 @@ qlist_match(
 			return true;
 
 		/* let's try exact matching w/out the PV */
-		atom = tree_get_atom(pkg_ctx, uslot != NULL || urepo != NULL);
-
-		i = snprintf(swap, sizeof(swap), "%s/%s", atom->CATEGORY, atom->PN);
-		if (uslot && i <= (int)sizeof(swap))
-			i += snprintf(swap + i, sizeof(swap) - i, ":%s", atom->SLOT);
-		if (urepo && i <= (int)sizeof(swap))
-			i += snprintf(swap + i, sizeof(swap) - i, "::%s", atom->REPO);
+		i = snprintf(buf, sizeof(buf), "%s/%s", atom->CATEGORY, atom->PN);
+		if (uslot[0] != '\0' && i <= (int)sizeof(buf))
+			i += snprintf(buf + i, sizeof(buf) - i, ":%s", atom->SLOT);
+		if (urepo && i <= (int)sizeof(buf))
+			i += snprintf(buf + i, sizeof(buf) - i, "::%s", atom->REPO);
 
 		/* exact match: CAT/PN[:SLOT][::REPO] */
-		if (strcmp(name, swap) == 0)
+		if (strcmp(name, buf) == 0)
 			return true;
 		/* exact match: PN[:SLOT][::REPO] */
-		if (strcmp(name, strstr(swap, "/") + 1) == 0)
+		if (strcmp(name, strstr(buf, "/") + 1) == 0)
 			return true;
 	} else {
-		size_t ulen = strlen(name);
-		if (urepo)
-			ulen -= (urepo_len + 2);
-		if (uslot)
-			ulen -= (uslot_len + 1);
-		snprintf(buf, sizeof(buf), "%s/%s", catname, pkgname);
 		/* partial leading match: CAT/PN-PVR */
-		if (strncmp(name, buf, ulen) == 0)
+		snprintf(buf, sizeof(buf), "%s/%s-%s",
+				atom->CATEGORY, atom->PN, atom->PVR);
+		if (strncmp(name, buf, pf_len) == 0 ||
+				rematch(name, buf, REG_EXTENDED) == 0)
 			return true;
 		/* partial leading match: PN-PVR */
-		if (strncmp(name, pkgname, ulen) == 0)
-			return true;
-		/* try again but with regexps */
-		if (rematch(name, buf, REG_EXTENDED) == 0)
-			return true;
-		if (rematch(name, pkgname, REG_EXTENDED) == 0)
+		snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PVR);
+		if (strncmp(name, buf, pf_len) == 0 ||
+				rematch(name, buf, REG_EXTENDED) == 0)
 			return true;
 	}
 
@@ -324,8 +329,6 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	struct qlist_opt_state *state = priv;
 	int i;
 	FILE *fp;
-	const char *catname = pkg_ctx->cat_ctx->name;
-	const char *pkgname = pkg_ctx->name;
 	depend_atom *atom;
 
 	/* see if this cat/pkg is requested */
@@ -339,30 +342,26 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	atom = tree_get_atom(pkg_ctx, false);
 	if (state->just_pkgname) {
 		if ((state->all + state->just_pkgname) < 2) {
+			char qfmt[128];
 			atom = tree_get_atom(pkg_ctx,
 					state->show_slots || state->show_repo);
-			if (state->show_slots && !pkg_ctx->slot) {
-				/* chop off the subslot if desired */
-				if (state->show_slots == 1 && pkg_ctx->slot != NULL) {
-					char *s = strchr(pkg_ctx->slot, '/');
-					if (s)
-						*s = '\0';
-				}
+			if (state->columns) {
+				snprintf(qfmt, sizeof(qfmt),
+						"%%{CATEGORY} %%{PN}%s%s%s%s",
+						verbose ? " %{PVR}" : "",
+						state->show_slots >= 1 ? " %{SLOT}" : "",
+						state->show_slots >= 2 ? " %{SUBSLOT}" : "",
+						state->show_repo ? " %{REPO}" : "");
+			} else {
+				snprintf(qfmt, sizeof(qfmt),
+						"%%[CATEGORY]%%[P%c]%s%s%s",
+						verbose ? 'F' : 'N',
+						state->show_slots >= 1 ? "%[SLOT]" : "",
+						state->show_slots >= 2 ? "%[SUBSLOT]" : "",
+						state->show_repo ? "%[REPO]" : "");
 			}
-			/* display it */
-			printf("%s%s/%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
-					BOLD, catname, BLUE,
-					(!state->columns ? (atom ? atom->PN : pkgname) : atom->PN),
-					(state->columns ? " " : ""),
-					(state->columns ? atom->PV : ""),
-					NORM, YELLOW,
-					state->show_slots ? ":" : "",
-					state->show_slots ? pkg_ctx->slot : "",
-					NORM,
-					NORM, GREEN,
-					state->show_repo ? "::" : "",
-					state->show_repo ? pkg_ctx->repo : "",
-					NORM,
+			printf("%s%s\n",
+					atom_format(qfmt, atom, 0),
 					umapstr(state->show_umap, pkg_ctx));
 		}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-11  7:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-11  7:14 UTC (permalink / raw
  To: gentoo-commits

commit:     3142453deeeb276753f82fb958bc8311f810fdd1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 10 18:51:07 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 10 18:51:07 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3142453d

qlop: use atom_format instead of custom fmt_atom

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 63 ++++++++++++++++++++++++---------------------------------------
 1 file changed, 24 insertions(+), 39 deletions(-)

diff --git a/qlop.c b/qlop.c
index c92575f..a60e5ac 100644
--- a/qlop.c
+++ b/qlop.c
@@ -269,25 +269,6 @@ static char *fmt_elapsedtime(struct qlop_mode *flags, time_t e)
 	return _elapsed_buf;
 }
 
-static char _atom_buf[BUFSIZ];
-static char *fmt_atom(struct qlop_mode *flags, depend_atom *atom)
-{
-	(void)flags;
-
-	if (verbose) {
-		size_t len = snprintf(_atom_buf, sizeof(_atom_buf), "%s/%s",
-				atom->CATEGORY, atom->P);
-		if (atom->PR_int > 0)
-			snprintf(_atom_buf + len, sizeof(_atom_buf) - len, "-r%d",
-				atom->PR_int);
-	} else {
-		snprintf(_atom_buf, sizeof(_atom_buf), "%s/%s",
-				atom->CATEGORY, atom->PN);
-	}
-
-	return _atom_buf;
-}
-
 /* The format of the sync log has changed over time.
 
 Old format:
@@ -361,6 +342,10 @@ static int do_emerge_log(
 	};
 	struct pkg_match *pkg;
 	struct pkg_match *pkgw;
+	const char *afmt = "%[CATEGORY]%[PN]";
+
+	if (verbose)
+		afmt = "%[CATEGORY]%[PF]";
 
 	if ((fp = fopen(log, "r")) == NULL) {
 		warnp("Could not open logfile '%s'", log);
@@ -602,14 +587,14 @@ static int do_emerge_log(
 						break;
 					}
 					if (flags->do_time) {
-						printf("%s >>> %s%s%s: %s\n",
+						printf("%s >>> %s: %s\n",
 								fmt_date(flags, pkgw->tbegin, tstart),
-								BLUE, fmt_atom(flags, pkgw->atom), NORM,
+								atom_format(afmt, pkgw->atom, 0),
 								fmt_elapsedtime(flags, elapsed));
 					} else if (!flags->do_average) {
-						printf("%s >>> %s%s%s\n",
+						printf("%s >>> %s\n",
 								fmt_date(flags, pkgw->tbegin, tstart),
-								BLUE, fmt_atom(flags, pkgw->atom), NORM);
+								atom_format(afmt, pkgw->atom, 0));
 					}
 					atom_implode(pkgw->atom);
 					xarraydelete(merge_matches, i);
@@ -701,14 +686,14 @@ static int do_emerge_log(
 						break;
 					}
 					if (flags->do_time) {
-						printf("%s <<< %s%s%s: %s\n",
+						printf("%s <<< %s: %s\n",
 								fmt_date(flags, pkgw->tbegin, tstart),
-								BLUE, fmt_atom(flags, pkgw->atom), NORM,
+								atom_format(afmt, pkgw->atom, 0),
 								fmt_elapsedtime(flags, elapsed));
 					} else if (!flags->do_average) {
-						printf("%s <<< %s%s%s\n",
+						printf("%s <<< %s\n",
 								fmt_date(flags, pkgw->tbegin, tstart),
-								BLUE, fmt_atom(flags, pkgw->atom), NORM);
+								atom_format(afmt, pkgw->atom, 0));
 					}
 					atom_implode(pkgw->atom);
 					xarraydelete(unmerge_matches, i);
@@ -768,17 +753,17 @@ static int do_emerge_log(
 			}
 
 			if (flags->do_time) {
-				printf("%s >>> %s%s%s: %s...%s ETA: %s\n",
+				printf("%s >>> %s: %s...%s ETA: %s\n",
 						fmt_date(flags, pkgw->tbegin, 0),
-						YELLOW, fmt_atom(flags, pkgw->atom), NORM,
+						atom_format(afmt, pkgw->atom, 0),
 						fmt_elapsedtime(flags, elapsed),
 						p == NULL ? "" : p,
 						maxtime == 0 ? "unknown" :
 							fmt_elapsedtime(flags, maxtime - elapsed));
 			} else {
-				printf("%s >>> %s%s%s...%s ETA: %s\n",
+				printf("%s >>> %s...%s ETA: %s\n",
 						fmt_date(flags, pkgw->tbegin, 0),
-						YELLOW, fmt_atom(flags, pkgw->atom), NORM,
+						atom_format(afmt, pkgw->atom, 0),
 						p == NULL ? "" : p,
 						maxtime == 0 ? "unknown" :
 							fmt_elapsedtime(flags, maxtime - elapsed));
@@ -801,16 +786,16 @@ static int do_emerge_log(
 			}
 
 			if (flags->do_time) {
-				printf("%s <<< %s%s%s: %s... ETA: %s\n",
+				printf("%s <<< %s: %s... ETA: %s\n",
 						fmt_date(flags, pkgw->tbegin, 0),
-						YELLOW, fmt_atom(flags, pkgw->atom), NORM,
+						atom_format(afmt, pkgw->atom, 0),
 						fmt_elapsedtime(flags, elapsed),
 						maxtime == 0 ? "unknown" :
 							fmt_elapsedtime(flags, maxtime - elapsed));
 			} else {
-				printf("%s <<< %s%s%s... ETA: %s\n",
+				printf("%s <<< %s... ETA: %s\n",
 						fmt_date(flags, pkgw->tbegin, 0),
-						YELLOW, fmt_atom(flags, pkgw->atom), NORM,
+						atom_format(afmt, pkgw->atom, 0),
 						maxtime == 0 ? "unknown" :
 							fmt_elapsedtime(flags, maxtime - elapsed));
 			}
@@ -821,16 +806,16 @@ static int do_emerge_log(
 		time_t total_time = (time_t)0;
 
 		array_for_each(merge_averages, i, pkg) {
-			printf("%s%s%s: %s average for %s%zd%s merge%s\n",
-					BLUE, fmt_atom(flags, pkg->atom), NORM,
+			printf("%s: %s average for %s%zd%s merge%s\n",
+					atom_format(afmt, pkg->atom, 0),
 					fmt_elapsedtime(flags, pkg->time / pkg->cnt),
 					GREEN, pkg->cnt, NORM, pkg->cnt == 1 ? "" : "s");
 			total_merges += pkg->cnt;
 			total_time += pkg->time;
 		}
 		array_for_each(unmerge_averages, i, pkg) {
-			printf("%s%s%s: %s average for %s%zd%s unmerge%s\n",
-					BLUE, fmt_atom(flags, pkg->atom), NORM,
+			printf("%s: %s average for %s%zd%s unmerge%s\n",
+					atom_format(afmt, pkg->atom, 0),
 					fmt_elapsedtime(flags, pkg->time / pkg->cnt),
 					GREEN, pkg->cnt, NORM, pkg->cnt == 1 ? "" : "s");
 			total_unmerges += pkg->cnt;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-11  7:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-11  7:14 UTC (permalink / raw
  To: gentoo-commits

commit:     569ce6581ce8823e9a827d22a2326351017835c0
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 10 18:21:58 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 10 18:21:58 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=569ce658

qlist: use tree_get_atom where possible

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlist.c | 52 ++++++++++++++--------------------------------------
 1 file changed, 14 insertions(+), 38 deletions(-)

diff --git a/qlist.c b/qlist.c
index abefbcf..32c87b4 100644
--- a/qlist.c
+++ b/qlist.c
@@ -193,24 +193,19 @@ qlist_match(
 	const char *urepo;
 	size_t urepo_len = 0;
 	depend_atom *atom;
+	depend_atom *_atom = NULL;
 
 	uslot = strchr(name, ':');
-	if (uslot) {
+	if (uslot != NULL) {
 		if (*++uslot == ':')
 			uslot = NULL;
 		else {
-			if (!pkg_ctx->slot)
-				tree_pkg_vdb_eat(pkg_ctx, "SLOT", &pkg_ctx->slot,
-						&pkg_ctx->slot_len);
 			uslot_len = strlen(uslot);
 		}
 	}
 
 	urepo = strstr(name, "::");
-	if (urepo) {
-		if (!pkg_ctx->repo)
-			tree_pkg_vdb_eat(pkg_ctx, "repository", &pkg_ctx->repo,
-					&pkg_ctx->repo_len);
+	if (urepo != NULL) {
 		urepo += 2;
 		urepo_len = strlen(urepo);
 
@@ -224,28 +219,18 @@ qlist_match(
 	case '>':
 	case '<':
 	case '~':
-		snprintf(buf, sizeof(buf), "%s/%s%c%s%s%s", catname, pkgname,
-			pkg_ctx->slot ? ':' : '\0', pkg_ctx->slot ? : "",
-			pkg_ctx->repo ? "::" : "", pkg_ctx->repo ? : "");
-		if ((atom = atom_explode(buf)) == NULL) {
-			warn("invalid atom %s", buf);
-			return false;
-		}
+		atom = tree_get_atom(pkg_ctx, uslot != NULL || urepo != NULL);
 
-		depend_atom *_atom = NULL;
 		if (!name_atom)
 			name_atom = &_atom;
 		if (!*name_atom) {
 			if ((*name_atom = atom_explode(name)) == NULL) {
-				atom_implode(atom);
 				warn("invalid atom %s", name);
 				return false;
 			}
 		}
 
-		bool ret = atom_compare(atom, *name_atom) == EQUAL;
-		atom_implode(atom);
-		return ret;
+		return atom_compare(atom, *name_atom) == EQUAL;
 	}
 
 	if (uslot) {
@@ -277,10 +262,7 @@ qlist_match(
 			return true;
 
 		/* let's try exact matching w/out the PV */
-		if ((atom = atom_explode(buf)) == NULL) {
-			warn("invalid atom %s", buf);
-			return false;
-		}
+		atom = tree_get_atom(pkg_ctx, uslot != NULL || urepo != NULL);
 
 		i = snprintf(swap, sizeof(swap), "%s/%s", atom->CATEGORY, atom->PN);
 		if (uslot && i <= (int)sizeof(swap))
@@ -288,7 +270,6 @@ qlist_match(
 		if (urepo && i <= (int)sizeof(swap))
 			i += snprintf(swap + i, sizeof(swap) - i, "::%s", atom->REPO);
 
-		atom_implode(atom);
 		/* exact match: CAT/PN[:SLOT][::REPO] */
 		if (strcmp(name, swap) == 0)
 			return true;
@@ -345,6 +326,7 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	FILE *fp;
 	const char *catname = pkg_ctx->cat_ctx->name;
 	const char *pkgname = pkg_ctx->name;
+	depend_atom *atom;
 
 	/* see if this cat/pkg is requested */
 	for (i = optind; i < state->argc; ++i)
@@ -354,23 +336,19 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	if ((i == state->argc) && (state->argc != optind))
 		return 0;
 
+	atom = tree_get_atom(pkg_ctx, false);
 	if (state->just_pkgname) {
-		depend_atom *atom;
-		atom = (verbose ? NULL : atom_explode(pkgname));
 		if ((state->all + state->just_pkgname) < 2) {
+			atom = tree_get_atom(pkg_ctx,
+					state->show_slots || state->show_repo);
 			if (state->show_slots && !pkg_ctx->slot) {
-				tree_pkg_vdb_eat(pkg_ctx, "SLOT",
-						&pkg_ctx->slot, &pkg_ctx->slot_len);
 				/* chop off the subslot if desired */
-				if (state->show_slots == 1) {
+				if (state->show_slots == 1 && pkg_ctx->slot != NULL) {
 					char *s = strchr(pkg_ctx->slot, '/');
 					if (s)
 						*s = '\0';
 				}
 			}
-			if (state->show_repo && !pkg_ctx->repo)
-				tree_pkg_vdb_eat(pkg_ctx, "repository",
-						&pkg_ctx->repo, &pkg_ctx->repo_len);
 			/* display it */
 			printf("%s%s/%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s\n",
 					BOLD, catname, BLUE,
@@ -387,16 +365,14 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 					NORM,
 					umapstr(state->show_umap, pkg_ctx));
 		}
-		if (atom)
-			atom_implode(atom);
 
 		if (!state->all)
 			return 1;
 	}
 
 	if (verbose)
-		printf("%s%s/%s%s%s %sCONTENTS%s:\n",
-				BOLD, catname, BLUE, pkgname, NORM, DKBLUE, NORM);
+		printf("%s %sCONTENTS%s:\n",
+				atom_format("%[CATEGORY]%[PF]", atom, 0), DKBLUE, NORM);
 
 	fp = tree_pkg_vdb_fopenat_ro(pkg_ctx, "CONTENTS");
 	if (fp == NULL)
@@ -423,7 +399,7 @@ qlist_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				break;
 			case CONTENTS_OBJ:
 				if (state->show_obj)
-					printf("%s%s%s\n", WHITE, e->name, NORM);
+					printf("%s%s%s\n", DKGREEN, e->name, NORM);
 				break;
 			case CONTENTS_SYM:
 				if (state->show_sym) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-11  7:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-11  7:14 UTC (permalink / raw
  To: gentoo-commits

commit:     e491ec5bc156077df5d86ff14c98b7e48948993e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 10 16:15:54 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 10 16:15:54 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e491ec5b

README: update after maintainer mode addition

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 README.md | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index bfb6341..2ad3226 100644
--- a/README.md
+++ b/README.md
@@ -15,7 +15,8 @@ of information.  The focus is on size and speed, so everything is in C.
 ## Building
 
 Run `configure` followed by `make`.  If you're using git-sources, run
-autoreconf first to get various timestamps correct.
+`configure` with `--disable-maintainer-mode` or run autoreconf to get
+various timestamps correct.
 
 ## Helping out
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-11  7:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-11  7:14 UTC (permalink / raw
  To: gentoo-commits

commit:     c7e04780a3161d6e8785c175680751839f9d768b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 10 16:40:50 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 10 16:40:50 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c7e04780

qgrep: use tree_get_atom

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qgrep.c | 17 ++++-------------
 1 file changed, 4 insertions(+), 13 deletions(-)

diff --git a/qgrep.c b/qgrep.c
index 8e240f3..2db61df 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -391,9 +391,7 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	int ret;
 	int pfd;
 
-	snprintf(buf, sizeof(buf), "%s/%s",
-			pkg_ctx->cat_ctx->name, pkg_ctx->name);
-	patom = atom_explode(buf);
+	patom = tree_get_atom(pkg_ctx, false);
 	if (patom == NULL)
 		return EXIT_FAILURE;
 
@@ -403,10 +401,8 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 			if (atom_compare(patom, *d) == EQUAL)
 				break;
 		}
-		if (*d == NULL) {
-			atom_implode(patom);
+		if (*d == NULL)
 			return EXIT_FAILURE;
-		}
 	}
 
 	/* need to construct path in portdir to ebuild, pass it to grep */
@@ -423,6 +419,7 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 	label = NULL;
 	if (data->show_name) {
+		/* this is a super-optimisation, should get it from the full atom */
 		char *repo = data->show_repo ? cctx->repo : NULL;
 		snprintf(name, sizeof(name), "%s%s/%s%s%s%s%s%s",
 				BOLD, patom->CATEGORY, BLUE, patom->P, GREEN,
@@ -434,8 +431,6 @@ qgrep_cache_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 	ret = qgrep_grepat(pfd, buf, label, data);
 
-	atom_implode(patom);
-
 	return ret;
 }
 
@@ -450,9 +445,7 @@ qgrep_vdb_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	int ret;
 	int pfd;
 
-	snprintf(buf, sizeof(buf), "%s/%s",
-			pkg_ctx->cat_ctx->name, pkg_ctx->name);
-	patom = atom_explode(buf);
+	patom = tree_get_atom(pkg_ctx, false);
 	if (patom == NULL)
 		return EXIT_FAILURE;
 
@@ -487,8 +480,6 @@ qgrep_vdb_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 	ret = qgrep_grepat(pfd, buf, label, data);
 
-	atom_implode(patom);
-
 	return ret;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-10 15:32 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-10 15:32 UTC (permalink / raw
  To: gentoo-commits

commit:     c64290307919bcd65e816277914309b4423be308
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 10 15:22:45 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 10 15:22:45 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c6429030

gitignore: ignore generated files

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 .gitignore | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/.gitignore b/.gitignore
index b65a0fb..47c12c7 100644
--- a/.gitignore
+++ b/.gitignore
@@ -28,6 +28,11 @@ config.log
 config.status
 libtool
 stamp-h1
+INSTALL
+Makefile
+/autotools/gnulib/*.h
+/autotools/gnulib/sys
+/tests/init.sh
 
 /*.old.c
 /q


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-10 15:32 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-10 15:32 UTC (permalink / raw
  To: gentoo-commits

commit:     2977f24478a673ff869bb6d26bf69b90b099deb5
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 10 15:31:00 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 10 15:31:00 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2977f244

qkeyword: optimise away redundant atom_explode calls

With some help from libq/tree now doing the sorting right (and
contructing an atom exactly once for each package) we can avoid
exploding atoms and greatly benefit in performance.  On my setup I've
seen timings half or even more.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md    |  4 ----
 qkeyword.c | 47 +++++------------------------------------------
 2 files changed, 5 insertions(+), 46 deletions(-)

diff --git a/TODO.md b/TODO.md
index ec5f843..768c435 100644
--- a/TODO.md
+++ b/TODO.md
@@ -93,8 +93,4 @@
 - read VDB on -v to print details about current USE-flag status, bug #656550
 
 # qkeyword
-- avoid multiple atom\_explode in path traversal
-  * during qkeyword\_vercmp
-  * during qkeyword\_results\_cb
-  * in libq/cache\_read\_metadata
 - drop -c argument? it can be fully expressed using -p cat/

diff --git a/qkeyword.c b/qkeyword.c
index b9792af..fda9b83 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -191,28 +191,6 @@ read_keywords(char *s, int *keywords)
 	return 0;
 }
 
-/*
- * Compare 2 struct dirent d_name strings based with atom_compare_str().
- * Used with dirscan() to sort ebuild filenames by version, reversed.
- *
- * IN:
- *  2 (const struct dirent **) with d_name filled in
- * OUT:
- *  -1 (NEWER)
- *   1 (OLDER)
- *   0 (SAME)
- */
-static int
-qkeyword_vercmp(const struct dirent **x, const struct dirent **y)
-{
-	switch (atom_compare_str((*x)->d_name, (*y)->d_name)) {
-		case EQUAL:      return  0;
-		case NEWER:      return -1;
-		case OLDER:      return  1;
-		default:         return strcmp((*x)->d_name, (*y)->d_name);
-	}
-}
-
 static int
 qkeyword_imlate(tree_pkg_ctx *pkg_ctx, void *priv)
 {
@@ -496,7 +474,7 @@ qkeyword_stats(tree_pkg_ctx *pkg_ctx, void *priv)
 		numcat++;
 	lastcat = pkg_ctx->cat_ctx->name;
 
-	atom = atom_explode(pkg_ctx->name);
+	atom = tree_get_atom(pkg_ctx, false);
 	if (atom && strcmp(lastpkg, atom->PN) != 0) {
 		for (a = 0; a < archlist_count; a++) {
 			switch (current_package_keywords[a]) {
@@ -515,7 +493,6 @@ qkeyword_stats(tree_pkg_ctx *pkg_ctx, void *priv)
 		memset(current_package_keywords, 0,
 				archlist_count * sizeof(*current_package_keywords));
 	}
-	atom_implode(atom);
 
 	numebld++;
 
@@ -617,25 +594,17 @@ qkeyword_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	struct elist *emailw;
 	int ret;
 
-	snprintf(buf, sizeof(buf), "%s/%s",
-			pkg_ctx->cat_ctx->name, pkg_ctx->name);
-	patom = atom_explode(buf);
+	patom = tree_get_atom(pkg_ctx, false);
 	if (patom == NULL)
 		return EXIT_FAILURE;
 
 	if (data->qatom != NULL &&
 			atom_compare(patom, data->qatom) != EQUAL)
-	{
-		atom_implode(patom);
 		return EXIT_FAILURE;
-	}
 
 	if (data->lastatom != NULL &&
 			atom_compare(data->lastatom, patom) != NOT_EQUAL)
-	{
-		atom_implode(patom);
 		return EXIT_SUCCESS;
-	}
 
 	if (data->qmaint != NULL) {
 		metadata = tree_pkg_metadata(pkg_ctx);
@@ -657,16 +626,13 @@ qkeyword_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 	keywords = data->keywordsbuf;
 	meta = tree_pkg_read(pkg_ctx);
-	if (meta == NULL) {
-		atom_implode(patom);
+	if (meta == NULL)
 		return EXIT_FAILURE;
-	}
 
 	if (read_keywords(meta->KEYWORDS, keywords) < 0) {
 		if (verbose)
 			warn("Failed to read keywords for %s%s/%s%s%s",
 				BOLD, pkg_ctx->cat_ctx->name, BLUE, pkg_ctx->name, NORM);
-		atom_implode(patom);
 		return EXIT_FAILURE;
 	}
 
@@ -678,9 +644,7 @@ qkeyword_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 		patom->PVR = patom->PN;
 		patom->PR_int = 0;
 		data->lastatom = patom;
-		patom = NULL;
-	} else {
-		atom_implode(patom);
+		pkg_ctx->atom = NULL;  /* take tree's atom */
 	}
 
 	return EXIT_SUCCESS;
@@ -759,8 +723,7 @@ qkeyword_traverse(tree_pkg_cb func, void *priv)
 	array_for_each(overlays, n, overlay) {
 		tree_ctx *t = tree_open(portroot, overlay);
 		if (t != NULL) {
-			ret |= tree_foreach_pkg(t, qkeyword_results_cb, priv,
-					NULL, true, NULL, qkeyword_vercmp);
+			ret |= tree_foreach_pkg_sorted(t, qkeyword_results_cb, priv);
 			tree_close(t);
 		}
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-10  7:30 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-10  7:30 UTC (permalink / raw
  To: gentoo-commits

commit:     b61ddadded74e0e7d088999a627dd35ed2ebb92a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 10 07:20:12 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 10 07:20:12 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b61ddadd

qfile: simply by using tree_get_atom and atom_format

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qfile.c | 75 +++++++++++++++++++++++++----------------------------------------
 1 file changed, 29 insertions(+), 46 deletions(-)

diff --git a/qfile.c b/qfile.c
index c451ae4..116c7c4 100644
--- a/qfile.c
+++ b/qfile.c
@@ -78,11 +78,9 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 {
 	struct qfile_opt_state *state = priv;
 	const char *catname = pkg_ctx->cat_ctx->name;
-	const char *pkgname = pkg_ctx->name;
 	qfile_args_t *args = &state->args;
 	FILE *fp;
 	const char *base;
-	char pkg[_Q_PATH_MAX];
 	depend_atom *atom = NULL;
 	int i;
 	bool path_ok;
@@ -93,8 +91,6 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	short *non_orphans = args->non_orphans;
 	int found = 0;
 
-	snprintf(pkg, sizeof(pkg), "%s/%s", catname, pkgname);
-
 	/* If exclude_pkg is not NULL, check it.  We are looking for files
 	 * collisions, and must exclude one package.
 	 */
@@ -103,21 +99,15 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 		if (state->exclude_atom->CATEGORY &&
 		    strcmp(state->exclude_atom->CATEGORY, catname))
 			goto dont_skip_pkg;
-		atom = atom_explode(pkg);
-		if (state->exclude_atom->PVR) {
-			/* see if PVR is exact match */
-			if (strcmp(state->exclude_atom->PVR, atom->PVR))
-				goto dont_skip_pkg;
-		} else {
-			/* see if PN is exact match */
-			if (strcmp(state->exclude_atom->PN, atom->PN))
-				goto dont_skip_pkg;
-		}
+		atom = tree_get_atom(pkg_ctx, false);
+		if (atom_compare(state->exclude_atom, atom) != EQUAL)
+			goto dont_skip_pkg;
+		/* "(CAT/)?(PN|PF)" matches, and no SLOT specified */
 		if (state->exclude_slot == NULL)
-			goto qlist_done; /* "(CAT/)?(PN|PF)" matches, and no SLOT specified */
-		tree_pkg_vdb_eat(pkg_ctx, "SLOT", &state->buf, &state->buflen);
-		rmspace(state->buf);
-		if (strcmp(state->exclude_slot, state->buf) == 0)
+			goto qlist_done;
+		/* retrieve atom, this time with SLOT */
+		atom = tree_get_atom(pkg_ctx, true);
+		if (strcmp(state->exclude_slot, atom->SLOT) == 0)
 			goto qlist_done; /* "(CAT/)?(PN|PF):SLOT" matches */
 	}
  dont_skip_pkg: /* End of the package exclusion tests. */
@@ -134,11 +124,7 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 		if (!e)
 			continue;
 
-		/* basename(3) possibly modifies e->name (if it has trailing
-		 * slashes) but this is not likely since it comes from VDB which
-		 * has normalised everything, so effectively e->name isn't
-		 * touched, however, it /can/ return a pointer to a private
-		 * allocation */
+		/* note: this is our own basename which doesn't modify its input */
 		base = basename(e->name);
 		if (base < e->name || base > (e->name + strlen(e->name)))
 			continue;
@@ -163,8 +149,8 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 			path_ok = false;
 
 			if (dir_names[i] &&
-			    strncmp(e->name, dir_names[i], dirname_len) == 0 &&
-				dir_names[i][dirname_len] == '\0')
+					strncmp(e->name, dir_names[i], dirname_len) == 0 &&
+					dir_names[i][dirname_len] == '\0')
 			{
 				/* dir_name == dirname(CONTENTS) */
 				path_ok = true;
@@ -185,8 +171,10 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				_rpath = rpath + real_root_len;
 				if (realpath(fullpath, rpath) == NULL) {
 					if (verbose) {
+						atom = tree_get_atom(pkg_ctx, false);
 						warnp("Could not read real path of \"%s\" (from %s)",
-								fullpath, pkg);
+								fullpath,
+								atom_format("%[CATEGORY]%[PF]", atom, false));
 						warn("We'll never know whether \"%s\" was a result "
 								"for your query...", e->name);
 					}
@@ -215,26 +203,24 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				continue;
 
 			if (non_orphans == NULL) {
-				char slot[126];
+				const char *fmt;
+
+				atom = tree_get_atom(pkg_ctx, true);
 
-				if (!atom) {
-					if ((atom = atom_explode(pkg)) == NULL) {
-						warn("invalid atom %s", pkg);
-						continue;
+				if (state->slotted) {
+					if (verbose) {
+						fmt = "%[CATEGORY]%[PF]%[SLOT]";
+					} else {
+						fmt = "%[CATEGORY]%[PN]%[SLOT]";
+					}
+				} else {
+					if (verbose) {
+						fmt = "%[CATEGORY]%[PF]";
+					} else {
+						fmt = "%[CATEGORY]%[PN]";
 					}
 				}
-				if (state->slotted) {
-					/* XXX: This assumes the buf is big enough. */
-					char *slot_hack = slot + 1;
-					size_t slot_len = sizeof(slot) - 1;
-					tree_pkg_vdb_eat(pkg_ctx, "SLOT", &slot_hack, &slot_len);
-					rmspace(slot_hack);
-					slot[0] = ':';
-				} else
-					slot[0] = '\0';
-				printf("%s%s/%s%s%s%s", BOLD, atom->CATEGORY, BLUE,
-					(verbose ? pkg_ctx->name : atom->PN),
-					slot, NORM);
+				printf("%s", atom_format(fmt, atom, false));
 				if (quiet)
 					puts("");
 				else
@@ -248,9 +234,6 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 	fclose(fp);
 
  qlist_done:
-	if (atom)
-		atom_implode(atom);
-
 	return found;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-10  7:30 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-10  7:30 UTC (permalink / raw
  To: gentoo-commits

commit:     a132116bfa8476cf7eaa6e024fd402070fa95563
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 10 07:24:48 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 10 07:24:48 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a132116b

qfile: adapt output slightly to match other q-tools

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qfile.c b/qfile.c
index 116c7c4..5a9f7c5 100644
--- a/qfile.c
+++ b/qfile.c
@@ -224,7 +224,7 @@ static int qfile_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 				if (quiet)
 					puts("");
 				else
-					printf(" (%s%s)\n", state->root ? : "", e->name);
+					printf(": %s%s\n", state->root ? : "", e->name);
 			} else {
 				non_orphans[i] = 1;
 			}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-10  7:30 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-10  7:30 UTC (permalink / raw
  To: gentoo-commits

commit:     47ea04c729af2408a3a8bd81a41bf0a260cb1f3e
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Thu May  9 17:25:58 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 10 07:26:06 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=47ea04c7

qmerge: implement keepdir and dodir, bug #682316

Bug: https://bugs.gentoo.org/682316
Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/qmerge.c b/qmerge.c
index e6bbdb5..a144805 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -739,6 +739,8 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 		"nonfatal() { \"$@\"; }\n"
 		"ebegin() { printf ' * %%b ...' \"$*\"; }\n"
 		"eend() { local r=${1:-$?}; [ $# -gt 0 ] && shift; [ $r -eq 0 ] && echo ' [ ok ]' || echo \" $* \"'[ !! ]'; return $r; }\n"
+		"dodir() { mkdir -p \"$@\"; }\n"
+		"keepdir() { dodir \"$@\" && touch \"$@\"/.keep_${CATEGORY}_${PN}-${SLOT%%/*}; }\n"
 		/* TODO: This should be fatal upon error */
 		"emake() { ${MAKE:-make} ${MAKEOPTS} \"$@\"; }\n"
 		/* Unpack the env if need be */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-07  6:19 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-07  6:19 UTC (permalink / raw
  To: gentoo-commits

commit:     2615b1a350ac54af4bb0f31e8eb13fed9979b564
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May  6 18:04:00 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May  6 18:04:00 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2615b1a3

qcheck: use atom_format to unify atom representation

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcheck.c | 43 ++++++++++++++++---------------------------
 1 file changed, 16 insertions(+), 27 deletions(-)

diff --git a/qcheck.c b/qcheck.c
index 377a187..68cdb30 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -69,14 +69,13 @@ qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 {
 	int fd_contents;
 	FILE *fp_contents, *fp_contents_update;
-	const char *catname = pkg_ctx->cat_ctx->name;
-	const char *pkgname = pkg_ctx->name;
 	size_t num_files, num_files_ok, num_files_unknown, num_files_ignored;
 	char *buffer, *line;
 	size_t linelen;
 	struct stat st, cst;
 	int cp_argc, cpm_argc;
 	char **cp_argv, **cpm_argv;
+	depend_atom *atom;
 
 	fp_contents_update = NULL;
 
@@ -94,15 +93,16 @@ qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 	}
 
 	/* Open contents_update, if needed */
+	atom = vdb_get_atom(pkg_ctx, false);
 	num_files = num_files_ok = num_files_unknown = num_files_ignored = 0;
-	qcprintf("%sing %s%s/%s%s ...\n",
+	qcprintf("%sing %s ...\n",
 		(state->qc_update ? "Updat" : "Check"),
-		GREEN, catname, pkgname, NORM);
+		atom_format("%[CATEGORY]%[PF]", atom, 0));
 	if (state->qc_update) {
 		fp_contents_update = vdb_pkg_fopenat_rw(pkg_ctx, "CONTENTS~");
 		if (fp_contents_update == NULL) {
 			fclose(fp_contents);
-			warnp("unable to fopen(%s/%s, w)", pkgname, "CONTENTS~");
+			warnp("unable to fopen(%s/%s, w)", atom->P, "CONTENTS~");
 			return EXIT_FAILURE;
 		}
 	}
@@ -165,13 +165,14 @@ qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 					break;
 			if (i == cpm_argc) {
 				/* Not explicitly masked, so it's protected */
-				for (i = 1; i < cp_argc; ++i)
+				for (i = 1; i < cp_argc; ++i) {
 					if (strncmp(cp_argv[i], entry->name,
 								strlen(cp_argv[i])) == 0)
 					{
 						num_files_ok++;
 						continue;
 					}
+				}
 			}
 		}
 
@@ -329,18 +330,9 @@ qcheck_process_contents(vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 	}
 	if (state->bad_only && num_files_ok != num_files) {
 		if (verbose)
-			printf("%s/%s\n", catname, pkgname);
+			printf("%s\n", atom_format("%[CATEGORY]%[PF]", atom, 0));
 		else {
-			depend_atom *atom = NULL;
-			char *buf;
-			xasprintf(&buf, "%s/%s", catname, pkgname);
-			if ((atom = atom_explode(buf)) != NULL) {
-				printf("%s/%s\n", catname, atom->PN);
-				atom_implode(atom);
-			} else  {
-				printf("%s/%s\n", catname, pkgname);
-			}
-			free(buf);
+			printf("%s\n", atom_format("%[CATEGORY]%[PN]", atom, 0));
 		}
 	}
 	qcprintf("  %2$s*%1$s %3$s%4$zu%1$s out of %3$s%5$zu%1$s file%6$s are good",
@@ -366,27 +358,24 @@ static int
 qcheck_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
 {
 	struct qcheck_opt_state *state = priv;
-	const char *catname = pkg_ctx->cat_ctx->name;
-	const char *pkgname = pkg_ctx->name;
 	bool showit = false;
 
 	/* see if this cat/pkg is requested */
 	if (array_cnt(state->atoms)) {
-		char *buf;
 		size_t i;
-		depend_atom *qatom, *atom;
+		depend_atom *qatom;
+		depend_atom *atom;
 
-		xasprintf(&buf, "%s/%s", catname, pkgname);
-		qatom = atom_explode(buf);
-		array_for_each(state->atoms, i, atom)
+		qatom = vdb_get_atom(pkg_ctx, false);
+		array_for_each(state->atoms, i, atom) {
 			if (atom_compare(atom, qatom) == EQUAL) {
 				showit = true;
 				break;
 			}
-		atom_implode(qatom);
-		free(buf);
-	} else
+		}
+	} else {
 		showit = true;
+	}
 
 	return showit ? qcheck_process_contents(pkg_ctx, priv) : 0;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-07  6:19 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-07  6:19 UTC (permalink / raw
  To: gentoo-commits

commit:     d136dcae0c0b4a177e42ad42e1396e43a82c0a12
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May  6 18:03:27 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May  6 18:03:27 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d136dcae

qdepends: make atom calls cheaper for the majority of calls

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qdepends.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index e49e533..64bf991 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -116,7 +116,7 @@ qdepends_results_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
 	 * *DEPEND alters the search somewhat and affects results printing.
 	 */
 
-	datom = vdb_get_atom(pkg_ctx);
+	datom = vdb_get_atom(pkg_ctx, false);
 	if (datom == NULL)
 		return ret;
 
@@ -135,6 +135,7 @@ qdepends_results_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
 
 		ret = 1;
 
+		datom = vdb_get_atom(pkg_ctx, true);
 		printf("%s:", atom_format(state->format, datom, 0));
 	}
 
@@ -172,8 +173,10 @@ qdepends_results_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
 				if (atom == NULL) {
 					ret = 1;
 
-					if (!firstmatch)
+					if (!firstmatch) {
+						datom = vdb_get_atom(pkg_ctx, true);
 						printf("%s:", atom_format(state->format, datom, 0));
+					}
 					firstmatch = true;
 
 					printf("\n%s=\"\n", *dfile);
@@ -199,8 +202,10 @@ qdepends_results_cb(vdb_pkg_ctx *pkg_ctx, void *priv)
 					if (fatom == NULL) {
 						ret = 1;
 
-						if (!firstmatch)
+						if (!firstmatch) {
+							datom = vdb_get_atom(pkg_ctx, true);
 							printf("%s:", atom_format(state->format, datom, 0));
+						}
 						firstmatch = true;
 
 						snprintf(buf, sizeof(buf), "%s%s%s",


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-06 16:04 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-06 16:04 UTC (permalink / raw
  To: gentoo-commits

commit:     96a398aa2a3f63af154b3af12da5d5103b37b613
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May  6 16:03:19 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May  6 16:03:19 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=96a398aa

qdepends: use q_vdb_get_atom instead of constructing manually

Using vdb's atom, atom_format() will be able to print SLOT and REPO.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qdepends.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index 9cfe095..7bb8818 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -95,8 +95,6 @@ static int
 qdepends_results_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 {
 	struct qdepends_opt_state *state = priv;
-	const char *catname = pkg_ctx->cat_ctx->name;
-	const char *pkgname = pkg_ctx->name;
 	depend_atom *atom;
 	depend_atom *datom;
 	depend_atom *fatom;
@@ -118,8 +116,7 @@ qdepends_results_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	 * *DEPEND alters the search somewhat and affects results printing.
 	 */
 
-	snprintf(buf, sizeof(buf), "%s/%s", catname, pkgname);
-	datom = atom_explode(buf);
+	datom = q_vdb_get_atom(pkg_ctx);
 	if (datom == NULL)
 		return ret;
 
@@ -133,10 +130,8 @@ qdepends_results_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 		}
 
 		/* nothing matched */
-		if (atom != NULL) {
-			atom_implode(datom);
+		if (atom != NULL)
 			return ret;
-		}
 
 		ret = 1;
 
@@ -237,8 +232,6 @@ qdepends_results_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 		}
 	}
 
-	atom_implode(datom);
-
 	return ret;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-06  6:41 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-06  6:41 UTC (permalink / raw
  To: gentoo-commits

commit:     baed7caa2b6e56545b5f3c29da7bc13c7658d0a8
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon May  6 06:40:33 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon May  6 06:40:33 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=baed7caa

qkeyword: correctly handle missing metadata.xml or email fields

- if metadata.xml is absent, don't crash
- if metadata.xml didn't contain an email, don't match as result

Bug: https://bugs.gentoo.org/685132
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qkeyword.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/qkeyword.c b/qkeyword.c
index e8fb5d6..ef61fba 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -639,10 +639,17 @@ qkeyword_results_cb(cache_pkg_ctx *pkg_ctx, void *priv)
 
 	if (data->qmaint != NULL) {
 		metadata = cache_read_metadata(pkg_ctx);
+		if (metadata == NULL)
+			return EXIT_SUCCESS;
+
 		for (emailw = metadata->email; emailw != NULL; emailw = emailw->next) {
 			if (strcmp(emailw->addr, data->qmaint) != 0)
 				break;
 		}
+		if (metadata->email == NULL)
+			/* arbitrary pointer to trigger exit below */
+			emailw = (struct elist *)buf;
+
 		cache_close_metadata(metadata);
 		if (emailw != NULL)
 			return EXIT_SUCCESS;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-04 17:23 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-04 17:23 UTC (permalink / raw
  To: gentoo-commits

commit:     a6ca96154d2429bdc840454bdfa9fcb42c0e49a8
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May  4 17:23:12 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May  4 17:23:12 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a6ca9615

qkeyword: use combined set of arches found on all overlays

Bug: https://bugs.gentoo.org/684252
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qkeyword.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/qkeyword.c b/qkeyword.c
index 8c781db..ffcd6ae 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -677,9 +677,6 @@ qkeyword_load_arches(const char *overlay)
 	if (!fp)
 		goto done;
 
-	clear_set(archs);
-	archlist_count = 0;
-	arch_longest_len = 0;
 	buf = NULL;
 	while ((linelen = getline(&buf, &buflen, fp)) >= 0) {
 		rmspace_len(buf, (size_t)linelen);
@@ -798,6 +795,9 @@ int qkeyword_main(int argc, char **argv)
 	}
 
 	archs = create_set();
+	archlist_count = 0;
+	arch_longest_len = 0;
+
 	data.lastatom = NULL;
 	data.keywordsbuf = NULL;
 	data.keywordsbuflen = 0;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-04 11:53 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-04 11:53 UTC (permalink / raw
  To: gentoo-commits

commit:     ae271f1257b84b43cf253cdf4e2c2cb4672936c9
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat May  4 11:50:14 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat May  4 11:50:14 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ae271f12

qkeyword: don't crash while processing an empty set

using -p/-c one can restrict to a possibly empty set, just bail on that,
don't crash

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qkeyword.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/qkeyword.c b/qkeyword.c
index 17430fc..8c781db 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -411,6 +411,12 @@ qkeyword_stats(cache_pkg_ctx *pkg_ctx, void *priv)
 		char **arch;
 		const char border[] = "------------------------------------------------------------------";
 
+		/* no packages, nothing to report */
+		if (current_package_keywords == NULL) {
+			printf("no packages found\n");
+			return EXIT_SUCCESS;
+		}
+
 		/* include stats for last package */
 		for (a = 0; a < archlist_count; a++) {
 			switch (current_package_keywords[a]) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-03 11:45 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-03 11:45 UTC (permalink / raw
  To: gentoo-commits

commit:     90a4313ac928eefd28213fb68737faf48c7dcc57
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May  3 08:58:56 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May  3 08:58:56 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=90a4313a

qlop: simplify fmt_atom somewhat

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qlop.c b/qlop.c
index a87cc5c..c92575f 100644
--- a/qlop.c
+++ b/qlop.c
@@ -275,8 +275,8 @@ static char *fmt_atom(struct qlop_mode *flags, depend_atom *atom)
 	(void)flags;
 
 	if (verbose) {
-		size_t len = snprintf(_atom_buf, sizeof(_atom_buf), "%s/%s-%s",
-				atom->CATEGORY, atom->PN, atom->PV);
+		size_t len = snprintf(_atom_buf, sizeof(_atom_buf), "%s/%s",
+				atom->CATEGORY, atom->P);
 		if (atom->PR_int > 0)
 			snprintf(_atom_buf + len, sizeof(_atom_buf) - len, "-r%d",
 				atom->PR_int);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-03  8:50 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-03  8:50 UTC (permalink / raw
  To: gentoo-commits

commit:     b4944d5546cab5946ec59e8a4b9053263860594b
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May  2 18:27:51 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May  2 18:27:51 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b4944d55

TODO: multiline reads are handled now

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 2 --
 1 file changed, 2 deletions(-)

diff --git a/TODO.md b/TODO.md
index 0c0c5bd..ac41911 100644
--- a/TODO.md
+++ b/TODO.md
@@ -8,8 +8,6 @@
 
 - disable color when tty = NULL; may break less?
 
-- multiline reads don't yet work for quse/qsearch
-
 - standardize/unify/clean up misc handling of colors
   define rules:
     BOLD CATEGORY/ BLUE PKG GREEN ::REPO NORM [ MAGENTA USE NORM ]


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-03  8:50 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-03  8:50 UTC (permalink / raw
  To: gentoo-commits

commit:     f95495b2a574c291caa6ce3564d32bb265ccd32c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May  3 08:50:12 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May  3 08:50:12 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f95495b2

TODO: add note for completion of bug #656550 with quse

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 1 +
 1 file changed, 1 insertion(+)

diff --git a/TODO.md b/TODO.md
index b70dffc..0d05670 100644
--- a/TODO.md
+++ b/TODO.md
@@ -89,3 +89,4 @@
 
 # quse
 - make -v only print requested USE-flag when flags given
+- read VDB on -v to print details about current USE-flag status, bug #656550


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-03  8:50 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-03  8:50 UTC (permalink / raw
  To: gentoo-commits

commit:     bfe82318250a4f5a14eea0d497905049d6a7c57d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May  2 18:33:53 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May  2 18:33:53 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bfe82318

TODO: quse -K is handled by qkeyword just fine

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 2 --
 1 file changed, 2 deletions(-)

diff --git a/TODO.md b/TODO.md
index ac41911..349170f 100644
--- a/TODO.md
+++ b/TODO.md
@@ -28,8 +28,6 @@
 
 - vdb repo/slot think about when it is freed (see cache\_pkg\_close)
 
-- quse -K -> move to qkeyword
-
 # Atoms
 
 - only 32bit values are supported for revision (-r#)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-03  8:50 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-03  8:50 UTC (permalink / raw
  To: gentoo-commits

commit:     da82e7fd977623f9577f68326027d361489d9192
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May  2 18:23:39 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May  2 18:23:39 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=da82e7fd

TODO: qatom handles deps like cat/pkg-123[foo(+)]

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/TODO.md b/TODO.md
index 007d906..0c0c5bd 100644
--- a/TODO.md
+++ b/TODO.md
@@ -38,7 +38,6 @@
 - only 64bit values are supported in any individual version component
   foo-(1234)\_alpha(56789)
 - these limits should not be an issue for all practical purposes
-- need to handle USE deps like: cat/pkg-123[foo(+)]
 
 # qmerge
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-02 16:09 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-02 16:09 UTC (permalink / raw
  To: gentoo-commits

commit:     b5fa36f7d557e8a30ca8edae69c3f187777c6727
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May  2 16:08:32 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May  2 16:08:32 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b5fa36f7

README: update somewhat

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 README.md | 31 ++++---------------------------
 1 file changed, 4 insertions(+), 27 deletions(-)

diff --git a/README.md b/README.md
index 8400c68..bfb6341 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,7 @@
 
 | What     | How                                                       |
 | -------- | --------------------------------------------------------- |
-| HOMEPAGE | https://wiki.gentoo.org/wiki/Q\_applets                   |
+| HOMEPAGE | https://wiki.gentoo.org/wiki/Q_applets                    |
 | GIT      | https://anongit.gentoo.org/git/proj/portage-utils.git     |
 | VIEWVCS  | https://gitweb.gentoo.org/proj/portage-utils.git/         |
 | GITHUB   | https://github.com/gentoo/portage-utils                   |
@@ -14,8 +14,8 @@ of information.  The focus is on size and speed, so everything is in C.
 
 ## Building
 
-Just run `make`.  This should work on any recent Linux system.
-Alternatively, run `configure` followed by `make`.
+Run `configure` followed by `make`.  If you're using git-sources, run
+autoreconf first to get various timestamps correct.
 
 ## Helping out
 
@@ -28,7 +28,7 @@ There's also a [HACKING](./HACKING.md) doc to help you get started.
 ## Examples
 
 * find elf files linking to old openssl (using app-misc/pax-utils)<br>
-  `qlist -ao | scanelf -BqgN libssl.so.0.9.6 -f -`
+  `qlist -Cao | scanelf -BqgN libssl.so.0.9.6 -f -`
 
 * produce a package.use file for currently installed packages<br>
   `qlist -UCq | grep ' ' > package.use`
@@ -54,26 +54,3 @@ Please file bugs at:
 * solar@gentoo.org
 * vapier@gentoo.org
 * grobian@gentoo.org
-
-## Notes
-
-### Speed is everything.
-
-Having your PORTDIR and VDB on the right file system helps dramatically
-
-Nowadays this should rarely matter, but on smaller scale (embedded) or
-older hardware, consider the following.
-
-IDE raid with PORTDIR on reiserfs:
-
-```sh
-$ q -r
-q: Finished 20655 entries in 1.990951 seconds
-```
-
-IDE raid with PORTDIR on ext3:
-
-```sh
-$ q -r
-q: Finished 20655 entries in 203.664252 seconds
-```


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-05-02  8:29 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-05-02  8:29 UTC (permalink / raw
  To: gentoo-commits

commit:     ee895eeb8e45c4f29c31b1559c5f0304292e6b08
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu May  2 08:19:12 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu May  2 08:19:12 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ee895eeb

TODO: add/refine some tasks

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/TODO.md b/TODO.md
index fcda59f..38778b0 100644
--- a/TODO.md
+++ b/TODO.md
@@ -4,6 +4,7 @@
 	- default \*foo\*
 	- -e foo
 	- -r (-R ?) regexp foo.\*
+- make default -e for apps like quse/qdepends?
 
 - disable color when tty = NULL; may break less?
 
@@ -29,6 +30,12 @@
 
 - vdb repo/slot think about when it is freed (see cache\_pkg\_close)
 
+- cache:cache\_read\_file\_ebuild deal with \\\\n sequences
+
+- qcache -> rename to qkeyword
+
+- quse -K -> move to qkeyword
+
 # Atoms
 
 - only 32bit values are supported for revision (-r#)
@@ -61,6 +68,7 @@
 - support querying uninstalled packages (via libq/cache)
 - add -S/-v/-R behavior like qlist #574934
 - support printing full dep content (with -v?) from libq/cache
+- bring back -k?  (but seems solved by using qlist -IF%{SLOT} pkg)
 
 # qpkg
 
@@ -83,3 +91,10 @@
   work)
 - make a -d mode that allows to do equivalent of "last portage emerge"
   to make it easy to see what was newly merged/unmerged
+
+# qlist
+- have -F for use with -I so one can do things like print SLOT for
+  package X
+
+# quse
+- make -v faster by calling searcg funcs once per package match


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-30  8:02 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-30  8:02 UTC (permalink / raw
  To: gentoo-commits

commit:     262ec2d23a8819c36b6983971dfead24bdd6cbee
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 30 08:00:59 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Apr 30 08:00:59 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=262ec2d2

qcache: suppress keywordless ebuilds in -n mode

Only return matches for ebuilds that actually have *any* keywords.

Bug: https://bugs.gentoo.org/684252
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcache.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/qcache.c b/qcache.c
index 7c5ae42..116f389 100644
--- a/qcache.c
+++ b/qcache.c
@@ -240,14 +240,23 @@ qcache_imlate(cache_pkg_ctx *pkg_ctx, void *priv)
 static int
 qcache_not(cache_pkg_ctx *pkg_ctx, void *priv)
 {
+	size_t a;
 	qcache_data *data = (qcache_data *)priv;
 
 	if (data->keywordsbuf[qcache_test_arch] != testing &&
 			data->keywordsbuf[qcache_test_arch] != stable)
 	{
-		print_keywords(pkg_ctx->cat_ctx->name, pkg_ctx->name,
-				data->keywordsbuf);
-		return EXIT_SUCCESS;
+		/* match if any of the other arches have keywords */
+		for (a = 0; a < archlist_count; a++) {
+			if (data->keywordsbuf[a] == stable ||
+					data->keywordsbuf[a] == testing)
+				break;
+		}
+		if (a < archlist_count) {
+			print_keywords(pkg_ctx->cat_ctx->name, pkg_ctx->name,
+					data->keywordsbuf);
+			return EXIT_SUCCESS;
+		}
 	}
 
 	return EXIT_FAILURE;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-30  7:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-30  7:54 UTC (permalink / raw
  To: gentoo-commits

commit:     7ae5a8f1ab58ceafb781cd25496777058e6a3d63
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 29 18:23:40 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Apr 29 18:23:40 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7ae5a8f1

q: drop reinitialize bits

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 q.c | 12 ------------
 1 file changed, 12 deletions(-)

diff --git a/q.c b/q.c
index a57ddb8..a18c791 100644
--- a/q.c
+++ b/q.c
@@ -78,8 +78,6 @@ int q_main(int argc, char **argv)
 	int i, install;
 	const char *p;
 	APPLET func;
-	int reinitialize_metacache = 0;
-	int reinitialize = 0;
 
 	if (argc == 0)
 		return 1;
@@ -157,16 +155,6 @@ int q_main(int argc, char **argv)
 		return ret;
 	}
 
-#if 0
-	if (reinitialize > 0 || reinitialize_metacache > 0) {
-		reinitialize_as_needed(reinitialize, reinitialize_metacache);
-		return 0;
-	}
-#endif
-	if (reinitialize < 0 || reinitialize_metacache < 0) {
-		reinitialize = reinitialize_metacache = 0;
-		return 0;
-	}
 	if (argc == optind)
 		q_usage(EXIT_FAILURE);
 	if ((func = lookup_applet(argv[optind])) == NULL)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-28 18:10 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-28 18:10 UTC (permalink / raw
  To: gentoo-commits

commit:     512b29304c7ddb1ea979631937f8d93bb4a2392a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 28 18:10:13 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Apr 28 18:10:13 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=512b2930

qpkg: use libq/cache

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qpkg.c | 53 +++++++++++++++++++----------------------------------
 1 file changed, 19 insertions(+), 34 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 9942184..af8df37 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -124,11 +124,27 @@ qpkg_clean_dir(char *dirp, set *vdb)
 	return num_all_bytes;
 }
 
+static int
+qpkg_cb(cache_pkg_ctx *pkg_ctx, void *priv)
+{
+	set *vdb = (set *)priv;
+	depend_atom *atom;
+	char buf[_Q_PATH_MAX];
+
+	snprintf(buf, sizeof(buf), "%s/%s", pkg_ctx->cat_ctx->name, pkg_ctx->name);
+	atom = atom_explode(buf);
+	if (atom == NULL)
+		return 0;
+
+	vdb = add_set(buf, vdb);
+
+	return 1;
+}
+
 /* figure out what dirs we want to process for cleaning and display results. */
 static int
 qpkg_clean(char *dirp)
 {
-	FILE *fp;
 	int i, count;
 	size_t disp_units = 0;
 	uint64_t num_all_bytes;
@@ -146,39 +162,8 @@ qpkg_clean(char *dirp)
 		size_t n;
 		const char *overlay;
 
-		array_for_each(overlays, n, overlay) {
-			/* FIXME: use libq/cache here */ continue;
-
-			size_t buflen;
-			char *buf;
-
-			buf = NULL;
-			while (getline(&buf, &buflen, fp) != -1) {
-				char *name, *p;
-				if ((p = strrchr(buf, '.')) == NULL)
-					continue;
-				*p = 0;
-				if ((p = strrchr(buf, '/')) == NULL)
-					continue;
-				*p = 0;
-				name = p + 1;
-				if ((p = strrchr(buf, '/')) == NULL)
-					continue;
-				*p = 0;
-				/* these strcat() are safe. the name is extracted from
-				 * buf already. */
-				strcat(buf, "/");
-				strcat(buf, name);
-
-				/* num_all_bytes will be off when pretend and eclean are
-				 * enabled together */
-				/* vdb = del_set(buf, vdb, &i); */
-				vdb = add_set(buf, vdb);
-			}
-
-			free(buf);
-			fclose(fp);
-		}
+		array_for_each(overlays, n, overlay)
+			cache_foreach_pkg(portroot, overlay, qpkg_cb, vdb, NULL);
 	}
 
 	num_all_bytes = qpkg_clean_dir(dirp, vdb);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-27  9:01 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-27  9:01 UTC (permalink / raw
  To: gentoo-commits

commit:     0a3db7b186f0785d29c2c72c5ad6dbb93381ac35
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 27 09:00:05 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Apr 27 09:00:05 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0a3db7b1

main.h: include limits.h for Linux PATH_MAX

make PATH_MAX available, such that the logic can properly use it (again)

This issue showed itself as a fortification error on Linux, because
_Q_PATH_MAX was defined as less than PATH_MAX making realpath_chk fail.

Bug: https://bugs.gentoo.org/684468
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.h | 1 +
 1 file changed, 1 insertion(+)

diff --git a/main.h b/main.h
index 32c995f..88412a8 100644
--- a/main.h
+++ b/main.h
@@ -19,6 +19,7 @@
 #include <string.h>
 #include <errno.h>
 #include <stdint.h>
+#include <limits.h>
 
 #include "i18n.h"
 #include "colors.h"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-27  8:33 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-27  8:33 UTC (permalink / raw
  To: gentoo-commits

commit:     c8f3405da20a8fffb088b4e1a81666ae2f1009e6
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 25 17:38:09 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 17:38:09 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c8f3405d

TODO: qdepends supports correct SLOT matching now

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 1 -
 1 file changed, 1 deletion(-)

diff --git a/TODO.md b/TODO.md
index fd0729e..fcda59f 100644
--- a/TODO.md
+++ b/TODO.md
@@ -59,7 +59,6 @@
 # qdepends
 
 - support querying uninstalled packages (via libq/cache)
-- support atoms like `qdepends -rQ qtsql:4` (should match unslotted deps)
 - add -S/-v/-R behavior like qlist #574934
 - support printing full dep content (with -v?) from libq/cache
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-25 17:36 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-25 17:36 UTC (permalink / raw
  To: gentoo-commits

commit:     df503f922e4070fdbb5bbe4731f79b15709a5ade
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 25 17:36:09 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 17:36:09 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=df503f92

qatom: print SUBSLOT as part of SLOT

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qatom.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/qatom.c b/qatom.c
index 20e2dcb..e3d2b0b 100644
--- a/qatom.c
+++ b/qatom.c
@@ -94,20 +94,23 @@ qatom_printf(const char *format, const depend_atom *atom, int pverbose)
 						printf("r%i", atom->PR_int);
 				} else if (!strncmp("SLOT", fmt, len)) {
 					if (showit || atom->SLOT)
-						printf(":%s%s",
-								atom->SLOT ? atom->SLOT : "-",
+						printf("%s%s%s%s%s",
+								atom->SLOT ? ":" : "<unset>",
+								atom->SLOT ? atom->SLOT : "",
+								atom->SUBSLOT ? "/" : "",
+								atom->SUBSLOT ? atom->SUBSLOT : "",
 								atom_slotdep_str[atom->slotdep]);
 				} else if (!strncmp("REPO", fmt, len)) {
 					if (showit || atom->REPO)
 						printf("::%s", HN(atom->REPO));
 				} else if (!strncmp("pfx", fmt, len)) {
 					if (showit || atom->pfx_op != ATOM_OP_NONE)
-						fputs(atom->pfx_op == ATOM_OP_NONE ?
-								"-" : atom_op_str[atom->pfx_op], stdout);
+						printf("%s", atom->pfx_op == ATOM_OP_NONE ?
+								"<unset>" : atom_op_str[atom->pfx_op]);
 				} else if (!strncmp("sfx", fmt, len)) {
 					if (showit || atom->sfx_op != ATOM_OP_NONE)
-						fputs(atom->sfx_op == ATOM_OP_NONE ?
-								"-" : atom_op_str[atom->sfx_op], stdout);
+						printf("%s", atom->sfx_op == ATOM_OP_NONE ?
+								"<unset>" : atom_op_str[atom->sfx_op]);
 				} else
 					printf("<BAD:%.*s>", (int)len, fmt);
 				++p;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-25  9:48 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-25  9:48 UTC (permalink / raw
  To: gentoo-commits

commit:     3d55262a9f8ab8e2888d13988a5656e6426cf8ec
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 25 09:34:17 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 09:34:17 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3d55262a

TODO: add some ideas about qlop

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/TODO.md b/TODO.md
index 08dae39..fd0729e 100644
--- a/TODO.md
+++ b/TODO.md
@@ -77,3 +77,10 @@
 # qgrep
 
 - make it use standard xarray instead of its own buf\_list
+
+# qlop
+
+- have a mode that doesn't print timestamp (to get just atoms, -v should
+  work)
+- make a -d mode that allows to do equivalent of "last portage emerge"
+  to make it easy to see what was newly merged/unmerged


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-25  9:48 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-25  9:48 UTC (permalink / raw
  To: gentoo-commits

commit:     78853af05fe71f27caf0dea62cb41553178d15be
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 25 09:48:17 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 09:48:17 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=78853af0

configure: remove removed dir tests/reinitialize(/Makefile)

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 configure    | 3 +--
 configure.ac | 1 -
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/configure b/configure
index 37bbed1..370512c 100755
--- a/configure
+++ b/configure
@@ -35008,7 +35008,7 @@ fi
 # -Wno-format-nonliteral
 # -Wno-expansion-to-defined
 
-ac_config_files="$ac_config_files Makefile libq/Makefile autotools/gnulib/Makefile tests/init.sh tests/Makefile tests/atom_compare/Makefile tests/atom_explode/Makefile tests/copy_file/Makefile tests/install/Makefile tests/mkdir/Makefile tests/profile/Makefile tests/qatom/Makefile tests/qcheck/Makefile tests/qdepends/Makefile tests/qfile/Makefile tests/qlist/Makefile tests/qlop/Makefile tests/qmerge/Makefile tests/qtbz2/Makefile tests/quse/Makefile tests/qxpak/Makefile tests/reinitialize/Makefile tests/rmspace/Makefile tests/source/Makefile"
+ac_config_files="$ac_config_files Makefile libq/Makefile autotools/gnulib/Makefile tests/init.sh tests/Makefile tests/atom_compare/Makefile tests/atom_explode/Makefile tests/copy_file/Makefile tests/install/Makefile tests/mkdir/Makefile tests/profile/Makefile tests/qatom/Makefile tests/qcheck/Makefile tests/qdepends/Makefile tests/qfile/Makefile tests/qlist/Makefile tests/qlop/Makefile tests/qmerge/Makefile tests/qtbz2/Makefile tests/quse/Makefile tests/qxpak/Makefile tests/rmspace/Makefile tests/source/Makefile"
 
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
@@ -36116,7 +36116,6 @@ do
     "tests/qtbz2/Makefile") CONFIG_FILES="$CONFIG_FILES tests/qtbz2/Makefile" ;;
     "tests/quse/Makefile") CONFIG_FILES="$CONFIG_FILES tests/quse/Makefile" ;;
     "tests/qxpak/Makefile") CONFIG_FILES="$CONFIG_FILES tests/qxpak/Makefile" ;;
-    "tests/reinitialize/Makefile") CONFIG_FILES="$CONFIG_FILES tests/reinitialize/Makefile" ;;
     "tests/rmspace/Makefile") CONFIG_FILES="$CONFIG_FILES tests/rmspace/Makefile" ;;
     "tests/source/Makefile") CONFIG_FILES="$CONFIG_FILES tests/source/Makefile" ;;
 

diff --git a/configure.ac b/configure.ac
index fffaf51..a0015d3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -79,7 +79,6 @@ AC_CONFIG_FILES([
 	tests/qtbz2/Makefile
 	tests/quse/Makefile
 	tests/qxpak/Makefile
-	tests/reinitialize/Makefile
 	tests/rmspace/Makefile
 	tests/source/Makefile
 ])


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-25  9:48 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-25  9:48 UTC (permalink / raw
  To: gentoo-commits

commit:     a4433152c1e30f39dce99128fc1156a30dc7cb79
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 25 09:28:26 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 09:28:26 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a4433152

TODO: add note about further improvements for qdepends with libq/cache

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/TODO.md b/TODO.md
index ab5acad..08dae39 100644
--- a/TODO.md
+++ b/TODO.md
@@ -58,9 +58,10 @@
 
 # qdepends
 
-- support querying uninstalled packages (via metadata/md5 cache)
+- support querying uninstalled packages (via libq/cache)
 - support atoms like `qdepends -rQ qtsql:4` (should match unslotted deps)
 - add -S/-v/-R behavior like qlist #574934
+- support printing full dep content (with -v?) from libq/cache
 
 # qpkg
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-25  9:22 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-25  9:22 UTC (permalink / raw
  To: gentoo-commits

commit:     33598fc089e54253261d5a0ec176bde9d300a94f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 25 09:03:21 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 09:03:21 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=33598fc0

qsearch: rewrite to use libq/cache

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsearch.c | 281 ++++++++++++++++++++++----------------------------------------
 1 file changed, 100 insertions(+), 181 deletions(-)

diff --git a/qsearch.c b/qsearch.c
index f543b8a..b6d7410 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -25,232 +25,151 @@
 #include "xarray.h"
 #include "xregex.h"
 
-#define QSEARCH_FLAGS "acesSNH" COMMON_FLAGS
+#define QSEARCH_FLAGS "asSNHR" COMMON_FLAGS
 static struct option const qsearch_long_opts[] = {
 	{"all",       no_argument, NULL, 'a'},
-	{"cache",     no_argument, NULL, 'c'},
-	{"ebuilds",   no_argument, NULL, 'e'},
 	{"search",    no_argument, NULL, 's'},
 	{"desc",       a_argument, NULL, 'S'},
 	{"name-only", no_argument, NULL, 'N'},
 	{"homepage",  no_argument, NULL, 'H'},
+	{"repo",      no_argument, NULL, 'R'},
 	COMMON_LONG_OPTS
 };
 static const char * const qsearch_opts_help[] = {
 	"List the descriptions of every package in the cache",
-	"Use the portage cache",
-	"Use the portage ebuild tree (default)",
 	"Regex search package basenames",
-	"Regex search package descriptions",
+	"Regex search package descriptions (or homepage when using -H)",
 	"Only show package name",
-	"Show homepage info",
+	"Show homepage info instead of description",
+	"Show repository the ebuild originates from",
 	COMMON_OPTS_HELP
 };
 #define qsearch_usage(ret) usage(ret, QSEARCH_FLAGS, qsearch_long_opts, qsearch_opts_help, NULL, lookup_applet_idx("qsearch"))
 
-#define LAST_BUF_SIZE 256
+struct qsearch_state {
+	bool show_homepage:1;
+	bool show_name:1;
+	bool show_desc:1;
+	bool show_repo:1;
+	bool search_desc:1;
+	bool search_name:1;
+	regex_t search_expr;
+};
 
-/* Search an ebuild's details via the metadata cache. */
-static void
-qsearch_ebuild_metadata(
-		int overlay_fd,
-		const char *ebuild,
-		const char *search_me,
-		char *last,
-		bool search_desc,
-		bool search_all,
-		bool search_name,
-		bool show_name_only,
-		bool show_homepage)
+static int
+qsearch_cb(cache_pkg_ctx *pkg_ctx, void *priv)
 {
-	(void)overlay_fd;
-	(void)search_name;
-
-	portage_cache *pcache = cache_read_file(portcachedir_type, ebuild);
-
-	if (pcache == NULL) {
-		warnf("missing cache, please (re)generate");
-		return;
+	static depend_atom *last_atom;
+
+	struct qsearch_state *state = (struct qsearch_state *)priv;
+	depend_atom *atom;
+	char buf[_Q_PATH_MAX];
+	cache_pkg_meta *meta;
+	char *desc;
+	char *repo;
+	bool match;
+
+	snprintf(buf, sizeof(buf), "%s/%s", pkg_ctx->cat_ctx->name, pkg_ctx->name);
+	atom = atom_explode(buf);
+	if (atom == NULL)
+		return 0;
+
+	/* skip duplicate packages (we never report version) */
+	if (last_atom != NULL && strcmp(last_atom->PN, atom->PN) == 0) {
+		atom_implode(atom);
+		return 0;
 	}
 
-	if (strcmp(pcache->atom->PN, last) != 0) {
-		strncpy(last, pcache->atom->PN, LAST_BUF_SIZE);
-		if (search_all || rematch(search_me,
-					(search_desc ? pcache->DESCRIPTION : ebuild),
-					REG_EXTENDED | REG_ICASE) == 0)
-			printf("%s%s/%s%s%s%s%s\n", BOLD, pcache->atom->CATEGORY, BLUE,
-			       pcache->atom->PN, NORM,
-				   (show_name_only ? "" : " "),
-			       (show_name_only ? "" :
-			        (show_homepage ? pcache->HOMEPAGE : pcache->DESCRIPTION)));
-	}
-	cache_free(pcache);
-}
-
-/* Search an ebuild's details via the ebuild cache. */
-static void
-qsearch_ebuild_ebuild(
-		int overlay_fd,
-		const char *ebuild,
-		const char *search_me,
-		char *last,
-		bool search_desc,
-		bool search_all,
-		bool search_name,
-		bool show_name_only,
-		bool show_homepage)
-{
-	const char * const search_vars[] = { "DESCRIPTION=", "HOMEPAGE=" };
-	const char *search_var = search_vars[show_homepage ? 1 : 0];
-	size_t search_len = strlen(search_var);
-	char *p, *q, *str;
-	char *buf = NULL;
-	int linelen;
-	size_t buflen;
-	bool show_it = false;
-	FILE *ebuildfp;
-	int fd;
-
-	str = xstrdup(ebuild);
-	p = dirname(str);
-
-	(void)search_desc;
-	(void)show_homepage;
-
-	if (strcmp(p, last) == 0)
-		goto no_cache_ebuild_match;
-
-	strncpy(last, p, LAST_BUF_SIZE);
-	if (search_name) {
-		if (rematch(search_me, basename(last), REG_EXTENDED | REG_ICASE) != 0) {
-			goto no_cache_ebuild_match;
-		} else {
-			q = NULL;
-			show_it = true;
+	match = false;
+	if (state->search_name &&
+			regexec(&state->search_expr, atom->PN, 0, NULL, 0) == 0)
+		match = true;
+
+	desc = NULL;
+	meta = NULL;
+	if ((match && (state->show_homepage || state->show_desc)) ||
+			(!match && state->search_desc))
+	{
+		meta = cache_pkg_read(pkg_ctx);
+		if (meta != NULL) {
+			if (state->show_homepage)
+				desc = meta->HOMEPAGE;
+			else if (state->show_desc)
+				desc = meta->DESCRIPTION;
 		}
 	}
 
-	fd = openat(overlay_fd, ebuild, O_RDONLY|O_CLOEXEC);
-	if (fd != -1) {
-		ebuildfp = fdopen(fd, "r");
-		if (ebuildfp == NULL) {
-			close(fd);
-			goto no_cache_ebuild_match;
-		}
-	} else {
-		warnf("missing cache, please (re)generate");
-		goto no_cache_ebuild_match;
+	if (!match && state->search_desc && desc != NULL &&
+			regexec(&state->search_expr, desc, 0, NULL, 0) == 0)
+		match = true;
+
+	repo = NULL;
+	if (match) {
+		if (state->show_repo)
+			repo = pkg_ctx->repo;
+		printf("%s%s/%s%s%s%s%s%s%s%s\n", BOLD, atom->CATEGORY,
+				BLUE, atom->PN,
+				GREEN, (repo ? "::" : ""), (repo ? repo : ""), NORM,
+				(state->show_name ? "" : " "),
+				(state->show_name ? "" : desc ? desc : ""));
 	}
 
-	while ((linelen = getline(&buf, &buflen, ebuildfp)) >= 0) {
-		if ((size_t)linelen <= search_len)
-			continue;
-		if (strncmp(buf, search_var, search_len) != 0)
-			continue;
-		if ((q = strrchr(buf, '"')) != NULL)
-			*q = 0;
-		if (strlen(buf) <= search_len)
-			break;
-		q = buf + search_len + 1;
-		if (!search_all && !search_name &&
-				rematch(search_me, q, REG_EXTENDED | REG_ICASE) != 0)
-			break;
-		show_it = true;
-		break;
-	}
+	if (meta != NULL)
+		cache_close_meta(meta);
 
-	if (show_it) {
-		const char *pkg = basename(p);
-		printf("%s%s/%s%s%s%s%s\n",
-			BOLD, dirname(p), BLUE, pkg, NORM,
-			(show_name_only ? "" : " "),
-			(show_name_only ? "" : q ? : "<no DESCRIPTION found>"));
-	}
+	if (last_atom != NULL)
+		atom_implode(last_atom);
+	last_atom = atom;
 
-	free(buf);
-	fclose(ebuildfp);
- no_cache_ebuild_match:
-	free(str);
+	return EXIT_SUCCESS;
 }
 
 int qsearch_main(int argc, char **argv)
 {
-	char last[LAST_BUF_SIZE];
-	char *search_me = NULL;
-	bool show_homepage = false, show_name_only = false;
-	bool search_desc = false, search_all = false, search_name = true;
-	int search_cache = CACHE_EBUILD;
+	int ret = EXIT_SUCCESS;
+	const char *search_me = NULL;
 	int i;
-	void (*search_func)(int, const char *, const char *, char *last, bool, bool, bool, bool, bool);
+	const char *overlay;
+	size_t n;
+	struct qsearch_state state = {
+		.show_homepage = false,
+		.show_name = false,
+		.show_desc = false,
+		.show_repo = false,
+		.search_desc = false,
+		.search_name = false,
+	};
 
 	while ((i = GETOPT_LONG(QSEARCH, qsearch, "")) != -1) {
 		switch (i) {
 		COMMON_GETOPTS_CASES(qsearch)
-		case 'a': search_all = true; break;
-		case 'c': search_cache = CACHE_METADATA; break;
-		case 'e': search_cache = CACHE_EBUILD; break;
-		case 's': search_desc = false; search_name = true; break;
-		case 'S': search_desc = true; search_name = false; break;
-		case 'N': show_name_only = true; break;
-		case 'H': show_homepage = true; break;
+		case 'a': search_me           = ".*";  break;
+		case 's': state.search_name   = true;  break;
+		case 'S': state.search_desc   = true;  break;
+		case 'N': state.show_name     = true;  break;
+		case 'H': state.show_homepage = true;  break;
+		case 'R': state.show_repo     = true;  break;
 		}
 	}
 
-	switch (search_cache) {
-	case CACHE_METADATA:
-		search_func = qsearch_ebuild_metadata;
-		break;
-	case CACHE_EBUILD:
-		search_func = qsearch_ebuild_ebuild;
-		break;
-	default:
-		err("unknown cache %i", search_cache);
-	}
+	/* set defaults */
+	if (!state.show_homepage)
+		state.show_desc = true;
+	if (!state.search_name && !state.search_desc)
+		state.search_name = true;
 
-	if (search_all) {
-		search_desc = true;
-		search_name = false;
-	} else {
+	/* compile expression */
+	if (search_me == NULL) {
 		if (argc == optind)
 			qsearch_usage(EXIT_FAILURE);
 		search_me = argv[optind];
 	}
-	last[0] = 0;
+	xregcomp(&state.search_expr, search_me, REG_EXTENDED | REG_ICASE);
 
-	int ret = 0;
-	size_t n;
-	const char *overlay;
-	array_for_each(overlays, n, overlay) {
-		FILE *fp = fopen(initialize_flat(overlay, search_cache, false), "r");
-		if (!fp) {
-			warnp("opening cache for %s failed", overlay);
-			ret = 1;
-			continue;
-		}
-
-		int overlay_fd = open(overlay, O_RDONLY|O_CLOEXEC|O_PATH);
-		if (overlay_fd < 0) {
-			fclose(fp);
-			warnp("open failed: %s", overlay);
-			ret = 1;
-			continue;
-		}
-
-		int linelen;
-		size_t buflen;
-		char *buf = NULL;
-		while ((linelen = getline(&buf, &buflen, fp)) >= 0) {
-			rmspace_len(buf, (size_t)linelen);
-			if (!buf[0])
-				continue;
-
-			search_func(overlay_fd, buf, search_me, last, search_desc,
-				search_all, search_name, show_name_only, show_homepage);
-		}
-		free(buf);
-		close(overlay_fd);
-		fclose(fp);
-	}
+	/* use sorted order here so the duplicate reduction works reliably */
+	array_for_each(overlays, n, overlay)
+		ret |= cache_foreach_pkg_sorted(portroot, overlay, qsearch_cb,
+				&state, NULL, NULL);
 
 	return ret;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-25  9:22 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-25  9:22 UTC (permalink / raw
  To: gentoo-commits

commit:     f4d9d1cc318d641ac24a7c4d8587a8990e7118d9
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 20 17:27:42 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Apr 20 17:27:42 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f4d9d1cc

TODO: update traversal optimisation note

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/TODO.md b/TODO.md
index 3841a8e..8173a63 100644
--- a/TODO.md
+++ b/TODO.md
@@ -25,7 +25,7 @@
   `ACCEPT_LICENSE=" bar"`
 
 - q\_vdb\_foreach\_pkg should have variant that takes an atom (or just
-  cat?) to reduce search space
+  cat?) to reduce search space, same for cache\_foreach\_pkg
 
 # Atoms
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-25  9:22 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-25  9:22 UTC (permalink / raw
  To: gentoo-commits

commit:     90f48f81ea23366f1140d0f8102a4e8d3752285a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 25 09:03:44 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr 25 09:03:44 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=90f48f81

TODO: add note about odd libq/vdb behaviour on pkg_free

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 TODO.md | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/TODO.md b/TODO.md
index 8173a63..ab5acad 100644
--- a/TODO.md
+++ b/TODO.md
@@ -27,6 +27,8 @@
 - q\_vdb\_foreach\_pkg should have variant that takes an atom (or just
   cat?) to reduce search space, same for cache\_foreach\_pkg
 
+- vdb repo/slot think about when it is freed (see cache\_pkg\_close)
+
 # Atoms
 
 - only 32bit values are supported for revision (-r#)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-25  9:22 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-25  9:22 UTC (permalink / raw
  To: gentoo-commits

commit:     86d662abd0216a49a6c2abee915e64d5c649cef2
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Apr 20 17:19:06 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Apr 20 17:19:06 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=86d662ab

qcache: rewrite to use new libq/cache

This fixes qcache for Prefix and no longer needs q's cache files.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcache.c | 1012 ++++++++++++++++++++++++--------------------------------------
 1 file changed, 396 insertions(+), 616 deletions(-)

diff --git a/qcache.c b/qcache.c
index f3252d7..7c5ae42 100644
--- a/qcache.c
+++ b/qcache.c
@@ -2,7 +2,8 @@
  * Copyright 2005-2019 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
- * Copyright 2006 Thomas A. Cort - <tcort@gentoo.org>
+ * Copyright 2006      Thomas A. Cort - <tcort@gentoo.org>
+ * Copyright 2019-     Fabian Groffen - <grobian@gentoo.org>
  */
 
 #include "main.h"
@@ -52,42 +53,24 @@ static const char * const qcache_opts_help[] = {
 };
 #define qcache_usage(ret) usage(ret, QCACHE_FLAGS, qcache_long_opts, qcache_opts_help, NULL, lookup_applet_idx("qcache"))
 
-/********************************************************************/
-/* Structs                                                          */
-/********************************************************************/
-
 typedef struct {
-	const char *overlay;
-	const char *category;
-	const char *package;
-	const char *ebuild;
-	portage_cache *cache_data;
-	unsigned char cur;
-	unsigned char num;
+	depend_atom *qatom;
+	depend_atom *lastatom;
+	int *keywordsbuf;
+	size_t keywordsbuflen;
+	const char *arch;
+	cache_pkg_cb *runfunc;
 } qcache_data;
 
-/********************************************************************/
-/* Global Variables                                                 */
-/********************************************************************/
-
-static set *archs;
-static char **archlist;
-static int archlist_count;
+static set *archs = NULL;
+static char **archlist = NULL;
+static size_t archlist_count;
 static size_t arch_longest_len;
 const char status[3] = {'-', '~', '+'};
-int qcache_skip, qcache_test_arch;
-char *qcache_matchpkg = NULL, *qcache_matchcat = NULL;
-
-/********************************************************************/
-/* Enumerations                                                     */
-/********************************************************************/
+int qcache_test_arch = 0;
 
 enum { none = 0, testing, stable, minus };
 
-/********************************************************************/
-/* Keyword functions                                                */
-/********************************************************************/
-
 /*
  * int decode_status(char c);
  *
@@ -109,8 +92,6 @@ decode_status(char c)
 }
 
 /*
- * int decode_arch(const char *arch);
- *
  * Decode the architecture string
  *
  * IN:
@@ -138,8 +119,6 @@ decode_arch(const char *arch)
 }
 
 /*
- * void print_keywords(char *category, char *ebuild, int *keywords);
- *
  * Prints the keywords to stdout
  *
  * IN:
@@ -150,31 +129,24 @@ static void
 print_keywords(const char *category, const char *ebuild, int *keywords)
 {
 	char **arch = archlist;
-	int a;
-	char *package;
+	size_t a;
 
-	package = xstrdup(ebuild);
-	package[strlen(ebuild)-7] = '\0';
-
-	printf("%s%s/%s%s%s ", BOLD, category, BLUE, package, NORM);
+	printf("%s%s/%s%s%s ", BOLD, category, BLUE, ebuild, NORM);
 	for (a = 0; a < archlist_count; a++) {
 		switch (keywords[a]) {
 			case stable:
 				printf("%s%c%s%s ", GREEN, status[keywords[a]], arch[a], NORM);
 				break;
 			case testing:
-				printf("%s%c%s%s ", YELLOW, status[keywords[a]], arch[0], NORM);
+				printf("%s%c%s%s ", YELLOW, status[keywords[a]], arch[a], NORM);
 				break;
 		}
 	}
 
 	printf("\n");
-	free(package);
 }
 
 /*
- * int read_keywords(char *s, int *keywords);
- *
  * Read the KEYWORDS string and decode the values
  *
  * IN:
@@ -188,7 +160,8 @@ read_keywords(char *s, int *keywords)
 {
 	char *arch, delim[2] = { ' ', '\0' };
 	size_t slen;
-	int a;
+	size_t a;
+	int i;
 
 	if (!s)
 		return -1;
@@ -206,138 +179,18 @@ read_keywords(char *s, int *keywords)
 
 	arch = strtok(s, delim);
 	do {
-		a = decode_arch(arch);
-		if (a == -1)
+		i = decode_arch(arch);
+		if (i == -1)
 			continue;
-		keywords[a] = decode_status(arch[0]);
+		keywords[i] = decode_status(arch[0]);
 	} while ((arch = strtok(NULL, delim)));
 
 	return 0;
 }
 
 /*
- * portage_cache *qcache_read_cache_file(const char *file);
- *
- * Read a file from the edb cache and store data in portage_cache.
- *
- * IN:
- *  const char *filename - cache file to read
- * OUT:
- *  portage_cache *pkg - cache data
- * ERR:
- *  NULL is returned when an error occurs.
- */
-static portage_cache *
-qcache_read_cache_file(const char *filename)
-{
-	struct stat s;
-	char *buf;
-	FILE *f;
-	portage_cache *ret = NULL;
-	int linelen;
-	size_t len, buflen;
-
-	if ((f = fopen(filename, "r")) == NULL)
-		goto err;
-
-	if (fstat(fileno(f), &s) != 0) {
-		fclose(f);
-		goto err;
-	}
-
-	buf = NULL;
-	len = sizeof(*ret) + s.st_size + 1;
-	ret = xzalloc(len);
-
-	while ((linelen = getline(&buf, &buflen, f)) >= 0) {
-		rmspace_len(buf, (size_t)linelen);
-
-		if (strncmp(buf, "DEPEND=", 7) == 0)
-			ret->DEPEND = xstrdup(buf + 7);
-
-		if (strncmp(buf, "DESCRIPTION=", 12) == 0)
-			ret->DESCRIPTION = xstrdup(buf + 12);
-
-		if (strncmp(buf, "HOMEPAGE=", 9) == 0)
-			ret->HOMEPAGE = xstrdup(buf + 9);
-
-		if (strncmp(buf, "INHERITED=", 10) == 0)
-			ret->INHERITED = xstrdup(buf + 10);
-
-		if (strncmp(buf, "IUSE=", 4) == 0)
-			ret->IUSE = xstrdup(buf + 4);
-
-		if (strncmp(buf, "KEYWORDS=", 9) == 0)
-			ret->KEYWORDS = xstrdup(buf + 9);
-
-		if (strncmp(buf, "LICENSE=", 8) == 0)
-			ret->LICENSE = xstrdup(buf + 8);
-
-		if (strncmp(buf, "PDEPEND=", 8) == 0)
-			ret->PDEPEND = xstrdup(buf + 8);
-
-		if (strncmp(buf, "PROVIDE=", 8) == 0)
-			ret->PROVIDE = xstrdup(buf + 8);
-
-		if (strncmp(buf, "RDEPEND=", 8) == 0)
-			ret->RDEPEND = xstrdup(buf + 8);
-
-		if (strncmp(buf, "RESTRICT=", 9) == 0)
-			ret->RESTRICT = xstrdup(buf + 9);
-
-		if (strncmp(buf, "SLOT=", 5) == 0)
-			ret->SLOT = xstrdup(buf + 5);
-
-		if (strncmp(buf, "SRC_URI=", 8) == 0)
-			ret->SRC_URI = xstrdup(buf + 8);
-	}
-
-	free(buf);
-	ret->atom = atom_explode(filename);
-	fclose(f);
-
-	return ret;
-
- err:
-	if (ret)
-		cache_free(ret);
-	return NULL;
-}
-
-/*
- * void qcache_free_data(portage_cache *cache);
- *
- * free()'s a portage_cache
- *
- * IN:
- *  portage_cache *cache - the portage_cache to be free()'d
- */
-static void
-qcache_free_data(portage_cache *cache)
-{
-	int i;
-	char **c;
-
-	if (!cache)
-		errf("Cache is empty !");
-
-	for (i = 0, c = (char**) cache; i < 15; i++)
-		if (c[i])
-			free(c[i]);
-
-	atom_implode(cache->atom);
-	free(cache);
-}
-
-/********************************************************************/
-/* Comparison functions                                             */
-/********************************************************************/
-
-/*
- * int qcache_vercmp(const void *x, const void *y);
- *
  * Compare 2 struct dirent d_name strings based with atom_compare_str().
- * Used with dirscan() to sort ebuild filenames by version.
+ * Used with dirscan() to sort ebuild filenames by version, reversed.
  *
  * IN:
  *  2 (const struct dirent **) with d_name filled in
@@ -350,357 +203,163 @@ static int
 qcache_vercmp(const struct dirent **x, const struct dirent **y)
 {
 	switch (atom_compare_str((*x)->d_name, (*y)->d_name)) {
-		case NEWER: return -1;
-		case OLDER: return  1;
-		default:    return  0;
-	}
-}
-
-/********************************************************************/
-/* Selection functions                                              */
-/********************************************************************/
-
-/*
- * int qcache_file_select(const struct dirent *entry);
- *
- * Selects filenames that do not begin with '.' and are not name "metadata.xml"
- *  or that file matches ".cpickle"
- *
- * IN:
- *  const struct dirent *entry - entry to check
- * OUT:
- *  int - 0 if filename begins with '.' or is "metadata.xml", otherwise 1
- */
-static int
-qcache_file_select(const struct dirent *entry)
-{
-	return !(entry->d_name[0] == '.' ||
-			(strcmp(entry->d_name, "metadata.xml") == 0) ||
-			(strstr(entry->d_name, ".cpickle") != 0));
-}
-
-/*
- * int qcache_ebuild_select(const struct dirent *entry);
- *
- * Select filenames that end in ".ebuild"
- *
- * IN:
- *  const struct dirent *entry - entry to check
- * OUT:
- *  int - 1 if the filename ends in ".ebuild", otherwise 0
- */
-static int
-qcache_ebuild_select(const struct dirent *entry)
-{
-	return ((strlen(entry->d_name) > 7) &&
-			!strcmp(entry->d_name+strlen(entry->d_name)-7, ".ebuild"));
-}
-
-/********************************************************************/
-/* Traversal function                                               */
-/********************************************************************/
-
-static void qcache_load_arches(const char *overlay);
-
-/*
- * int qcache_traverse(void (*func)(qcache_data*));
- *
- * visit every version of every package of every category in the tree
- *
- * IN:
- *  void (*func)(qcache_data*) - function to call
- * OUT:
- *  int - 0 on success.
- * ERR:
- *  exit or return -1 on failure.
- */
-static int
-qcache_traverse_overlay(void (*func)(qcache_data*), const char *overlay)
-{
-	qcache_data data = {
-		.overlay = overlay,
-	};
-	char *catpath, *pkgpath, *ebuildpath, *cachepath;
-	int i, j, k, len, num_cat, num_pkg, num_ebuild;
-	struct dirent **categories, **packages, **ebuilds;
-
-	xasprintf(&catpath, "%s/metadata/md5-cache", overlay);
-
-	if (-1 == (num_cat = scandir(catpath, &categories,
-					qcache_file_select, alphasort)))
-	{
-		errp("%s", catpath);
-		free(catpath);
+		case EQUAL:      return  0;
+		case NEWER:      return -1;
+		case OLDER:      return  1;
+		default:         return strcmp((*x)->d_name, (*y)->d_name);
 	}
-
-	if (!num_cat)
-		warn("%s is empty!", catpath);
-
-	/* traverse categories */
-	for (i = 0; i < num_cat; i++) {
-		xasprintf(&pkgpath, "%s/%s", overlay, categories[i]->d_name);
-
-		if (-1 == (num_pkg = scandir(pkgpath, &packages,
-						qcache_file_select, alphasort)))
-		{
-			if (errno != ENOENT)
-				warnp("Found a cache dir, but unable to process %s", pkgpath);
-			free(categories[i]);
-			free(pkgpath);
-			continue;
-		}
-
-		if (qcache_matchcat) {
-			if (strcmp(categories[i]->d_name, qcache_matchcat) != 0) {
-				scandir_free(packages, num_pkg);
-				free(categories[i]);
-				free(pkgpath);
-				continue;
-			}
-		}
-
-		/* traverse packages */
-		for (j = 0; j < num_pkg; j++) {
-			xasprintf(&ebuildpath, "%s/%s/%s",
-					overlay, categories[i]->d_name, packages[j]->d_name);
-
-			if (-1 == (num_ebuild = scandir(ebuildpath, &ebuilds,
-							qcache_ebuild_select, qcache_vercmp)))
-			{
-				/* Do not complain about spurious files */
-				if (errno != ENOTDIR)
-					warnp("%s", ebuildpath);
-				free(packages[j]);
-				free(ebuildpath);
-				continue;
-			}
-
-			if (qcache_matchpkg) {
-				if (strcmp(packages[j]->d_name, qcache_matchpkg) != 0) {
-					scandir_free(ebuilds, num_ebuild);
-					free(packages[j]);
-					free(ebuildpath);
-					continue;
-				}
-			}
-
-			qcache_skip = 0;
-
-			/* traverse ebuilds */
-			data.num = num_ebuild;
-			for (k = 0; k < num_ebuild; k++) {
-				len = xasprintf(&cachepath, "%s/%s/%s",
-						catpath, categories[i]->d_name, ebuilds[k]->d_name);
-				cachepath[len - 7] = '\0'; /* remove ".ebuild" */
-
-				data.category = categories[i]->d_name;
-				data.package = packages[j]->d_name;
-				data.ebuild = ebuilds[k]->d_name;
-				data.cur = k + 1;
-				data.cache_data = qcache_read_cache_file(cachepath);
-
-				if (data.cache_data != NULL) {
-					if (!qcache_skip)
-						func(&data);
-
-					qcache_free_data(data.cache_data);
-				} else {
-					static bool warned = false;
-					if (!warned) {
-						warned = true;
-						warnp("unable to read cache '%s'\n"
-						      "\tperhaps you need to `egencache`?", cachepath);
-					}
-				}
-
-				free(ebuilds[k]);
-				free(cachepath);
-			}
-
-			free(packages[j]);
-			free(ebuilds);
-			free(ebuildpath);
-		}
-
-		free(categories[i]);
-		free(packages);
-		free(pkgpath);
-	}
-
-	free(categories);
-	free(catpath);
-
-	return 0;
 }
 
 static int
-qcache_traverse(void (*func)(qcache_data*))
+qcache_imlate(cache_pkg_ctx *pkg_ctx, void *priv)
 {
-	int ret;
-	size_t n;
-	const char *overlay;
+	size_t a;
+	qcache_data *data = (qcache_data *)priv;
 
-	/* Preload all the arches. Not entirely correctly (as arches are bound
-	 * to overlays if set), but oh well. */
-	array_for_each(overlays, n, overlay)
-		qcache_load_arches(overlay);
-
-	ret = 0;
-	array_for_each(overlays, n, overlay)
-		ret |= qcache_traverse_overlay(func, overlay);
-
-	func(NULL);
-
-	return ret;
-}
-
-/********************************************************************/
-/* functors                                                         */
-/********************************************************************/
-
-static void
-qcache_imlate(qcache_data *data)
-{
-	int *keywords;
-	int a;
-
-	if (!data)
-		return;
-
-	keywords = xmalloc(sizeof(*keywords) * archlist_count);
-
-	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
-		if (verbose)
-			warn("Failed to read keywords for %s%s/%s%s%s",
-				BOLD, data->category, BLUE, data->ebuild, NORM);
-		free(keywords);
-		return;
-	}
-
-	switch (keywords[qcache_test_arch]) {
+	switch (data->keywordsbuf[qcache_test_arch]) {
 		case stable:
-			qcache_skip = 1;
 		case none:
 		case minus:
 			break;
 
 		default:
-			for (a = 0; a < archlist_count && !qcache_skip; ++a) {
-				if (keywords[a] != stable)
+			/* match if any of the other arches have stable keywords */
+			for (a = 0; a < archlist_count; a++) {
+				if (data->keywordsbuf[a] != stable)
 					continue;
-				qcache_skip = 1;
-				print_keywords(data->category, data->ebuild, keywords);
+				print_keywords(pkg_ctx->cat_ctx->name, pkg_ctx->name,
+						data->keywordsbuf);
+
+				return EXIT_SUCCESS;
 			}
 	}
-	free(keywords);
+
+	return EXIT_FAILURE;
 }
 
-static void
-qcache_not(qcache_data *data)
+static int
+qcache_not(cache_pkg_ctx *pkg_ctx, void *priv)
 {
-	int *keywords;
-
-	if (!data)
-		return;
+	qcache_data *data = (qcache_data *)priv;
 
-	keywords = xmalloc(sizeof(*keywords) * archlist_count);
-
-	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
-		if (verbose)
-			warn("Failed to read keywords for %s%s/%s%s%s",
-				BOLD, data->category, BLUE, data->ebuild, NORM);
-		free(keywords);
-		return;
-	}
-
-	if (keywords[qcache_test_arch] == testing ||
-			keywords[qcache_test_arch] == stable)
+	if (data->keywordsbuf[qcache_test_arch] != testing &&
+			data->keywordsbuf[qcache_test_arch] != stable)
 	{
-		qcache_skip = 1;
-	} else if (data->cur == data->num) {
-		printf("%s%s/%s%s%s\n", BOLD, data->category, BLUE,
-				data->package, NORM);
+		print_keywords(pkg_ctx->cat_ctx->name, pkg_ctx->name,
+				data->keywordsbuf);
+		return EXIT_SUCCESS;
 	}
 
-	free(keywords);
+	return EXIT_FAILURE;
 }
 
-static void
-qcache_all(qcache_data *data)
+static int
+qcache_all(cache_pkg_ctx *pkg_ctx, void *priv)
 {
-	int *keywords;
-
-	if (!data)
-		return;
-
-	keywords = xmalloc(sizeof(*keywords) * archlist_count);
-
-	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
-		if (verbose)
-			warn("Failed to read keywords for %s%s/%s%s%s",
-				BOLD, data->category, BLUE, data->ebuild, NORM);
-		free(keywords);
-		return;
-	}
+	qcache_data *data = (qcache_data *)priv;
 
-	if (keywords[qcache_test_arch] == stable ||
-			keywords[qcache_test_arch] == testing)
+	if (data->keywordsbuf[qcache_test_arch] == stable ||
+			data->keywordsbuf[qcache_test_arch] == testing)
 	{
-		qcache_skip = 1;
-		printf("%s%s/%s%s%s\n", BOLD, data->category, BLUE,
-				data->package, NORM);
+		print_keywords(pkg_ctx->cat_ctx->name, pkg_ctx->name,
+				data->keywordsbuf);
+		return EXIT_SUCCESS;
 	}
 
-	free(keywords);
+	return EXIT_FAILURE;
 }
 
-static void
-qcache_dropped(qcache_data *data)
+static int
+qcache_dropped(cache_pkg_ctx *pkg_ctx, void *priv)
 {
-	static int possible = 0;
-	int *keywords, i;
-
-	if (!data)
-		return;
-
-	if (data->cur == 1)
-		possible = 0;
-
-	keywords = xmalloc(sizeof(*keywords) * archlist_count);
-
-	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
-		if (verbose)
-			warn("Failed to read keywords for %s%s/%s%s%s",
-				BOLD, data->category, BLUE, data->ebuild, NORM);
-		free(keywords);
-		return;
+	static bool candidate = false;
+	static char pkg1[_Q_PATH_MAX];
+	static char pkg2[_Q_PATH_MAX];
+	static char *lastpkg = pkg1;
+	static char *curpkg = pkg2;
+	static char candpkg[_Q_PATH_MAX];
+	static int *candkwds = NULL;
+	static size_t candkwdslen = 0;
+
+	qcache_data *data = (qcache_data *)priv;
+	size_t i;
+	char *p;
+
+	/* a keyword is "dropped", if:
+	 * - the keyword is present (stable or testing) in earlier ebuilds
+	 * - there are other stable or testing keywords in the ebuild being
+	 *   evaluated
+	 * - the keyword is absent, thus not explicitly removed -keyword */
+
+	/* mutt-1.10.4: amd64
+	 * mutt-1.11.1: amd64 ppc64
+	 * mutt-1.15.1: amd64           <-- this ebuild for ppc64
+	 * mutt-9999:                                                    */
+
+	p = lastpkg;
+	lastpkg = curpkg;
+	curpkg = p;
+	if (pkg_ctx != NULL) {
+		snprintf(curpkg, _Q_PATH_MAX, "%s/%s",
+				pkg_ctx->cat_ctx->name, pkg_ctx->name);
+	} else {
+		curpkg[0] = '\0';
 	}
-
-	if (keywords[qcache_test_arch] == testing ||
-			keywords[qcache_test_arch] == stable)
+	if (atom_compare_str(lastpkg, curpkg) == NOT_EQUAL)
 	{
-		qcache_skip = 1;
+		/* different package, reset */
+		candidate = false;
+	}
 
-		if (possible) {
-			printf("%s%s/%s%s%s\n", BOLD, data->category, BLUE,
-					data->package, NORM);
-		}
+	if (data == NULL) {
+		if (candkwds != NULL)
+			free(candkwds);
+		return EXIT_SUCCESS;
+	}
 
-		free(keywords);
-		return;
+	if (candkwdslen < data->keywordsbuflen) {
+		candkwds = xrealloc(candkwds,
+				data->keywordsbuflen * sizeof(candkwds[0]));
+		candkwdslen = data->keywordsbuflen;
 	}
 
-	if (!possible) {
-		/* don't count newer versions with "-*" keywords */
-		for (i = 0; i < archlist_count; ++i) {
-			if (keywords[i] == stable || keywords[i] == testing) {
-				possible = 1;
-				break;
+	/* explicitly removed? */
+	if (data->keywordsbuf[qcache_test_arch] == minus)
+		return EXIT_FAILURE;
+
+	/* got a keyword? */
+	if (data->keywordsbuf[qcache_test_arch] == testing ||
+			data->keywordsbuf[qcache_test_arch] == stable)
+	{
+		if (candidate) {
+			p = strchr(candpkg, '/');
+			if (p != NULL) {
+				*p++ = '\0';
+				print_keywords(candpkg, p, candkwds);
 			}
+			candidate = false;
 		}
+		return EXIT_SUCCESS;  /* suppress further hits for this package */
 	}
 
-	free(keywords);
+	/* do others have keywords? */
+	for (i = 0; i < archlist_count; i++) {
+		if (data->keywordsbuf[i] == stable || data->keywordsbuf[i] == testing) {
+			/* we don't have a keyword, others do: candidate */
+			break;
+		}
+	}
+	if (i == archlist_count)
+		return EXIT_FAILURE;
+
+	/* keep the "highest" candidate */
+	if (!candidate) {
+		memcpy(candkwds, data->keywordsbuf,
+				data->keywordsbuflen * sizeof(candkwds[0]));
+		memcpy(candpkg, curpkg, _Q_PATH_MAX);
+		candidate = true;
+	}
+	return EXIT_FAILURE;
 }
 
 static void
@@ -712,36 +371,54 @@ print_seconds_for_earthlings(const unsigned long t)
 	mm = tt % 60; tt /= 60;
 	hh = tt % 24; tt /= 24;
 	dd = tt;
-	if (dd) printf("%s%u%s day%s, ", GREEN, dd, NORM, (dd == 1 ? "" : "s"));
-	if (hh) printf("%s%u%s hour%s, ", GREEN, hh, NORM, (hh == 1 ? "" : "s"));
-	if (mm) printf("%s%u%s minute%s, ", GREEN, mm, NORM, (mm == 1 ? "" : "s"));
+	if (dd)
+		printf("%s%u%s day%s, ", GREEN, dd, NORM, (dd == 1 ? "" : "s"));
+	if (hh)
+		printf("%s%u%s hour%s, ", GREEN, hh, NORM, (hh == 1 ? "" : "s"));
+	if (mm)
+		printf("%s%u%s minute%s, ", GREEN, mm, NORM, (mm == 1 ? "" : "s"));
 	printf("%s%u%s second%s", GREEN, ss, NORM, (ss == 1 ? "" : "s"));
 }
 
-static void
-qcache_stats(qcache_data *data)
+static int
+qcache_stats(cache_pkg_ctx *pkg_ctx, void *priv)
 {
 	static time_t runtime;
-	static set *allcats;
-	static const char *last_overlay;
 	static int numpkg  = 0;
 	static int numebld = 0;
-	static int numcat;
+	static int numcat = 0;
 	static int *packages_stable;
 	static int *packages_testing;
 	static int *current_package_keywords;
-	static int *keywords;
-	int a;
+	static const char *lastcat = NULL;
+	static char lastpkg[_Q_PATH_MAX];
+
+	size_t a;
+	depend_atom *atom;
+	qcache_data *data = (qcache_data *)priv;
 
 	/* Is this the last time we'll be called? */
 	if (!data) {
 		char **arch;
 		const char border[] = "------------------------------------------------------------------";
 
+		/* include stats for last package */
+		for (a = 0; a < archlist_count; a++) {
+			switch (current_package_keywords[a]) {
+				case stable:
+					packages_stable[a]++;
+					break;
+				case testing:
+					packages_testing[a]++;
+				default:
+					break;
+			}
+		}
+
 		printf("+%.*s+\n", 25, border);
 		printf("|   general statistics    |\n");
 		printf("+%.*s+\n", 25, border);
-		printf("| %s%13s%s | %s%7d%s |\n",
+		printf("| %s%13s%s | %s%7zd%s |\n",
 				GREEN, "architectures", NORM, BLUE, archlist_count, NORM);
 		printf("| %s%13s%s | %s%7d%s |\n",
 				GREEN, "categories", NORM, BLUE, numcat, NORM);
@@ -783,81 +460,49 @@ qcache_stats(qcache_data *data)
 
 		free(packages_stable);
 		free(packages_testing);
-		free(keywords);
 		free(current_package_keywords);
-		free_set(allcats);
-		return;
+		return EXIT_SUCCESS;
 	}
 
-	if (last_overlay != data->overlay) {
-		DIR *dir;
-		struct dirent *de;
-		char *catpath;
-
-		runtime = time(NULL);
-
-		xasprintf(&catpath, "%s/metadata/md5-cache", data->overlay);
-		dir = opendir(catpath);
-		while ((de = readdir(dir))) {
-			/* Look for all the directories in this path. */
-#if defined(DT_UNKNOWN) && defined(DT_DIR)
-			if (de->d_type == DT_UNKNOWN)
-#endif
-			{
-				struct stat s;
-				char spath[_Q_PATH_MAX * 2];
-				snprintf(spath, sizeof(spath), "%s/%s", catpath, de->d_name);
-				if (lstat(spath, &s) != 0)
-					continue;
-				if (!S_ISDIR(s.st_mode))
-					continue;
-			}
-#if defined(DT_UNKNOWN) && defined(DT_DIR)
-			else if (de->d_type != DT_DIR)
-				continue;
-#endif
-
-			if (de->d_name[0] != '.') {
-				bool ok;
-				allcats = add_set_unique(de->d_name, allcats, &ok);
-				if (ok)
-					++numcat;
-			}
-		}
-		closedir(dir);
-		free(catpath);
-
-		last_overlay = data->overlay;
-	}
-
-	if (!numpkg) {
+	if (numpkg == 0) {
+		runtime                  = time(NULL);
 		packages_stable          =
 			xcalloc(archlist_count, sizeof(*packages_stable));
 		packages_testing         =
 			xcalloc(archlist_count, sizeof(*packages_testing));
-		keywords                 =
-			xcalloc(archlist_count, sizeof(*keywords));
 		current_package_keywords =
 			xcalloc(archlist_count, sizeof(*current_package_keywords));
 	}
 
-	if (data->cur == 1) {
+	if (lastcat != pkg_ctx->cat_ctx->name)
+		numcat++;
+	lastcat = pkg_ctx->cat_ctx->name;
+
+	atom = atom_explode(pkg_ctx->name);
+	if (atom && strcmp(lastpkg, atom->PN) != 0) {
+		for (a = 0; a < archlist_count; a++) {
+			switch (current_package_keywords[a]) {
+				case stable:
+					packages_stable[a]++;
+					break;
+				case testing:
+					packages_testing[a]++;
+				default:
+					break;
+			}
+		}
+
 		numpkg++;
+		snprintf(lastpkg, sizeof(lastpkg), "%s", atom->PN);
 		memset(current_package_keywords, 0,
 				archlist_count * sizeof(*current_package_keywords));
 	}
-	++numebld;
+	atom_implode(atom);
 
-	memset(keywords, 0, archlist_count * sizeof(*keywords));
-	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
-		if (verbose)
-			warn("Failed to read keywords for %s%s/%s%s%s",
-				BOLD, data->category, BLUE, data->ebuild, NORM);
-		return;
-	}
+	numebld++;
 
-	for (a = 0; a < archlist_count; ++a) {
-		switch (keywords[a]) {
+	for (a = 0; a < archlist_count; a++) {
+		switch (data->keywordsbuf[a]) {
 			case stable:
 				current_package_keywords[a] = stable;
 				break;
@@ -869,65 +514,140 @@ qcache_stats(qcache_data *data)
 		}
 	}
 
-	if (data->cur == data->num) {
-		for (a = 0; a < archlist_count; ++a) {
-			switch (current_package_keywords[a]) {
-				case stable:
-					packages_stable[a]++;
-					break;
-				case testing:
-					packages_testing[a]++;
-				default:
-					break;
+	return EXIT_FAILURE;
+}
+
+static int
+qcache_testing_only(cache_pkg_ctx *pkg_ctx, void *priv)
+{
+	static bool candidate = false;
+	static char pkg1[_Q_PATH_MAX];
+	static char pkg2[_Q_PATH_MAX];
+	static char *lastpkg = pkg1;
+	static char *curpkg = pkg2;
+	static char candpkg[_Q_PATH_MAX];
+	static int *candkwds = NULL;
+	static size_t candkwdslen = 0;
+
+	qcache_data *data = (qcache_data *)priv;
+	char *p;
+
+	p = lastpkg;
+	lastpkg = curpkg;
+	curpkg = p;
+	if (pkg_ctx != NULL) {
+		snprintf(curpkg, _Q_PATH_MAX, "%s/%s",
+				pkg_ctx->cat_ctx->name, pkg_ctx->name);
+	} else {
+		curpkg[0] = '\0';
+	}
+	if (atom_compare_str(lastpkg, curpkg) == NOT_EQUAL)
+	{
+		/* different package, print if candidate */
+		if (candidate) {
+			p = strchr(candpkg, '/');
+			if (p != NULL) {
+				*p++ = '\0';
+				print_keywords(candpkg, p, candkwds);
 			}
+			candidate = false;
 		}
 	}
+
+	if (data == NULL) {
+		if (candkwds != NULL)
+			free(candkwds);
+		return EXIT_SUCCESS;
+	}
+
+	if (candkwdslen < data->keywordsbuflen) {
+		candkwds = xrealloc(candkwds,
+				data->keywordsbuflen * sizeof(candkwds[0]));
+		candkwdslen = data->keywordsbuflen;
+	}
+
+	/* explicitly removed or unkeyworded? */
+	if (data->keywordsbuf[qcache_test_arch] == minus ||
+			data->keywordsbuf[qcache_test_arch] == none)
+		return EXIT_FAILURE;
+
+	/* got a stable keyword? */
+	if (data->keywordsbuf[qcache_test_arch] == stable)
+		return EXIT_SUCCESS;  /* suppress further hits for this package */
+
+	/* must be testing at this point */
+
+	/* keep the "highest" candidate */
+	if (!candidate) {
+		memcpy(candkwds, data->keywordsbuf,
+				data->keywordsbuflen * sizeof(candkwds[0]));
+		memcpy(candpkg, curpkg, _Q_PATH_MAX);
+		candidate = true;
+	}
+	return EXIT_FAILURE;
 }
 
-static void
-qcache_testing_only(qcache_data *data)
+static int
+qcache_results_cb(cache_pkg_ctx *pkg_ctx, void *priv)
 {
-	static int possible = 0;
 	int *keywords;
+	qcache_data *data = (qcache_data *)priv;
+	char buf[_Q_PATH_MAX];
+	depend_atom *patom = NULL;
+	cache_pkg_meta *meta;
+	int ret;
 
-	if (!data)
-		return;
-
-	if (data->cur == 1)
-		possible = 0;
+	snprintf(buf, sizeof(buf), "%s/%s",
+			pkg_ctx->cat_ctx->name, pkg_ctx->name);
+	patom = atom_explode(buf);
+	if (patom == NULL)
+		return EXIT_FAILURE;
 
-	keywords = xmalloc(sizeof(*keywords) * archlist_count);
+	if (data->qatom != NULL &&
+			atom_compare(patom, data->qatom) != EQUAL)
+	{
+		atom_implode(patom);
+		return EXIT_FAILURE;
+	}
 
-	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
-		if (verbose)
-			warn("Failed to read keywords for %s%s/%s%s%s",
-				BOLD, data->category, BLUE, data->ebuild, NORM);
-		free(keywords);
-		return;
+	if (data->lastatom != NULL &&
+			atom_compare(data->lastatom, patom) != NOT_EQUAL)
+	{
+		atom_implode(patom);
+		return EXIT_SUCCESS;
 	}
 
-	if (keywords[qcache_test_arch] == stable) {
-		qcache_skip = 1;
-		free(keywords);
-		return;
+	keywords = data->keywordsbuf;
+	meta = cache_pkg_read(pkg_ctx);
+	if (meta == NULL) {
+		atom_implode(patom);
+		return EXIT_FAILURE;
 	}
 
-	/* the qcache_test_arch must have at least 1 ~arch keyword */
-	if (keywords[qcache_test_arch] == testing)
-		possible = 1;
+	if (read_keywords(meta->KEYWORDS, keywords) < 0) {
+		if (verbose)
+			warn("Failed to read keywords for %s%s/%s%s%s",
+				BOLD, pkg_ctx->cat_ctx->name, BLUE, pkg_ctx->name, NORM);
+		atom_implode(patom);
+		return EXIT_FAILURE;
+	}
 
-	if (data->cur == data->num && possible) {
-		printf("%s%s/%s%s%s\n", BOLD, data->category, BLUE,
-				data->package, NORM);
+	ret = data->runfunc(pkg_ctx, priv);
+
+	if (ret == EXIT_SUCCESS) {
+		/* store CAT/PN in lastatom */
+		patom->P = patom->PN;
+		patom->PVR = patom->PN;
+		patom->PR_int = 0;
+		data->lastatom = patom;
+		patom = NULL;
+	} else {
+		atom_implode(patom);
 	}
 
-	free(keywords);
+	return EXIT_SUCCESS;
 }
 
-/********************************************************************/
-/* Misc functions                                                   */
-/********************************************************************/
-
 static void
 qcache_load_arches(const char *overlay)
 {
@@ -937,11 +657,12 @@ qcache_load_arches(const char *overlay)
 	size_t buflen;
 	char *buf;
 
-	xasprintf(&filename, "%s/profiles/arch.list", overlay);
+	xasprintf(&filename, "%s/%s/profiles/arch.list", portroot, overlay);
 	fp = fopen(filename, "re");
 	if (!fp)
 		goto done;
 
+	clear_set(archs);
 	archlist_count = 0;
 	arch_longest_len = 0;
 	buf = NULL;
@@ -956,13 +677,17 @@ qcache_load_arches(const char *overlay)
 		bool ok;
 		archs = add_set_unique(buf, archs, &ok);
 		if (ok) {
-			++archlist_count;
-			arch_longest_len = MAX(arch_longest_len, strlen(buf));
+			archlist_count++;
+			buflen = strlen(buf);
+			if (arch_longest_len < buflen)
+				arch_longest_len = buflen;
 		}
 	}
 	free(buf);
 
 	/* materialise into a list */
+	if (archlist != NULL)
+		free(archlist);
 	list_set(archs, &archlist);
 
 	fclose(fp);
@@ -970,30 +695,51 @@ qcache_load_arches(const char *overlay)
 	free(filename);
 }
 
-/*
- * int qcache_free();
- *
- * Deallocate variables (archlist)
- */
-static void
-qcache_free(void)
+static int
+qcache_traverse(cache_pkg_cb func, void *priv)
 {
-	free(archlist);
-	free_set(archs);
-}
+	int ret;
+	size_t n;
+	const char *overlay;
+	qcache_data *data = (qcache_data *)priv;
 
-/********************************************************************/
-/* main                                                             */
-/********************************************************************/
+	/* Preload all the arches. Not entirely correctly (as arches are bound
+	 * to overlays if set), but oh well. */
+	array_for_each(overlays, n, overlay)
+		qcache_load_arches(overlay);
+
+	/* allocate memory (once) for the list used by various funcs */
+	if (archlist_count > data->keywordsbuflen) {
+		data->keywordsbuf = xrealloc(data->keywordsbuf,
+				archlist_count * sizeof(data->keywordsbuf[0]));
+		data->keywordsbuflen = archlist_count;
+	}
+
+	qcache_test_arch = decode_arch(data->arch);
+	if (qcache_test_arch == -1)
+		return EXIT_FAILURE;
+
+	data->runfunc = func;
+	ret = 0;
+	array_for_each(overlays, n, overlay)
+		ret |= cache_foreach_pkg_sorted(portroot, overlay,
+				qcache_results_cb, priv, NULL, qcache_vercmp);
+
+	return ret;
+}
 
 int qcache_main(int argc, char **argv)
 {
-	int i, action = 0;
+	int i;
+	char action = '\0';
+	qcache_data data;
+	char *pkg = NULL;
+	char *cat = NULL;
 
 	while ((i = GETOPT_LONG(QCACHE, qcache, "")) != -1) {
 		switch (i) {
-			case 'p': qcache_matchpkg = optarg; break;
-			case 'c': qcache_matchcat = optarg; break;
+			case 'p': pkg = optarg; break;
+			case 'c': cat = optarg; break;
 			case 'i':
 			case 'd':
 			case 't':
@@ -1010,22 +756,56 @@ int qcache_main(int argc, char **argv)
 		}
 	}
 
+	data.arch = NULL;
 	if (optind < argc)
-		qcache_test_arch = decode_arch(argv[optind]);
+		data.arch = argv[optind];
 
-	if ((qcache_test_arch == -1 && action != 's') || optind + 1 < argc)
+	if ((data.arch == NULL && action != 's') || optind + 1 < argc)
 		qcache_usage(EXIT_FAILURE);
 
+	if (cat != NULL) {
+		char buf[_Q_PATH_MAX];
+
+		snprintf(buf, sizeof(buf), "%s/%s", cat, pkg == NULL ? "" : pkg);
+		data.qatom = atom_explode(buf);
+		if (data.qatom == NULL) {
+			warnf("invalid cat/pkg: %s\n", buf);
+			return EXIT_FAILURE;
+		}
+	} else if (pkg != NULL) {
+		data.qatom = atom_explode(pkg);
+		if (data.qatom == NULL) {
+			warnf("invalid pkg: %s\n", pkg);
+			return EXIT_FAILURE;
+		}
+	} else {
+		data.qatom = NULL;
+	}
+
+	archs = create_set();
+	data.lastatom = NULL;
+	data.keywordsbuf = NULL;
+	data.keywordsbuflen = 0;
+
 	switch (action) {
-		case 'i': return qcache_traverse(qcache_imlate);
-		case 'd': return qcache_traverse(qcache_dropped);
-		case 't': return qcache_traverse(qcache_testing_only);
-		case 's': return qcache_traverse(qcache_stats);
-		case 'a': return qcache_traverse(qcache_all);
-		case 'n': return qcache_traverse(qcache_not);
+		case 'i': i = qcache_traverse(qcache_imlate, &data);          break;
+		case 'd': i = qcache_traverse(qcache_dropped, &data);
+				  i = qcache_dropped(NULL, NULL);                     break;
+		case 't': i = qcache_traverse(qcache_testing_only, &data);
+				  i = qcache_testing_only(NULL, NULL);                break;
+		case 's': data.arch = "amd64";  /* doesn't matter, need to be set */
+				  i = qcache_traverse(qcache_stats, &data);
+				  i = qcache_stats(NULL, NULL);                       break;
+		case 'a': i = qcache_traverse(qcache_all, &data);             break;
+		case 'n': i = qcache_traverse(qcache_not, &data);             break;
+		default:  i = -2;                                             break;
 	}
 
-	qcache_free();
-	qcache_usage(EXIT_FAILURE);
-	return EXIT_FAILURE;
+	if (data.qatom != NULL)
+		atom_implode(data.qatom);
+	free(archlist);
+	free_set(archs);
+	if (i == -2)
+		qcache_usage(EXIT_FAILURE);
+	return i;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-04-14 10:52 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-04-14 10:52 UTC (permalink / raw
  To: gentoo-commits

commit:     4d8a3a30768248aa083f1198dba491bafe9b1444
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 14 10:51:47 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Apr 14 10:51:47 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4d8a3a30

build: cleanup Makfile preparing for dist

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 Makefile.am       | 335 ++++++++++--------------------------------------------
 Makefile.in       | 194 +++++++++++--------------------
 include_applets.h |  17 ---
 3 files changed, 123 insertions(+), 423 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index a9eba56..5a9d55d 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,12 +1,59 @@
 ACLOCAL_AMFLAGS = -I autotools/m4
 
-SUBDIRS = autotools/gnulib libq
+SUBDIRS = \
+	autotools/gnulib \
+	libq \
+	tests/atom_explode \
+	tests/copy_file \
+	tests/mkdir \
+	tests/rmspace \
+	$(NULL)
 
 portagedir = $(sysconfdir)/portage
 postsyncddir = $(portagedir)/repo.postsync.d
 
 dist_postsyncd_SCRIPTS = repo.postsync/q-reinit
 
+APPLETS = \
+	q \
+	qatom \
+	qcache \
+	qcheck \
+	qdepends \
+	qfile \
+	qgrep \
+	qlist \
+	qlop \
+	qmerge \
+	qpkg \
+	qsearch \
+	qsize \
+	qtbz2 \
+	qtegrity \
+	quse \
+	qxpak \
+	$(NULL)
+
+dist_man_MANS = \
+	man/q.1 \
+	man/qatom.1 \
+	man/qcache.1 \
+	man/qcheck.1 \
+	man/qdepends.1 \
+	man/qfile.1 \
+	man/qgrep.1 \
+	man/qlist.1 \
+	man/qlop.1 \
+	man/qmerge.1 \
+	man/qpkg.1 \
+	man/qsearch.1 \
+	man/qsize.1 \
+	man/qtbz2.1 \
+	man/qtegrity.1 \
+	man/quse.1 \
+	man/qxpak.1 \
+	$(NULL)
+
 bin_PROGRAMS = q
 q_SOURCES = \
 	main.c \
@@ -26,22 +73,25 @@ q_SOURCES = \
 	qtbz2.c \
 	qtegrity.c \
 	quse.c \
-	qxpak.c
+	qxpak.c \
+	$(NULL)
 q_CPPFLAGS = \
 	-I$(top_srcdir)/libq \
 	-I$(top_builddir)/autotools/gnulib \
-	-I$(top_srcdir)/autotools/gnulib
+	-I$(top_srcdir)/autotools/gnulib \
+	$(NULL)
 q_LDADD = \
 	$(top_builddir)/libq/libq.la \
 	$(top_builddir)/autotools/gnulib/libgnu.a \
 	-liniparser \
 	$(LIB_CLOCK_GETTIME) \
-	$(LIB_EACCESS)
+	$(LIB_EACCESS) \
+	$(NULL)
 
 install-exec-hook:
 	cd $(DESTDIR)$(bindir); \
 	for applet in $(APPLETS) ; do \
-		[ ! -e "$$applet" ] && ln -s q $${applet} ; \
+		[ ! -e "$${applet}" ] && $(LN_S) q $${applet} ; \
 	done
 
 TMAKE = \
@@ -55,275 +105,8 @@ clean-local:
 	rm -f $(APPLETS)
 check: check-hook
 
-# Start off with base values which we append below
-dist_man_MANS =
-APPLETS =
-EXTRA_DIST = autotools/m4/gnulib-cache.m4
-
-# @@@ GEN START @@@ #
-q_CPPFLAGS += \
-	-DAPPLET_q \
-	-DAPPLET_qatom \
-	-DAPPLET_qcache \
-	-DAPPLET_qcheck \
-	-DAPPLET_qdepends \
-	-DAPPLET_qfile \
-	-DAPPLET_qgrep \
-	-DAPPLET_qlist \
-	-DAPPLET_qlop \
-	-DAPPLET_qmerge \
-	-DAPPLET_qpkg \
-	-DAPPLET_qsearch \
-	-DAPPLET_qsize \
-	-DAPPLET_qtbz2 \
-	-DAPPLET_qtegrity \
-	-DAPPLET_quse \
-	-DAPPLET_qxpak
-dist_man_MANS += \
-	man/q.1 \
-	man/qatom.1 \
-	man/qcache.1 \
-	man/qcheck.1 \
-	man/qdepends.1 \
-	man/qfile.1 \
-	man/qgrep.1 \
-	man/qlist.1 \
-	man/qlop.1 \
-	man/qmerge.1 \
-	man/qpkg.1 \
-	man/qsearch.1 \
-	man/qsize.1 \
-	man/qtbz2.1 \
-	man/qtegrity.1 \
-	man/quse.1 \
-	man/qxpak.1
-APPLETS += \
-	q \
-	qatom \
-	qcache \
-	qcheck \
-	qdepends \
-	qfile \
-	qgrep \
-	qlist \
-	qlop \
-	qmerge \
-	qpkg \
-	qsearch \
-	qsize \
-	qtbz2 \
-	qtegrity \
-	quse \
-	qxpak
-EXTRA_DIST += \
+EXTRA_DIST = \
+	autotools/m4/gnulib-cache.m4 \
 	applets.h \
-	config.h \
-	include_applets.h \
-	libq/atom_compare.c \
-	libq/atom_explode.c \
-	libq/basename.c \
-	libq/busybox.h \
-	libq/colors.c \
-	libq/copy_file.c \
-	libq/hash_fd.c \
-	libq/human_readable.c \
-	libq/i18n.h \
-	libq/libq.c \
-	libq/libq.h \
-	libq/md5_sha1_sum.c \
-	libq/prelink.c \
-	libq/profile.c \
-	libq/rmspace.c \
-	libq/safe_io.c \
-	libq/scandirat.c \
-	libq/set.c \
-	libq/vdb.c \
-	libq/vdb_get_next_dir.c \
-	libq/xarray.c \
-	libq/xasprintf.c \
-	libq/xchdir.c \
-	libq/xmalloc.c \
-	libq/xmkdir.c \
-	libq/xregex.c \
-	libq/xsystem.c \
-	main.c \
-	main.h \
-	porting.h \
-	q.c \
-	qatom.c \
-	qcache.c \
-	qcheck.c \
-	qdepends.c \
-	qfile.c \
-	qglsa.c \
-	qgrep.c \
-	qlist.c \
-	qlop.c \
-	qmerge.c \
-	qpkg.c \
-	qsearch.c \
-	qsize.c \
-	qtbz2.c \
-	qtegrity.c \
-	quse.c \
-	qxpak.c \
-	tests/Makefile \
-	tests/atom_compare/.gitignore \
-	tests/atom_compare/Makefile \
-	tests/atom_compare/atom-compare.py \
-	tests/atom_compare/static.good \
-	tests/atom_compare/static.q.good \
-	tests/atom_compare/static.q.tests \
-	tests/atom_compare/static.tests \
-	tests/atom_explode/.gitignore \
-	tests/atom_explode/Makefile \
-	tests/atom_explode/atom-explode.py \
-	tests/atom_explode/basic.good \
-	tests/atom_explode/basic.tests \
-	tests/atom_explode/dotest \
-	tests/atom_explode/ebuildlist.xz \
-	tests/atom_explode/portageatoms.xz \
-	tests/atom_explode/test.c \
-	tests/copy_file/.gitignore \
-	tests/copy_file/Makefile \
-	tests/copy_file/dotest \
-	tests/copy_file/test.c \
-	tests/init.sh \
-	tests/install/.gitignore \
-	tests/install/Makefile \
-	tests/install/dotest \
-	tests/mkdir/.gitignore \
-	tests/mkdir/Makefile \
-	tests/mkdir/dotest \
-	tests/mkdir/test.c \
-	tests/profile/Makefile \
-	tests/profile/dotest \
-	tests/profile/profile1/etc/parent.conf \
-	tests/profile/profile1/etc/portage/make.conf \
-	tests/profile/profile1/etc/portage/subdir/file.conf \
-	tests/profile/profile1/etc/portage/this.level.conf \
-	tests/qatom/Makefile \
-	tests/qatom/dotest \
-	tests/qcheck/Makefile \
-	tests/qcheck/dotest \
-	tests/qcheck/list01.good \
-	tests/qcheck/list02.good \
-	tests/qcheck/list03.good \
-	tests/qcheck/list04.good \
-	tests/qcheck/list05.good \
-	tests/qcheck/list06.good \
-	tests/qcheck/list07.good \
-	tests/qcheck/list08.good \
-	tests/qcheck/list09.good \
-	tests/qcheck/root/a-b/pkg-1.0/CONTENTS \
-	tests/qcheck/root/a-b/pkg-1.0/SLOT \
-	tests/qcheck/root/a-b/pkg-1.0/repository \
-	tests/qcheck/root/bin/bad-md5 \
-	tests/qcheck/root/bin/bad-mtime \
-	tests/qcheck/root/bin/bad-mtime-obj \
-	tests/qcheck/root/bin/bad-sha1 \
-	tests/qcheck/root/bin/good-md5 \
-	tests/qcheck/root/bin/good-sha1 \
-	tests/qcheck/root/cat/pkg-1/CONTENTS \
-	tests/qcheck/root/cat/pkg-1/SLOT \
-	tests/qcheck/root/cat/pkg-1/repository \
-	tests/qdepends/Makefile \
-	tests/qdepends/dotest \
-	tests/qdepends/list01.good \
-	tests/qdepends/list02.good \
-	tests/qdepends/list03.good \
-	tests/qdepends/list04.good \
-	tests/qdepends/list05.good \
-	tests/qdepends/list06.good \
-	tests/qdepends/list07.good \
-	tests/qdepends/list08.good \
-	tests/qdepends/root/app-arch/cpio-2.11/CONTENTS \
-	tests/qdepends/root/app-arch/cpio-2.11/SLOT \
-	tests/qdepends/root/app-arch/cpio-2.11/repository \
-	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/DEPEND \
-	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/RDEPEND \
-	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/USE \
-	tests/qfile/Makefile \
-	tests/qfile/dotest \
-	tests/qlist/Makefile \
-	tests/qlist/dotest \
-	tests/qlist/list01.good \
-	tests/qlist/list02.good \
-	tests/qlist/list03.good \
-	tests/qlist/list04.good \
-	tests/qlist/list05.good \
-	tests/qlist/list06.good \
-	tests/qlist/list07.good \
-	tests/qlist/list08.good \
-	tests/qlist/list09.good \
-	tests/qlist/list10.good \
-	tests/qlist/list11.good \
-	tests/qlist/list12.good \
-	tests/qlist/list13.good \
-	tests/qlist/list14.good \
-	tests/qlist/list15.good \
-	tests/qlist/list16.good \
-	tests/qlist/root/-merge-foo/CONTENTS \
-	tests/qlist/root/a-b/a-0/CONTENTS \
-	tests/qlist/root/a-b/a-0/SLOT \
-	tests/qlist/root/a-b/a-0/repository \
-	tests/qlist/root/a-b/b-0/CONTENTS \
-	tests/qlist/root/a-b/b-0/SLOT \
-	tests/qlist/root/a-b/b-0/repository \
-	tests/qlist/root/app-arch/cpio-2.11/CONTENTS \
-	tests/qlist/root/app-arch/cpio-2.11/SLOT \
-	tests/qlist/root/app-arch/cpio-2.11/repository \
-	tests/qlist/root/cat/pkg-1/CONTENTS \
-	tests/qlist/root/cat/pkg-1/SLOT \
-	tests/qlist/root/cat/pkg-1/repository \
-	tests/qlist/root/cat/sub-2/CONTENTS \
-	tests/qlist/root/cat/sub-2/SLOT \
-	tests/qlist/root/cat/sub-2/repository \
-	tests/qlist/root/sys-fs/mtools-4.0.13/CONTENTS \
-	tests/qlist/root/sys-fs/mtools-4.0.13/SLOT \
-	tests/qlist/root/sys-fs/mtools-4.0.13/repository \
-	tests/qlop/Makefile \
-	tests/qlop/aborts.log \
-	tests/qlop/dotest \
-	tests/qlop/list01.good \
-	tests/qlop/list02.good \
-	tests/qlop/list03.good \
-	tests/qlop/list04.good \
-	tests/qlop/list05.good \
-	tests/qlop/list06.good \
-	tests/qlop/list07.good \
-	tests/qlop/list08.good \
-	tests/qlop/list09.good \
-	tests/qlop/sync.log \
-	tests/qlop/test04.good \
-	tests/qmerge/Makefile \
-	tests/qmerge/dotest \
-	tests/qmerge/packages/Packages \
-	tests/qmerge/packages/sys-devel/qmerge-test-1.3.tbz2 \
-	tests/qtbz2/Makefile \
-	tests/qtbz2/dotest \
-	tests/quse/Makefile \
-	tests/quse/dotest \
-	tests/quse/list01.good \
-	tests/quse/portdir/profiles/arch.list \
-	tests/quse/portdir/profiles/desc/elibc.desc \
-	tests/quse/portdir/profiles/desc/one.desc \
-	tests/quse/portdir/profiles/desc/two.desc \
-	tests/quse/portdir/profiles/use.desc \
-	tests/quse/portdir/profiles/use.local.desc \
-	tests/qxpak/Makefile \
-	tests/qxpak/dotest \
-	tests/qxpak/list01.good \
-	tests/qxpak/list02.good \
-	tests/reinitialize/Makefile \
-	tests/reinitialize/dotest \
-	tests/rmspace/.gitignore \
-	tests/rmspace/Makefile \
-	tests/rmspace/dotest \
-	tests/rmspace/test.c \
-	tests/source/Makefile \
-	tests/source/dotest \
-	tests/source/space \
-	tests/subdir.mk \
-	tests/tests.h
-# @@@ GEN START @@@ #
+	tests \
+	$(NULL)

diff --git a/Makefile.in b/Makefile.in
index a014d25..1b37f24 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -1543,10 +1543,58 @@ top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 ACLOCAL_AMFLAGS = -I autotools/m4
-SUBDIRS = autotools/gnulib libq
+SUBDIRS = \
+	autotools/gnulib \
+	libq \
+	tests/atom_explode \
+	tests/copy_file \
+	tests/mkdir \
+	tests/rmspace \
+	$(NULL)
+
 portagedir = $(sysconfdir)/portage
 postsyncddir = $(portagedir)/repo.postsync.d
 dist_postsyncd_SCRIPTS = repo.postsync/q-reinit
+APPLETS = \
+	q \
+	qatom \
+	qcache \
+	qcheck \
+	qdepends \
+	qfile \
+	qgrep \
+	qlist \
+	qlop \
+	qmerge \
+	qpkg \
+	qsearch \
+	qsize \
+	qtbz2 \
+	qtegrity \
+	quse \
+	qxpak \
+	$(NULL)
+
+dist_man_MANS = \
+	man/q.1 \
+	man/qatom.1 \
+	man/qcache.1 \
+	man/qcheck.1 \
+	man/qdepends.1 \
+	man/qfile.1 \
+	man/qgrep.1 \
+	man/qlist.1 \
+	man/qlop.1 \
+	man/qmerge.1 \
+	man/qpkg.1 \
+	man/qsearch.1 \
+	man/qsize.1 \
+	man/qtbz2.1 \
+	man/qtegrity.1 \
+	man/quse.1 \
+	man/qxpak.1 \
+	$(NULL)
+
 q_SOURCES = \
 	main.c \
 	q.c \
@@ -1565,147 +1613,34 @@ q_SOURCES = \
 	qtbz2.c \
 	qtegrity.c \
 	quse.c \
-	qxpak.c
+	qxpak.c \
+	$(NULL)
 
+q_CPPFLAGS = \
+	-I$(top_srcdir)/libq \
+	-I$(top_builddir)/autotools/gnulib \
+	-I$(top_srcdir)/autotools/gnulib \
+	$(NULL)
 
-# @@@ GEN START @@@ #
-q_CPPFLAGS = -I$(top_srcdir)/libq -I$(top_builddir)/autotools/gnulib \
-	-I$(top_srcdir)/autotools/gnulib -DAPPLET_q -DAPPLET_qatom \
-	-DAPPLET_qcache -DAPPLET_qcheck -DAPPLET_qdepends \
-	-DAPPLET_qfile -DAPPLET_qgrep -DAPPLET_qlist -DAPPLET_qlop \
-	-DAPPLET_qmerge -DAPPLET_qpkg -DAPPLET_qsearch -DAPPLET_qsize \
-	-DAPPLET_qtbz2 -DAPPLET_qtegrity -DAPPLET_quse -DAPPLET_qxpak
 q_LDADD = \
 	$(top_builddir)/libq/libq.la \
 	$(top_builddir)/autotools/gnulib/libgnu.a \
 	-liniparser \
 	$(LIB_CLOCK_GETTIME) \
-	$(LIB_EACCESS)
+	$(LIB_EACCESS) \
+	$(NULL)
 
 TMAKE = \
 	$(MAKE) -C $(abs_top_srcdir)/tests \
 		abs_top_builddir="$(abs_top_builddir)" \
 		abs_top_srcdir="$(abs_top_srcdir)"
 
+EXTRA_DIST = \
+	autotools/m4/gnulib-cache.m4 \
+	applets.h \
+	tests \
+	$(NULL)
 
-# Start off with base values which we append below
-dist_man_MANS = man/q.1 man/qatom.1 man/qcache.1 man/qcheck.1 \
-	man/qdepends.1 man/qfile.1 man/qgrep.1 man/qlist.1 man/qlop.1 \
-	man/qmerge.1 man/qpkg.1 man/qsearch.1 man/qsize.1 man/qtbz2.1 \
-	man/qtegrity.1 man/quse.1 man/qxpak.1
-APPLETS = q qatom qcache qcheck qdepends qfile qgrep qlist qlop qmerge \
-	qpkg qsearch qsize qtbz2 qtegrity quse qxpak
-EXTRA_DIST = autotools/m4/gnulib-cache.m4 applets.h config.h \
-	include_applets.h libq/atom_compare.c libq/atom_explode.c \
-	libq/basename.c libq/busybox.h libq/colors.c libq/copy_file.c \
-	libq/hash_fd.c libq/human_readable.c libq/i18n.h libq/libq.c \
-	libq/libq.h libq/md5_sha1_sum.c libq/prelink.c libq/profile.c \
-	libq/rmspace.c libq/safe_io.c libq/scandirat.c libq/set.c \
-	libq/vdb.c libq/vdb_get_next_dir.c libq/xarray.c \
-	libq/xasprintf.c libq/xchdir.c libq/xmalloc.c libq/xmkdir.c \
-	libq/xregex.c libq/xsystem.c main.c main.h porting.h q.c \
-	qatom.c qcache.c qcheck.c qdepends.c qfile.c qglsa.c qgrep.c \
-	qlist.c qlop.c qmerge.c qpkg.c qsearch.c qsize.c qtbz2.c \
-	qtegrity.c quse.c qxpak.c tests/Makefile \
-	tests/atom_compare/.gitignore tests/atom_compare/Makefile \
-	tests/atom_compare/atom-compare.py \
-	tests/atom_compare/static.good \
-	tests/atom_compare/static.q.good \
-	tests/atom_compare/static.q.tests \
-	tests/atom_compare/static.tests tests/atom_explode/.gitignore \
-	tests/atom_explode/Makefile tests/atom_explode/atom-explode.py \
-	tests/atom_explode/basic.good tests/atom_explode/basic.tests \
-	tests/atom_explode/dotest tests/atom_explode/ebuildlist.xz \
-	tests/atom_explode/portageatoms.xz tests/atom_explode/test.c \
-	tests/copy_file/.gitignore tests/copy_file/Makefile \
-	tests/copy_file/dotest tests/copy_file/test.c tests/init.sh \
-	tests/install/.gitignore tests/install/Makefile \
-	tests/install/dotest tests/mkdir/.gitignore \
-	tests/mkdir/Makefile tests/mkdir/dotest tests/mkdir/test.c \
-	tests/profile/Makefile tests/profile/dotest \
-	tests/profile/profile1/etc/parent.conf \
-	tests/profile/profile1/etc/portage/make.conf \
-	tests/profile/profile1/etc/portage/subdir/file.conf \
-	tests/profile/profile1/etc/portage/this.level.conf \
-	tests/qatom/Makefile tests/qatom/dotest tests/qcheck/Makefile \
-	tests/qcheck/dotest tests/qcheck/list01.good \
-	tests/qcheck/list02.good tests/qcheck/list03.good \
-	tests/qcheck/list04.good tests/qcheck/list05.good \
-	tests/qcheck/list06.good tests/qcheck/list07.good \
-	tests/qcheck/list08.good tests/qcheck/list09.good \
-	tests/qcheck/root/a-b/pkg-1.0/CONTENTS \
-	tests/qcheck/root/a-b/pkg-1.0/SLOT \
-	tests/qcheck/root/a-b/pkg-1.0/repository \
-	tests/qcheck/root/bin/bad-md5 tests/qcheck/root/bin/bad-mtime \
-	tests/qcheck/root/bin/bad-mtime-obj \
-	tests/qcheck/root/bin/bad-sha1 tests/qcheck/root/bin/good-md5 \
-	tests/qcheck/root/bin/good-sha1 \
-	tests/qcheck/root/cat/pkg-1/CONTENTS \
-	tests/qcheck/root/cat/pkg-1/SLOT \
-	tests/qcheck/root/cat/pkg-1/repository tests/qdepends/Makefile \
-	tests/qdepends/dotest tests/qdepends/list01.good \
-	tests/qdepends/list02.good tests/qdepends/list03.good \
-	tests/qdepends/list04.good tests/qdepends/list05.good \
-	tests/qdepends/list06.good tests/qdepends/list07.good \
-	tests/qdepends/list08.good \
-	tests/qdepends/root/app-arch/cpio-2.11/CONTENTS \
-	tests/qdepends/root/app-arch/cpio-2.11/SLOT \
-	tests/qdepends/root/app-arch/cpio-2.11/repository \
-	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/DEPEND \
-	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/RDEPEND \
-	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/USE \
-	tests/qfile/Makefile tests/qfile/dotest tests/qlist/Makefile \
-	tests/qlist/dotest tests/qlist/list01.good \
-	tests/qlist/list02.good tests/qlist/list03.good \
-	tests/qlist/list04.good tests/qlist/list05.good \
-	tests/qlist/list06.good tests/qlist/list07.good \
-	tests/qlist/list08.good tests/qlist/list09.good \
-	tests/qlist/list10.good tests/qlist/list11.good \
-	tests/qlist/list12.good tests/qlist/list13.good \
-	tests/qlist/list14.good tests/qlist/list15.good \
-	tests/qlist/list16.good tests/qlist/root/-merge-foo/CONTENTS \
-	tests/qlist/root/a-b/a-0/CONTENTS \
-	tests/qlist/root/a-b/a-0/SLOT \
-	tests/qlist/root/a-b/a-0/repository \
-	tests/qlist/root/a-b/b-0/CONTENTS \
-	tests/qlist/root/a-b/b-0/SLOT \
-	tests/qlist/root/a-b/b-0/repository \
-	tests/qlist/root/app-arch/cpio-2.11/CONTENTS \
-	tests/qlist/root/app-arch/cpio-2.11/SLOT \
-	tests/qlist/root/app-arch/cpio-2.11/repository \
-	tests/qlist/root/cat/pkg-1/CONTENTS \
-	tests/qlist/root/cat/pkg-1/SLOT \
-	tests/qlist/root/cat/pkg-1/repository \
-	tests/qlist/root/cat/sub-2/CONTENTS \
-	tests/qlist/root/cat/sub-2/SLOT \
-	tests/qlist/root/cat/sub-2/repository \
-	tests/qlist/root/sys-fs/mtools-4.0.13/CONTENTS \
-	tests/qlist/root/sys-fs/mtools-4.0.13/SLOT \
-	tests/qlist/root/sys-fs/mtools-4.0.13/repository \
-	tests/qlop/Makefile tests/qlop/aborts.log tests/qlop/dotest \
-	tests/qlop/list01.good tests/qlop/list02.good \
-	tests/qlop/list03.good tests/qlop/list04.good \
-	tests/qlop/list05.good tests/qlop/list06.good \
-	tests/qlop/list07.good tests/qlop/list08.good \
-	tests/qlop/list09.good tests/qlop/sync.log \
-	tests/qlop/test04.good tests/qmerge/Makefile \
-	tests/qmerge/dotest tests/qmerge/packages/Packages \
-	tests/qmerge/packages/sys-devel/qmerge-test-1.3.tbz2 \
-	tests/qtbz2/Makefile tests/qtbz2/dotest tests/quse/Makefile \
-	tests/quse/dotest tests/quse/list01.good \
-	tests/quse/portdir/profiles/arch.list \
-	tests/quse/portdir/profiles/desc/elibc.desc \
-	tests/quse/portdir/profiles/desc/one.desc \
-	tests/quse/portdir/profiles/desc/two.desc \
-	tests/quse/portdir/profiles/use.desc \
-	tests/quse/portdir/profiles/use.local.desc \
-	tests/qxpak/Makefile tests/qxpak/dotest \
-	tests/qxpak/list01.good tests/qxpak/list02.good \
-	tests/reinitialize/Makefile tests/reinitialize/dotest \
-	tests/rmspace/.gitignore tests/rmspace/Makefile \
-	tests/rmspace/dotest tests/rmspace/test.c \
-	tests/source/Makefile tests/source/dotest tests/source/space \
-	tests/subdir.mk tests/tests.h
 all: config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-recursive
 
@@ -2636,7 +2571,7 @@ uninstall-man: uninstall-man1
 install-exec-hook:
 	cd $(DESTDIR)$(bindir); \
 	for applet in $(APPLETS) ; do \
-		[ ! -e "$$applet" ] && ln -s q $${applet} ; \
+		[ ! -e "$${applet}" ] && $(LN_S) q $${applet} ; \
 	done
 check-hook:
 	$(TMAKE) check
@@ -2644,7 +2579,6 @@ clean-local:
 	$(TMAKE) clean
 	rm -f $(APPLETS)
 check: check-hook
-# @@@ GEN START @@@ #
 
 # Tell versions [3.59,3.63) of GNU make to not export all variables.
 # Otherwise a system limit (for SysV at least) may be exceeded.

diff --git a/include_applets.h b/include_applets.h
deleted file mode 100644
index 916e5f7..0000000
--- a/include_applets.h
+++ /dev/null
@@ -1,17 +0,0 @@
-#include "q.c"
-#include "qcheck.c"
-#include "qdepends.c"
-#include "qfile.c"
-#include "qlist.c"
-#include "qlop.c"
-#include "qsearch.c"
-#include "qsize.c"
-#include "qtbz2.c"
-#include "quse.c"
-#include "qxpak.c"
-#include "qpkg.c"
-#include "qgrep.c"
-#include "qatom.c"
-#include "qmerge.c"
-#include "qcache.c"
-#include "qtegrity.c"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-03-27 20:52 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-03-27 20:52 UTC (permalink / raw
  To: gentoo-commits

commit:     8a3e762753c3a17fc74fb56cb11c27d9fec82b2d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 27 20:52:12 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Mar 27 20:52:12 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8a3e7627

q: silence warning on Darwin

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 q.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/q.c b/q.c
index 1e180de..d50056a 100644
--- a/q.c
+++ b/q.c
@@ -15,6 +15,10 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 
+#if defined(__MACH__)
+#include <libproc.h>
+#endif
+
 #include "atom.h"
 #include "basename.h"
 #include "cache.h"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-03-27 20:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-03-27 20:37 UTC (permalink / raw
  To: gentoo-commits

commit:     5afa37bd046ea35d9c68f43a1a28233bd0dbc7a7
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 27 20:36:39 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Mar 27 20:36:39 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5afa37bd

qgrep: squash truncation warning on Solaris

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qgrep.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/qgrep.c b/qgrep.c
index fdabf9c..a2b6a98 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -449,6 +449,7 @@ int qgrep_main(int argc, char **argv)
 				if ((p = strchr(ebuild, '\n')) != NULL)
 					*p = '\0';
 				if (show_name || (include_atoms != NULL)) {
+					size_t l;
 					/* cut ".ebuild" */
 					if (p == NULL)
 						p = ebuild + strlen(ebuild);
@@ -460,8 +461,11 @@ int qgrep_main(int argc, char **argv)
 					/* find head of the ebuild basename */
 					if ((p = strchr(p, '/')) == NULL)
 						continue;
-					/* find	start of the pkg name */
-					snprintf(name, sizeof(name), "%s/%s", ebuild, (p+1));
+					/* find	start of the pkg name, break up in two to
+					 * avoid warning about possible truncation (very
+					 * unlikely) */
+					l = snprintf(name, sizeof(name), "%s", ebuild);
+					snprintf(name + l, sizeof(name) - l, "%s", p);
 					/* restore the filepath */
 					*p = '/';
 					*(p + strlen(p)) = '.';


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-03-27 20:18 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-03-27 20:18 UTC (permalink / raw
  To: gentoo-commits

commit:     8313efaff478fdec6b736a6cdef31e37ce00be9c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Mar 27 19:40:46 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Mar 27 19:40:46 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8313efaf

configure: ignore expansion undefined warnings for gnulib

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 configure    | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 configure.ac |  5 ++++
 2 files changed, 80 insertions(+)

diff --git a/configure b/configure
index e538b3e..ec5426d 100755
--- a/configure
+++ b/configure
@@ -34929,6 +34929,81 @@ else
 fi
 
 
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wno-format-nonliteral" >&5
+$as_echo_n "checking whether C compiler accepts -Wno-format-nonliteral... " >&6; }
+if ${ax_cv_check_cflags___Wno_format_nonliteral+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  ax_check_save_flags=$CFLAGS
+  CFLAGS="$CFLAGS  -Wno-format-nonliteral"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ax_cv_check_cflags___Wno_format_nonliteral=yes
+else
+  ax_cv_check_cflags___Wno_format_nonliteral=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  CFLAGS=$ax_check_save_flags
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wno_format_nonliteral" >&5
+$as_echo "$ax_cv_check_cflags___Wno_format_nonliteral" >&6; }
+if test "x$ax_cv_check_cflags___Wno_format_nonliteral" = xyes; then :
+  as_fn_append CFLAGS " -Wno-format-nonliteral"
+else
+  :
+fi
+
+
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether C compiler accepts -Wno-expansion-to-defined" >&5
+$as_echo_n "checking whether C compiler accepts -Wno-expansion-to-defined... " >&6; }
+if ${ax_cv_check_cflags___Wno_expansion_to_defined+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  ax_check_save_flags=$CFLAGS
+  CFLAGS="$CFLAGS  -Wno-expansion-to-defined"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ax_cv_check_cflags___Wno_expansion_to_defined=yes
+else
+  ax_cv_check_cflags___Wno_expansion_to_defined=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  CFLAGS=$ax_check_save_flags
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cflags___Wno_expansion_to_defined" >&5
+$as_echo "$ax_cv_check_cflags___Wno_expansion_to_defined" >&6; }
+if test "x$ax_cv_check_cflags___Wno_expansion_to_defined" = xyes; then :
+  as_fn_append CFLAGS " -Wno-expansion-to-defined"
+else
+  :
+fi
+
+
+# gnulib triggers this a lot, just to silence:
+# -Wno-format-nonliteral
+# -Wno-expansion-to-defined
 
 ac_config_files="$ac_config_files Makefile libq/Makefile autotools/gnulib/Makefile tests/atom_explode/Makefile tests/copy_file/Makefile tests/mkdir/Makefile tests/rmspace/Makefile"
 

diff --git a/configure.ac b/configure.ac
index c7f6e69..902071d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -46,9 +46,14 @@ m4_foreach_w([flag], [
 	-Wsequence-point
 	-Wold-style-definition
 	-Wextra
+	-Wno-format-nonliteral
+	-Wno-expansion-to-defined
 ], [
 	AX_CHECK_COMPILE_FLAG(flag, AS_VAR_APPEND([CFLAGS], " flag"))
 ])
+# gnulib triggers this a lot, just to silence:
+# -Wno-format-nonliteral
+# -Wno-expansion-to-defined
 
 AC_CONFIG_FILES([
 	Makefile


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-03-18 13:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-03-18 13:14 UTC (permalink / raw
  To: gentoo-commits

commit:     dca70b24386de8b484a6b62f36e7c2cb55bfbcb9
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 15 14:00:08 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 15 14:00:08 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=dca70b24

main.h: drop DEFAULT_PORTAGE_BINHOST setup

tinderbox.dev.gentoo.org albeit being still around is very outdated, so
very unlikely to be useful

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.h | 64 ++--------------------------------------------------------------
 1 file changed, 2 insertions(+), 62 deletions(-)

diff --git a/main.h b/main.h
index 0776f2a..c409057 100644
--- a/main.h
+++ b/main.h
@@ -1,9 +1,10 @@
 /*
- * Copyright 2005-2018 Gentoo Foundation
+ * Copyright 2005-2019 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2014 Mike Frysinger  - <vapier@gentoo.org>
+ * Copyright 2019-     Fabian Groffen  - <grobian@gentoo.org>
  */
 
 /* make sure our buffers are as big as they can be */
@@ -13,67 +14,6 @@
 # define _Q_PATH_MAX _POSIX_PATH_MAX
 #endif
 
-/* http://tinderbox.dev.gentoo.org/default-linux/arm */
-/* http://tinderbox.dev.gentoo.org/default-linux/hppa */
-
-#ifdef __linux__
-# undef URL_BASE
-# define URL_BASE "http://tinderbox.dev.gentoo.org"
-
-# undef URL_PROFILE
-# ifdef __UCLIBC__
-#  define URL_PROFILE "uclibc"
-# else
-#  ifdef __SSP__
-#   define URL_PROFILE "hardened"
-#  else
-#   define URL_PROFILE "default/linux"
-#  endif
-# endif
-
-# undef URL_ARCH
-# if 0
-# elif defined(__alpha__)
-#  define URL_ARCH "alpha"
-# elif defined(__x86_64__)
-#  define URL_ARCH "amd64"
-# elif defined(__arm__)
-#  define URL_ARCH "arm"
-# elif defined(__aarch64__)
-#  define URL_ARCH "arm64"
-# elif defined(__bfin__)
-#  define URL_ARCH "bfin"
-# elif defined(__cris__)
-#  define URL_ARCH "cris"
-# elif defined(__hppa__)
-#  define URL_ARCH "hppa"
-# elif defined(__ia64__)
-#  define URL_ARCH "ia64"
-# elif defined(__m68k__)
-#  define URL_ARCH "m68k"
-# elif defined(__mips__)
-#  define URL_ARCH "mips"
-# elif defined(__powerpc__)
-#  if defined(__powerpc64__)
-#   define URL_ARCH "ppc64"
-#  else
-#   define URL_ARCH "ppc"
-#  endif
-# elif defined(__s390__)
-#  define URL_ARCH "s390"
-# elif defined(__sh__)
-#  define URL_ARCH "sh"
-# elif defined(__sparc__)
-#  define URL_ARCH "sparc"
-# elif defined(__i386__)
-#  define URL_ARCH "x86"
-# endif
-
-# if defined(URL_PROFILE) && defined(URL_ARCH)
-#  define DEFAULT_PORTAGE_BINHOST URL_BASE "/" URL_PROFILE "/" URL_ARCH
-# endif
-#endif
-
 #ifndef DEFAULT_PORTAGE_BINHOST
 # define DEFAULT_PORTAGE_BINHOST ""
 #endif


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-03-18 13:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-03-18 13:14 UTC (permalink / raw
  To: gentoo-commits

commit:     4d2a9d4b6e7fe431c2f257323bc902b347a943c1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 15 14:01:37 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 15 14:01:37 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4d2a9d4b

porting.h: move iniparser include to its only consumer

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c    | 4 +++-
 porting.h | 2 --
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/main.c b/main.c
index 4bc9130..5a47b0c 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2018 Gentoo Foundation
+ * Copyright 2005-2019 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2008 Ned Ludd        - <solar@gentoo.org>
@@ -9,6 +9,8 @@
 #include "porting.h"
 #include "main.h"
 
+#include <iniparser.h>
+
 /* prototypes and such */
 static bool eat_file(const char *, char **, size_t *);
 static bool eat_file_fd(int, char **, size_t *);

diff --git a/porting.h b/porting.h
index 97a45c7..41baa7a 100644
--- a/porting.h
+++ b/porting.h
@@ -50,8 +50,6 @@
 #include <sys/time.h>
 #include <sys/types.h>
 
-#include <iniparser.h>
-
 #if defined(__MACH__)
 #include <libproc.h>
 #endif


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-03-18 13:14 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-03-18 13:14 UTC (permalink / raw
  To: gentoo-commits

commit:     43d8c0998aafc279cdfdb18c715ae945e945138a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 15 14:02:55 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 15 14:02:55 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=43d8c099

q.c: move run_applet_l to its only consumer qmerge.c

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 q.c      | 45 ++++-----------------------------------------
 qmerge.c | 40 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 44 insertions(+), 41 deletions(-)

diff --git a/q.c b/q.c
index 64aa284..30a295d 100644
--- a/q.c
+++ b/q.c
@@ -87,7 +87,8 @@ int q_main(int argc, char **argv)
 		case 'M': modpath = optarg; break;
 		case 'm':
 			if (optarg) {
-				const char *path = initialize_flat(optarg, CACHE_METADATA, true);
+				const char *path =
+					initialize_flat(optarg, CACHE_METADATA, true);
 				if (USE_CLEANUP)
 					free((void *)path);
 				reinitialize_metacache = -1;
@@ -149,7 +150,8 @@ int q_main(int argc, char **argv)
 		for (i = 1; applets[i].desc; ++i) {
 			int r = symlinkat(prog, fd, applets[i].name);
 			if (!quiet)
-				printf(" %s ...\t[%s]\n", applets[i].name, r ? strerror(errno) : "OK");
+				printf(" %s ...\t[%s]\n",
+						applets[i].name, r ? strerror(errno) : "OK");
 			if (r && errno != EEXIST)
 				ret = 1;
 		}
@@ -184,42 +186,3 @@ int q_main(int argc, char **argv)
 	return (func)(argc - 1, argv);
 }
 
-static int run_applet_l(const char *arg, ...)
-{
-	int (*applet)(int, char **);
-	va_list ap;
-	int ret, optind_saved, argc;
-	char **argv;
-	const char *argv0_saved;
-
-	optind_saved = optind;
-	argv0_saved = argv0;
-
-	applet = lookup_applet(arg);
-	if (!applet)
-		return -1;
-
-	/* This doesn't NULL terminate argv, but you should be using argc */
-	va_start(ap, arg);
-	argc = 0;
-	argv = NULL;
-	while (arg) {
-		argv = xrealloc(argv, sizeof(*argv) * ++argc);
-		argv[argc - 1] = xstrdup(arg);
-		arg = va_arg(ap, const char *);
-	}
-	va_end(ap);
-
-	optind = 0;
-	argv0 = argv[0];
-	ret = applet(argc, argv);
-
-	while (argc--)
-		free(argv[argc]);
-	free(argv);
-
-	optind = optind_saved;
-	argv0 = argv0_saved;
-
-	return ret;
-}

diff --git a/qmerge.c b/qmerge.c
index aec51be..c90f786 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -105,6 +105,46 @@ static int pkg_unmerge(q_vdb_pkg_ctx *, set *, int, char **, int, char **);
 static struct pkg_t *grab_binpkg_info(const char *);
 static char *find_binpkg(const char *);
 
+static int run_applet_l(const char *arg, ...)
+{
+	int (*applet)(int, char **);
+	va_list ap;
+	int ret, optind_saved, argc;
+	char **argv;
+	const char *argv0_saved;
+
+	optind_saved = optind;
+	argv0_saved = argv0;
+
+	applet = lookup_applet(arg);
+	if (!applet)
+		return -1;
+
+	/* This doesn't NULL terminate argv, but you should be using argc */
+	va_start(ap, arg);
+	argc = 0;
+	argv = NULL;
+	while (arg) {
+		argv = xrealloc(argv, sizeof(*argv) * ++argc);
+		argv[argc - 1] = xstrdup(arg);
+		arg = va_arg(ap, const char *);
+	}
+	va_end(ap);
+
+	optind = 0;
+	argv0 = argv[0];
+	ret = applet(argc, argv);
+
+	while (argc--)
+		free(argv[argc]);
+	free(argv);
+
+	optind = optind_saved;
+	argv0 = argv0_saved;
+
+	return ret;
+}
+
 static void
 fetch(const char *destdir, const char *src)
 {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-03-12  8:05 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-03-12  8:05 UTC (permalink / raw
  To: gentoo-commits

commit:     ccd134cdd4b7d053fd87fbe30f98f9e6c4f9e32e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 12 08:04:24 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Mar 12 08:04:24 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ccd134cd

main: reduce overeager timestamp precision in initialize_flat

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c
index 044777c..4bc9130 100644
--- a/main.c
+++ b/main.c
@@ -1143,9 +1143,10 @@ initialize_flat(const char *overlay, int cache_type, bool force)
 	if (secs < 0) secs = 0;
 	if (frac < 0) frac = 0;
 
-	warn("Finished %u entries in %d.%06d seconds", count, secs, frac);
+	warn("Finished %u entries in %d.%02d seconds", count, secs, frac);
 	if (secs > 120)
-		warn("You should consider using the noatime mount option for '%s' if it's not already enabled", overlay);
+		warn("You should consider using the noatime mount option "
+				"for '%s' if it's not already enabled", overlay);
 ret:
 	close(subdir_fd);
 	if (subdir_fd != overlay_fd)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-03-01 13:51 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-03-01 13:51 UTC (permalink / raw
  To: gentoo-commits

commit:     55ad84ae976fdfc53d09faaca17549172ed62681
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar  1 13:49:43 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar  1 13:49:43 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=55ad84ae

fix GCC-8.2 warnings

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 porting.h |   4 ++
 q.c       |   9 ++--
 qfile.c   |  76 +++++++++++++-------------
 qgrep.c   |   7 +--
 qlist.c   |  10 ++--
 qmerge.c  | 181 ++++++++++++++++++++++++++++++++++++++++----------------------
 qpkg.c    |  29 ++++++----
 quse.c    |   7 +--
 8 files changed, 196 insertions(+), 127 deletions(-)

diff --git a/porting.h b/porting.h
index daf1d2e..9239897 100644
--- a/porting.h
+++ b/porting.h
@@ -51,6 +51,10 @@
 
 #include <iniparser.h>
 
+#if defined(__MACH__)
+#include <libproc.h>
+#endif
+
 #if defined(__sun) && defined(__SVR4)
 /* workaround non-const defined name in option struct, such that we
  * don't get a zillion of warnings */

diff --git a/q.c b/q.c
index 3d45160..64aa284 100644
--- a/q.c
+++ b/q.c
@@ -1,15 +1,12 @@
 /*
- * Copyright 2005-2018 Gentoo Foundation
+ * Copyright 2005-2019 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2014 Mike Frysinger  - <vapier@gentoo.org>
+ * Copyright 2017-     Fabian Groffen  - <grobian@gentoo.org>
  */
 
-#if defined(__MACH__)
-#include <libproc.h>
-#endif
-
 #define Q_FLAGS "irmM:" COMMON_FLAGS
 static struct option const q_long_opts[] = {
 	{"install",       no_argument, NULL, 'i'},
@@ -129,7 +126,7 @@ int q_main(int argc, char **argv)
 		if ((size_t)rret > sizeof(buf) - 1) {
 			rret = -1;
 		} else {
-			strncpy(buf, prog, rret);
+			snprintf(buf, sizeof(buf), "%s", prog);
 		}
 #else
 		rret = readlink("/proc/self/exe", buf, sizeof(buf) - 1);

diff --git a/qfile.c b/qfile.c
index 6e1cb0a..55fbb42 100644
--- a/qfile.c
+++ b/qfile.c
@@ -270,13 +270,15 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 	int i;
 	int nb_of_queries = argc;
 	char *pwd = state->pwd;
+	const char *p;
 	size_t real_root_len = state->real_root_len;
+	size_t len;
 	char *real_root = state->real_root;
 	char **basenames = NULL;
 	char **dirnames = NULL;
 	char **realdirnames = NULL;
-	char tmppath[_Q_PATH_MAX+1];
-	char abspath[_Q_PATH_MAX+1];
+	char tmppath[_Q_PATH_MAX];
+	char abspath[_Q_PATH_MAX];
 
 	/* For each argument, we store its basename, its absolute dirname,
 	 * and the realpath of its dirname.  Dirnames and their realpaths
@@ -289,17 +291,17 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 
 	for (i = 0; i < argc; ++i) {
 		/* Record basename, but if it is ".", ".." or "/" */
-		/* strncopy so that "argv" can be "const" */
-		strncpy(abspath, argv[i], _Q_PATH_MAX);
-		strncpy(tmppath, basename(abspath), _Q_PATH_MAX);
-		if ((strlen(tmppath) > 2) ||
-		    (strncmp(tmppath, "..", strlen(tmppath))
-		     && strncmp(tmppath, "/", strlen(tmppath))))
+		/* copy so that "argv" can be "const" */
+		snprintf(tmppath, sizeof(tmppath), "%s", argv[i]);
+		p = basename(tmppath);
+		len = strlen(p);
+		if ((len > 2) ||
+		    (strncmp(tmppath, "..", len) != 0 &&
+		     strncmp(tmppath, "/", len) != 0))
 		{
-			basenames[i] = xstrdup(tmppath);
+			basenames[i] = xstrdup(p);
 			/* If there is no "/" in the argument, then it's over.
-			 * (we are searching a simple file name)
-			 */
+			 * (we are searching a simple file name) */
 			if (strchr(argv[i], '/') == NULL)
 				continue;
 		}
@@ -307,15 +309,13 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 		/* Make sure we have an absolute path available (with
 		 * "realpath(ROOT)" prefix) */
 		if (argv[i][0] == '/') {
-			if (state->assume_root_prefix)
-				strncpy(abspath, argv[i], _Q_PATH_MAX);
-			else
-				snprintf(abspath, _Q_PATH_MAX, "%s%s", real_root, argv[i]);
+			snprintf(abspath, sizeof(abspath), "%s%s",
+					state->assume_root_prefix ? real_root : "", argv[i]);
 		} else if (pwd) {
 			if (state->assume_root_prefix)
-				snprintf(abspath, _Q_PATH_MAX, "%s/%s", pwd, argv[i]);
+				snprintf(abspath, sizeof(abspath), "%s/%s", pwd, argv[i]);
 			else
-				snprintf(abspath, _Q_PATH_MAX, "%s%s/%s",
+				snprintf(abspath, sizeof(abspath), "%s%s/%s",
 						real_root, pwd, argv[i]);
 		} else {
 			warn("$PWD was not found in environment, "
@@ -323,38 +323,36 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 			goto skip_query_item;
 		}
 
-		if (basenames[i]) {
-			/* Get both the dirname and its realpath.  This paths will
-			 * have no trailing slash, but if it is the only char (ie.,
-			 * when searching for "/foobar").
-			 */
-			strncpy(tmppath, abspath, _Q_PATH_MAX);
-			strncpy(abspath, dirname(tmppath), _Q_PATH_MAX);
-			if (abspath[real_root_len] == '\0')
-				strncat(abspath, "/", 1);
-			dirnames[i] = xstrdup(abspath + real_root_len);
-			if (realpath(abspath, tmppath) == NULL) {
+		if (basenames[i] != NULL) {
+			/* Get both the dirname and its realpath.  These paths will
+			 * have no trailing slash, except if it is the only char (ie.,
+			 * when searching for "/foobar"). */
+			snprintf(tmppath, sizeof(tmppath), "%s%s",
+					dirname(abspath),
+					abspath[real_root_len] == '\0' ? "/" : "");
+			dirnames[i] = xstrdup(tmppath + real_root_len);
+			if (realpath(tmppath, abspath) == NULL) {
 				if (verbose) {
-					warnp("Could not read real path of \"%s\"", abspath);
+					warnp("Could not read real path of \"%s\"", tmppath);
 					warn("Results for query item \"%s\" may be inaccurate.",
 							argv[i]);
 				}
 				continue;
 			}
-			if (!qfile_is_prefix(tmppath, real_root, real_root_len)) {
+			if (!qfile_is_prefix(abspath, real_root, real_root_len)) {
 				warn("Real path of \"%s\" is not under ROOT: %s",
-						abspath, tmppath);
+						tmppath, abspath);
 				goto skip_query_item;
 			}
-			if (tmppath[real_root_len] == '\0')
-				strncat(tmppath, "/", 1);
+			snprintf(tmppath, sizeof(tmppath), "%s%s",
+					dirname(abspath),
+					abspath[real_root_len] == '\0' ? "/" : "");
 			if (strcmp(dirnames[i], tmppath + real_root_len))
 				realdirnames[i] = xstrdup(tmppath + real_root_len);
 		} else {
 			/* No basename means we are looking for something like "/foo/bar/.."
 			 * Dirname is meaningless here, we can only get realpath of the full
-			 * path and then split it.
-			 */
+			 * path and then split it. */
 			if (realpath(abspath, tmppath) == NULL) {
 				warnp("Could not read real path of \"%s\"", abspath);
 				goto skip_query_item;
@@ -364,11 +362,11 @@ prepare_qfile_args(const int argc, const char **argv, struct qfile_opt_state *st
 						abspath, tmppath);
 				goto skip_query_item;
 			}
-			strncpy(abspath, tmppath, _Q_PATH_MAX);
+			snprintf(abspath, sizeof(abspath), "%s", tmppath);
 			basenames[i] = xstrdup(basename(abspath));
-			strncpy(abspath, dirname(tmppath), _Q_PATH_MAX);
-			if (tmppath[real_root_len] == '\0')
-				strncat(tmppath, "/", 1);
+			snprintf(abspath, sizeof(abspath), "%s%s",
+					dirname(tmppath),
+					tmppath[real_root_len] == '\0' ? "/" : "");
 			realdirnames[i] = xstrdup(abspath + real_root_len);
 		}
 		continue;

diff --git a/qgrep.c b/qgrep.c
index 85dab58..f018821 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -1,10 +1,11 @@
 /*
- * Copyright 2005-2018 Gentoo Foundation
+ * Copyright 2005-2019 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
+ * Copyright 2005      Petteri Räty    - <betelgeuse@gentoo.org>
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2014 Mike Frysinger  - <vapier@gentoo.org>
- * Copyright 2005 Petteri Räty    - <betelgeuse@gentoo.org>
+ * Copyright 2018-     Fabian Groffen  - <grobian@gentoo.org>
  */
 
 #ifdef APPLET_qgrep
@@ -245,7 +246,7 @@ int qgrep_main(int argc, char **argv)
 	DIR *cat_dir = NULL;
 	struct dirent *dentry = NULL;
 	char ebuild[_Q_PATH_MAX];
-	char name[_Q_PATH_MAX];
+	char name[_Q_PATH_MAX * 2];
 	char *label;
 	int reflags = 0;
 	char invert_match = 0;

diff --git a/qlist.c b/qlist.c
index a332acc..4a3b95a 100644
--- a/qlist.c
+++ b/qlist.c
@@ -1,10 +1,11 @@
 /*
- * Copyright 2005-2018 Gentoo Foundation
+ * Copyright 2005-2019 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
+ * Copyright 2005 Martin Schlemmer     - <azarah@gentoo.org>
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2014 Mike Frysinger  - <vapier@gentoo.org>
- * Copyright 2005 Martin Schlemmer - <azarah@gentoo.org>
+ * Copyright 2018-     Fabian Groffen  - <grobian@gentoo.org>
  */
 
 #ifdef APPLET_qlist
@@ -115,7 +116,10 @@ umapstr(char display, q_vdb_pkg_ctx *pkg_ctx)
 	rmspace(umap);
 	if (!strlen(umap))
 		return buf;
-	snprintf(buf, sizeof(buf), " %s%s%s%s%s", quiet ? "": "(", RED, umap, NORM, quiet ? "": ")");
+	snprintf(buf, sizeof(buf), " %s%s%.*s%s%s",
+			quiet ? "": "(", RED,
+			(int)(sizeof(buf) - (quiet ? 3 : 1) - sizeof(RED) - sizeof(NORM)),
+			umap, NORM, quiet ? "": ")");
 	return buf;
 }
 

diff --git a/qmerge.c b/qmerge.c
index 535966e..195d92b 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2018 Gentoo Authors
+ * Copyright 2005-2019 Gentoo Authors
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
@@ -538,16 +538,6 @@ install_mask_pwd(int iargc, char **iargv, const struct stat * const st, int fd)
 	install_mask_check_dir(masksv, masksc, st, fd, 1, INCLUDE, qpth);
 }
 
-static char *
-atom2str(const depend_atom *atom, char *buf, size_t size)
-{
-	if (atom->PR_int)
-		snprintf(buf, size, "%s-%s-r%i", atom->PN, atom->PV, atom->PR_int);
-	else
-		snprintf(buf, size, "%s-%s", atom->PN, atom->PV);
-	return buf;
-}
-
 static char
 qprint_tree_node(int level, const depend_atom *atom, const struct pkg_t *pkg)
 {
@@ -570,17 +560,18 @@ qprint_tree_node(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	} else {
 		depend_atom *subatom = atom_explode(p);
 		if (subatom != NULL) {
-			atom2str(subatom, buf, sizeof(buf));
-			atom2str(atom, install_ver, sizeof(install_ver));
-			ret = atom_compare_str(install_ver, buf);
+			ret = atom_compare(atom, subatom);
 			switch (ret) {
 				case EQUAL: c = 'R'; break;
 				case NEWER: c = 'U'; break;
 				case OLDER: c = 'D'; break;
 				default: c = '?'; break;
 			}
-			strncpy(buf, subatom->P, sizeof(buf));
-			snprintf(install_ver, sizeof(install_ver), "[%s%s%s] ", DKBLUE, buf, NORM);
+			snprintf(install_ver, sizeof(install_ver), "[%s%.*s%s] ",
+					DKBLUE,
+					(int)(sizeof(install_ver) - 4 -
+						sizeof(DKBLUE) - sizeof(NORM)),
+					subatom->P, NORM);
 			atom_implode(subatom);
 		}
 		if (update_only && c != 'U')
@@ -1814,23 +1805,38 @@ grab_binpkg_info(const char *name)
 				snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF);
 				if (strstr(buf, name) != NULL) {
 					if (!best_match[0])
-						strncpy(best_match, buf, sizeof(best_match));
+						snprintf(best_match, sizeof(best_match), "%.*s",
+								(int)sizeof(best_match) - 1, buf);
 
 					atom = atom_explode(buf);
-					snprintf(buf, sizeof(buf), "%s/%s-%s", atom->CATEGORY, atom->PN, atom->PV);
-					if (atom->PR_int)
-						snprintf(buf, sizeof(buf), "%s/%s-%s-r%i", atom->CATEGORY, atom->PN, atom->PV, atom->PR_int);
+					if (atom->PR_int) {
+						snprintf(buf, sizeof(buf), "%s/%s-%s-r%i",
+								atom->CATEGORY, atom->PN,
+								atom->PV, atom->PR_int);
+					} else {
+						snprintf(buf, sizeof(buf), "%s/%s-%s",
+								atom->CATEGORY, atom->PN, atom->PV);
+					}
 					ret = atom_compare_str(name, buf);
-					IF_DEBUG(fprintf(stderr, "=== atom_compare(%s, %s) = %d %s\n", name, buf, ret, booga[ret])); /* buf(%s) depend(%s)\n", ret, pkg->CATEGORY, pkg->PF, name, pkg->RDEPEND); */
+					IF_DEBUG(fprintf(stderr,
+								"=== atom_compare(%s, %s) = %d %s\n",
+								name, buf, ret, booga[ret]));
+					/* buf(%s) depend(%s)\n", ret, pkg->CATEGORY,
+					 * pkg->PF, name, pkg->RDEPEND); */
 					switch (ret) {
 						case EQUAL:
 						case NEWER:
-							snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF);
+							snprintf(buf, sizeof(buf), "%s/%s",
+									pkg->CATEGORY, pkg->PF);
 							ret = atom_compare_str(buf, best_match);
 							if (ret == NEWER || ret == EQUAL) {
-								strncpy(best_match, buf, sizeof(best_match));
+								snprintf(best_match, sizeof(best_match), "%.*s",
+										(int)sizeof(best_match) - 1, buf);
 								memcpy(rpkg, pkg, sizeof(struct pkg_t));
-								IF_DEBUG(fprintf(stderr, "--- %s/%s depend(%s)\n", rpkg->CATEGORY, rpkg->PF, rpkg->RDEPEND));
+								IF_DEBUG(fprintf(stderr,
+											"--- %s/%s depend(%s)\n",
+											rpkg->CATEGORY, rpkg->PF,
+											rpkg->RDEPEND));
 							}
 						case OLDER: break;
 						default:
@@ -1856,34 +1862,46 @@ grab_binpkg_info(const char *name)
 		if (*buf) {
 			/* we dont need all the info */
 			if (strcmp(buf, "RDEPEND") == 0)
-				strncpy(pkg->RDEPEND, p, sizeof(Pkg.RDEPEND));
+				snprintf(pkg->RDEPEND, sizeof(Pkg.RDEPEND), "%.*s",
+						(int)sizeof(Pkg.RDEPEND) - 1, p);
 			if (strcmp(buf, "PF") == 0)
-				strncpy(pkg->PF, p, sizeof(Pkg.PF));
+				snprintf(pkg->PF, sizeof(Pkg.PF), "%.*s",
+						(int)sizeof(Pkg.PF) - 1, p);
 			if (strcmp(buf, "CATEGORY") == 0)
-				strncpy(pkg->CATEGORY, p, sizeof(Pkg.CATEGORY));
+				snprintf(pkg->CATEGORY, sizeof(Pkg.CATEGORY), "%.*s",
+						(int)sizeof(Pkg.CATEGORY) - 1, p);
 			if (strcmp(buf, "REPO") == 0)
-				strncpy(pkg->REPO, p, sizeof(Pkg.REPO));
+				snprintf(pkg->REPO, sizeof(Pkg.REPO), "%.*s",
+						(int)sizeof(Pkg.REPO) - 1, p);
 
 			if (strcmp(buf, "CPV") == 0) {
 				if ((atom = atom_explode(p)) != NULL) {
-					snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
-					if (atom->PR_int)
-						snprintf(buf, sizeof(buf), "%s-%s-r%i", atom->PN, atom->PV, atom->PR_int);
-					strncpy(pkg->PF, buf, sizeof(Pkg.PF));
-					strncpy(pkg->CATEGORY, atom->CATEGORY, sizeof(Pkg.CATEGORY));
+					if (atom->PR_int) {
+						snprintf(buf, sizeof(buf), "%s-%s-r%i",
+								atom->PN, atom->PV, atom->PR_int);
+					} else {
+						snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
+					}
+					snprintf(pkg->PF, sizeof(Pkg.PF), "%.*s",
+							(int)sizeof(Pkg.PF) - 1, buf);
+					snprintf(pkg->CATEGORY, sizeof(Pkg.CATEGORY), "%.*s",
+							(int)sizeof(Pkg.CATEGORY) - 1, atom->CATEGORY);
 					atom_implode(atom);
 				}
 			}
 			if (strcmp(buf, "SLOT") == 0)
-				strncpy(pkg->SLOT, p, sizeof(Pkg.SLOT));
+				snprintf(pkg->SLOT, sizeof(Pkg.SLOT), "%.*s",
+						(int)sizeof(Pkg.SLOT) - 1, p);
 			if (strcmp(buf, "USE") == 0)
-				strncpy(pkg->USE, p, sizeof(Pkg.USE));
-
+				snprintf(pkg->USE, sizeof(Pkg.USE), "%.*s",
+						(int)sizeof(Pkg.USE) - 1, p);
 			/* checksums. We must have 1 or the other unless --*/
 			if (strcmp(buf, "MD5") == 0)
-				strncpy(pkg->MD5, p, sizeof(Pkg.MD5));
+				snprintf(pkg->MD5, sizeof(Pkg.MD5), "%.*s",
+						(int)sizeof(Pkg.MD5) - 1, p);
 			if (strcmp(buf, "SHA1") == 0)
-				strncpy(pkg->SHA1, p, sizeof(Pkg.SHA1));
+				snprintf(pkg->SHA1, sizeof(Pkg.SHA1), "%.*s",
+						(int)sizeof(Pkg.SHA1) - 1, p);
 		}
 	}
 	fclose(fp);
@@ -1918,10 +1936,12 @@ find_binpkg(const char *name)
 					depend_atom *atom;
 
 					if (!best_match[0])
-						strncpy(best_match, buf, sizeof(best_match));
+						snprintf(best_match, sizeof(best_match), "%.*s",
+								(int)sizeof(best_match) - 1, buf);
 
 					atom = atom_explode(buf);
-					snprintf(buf, sizeof(buf), "%s/%s", atom->CATEGORY, atom->PN);
+					snprintf(buf, sizeof(buf), "%s/%s",
+							atom->CATEGORY, atom->PN);
 					ret = atom_compare_str(name, buf);
 					switch (ret) {
 						case OLDER: break;
@@ -1930,8 +1950,10 @@ find_binpkg(const char *name)
 							snprintf(buf, sizeof(buf), "%s/%s", CATEGORY, PF);
 							ret = atom_compare_str(buf, best_match);
 							if (ret == NEWER || ret == EQUAL)
-								strncpy(best_match, buf, sizeof(best_match));
-							/* printf("[%s == %s] = %d; %s/%s\n", name, buf, ret, CATEGORY, PF); */
+								snprintf(best_match, sizeof(best_match), "%.*s",
+										(int)sizeof(best_match) - 1, buf);
+							/* printf("[%s == %s] = %d; %s/%s\n",
+							 * name, buf, ret, CATEGORY, PF); */
 						default:
 							break;
 					}
@@ -1954,18 +1976,23 @@ find_binpkg(const char *name)
 			if (strcmp(buf, "CPV") == 0) {
 				depend_atom *atom;
 				if ((atom = atom_explode(p)) != NULL) {
-					snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
-					if (atom->PR_int)
-						snprintf(buf, sizeof(buf), "%s-%s-r%i", atom->PN, atom->PV, atom->PR_int);
-					strncpy(PF, buf, sizeof(PF));
-					strncpy(CATEGORY, atom->CATEGORY, sizeof(CATEGORY));
+					if (atom->PR_int) {
+						snprintf(buf, sizeof(buf), "%s-%s-r%i",
+								atom->PN, atom->PV, atom->PR_int);
+					} else {
+						snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
+					}
+					snprintf(PF, sizeof(PF), "%.*s", (int)sizeof(PF) - 1, buf);
+					snprintf(CATEGORY, sizeof(CATEGORY), "%.*s",
+							(int)sizeof(CATEGORY) - 1, atom->CATEGORY);
 					atom_implode(atom);
 				}
 			}
 			if (strcmp(buf, "PF") == 0)
-				strncpy(PF, p, sizeof(PF));
+				snprintf(PF, sizeof(PF), "%.*s", (int)sizeof(PF) - 1, p);
 			if (strcmp(buf, "CATEGORY") == 0)
-				strncpy(CATEGORY, p, sizeof(CATEGORY));
+				snprintf(CATEGORY, sizeof(CATEGORY), "%.*s",
+						(int)sizeof(CATEGORY) - 1, p);
 		}
 	}
 	fclose(fp);
@@ -2004,7 +2031,7 @@ parse_packages(queue *todo)
 		switch (*buf) {
 		case 'R':
 			if (!strcmp(buf, "REPO"))
-				strncpy(repo, p, sizeof(repo));
+				snprintf(repo, sizeof(repo), "%.*s", (int)sizeof(repo) - 1, p);
 			break;
 		}
 	}
@@ -2057,40 +2084,66 @@ parse_packages(queue *todo)
 
 		switch (*buf) {
 			case 'U':
-				if (strcmp(buf, "USE") == 0) strncpy(Pkg.USE, p, sizeof(Pkg.USE));
+				if (strcmp(buf, "USE") == 0)
+					snprintf(Pkg.USE, sizeof(Pkg.USE), "%.*s",
+							(int)sizeof(Pkg.USE) - 1, p);
 				break;
 			case 'P':
-				if (strcmp(buf, "PF") == 0) strncpy(Pkg.PF, p, sizeof(Pkg.PF));
+				if (strcmp(buf, "PF") == 0)
+					snprintf(Pkg.PF, sizeof(Pkg.PF), "%.*s",
+							(int)sizeof(Pkg.PF) - 1, p);
 				break;
 			case 'S':
-				if (strcmp(buf, "SIZE") == 0) Pkg.SIZE = atol(p);
-				if (strcmp(buf, "SLOT") == 0) strncpy(Pkg.SLOT, p, sizeof(Pkg.SLOT));
-				if (strcmp(buf, "SHA1") == 0) strncpy(Pkg.SHA1, p, sizeof(Pkg.SHA1));
+				if (strcmp(buf, "SIZE") == 0)
+					Pkg.SIZE = atol(p);
+				if (strcmp(buf, "SLOT") == 0)
+					snprintf(Pkg.SLOT, sizeof(Pkg.SLOT), "%.*s",
+							(int)sizeof(Pkg.SLOT) - 1, p);
+				if (strcmp(buf, "SHA1") == 0)
+					snprintf(Pkg.SHA1, sizeof(Pkg.SHA1), "%.*s",
+							(int)sizeof(Pkg.SHA1) - 1, p);
 				break;
 			case 'M':
-				if (strcmp(buf, "MD5") == 0) strncpy(Pkg.MD5, p, sizeof(Pkg.MD5));
+				if (strcmp(buf, "MD5") == 0)
+					snprintf(Pkg.MD5, sizeof(Pkg.MD5), "%.*s",
+							(int)sizeof(Pkg.MD5) - 1, p);
 				break;
 			case 'R':
-				if (strcmp(buf, "REPO") == 0) strncpy(Pkg.REPO, p, sizeof(Pkg.REPO));
-				if (strcmp(buf, "RDEPEND") == 0) strncpy(Pkg.RDEPEND, p, sizeof(Pkg.RDEPEND));
+				if (strcmp(buf, "REPO") == 0)
+					snprintf(Pkg.REPO, sizeof(Pkg.REPO), "%.*s",
+							(int)sizeof(Pkg.REPO) - 1, p);
+				if (strcmp(buf, "RDEPEND") == 0)
+					snprintf(Pkg.RDEPEND, sizeof(Pkg.RDEPEND), "%.*s",
+							(int)sizeof(Pkg.RDEPEND) - 1, p);
 				break;
 			case 'L':
-				if (strcmp(buf, "LICENSE") == 0) strncpy(Pkg.LICENSE, p, sizeof(Pkg.LICENSE));
+				if (strcmp(buf, "LICENSE") == 0)
+					snprintf(Pkg.LICENSE, sizeof(Pkg.LICENSE), "%.*s",
+							(int)sizeof(Pkg.LICENSE) - 1, p);
 				break;
 			case 'C':
-				if (strcmp(buf, "CATEGORY") == 0) strncpy(Pkg.CATEGORY, p, sizeof(Pkg.CATEGORY));
+				if (strcmp(buf, "CATEGORY") == 0)
+					snprintf(Pkg.CATEGORY, sizeof(Pkg.CATEGORY), "%.*s",
+							(int)sizeof(Pkg.CATEGORY) - 1, p);
 				if (strcmp(buf, "CPV") == 0) {
 					if ((pkg_atom = atom_explode(p)) != NULL) {
 						if (pkg_atom->PR_int)
-							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s-r%i", pkg_atom->PN, pkg_atom->PV, pkg_atom->PR_int);
+							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s-r%i",
+									pkg_atom->PN, pkg_atom->PV,
+									pkg_atom->PR_int);
 						else
-							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s", pkg_atom->PN, pkg_atom->PV);
-						strncpy(Pkg.CATEGORY, pkg_atom->CATEGORY, sizeof(Pkg.CATEGORY));
+							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s",
+									pkg_atom->PN, pkg_atom->PV);
+						snprintf(Pkg.CATEGORY, sizeof(Pkg.CATEGORY),
+								"%.*s", (int)sizeof(Pkg.CATEGORY) - 1,
+								pkg_atom->CATEGORY);
 					}
 				}
 				break;
 			case 'D':
-				if (strcmp(buf, "DESC") == 0) strncpy(Pkg.DESC, p, sizeof(Pkg.DESC));
+				if (strcmp(buf, "DESC") == 0)
+					snprintf(Pkg.DESC, sizeof(Pkg.DESC), "%.*s",
+							(int)sizeof(Pkg.DESC) - 1, p);
 				break;
 			default:
 				break;

diff --git a/qpkg.c b/qpkg.c
index bab3cd1..dcdc190 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -1,9 +1,10 @@
 /*
- * Copyright 2005-2018 Gentoo Foundation
+ * Copyright 2005-2019 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
- * Copyright 2005-2010 Ned Ludd	- <solar@gentoo.org>
+ * Copyright 2005-2010 Ned Ludd	       - <solar@gentoo.org>
  * Copyright 2005-2014 Mike Frysinger  - <vapier@gentoo.org>
+ * Copyright 2018-     Fabian Groffen  - <grobian@gentoo.org>
  */
 
 #ifdef APPLET_qpkg
@@ -215,7 +216,10 @@ static int
 qpkg_make(depend_atom *atom)
 {
 	FILE *fp, *out;
-	char tmpdir[BUFSIZE], filelist[BUFSIZE], xpak[BUFSIZE], tbz2[BUFSIZE];
+	char tmpdir[BUFSIZE];
+	char filelist[BUFSIZE + 32];
+	char xpak[BUFSIZE + 32];
+	char tbz2[BUFSIZE + 32];
 	size_t buflen;
 	char *buf;
 	int i;
@@ -230,7 +234,8 @@ qpkg_make(depend_atom *atom)
 	buflen = _Q_PATH_MAX;
 	buf = xmalloc(buflen);
 
-	snprintf(buf, buflen, "%s/%s/%s/CONTENTS", portvdb, atom->CATEGORY, atom_to_pvr(atom));
+	snprintf(buf, buflen, "%s/%s/%s/CONTENTS",
+			portvdb, atom->CATEGORY, atom_to_pvr(atom));
 	if ((fp = fopen(buf, "r")) == NULL)
 		return -1;
 
@@ -258,7 +263,8 @@ qpkg_make(depend_atom *atom)
 			char *hash = (char *)hash_file(e->name, HASH_MD5);
 			if (hash != NULL) {
 				if (strcmp(e->digest, hash) != 0)
-					warn("MD5: mismatch expected %s got %s for %s", e->digest, hash, e->name);
+					warn("MD5: mismatch expected %s got %s for %s",
+							e->digest, hash, e->name);
 				free(hash);
 			}
 		}
@@ -271,13 +277,16 @@ qpkg_make(depend_atom *atom)
 	fflush(stdout);
 
 	snprintf(tbz2, sizeof(tbz2), "%s/bin.tar.bz2", tmpdir);
-	snprintf(buf, buflen, "tar jcf '%s' --files-from='%s' --no-recursion >/dev/null 2>&1", tbz2, filelist);
+	if (snprintf(buf, buflen, "tar jcf '%s' --files-from='%s' "
+			"--no-recursion >/dev/null 2>&1", tbz2, filelist) > (int)buflen)
+		return 2;
 	if ((fp = popen(buf, "r")) == NULL)
 		return 2;
 	pclose(fp);
 
 	snprintf(xpak, sizeof(xpak), "%s/inf.xpak", tmpdir);
-	snprintf(buf, buflen, "%s/%s/%s", portvdb, atom->CATEGORY, atom_to_pvr(atom));
+	snprintf(buf, buflen, "%s/%s/%s",
+			portvdb, atom->CATEGORY, atom_to_pvr(atom));
 	xpak_argv[0] = buf;
 	xpak_argv[1] = NULL;
 	xpak_create(AT_FDCWD, xpak, 1, xpak_argv);
@@ -289,7 +298,8 @@ qpkg_make(depend_atom *atom)
 	unlink(xpak);
 	unlink(tbz2);
 
-	snprintf(tbz2, sizeof(tbz2), "%s/%s.tbz2", qpkg_get_bindir(), atom_to_pvr(atom));
+	snprintf(tbz2, sizeof(tbz2), "%s/%s.tbz2",
+			qpkg_get_bindir(), atom_to_pvr(atom));
 	if (rename(buf, tbz2)) {
 		warnp("could not move '%s' to '%s'", buf, tbz2);
 		return 1;
@@ -298,7 +308,8 @@ qpkg_make(depend_atom *atom)
 	rmdir(tmpdir);
 
 	stat(tbz2, &st);
-	printf("%s%s%s kB\n", RED, make_human_readable_str(st.st_size, 1, KILOBYTE), NORM);
+	printf("%s%s%s kB\n",
+			RED, make_human_readable_str(st.st_size, 1, KILOBYTE), NORM);
 
 	return 0;
 }

diff --git a/quse.c b/quse.c
index 05ba2f4..1fd4f3a 100644
--- a/quse.c
+++ b/quse.c
@@ -1,9 +1,10 @@
 /*
- * Copyright 2005-2018 Gentoo Foundation
+ * Copyright 2005-2019 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2014 Mike Frysinger  - <vapier@gentoo.org>
+ * Copyright 2018-     Fabian Groffen  - <grobian@gentoo.org>
  */
 
 #ifdef APPLET_quse
@@ -50,12 +51,12 @@ print_highlighted_use_flags(char *string, int ind, int argc, char **argv)
 	if (quse_name_only)
 		return;
 
-	strncpy(buf, string, sizeof(buf));
+	snprintf(buf, sizeof(buf), "%.*s", (int)sizeof(buf) - 1, string);
 	str = buf;
 	remove_extra_space(str);
 	rmspace(str);
 
-	if (*WHITE != '\e') {
+	if (*WHITE == '\0') {
 		printf("%s", str);
 		return;
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-02-28 18:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-02-28 18:37 UTC (permalink / raw
  To: gentoo-commits

commit:     9dcbcdfd0c90d76ddbb4b4dcdd41a981441f53e2
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 28 18:35:53 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Feb 28 18:35:53 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9dcbcdfd

qlop: introduce machine elapsed time and standard time

Report elapsed time in short notation by default, use elaborate notation
using -H, print just seconds (previous behaviour) using -M.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++------------------
 1 file changed, 54 insertions(+), 20 deletions(-)

diff --git a/qlop.c b/qlop.c
index 08ea479..d5c2548 100644
--- a/qlop.c
+++ b/qlop.c
@@ -11,12 +11,13 @@
 
 #define QLOP_DEFAULT_LOGFILE "emerge.log"
 
-#define QLOP_FLAGS "ctaHmuUserd:f:w:" COMMON_FLAGS
+#define QLOP_FLAGS "ctaHMmuUserd:f:w:" COMMON_FLAGS
 static struct option const qlop_long_opts[] = {
 	{"summary",   no_argument, NULL, 'c'},
 	{"time",      no_argument, NULL, 't'},
 	{"average",   no_argument, NULL, 'a'},
 	{"human",     no_argument, NULL, 'H'},
+	{"machine",   no_argument, NULL, 'M'},
 	{"merge",     no_argument, NULL, 'm'},
 	{"unmerge",   no_argument, NULL, 'u'},
 	{"autoclean", no_argument, NULL, 'U'},
@@ -33,6 +34,7 @@ static const char * const qlop_opts_help[] = {
 	"Print time taken to complete action",
 	"Print average time taken to complete action",
 	"Print elapsed time in human readable format (use with -t or -a)",
+	"Print elapsed time as seconds with no formatting",
 	"Show merge history",
 	"Show unmerge history",
 	"Show autoclean unmerge history",
@@ -63,6 +65,7 @@ struct qlop_mode {
 	char do_average:1;
 	char do_summary:1;
 	char do_human:1;
+	char do_machine:1;
 	char do_endtime:1;
 };
 
@@ -181,21 +184,28 @@ static char *fmt_date(struct qlop_mode *flags, time_t ts, time_t te)
 static char _elapsed_buf[256];
 static char *fmt_elapsedtime(struct qlop_mode *flags, time_t e)
 {
-	if (flags->do_human) {
-		time_t dd;
-		time_t hh;
-		time_t mm;
-		time_t ss;
-		size_t bufpos = 0;
-
-		ss = e % 60;
-		e /= 60;
-		mm = e % 60;
-		e /= 60;
-		hh = e % 24;
-		e /= 24;
-		dd = e;
+	time_t dd;
+	time_t hh;
+	time_t mm;
+	time_t ss;
+	size_t bufpos = 0;
+
+	if (flags->do_machine) {
+		snprintf(_elapsed_buf, sizeof(_elapsed_buf),
+				"%s%zd%s",
+				GREEN, (size_t)e, NORM);
+		return _elapsed_buf;
+	}
 
+	ss = e % 60;
+	e /= 60;
+	mm = e % 60;
+	e /= 60;
+	hh = e % 24;
+	e /= 24;
+	dd = e;
+
+	if (flags->do_human) {
 		if (dd > 0)
 			bufpos += snprintf(_elapsed_buf + bufpos,
 					sizeof(_elapsed_buf) - bufpos,
@@ -220,8 +230,23 @@ static char *fmt_elapsedtime(struct qlop_mode *flags, time_t e)
 					bufpos == 0 ? "" : ", ",
 					GREEN, (size_t)ss, NORM, ss == 1 ? "" : "s");
 	} else {
-		snprintf(_elapsed_buf, sizeof(_elapsed_buf), "%s%zd%s seconds",
-				GREEN, (size_t)e, NORM);
+		hh += 24 * dd;
+		if (hh > 0) {
+			snprintf(_elapsed_buf, sizeof(_elapsed_buf),
+					"%s%zd%s:%s%02zd%s:%s%02zd%s",
+					GREEN, (size_t)hh, NORM,
+					GREEN, (size_t)mm, NORM,
+					GREEN, (size_t)ss, NORM);
+		} else if (mm > 0) {
+			snprintf(_elapsed_buf, sizeof(_elapsed_buf),
+					"%s%zd%s′%s%02zd%s″",
+					GREEN, (size_t)mm, NORM,
+					GREEN, (size_t)ss, NORM);
+		} else {
+			snprintf(_elapsed_buf, sizeof(_elapsed_buf),
+					"%s%zd%ss",
+					GREEN, (size_t)ss, NORM);
+		}
 	}
 
 	return _elapsed_buf;
@@ -461,7 +486,8 @@ static int do_emerge_log(
 				if (flags->do_time) {
 					printf("%s *** %s%s%s: %s\n",
 							fmt_date(flags, sync_start, tstart),
-							GREEN, p, NORM, fmt_elapsedtime(flags, elapsed));
+							GREEN, p, NORM,
+							fmt_elapsedtime(flags, elapsed));
 				} else {
 					printf("%s *** %s%s%s\n",
 							fmt_date(flags, sync_start, tstart),
@@ -846,6 +872,7 @@ int qlop_main(int argc, char **argv)
 	m.do_average = 0;
 	m.do_summary = 0;
 	m.do_human = 0;
+	m.do_machine = 0;
 	m.do_endtime = 0;
 
 	while ((ret = GETOPT_LONG(QLOP, qlop, "")) != -1) {
@@ -861,6 +888,7 @@ int qlop_main(int argc, char **argv)
 			case 'a': m.do_average = 1;   break;
 			case 'c': m.do_summary = 1;   break;
 			case 'H': m.do_human = 1;     break;
+			case 'M': m.do_machine = 1;   break;
 			case 'e': m.do_endtime = 1;   break;
 			case 'd':
 				if (start_time == 0) {
@@ -924,8 +952,7 @@ int qlop_main(int argc, char **argv)
 			m.do_sync == 0 &&
 			m.do_running == 0 &&
 			m.do_average == 0 &&
-			m.do_summary == 0 &&
-			m.do_human == 0
+			m.do_summary == 0
 		)
 	{
 		m.do_merge = 1;
@@ -951,6 +978,13 @@ int qlop_main(int argc, char **argv)
 		m.do_average = 0;
 	}
 
+	/* handle -H / -M conflict */
+	if (m.do_human && m.do_machine) {
+		warn("-H and -M cannot be used together, dropping -M: "
+				"only humans make mistakes");
+		m.do_machine = 0;
+	}
+
 	if (m.do_sync && array_cnt(atoms) > 0) {
 		warn("-s cannot be used when specifying atoms, dropping -s");
 		m.do_sync = 0;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-02-28 18:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-02-28 18:37 UTC (permalink / raw
  To: gentoo-commits

commit:     0cf3703a4f7a4bebd0cc660690434a7bcffd507a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 28 18:21:24 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Feb 28 18:21:24 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0cf3703a

qlop: avoid warning about -s when specifying an atom

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qlop.c b/qlop.c
index 12c66a6..08ea479 100644
--- a/qlop.c
+++ b/qlop.c
@@ -930,7 +930,8 @@ int qlop_main(int argc, char **argv)
 	{
 		m.do_merge = 1;
 		m.do_unmerge = 1;
-		m.do_sync = 1;
+		if (array_cnt(atoms) == 0)
+			m.do_sync = 1;
 		m.do_time = 1;
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-02-27 21:18 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-02-27 21:18 UTC (permalink / raw
  To: gentoo-commits

commit:     56e50dea636a760fb3f3ad3a53bd72daaa8c987d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 27 21:15:56 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Feb 27 21:15:56 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=56e50dea

qlop: implement current package order number for --running

Print extracted package order number to indicate some more progress.
Example:

./qlop -r
2019-02-27T22:14:29 >>> dev-util/cmake... (1 of 1) ETA: 532 seconds

Bug: https://bugs.gentoo.org/442406
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/qlop.c b/qlop.c
index 26b27b2..12c66a6 100644
--- a/qlop.c
+++ b/qlop.c
@@ -714,17 +714,29 @@ static int do_emerge_log(
 				pkg = NULL;
 			}
 
+			/* extract (X of Y) from id, bug #442406 */
+			if ((p = strchr(pkgw->id, '(')) != NULL) {
+				if ((q = strchr(p, ')')) != NULL) {
+					q[1] = '\0';
+					p--;
+				} else {
+					p = NULL;
+				}
+			}
+
 			if (flags->do_time) {
-				printf("%s >>> %s%s%s: %s... ETA: %s\n",
+				printf("%s >>> %s%s%s: %s...%s ETA: %s\n",
 						fmt_date(flags, pkgw->tbegin, 0),
 						YELLOW, fmt_atom(flags, pkgw->atom), NORM,
 						fmt_elapsedtime(flags, elapsed),
+						p == NULL ? "" : p,
 						maxtime == 0 ? "unknown" :
 							fmt_elapsedtime(flags, maxtime - elapsed));
 			} else {
-				printf("%s >>> %s%s%s... ETA: %s\n",
+				printf("%s >>> %s%s%s...%s ETA: %s\n",
 						fmt_date(flags, pkgw->tbegin, 0),
 						YELLOW, fmt_atom(flags, pkgw->atom), NORM,
+						p == NULL ? "" : p,
 						maxtime == 0 ? "unknown" :
 							fmt_elapsedtime(flags, maxtime - elapsed));
 			}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-02-27 20:53 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-02-27 20:53 UTC (permalink / raw
  To: gentoo-commits

commit:     b7b0034258f1a378cc3902b238bffdaca001d0f5
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 26 08:35:01 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Feb 27 20:50:10 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b7b00342

qcache: move print_seconds_for_earthlings here

qcache currently is the only consumer of this function

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcache.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/qcache.c b/qcache.c
index a3be446..831af2e 100644
--- a/qcache.c
+++ b/qcache.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2018 Gentoo Foundation
+ * Copyright 2005-2019 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2006 Thomas A. Cort - <tcort@gentoo.org>
@@ -677,6 +677,21 @@ qcache_dropped(qcache_data *data)
 	free(keywords);
 }
 
+static void
+print_seconds_for_earthlings(const unsigned long t)
+{
+	unsigned dd, hh, mm, ss;
+	unsigned long tt = t;
+	ss = tt % 60; tt /= 60;
+	mm = tt % 60; tt /= 60;
+	hh = tt % 24; tt /= 24;
+	dd = tt;
+	if (dd) printf("%s%u%s day%s, ", GREEN, dd, NORM, (dd == 1 ? "" : "s"));
+	if (hh) printf("%s%u%s hour%s, ", GREEN, hh, NORM, (hh == 1 ? "" : "s"));
+	if (mm) printf("%s%u%s minute%s, ", GREEN, mm, NORM, (mm == 1 ? "" : "s"));
+	printf("%s%u%s second%s", GREEN, ss, NORM, (ss == 1 ? "" : "s"));
+}
+
 static void
 qcache_stats(qcache_data *data)
 {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2019-02-23 15:22 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2019-02-23 15:22 UTC (permalink / raw
  To: gentoo-commits

commit:     10de44241d6e3acd30e8e579f7f119510391651f
Author:     Sam Besselink <sambesselink <AT> planet <DOT> nl>
AuthorDate: Thu Feb 14 15:32:27 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 23 15:22:08 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=10de4424

In qtegrity.c make check_file use _Q_PATH_MAX when checking filename len

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qtegrity.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/qtegrity.c b/qtegrity.c
index 0b30fb8..db139f1 100644
--- a/qtegrity.c
+++ b/qtegrity.c
@@ -245,9 +245,7 @@ static int get_size_digest(char * line)
 
 static int check_file(char * filename)
 {
-	/* TODO, this is 4096 too low, because this variable also holds
-	 * path; for linux path is max 4096 chars */
-	if (strlen(filename) > 255)
+	if (strlen(filename) > _Q_PATH_MAX)
 		err("Filename too long");
 
 	if (filename[0] != '/') {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-12-28  9:08 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-12-28  9:08 UTC (permalink / raw
  To: gentoo-commits

commit:     16e7280ec40c26f586f0db62f0d63960dd42a3d0
Author:     Sam Besselink <sambesselink <AT> planet <DOT> nl>
AuthorDate: Wed Oct 24 22:30:31 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Dec 28 09:07:25 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=16e7280e

Refactor: use successive fail branches

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcheck.c | 231 ++++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 126 insertions(+), 105 deletions(-)

diff --git a/qcheck.c b/qcheck.c
index 8a83466..7b6e58c 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -50,8 +50,8 @@ struct qcheck_opt_state {
 static int
 qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 {
-	int fd;
-	FILE *fp, *fpx;
+	int fd_contents;
+	FILE *fp_contents, *fp_contents_update;
 	const char *catname = pkg_ctx->cat_ctx->name;
 	const char *pkgname = pkg_ctx->name;
 	size_t num_files, num_files_ok, num_files_unknown, num_files_ignored;
@@ -61,28 +61,30 @@ qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 	int cp_argc, cpm_argc;
 	char **cp_argv, **cpm_argv;
 
-	fpx = NULL;
+	fp_contents_update = NULL;
 
-	fd = q_vdb_pkg_openat(pkg_ctx, "CONTENTS", O_RDONLY|O_CLOEXEC, 0);
-	if (fd == -1)
+	/* Open contents */
+	fd_contents = q_vdb_pkg_openat(pkg_ctx, "CONTENTS", O_RDONLY|O_CLOEXEC, 0);
+	if (fd_contents == -1)
 		return EXIT_SUCCESS;
-	if (fstat(fd, &cst)) {
-		close(fd);
+	if (fstat(fd_contents, &cst)) {
+		close(fd_contents);
 		return EXIT_SUCCESS;
 	}
-	if ((fp = fdopen(fd, "r")) == NULL) {
-		close(fd);
+	if ((fp_contents = fdopen(fd_contents, "r")) == NULL) {
+		close(fd_contents);
 		return EXIT_SUCCESS;
 	}
 
+	/* Open contents_update, if needed */
 	num_files = num_files_ok = num_files_unknown = num_files_ignored = 0;
 	qcprintf("%sing %s%s/%s%s ...\n",
 		(state->qc_update ? "Updat" : "Check"),
 		GREEN, catname, pkgname, NORM);
 	if (state->qc_update) {
-		fpx = q_vdb_pkg_fopenat_rw(pkg_ctx, "CONTENTS~");
-		if (fpx == NULL) {
-			fclose(fp);
+		fp_contents_update = q_vdb_pkg_fopenat_rw(pkg_ctx, "CONTENTS~");
+		if (fp_contents_update == NULL) {
+			fclose(fp_contents);
 			warnp("unable to fopen(%s/%s, w)", pkgname, "CONTENTS~");
 			return EXIT_FAILURE;
 		}
@@ -94,21 +96,23 @@ qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 	}
 
 	buffer = line = NULL;
-	while (getline(&line, &linelen, fp) != -1) {
-		contents_entry *e;
+	while (getline(&line, &linelen, fp_contents) != -1) {
+		contents_entry *entry;
 		free(buffer);
 		buffer = xstrdup(line);
-		e = contents_parse_line(line);
-		if (!e)
+
+		entry = contents_parse_line(line);
+
+		if (!entry)
 			continue;
 
-		/* run our little checks */
+		/* run initial checks */
 		++num_files;
 		if (array_cnt(state->regex_arr)) {
 			size_t n;
 			regex_t *regex;
 			array_for_each(state->regex_arr, n, regex)
-				if (!regexec(regex, e->name, 0, NULL, 0))
+				if (!regexec(regex, entry->name, 0, NULL, 0))
 					break;
 			if (n < array_cnt(state->regex_arr)) {
 				--num_files;
@@ -116,142 +120,159 @@ qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 				continue;
 			}
 		}
-		if (fstatat(pkg_ctx->cat_ctx->ctx->portroot_fd, e->name + 1, &st, AT_SYMLINK_NOFOLLOW)) {
+		if (fstatat(pkg_ctx->cat_ctx->ctx->portroot_fd, entry->name + 1, &st, AT_SYMLINK_NOFOLLOW)) {
 			/* make sure file exists */
 			if (state->chk_afk) {
 				if (errno == ENOENT)
-					qcprintf(" %sAFK%s: %s\n", RED, NORM, e->name);
+					qcprintf(" %sAFK%s: %s\n", RED, NORM, entry->name);
 				else
-					qcprintf(" %sERROR (%s)%s: %s\n", RED, strerror(errno), NORM, e->name);
+					qcprintf(" %sERROR (%s)%s: %s\n", RED, strerror(errno), NORM, entry->name);
 			} else {
 				--num_files;
 				++num_files_ignored;
 				if (state->qc_update)
-					fputs(buffer, fpx);
+					fputs(buffer, fp_contents_update);
 			}
 			continue;
 		}
-		if (e->digest && S_ISREG(st.st_mode)) {
-			if (!state->chk_config_protect) {
-				/* handle CONFIG_PROTECT-ed files */
-				int i;
-				/* if it's in CONFIG_PROTECT_MASK, check it like normal */
-				for (i = 1; i < cpm_argc; ++i)
-					if (strncmp(cpm_argv[i], e->name, strlen(cpm_argv[i])) == 0)
-						break;
-				if (i == cpm_argc) {
-					/* not explicitly masked, so if it's protected */
-					for (i = 1; i < cp_argc; ++i)
-						if (strncmp(cp_argv[i], e->name, strlen(cp_argv[i])) == 0)
-							goto cfg_protected;
-				}
+
+		/* Handle CONFIG_PROTECT-ed files */
+		if (!state->chk_config_protect) {
+			int i;
+			/* If in CONFIG_PROTECT_MASK, handle like normal */
+			for (i = 1; i < cpm_argc; ++i)
+				if (strncmp(cpm_argv[i], entry->name, strlen(cpm_argv[i])) == 0)
+					break;
+			if (i == cpm_argc) {
+				/* Not explicitly masked, so it's protected */
+				for (i = 1; i < cp_argc; ++i)
+					if (strncmp(cp_argv[i], entry->name, strlen(cp_argv[i])) == 0) {
+						num_files_ok++;
+						continue;
+					}
 			}
+		}
+
+		/* For certain combinations of flags and filetypes, a file
+		 * won't get checks and should be ignored */
+		if (!state->chk_mtime && entry->type == CONTENTS_SYM) {
+			--num_files;
+			++num_files_ignored;
+			if (state->qc_update)
+				fputs(buffer, fp_contents_update);
 
-			/* validate digest (handles MD5 / SHA1) */
+			continue;
+		}
+
+		/* Digest checks only work on regular files
+		 * Note: We don't check for state->chk_hash when entering
+		 * but rather in digest-check #3, because we only succeed
+		 * tests/qcheck/list04.good if when chk_hash is false, we
+		 * do check hashes, but only print mismatched digests as
+		 * 'ignored file'. */
+		if (entry->digest && S_ISREG(st.st_mode)) {
+			/* Validate digest (handles MD5 / SHA1)
+			 * Digest-check 1/3:
+			 * Should we check digests? */
+			char *f_digest;
 			uint8_t hash_algo;
-			char *hashed_file;
-			hash_cb_t hash_cb = state->undo_prelink ? hash_cb_prelink_undo : hash_cb_default;
-			switch (strlen(e->digest)) {
+			switch (strlen(entry->digest)) {
 				case 32: hash_algo = HASH_MD5; break;
 				case 40: hash_algo = HASH_SHA1; break;
 				default: hash_algo = 0; break;
 			}
+
 			if (!hash_algo) {
 				if (state->chk_hash) {
-					qcprintf(" %sUNKNOWN DIGEST%s: '%s' for '%s'\n", RED, NORM, e->digest, e->name);
+					qcprintf(" %sUNKNOWN DIGEST%s: '%s' for '%s'\n", RED, NORM, entry->digest, entry->name);
 					++num_files_unknown;
 				} else {
 					--num_files;
 					++num_files_ignored;
 					if (state->qc_update)
-						fputs(buffer, fpx);
+						fputs(buffer, fp_contents_update);
 				}
 				continue;
 			}
-			hashed_file = (char *)hash_file_at_cb(pkg_ctx->cat_ctx->ctx->portroot_fd, e->name + 1, hash_algo, hash_cb);
-			if (!hashed_file) {
+
+			hash_cb_t hash_cb = state->undo_prelink ? hash_cb_prelink_undo : hash_cb_default;
+			f_digest = (char *)hash_file_at_cb(pkg_ctx->cat_ctx->ctx->portroot_fd, entry->name + 1, hash_algo, hash_cb);
+
+			/* Digest-check 2/3:
+			 * Can we get a digest of the file? */
+			if (!f_digest) {
 				++num_files_unknown;
-				free(hashed_file);
-				if (state->qc_update) {
-					fputs(buffer, fpx);
-					if (!verbose)
-						continue;
-				}
-				qcprintf(" %sPERM %4o%s: %s\n", RED, (unsigned int)(st.st_mode & 07777), NORM, e->name);
+				free(f_digest);
+
+				if (state->qc_update)
+					fputs(buffer, fp_contents_update);
+
+				if (verbose)
+					qcprintf(" %sPERM %4o%s: %s\n", RED, (unsigned int)(st.st_mode & 07777), NORM, entry->name);
+
 				continue;
-			} else if (strcmp(e->digest, hashed_file)) {
+			}
+
+			/* Digest-check 3/3:
+			 * Does the digest equal what portage recorded? */
+			if (strcmp(entry->digest, f_digest) != 0) {
 				if (state->chk_hash) {
-					const char *digest_disp;
 					if (state->qc_update)
-						fprintf(fpx, "obj %s %s %"PRIu64"\n", e->name, hashed_file, (uint64_t)st.st_mtime);
+						fprintf(fp_contents_update, "obj %s %s %"PRIu64"\n", entry->name, f_digest, (uint64_t)st.st_mtime);
+
+					const char *digest_disp;
 					switch (hash_algo) {
-						case HASH_MD5:  digest_disp = "MD5"; break;
-						case HASH_SHA1: digest_disp = "SHA1"; break;
-						default:        digest_disp = "UNK"; break;
+						case HASH_MD5:	digest_disp = "MD5"; break;
+						case HASH_SHA1:	digest_disp = "SHA1"; break;
+						default: digest_disp = "UNK"; break;
 					}
-					qcprintf(" %s%s-DIGEST%s: %s", RED, digest_disp, NORM, e->name);
+
+					qcprintf(" %s%s-DIGEST%s: %s", RED, digest_disp, NORM, entry->name);
 					if (verbose)
-						qcprintf(" (recorded '%s' != actual '%s')", e->digest, hashed_file);
+						qcprintf(" (recorded '%s' != actual '%s')", entry->digest, f_digest);
 					qcprintf("\n");
 				} else {
 					--num_files;
 					++num_files_ignored;
 					if (state->qc_update)
-						fputs(buffer, fpx);
+						fputs(buffer, fp_contents_update);
 				}
-				free(hashed_file);
+
+				free(f_digest);
 				continue;
-			} else if (e->mtime && e->mtime != st.st_mtime) {
-				if (state->chk_mtime) {
-					qcprintf(" %sMTIME%s: %s", RED, NORM, e->name);
-					if (verbose)
-						qcprintf(" (recorded '%"PRIu64"' != actual '%"PRIu64"')", (uint64_t)e->mtime, (uint64_t)st.st_mtime);
-					qcprintf("\n");
+			}
 
-					/* This can only be an obj, dir and sym have no digest */
-					if (state->qc_update)
-						fprintf(fpx, "obj %s %s %"PRIu64"\n", e->name, e->digest, (uint64_t)st.st_mtime);
+			free(f_digest);
+		}
+
+		/* Validate mtimes */
+		if (state->chk_mtime && entry->mtime && entry->mtime != st.st_mtime) {
+			qcprintf(" %sMTIME%s: %s", RED, NORM, entry->name);
+			if (verbose)
+				qcprintf(" (recorded '%"PRIu64"' != actual '%"PRIu64"')", (uint64_t)entry->mtime, (uint64_t)st.st_mtime);
+			qcprintf("\n");
+
+			/* Update mtime */
+			if (state->qc_update) {
+				if (entry->type == CONTENTS_SYM) {
+					fprintf(fp_contents_update, "sym %s -> %s %"PRIu64"\n", entry->name, entry->sym_target, (uint64_t)st.st_mtime);
 				} else {
-					--num_files;
-					++num_files_ignored;
-					if (state->qc_update)
-						fputs(buffer, fpx);
+					fprintf(fp_contents_update, "obj %s %s %"PRIu64"\n", entry->name, entry->digest, (uint64_t)st.st_mtime);
 				}
-				free(hashed_file);
-				continue;
-			} else {
-				if (state->qc_update)
-					fputs(buffer, fpx);
-				free(hashed_file);
 			}
-		} else if (e->mtime && e->mtime != st.st_mtime) {
-			if (state->chk_mtime) {
-				qcprintf(" %sMTIME%s: %s", RED, NORM, e->name);
-				if (verbose)
-					qcprintf(" (recorded '%"PRIu64"' != actual '%"PRIu64"')",
-						(uint64_t)e->mtime, (uint64_t)st.st_mtime);
-				qcprintf("\n");
 
-				/* This can only be a sym */
-				if (state->qc_update)
-					fprintf(fpx, "sym %s -> %s %"PRIu64"\n", e->name, e->sym_target, (uint64_t)st.st_mtime);
-			} else {
-				--num_files;
-				++num_files_ignored;
-				if (state->qc_update)
-					fputs(buffer, fpx);
-			}
 			continue;
-		} else {
-			if (state->qc_update)
-				fputs(buffer, fpx);
 		}
- cfg_protected:
-		++num_files_ok;
+
+		/* Success! */
+		if (state->qc_update)
+			fputs(buffer, fp_contents_update);
+
+		num_files_ok++;
 	}
 	free(line);
 	free(buffer);
-	fclose(fp);
+	fclose(fp_contents);
 
 	if (!state->chk_config_protect) {
 		freeargv(cp_argc, cp_argv);
@@ -259,13 +280,13 @@ qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_state *state)
 	}
 
 	if (state->qc_update) {
-		if (fchown(fd, cst.st_uid, cst.st_gid)) {
+		if (fchown(fd_contents, cst.st_uid, cst.st_gid)) {
 			/* meh */;
 		}
-		if (fchmod(fd, cst.st_mode)) {
+		if (fchmod(fd_contents, cst.st_mode)) {
 			/* meh */;
 		}
-		fclose(fpx);
+		fclose(fp_contents_update);
 		if (renameat(pkg_ctx->fd, "CONTENTS~", pkg_ctx->fd, "CONTENTS"))
 			unlinkat(pkg_ctx->fd, "CONTENTS~", 0);
 		if (!verbose)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-12-24 16:02 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-12-24 16:02 UTC (permalink / raw
  To: gentoo-commits

commit:     6cc0db6da1808164e159ad6f0f6fbc8b623f6fb8
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Dec 24 16:02:30 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Dec 24 16:02:30 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6cc0db6d

docs: update

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 README.md | 25 +++++++++++++++----------
 TODO.md   | 22 +++++-----------------
 2 files changed, 20 insertions(+), 27 deletions(-)

diff --git a/README.md b/README.md
index 59692a7..8400c68 100644
--- a/README.md
+++ b/README.md
@@ -2,9 +2,10 @@
 
 | What     | How                                                       |
 | -------- | --------------------------------------------------------- |
-| HOMEPAGE | https://wiki.gentoo.org/wiki/Portage-utils                |
-| GIT      | git clone git://anongit.gentoo.org/proj/portage-utils.git |
+| HOMEPAGE | https://wiki.gentoo.org/wiki/Q\_applets                   |
+| GIT      | https://anongit.gentoo.org/git/proj/portage-utils.git     |
 | VIEWVCS  | https://gitweb.gentoo.org/proj/portage-utils.git/         |
+| GITHUB   | https://github.com/gentoo/portage-utils                   |
 | STATUS   | [![Build Status](https://travis-ci.org/gentoo/portage-utils.svg?branch=master)](https://travis-ci.org/gentoo/portage-utils) [![Coverity Status](https://scan.coverity.com/projects/9213/badge.svg)](https://scan.coverity.com/projects/gentoo-portage-utils) |
 
 portage-utils is a small set of utilities for working with Portage, Gentoo
@@ -18,40 +19,41 @@ Alternatively, run `configure` followed by `make`.
 
 ## Helping out
 
-There's a large [TODO](./TODO.md) list with various ideas for improvements.
+There's a large [TODO](./TODO.md) list with various ideas for
+improvements.  File a bug on Gentoo's Bugzilla, or use Github's issues
+and pull requests.
 
 There's also a [HACKING](./HACKING.md) doc to help you get started.
 
 ## Examples
 
-* find elf files linking to old openssl<br>
+* find elf files linking to old openssl (using app-misc/pax-utils)<br>
   `qlist -ao | scanelf -BqgN libssl.so.0.9.6 -f -`
 
-* print a package.use<br>
+* produce a package.use file for currently installed packages<br>
   `qlist -UCq | grep ' ' > package.use`
 
 * find orphan files not owned by any package in /lib and /usr/lib<br>
   `qfile -o {,/usr}/lib/*`
 	
 * get PORTDIR<br>
-  `DEBUG=: ./q -Ch 2>&1 | grep ^PORTDIR | awk '{print $3}`
+  `env DEBUG=: q -Ch 2>&1 | grep ^PORTDIR | awk '{print $3}`
 
 * Verify all packages<br>
-  `qcheck -a`
+  `qcheck`
 
 ## Contact
 
 ### Bugs
 
 Please file bugs at:
-	https://bugs.gentoo.org/enter_bug.cgi?product=Portage%20Development&format=guided
-
-Use Component of "Third-Party Tools".
+	https://bugs.gentoo.org/enter_bug.cgi?product=Portage%20Development&component=Tools&format=guided
 
 ### Developers
 
 * solar@gentoo.org
 * vapier@gentoo.org
+* grobian@gentoo.org
 
 ## Notes
 
@@ -59,6 +61,9 @@ Use Component of "Third-Party Tools".
 
 Having your PORTDIR and VDB on the right file system helps dramatically
 
+Nowadays this should rarely matter, but on smaller scale (embedded) or
+older hardware, consider the following.
+
 IDE raid with PORTDIR on reiserfs:
 
 ```sh

diff --git a/TODO.md b/TODO.md
index 86ebbd7..24e5eca 100644
--- a/TODO.md
+++ b/TODO.md
@@ -1,9 +1,9 @@
 # Common
 
 - unify match behavior:
-	- default *foo*
+	- default \*foo\*
 	- -e foo
-	- -r (-R ?) regexp foo.*
+	- -r (-R ?) regexp foo.\*
 
 - disable color when tty = NULL; may break less?
 
@@ -25,10 +25,9 @@
 
 - only 32bit values are supported for revision (-r#)
 - only 64bit values are supported in any individual version component
-  foo-(1234)_alpha(56789)
+  foo-(1234)\_alpha(56789)
 - these limits should not be an issue for all practical purposes
 - need to handle USE deps like: cat/pkg-123[foo(+)]
-- show support slots like: qmerge -U automake:1.12
 
 # qmerge
 
@@ -40,21 +39,14 @@
 - gpg sign the packages file (before compression)
 - binary vdb (sqlite) ... talk to zmedico
 - remote vdb
-- don't bother emitting any "DIR" entries to CONTENTS ?
-	- auto rmdir any empty dirs
-- avoid Packages fetching all the damned time
 - parallel fetch tbz2s
-- check order of pkg_{pre,post}{inst,rm} during install, unmerge, and upgrade
-- env is not saved/restored between pkg_{pre,post}inst (see portage and REPO_LAYOUT_CONF_WARN)
+- check order of pkg\_{pre,post}{inst,rm} during install, unmerge, and upgrade
+- env is not saved/restored between pkg\_{pre,post}inst (see portage and REPO\_LAYOUT\_CONF\_WARN)
 - support installing via path to tbz2 package
 - support TTL field in binpkgs file
 - merge duplicate atoms on the CLI (`qmerge -Uq nano nano nano`)
 - unmerging should clean out @world set
 
-# qcache
-
-- need to convert it to new metadata/md5 style
-
 # qdepends
 
 - support querying uninstalled packages (via metadata/md5 cache)
@@ -71,7 +63,3 @@
 # qsync
 
 - rewrite to use new repos.conf standard
-
-# qlist
-
-- support atoms instead of exact matches


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-12-20 18:24 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-12-20 18:24 UTC (permalink / raw
  To: gentoo-commits

commit:     e3d45aadf559ba2ff9c929715bbeade5a42e3634
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 20 18:11:43 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Dec 20 18:24:30 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e3d45aad

qmerge: support "negative" INSTALL_MASK entries

Reworked qmerge install_mask handling to support negative entries in
INSTALL_MASK, which "undo" (part of) a previous masking.
This should implement the same behaviour as
https://archives.gentoo.org/gentoo-portage-dev/message/29e128a9f41122fa0420c1140f7b7f94

Along the way some behavioural changes were made:
- pretend mode now prints what would be merged (use with -y to be
  useful)
- directory objects are recorded and merged again

Bug: https://bugs.gentoo.org/656318
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 561 ++++++++++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 393 insertions(+), 168 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index a1b5a86..535966e 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,9 +1,10 @@
 /*
- * Copyright 2005-2018 Gentoo Foundation
+ * Copyright 2005-2018 Gentoo Authors
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2014 Mike Frysinger  - <vapier@gentoo.org>
+ * Copyright 2018-     Fabian Groffen  - <grobian@gentoo.org>
  */
 
 #ifdef APPLET_qmerge
@@ -100,7 +101,7 @@ typedef struct llist_char_t llist_char;
 
 static void pkg_fetch(int, const depend_atom *, const struct pkg_t *);
 static void pkg_merge(int, const depend_atom *, const struct pkg_t *);
-static int pkg_unmerge(q_vdb_pkg_ctx *, queue *);
+static int pkg_unmerge(q_vdb_pkg_ctx *, queue *, int, char **, int, char **);
 static struct pkg_t *grab_binpkg_info(const char *);
 static char *find_binpkg(const char *);
 
@@ -289,52 +290,252 @@ config_protected(const char *buf, int cp_argc, char **cp_argv,
 }
 
 static void
-crossmount_rm(const char *fname, const struct stat * const st)
+crossmount_rm(const char *fname, const struct stat * const st,
+		int fd, char *qpth)
 {
 	struct stat lst;
 
-	assert(pretend == 0);
-
-	if (lstat(fname, &lst) == -1)
+	if (fstatat(fd, fname, &lst, AT_SYMLINK_NOFOLLOW) == -1)
 		return;
 	if (lst.st_dev != st->st_dev) {
 		warn("skipping crossmount install masking: %s", fname);
 		return;
 	}
-	qprintf("%s<<<%s %s\n", YELLOW, NORM, fname);
-	rm_rf(fname);
+	qprintf("%s<<<%s %s/%s (INSTALL_MASK)\n", YELLOW, NORM, qpth, fname);
+	rm_rf_at(fd, fname);
+}
+
+static int
+q_merge_filter_self_parent(const struct dirent *de)
+{
+	if (de->d_name[0] == '.' && (de->d_name[1] == '\0' ||
+			 (de->d_name[1] == '.' && de->d_name[2] == '\0')))
+		return 0;
+
+	return 1;
 }
 
+enum inc_exc { INCLUDE = 1, EXCLUDE = 2 };
+
 static void
-install_mask_pwd(int iargc, char **iargv, const struct stat * const st)
+install_mask_check_dir(
+		char ***maskv,
+		int maskc,
+		const struct stat * const st,
+		int fd,
+		ssize_t level,
+		enum inc_exc parent_mode,
+		char *qpth)
 {
-	char buf[1024];
+	struct dirent **files;
+	int cnt;
 	int i;
+	int j;
+	enum inc_exc mode;
+	enum inc_exc child_mode;
+#ifndef DT_DIR
+	struct stat s;
+#endif
+	char *npth = qpth + strlen(qpth);
+
+	cnt = scandirat(fd, ".", &files, q_merge_filter_self_parent, alphasort);
+	for (j = 0; j < cnt; j++) {
+		mode = child_mode = parent_mode;
+		for (i = 0; i < maskc; i++) {
+			if ((ssize_t)maskv[i][0] < 0) {
+				/* relative matches need to be a "file", as the Portage
+				 * implementation suggests, so that's easy for us here,
+				 * since we can just match it against each component in
+				 * the path */
+				if ((ssize_t)maskv[i][0] < -1)
+					continue;  /* this is unsupported, so skip it */
+				/* this also works if maskv happens to be a glob */
+				if (fnmatch(maskv[i][1], files[j]->d_name, FNM_PERIOD) != 0)
+					continue;
+				mode = child_mode = maskv[i][2] ? INCLUDE : EXCLUDE;
+			} else if ((ssize_t)maskv[i][0] < level) {
+				/* either this is a mask that didn't match, or it
+				 * matched, but a negative match exists for a deeper
+				 * level, parent_mode should reflect this */
+				continue;
+			} else {
+				if (fnmatch(maskv[i][level], files[j]->d_name, FNM_PERIOD) != 0)
+					continue;
 
-	for (i = 1; i < iargc; i++) {
+				if ((ssize_t)maskv[i][0] == level)  /* full mask match */
+					mode = child_mode =
+						(ssize_t)maskv[i][level + 1] ? INCLUDE : EXCLUDE;
+				else if (maskv[i][(ssize_t)maskv[i][0] + 1])
+					/* partial include mask */
+					mode = INCLUDE;
+			}
+		}
 
-		if (iargv[i][0] != '/')
+		DBG("%s/%s: %s/%s", qpth, files[j]->d_name,
+				mode == EXCLUDE       ? "EXCLUDE" : "INCLUDE",
+				child_mode == EXCLUDE ? "EXCLUDE" : "INCLUDE");
+		if (mode == EXCLUDE) {
+			crossmount_rm(files[j]->d_name, st, fd, qpth);
 			continue;
+		}
 
-		snprintf(buf, sizeof(buf), ".%s", iargv[i]);
+#ifdef DT_DIR
+		if (files[j]->d_type == DT_DIR) {
+#else
+		if (fstatat(fd, files[j]->d_name, &s, AT_SYMLINK_NOFOLLOW) != 0)
+			continue;
+		if (S_ISDIR(s.st_mode)) {
+#endif
+			int subfd = openat(fd, files[j]->d_name, O_RDONLY);
+			if (subfd < 0)
+				continue;
+			snprintf(npth, _Q_PATH_MAX - (npth - qpth),
+					"/%s", files[j]->d_name);
+			install_mask_check_dir(maskv, maskc, st, subfd,
+					level + 1, child_mode, qpth);
+			close(subfd);
+			*npth = '\0';
+		}
+	}
+}
 
-		if ((strchr(iargv[i], '*') != NULL) || (strchr(iargv[i], '{') != NULL)) {
-			int g;
-			glob_t globbuf;
+static void
+install_mask_pwd(int iargc, char **iargv, const struct stat * const st, int fd)
+{
+	char *p;
+	int i;
+	size_t cnt;
+	size_t maxdirs;
+	char **masks;
+	size_t masksc;
+	char ***masksv;
+	char qpth[_Q_PATH_MAX];
+
+	/* we have to deal with "negative" masks, see
+	 * https://archives.gentoo.org/gentoo-portage-dev/message/29e128a9f41122fa0420c1140f7b7f94
+	 * which means we'll need to see what thing matches last
+	 * (inclusion or exclusion) for *every* file :( */
+
+   /*
+	example package contents:
+	/e/t1
+    /u/b/t1
+	/u/b/t2
+	/u/l/lt1
+	/u/s/d/t1
+	/u/s/m/m1/t1
+	/u/s/m/m5/t2
+
+	masking rules:     array encoding:
+	 /u/s              2 u s 0          relative=0 include=0
+	-/u/s/m/m1         4 u s m m1 1     relative=0 include=1
+	 e                -1 e 0            relative=1 include=0
+
+	should result in:
+	/u/b/t1
+	/u/b/t2
+	/u/l/lt1
+	/u/s/m/m1/t1
+	strategy:
+	- for each dir level
+	  - find if there is a match on that level in rules
+	  - if the last match is the full mask
+	    - if the mask is negated, do not remove entry
+	    - else, remove entry
+	  - if the last match is negated, partial and a full mask matched before
+	    - do not remove entry
+	practice:
+	/e | matches "e" -> remove
+	/u | matches partial last negated -> continue
+	  /b | doesn't match -> leave subtree
+	  /l | doesn't match -> leave subtree
+	  /s | match, partial last negated match -> remember match, continue
+	    /d | doesn't match -> remembered match, remove subtree
+		/m | partial match negated -> continue
+		  /m1 | match negated -> leave subtree
+		  /m5 | doesn't match -> remembered match, remove subtree
+	*/
+
+	/* find the longest path so we can allocate a matrix */
+	maxdirs = 0;
+	for (i = 1; i < iargc; i++) {
+		char lastc = '/';
+
+		cnt = 1; /* we always have "something", right? */
+		p = iargv[i];
+		if (*p == '-')
+			p++;
+		for (; *p != '\0'; p++) {
+			/* eliminate duplicate /-es, also ignore the leading / in
+			 * the count */
+			if (*p == '/' && *p != lastc)
+				cnt++;
+			lastc = *p;
+		}
+		if (cnt > maxdirs)
+			maxdirs = cnt;
+	}
+	maxdirs += 2;  /* allocate plus relative and include elements */
 
-			globbuf.gl_offs = 0;
-			if (glob(buf, GLOB_DOOFFS|GLOB_BRACE, NULL, &globbuf) == 0) {
-				for (g = 0; g < (int)globbuf.gl_pathc; g++) {
-					strncpy(buf, globbuf.gl_pathv[g], sizeof(buf));
-					/* qprintf("globbed: %s\n", globbuf.gl_pathv[g]); */
-					crossmount_rm(globbuf.gl_pathv[g], st);
-				}
-				globfree(&globbuf);
+	/* allocate and populate matrix */
+	masksc = iargc - 1;
+	masks = xmalloc(sizeof(char *) * (maxdirs * masksc));
+	masksv = xmalloc(sizeof(char **) * (masksc));
+	for (i = 1; i < iargc; i++) {
+		masksv[i - 1] = &masks[(i - 1) * maxdirs];
+		p = iargv[i];
+		cnt = 1;  /* start after count */
+		/* ignore include marker */
+		if (*p == '-')
+			p++;
+		/* strip of leading slash(es) */
+		while (*p == '/')
+			p++;
+		masks[((i - 1) * maxdirs) + cnt] = p;
+		for (; *p != '\0'; p++) {
+			if (*p == '/') {
+				/* fold duplicate slashes */
+				do {
+					*p++ = '\0';
+				} while (*p == '/');
+				cnt++;
+				masks[((i - 1) * maxdirs) + cnt] = p;
 			}
-			continue;
 		}
-		crossmount_rm(iargv[i], st);
+		/* brute force cast below values, a pointer basically is size_t,
+		 * which is large enough to store what we need here */
+		p = iargv[i];
+		/* set include bit */
+		if (*p == '-') {
+			masks[((i - 1) * maxdirs) + cnt + 1] = (char *)1;
+			p++;
+		} else {
+			masks[((i - 1) * maxdirs) + cnt + 1] = (char *)0;
+		}
+		/* set count */
+		masks[((i - 1) * maxdirs) + 0] =
+			(char *)((*p == '/' ? 1 : -1) * cnt);
 	}
+
+#if EBUG
+	printf("applying install masks:\n");
+	for (cnt = 0; cnt < masksc; cnt++) {
+		ssize_t plen = (ssize_t)masksv[cnt][0];
+		printf("%3zd  ", plen);
+		if (plen < 0)
+			plen = -plen;
+		for (i = 1; i <= plen; i++)
+			printf("%s ", masksv[cnt][i]);
+		printf(" %zd\n", (size_t)masksv[cnt][i]);
+	}
+#endif
+
+	cnt = snprintf(qpth, _Q_PATH_MAX, "%s", CONFIG_EPREFIX);
+	cnt--;
+	if (qpth[cnt] == '/')
+		qpth[cnt] = '\0';
+
+	install_mask_check_dir(masksv, masksc, st, fd, 1, INCLUDE, qpth);
 }
 
 static char *
@@ -492,7 +693,7 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 /* Copy one tree (the single package) to another tree (ROOT) */
 static int
 merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
-              FILE *contents, queue **objs, char **cpathp, int iargc, char **iargv,
+              FILE *contents, queue **objs, char **cpathp,
               int cp_argc, char **cp_argv, int cpm_argc, char **cpm_argv)
 {
 	int i, ret, subfd_src, subfd_dst;
@@ -538,15 +739,6 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 		}
 		strcpy(cpath + clen + 1, name);
 
-		/* Check INSTALL_MASK */
-		for (i = 1; i < iargc; ++i) {
-			if (fnmatch(iargv[i], cpath, 0) == 0) {
-				unlinkat(subfd_src, name, 0);
-				unlinkat(subfd_dst, name, 0);
-				continue;
-			}
-		}
-
 		/* Find out what the source path is */
 		if (fstatat(subfd_src, name, &st, AT_SYMLINK_NOFOLLOW)) {
 			warnp("could not read %s", cpath);
@@ -555,34 +747,32 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 
 		/* Migrate a directory */
 		if (S_ISDIR(st.st_mode)) {
-			if (mkdirat(subfd_dst, name, st.st_mode)) {
+			if (!pretend && mkdirat(subfd_dst, name, st.st_mode)) {
 				if (errno != EEXIST) {
-					warnp("could not read %s", cpath);
+					warnp("could not create %s", cpath);
 					continue;
 				}
 
 				/* XXX: update times of dir ? */
 			}
 
-#if 0		/* We filter out "dir" as it's generally unnecessary cruft */
 			/* syntax: dir dirname */
-			fprintf(contents, "dir %s\n", cpath);
+			if (!pretend)
+				fprintf(contents, "dir %s\n", cpath);
 			*objs = add_set(cpath, *objs);
 			qprintf("%s>>>%s %s%s%s/\n", GREEN, NORM, DKBLUE, cpath, NORM);
-#endif
 
 			/* Copy all of these contents */
-			merge_tree_at(subfd_src, name, subfd_dst, name, contents, objs, cpathp,
-				iargc, iargv, cp_argc, cp_argv, cpm_argc, cpm_argv);
+			merge_tree_at(subfd_src, name, subfd_dst, name, contents, objs,
+					cpathp, cp_argc, cp_argv, cpm_argc, cpm_argv);
 			cpath = *cpathp;
 			mnlen = 0;
 
 			/* In case we didn't install anything, prune the empty dir */
-			unlinkat(subfd_dst, name, AT_REMOVEDIR);
-		}
-
-		/* Migrate a file */
-		else if (S_ISREG(st.st_mode)) {
+			if (!pretend)
+				unlinkat(subfd_dst, name, AT_REMOVEDIR);
+		} else if (S_ISREG(st.st_mode)) {
+			/* Migrate a file */
 			struct timespec times[2];
 			int fd_srcf, fd_dstf;
 			unsigned char *hash;
@@ -590,7 +780,9 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 
 			/* syntax: obj filename hash mtime */
 			hash = hash_file_at(subfd_src, name, HASH_MD5);
-			fprintf(contents, "obj %s %s %"PRIu64"\n", cpath, hash, (uint64_t)st.st_mtime);
+			if (!pretend)
+				fprintf(contents, "obj %s %s %"PRIu64"\n",
+						cpath, hash, (uint64_t)st.st_mtime);
 			free(hash);
 
 			/* Check CONFIG_PROTECT */
@@ -617,6 +809,9 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 			}
 			*objs = add_set(cpath, *objs);
 
+			if (pretend)
+				continue;
+
 			/* First try fast path -- src/dst are same device */
 			if (renameat(subfd_src, dname, subfd_dst, name) == 0)
 				continue;
@@ -633,7 +828,8 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 			 * XXX: Should we make this random ?
 			 */
 			tmpname = ".qmerge.update";
-			fd_dstf = openat(subfd_dst, tmpname, O_WRONLY|O_CLOEXEC|O_CREAT|O_TRUNC, st.st_mode);
+			fd_dstf = openat(subfd_dst, tmpname,
+					O_WRONLY|O_CLOEXEC|O_CREAT|O_TRUNC, st.st_mode);
 			if (fd_dstf < 0) {
 				warnp("could not write %s", cpath);
 				close(fd_srcf);
@@ -674,10 +870,8 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 				warnp("could not rename %s to %s", tmpname, cpath);
 				continue;
 			}
-		}
-
-		/* Migrate a symlink */
-		else if (S_ISLNK(st.st_mode)) {
+		} else if (S_ISLNK(st.st_mode)) {
+			/* Migrate a symlink */
 			size_t len = st.st_size;
 			char *sym = alloca(len + 1);
 
@@ -689,10 +883,16 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 			sym[len] = '\0';
 
 			/* syntax: sym src -> dst mtime */
-			fprintf(contents, "sym %s -> %s %"PRIu64"\n", cpath, sym, (uint64_t)st.st_mtime);
-			qprintf("%s>>>%s %s%s -> %s%s\n", GREEN, NORM, CYAN, cpath, sym, NORM);
+			if (!pretend)
+				fprintf(contents, "sym %s -> %s %"PRIu64"\n",
+						cpath, sym, (uint64_t)st.st_mtime);
+			qprintf("%s>>>%s %s%s -> %s%s\n", GREEN, NORM,
+					CYAN, cpath, sym, NORM);
 			*objs = add_set(cpath, *objs);
 
+			if (pretend)
+				continue;
+
 			/* Make it in the dest tree */
 			if (symlinkat(sym, subfd_dst, name)) {
 				/* If the symlink exists, unlink it and try again */
@@ -708,10 +908,8 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 			times[0] = get_stat_mtime(&st);
 			times[1] = get_stat_mtime(&st);
 			utimensat(subfd_dst, name, times, AT_SYMLINK_NOFOLLOW);
-		}
-
-		/* WTF is this !? */
-		else {
+		} else {
+			/* WTF is this !? */
 			warnp("unknown file type %s", cpath);
 			continue;
 		}
@@ -726,34 +924,6 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 	return ret;
 }
 
-/* Copy one tree (the single package) to another tree (ROOT) */
-static int
-merge_tree(const char *src, const char *dst, FILE *contents,
-           queue **objs, int iargc, char **iargv)
-{
-	int ret;
-	int cp_argc, cpm_argc;
-	char **cp_argv, **cpm_argv;
-	char *cpath;
-
-	/* XXX: be nice to pull this out of the current func
-	 *      so we don't keep reparsing the same env var
-	 *      when unmerging multiple packages.
-	 */
-	makeargv(config_protect, &cp_argc, &cp_argv);
-	makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
-
-	cpath = xstrdup("");
-	ret = merge_tree_at(AT_FDCWD, src, AT_FDCWD, dst, contents, objs, &cpath,
-		iargc, iargv, cp_argc, cp_argv, cpm_argc, cpm_argv);
-	free(cpath);
-
-	freeargv(cp_argc, cp_argv);
-	freeargv(cpm_argc, cpm_argv);
-
-	return ret;
-}
-
 /* oh shit getting into pkg mgt here. FIXME: write a real dep resolver. */
 static void
 pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
@@ -774,6 +944,10 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	char c;
 	int iargc;
 	const char *compr;
+	int cp_argc;
+	int cpm_argc;
+	char **cp_argv;
+	char **cpm_argv;
 
 	if (!install || !pkg || !atom)
 		return;
@@ -830,30 +1004,39 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 
 						resolved = find_binpkg(name);
 
-						IF_DEBUG(fprintf(stderr, "+Atom: argv0(%s) resolved(%s)\n", name, resolved));
+						IF_DEBUG(fprintf(stderr,
+									"+Atom: argv0(%s) resolved(%s)\n",
+									name, resolved));
 
 						if (strlen(resolved) < 1) {
-							warn("Cant find a binpkg for %s from rdepend(%s)", name, pkg->RDEPEND);
+							warn("Cant find a binpkg for %s from rdepend(%s)",
+									name, pkg->RDEPEND);
 							continue;
 						}
 
 						/* ratom = atom_explode(resolved); */
-						subpkg = grab_binpkg_info(resolved);	/* free me later */
+						subpkg = grab_binpkg_info(resolved); /* free me later */
 
 						assert(subpkg != NULL);
-						IF_DEBUG(fprintf(stderr, "+Subpkg: %s/%s\n", subpkg->CATEGORY, subpkg->PF));
+						IF_DEBUG(fprintf(stderr, "+Subpkg: %s/%s\n",
+									subpkg->CATEGORY, subpkg->PF));
 
-						/* look at installed versions now. If NULL or < merge this pkg */
-						snprintf(buf, sizeof(buf), "%s/%s", subpkg->CATEGORY, subpkg->PF);
+						/* look at installed versions now.
+						 * If NULL or < merge this pkg */
+						snprintf(buf, sizeof(buf), "%s/%s",
+								subpkg->CATEGORY, subpkg->PF);
 
 						ratom = atom_explode(buf);
 
-						p = best_version(subpkg->CATEGORY, subpkg->PF, subpkg->SLOT);
+						p = best_version(subpkg->CATEGORY,
+								subpkg->PF, subpkg->SLOT);
 
 						/* we dont want to remerge equal versions here */
 						IF_DEBUG(fprintf(stderr, "+Installed: %s\n", p));
 						if (strlen(p) < 1)
-							if (!((strcmp(pkg->PF, subpkg->PF) == 0) && (strcmp(pkg->CATEGORY, subpkg->CATEGORY) == 0)))
+							if (!((strcmp(pkg->PF, subpkg->PF) == 0) &&
+										(strcmp(pkg->CATEGORY,
+												subpkg->CATEGORY) == 0)))
 								pkg_fetch(level+1, ratom, subpkg);
 
 						atom_implode(subatom);
@@ -867,8 +1050,6 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		}
 		freeargv(ARGC, ARGV);
 	}
-	if (pretend)
-		return;
 
 	/* Get a handle on the main vdb repo */
 	vdb_ctx = q_vdb_open();
@@ -1000,13 +1181,11 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 
 	/* extract the binary package data */
 	mkdir("image", 0755);
-	if (compr[0] != 'I')
-	{
+	if (compr[0] != 'I') {
 		snprintf(buf, sizeof(buf),
 			BUSYBOX " tar -x%s%s -f %s.tar.bz2 -C image/",
 			((verbose > 1) ? "v" : ""), compr, pkg->PF);
-	} else
-	{
+	} else {
 		/* busybox's tar has no -I option. Thus, although we possibly
 		 * use busybox's shell and tar, we thus pipe, expecting the
 		 * corresponding (de)compression tool to be in PATH; if not,
@@ -1025,48 +1204,75 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	pkg_run_func("vdb", phases, "pkg_setup", D, T);
 	pkg_run_func("vdb", phases, "pkg_preinst", D, T);
 
-	/* XXX: kill this off */
-	xchdir("image");
-
-	if (stat(".", &st) == -1)
-		err("Cant stat pwd");
-
-	/* Initialize INSTALL_MASK and common stuff */
-	makeargv(install_mask, &iargc, &iargv);
-	/* XXX: Would be better if INSTALL_MASK deleted from image/
-	 *      so we didn't have to parse it while doing merge_tree() */
-	install_mask_pwd(iargc, iargv, &st);
-
-	if (strstr(features, "noinfo")) rm_rf("./usr/share/info");
-	if (strstr(features, "noman" )) rm_rf("./usr/share/man");
-	if (strstr(features, "nodoc" )) rm_rf("./usr/share/doc");
+	{
+		int imagefd = open("image" CONFIG_EPREFIX, O_RDONLY);
+		size_t masklen = strlen(install_mask) + 1 +
+				15 + 1 + 14 + 1 + 14 + 1 + 1;  /* worst case scenario */
+		char *imask = xmalloc(masklen);
+		size_t maskp;
+
+		if (fstat(imagefd, &st) == -1) {
+			close(imagefd);
+			err("Cannot stat image dirfd");
+		}
 
-	/* we dont care about the return code */
-	rmdir("./usr/share");
+		/* rely on INSTALL_MASK code to remove optional dirs */
+		maskp = snprintf(imask, masklen, "%s ", install_mask);
+		if (strstr(features, "noinfo") != NULL)
+			maskp += snprintf(imask + maskp, masklen - maskp,
+					"/usr/share/info ");
+		if (strstr(features, "noman" ) != NULL)
+			maskp += snprintf(imask + maskp, masklen - maskp,
+					"/usr/share/man ");
+		if (strstr(features, "nodoc" ) != NULL)
+			maskp += snprintf(imask + maskp, masklen - maskp,
+					"/usr/share/doc ");
+
+		/* Initialize INSTALL_MASK and common stuff */
+		makeargv(imask, &iargc, &iargv);
+		free(imask);
+		install_mask_pwd(iargc, iargv, &st, imagefd);
+		freeargv(iargc, iargv);
+
+		/* we dont care about the return code, if it's empty, we want it
+		 * gone */
+		unlinkat(imagefd, "./usr/share", AT_REMOVEDIR);
+
+		close(imagefd);
+	}
 
-	/* XXX: Once we kill xchdir(image), this can die too */
-	xchdir("..");
+	makeargv(config_protect, &cp_argc, &cp_argv);
+	makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
 
 	if ((contents = fopen("vdb/CONTENTS", "w")) == NULL)
 		errf("come on wtf?");
 	objs = NULL;
-	if (merge_tree("image", portroot, contents, &objs, iargc, iargv))
-		errp("failed to merge to %s", portroot);
-	fclose(contents);
+	{
+		char *cpath;
+		int ret;
+
+		cpath = xstrdup("");  /* xrealloced in merge_tree_at */
 
-	freeargv(iargc, iargv);
+		ret = merge_tree_at(AT_FDCWD, "image", AT_FDCWD, portroot, contents,
+					&objs, &cpath, cp_argc, cp_argv, cpm_argc, cpm_argv);
+
+		free(cpath);
+
+		if (ret != 0)
+			errp("failed to merge to %s", portroot);
+	}
+	fclose(contents);
 
 	/* run postinst */
-	pkg_run_func("vdb", phases, "pkg_postinst", D, T);
+	if (!pretend)
+		pkg_run_func("vdb", phases, "pkg_postinst", D, T);
 
 	/* XXX: hmm, maybe we'll want to strip more ? */
 	unlink("vdb/environment");
 
-	/* FIXME */ /* move unmerging to around here ? */
-	/* check for an already installed pkg */
-
-	/* Unmerge any stray pieces from the older version which we didn't replace */
-	/* XXX: Should see about merging with unmerge_packages() */
+	/* Unmerge any stray pieces from the older version which we didn't
+	 * replace */
+	/* TODO: Should see about merging with unmerge_packages() */
 	while (1) {
 		int ret;
 		q_vdb_pkg_ctx *pkg_ctx;
@@ -1085,7 +1291,8 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 			case NEWER:
 			case OLDER:
 			case EQUAL:
-				/* We need to really set this unmerge pending after we look at contents of the new pkg */
+				/* We need to really set this unmerge pending after we
+				 * look at contents of the new pkg */
 				break;
 			default:
 				warn("no idea how we reached here.");
@@ -1094,14 +1301,18 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 				goto next_pkg;
 		}
 
-		qprintf("%s+++%s %s/%s %s %s/%s\n", GREEN, NORM, atom->CATEGORY, pkg->PF,
-			booga[ret], cat_ctx->name, pkg_ctx->name);
+		qprintf("%s+++%s %s/%s %s %s/%s\n",
+				GREEN, NORM, atom->CATEGORY, pkg->PF,
+				booga[ret], cat_ctx->name, pkg_ctx->name);
 
-		pkg_unmerge(pkg_ctx, objs);
+		pkg_unmerge(pkg_ctx, objs, cp_argc, cp_argv, cpm_argc, cpm_argv);
  next_pkg:
 		q_vdb_close_pkg(pkg_ctx);
 	}
 
+	freeargv(cp_argc, cp_argv);
+	freeargv(cpm_argc, cpm_argv);
+
 	/* Clean up the package state */
 	free_sets(objs);
 	free(D);
@@ -1113,14 +1324,17 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		fclose(fp);
 	}
 
-	/* move the local vdb copy to the final place */
-	snprintf(buf, sizeof(buf), "%s%s/%s/", portroot, portvdb, pkg->CATEGORY);
-	mkdir_p(buf, 0755);
-	strcat(buf, pkg->PF);
-	if (rename("vdb", buf)) {
-		xasprintf(&p, "mv vdb '%s'", buf);
-		xsystem(p);
-		free(p);
+	if (!pretend) {
+		/* move the local vdb copy to the final place */
+		snprintf(buf, sizeof(buf), "%s%s/%s/",
+				portroot, portvdb, pkg->CATEGORY);
+		mkdir_p(buf, 0755);
+		strcat(buf, pkg->PF);
+		if (rename("vdb", buf)) {
+			xasprintf(&p, "mv vdb '%s'", buf);
+			xsystem(p);
+			free(p);
+		}
 	}
 
 	/* clean up our local temp dir */
@@ -1129,13 +1343,15 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	/* don't care about return */
 	rmdir("../qmerge");
 
-	printf("%s>>>%s %s%s%s/%s%s%s\n", YELLOW, NORM, WHITE, atom->CATEGORY, NORM, CYAN, atom->PN, NORM);
+	printf("%s>>>%s %s%s%s/%s%s%s\n",
+			YELLOW, NORM, WHITE, atom->CATEGORY, NORM, CYAN, atom->PN, NORM);
 
 	q_vdb_close(vdb_ctx);
 }
 
 static int
-pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
+pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep,
+		int cp_argc, char **cp_argv, int cpm_argc, char **cpm_argv)
 {
 	q_vdb_cat_ctx *cat_ctx = pkg_ctx->cat_ctx;
 	const char *cat = cat_ctx->name;
@@ -1147,15 +1363,15 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
 	char *buf;
 	FILE *fp;
 	int ret, portroot_fd;
-	int cp_argc, cpm_argc;
-	char **cp_argv, **cpm_argv;
 	llist_char *dirs = NULL;
+	bool unmerge_config_protected;
 
 	ret = 1;
 	buf = phases = NULL;
 	T = "${PWD}/temp";
 
-	printf("%s<<<%s %s%s%s/%s%s%s\n", YELLOW, NORM, WHITE, cat, NORM, CYAN, pkgname, NORM);
+	printf("%s<<<%s %s%s%s/%s%s%s\n",
+			YELLOW, NORM, WHITE, cat, NORM, CYAN, pkgname, NORM);
 
 	if (pretend == 100)
 		return 0;
@@ -1174,14 +1390,8 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
 		pkg_run_func_at(pkg_ctx->fd, ".", phases, "pkg_prerm", T, T);
 	}
 
-	/* XXX: be nice to pull this out of the current func
-	 *      so we don't keep reparsing the same env var
-	 *      when unmerging multiple packages.
-	 */
-	makeargv(config_protect, &cp_argc, &cp_argv);
-	makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
-
-	bool unmerge_config_protected = !!strstr(features, "config-protect-if-modified");
+	unmerge_config_protected =
+		strstr(features, "config-protect-if-modified") != NULL;
 
 	while (getline(&buf, &buflen, fp) != -1) {
 		queue *q;
@@ -1194,7 +1404,8 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
 		if (!e)
 			continue;
 
-		protected = config_protected(e->name, cp_argc, cp_argv, cpm_argc, cpm_argv);
+		protected = config_protected(e->name,
+				cp_argc, cp_argv, cpm_argc, cpm_argv);
 
 		/* This should never happen ... */
 		assert(e->name[0] == '/' && e->name[1] != '/');
@@ -1213,16 +1424,19 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
 			case CONTENTS_OBJ:
 				if (protected && unmerge_config_protected) {
 					/* If the file wasn't modified, unmerge it */
-					unsigned char *hash = hash_file_at(portroot_fd, e->name + 1, HASH_MD5);
+					unsigned char *hash = hash_file_at(portroot_fd,
+							e->name + 1, HASH_MD5);
 					protected = strcmp(e->digest, (const char *)hash);
 					free(hash);
 				}
 				break;
 
 			case CONTENTS_SYM:
-				if (fstatat(portroot_fd, e->name + 1, &st, AT_SYMLINK_NOFOLLOW)) {
+				if (fstatat(portroot_fd,
+							e->name + 1, &st, AT_SYMLINK_NOFOLLOW)) {
 					if (errno != ENOENT) {
-						warnp("stat failed for %s -> '%s'", e->name, e->sym_target);
+						warnp("stat failed for %s -> '%s'",
+								e->name, e->sym_target);
 						continue;
 					} else
 						break;
@@ -1235,11 +1449,14 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
 				break;
 
 			default:
-				warn("%s???%s %s%s%s (%d)", RED, NORM, WHITE, e->name, NORM, e->type);
+				warn("%s???%s %s%s%s (%d)", RED, NORM,
+						WHITE, e->name, NORM, e->type);
 				continue;
 		}
 
-		snprintf(zing, sizeof(zing), "%s%s%s", protected ? YELLOW : GREEN, protected ? "***" : "<<<" , NORM);
+		snprintf(zing, sizeof(zing), "%s%s%s",
+				protected ? YELLOW : GREEN,
+				protected ? "***" : "<<<" , NORM);
 
 		if (protected) {
 			qprintf("%s %s\n", zing, e->name);
@@ -1264,7 +1481,7 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
 		if (!keep || q) {
 			char *p;
 
-			if (unlinkat(portroot_fd, e->name + 1, 0)) {
+			if (!pretend && unlinkat(portroot_fd, e->name + 1, 0)) {
 				/* If a file was already deleted, ignore the error */
 				if (errno != ENOENT)
 					errp("could not unlink: %s%s", portroot, e->name + 1);
@@ -1273,7 +1490,8 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
 			p = strrchr(e->name, '/');
 			if (p) {
 				*p = '\0';
-				rmdir_r_at(portroot_fd, e->name + 1);
+				if (!pretend)
+					rmdir_r_at(portroot_fd, e->name + 1);
 			}
 		}
 	}
@@ -1295,9 +1513,6 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
 		free(list);
 	}
 
-	freeargv(cp_argc, cp_argv);
-	freeargv(cpm_argc, cpm_argv);
-
 	if (!pretend) {
 		/* Then execute the pkg_postrm step */
 		pkg_run_func_at(pkg_ctx->fd, ".", phases, "pkg_postrm", T, T);
@@ -1495,13 +1710,23 @@ static int
 qmerge_unmerge_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 {
 	queue *todo = priv;
+	int cp_argc;
+	int cpm_argc;
+	char **cp_argv;
+	char **cpm_argv;
+
+	makeargv(config_protect, &cp_argc, &cp_argv);
+	makeargv(config_protect_mask, &cpm_argc, &cpm_argv);
 
 	while (todo) {
 		if (qlist_match(pkg_ctx, todo->name, NULL, true))
-			pkg_unmerge(pkg_ctx, NULL);
+			pkg_unmerge(pkg_ctx, NULL, cp_argc, cp_argv, cpm_argc, cpm_argv);
 		todo = todo->next;
 	}
 
+	freeargv(cp_argc, cp_argv);
+	freeargv(cpm_argc, cpm_argv);
+
 	return 0;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-12-20 18:24 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-12-20 18:24 UTC (permalink / raw
  To: gentoo-commits

commit:     476e1cb9c9385e6219fedb457fc558e4de7c4add
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 20 18:19:16 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Dec 20 18:24:32 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=476e1cb9

initialize_portage_env: empty default for FEATURES in vars_to_read

Because FEATURES is an ISTR (incremental string) when a default it set,
we're never able to loose the default, so don't set it.  This causes a
behavioural change of "nodoc noman noinfo" no longer being (always) set.
qmerge in particular will hence install /usr/share/{doc,man,info} again.

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 30dd063..2eeb21b 100644
--- a/main.c
+++ b/main.c
@@ -854,7 +854,7 @@ initialize_portage_env(void)
 		_Q_EVS(ISTR, CONFIG_PROTECT,      config_protect,      CONFIG_EPREFIX "etc")
 		_Q_EVS(ISTR, CONFIG_PROTECT_MASK, config_protect_mask, "")
 		_Q_EVB(BOOL, NOCOLOR,             nocolor,             0)
-		_Q_EVS(ISTR, FEATURES,            features,            "noman noinfo nodoc")
+		_Q_EVS(ISTR, FEATURES,            features,            "")
 		_Q_EVS(STR,  EPREFIX,             eprefix,             CONFIG_EPREFIX)
 		_Q_EVS(STR,  EMERGE_LOG_DIR,      portlogdir,          CONFIG_EPREFIX "var/log")
 		_Q_EVS(STR,  PORTDIR,             main_overlay,        CONFIG_EPREFIX "usr/portage")


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-12-09 10:42 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-12-09 10:42 UTC (permalink / raw
  To: gentoo-commits

commit:     8ccd45be3ade13b4bef748b7486a87b3d143afc1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Dec  9 10:40:07 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Dec  9 10:40:07 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8ccd45be

qsearch: avoid printing a trailing space, bug #672764

When --name-only is in effect, don't print the space separating the
package and its description, for we won't print the latter.

Bug: https://bugs.gentoo.org/672764
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qsearch.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/qsearch.c b/qsearch.c
index 4fce4de..b75a4f7 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -1,9 +1,10 @@
 /*
- * Copyright 2005-2018 Gentoo Foundation
+ * Copyright 2005-2018 Gentoo Authors
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2014 Mike Frysinger  - <vapier@gentoo.org>
+ * Copyright 2018-     Fabian Groffen  - <grobian@gentoo.org
  */
 
 #ifdef APPLET_qsearch
@@ -50,8 +51,9 @@ qsearch_ebuild_metadata(_q_unused_ int overlay_fd, const char *ebuild, const cha
 	if (strcmp(pcache->atom->PN, last) != 0) {
 		strncpy(last, pcache->atom->PN, LAST_BUF_SIZE);
 		if (search_all || rematch(search_me, (search_desc ? pcache->DESCRIPTION : ebuild), REG_EXTENDED | REG_ICASE) == 0)
-			printf("%s%s/%s%s%s %s\n", BOLD, pcache->atom->CATEGORY, BLUE,
+			printf("%s%s/%s%s%s%s%s\n", BOLD, pcache->atom->CATEGORY, BLUE,
 			       pcache->atom->PN, NORM,
+				   (show_name_only ? "" : " "),
 			       (show_name_only ? "" :
 			        (show_homepage ? pcache->HOMEPAGE : pcache->DESCRIPTION)));
 	}
@@ -121,8 +123,9 @@ qsearch_ebuild_ebuild(int overlay_fd, const char *ebuild, const char *search_me,
 
 	if (show_it) {
 		const char *pkg = basename(p);
-		printf("%s%s/%s%s%s %s\n",
+		printf("%s%s/%s%s%s%s%s\n",
 			BOLD, dirname(p), BLUE, pkg, NORM,
+			(show_name_only ? "" : " "),
 			(show_name_only ? "" : q ? : "<no DESCRIPTION found>"));
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-11-20 14:25 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-11-20 14:25 UTC (permalink / raw
  To: gentoo-commits

commit:     2e83b5bd31ee989b79fbed7d2a9882f98c2771a5
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 20 14:24:33 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Nov 20 14:24:33 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2e83b5bd

qdepends: match reverse deps without SLOT if not given

Continuation of bug #668418, atom_compare is strict about SLOT matches.

Bug: https://bugs.gentoo.org/668418
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qdepends.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/qdepends.c b/qdepends.c
index 3ff0ebb..e6b9bcf 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -1,9 +1,10 @@
 /*
- * Copyright 2005-2018 Gentoo Foundation
+ * Copyright 2005-2018 Gentoo Authors
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2014 Mike Frysinger  - <vapier@gentoo.org>
+ * Copyright 2018-     Fabian Groffen  - <grobian@gentoo.org>
  */
 
 #ifdef APPLET_qdepends
@@ -486,6 +487,7 @@ qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	depend_atom *as;
 	depend_atom *ac;
 	char firstmatch = 0;
+	char *sslot;
 
 	if (!q_vdb_pkg_eat(pkg_ctx, state->depend_file, &depend, &depend_len))
 		return 0;
@@ -569,7 +571,13 @@ qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 					ptr + match.rm_so);
 		ac = atom_explode(qbuf);
 
+		/* drop SLOT when not present in aq so we can match atoms
+		 * regardless */
+		sslot = ac->SLOT;
+		if (aq->SLOT == NULL && ac->SLOT != NULL)
+			ac->SLOT = NULL;
 		ret = atom_compare(ac, aq);
+		ac->SLOT = sslot;
 		if (ret != EQUAL) {
 			atom_implode(ac);
 			break;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-10-26 13:50 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-10-26 13:50 UTC (permalink / raw
  To: gentoo-commits

commit:     d7cf583b6be5b29e5607fe0d90b8f566baf65f34
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 26 13:49:05 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Oct 26 13:49:05 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d7cf583b

depends: fix matching atoms for bug #668418

atoms in dependency strings can contain built-with-use declarations in
bracket notation, so ensure we ignore that when feeding this into
atom_explode.

Bug: https://bugs.gentoo.org/668418

 qatom.c    | 3 ++-
 qdepends.c | 7 +++++--
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/qatom.c b/qatom.c
index f079299..d7782ea 100644
--- a/qatom.c
+++ b/qatom.c
@@ -133,7 +133,8 @@ int qatom_main(int argc, char **argv)
 	for (i = optind; i < argc; ++i) {
 		switch (action) {
 		case _COMPARE:
-			printf("%s %s %s\n", argv[i], booga[atom_compare_str(argv[i], argv[i+1])], argv[i+1]);
+			printf("%s %s %s\n", argv[i],
+					booga[atom_compare_str(argv[i], argv[i+1])], argv[i+1]);
 			++i;
 			break;
 		case _EXPLODE:

diff --git a/qdepends.c b/qdepends.c
index e89216b..3ff0ebb 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -555,10 +555,13 @@ qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 		if (ret != 0)
 			break;
 
-		/* find the boundaries for matched atom */
+		/* find the boundaries for matched atom, dep specifications can
+		 * include built-with-use deps using [xxx] notation, so ensure
+		 * we exclude that as part of the atom */
 		while (match.rm_so > 0 && !isspace(ptr[match.rm_so - 1]))
 			match.rm_so--;
-		while (ptr[match.rm_eo] != '\0' && !isspace(ptr[match.rm_eo]))
+		while (ptr[match.rm_eo] != '\0' && ptr[match.rm_eo] != '[' &&
+				!isspace(ptr[match.rm_eo]))
 			match.rm_eo++;
 
 		snprintf(qbuf, sizeof(qbuf), "%.*s",


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-10-26 13:50 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-10-26 13:50 UTC (permalink / raw
  To: gentoo-commits

commit:     ebce91a9a86fe3e63561734ff902fc51f478e08c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Oct 26 13:07:33 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Oct 26 13:07:33 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ebce91a9

buildsys: properly disable qglsa applet

 .depend           | 2 +-
 Makefile.am       | 3 +++
 applets.h         | 4 +++-
 include_applets.h | 1 -
 4 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/.depend b/.depend
index 5de684d..f823923 100644
--- a/.depend
+++ b/.depend
@@ -7,4 +7,4 @@ main.o: main.c porting.h main.h libq/libq.c libq/busybox.h libq/i18n.h \
  libq/prelink.c libq/profile.c libq/vdb.c libq/vdb_get_next_dir.c \
  libq/virtuals.c applets.h include_applets.h q.c qcheck.c qdepends.c \
  qfile.c qlist.c qlop.c qsearch.c qsize.c qtbz2.c quse.c qxpak.c qpkg.c \
- qgrep.c qatom.c qmerge.c qcache.c qglsa.c qtegrity.c
+ qgrep.c qatom.c qmerge.c qcache.c qtegrity.c

diff --git a/Makefile.am b/Makefile.am
index 425a018..db20879 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -76,6 +76,7 @@ dist_man_MANS += \
 	man/qsearch.1 \
 	man/qsize.1 \
 	man/qtbz2.1 \
+	man/qtegrity.1 \
 	man/quse.1 \
 	man/qxpak.1
 APPLETS += \
@@ -164,6 +165,8 @@ EXTRA_DIST += \
 	tests/atom_explode/basic.good \
 	tests/atom_explode/basic.tests \
 	tests/atom_explode/dotest \
+	tests/atom_explode/ebuildlist.xz \
+	tests/atom_explode/portageatoms.xz \
 	tests/atom_explode/test.c \
 	tests/copy_file/.gitignore \
 	tests/copy_file/Makefile \

diff --git a/applets.h b/applets.h
index daf7047..14b0154 100644
--- a/applets.h
+++ b/applets.h
@@ -30,7 +30,7 @@ DECLARE_APPLET(qgrep)
 DECLARE_APPLET(qatom)
 DECLARE_APPLET(qmerge)
 DECLARE_APPLET(qcache)
-DECLARE_APPLET(qglsa) /* disable */
+/*DECLARE_APPLET(qglsa) disable */
 DECLARE_APPLET(qtegrity)
 #undef DECLARE_APPLET
 
@@ -52,7 +52,9 @@ static const struct applet_t {
 	{"qcheck",    qcheck_main,    "<pkgname>",       "verify integrity of installed packages"},
 	{"qdepends",  qdepends_main,  "<pkgname>",       "show dependency info"},
 	{"qfile",     qfile_main,     "<filename>",      "list all pkgs owning files"},
+	/*
 	{"qglsa",     qglsa_main,     "<action> <list>", "check GLSAs against system"},
+	*/
 	{"qgrep",     qgrep_main,     "<misc args>",     "grep in ebuilds"},
 	{"qlist",     qlist_main,     "<pkgname>",       "list files owned by pkgname"},
 	{"qlop",      qlop_main,      "<pkgname>",       "emerge log analyzer"},

diff --git a/include_applets.h b/include_applets.h
index 6ff8f8a..916e5f7 100644
--- a/include_applets.h
+++ b/include_applets.h
@@ -14,5 +14,4 @@
 #include "qatom.c"
 #include "qmerge.c"
 #include "qcache.c"
-#include "qglsa.c"
 #include "qtegrity.c"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-08-06  7:25 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-08-06  7:25 UTC (permalink / raw
  To: gentoo-commits

commit:     e50796ff86a75ec01e1346117e7c753b8e955654
Author:     Martin Väth <martin <AT> mvath <DOT> de>
AuthorDate: Thu Aug  2 09:53:42 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Aug  6 04:42:06 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e50796ff

qmerge: Support for more decompresssion programs

Support additional compression programs like zstd or lz4 for BINPKG_COMPRESS.
Also make the gzip test less http://www.onicos.com/staff/iz/formats/gzip.html
and the bzip2 test more https://en.wikipedia.org/wiki/Bzip2#File_format
restrictive.

 qmerge.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 65 insertions(+), 11 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 6d98c43..a1b5a86 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -919,12 +919,17 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	 * name suggests, bug #660508, usage of BINPKG_COMPRESS,
 	 * due to the minimal nature of where we run, we cannot rely on file
 	 * or GNU tar, so have to do some laymans MAGIC hunting ourselves */
-	compr = "j";  /* default: bzip2 */
+	compr = "I brotli"; /* default: brotli; has no magic header */
 	{
-		/* bz2: 2-byte: 'B' 'Z'                  at byte 0
-		 * gz:  4-byte:  1f  8b                  at byte 0
+		/* bz2: 3-byte: 'B' 'Z' 'h'              at byte 0
+		 * gz:  2-byte:  1f  8b                  at byte 0
 		 * xz:  4-byte: '7' 'z' 'X' 'Z'          at byte 1
-		 * tar: 6-byte: 'u' 's' 't' 'a' 'r' \0   at byte 257 */
+		 * tar: 6-byte: 'u' 's' 't' 'a' 'r' \0   at byte 257
+		 * lz4: 4-byte:   4  22  4d  18          at byte 0
+		 * zst: 4-byte: 22-28 b5 2f  fd          at byte 0
+		 * lz:  4-byte: 'L' 'Z' 'I' 'P'          at byte 0
+		 * lzo: 9-byte:  89 'L' 'Z' 'O' 0 d a 1a a at byte 0
+		 * br:  anything else */
 		unsigned char magic[257+6];
 		FILE *mfd;
 
@@ -934,11 +939,12 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 			size_t mlen = fread(magic, 1, sizeof(magic), mfd);
 			fclose(mfd);
 
-			if (mlen >= 2 && magic[0] == 'B' && magic[1] == 'Z') {
+			if (mlen >= 3 && magic[0] == 'B' && magic[1] == 'Z' &&
+					magic[2] == 'h')
+			{
 				compr = "j";
-			} else if (mlen >= 4 &&
-					magic[0] == 037 && magic[1] == 0213 &&
-					magic[2] == 010 && magic[3] == 00)
+			} else if (mlen >= 2 &&
+					magic[0] == 037 && magic[1] == 0213)
 			{
 				compr = "z";
 			} else if (mlen >= 5 &&
@@ -952,6 +958,40 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 					magic[261] == 'r' && magic[262] == '\0')
 			{
 				compr = "";
+			} else if (mlen >= 4 &&
+					magic[0] == 0x04 && magic[1] == 0x22 &&
+					magic[2] == 0x4D && magic[3] == 0x18)
+			{
+				compr = "I lz4";
+			} else if (mlen >= 4 &&
+					magic[0] >= 0x22 && magic[0] <= 0x28 &&
+					magic[1] == 0xB5 && magic[2] == 0x2F &&
+					magic[3] == 0xFD)
+			{
+				/*
+				 * --long=31 is needed to uncompress files compressed with
+				 * --long=xx where xx>27. The option is "safe" in the sense
+				 * that not more memory is allocated than what is really
+				 * needed to decompress the file. See
+				 * https://bugs.gentoo.org/show_bug.cgi?id=634980 */
+				compr = "I zstd --long=31";
+				/*
+				 * If really tar -I would be used we would have to quote:
+				 * compr = "I \"zstd --long=31\"";
+				 * But actually we use a pipe (see below) */
+			} else if (mlen >= 4 &&
+					magic[0] == 'L' && magic[1] == 'Z' &&
+					magic[2] == 'I' && magic[3] == 'P')
+			{
+				compr = "I lzip";
+			} else if (mlen >= 9 &&
+					magic[0] == 0x89 && magic[1] == 'L' &&
+					magic[2] == 'Z' && magic[3] == 'O' &&
+					magic[4] == 0x00 && magic[5] == 0x0D &&
+					magic[6] == 0x0A && magic[7] == 0x1A &&
+					magic[8] == 0x0A)
+			{
+				compr = "I lzop";
 			}
 		}
 	}
@@ -960,9 +1000,23 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 
 	/* extract the binary package data */
 	mkdir("image", 0755);
-	snprintf(buf, sizeof(buf),
-			BUSYBOX " tar -%sx%sf %s.tar.bz2 -C image/",
-			compr, ((verbose > 1) ? "v" : ""), pkg->PF);
+	if (compr[0] != 'I')
+	{
+		snprintf(buf, sizeof(buf),
+			BUSYBOX " tar -x%s%s -f %s.tar.bz2 -C image/",
+			((verbose > 1) ? "v" : ""), compr, pkg->PF);
+	} else
+	{
+		/* busybox's tar has no -I option. Thus, although we possibly
+		 * use busybox's shell and tar, we thus pipe, expecting the
+		 * corresponding (de)compression tool to be in PATH; if not,
+		 * a failure will occur.
+		 * Since some tools (e.g. zstd) complain about the .bz2
+		 * extension, we feed the tool by input redirection. */
+		snprintf(buf, sizeof(buf),
+			BUSYBOX " sh -c '%s -dc <%s.tar.bz2 | tar -x%sf - -C image/'",
+			compr + 2, pkg->PF, ((verbose > 1) ? "v" : ""));
+	}
 	xsystem(buf);
 	fflush(stdout);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-08-06  7:25 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-08-06  7:25 UTC (permalink / raw
  To: gentoo-commits

commit:     2203bd5a8b9c3b26b957d93d9c908940a0e676bb
Author:     Fabian Groffen <grobian <AT> users <DOT> noreply <DOT> github <DOT> com>
AuthorDate: Mon Aug  6 07:24:34 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Aug  6 07:24:34 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2203bd5a

Merge pull request #4 from vaeth/master

qmerge: support for more decompresssion programs

 qmerge.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 file changed, 65 insertions(+), 11 deletions(-)


^ permalink raw reply	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-08-01 13:28 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-08-01 13:28 UTC (permalink / raw
  To: gentoo-commits

commit:     e04d4940401a13f6851c732b70bdba0a64902d10
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Aug  1 13:26:32 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Aug  1 13:26:32 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e04d4940

qmerge: implement laymans file identification, bug #660508

Portage can create binpkgs compressed differently than with bzip2, so
try to probe the file quickly before untarring, so we can use the
correct flag with tar.

Bug: https://bugs.gentoo.org/660508

 qmerge.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 46 insertions(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 54d6a79..6d98c43 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -773,6 +773,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	char **iargv;
 	char c;
 	int iargc;
+	const char *compr;
 
 	if (!install || !pkg || !atom)
 		return;
@@ -914,11 +915,54 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	if (run_applet_l("qxpak", "-d", "vdb", "-x", tbz2, NULL) != 0)
 		err("`qxpak -d vdb -x %s` failed", tbz2);
 
+	/* figure out if the data is compressed differently from what the
+	 * name suggests, bug #660508, usage of BINPKG_COMPRESS,
+	 * due to the minimal nature of where we run, we cannot rely on file
+	 * or GNU tar, so have to do some laymans MAGIC hunting ourselves */
+	compr = "j";  /* default: bzip2 */
+	{
+		/* bz2: 2-byte: 'B' 'Z'                  at byte 0
+		 * gz:  4-byte:  1f  8b                  at byte 0
+		 * xz:  4-byte: '7' 'z' 'X' 'Z'          at byte 1
+		 * tar: 6-byte: 'u' 's' 't' 'a' 'r' \0   at byte 257 */
+		unsigned char magic[257+6];
+		FILE *mfd;
+
+		sprintf(tbz2, "%s.tar.bz2", pkg->PF);
+		mfd = fopen(tbz2, "r");
+		if (mfd != NULL) {
+			size_t mlen = fread(magic, 1, sizeof(magic), mfd);
+			fclose(mfd);
+
+			if (mlen >= 2 && magic[0] == 'B' && magic[1] == 'Z') {
+				compr = "j";
+			} else if (mlen >= 4 &&
+					magic[0] == 037 && magic[1] == 0213 &&
+					magic[2] == 010 && magic[3] == 00)
+			{
+				compr = "z";
+			} else if (mlen >= 5 &&
+					magic[1] == '7' && magic[2] == 'z' &&
+					magic[3] == 'X' && magic[4] == 'Z')
+			{
+				compr = "J";
+			} else if (mlen == 257+6 &&
+					magic[257] == 'u' && magic[258] == 's' &&
+					magic[259] == 't' && magic[260] == 'a' &&
+					magic[261] == 'r' && magic[262] == '\0')
+			{
+				compr = "";
+			}
+		}
+	}
+
 	free(tbz2);
 
-	/* extrct the binary package data */
+	/* extract the binary package data */
 	mkdir("image", 0755);
-	snprintf(buf, sizeof(buf), BUSYBOX " tar -jx%sf %s.tar.bz2 -C image/", ((verbose > 1) ? "v" : ""), pkg->PF);
+	snprintf(buf, sizeof(buf),
+			BUSYBOX " tar -%sx%sf %s.tar.bz2 -C image/",
+			compr, ((verbose > 1) ? "v" : ""), pkg->PF);
 	xsystem(buf);
 	fflush(stdout);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-07-18 20:20 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-07-18 20:20 UTC (permalink / raw
  To: gentoo-commits

commit:     de6b2ac12e02c690f8dee2517af1c09b436f5fc9
Author:     Hanno Boeck <hanno <AT> gentoo <DOT> org>
AuthorDate: Wed Jul 18 20:03:34 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jul 18 20:03:34 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=de6b2ac1

main: fix potential buffer underrun

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 7dbdbe7..30dd063 100644
--- a/main.c
+++ b/main.c
@@ -969,7 +969,7 @@ initialize_portage_env(void)
 
 	/* Make sure ROOT always ends in a slash */
 	var = &vars_to_read[0];
-	if ((*var->value.s)[var->value_len - 1] != '/') {
+	if (var->value_len == 0 || (*var->value.s)[var->value_len - 1] != '/') {
 		portroot = xrealloc(portroot, var->value_len + 2);
 		portroot[var->value_len] = '/';
 		portroot[var->value_len + 1] = '\0';


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-06-28  9:35 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-06-28  9:35 UTC (permalink / raw
  To: gentoo-commits

commit:     223d945738ca75047f8edd1f18eb9686503decdf
Author:     Fabian Groffen <grobian <AT> users <DOT> noreply <DOT> github <DOT> com>
AuthorDate: Thu Jun 28 09:35:20 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Jun 28 09:35:20 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=223d9457

Merge pull request #3 from hoefling/readme-fix

Fix code snippets highlighting in README

 README.md | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)


^ permalink raw reply	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-06-28  9:35 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-06-28  9:35 UTC (permalink / raw
  To: gentoo-commits

commit:     0cda5213a912f6423c1679a283861d3d6cb7e3dc
Author:     hoefling <oleg.hoefling <AT> gmail <DOT> com>
AuthorDate: Sun May 27 19:15:53 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun May 27 19:17:38 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0cda5213

fixed snippets highlighting

 README.md | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index fb8d800..59692a7 100644
--- a/README.md
+++ b/README.md
@@ -61,13 +61,14 @@ Having your PORTDIR and VDB on the right file system helps dramatically
 
 IDE raid with PORTDIR on reiserfs:
 
-```
+```sh
 $ q -r
 q: Finished 20655 entries in 1.990951 seconds
+```
 
 IDE raid with PORTDIR on ext3:
 
-```
+```sh
 $ q -r
 q: Finished 20655 entries in 203.664252 seconds
 ```


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-05-18 16:58 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-05-18 16:58 UTC (permalink / raw
  To: gentoo-commits

commit:     a34f5c952f8da3a83be91244be006d4b59c72aa3
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 18 15:58:01 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 18 15:58:01 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a34f5c95

qtegrity: fix signedness warning

 qtegrity.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qtegrity.c b/qtegrity.c
index 8af5b08..0b30fb8 100644
--- a/qtegrity.c
+++ b/qtegrity.c
@@ -138,7 +138,7 @@ static void get_digest_from_line(char * line, char * ret, int digest_size, int o
 {
 	size_t dlenstr = strlen(line);
 	/* Skip first chars to get to digest depends on digest_func in IMA */
-	int skip = ((digest_size == SHA256_DIGEST_LENGTH) ||
+	size_t skip = ((digest_size == SHA256_DIGEST_LENGTH) ||
 			(digest_size == SHA512_DIGEST_LENGTH)) ?
 		offset+8 : offset+6;
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-05-18 12:19 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-05-18 12:19 UTC (permalink / raw
  To: gentoo-commits

commit:     c1deada5ab2f1f66d5e1dd684569f74cd9d1f35d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 18 11:35:49 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 18 11:35:49 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c1deada5

add qtegrity

 .gitignore | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.gitignore b/.gitignore
index 769c4a1..b4d4456 100644
--- a/.gitignore
+++ b/.gitignore
@@ -51,3 +51,4 @@ stamp-h1
 /qsize
 /quse
 /qxpak
+/qtegrity


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-05-18 12:19 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-05-18 12:19 UTC (permalink / raw
  To: gentoo-commits

commit:     a6abfcfaa1ed4530e152b69ca5c46808c5e93d46
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 18 11:33:58 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 18 11:33:58 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a6abfcfa

version_barf: cleanup, add myself

 main.c          | 13 ++++++++-----
 make-tarball.sh |  4 ++--
 2 files changed, 10 insertions(+), 7 deletions(-)

diff --git a/main.c b/main.c
index 9103dc4..7dbdbe7 100644
--- a/main.c
+++ b/main.c
@@ -189,21 +189,24 @@ usage(int status, const char *flags, struct option const opts[],
 static void
 version_barf(void)
 {
+	const char *vcsid = "";
 	const char *eprefixid = "";
 
 #ifndef VERSION
 # define VERSION "git"
 #endif
-#ifndef VCSID
-# define VCSID "<unknown>"
+
+#ifdef VCSID
+	vcsid = " (" VCSID ")";
 #endif
 
 	if (strlen(CONFIG_EPREFIX) > 1)
 		eprefixid = "configured for " CONFIG_EPREFIX "\n";
-	printf("portage-utils-%s: %s\n"
+
+	printf("portage-utils-%s%s\n"
 	       "%s"
-	       "%s written for Gentoo by <solar and vapier @ gentoo.org>\n",
-	       VERSION, VCSID, eprefixid, argv0);
+	       "written for Gentoo by solar, vapier and grobian\n",
+	       VERSION, vcsid, eprefixid);
 	exit(EXIT_SUCCESS);
 }
 

diff --git a/make-tarball.sh b/make-tarball.sh
index 4f8eed7..ce25579 100755
--- a/make-tarball.sh
+++ b/make-tarball.sh
@@ -36,8 +36,8 @@ git archive "${ver}" | tar xf - -C "${p}"
 cd "${p}"
 
 einfo "Building autotools ..."
-sed -i "/^AC_INIT/s:git:${ver}:" configure.ac
-sed -i "1iPV := ${ver}" Makefile
+sed -i "/^AC_INIT/s:git:${ver#v}:" configure.ac
+sed -i "1iPV := ${ver#v}" Makefile
 LC_ALL=C ${MAKE} -s autotools >/dev/null
 rm -rf autom4te.cache
 cd ..


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-05-18 10:15 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-05-18 10:15 UTC (permalink / raw
  To: gentoo-commits

commit:     3c8e539de00f6ff24f6d65ade95ec5aecc09b5b1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri May 18 10:15:04 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri May 18 10:15:04 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3c8e539d

build-sys: update generated files for qtegrity

 .depend           | 2 +-
 Makefile.am       | 5 +++++
 include_applets.h | 1 +
 3 files changed, 7 insertions(+), 1 deletion(-)

diff --git a/.depend b/.depend
index d824273..5de684d 100644
--- a/.depend
+++ b/.depend
@@ -7,4 +7,4 @@ main.o: main.c porting.h main.h libq/libq.c libq/busybox.h libq/i18n.h \
  libq/prelink.c libq/profile.c libq/vdb.c libq/vdb_get_next_dir.c \
  libq/virtuals.c applets.h include_applets.h q.c qcheck.c qdepends.c \
  qfile.c qlist.c qlop.c qsearch.c qsize.c qtbz2.c quse.c qxpak.c qpkg.c \
- qgrep.c qatom.c qmerge.c qcache.c qglsa.c
+ qgrep.c qatom.c qmerge.c qcache.c qglsa.c qtegrity.c

diff --git a/Makefile.am b/Makefile.am
index d609b3f..425a018 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -58,6 +58,7 @@ q_CPPFLAGS += \
 	-DAPPLET_qsearch \
 	-DAPPLET_qsize \
 	-DAPPLET_qtbz2 \
+	-DAPPLET_qtegrity \
 	-DAPPLET_quse \
 	-DAPPLET_qxpak
 dist_man_MANS += \
@@ -92,6 +93,7 @@ APPLETS += \
 	qsearch \
 	qsize \
 	qtbz2 \
+	qtegrity \
 	quse \
 	qxpak
 EXTRA_DIST += \
@@ -145,6 +147,7 @@ EXTRA_DIST += \
 	qsearch.c \
 	qsize.c \
 	qtbz2.c \
+	qtegrity.c \
 	quse.c \
 	qxpak.c \
 	tests/Makefile \
@@ -261,6 +264,7 @@ EXTRA_DIST += \
 	tests/qlist/root/sys-fs/mtools-4.0.13/SLOT \
 	tests/qlist/root/sys-fs/mtools-4.0.13/repository \
 	tests/qlop/Makefile \
+	tests/qlop/aborts.log \
 	tests/qlop/dotest \
 	tests/qlop/list01.good \
 	tests/qlop/list02.good \
@@ -270,6 +274,7 @@ EXTRA_DIST += \
 	tests/qlop/list06.good \
 	tests/qlop/list07.good \
 	tests/qlop/list08.good \
+	tests/qlop/list09.good \
 	tests/qlop/sync.log \
 	tests/qlop/test04.good \
 	tests/qmerge/Makefile \

diff --git a/include_applets.h b/include_applets.h
index bed18e6..6ff8f8a 100644
--- a/include_applets.h
+++ b/include_applets.h
@@ -15,3 +15,4 @@
 #include "qmerge.c"
 #include "qcache.c"
 #include "qglsa.c"
+#include "qtegrity.c"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-04-18 13:58 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-04-18 13:58 UTC (permalink / raw
  To: gentoo-commits

commit:     4176ede48eabc7fce958d6d9c5d22154fe122447
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Apr 18 13:57:51 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Apr 18 13:57:51 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4176ede4

qcache: make categories counting work properly

 qcache.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/qcache.c b/qcache.c
index 03bcd05..a3be446 100644
--- a/qcache.c
+++ b/qcache.c
@@ -747,23 +747,24 @@ qcache_stats(qcache_data *data)
 
 		runtime = time(NULL);
 
-		xasprintf(&catpath, "%s/dep/%s", portedb, data->overlay);
+		xasprintf(&catpath, "%s/metadata/md5-cache", data->overlay);
 		dir = opendir(catpath);
 		while ((de = readdir(dir))) {
 			/* Look for all the directories in this path. */
-#ifdef DT_UNKNOWN
+#if defined(DT_UNKNOWN) && defined(DT_DIR)
 			if (de->d_type == DT_UNKNOWN)
 #endif
 			{
 				struct stat s;
-				if (lstat(de->d_name, &s))
+				char spath[_Q_PATH_MAX];
+				snprintf(spath, sizeof(spath), "%s/%s", catpath, de->d_name);
+				if (lstat(spath, &s) != 0)
 					continue;
 				if (!S_ISDIR(s.st_mode))
 					continue;
 			}
-
-#ifdef DT_DIR
-			if (de->d_type != DT_DIR)
+#if defined(DT_UNKNOWN) && defined(DT_DIR)
+			else if (de->d_type != DT_DIR)
 				continue;
 #endif
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-04-17 20:12 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-04-17 20:12 UTC (permalink / raw
  To: gentoo-commits

commit:     717aa306c7138580d2aa4e3946049b121b7b2b4c
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Apr 17 20:12:11 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Apr 17 20:12:11 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=717aa306

qcache: use metadata/md5-cache iso /var/cache/edb/

 main.c   | 14 +++++++++-----
 qcache.c | 22 +++++++++++++++-------
 2 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/main.c b/main.c
index bf85786..9103dc4 100644
--- a/main.c
+++ b/main.c
@@ -1037,7 +1037,7 @@ initialize_flat(const char *overlay, int cache_type, bool force)
 				return cache_file;
 	}
 
-	warn("Updating ebuild %scache in %s ... ",
+	warn("Updating ebuild %scache for %s ... ",
 		cache_type == CACHE_EBUILD ? "" : "meta", overlay);
 
 	count = frac = secs = 0;
@@ -1048,7 +1048,8 @@ initialize_flat(const char *overlay, int cache_type, bool force)
 	if (cache_type == CACHE_METADATA) {
 		subdir_fd = openat(overlay_fd, portcachedir_md5, O_RDONLY|O_CLOEXEC);
 		if (subdir_fd == -1) {
-			subdir_fd = openat(overlay_fd, portcachedir_pms, O_RDONLY|O_CLOEXEC);
+			subdir_fd = openat(overlay_fd, portcachedir_pms,
+					O_RDONLY|O_CLOEXEC);
 			if (subdir_fd == -1) {
 				warnp("could not read md5 or pms cache dirs in %s", overlay);
 				goto ret;
@@ -1084,13 +1085,15 @@ initialize_flat(const char *overlay, int cache_type, bool force)
 				continue;
 
 		int c, pkg_cnt;
-		pkg_cnt = scandirat(subdir_fd, category[i]->d_name, &pn, q_vdb_filter_pkg, alphasort);
+		pkg_cnt = scandirat(subdir_fd, category[i]->d_name, &pn,
+				q_vdb_filter_pkg, alphasort);
 		if (pkg_cnt < 0)
 			continue;
 		for (c = 0; c < pkg_cnt; c++) {
 			char de[_Q_PATH_MAX];
 
-			snprintf(de, sizeof(de), "%s/%s", category[i]->d_name, pn[c]->d_name);
+			snprintf(de, sizeof(de), "%s/%s",
+					category[i]->d_name, pn[c]->d_name);
 
 			if (fstatat(subdir_fd, de, &st, 0) < 0)
 				continue;
@@ -1107,7 +1110,8 @@ initialize_flat(const char *overlay, int cache_type, bool force)
 			}
 
 			int e, ebuild_cnt;
-			ebuild_cnt = scandirat(subdir_fd, de, &eb, filter_hidden, alphasort);
+			ebuild_cnt = scandirat(subdir_fd, de, &eb,
+					filter_hidden, alphasort);
 			if (ebuild_cnt < 0)
 				continue;
 			for (e = 0; e < ebuild_cnt; ++e) {

diff --git a/qcache.c b/qcache.c
index 545f336..03bcd05 100644
--- a/qcache.c
+++ b/qcache.c
@@ -407,9 +407,11 @@ qcache_traverse_overlay(void (*func)(qcache_data*), const char *overlay)
 	int i, j, k, len, num_cat, num_pkg, num_ebuild;
 	struct dirent **categories, **packages, **ebuilds;
 
-	xasprintf(&catpath, "%s/dep/%s", portedb, overlay);
+	xasprintf(&catpath, "%s/metadata/md5-cache", overlay);
 
-	if (-1 == (num_cat = scandir(catpath, &categories, qcache_file_select, alphasort))) {
+	if (-1 == (num_cat = scandir(catpath, &categories,
+					qcache_file_select, alphasort)))
+	{
 		errp("%s", catpath);
 		free(catpath);
 	}
@@ -421,7 +423,9 @@ qcache_traverse_overlay(void (*func)(qcache_data*), const char *overlay)
 	for (i = 0; i < num_cat; i++) {
 		xasprintf(&pkgpath, "%s/%s", overlay, categories[i]->d_name);
 
-		if (-1 == (num_pkg = scandir(pkgpath, &packages, qcache_file_select, alphasort))) {
+		if (-1 == (num_pkg = scandir(pkgpath, &packages,
+						qcache_file_select, alphasort)))
+		{
 			if (errno != ENOENT)
 				warnp("Found a cache dir, but unable to process %s", pkgpath);
 			free(categories[i]);
@@ -440,9 +444,12 @@ qcache_traverse_overlay(void (*func)(qcache_data*), const char *overlay)
 
 		/* traverse packages */
 		for (j = 0; j < num_pkg; j++) {
-			xasprintf(&ebuildpath, "%s/%s/%s", overlay, categories[i]->d_name, packages[j]->d_name);
+			xasprintf(&ebuildpath, "%s/%s/%s",
+					overlay, categories[i]->d_name, packages[j]->d_name);
 
-			if (-1 == (num_ebuild = scandir(ebuildpath, &ebuilds, qcache_ebuild_select, qcache_vercmp))) {
+			if (-1 == (num_ebuild = scandir(ebuildpath, &ebuilds,
+							qcache_ebuild_select, qcache_vercmp)))
+			{
 				/* Do not complain about spurious files */
 				if (errno != ENOTDIR)
 					warnp("%s", ebuildpath);
@@ -465,7 +472,8 @@ qcache_traverse_overlay(void (*func)(qcache_data*), const char *overlay)
 			/* traverse ebuilds */
 			data.num = num_ebuild;
 			for (k = 0; k < num_ebuild; k++) {
-				len = xasprintf(&cachepath, "%s/%s/%s", catpath, categories[i]->d_name, ebuilds[k]->d_name);
+				len = xasprintf(&cachepath, "%s/%s/%s",
+						catpath, categories[i]->d_name, ebuilds[k]->d_name);
 				cachepath[len - 7] = '\0'; /* remove ".ebuild" */
 
 				data.category = categories[i]->d_name;
@@ -484,7 +492,7 @@ qcache_traverse_overlay(void (*func)(qcache_data*), const char *overlay)
 					if (!warned) {
 						warned = true;
 						warnp("unable to read cache '%s'\n"
-						      "\tperhaps you need to `egencache -j 4` ?", cachepath);
+						      "\tperhaps you need to `egencache`?", cachepath);
 					}
 				}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-04-15 15:41 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-04-15 15:41 UTC (permalink / raw
  To: gentoo-commits

commit:     ce88951da19eb0b82d53fc18764afeed845a3626
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 15 15:41:00 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Apr 15 15:41:00 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ce88951d

Makefile: revert to non-autotools version

This reverts the accidential commit to Makefile from
054b993a9433a45c00086fb2841a8150d85eb437.

 Makefile | 2466 +++++---------------------------------------------------------
 1 file changed, 165 insertions(+), 2301 deletions(-)

diff --git a/Makefile b/Makefile
index bcde52c..2afb67d 100644
--- a/Makefile
+++ b/Makefile
@@ -1,2304 +1,168 @@
-# Makefile.in generated by automake 1.15.1 from Makefile.am.
-# Makefile.  Generated from Makefile.in by configure.
-
-# Copyright (C) 1994-2017 Free Software Foundation, Inc.
-
-# This Makefile.in is free software; the Free Software Foundation
-# gives unlimited permission to copy and/or distribute it,
-# with or without modifications, as long as this notice is preserved.
-
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
-# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-# PARTICULAR PURPOSE.
-
-
-
-
-
-am__is_gnu_make = { \
-  if test -z '$(MAKELEVEL)'; then \
-    false; \
-  elif test -n '$(MAKE_HOST)'; then \
-    true; \
-  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
-    true; \
-  else \
-    false; \
-  fi; \
-}
-am__make_running_with_option = \
-  case $${target_option-} in \
-      ?) ;; \
-      *) echo "am__make_running_with_option: internal error: invalid" \
-              "target option '$${target_option-}' specified" >&2; \
-         exit 1;; \
-  esac; \
-  has_opt=no; \
-  sane_makeflags=$$MAKEFLAGS; \
-  if $(am__is_gnu_make); then \
-    sane_makeflags=$$MFLAGS; \
-  else \
-    case $$MAKEFLAGS in \
-      *\\[\ \	]*) \
-        bs=\\; \
-        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
-          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
-    esac; \
-  fi; \
-  skip_next=no; \
-  strip_trailopt () \
-  { \
-    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
-  }; \
-  for flg in $$sane_makeflags; do \
-    test $$skip_next = yes && { skip_next=no; continue; }; \
-    case $$flg in \
-      *=*|--*) continue;; \
-        -*I) strip_trailopt 'I'; skip_next=yes;; \
-      -*I?*) strip_trailopt 'I';; \
-        -*O) strip_trailopt 'O'; skip_next=yes;; \
-      -*O?*) strip_trailopt 'O';; \
-        -*l) strip_trailopt 'l'; skip_next=yes;; \
-      -*l?*) strip_trailopt 'l';; \
-      -[dEDm]) skip_next=yes;; \
-      -[JT]) skip_next=yes;; \
-    esac; \
-    case $$flg in \
-      *$$target_option*) has_opt=yes; break;; \
-    esac; \
-  done; \
-  test $$has_opt = yes
-am__make_dryrun = (target_option=n; $(am__make_running_with_option))
-am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
-pkgdatadir = $(datadir)/portage-utils
-pkgincludedir = $(includedir)/portage-utils
-pkglibdir = $(libdir)/portage-utils
-pkglibexecdir = $(libexecdir)/portage-utils
-am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-install_sh_DATA = $(install_sh) -c -m 644
-install_sh_PROGRAM = $(install_sh) -c
-install_sh_SCRIPT = $(install_sh) -c
-INSTALL_HEADER = $(INSTALL_DATA)
-transform = $(program_transform_name)
-NORMAL_INSTALL = :
-PRE_INSTALL = :
-POST_INSTALL = :
-NORMAL_UNINSTALL = :
-PRE_UNINSTALL = :
-POST_UNINSTALL = :
-build_triplet = x86_64-pc-solaris2.11
-host_triplet = x86_64-pc-solaris2.11
-bin_PROGRAMS = q$(EXEEXT)
-subdir = .
-ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
-am__aclocal_m4_deps = $(top_srcdir)/autotools/m4/00gnulib.m4 \
-	$(top_srcdir)/autotools/m4/absolute-header.m4 \
-	$(top_srcdir)/autotools/m4/alloca.m4 \
-	$(top_srcdir)/autotools/m4/canonicalize.m4 \
-	$(top_srcdir)/autotools/m4/chdir-long.m4 \
-	$(top_srcdir)/autotools/m4/clock_time.m4 \
-	$(top_srcdir)/autotools/m4/close.m4 \
-	$(top_srcdir)/autotools/m4/closedir.m4 \
-	$(top_srcdir)/autotools/m4/dirent_h.m4 \
-	$(top_srcdir)/autotools/m4/dirfd.m4 \
-	$(top_srcdir)/autotools/m4/dirname.m4 \
-	$(top_srcdir)/autotools/m4/double-slash-root.m4 \
-	$(top_srcdir)/autotools/m4/dup.m4 \
-	$(top_srcdir)/autotools/m4/dup2.m4 \
-	$(top_srcdir)/autotools/m4/eealloc.m4 \
-	$(top_srcdir)/autotools/m4/errno_h.m4 \
-	$(top_srcdir)/autotools/m4/error.m4 \
-	$(top_srcdir)/autotools/m4/euidaccess.m4 \
-	$(top_srcdir)/autotools/m4/exponentd.m4 \
-	$(top_srcdir)/autotools/m4/exponentf.m4 \
-	$(top_srcdir)/autotools/m4/exponentl.m4 \
-	$(top_srcdir)/autotools/m4/extensions.m4 \
-	$(top_srcdir)/autotools/m4/extern-inline.m4 \
-	$(top_srcdir)/autotools/m4/faccessat.m4 \
-	$(top_srcdir)/autotools/m4/fchdir.m4 \
-	$(top_srcdir)/autotools/m4/fcntl-o.m4 \
-	$(top_srcdir)/autotools/m4/fcntl.m4 \
-	$(top_srcdir)/autotools/m4/fcntl_h.m4 \
-	$(top_srcdir)/autotools/m4/fdopendir.m4 \
-	$(top_srcdir)/autotools/m4/filenamecat.m4 \
-	$(top_srcdir)/autotools/m4/float_h.m4 \
-	$(top_srcdir)/autotools/m4/fpieee.m4 \
-	$(top_srcdir)/autotools/m4/frexp.m4 \
-	$(top_srcdir)/autotools/m4/frexpl.m4 \
-	$(top_srcdir)/autotools/m4/fstat.m4 \
-	$(top_srcdir)/autotools/m4/fstatat.m4 \
-	$(top_srcdir)/autotools/m4/futimens.m4 \
-	$(top_srcdir)/autotools/m4/getcwd.m4 \
-	$(top_srcdir)/autotools/m4/getdelim.m4 \
-	$(top_srcdir)/autotools/m4/getdtablesize.m4 \
-	$(top_srcdir)/autotools/m4/getgroups.m4 \
-	$(top_srcdir)/autotools/m4/getline.m4 \
-	$(top_srcdir)/autotools/m4/getopt.m4 \
-	$(top_srcdir)/autotools/m4/getprogname.m4 \
-	$(top_srcdir)/autotools/m4/gettime.m4 \
-	$(top_srcdir)/autotools/m4/gettimeofday.m4 \
-	$(top_srcdir)/autotools/m4/gnulib-common.m4 \
-	$(top_srcdir)/autotools/m4/gnulib-comp.m4 \
-	$(top_srcdir)/autotools/m4/group-member.m4 \
-	$(top_srcdir)/autotools/m4/include_next.m4 \
-	$(top_srcdir)/autotools/m4/intmax_t.m4 \
-	$(top_srcdir)/autotools/m4/inttypes-pri.m4 \
-	$(top_srcdir)/autotools/m4/inttypes.m4 \
-	$(top_srcdir)/autotools/m4/inttypes_h.m4 \
-	$(top_srcdir)/autotools/m4/isnand.m4 \
-	$(top_srcdir)/autotools/m4/isnanf.m4 \
-	$(top_srcdir)/autotools/m4/isnanl.m4 \
-	$(top_srcdir)/autotools/m4/largefile.m4 \
-	$(top_srcdir)/autotools/m4/ldexpl.m4 \
-	$(top_srcdir)/autotools/m4/limits-h.m4 \
-	$(top_srcdir)/autotools/m4/localtime-buffer.m4 \
-	$(top_srcdir)/autotools/m4/longlong.m4 \
-	$(top_srcdir)/autotools/m4/lstat.m4 \
-	$(top_srcdir)/autotools/m4/malloc.m4 \
-	$(top_srcdir)/autotools/m4/malloca.m4 \
-	$(top_srcdir)/autotools/m4/math_h.m4 \
-	$(top_srcdir)/autotools/m4/memchr.m4 \
-	$(top_srcdir)/autotools/m4/mempcpy.m4 \
-	$(top_srcdir)/autotools/m4/memrchr.m4 \
-	$(top_srcdir)/autotools/m4/mkdir.m4 \
-	$(top_srcdir)/autotools/m4/mkdirat.m4 \
-	$(top_srcdir)/autotools/m4/mmap-anon.m4 \
-	$(top_srcdir)/autotools/m4/mode_t.m4 \
-	$(top_srcdir)/autotools/m4/msvc-inval.m4 \
-	$(top_srcdir)/autotools/m4/msvc-nothrow.m4 \
-	$(top_srcdir)/autotools/m4/multiarch.m4 \
-	$(top_srcdir)/autotools/m4/nocrash.m4 \
-	$(top_srcdir)/autotools/m4/off_t.m4 \
-	$(top_srcdir)/autotools/m4/open-cloexec.m4 \
-	$(top_srcdir)/autotools/m4/open.m4 \
-	$(top_srcdir)/autotools/m4/openat.m4 \
-	$(top_srcdir)/autotools/m4/opendir.m4 \
-	$(top_srcdir)/autotools/m4/pathmax.m4 \
-	$(top_srcdir)/autotools/m4/printf-frexp.m4 \
-	$(top_srcdir)/autotools/m4/printf-frexpl.m4 \
-	$(top_srcdir)/autotools/m4/printf.m4 \
-	$(top_srcdir)/autotools/m4/readlink.m4 \
-	$(top_srcdir)/autotools/m4/readlinkat.m4 \
-	$(top_srcdir)/autotools/m4/realloc.m4 \
-	$(top_srcdir)/autotools/m4/rename.m4 \
-	$(top_srcdir)/autotools/m4/renameat.m4 \
-	$(top_srcdir)/autotools/m4/rmdir.m4 \
-	$(top_srcdir)/autotools/m4/save-cwd.m4 \
-	$(top_srcdir)/autotools/m4/signbit.m4 \
-	$(top_srcdir)/autotools/m4/size_max.m4 \
-	$(top_srcdir)/autotools/m4/ssize_t.m4 \
-	$(top_srcdir)/autotools/m4/stat-time.m4 \
-	$(top_srcdir)/autotools/m4/stat.m4 \
-	$(top_srcdir)/autotools/m4/stdbool.m4 \
-	$(top_srcdir)/autotools/m4/stddef_h.m4 \
-	$(top_srcdir)/autotools/m4/stdint.m4 \
-	$(top_srcdir)/autotools/m4/stdint_h.m4 \
-	$(top_srcdir)/autotools/m4/stdio_h.m4 \
-	$(top_srcdir)/autotools/m4/stdlib_h.m4 \
-	$(top_srcdir)/autotools/m4/stpcpy.m4 \
-	$(top_srcdir)/autotools/m4/strcase.m4 \
-	$(top_srcdir)/autotools/m4/strcasestr.m4 \
-	$(top_srcdir)/autotools/m4/strdup.m4 \
-	$(top_srcdir)/autotools/m4/strerror.m4 \
-	$(top_srcdir)/autotools/m4/string_h.m4 \
-	$(top_srcdir)/autotools/m4/strings_h.m4 \
-	$(top_srcdir)/autotools/m4/strncat.m4 \
-	$(top_srcdir)/autotools/m4/symlink.m4 \
-	$(top_srcdir)/autotools/m4/symlinkat.m4 \
-	$(top_srcdir)/autotools/m4/sys_socket_h.m4 \
-	$(top_srcdir)/autotools/m4/sys_stat_h.m4 \
-	$(top_srcdir)/autotools/m4/sys_time_h.m4 \
-	$(top_srcdir)/autotools/m4/sys_types_h.m4 \
-	$(top_srcdir)/autotools/m4/time_h.m4 \
-	$(top_srcdir)/autotools/m4/timespec.m4 \
-	$(top_srcdir)/autotools/m4/unistd-safer.m4 \
-	$(top_srcdir)/autotools/m4/unistd_h.m4 \
-	$(top_srcdir)/autotools/m4/unlink.m4 \
-	$(top_srcdir)/autotools/m4/unlinkat.m4 \
-	$(top_srcdir)/autotools/m4/utime.m4 \
-	$(top_srcdir)/autotools/m4/utime_h.m4 \
-	$(top_srcdir)/autotools/m4/utimens.m4 \
-	$(top_srcdir)/autotools/m4/utimensat.m4 \
-	$(top_srcdir)/autotools/m4/utimes.m4 \
-	$(top_srcdir)/autotools/m4/vasnprintf.m4 \
-	$(top_srcdir)/autotools/m4/vasprintf-posix.m4 \
-	$(top_srcdir)/autotools/m4/vasprintf.m4 \
-	$(top_srcdir)/autotools/m4/warn-on-use.m4 \
-	$(top_srcdir)/autotools/m4/wchar_h.m4 \
-	$(top_srcdir)/autotools/m4/wchar_t.m4 \
-	$(top_srcdir)/autotools/m4/wint_t.m4 \
-	$(top_srcdir)/autotools/m4/xsize.m4 $(top_srcdir)/configure.ac
-am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
-	$(ACLOCAL_M4)
-DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
-	$(am__configure_deps) $(dist_postsyncd_SCRIPTS) \
-	$(am__DIST_COMMON)
-am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
- configure.lineno config.status.lineno
-mkinstalldirs = $(install_sh) -d
-CONFIG_HEADER = config.h
-CONFIG_CLEAN_FILES =
-CONFIG_CLEAN_VPATH_FILES =
-am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(postsyncddir)" \
-	"$(DESTDIR)$(man1dir)"
-PROGRAMS = $(bin_PROGRAMS)
-am_q_OBJECTS = q-main.$(OBJEXT)
-q_OBJECTS = $(am_q_OBJECTS)
-am__DEPENDENCIES_1 =
-q_DEPENDENCIES = $(top_builddir)/autotools/gnulib/libgnu.a \
-	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
-am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
-am__vpath_adj = case $$p in \
-    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
-    *) f=$$p;; \
-  esac;
-am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
-am__install_max = 40
-am__nobase_strip_setup = \
-  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
-am__nobase_strip = \
-  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
-am__nobase_list = $(am__nobase_strip_setup); \
-  for p in $$list; do echo "$$p $$p"; done | \
-  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
-  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
-    if (++n[$$2] == $(am__install_max)) \
-      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
-    END { for (dir in files) print dir, files[dir] }'
-am__base_list = \
-  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
-  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
-am__uninstall_files_from_dir = { \
-  test -z "$$files" \
-    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
-    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
-         $(am__cd) "$$dir" && rm -f $$files; }; \
-  }
-SCRIPTS = $(dist_postsyncd_SCRIPTS)
-AM_V_P = $(am__v_P_$(V))
-am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
-am__v_P_0 = false
-am__v_P_1 = :
-AM_V_GEN = $(am__v_GEN_$(V))
-am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
-am__v_GEN_0 = @echo "  GEN     " $@;
-am__v_GEN_1 = 
-AM_V_at = $(am__v_at_$(V))
-am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
-am__v_at_0 = @
-am__v_at_1 = 
-DEFAULT_INCLUDES = -I.
-depcomp = $(SHELL) $(top_srcdir)/autotools/depcomp
-am__depfiles_maybe = depfiles
-am__mv = mv -f
-AM_V_lt = $(am__v_lt_$(V))
-am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
-am__v_lt_0 = --silent
-am__v_lt_1 = 
-COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
-	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
-AM_V_CC = $(am__v_CC_$(V))
-am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
-am__v_CC_0 = @echo "  CC      " $@;
-am__v_CC_1 = 
-CCLD = $(CC)
-LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
-AM_V_CCLD = $(am__v_CCLD_$(V))
-am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
-am__v_CCLD_0 = @echo "  CCLD    " $@;
-am__v_CCLD_1 = 
-SOURCES = $(q_SOURCES)
-DIST_SOURCES = $(q_SOURCES)
-RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
-	ctags-recursive dvi-recursive html-recursive info-recursive \
-	install-data-recursive install-dvi-recursive \
-	install-exec-recursive install-html-recursive \
-	install-info-recursive install-pdf-recursive \
-	install-ps-recursive install-recursive installcheck-recursive \
-	installdirs-recursive pdf-recursive ps-recursive \
-	tags-recursive uninstall-recursive
-am__can_run_installinfo = \
-  case $$AM_UPDATE_INFO_DIR in \
-    n|no|NO) false;; \
-    *) (install-info --version) >/dev/null 2>&1;; \
-  esac
-man1dir = $(mandir)/man1
-NROFF = nroff
-MANS = $(dist_man_MANS)
-RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
-  distclean-recursive maintainer-clean-recursive
-am__recursive_targets = \
-  $(RECURSIVE_TARGETS) \
-  $(RECURSIVE_CLEAN_TARGETS) \
-  $(am__extra_recursive_targets)
-AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
-	cscope distdir dist dist-all distcheck
-am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
-	$(LISP)config.h.in
-# Read a list of newline-separated strings from the standard input,
-# and print each of them once, without duplicates.  Input order is
-# *not* preserved.
-am__uniquify_input = $(AWK) '\
-  BEGIN { nonempty = 0; } \
-  { items[$$0] = 1; nonempty = 1; } \
-  END { if (nonempty) { for (i in items) print i; }; } \
-'
-# Make sure the list of sources is unique.  This is necessary because,
-# e.g., the same source file might be shared among _SOURCES variables
-# for different programs/libraries.
-am__define_uniq_tagged_files = \
-  list='$(am__tagged_files)'; \
-  unique=`for i in $$list; do \
-    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
-  done | $(am__uniquify_input)`
-ETAGS = etags
-CTAGS = ctags
-CSCOPE = cscope
-DIST_SUBDIRS = $(SUBDIRS)
-am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in \
-	$(srcdir)/config.h.in $(top_srcdir)/autotools/compile \
-	$(top_srcdir)/autotools/config.guess \
-	$(top_srcdir)/autotools/config.sub \
-	$(top_srcdir)/autotools/depcomp \
-	$(top_srcdir)/autotools/install-sh \
-	$(top_srcdir)/autotools/missing COPYING autotools/compile \
-	autotools/config.guess autotools/config.sub autotools/depcomp \
-	autotools/install-sh autotools/missing
-DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-distdir = $(PACKAGE)-$(VERSION)
-top_distdir = $(distdir)
-am__remove_distdir = \
-  if test -d "$(distdir)"; then \
-    find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
-      && rm -rf "$(distdir)" \
-      || { sleep 5 && rm -rf "$(distdir)"; }; \
-  else :; fi
-am__post_remove_distdir = $(am__remove_distdir)
-am__relativize = \
-  dir0=`pwd`; \
-  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
-  sed_rest='s,^[^/]*/*,,'; \
-  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
-  sed_butlast='s,/*[^/]*$$,,'; \
-  while test -n "$$dir1"; do \
-    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
-    if test "$$first" != "."; then \
-      if test "$$first" = ".."; then \
-        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
-        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
-      else \
-        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
-        if test "$$first2" = "$$first"; then \
-          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
-        else \
-          dir2="../$$dir2"; \
-        fi; \
-        dir0="$$dir0"/"$$first"; \
-      fi; \
-    fi; \
-    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
-  done; \
-  reldir="$$dir2"
-GZIP_ENV = --best
-DIST_ARCHIVES = $(distdir).tar.xz
-DIST_TARGETS = dist-xz
-distuninstallcheck_listfiles = find . -type f -print
-am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
-  | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
-distcleancheck_listfiles = find . -type f -print
-ACLOCAL = ${SHELL} /net/ptah/export/gentoo/working-repos/portage-utils/autotools/missing aclocal-1.15
-ALLOCA = 
-ALLOCA_H = alloca.h
-AMTAR = $${TAR-tar}
-AM_DEFAULT_VERBOSITY = 0
-APPLE_UNIVERSAL_BUILD = 0
-AR = ar
-ARFLAGS = cr
-AUTOCONF = ${SHELL} /net/ptah/export/gentoo/working-repos/portage-utils/autotools/missing autoconf
-AUTOHEADER = ${SHELL} /net/ptah/export/gentoo/working-repos/portage-utils/autotools/missing autoheader
-AUTOMAKE = ${SHELL} /net/ptah/export/gentoo/working-repos/portage-utils/autotools/missing automake-1.15
-AWK = gawk
-BITSIZEOF_PTRDIFF_T = 
-BITSIZEOF_SIG_ATOMIC_T = 
-BITSIZEOF_SIZE_T = 
-BITSIZEOF_WCHAR_T = 
-BITSIZEOF_WINT_T = 
-CC = gcc
-CCDEPMODE = depmode=gcc3
-CFLAGS = -g -O2 -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings -Wbad-function-cast -Wnested-externs -Wcomment -Winline -Wchar-subscripts -Wcast-align -Wno-format-nonliteral -Wsequence-point -Wold-style-definition -Wextra
-CPP = gcc -E
-CPPFLAGS = 
-CYGPATH_W = echo
-DEFS = -DHAVE_CONFIG_H
-DEPDIR = .deps
-ECHO_C = \c
-ECHO_N = 
-ECHO_T = 
-EGREP = /gentoo/prefix64/usr/bin/grep -E
-EMULTIHOP_HIDDEN = 
-EMULTIHOP_VALUE = 
-ENOLINK_HIDDEN = 
-ENOLINK_VALUE = 
-EOVERFLOW_HIDDEN = 
-EOVERFLOW_VALUE = 
-ERRNO_H = 
-EXEEXT = 
-FLOAT_H = 
-GETOPT_CDEFS_H = 
-GETOPT_H = 
-GNULIB_ACOSF = 0
-GNULIB_ACOSL = 0
-GNULIB_ALPHASORT = 0
-GNULIB_ASINF = 0
-GNULIB_ASINL = 0
-GNULIB_ATAN2F = 0
-GNULIB_ATANF = 0
-GNULIB_ATANL = 0
-GNULIB_ATOLL = 0
-GNULIB_BTOWC = 0
-GNULIB_CALLOC_POSIX = 0
-GNULIB_CANONICALIZE_FILE_NAME = 1
-GNULIB_CBRT = 0
-GNULIB_CBRTF = 0
-GNULIB_CBRTL = 0
-GNULIB_CEIL = 0
-GNULIB_CEILF = 0
-GNULIB_CEILL = 0
-GNULIB_CHDIR = 1
-GNULIB_CHOWN = 0
-GNULIB_CLOSE = 1
-GNULIB_CLOSEDIR = 1
-GNULIB_COPYSIGN = 0
-GNULIB_COPYSIGNF = 0
-GNULIB_COPYSIGNL = 0
-GNULIB_COSF = 0
-GNULIB_COSHF = 0
-GNULIB_COSL = 0
-GNULIB_CTIME = 0
-GNULIB_DIRFD = 1
-GNULIB_DPRINTF = 0
-GNULIB_DUP = 1
-GNULIB_DUP2 = 1
-GNULIB_DUP3 = 0
-GNULIB_ENVIRON = 0
-GNULIB_EUIDACCESS = 1
-GNULIB_EXP2 = 0
-GNULIB_EXP2F = 0
-GNULIB_EXP2L = 0
-GNULIB_EXPF = 0
-GNULIB_EXPL = 0
-GNULIB_EXPLICIT_BZERO = 0
-GNULIB_EXPM1 = 0
-GNULIB_EXPM1F = 0
-GNULIB_EXPM1L = 0
-GNULIB_FABSF = 0
-GNULIB_FABSL = 0
-GNULIB_FACCESSAT = 1
-GNULIB_FCHDIR = 1
-GNULIB_FCHMODAT = 0
-GNULIB_FCHOWNAT = 0
-GNULIB_FCLOSE = 0
-GNULIB_FCNTL = 1
-GNULIB_FDATASYNC = 0
-GNULIB_FDOPEN = 0
-GNULIB_FDOPENDIR = 1
-GNULIB_FFLUSH = 0
-GNULIB_FFS = 0
-GNULIB_FFSL = 0
-GNULIB_FFSLL = 0
-GNULIB_FGETC = 1
-GNULIB_FGETS = 1
-GNULIB_FLOOR = 0
-GNULIB_FLOORF = 0
-GNULIB_FLOORL = 0
-GNULIB_FMA = 0
-GNULIB_FMAF = 0
-GNULIB_FMAL = 0
-GNULIB_FMOD = 0
-GNULIB_FMODF = 0
-GNULIB_FMODL = 0
-GNULIB_FOPEN = 0
-GNULIB_FPRINTF = 1
-GNULIB_FPRINTF_POSIX = 0
-GNULIB_FPURGE = 0
-GNULIB_FPUTC = 1
-GNULIB_FPUTS = 1
-GNULIB_FREAD = 1
-GNULIB_FREOPEN = 0
-GNULIB_FREXP = 1
-GNULIB_FREXPF = 0
-GNULIB_FREXPL = 1
-GNULIB_FSCANF = 1
-GNULIB_FSEEK = 0
-GNULIB_FSEEKO = 0
-GNULIB_FSTAT = 1
-GNULIB_FSTATAT = 1
-GNULIB_FSYNC = 0
-GNULIB_FTELL = 0
-GNULIB_FTELLO = 0
-GNULIB_FTRUNCATE = 0
-GNULIB_FUTIMENS = 1
-GNULIB_FWRITE = 1
-GNULIB_GETC = 1
-GNULIB_GETCHAR = 1
-GNULIB_GETCWD = 1
-GNULIB_GETDELIM = 1
-GNULIB_GETDOMAINNAME = 0
-GNULIB_GETDTABLESIZE = 1
-GNULIB_GETGROUPS = 1
-GNULIB_GETHOSTNAME = 0
-GNULIB_GETLINE = 1
-GNULIB_GETLOADAVG = 0
-GNULIB_GETLOGIN = 0
-GNULIB_GETLOGIN_R = 0
-GNULIB_GETPAGESIZE = 0
-GNULIB_GETSUBOPT = 0
-GNULIB_GETTIMEOFDAY = 1
-GNULIB_GETUSERSHELL = 0
-GNULIB_GL_UNISTD_H_GETOPT = 
-GNULIB_GRANTPT = 0
-GNULIB_GROUP_MEMBER = 1
-GNULIB_HYPOT = 0
-GNULIB_HYPOTF = 0
-GNULIB_HYPOTL = 0
-GNULIB_ILOGB = 0
-GNULIB_ILOGBF = 0
-GNULIB_ILOGBL = 0
-GNULIB_IMAXABS = 0
-GNULIB_IMAXDIV = 0
-GNULIB_ISATTY = 0
-GNULIB_ISFINITE = 0
-GNULIB_ISINF = 0
-GNULIB_ISNAN = 0
-GNULIB_ISNAND = 0
-GNULIB_ISNANF = 0
-GNULIB_ISNANL = 0
-GNULIB_LCHMOD = 0
-GNULIB_LCHOWN = 0
-GNULIB_LDEXPF = 0
-GNULIB_LDEXPL = 0
-GNULIB_LINK = 0
-GNULIB_LINKAT = 0
-GNULIB_LOCALTIME = 0
-GNULIB_LOG = 0
-GNULIB_LOG10 = 0
-GNULIB_LOG10F = 0
-GNULIB_LOG10L = 0
-GNULIB_LOG1P = 0
-GNULIB_LOG1PF = 0
-GNULIB_LOG1PL = 0
-GNULIB_LOG2 = 0
-GNULIB_LOG2F = 0
-GNULIB_LOG2L = 0
-GNULIB_LOGB = 0
-GNULIB_LOGBF = 0
-GNULIB_LOGBL = 0
-GNULIB_LOGF = 0
-GNULIB_LOGL = 0
-GNULIB_LSEEK = 0
-GNULIB_LSTAT = 1
-GNULIB_MALLOC_POSIX = 1
-GNULIB_MBRLEN = 0
-GNULIB_MBRTOWC = 0
-GNULIB_MBSCASECMP = 0
-GNULIB_MBSCASESTR = 0
-GNULIB_MBSCHR = 0
-GNULIB_MBSCSPN = 0
-GNULIB_MBSINIT = 0
-GNULIB_MBSLEN = 0
-GNULIB_MBSNCASECMP = 0
-GNULIB_MBSNLEN = 0
-GNULIB_MBSNRTOWCS = 0
-GNULIB_MBSPBRK = 0
-GNULIB_MBSPCASECMP = 0
-GNULIB_MBSRCHR = 0
-GNULIB_MBSRTOWCS = 0
-GNULIB_MBSSEP = 0
-GNULIB_MBSSPN = 0
-GNULIB_MBSSTR = 0
-GNULIB_MBSTOK_R = 0
-GNULIB_MBTOWC = 0
-GNULIB_MEMCHR = 1
-GNULIB_MEMMEM = 0
-GNULIB_MEMPCPY = 1
-GNULIB_MEMRCHR = 1
-GNULIB_MKDIRAT = 1
-GNULIB_MKDTEMP = 0
-GNULIB_MKFIFO = 0
-GNULIB_MKFIFOAT = 0
-GNULIB_MKNOD = 0
-GNULIB_MKNODAT = 0
-GNULIB_MKOSTEMP = 0
-GNULIB_MKOSTEMPS = 0
-GNULIB_MKSTEMP = 0
-GNULIB_MKSTEMPS = 0
-GNULIB_MKTIME = 0
-GNULIB_MODF = 0
-GNULIB_MODFF = 0
-GNULIB_MODFL = 0
-GNULIB_NANOSLEEP = 0
-GNULIB_NONBLOCKING = 0
-GNULIB_OBSTACK_PRINTF = 0
-GNULIB_OBSTACK_PRINTF_POSIX = 0
-GNULIB_OPEN = 1
-GNULIB_OPENAT = 1
-GNULIB_OPENDIR = 1
-GNULIB_OVERRIDES_STRUCT_STAT = 0
-GNULIB_OVERRIDES_WINT_T = 0
-GNULIB_PCLOSE = 0
-GNULIB_PERROR = 0
-GNULIB_PIPE = 0
-GNULIB_PIPE2 = 0
-GNULIB_POPEN = 0
-GNULIB_POSIX_OPENPT = 0
-GNULIB_POWF = 0
-GNULIB_PREAD = 0
-GNULIB_PRINTF = 1
-GNULIB_PRINTF_POSIX = 0
-GNULIB_PTSNAME = 0
-GNULIB_PTSNAME_R = 0
-GNULIB_PUTC = 1
-GNULIB_PUTCHAR = 1
-GNULIB_PUTENV = 0
-GNULIB_PUTS = 1
-GNULIB_PWRITE = 0
-GNULIB_QSORT_R = 0
-GNULIB_RANDOM = 0
-GNULIB_RANDOM_R = 0
-GNULIB_RAWMEMCHR = 0
-GNULIB_READ = 0
-GNULIB_READDIR = 0
-GNULIB_READLINK = 1
-GNULIB_READLINKAT = 1
-GNULIB_REALLOCARRAY = 0
-GNULIB_REALLOC_POSIX = 1
-GNULIB_REALPATH = 1
-GNULIB_REMAINDER = 0
-GNULIB_REMAINDERF = 0
-GNULIB_REMAINDERL = 0
-GNULIB_REMOVE = 0
-GNULIB_RENAME = 1
-GNULIB_RENAMEAT = 1
-GNULIB_REWINDDIR = 0
-GNULIB_RINT = 0
-GNULIB_RINTF = 0
-GNULIB_RINTL = 0
-GNULIB_RMDIR = 1
-GNULIB_ROUND = 0
-GNULIB_ROUNDF = 0
-GNULIB_ROUNDL = 0
-GNULIB_RPMATCH = 0
-GNULIB_SCANDIR = 0
-GNULIB_SCANF = 1
-GNULIB_SECURE_GETENV = 0
-GNULIB_SETENV = 0
-GNULIB_SETHOSTNAME = 0
-GNULIB_SIGNBIT = 1
-GNULIB_SINF = 0
-GNULIB_SINHF = 0
-GNULIB_SINL = 0
-GNULIB_SLEEP = 0
-GNULIB_SNPRINTF = 0
-GNULIB_SPRINTF_POSIX = 0
-GNULIB_SQRTF = 0
-GNULIB_SQRTL = 0
-GNULIB_STAT = 1
-GNULIB_STDIO_H_NONBLOCKING = 0
-GNULIB_STDIO_H_SIGPIPE = 0
-GNULIB_STPCPY = 1
-GNULIB_STPNCPY = 0
-GNULIB_STRCASESTR = 1
-GNULIB_STRCHRNUL = 0
-GNULIB_STRDUP = 1
-GNULIB_STRERROR = 1
-GNULIB_STRERROR_R = 0
-GNULIB_STRFTIME = 0
-GNULIB_STRNCAT = 1
-GNULIB_STRNDUP = 0
-GNULIB_STRNLEN = 0
-GNULIB_STRPBRK = 0
-GNULIB_STRPTIME = 0
-GNULIB_STRSEP = 0
-GNULIB_STRSIGNAL = 0
-GNULIB_STRSTR = 0
-GNULIB_STRTOD = 0
-GNULIB_STRTOIMAX = 0
-GNULIB_STRTOK_R = 0
-GNULIB_STRTOLL = 0
-GNULIB_STRTOULL = 0
-GNULIB_STRTOUMAX = 0
-GNULIB_STRVERSCMP = 0
-GNULIB_SYMLINK = 1
-GNULIB_SYMLINKAT = 1
-GNULIB_SYSTEM_POSIX = 0
-GNULIB_TANF = 0
-GNULIB_TANHF = 0
-GNULIB_TANL = 0
-GNULIB_TIMEGM = 0
-GNULIB_TIME_R = 0
-GNULIB_TIME_RZ = 0
-GNULIB_TMPFILE = 0
-GNULIB_TRUNC = 0
-GNULIB_TRUNCATE = 0
-GNULIB_TRUNCF = 0
-GNULIB_TRUNCL = 0
-GNULIB_TTYNAME_R = 0
-GNULIB_TZSET = 0
-GNULIB_UNISTD_H_NONBLOCKING = 0
-GNULIB_UNISTD_H_SIGPIPE = 0
-GNULIB_UNLINK = 1
-GNULIB_UNLINKAT = 1
-GNULIB_UNLOCKPT = 0
-GNULIB_UNSETENV = 0
-GNULIB_USLEEP = 0
-GNULIB_UTIME = 1
-GNULIB_UTIMENSAT = 1
-GNULIB_VASPRINTF = 1
-GNULIB_VDPRINTF = 0
-GNULIB_VFPRINTF = 1
-GNULIB_VFPRINTF_POSIX = 0
-GNULIB_VFSCANF = 0
-GNULIB_VPRINTF = 1
-GNULIB_VPRINTF_POSIX = 0
-GNULIB_VSCANF = 0
-GNULIB_VSNPRINTF = 0
-GNULIB_VSPRINTF_POSIX = 0
-GNULIB_WCPCPY = 0
-GNULIB_WCPNCPY = 0
-GNULIB_WCRTOMB = 0
-GNULIB_WCSCASECMP = 0
-GNULIB_WCSCAT = 0
-GNULIB_WCSCHR = 0
-GNULIB_WCSCMP = 0
-GNULIB_WCSCOLL = 0
-GNULIB_WCSCPY = 0
-GNULIB_WCSCSPN = 0
-GNULIB_WCSDUP = 0
-GNULIB_WCSFTIME = 0
-GNULIB_WCSLEN = 0
-GNULIB_WCSNCASECMP = 0
-GNULIB_WCSNCAT = 0
-GNULIB_WCSNCMP = 0
-GNULIB_WCSNCPY = 0
-GNULIB_WCSNLEN = 0
-GNULIB_WCSNRTOMBS = 0
-GNULIB_WCSPBRK = 0
-GNULIB_WCSRCHR = 0
-GNULIB_WCSRTOMBS = 0
-GNULIB_WCSSPN = 0
-GNULIB_WCSSTR = 0
-GNULIB_WCSTOK = 0
-GNULIB_WCSWIDTH = 0
-GNULIB_WCSXFRM = 0
-GNULIB_WCTOB = 0
-GNULIB_WCTOMB = 0
-GNULIB_WCWIDTH = 0
-GNULIB_WMEMCHR = 0
-GNULIB_WMEMCMP = 0
-GNULIB_WMEMCPY = 0
-GNULIB_WMEMMOVE = 0
-GNULIB_WMEMSET = 0
-GNULIB_WRITE = 0
-GNULIB__EXIT = 0
-GREP = /gentoo/prefix64/usr/bin/grep
-HAVE_ACOSF = 1
-HAVE_ACOSL = 1
-HAVE_ALPHASORT = 1
-HAVE_ASINF = 1
-HAVE_ASINL = 1
-HAVE_ATAN2F = 1
-HAVE_ATANF = 1
-HAVE_ATANL = 1
-HAVE_ATOLL = 1
-HAVE_BTOWC = 1
-HAVE_C99_STDINT_H = 1
-HAVE_CANONICALIZE_FILE_NAME = 1
-HAVE_CBRT = 1
-HAVE_CBRTF = 1
-HAVE_CBRTL = 1
-HAVE_CHOWN = 1
-HAVE_CLOSEDIR = 1
-HAVE_COPYSIGN = 1
-HAVE_COPYSIGNL = 1
-HAVE_COSF = 1
-HAVE_COSHF = 1
-HAVE_COSL = 1
-HAVE_CRTDEFS_H = 0
-HAVE_DECL_ACOSL = 1
-HAVE_DECL_ASINL = 1
-HAVE_DECL_ATANL = 1
-HAVE_DECL_CBRTF = 1
-HAVE_DECL_CBRTL = 1
-HAVE_DECL_CEILF = 1
-HAVE_DECL_CEILL = 1
-HAVE_DECL_COPYSIGNF = 1
-HAVE_DECL_COSL = 1
-HAVE_DECL_DIRFD = 1
-HAVE_DECL_ENVIRON = 1
-HAVE_DECL_EXP2 = 1
-HAVE_DECL_EXP2F = 1
-HAVE_DECL_EXP2L = 1
-HAVE_DECL_EXPL = 1
-HAVE_DECL_EXPM1L = 1
-HAVE_DECL_FCHDIR = 1
-HAVE_DECL_FDATASYNC = 1
-HAVE_DECL_FDOPENDIR = 1
-HAVE_DECL_FLOORF = 1
-HAVE_DECL_FLOORL = 1
-HAVE_DECL_FPURGE = 1
-HAVE_DECL_FREXPL = 1
-HAVE_DECL_FSEEKO = 1
-HAVE_DECL_FTELLO = 1
-HAVE_DECL_GETDELIM = 1
-HAVE_DECL_GETDOMAINNAME = 1
-HAVE_DECL_GETLINE = 1
-HAVE_DECL_GETLOADAVG = 1
-HAVE_DECL_GETLOGIN = 1
-HAVE_DECL_GETLOGIN_R = 1
-HAVE_DECL_GETPAGESIZE = 1
-HAVE_DECL_GETUSERSHELL = 1
-HAVE_DECL_IMAXABS = 1
-HAVE_DECL_IMAXDIV = 1
-HAVE_DECL_INITSTATE = 1
-HAVE_DECL_LDEXPL = 1
-HAVE_DECL_LOCALTIME_R = 1
-HAVE_DECL_LOG10L = 1
-HAVE_DECL_LOG2 = 1
-HAVE_DECL_LOG2F = 1
-HAVE_DECL_LOG2L = 1
-HAVE_DECL_LOGB = 1
-HAVE_DECL_LOGL = 1
-HAVE_DECL_MEMMEM = 1
-HAVE_DECL_MEMRCHR = 0
-HAVE_DECL_OBSTACK_PRINTF = 1
-HAVE_DECL_REMAINDER = 1
-HAVE_DECL_REMAINDERL = 1
-HAVE_DECL_RINTF = 1
-HAVE_DECL_ROUND = 1
-HAVE_DECL_ROUNDF = 1
-HAVE_DECL_ROUNDL = 1
-HAVE_DECL_SETENV = 1
-HAVE_DECL_SETHOSTNAME = 1
-HAVE_DECL_SETSTATE = 1
-HAVE_DECL_SINL = 1
-HAVE_DECL_SNPRINTF = 1
-HAVE_DECL_SQRTL = 1
-HAVE_DECL_STRDUP = 1
-HAVE_DECL_STRERROR_R = 1
-HAVE_DECL_STRNCASECMP = 1
-HAVE_DECL_STRNDUP = 1
-HAVE_DECL_STRNLEN = 1
-HAVE_DECL_STRSIGNAL = 1
-HAVE_DECL_STRTOIMAX = 1
-HAVE_DECL_STRTOK_R = 1
-HAVE_DECL_STRTOUMAX = 1
-HAVE_DECL_TANL = 1
-HAVE_DECL_TRUNC = 1
-HAVE_DECL_TRUNCF = 1
-HAVE_DECL_TRUNCL = 1
-HAVE_DECL_TTYNAME_R = 1
-HAVE_DECL_UNSETENV = 1
-HAVE_DECL_VSNPRINTF = 1
-HAVE_DECL_WCTOB = 1
-HAVE_DECL_WCWIDTH = 1
-HAVE_DIRENT_H = 1
-HAVE_DPRINTF = 1
-HAVE_DUP2 = 1
-HAVE_DUP3 = 1
-HAVE_EUIDACCESS = 0
-HAVE_EXPF = 1
-HAVE_EXPL = 1
-HAVE_EXPLICIT_BZERO = 1
-HAVE_EXPM1 = 1
-HAVE_EXPM1F = 1
-HAVE_FABSF = 1
-HAVE_FABSL = 1
-HAVE_FACCESSAT = 1
-HAVE_FCHDIR = 1
-HAVE_FCHMODAT = 1
-HAVE_FCHOWNAT = 1
-HAVE_FCNTL = 1
-HAVE_FDATASYNC = 1
-HAVE_FDOPENDIR = 1
-HAVE_FEATURES_H = 0
-HAVE_FFS = 1
-HAVE_FFSL = 1
-HAVE_FFSLL = 1
-HAVE_FMA = 1
-HAVE_FMAF = 1
-HAVE_FMAL = 1
-HAVE_FMODF = 1
-HAVE_FMODL = 1
-HAVE_FREXPF = 1
-HAVE_FSEEKO = 1
-HAVE_FSTATAT = 1
-HAVE_FSYNC = 1
-HAVE_FTELLO = 1
-HAVE_FTRUNCATE = 1
-HAVE_FUTIMENS = 1
-HAVE_GETDTABLESIZE = 1
-HAVE_GETGROUPS = 1
-HAVE_GETHOSTNAME = 1
-HAVE_GETLOGIN = 1
-HAVE_GETOPT_H = 1
-HAVE_GETPAGESIZE = 1
-HAVE_GETSUBOPT = 1
-HAVE_GETTIMEOFDAY = 1
-HAVE_GRANTPT = 1
-HAVE_GROUP_MEMBER = 0
-HAVE_HYPOTF = 1
-HAVE_HYPOTL = 1
-HAVE_ILOGB = 1
-HAVE_ILOGBF = 1
-HAVE_ILOGBL = 1
-HAVE_INTTYPES_H = 1
-HAVE_ISNAND = 1
-HAVE_ISNANF = 1
-HAVE_ISNANL = 1
-HAVE_LCHMOD = 1
-HAVE_LCHOWN = 1
-HAVE_LDEXPF = 1
-HAVE_LINK = 1
-HAVE_LINKAT = 1
-HAVE_LOG10F = 1
-HAVE_LOG10L = 1
-HAVE_LOG1P = 1
-HAVE_LOG1PF = 1
-HAVE_LOG1PL = 1
-HAVE_LOGBF = 1
-HAVE_LOGBL = 1
-HAVE_LOGF = 1
-HAVE_LOGL = 1
-HAVE_LONG_LONG_INT = 1
-HAVE_LSTAT = 1
-HAVE_MAX_ALIGN_T = 1
-HAVE_MBRLEN = 1
-HAVE_MBRTOWC = 1
-HAVE_MBSINIT = 1
-HAVE_MBSLEN = 0
-HAVE_MBSNRTOWCS = 1
-HAVE_MBSRTOWCS = 1
-HAVE_MEMCHR = 1
-HAVE_MEMPCPY = 0
-HAVE_MKDIRAT = 1
-HAVE_MKDTEMP = 1
-HAVE_MKFIFO = 1
-HAVE_MKFIFOAT = 1
-HAVE_MKNOD = 1
-HAVE_MKNODAT = 1
-HAVE_MKOSTEMP = 1
-HAVE_MKOSTEMPS = 1
-HAVE_MKSTEMP = 1
-HAVE_MKSTEMPS = 1
-HAVE_MODFF = 1
-HAVE_MODFL = 1
-HAVE_MSVC_INVALID_PARAMETER_HANDLER = 0
-HAVE_NANOSLEEP = 1
-HAVE_OPENAT = 1
-HAVE_OPENDIR = 1
-HAVE_OS_H = 0
-HAVE_PCLOSE = 1
-HAVE_PIPE = 1
-HAVE_PIPE2 = 1
-HAVE_POPEN = 1
-HAVE_POSIX_OPENPT = 1
-HAVE_POWF = 1
-HAVE_PREAD = 1
-HAVE_PTSNAME = 1
-HAVE_PTSNAME_R = 1
-HAVE_PWRITE = 1
-HAVE_QSORT_R = 1
-HAVE_RANDOM = 1
-HAVE_RANDOM_H = 1
-HAVE_RANDOM_R = 1
-HAVE_RAWMEMCHR = 1
-HAVE_READDIR = 1
-HAVE_READLINK = 1
-HAVE_READLINKAT = 1
-HAVE_REALLOCARRAY = 1
-HAVE_REALPATH = 1
-HAVE_REMAINDER = 1
-HAVE_REMAINDERF = 1
-HAVE_RENAMEAT = 1
-HAVE_REWINDDIR = 1
-HAVE_RINT = 1
-HAVE_RINTL = 1
-HAVE_RPMATCH = 1
-HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0
-HAVE_SCANDIR = 1
-HAVE_SECURE_GETENV = 1
-HAVE_SETENV = 1
-HAVE_SETHOSTNAME = 1
-HAVE_SIGNED_SIG_ATOMIC_T = 
-HAVE_SIGNED_WCHAR_T = 
-HAVE_SIGNED_WINT_T = 
-HAVE_SINF = 1
-HAVE_SINHF = 1
-HAVE_SINL = 1
-HAVE_SLEEP = 1
-HAVE_SQRTF = 1
-HAVE_SQRTL = 1
-HAVE_STDINT_H = 1
-HAVE_STPCPY = 1
-HAVE_STPNCPY = 1
-HAVE_STRCASECMP = 1
-HAVE_STRCASESTR = 1
-HAVE_STRCHRNUL = 1
-HAVE_STRINGS_H = 1
-HAVE_STRPBRK = 1
-HAVE_STRPTIME = 1
-HAVE_STRSEP = 1
-HAVE_STRTOD = 1
-HAVE_STRTOLL = 1
-HAVE_STRTOULL = 1
-HAVE_STRUCT_RANDOM_DATA = 1
-HAVE_STRUCT_TIMEVAL = 1
-HAVE_STRVERSCMP = 1
-HAVE_SYMLINK = 1
-HAVE_SYMLINKAT = 1
-HAVE_SYS_BITYPES_H = 0
-HAVE_SYS_CDEFS_H = 
-HAVE_SYS_INTTYPES_H = 0
-HAVE_SYS_LOADAVG_H = 0
-HAVE_SYS_PARAM_H = 0
-HAVE_SYS_TIME_H = 1
-HAVE_SYS_TYPES_H = 1
-HAVE_TANF = 1
-HAVE_TANHF = 1
-HAVE_TANL = 1
-HAVE_TIMEGM = 1
-HAVE_TIMEZONE_T = 0
-HAVE_TRUNCATE = 1
-HAVE_TZSET = 1
-HAVE_UNISTD_H = 1
-HAVE_UNLINKAT = 1
-HAVE_UNLOCKPT = 1
-HAVE_UNSIGNED_LONG_LONG_INT = 1
-HAVE_USLEEP = 1
-HAVE_UTIME = 1
-HAVE_UTIMENSAT = 1
-HAVE_UTIME_H = 1
-HAVE_VASPRINTF = 1
-HAVE_VDPRINTF = 1
-HAVE_WCHAR_H = 1
-HAVE_WCHAR_T = 1
-HAVE_WCPCPY = 1
-HAVE_WCPNCPY = 1
-HAVE_WCRTOMB = 1
-HAVE_WCSCASECMP = 1
-HAVE_WCSCAT = 1
-HAVE_WCSCHR = 1
-HAVE_WCSCMP = 1
-HAVE_WCSCOLL = 1
-HAVE_WCSCPY = 1
-HAVE_WCSCSPN = 1
-HAVE_WCSDUP = 1
-HAVE_WCSFTIME = 1
-HAVE_WCSLEN = 1
-HAVE_WCSNCASECMP = 1
-HAVE_WCSNCAT = 1
-HAVE_WCSNCMP = 1
-HAVE_WCSNCPY = 1
-HAVE_WCSNLEN = 1
-HAVE_WCSNRTOMBS = 1
-HAVE_WCSPBRK = 1
-HAVE_WCSRCHR = 1
-HAVE_WCSRTOMBS = 1
-HAVE_WCSSPN = 1
-HAVE_WCSSTR = 1
-HAVE_WCSTOK = 1
-HAVE_WCSWIDTH = 1
-HAVE_WCSXFRM = 1
-HAVE_WINSOCK2_H = 0
-HAVE_WINT_T = 1
-HAVE_WMEMCHR = 1
-HAVE_WMEMCMP = 1
-HAVE_WMEMCPY = 1
-HAVE_WMEMMOVE = 1
-HAVE_WMEMSET = 1
-HAVE__BOOL = 1
-HAVE__EXIT = 1
-INCLUDE_NEXT = include_next
-INCLUDE_NEXT_AS_FIRST_DIRECTIVE = include_next
-INSTALL = /gentoo/prefix64/usr/bin/install -c
-INSTALL_DATA = ${INSTALL} -m 644
-INSTALL_PROGRAM = ${INSTALL}
-INSTALL_SCRIPT = ${INSTALL}
-INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
-INT32_MAX_LT_INTMAX_MAX = 1
-INT64_MAX_EQ_LONG_MAX = 1
-LDFLAGS = 
-LIBGNU_LIBDEPS = 
-LIBGNU_LTLIBDEPS = 
-LIBINTL = 
-LIBOBJS = 
-LIBS = -lkvm 
-LIB_CLOCK_GETTIME = 
-LIB_EACCESS = -lgen
-LIMITS_H = limits.h
-LTLIBINTL = 
-LTLIBOBJS = 
-MAKEINFO = ${SHELL} /net/ptah/export/gentoo/working-repos/portage-utils/autotools/missing makeinfo
-MKDIR_P = /gentoo/prefix64/usr/bin/mkdir -p
-NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = <dirent.h>
-NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = 
-NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = <fcntl.h>
-NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = 
-NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = <getopt.h>
-NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = <inttypes.h>
-NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = <limits.h>
-NEXT_AS_FIRST_DIRECTIVE_MATH_H = <math.h>
-NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = 
-NEXT_AS_FIRST_DIRECTIVE_STDINT_H = <stdint.h>
-NEXT_AS_FIRST_DIRECTIVE_STDIO_H = <stdio.h>
-NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = <stdlib.h>
-NEXT_AS_FIRST_DIRECTIVE_STRINGS_H = <strings.h>
-NEXT_AS_FIRST_DIRECTIVE_STRING_H = <string.h>
-NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = <sys/stat.h>
-NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = <sys/time.h>
-NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = <sys/types.h>
-NEXT_AS_FIRST_DIRECTIVE_TIME_H = <time.h>
-NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = <unistd.h>
-NEXT_AS_FIRST_DIRECTIVE_UTIME_H = <utime.h>
-NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = <wchar.h>
-NEXT_DIRENT_H = <dirent.h>
-NEXT_ERRNO_H = 
-NEXT_FCNTL_H = <fcntl.h>
-NEXT_FLOAT_H = 
-NEXT_GETOPT_H = <getopt.h>
-NEXT_INTTYPES_H = <inttypes.h>
-NEXT_LIMITS_H = <limits.h>
-NEXT_MATH_H = <math.h>
-NEXT_STDDEF_H = 
-NEXT_STDINT_H = <stdint.h>
-NEXT_STDIO_H = <stdio.h>
-NEXT_STDLIB_H = <stdlib.h>
-NEXT_STRINGS_H = <strings.h>
-NEXT_STRING_H = <string.h>
-NEXT_SYS_STAT_H = <sys/stat.h>
-NEXT_SYS_TIME_H = <sys/time.h>
-NEXT_SYS_TYPES_H = <sys/types.h>
-NEXT_TIME_H = <time.h>
-NEXT_UNISTD_H = <unistd.h>
-NEXT_UTIME_H = <utime.h>
-NEXT_WCHAR_H = <wchar.h>
-OBJEXT = o
-PACKAGE = portage-utils
-PACKAGE_BUGREPORT = 
-PACKAGE_NAME = portage-utils
-PACKAGE_STRING = portage-utils git
-PACKAGE_TARNAME = portage-utils
-PACKAGE_URL = 
-PACKAGE_VERSION = git
-PATH_SEPARATOR = :
-PRAGMA_COLUMNS = 
-PRAGMA_SYSTEM_HEADER = #pragma GCC system_header
-PRIPTR_PREFIX = "l"
-PRI_MACROS_BROKEN = 0
-PTHREAD_H_DEFINES_STRUCT_TIMESPEC = 0
-PTRDIFF_T_SUFFIX = 
-RANLIB = ranlib
-REPLACE_ACOSF = 0
-REPLACE_ASINF = 0
-REPLACE_ATAN2F = 0
-REPLACE_ATANF = 0
-REPLACE_BTOWC = 0
-REPLACE_CALLOC = 0
-REPLACE_CANONICALIZE_FILE_NAME = 0
-REPLACE_CBRTF = 0
-REPLACE_CBRTL = 0
-REPLACE_CEIL = 0
-REPLACE_CEILF = 0
-REPLACE_CEILL = 0
-REPLACE_CHOWN = 0
-REPLACE_CLOSE = 0
-REPLACE_CLOSEDIR = 0
-REPLACE_COSF = 0
-REPLACE_COSHF = 0
-REPLACE_CTIME = GNULIB_PORTCHECK
-REPLACE_DIRFD = 0
-REPLACE_DPRINTF = 0
-REPLACE_DUP = 0
-REPLACE_DUP2 = 0
-REPLACE_EXP2 = 0
-REPLACE_EXP2L = 0
-REPLACE_EXPF = 0
-REPLACE_EXPM1 = 0
-REPLACE_EXPM1F = 0
-REPLACE_FABSL = 0
-REPLACE_FACCESSAT = 0
-REPLACE_FCHOWNAT = 0
-REPLACE_FCLOSE = 0
-REPLACE_FCNTL = 0
-REPLACE_FDOPEN = 0
-REPLACE_FDOPENDIR = 0
-REPLACE_FFLUSH = 0
-REPLACE_FLOOR = 0
-REPLACE_FLOORF = 0
-REPLACE_FLOORL = 0
-REPLACE_FMA = 0
-REPLACE_FMAF = 0
-REPLACE_FMAL = 0
-REPLACE_FMOD = 0
-REPLACE_FMODF = 0
-REPLACE_FMODL = 0
-REPLACE_FOPEN = 0
-REPLACE_FPRINTF = 0
-REPLACE_FPURGE = 0
-REPLACE_FREOPEN = 0
-REPLACE_FREXP = 0
-REPLACE_FREXPF = 0
-REPLACE_FREXPL = 1
-REPLACE_FSEEK = 0
-REPLACE_FSEEKO = 0
-REPLACE_FSTAT = 1
-REPLACE_FSTATAT = 1
-REPLACE_FTELL = 0
-REPLACE_FTELLO = 0
-REPLACE_FTRUNCATE = 0
-REPLACE_FUTIMENS = 1
-REPLACE_GETCWD = 1
-REPLACE_GETDELIM = 0
-REPLACE_GETDOMAINNAME = 0
-REPLACE_GETDTABLESIZE = 0
-REPLACE_GETGROUPS = 0
-REPLACE_GETLINE = 0
-REPLACE_GETLOGIN_R = 0
-REPLACE_GETPAGESIZE = 0
-REPLACE_GETTIMEOFDAY = 0
-REPLACE_GMTIME = 0
-REPLACE_HUGE_VAL = 0
-REPLACE_HYPOT = 0
-REPLACE_HYPOTF = 0
-REPLACE_HYPOTL = 0
-REPLACE_ILOGB = 0
-REPLACE_ILOGBF = 0
-REPLACE_ILOGBL = 0
-REPLACE_ISATTY = 0
-REPLACE_ISFINITE = 0
-REPLACE_ISINF = 0
-REPLACE_ISNAN = 0
-REPLACE_ITOLD = 0
-REPLACE_LCHOWN = 0
-REPLACE_LDEXPL = 0
-REPLACE_LINK = 0
-REPLACE_LINKAT = 0
-REPLACE_LOCALTIME = 0
-REPLACE_LOCALTIME_R = GNULIB_PORTCHECK
-REPLACE_LOG = 0
-REPLACE_LOG10 = 0
-REPLACE_LOG10F = 0
-REPLACE_LOG10L = 0
-REPLACE_LOG1P = 0
-REPLACE_LOG1PF = 0
-REPLACE_LOG1PL = 0
-REPLACE_LOG2 = 0
-REPLACE_LOG2F = 0
-REPLACE_LOG2L = 0
-REPLACE_LOGB = 0
-REPLACE_LOGBF = 0
-REPLACE_LOGBL = 0
-REPLACE_LOGF = 0
-REPLACE_LOGL = 0
-REPLACE_LSEEK = 0
-REPLACE_LSTAT = 1
-REPLACE_MALLOC = 0
-REPLACE_MBRLEN = 0
-REPLACE_MBRTOWC = 0
-REPLACE_MBSINIT = 0
-REPLACE_MBSNRTOWCS = 0
-REPLACE_MBSRTOWCS = 0
-REPLACE_MBSTATE_T = 0
-REPLACE_MBTOWC = 0
-REPLACE_MEMCHR = 0
-REPLACE_MEMMEM = 0
-REPLACE_MKDIR = 0
-REPLACE_MKFIFO = 0
-REPLACE_MKNOD = 0
-REPLACE_MKSTEMP = 0
-REPLACE_MKTIME = GNULIB_PORTCHECK
-REPLACE_MODF = 0
-REPLACE_MODFF = 0
-REPLACE_MODFL = 0
-REPLACE_NAN = 0
-REPLACE_NANOSLEEP = GNULIB_PORTCHECK
-REPLACE_NULL = 0
-REPLACE_OBSTACK_PRINTF = 0
-REPLACE_OPEN = 0
-REPLACE_OPENAT = 0
-REPLACE_OPENDIR = 0
-REPLACE_PERROR = 0
-REPLACE_POPEN = 0
-REPLACE_PREAD = 0
-REPLACE_PRINTF = 0
-REPLACE_PTSNAME = 0
-REPLACE_PTSNAME_R = 0
-REPLACE_PUTENV = 0
-REPLACE_PWRITE = 0
-REPLACE_QSORT_R = 0
-REPLACE_RANDOM_R = 0
-REPLACE_READ = 0
-REPLACE_READLINK = 0
-REPLACE_READLINKAT = 0
-REPLACE_REALLOC = 0
-REPLACE_REALPATH = 0
-REPLACE_REMAINDER = 0
-REPLACE_REMAINDERF = 0
-REPLACE_REMAINDERL = 0
-REPLACE_REMOVE = 0
-REPLACE_RENAME = 1
-REPLACE_RENAMEAT = 1
-REPLACE_RMDIR = 0
-REPLACE_ROUND = 0
-REPLACE_ROUNDF = 0
-REPLACE_ROUNDL = 0
-REPLACE_SETENV = 0
-REPLACE_SIGNBIT = 0
-REPLACE_SIGNBIT_USING_GCC = 1
-REPLACE_SINF = 0
-REPLACE_SINHF = 0
-REPLACE_SLEEP = 0
-REPLACE_SNPRINTF = 0
-REPLACE_SPRINTF = 0
-REPLACE_SQRTF = 0
-REPLACE_SQRTL = 0
-REPLACE_STAT = 0
-REPLACE_STDIO_READ_FUNCS = 0
-REPLACE_STDIO_WRITE_FUNCS = 0
-REPLACE_STPNCPY = 0
-REPLACE_STRCASESTR = 0
-REPLACE_STRCHRNUL = 0
-REPLACE_STRDUP = 0
-REPLACE_STRERROR = 0
-REPLACE_STRERROR_R = 0
-REPLACE_STRFTIME = GNULIB_PORTCHECK
-REPLACE_STRNCAT = 0
-REPLACE_STRNDUP = 0
-REPLACE_STRNLEN = 0
-REPLACE_STRSIGNAL = 0
-REPLACE_STRSTR = 0
-REPLACE_STRTOD = 0
-REPLACE_STRTOIMAX = 0
-REPLACE_STRTOK_R = 0
-REPLACE_STRTOUMAX = 0
-REPLACE_STRUCT_TIMEVAL = 0
-REPLACE_SYMLINK = 0
-REPLACE_SYMLINKAT = 0
-REPLACE_TANF = 0
-REPLACE_TANHF = 0
-REPLACE_TIMEGM = GNULIB_PORTCHECK
-REPLACE_TMPFILE = 0
-REPLACE_TRUNC = 0
-REPLACE_TRUNCATE = 0
-REPLACE_TRUNCF = 0
-REPLACE_TRUNCL = 0
-REPLACE_TTYNAME_R = 0
-REPLACE_TZSET = GNULIB_PORTCHECK
-REPLACE_UNLINK = 0
-REPLACE_UNLINKAT = 0
-REPLACE_UNSETENV = 0
-REPLACE_USLEEP = 0
-REPLACE_UTIME = 0
-REPLACE_UTIMENSAT = 0
-REPLACE_VASPRINTF = 1
-REPLACE_VDPRINTF = 0
-REPLACE_VFPRINTF = 0
-REPLACE_VPRINTF = 0
-REPLACE_VSNPRINTF = 0
-REPLACE_VSPRINTF = 0
-REPLACE_WCRTOMB = 0
-REPLACE_WCSFTIME = 0
-REPLACE_WCSNRTOMBS = 0
-REPLACE_WCSRTOMBS = 0
-REPLACE_WCSWIDTH = 0
-REPLACE_WCTOB = 0
-REPLACE_WCTOMB = 0
-REPLACE_WCWIDTH = 0
-REPLACE_WRITE = 0
-SET_MAKE = 
-SHELL = /bin/sh
-SIG_ATOMIC_T_SUFFIX = 
-SIZE_T_SUFFIX = 
-STDBOOL_H = 
-STDDEF_H = 
-STDINT_H = stdint.h
-STRIP = 
-SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = 0
-TIME_H_DEFINES_STRUCT_TIMESPEC = 1
-UINT32_MAX_LT_UINTMAX_MAX = 1
-UINT64_MAX_EQ_ULONG_MAX = 1
-UNDEFINE_STRTOK_R = 0
-UNISTD_H_DEFINES_STRUCT_TIMESPEC = 0
-UNISTD_H_HAVE_WINSOCK2_H = 0
-UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = 0
-UTIME_H = 
-VERSION = git
-WCHAR_T_SUFFIX = 
-WINDOWS_64_BIT_OFF_T = 0
-WINDOWS_64_BIT_ST_SIZE = 0
-WINDOWS_STAT_INODES = 0
-WINDOWS_STAT_TIMESPEC = 0
-WINT_T_SUFFIX = 
-abs_builddir = /net/ptah/export/gentoo/working-repos/portage-utils
-abs_srcdir = /net/ptah/export/gentoo/working-repos/portage-utils
-abs_top_builddir = /net/ptah/export/gentoo/working-repos/portage-utils
-abs_top_srcdir = /net/ptah/export/gentoo/working-repos/portage-utils
-ac_ct_CC = gcc
-am__include = include
-am__leading_dot = .
-am__quote = 
-am__tar = $${TAR-tar} chof - "$$tardir"
-am__untar = $${TAR-tar} xf -
-bindir = ${exec_prefix}/bin
-build = x86_64-pc-solaris2.11
-build_alias = 
-build_cpu = x86_64
-build_os = solaris2.11
-build_vendor = pc
-builddir = .
-datadir = ${datarootdir}
-datarootdir = ${prefix}/share
-docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
-dvidir = ${docdir}
-exec_prefix = ${prefix}
-gl_LIBOBJS =  asnprintf.o asprintf.o chdir-long.o error.o euidaccess.o frexpl.o fstat.o fstatat.o futimens.o getcwd-lgpl.o group-member.o localtime-buffer.o lstat.o mempcpy.o memrchr.o openat-proc.o printf-args.o printf-parse.o rename.o renameat.o vasnprintf.o vasprintf.o
-gl_LTLIBOBJS =  asnprintf.lo asprintf.lo chdir-long.lo error.lo euidaccess.lo frexpl.lo fstat.lo fstatat.lo futimens.lo getcwd-lgpl.lo group-member.lo localtime-buffer.lo lstat.lo mempcpy.lo memrchr.lo openat-proc.lo printf-args.lo printf-parse.lo rename.lo renameat.lo vasnprintf.lo vasprintf.lo
-gltests_LIBOBJS = 
-gltests_LTLIBOBJS = 
-gltests_WITNESS = IN_PORTAGE_UTILS_GNULIB_TESTS
-host = x86_64-pc-solaris2.11
-host_alias = 
-host_cpu = x86_64
-host_os = solaris2.11
-host_vendor = pc
-htmldir = ${docdir}
-includedir = ${prefix}/include
-infodir = ${datarootdir}/info
-install_sh = ${SHELL} /net/ptah/export/gentoo/working-repos/portage-utils/autotools/install-sh
-libdir = ${exec_prefix}/lib
-libexecdir = ${exec_prefix}/libexec
-localedir = ${datarootdir}/locale
-localstatedir = ${prefix}/var
-mandir = ${datarootdir}/man
-mkdir_p = $(MKDIR_P)
-oldincludedir = /usr/include
-pdfdir = ${docdir}
-prefix = /usr/local
-program_transform_name = s,x,x,
-psdir = ${docdir}
-sbindir = ${exec_prefix}/sbin
-sharedstatedir = ${prefix}/com
-srcdir = .
-sysconfdir = ${prefix}/etc
-target_alias = 
-top_build_prefix = 
-top_builddir = .
-top_srcdir = .
-ACLOCAL_AMFLAGS = -I autotools/m4
-SUBDIRS = autotools/gnulib
-portagedir = $(sysconfdir)/portage
-postsyncddir = $(portagedir)/repo.postsync.d
-dist_postsyncd_SCRIPTS = repo.postsync/q-reinit
-q_SOURCES = main.c
-
-# @@@ GEN START @@@ #
-q_CPPFLAGS = -I$(top_builddir)/autotools/gnulib \
-	-I$(top_srcdir)/autotools/gnulib -DAPPLET_q -DAPPLET_qatom \
-	-DAPPLET_qcache -DAPPLET_qcheck -DAPPLET_qdepends \
-	-DAPPLET_qfile -DAPPLET_qgrep -DAPPLET_qlist -DAPPLET_qlop \
-	-DAPPLET_qmerge -DAPPLET_qpkg -DAPPLET_qsearch -DAPPLET_qsize \
-	-DAPPLET_qtbz2 -DAPPLET_quse -DAPPLET_qxpak
-q_LDADD = \
-	$(top_builddir)/autotools/gnulib/libgnu.a \
-	-liniparser \
-	$(LIB_CLOCK_GETTIME) \
-	$(LIB_EACCESS)
-
-TMAKE = \
-	$(MAKE) -C $(abs_top_srcdir)/tests \
-		AUTOTOOLS=true \
-		abs_top_builddir="$(abs_top_builddir)" \
-		abs_top_srcdir="$(abs_top_srcdir)"
-
-
-# Start off with base values which we append below
-dist_man_MANS = man/q.1 man/qatom.1 man/qcache.1 man/qcheck.1 \
-	man/qdepends.1 man/qfile.1 man/qgrep.1 man/qlist.1 man/qlop.1 \
-	man/qmerge.1 man/qpkg.1 man/qsearch.1 man/qsize.1 man/qtbz2.1 \
-	man/quse.1 man/qxpak.1
-APPLETS = q qatom qcache qcheck qdepends qfile qgrep qlist qlop qmerge \
-	qpkg qsearch qsize qtbz2 quse qxpak
-EXTRA_DIST = autotools/m4/gnulib-cache.m4 applets.h config.h \
-	include_applets.h libq/atom_compare.c libq/atom_explode.c \
-	libq/basename.c libq/busybox.h libq/colors.c libq/compat.c \
-	libq/copy_file.c libq/hash_fd.c libq/human_readable.c \
-	libq/i18n.h libq/libq.c libq/libq.h libq/md5_sha1_sum.c \
-	libq/prelink.c libq/profile.c libq/rmspace.c libq/safe_io.c \
-	libq/scandirat.c libq/vdb.c libq/vdb_get_next_dir.c \
-	libq/virtuals.c libq/xarray.c libq/xasprintf.c libq/xchdir.c \
-	libq/xmalloc.c libq/xmkdir.c libq/xregex.c libq/xstrdup.c \
-	libq/xsystem.c main.c main.h porting.h q.c qatom.c qcache.c \
-	qcheck.c qdepends.c qfile.c qglsa.c qgrep.c qlist.c qlop.c \
-	qmerge.c qpkg.c qsearch.c qsize.c qtbz2.c quse.c qxpak.c \
-	tests/Makefile tests/atom_compare/.gitignore \
-	tests/atom_compare/Makefile tests/atom_compare/atom-compare.py \
-	tests/atom_compare/static.good \
-	tests/atom_compare/static.q.good \
-	tests/atom_compare/static.q.tests \
-	tests/atom_compare/static.tests tests/atom_explode/.gitignore \
-	tests/atom_explode/Makefile tests/atom_explode/atom-explode.py \
-	tests/atom_explode/basic.good tests/atom_explode/basic.tests \
-	tests/atom_explode/dotest tests/atom_explode/test.c \
-	tests/copy_file/.gitignore tests/copy_file/Makefile \
-	tests/copy_file/dotest tests/copy_file/test.c tests/init.sh \
-	tests/install/.gitignore tests/install/Makefile \
-	tests/install/dotest tests/mkdir/.gitignore \
-	tests/mkdir/Makefile tests/mkdir/dotest tests/mkdir/test.c \
-	tests/profile/Makefile tests/profile/dotest \
-	tests/profile/profile1/etc/parent.conf \
-	tests/profile/profile1/etc/portage/make.conf \
-	tests/profile/profile1/etc/portage/subdir/file.conf \
-	tests/profile/profile1/etc/portage/this.level.conf \
-	tests/qatom/Makefile tests/qatom/dotest tests/qcheck/Makefile \
-	tests/qcheck/dotest tests/qcheck/list01.good \
-	tests/qcheck/list02.good tests/qcheck/list03.good \
-	tests/qcheck/list04.good tests/qcheck/list05.good \
-	tests/qcheck/list06.good tests/qcheck/list07.good \
-	tests/qcheck/list08.good tests/qcheck/list09.good \
-	tests/qcheck/root/a-b/pkg-1.0/CONTENTS \
-	tests/qcheck/root/a-b/pkg-1.0/SLOT \
-	tests/qcheck/root/a-b/pkg-1.0/repository \
-	tests/qcheck/root/bin/bad-md5 tests/qcheck/root/bin/bad-mtime \
-	tests/qcheck/root/bin/bad-mtime-obj \
-	tests/qcheck/root/bin/bad-sha1 tests/qcheck/root/bin/good-md5 \
-	tests/qcheck/root/bin/good-sha1 \
-	tests/qcheck/root/cat/pkg-1/CONTENTS \
-	tests/qcheck/root/cat/pkg-1/SLOT \
-	tests/qcheck/root/cat/pkg-1/repository tests/qdepends/Makefile \
-	tests/qdepends/dotest tests/qdepends/list01.good \
-	tests/qdepends/list02.good tests/qdepends/list03.good \
-	tests/qdepends/list04.good tests/qdepends/list05.good \
-	tests/qdepends/list06.good tests/qdepends/list07.good \
-	tests/qdepends/list08.good \
-	tests/qdepends/root/app-arch/cpio-2.11/CONTENTS \
-	tests/qdepends/root/app-arch/cpio-2.11/SLOT \
-	tests/qdepends/root/app-arch/cpio-2.11/repository \
-	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/DEPEND \
-	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/RDEPEND \
-	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/USE \
-	tests/qfile/Makefile tests/qfile/dotest tests/qlist/Makefile \
-	tests/qlist/dotest tests/qlist/list01.good \
-	tests/qlist/list02.good tests/qlist/list03.good \
-	tests/qlist/list04.good tests/qlist/list05.good \
-	tests/qlist/list06.good tests/qlist/list07.good \
-	tests/qlist/list08.good tests/qlist/list09.good \
-	tests/qlist/list10.good tests/qlist/list11.good \
-	tests/qlist/list12.good tests/qlist/list13.good \
-	tests/qlist/list14.good tests/qlist/list15.good \
-	tests/qlist/list16.good tests/qlist/root/-merge-foo/CONTENTS \
-	tests/qlist/root/a-b/a-0/CONTENTS \
-	tests/qlist/root/a-b/a-0/SLOT \
-	tests/qlist/root/a-b/a-0/repository \
-	tests/qlist/root/a-b/b-0/CONTENTS \
-	tests/qlist/root/a-b/b-0/SLOT \
-	tests/qlist/root/a-b/b-0/repository \
-	tests/qlist/root/app-arch/cpio-2.11/CONTENTS \
-	tests/qlist/root/app-arch/cpio-2.11/SLOT \
-	tests/qlist/root/app-arch/cpio-2.11/repository \
-	tests/qlist/root/cat/pkg-1/CONTENTS \
-	tests/qlist/root/cat/pkg-1/SLOT \
-	tests/qlist/root/cat/pkg-1/repository \
-	tests/qlist/root/cat/sub-2/CONTENTS \
-	tests/qlist/root/cat/sub-2/SLOT \
-	tests/qlist/root/cat/sub-2/repository \
-	tests/qlist/root/sys-fs/mtools-4.0.13/CONTENTS \
-	tests/qlist/root/sys-fs/mtools-4.0.13/SLOT \
-	tests/qlist/root/sys-fs/mtools-4.0.13/repository \
-	tests/qlop/Makefile tests/qlop/dotest tests/qlop/list01.good \
-	tests/qlop/list02.good tests/qlop/list03.good \
-	tests/qlop/list04.good tests/qlop/list05.good \
-	tests/qlop/list06.good tests/qlop/list07.good \
-	tests/qlop/list08.good tests/qlop/sync.log \
-	tests/qlop/test04.good tests/qmerge/Makefile \
-	tests/qmerge/dotest tests/qmerge/packages/Packages \
-	tests/qmerge/packages/sys-devel/qmerge-test-1.3.tbz2 \
-	tests/qtbz2/Makefile tests/qtbz2/dotest tests/quse/Makefile \
-	tests/quse/dotest tests/quse/list01.good \
-	tests/quse/portdir/profiles/arch.list \
-	tests/quse/portdir/profiles/desc/elibc.desc \
-	tests/quse/portdir/profiles/desc/one.desc \
-	tests/quse/portdir/profiles/desc/two.desc \
-	tests/quse/portdir/profiles/use.desc \
-	tests/quse/portdir/profiles/use.local.desc \
-	tests/qxpak/Makefile tests/qxpak/dotest \
-	tests/qxpak/list01.good tests/qxpak/list02.good \
-	tests/reinitialize/Makefile tests/reinitialize/dotest \
-	tests/rmspace/.gitignore tests/rmspace/Makefile \
-	tests/rmspace/dotest tests/rmspace/test.c \
-	tests/source/Makefile tests/source/dotest tests/source/space \
-	tests/subdir.mk tests/tests.h
-all: config.h
-	$(MAKE) $(AM_MAKEFLAGS) all-recursive
-
-.SUFFIXES:
-.SUFFIXES: .c .o .obj
-am--refresh: Makefile
-	@:
-$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
-	@for dep in $?; do \
-	  case '$(am__configure_deps)' in \
-	    *$$dep*) \
-	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
-	      $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
-		&& exit 0; \
-	      exit 1;; \
-	  esac; \
-	done; \
-	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
-	$(am__cd) $(top_srcdir) && \
-	  $(AUTOMAKE) --foreign Makefile
-Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
-	@case '$?' in \
-	  *config.status*) \
-	    echo ' $(SHELL) ./config.status'; \
-	    $(SHELL) ./config.status;; \
-	  *) \
-	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
-	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
-	esac;
-
-$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
-	$(SHELL) ./config.status --recheck
-
-$(top_srcdir)/configure:  $(am__configure_deps)
-	$(am__cd) $(srcdir) && $(AUTOCONF)
-$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
-	$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
-$(am__aclocal_m4_deps):
-
-config.h: stamp-h1
-	@test -f $@ || rm -f stamp-h1
-	@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
-
-stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
-	@rm -f stamp-h1
-	cd $(top_builddir) && $(SHELL) ./config.status config.h
-$(srcdir)/config.h.in:  $(am__configure_deps) 
-	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
-	rm -f stamp-h1
-	touch $@
-
-distclean-hdr:
-	-rm -f config.h stamp-h1
-install-binPROGRAMS: $(bin_PROGRAMS)
-	@$(NORMAL_INSTALL)
-	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
-	if test -n "$$list"; then \
-	  echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
-	  $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
-	fi; \
-	for p in $$list; do echo "$$p $$p"; done | \
-	sed 's/$(EXEEXT)$$//' | \
-	while read p p1; do if test -f $$p \
-	  ; then echo "$$p"; echo "$$p"; else :; fi; \
-	done | \
-	sed -e 'p;s,.*/,,;n;h' \
-	    -e 's|.*|.|' \
-	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
-	sed 'N;N;N;s,\n, ,g' | \
-	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
-	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
-	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
-	    else { print "f", $$3 "/" $$4, $$1; } } \
-	  END { for (d in files) print "f", d, files[d] }' | \
-	while read type dir files; do \
-	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
-	    test -z "$$files" || { \
-	      echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
-	      $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
-	    } \
-	; done
-
-uninstall-binPROGRAMS:
-	@$(NORMAL_UNINSTALL)
-	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
-	files=`for p in $$list; do echo "$$p"; done | \
-	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
-	      -e 's/$$/$(EXEEXT)/' \
-	`; \
-	test -n "$$list" || exit 0; \
-	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
-	cd "$(DESTDIR)$(bindir)" && rm -f $$files
-
-clean-binPROGRAMS:
-	-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
-
-q$(EXEEXT): $(q_OBJECTS) $(q_DEPENDENCIES) $(EXTRA_q_DEPENDENCIES) 
-	@rm -f q$(EXEEXT)
-	$(AM_V_CCLD)$(LINK) $(q_OBJECTS) $(q_LDADD) $(LIBS)
-install-dist_postsyncdSCRIPTS: $(dist_postsyncd_SCRIPTS)
-	@$(NORMAL_INSTALL)
-	@list='$(dist_postsyncd_SCRIPTS)'; test -n "$(postsyncddir)" || list=; \
-	if test -n "$$list"; then \
-	  echo " $(MKDIR_P) '$(DESTDIR)$(postsyncddir)'"; \
-	  $(MKDIR_P) "$(DESTDIR)$(postsyncddir)" || exit 1; \
-	fi; \
-	for p in $$list; do \
-	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
-	  if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
-	done | \
-	sed -e 'p;s,.*/,,;n' \
-	    -e 'h;s|.*|.|' \
-	    -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
-	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
-	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
-	    if ($$2 == $$4) { files[d] = files[d] " " $$1; \
-	      if (++n[d] == $(am__install_max)) { \
-		print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
-	    else { print "f", d "/" $$4, $$1 } } \
-	  END { for (d in files) print "f", d, files[d] }' | \
-	while read type dir files; do \
-	     if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
-	     test -z "$$files" || { \
-	       echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(postsyncddir)$$dir'"; \
-	       $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(postsyncddir)$$dir" || exit $$?; \
-	     } \
-	; done
-
-uninstall-dist_postsyncdSCRIPTS:
-	@$(NORMAL_UNINSTALL)
-	@list='$(dist_postsyncd_SCRIPTS)'; test -n "$(postsyncddir)" || exit 0; \
-	files=`for p in $$list; do echo "$$p"; done | \
-	       sed -e 's,.*/,,;$(transform)'`; \
-	dir='$(DESTDIR)$(postsyncddir)'; $(am__uninstall_files_from_dir)
-
-mostlyclean-compile:
-	-rm -f *.$(OBJEXT)
-
-distclean-compile:
-	-rm -f *.tab.c
-
-include ./$(DEPDIR)/q-main.Po
-
-.c.o:
-	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
-	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-#	$(AM_V_CC)source='$<' object='$@' libtool=no \
-#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
-#	$(AM_V_CC_no)$(COMPILE) -c -o $@ $<
-
-.c.obj:
-	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
-	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
-#	$(AM_V_CC)source='$<' object='$@' libtool=no \
-#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
-#	$(AM_V_CC_no)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
-
-q-main.o: main.c
-	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(q_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT q-main.o -MD -MP -MF $(DEPDIR)/q-main.Tpo -c -o q-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
-	$(AM_V_at)$(am__mv) $(DEPDIR)/q-main.Tpo $(DEPDIR)/q-main.Po
-#	$(AM_V_CC)source='main.c' object='q-main.o' libtool=no \
-#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
-#	$(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(q_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o q-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
-
-q-main.obj: main.c
-	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(q_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT q-main.obj -MD -MP -MF $(DEPDIR)/q-main.Tpo -c -o q-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
-	$(AM_V_at)$(am__mv) $(DEPDIR)/q-main.Tpo $(DEPDIR)/q-main.Po
-#	$(AM_V_CC)source='main.c' object='q-main.obj' libtool=no \
-#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
-#	$(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(q_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o q-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
-install-man1: $(dist_man_MANS)
-	@$(NORMAL_INSTALL)
-	@list1=''; \
-	list2='$(dist_man_MANS)'; \
-	test -n "$(man1dir)" \
-	  && test -n "`echo $$list1$$list2`" \
-	  || exit 0; \
-	echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \
-	$(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \
-	{ for i in $$list1; do echo "$$i"; done;  \
-	if test -n "$$list2"; then \
-	  for i in $$list2; do echo "$$i"; done \
-	    | sed -n '/\.1[a-z]*$$/p'; \
-	fi; \
-	} | while read p; do \
-	  if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
-	  echo "$$d$$p"; echo "$$p"; \
-	done | \
-	sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
-	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
-	sed 'N;N;s,\n, ,g' | { \
-	list=; while read file base inst; do \
-	  if test "$$base" = "$$inst"; then list="$$list $$file"; else \
-	    echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
-	    $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
-	  fi; \
-	done; \
-	for i in $$list; do echo "$$i"; done | $(am__base_list) | \
-	while read files; do \
-	  test -z "$$files" || { \
-	    echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
-	    $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
-	done; }
-
-uninstall-man1:
-	@$(NORMAL_UNINSTALL)
-	@list=''; test -n "$(man1dir)" || exit 0; \
-	files=`{ for i in $$list; do echo "$$i"; done; \
-	l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
-	  sed -n '/\.1[a-z]*$$/p'; \
-	} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
-	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
-	dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir)
-
-# This directory's subdirectories are mostly independent; you can cd
-# into them and run 'make' without going through this Makefile.
-# To change the values of 'make' variables: instead of editing Makefiles,
-# (1) if the variable is set in 'config.status', edit 'config.status'
-#     (which will cause the Makefiles to be regenerated when you run 'make');
-# (2) otherwise, pass the desired values on the 'make' command line.
-$(am__recursive_targets):
-	@fail=; \
-	if $(am__make_keepgoing); then \
-	  failcom='fail=yes'; \
-	else \
-	  failcom='exit 1'; \
-	fi; \
-	dot_seen=no; \
-	target=`echo $@ | sed s/-recursive//`; \
-	case "$@" in \
-	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
-	  *) list='$(SUBDIRS)' ;; \
-	esac; \
-	for subdir in $$list; do \
-	  echo "Making $$target in $$subdir"; \
-	  if test "$$subdir" = "."; then \
-	    dot_seen=yes; \
-	    local_target="$$target-am"; \
-	  else \
-	    local_target="$$target"; \
-	  fi; \
-	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
-	  || eval $$failcom; \
-	done; \
-	if test "$$dot_seen" = "no"; then \
-	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
-	fi; test -z "$$fail"
-
-ID: $(am__tagged_files)
-	$(am__define_uniq_tagged_files); mkid -fID $$unique
-tags: tags-recursive
-TAGS: tags
-
-tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
-	set x; \
-	here=`pwd`; \
-	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
-	  include_option=--etags-include; \
-	  empty_fix=.; \
-	else \
-	  include_option=--include; \
-	  empty_fix=; \
-	fi; \
-	list='$(SUBDIRS)'; for subdir in $$list; do \
-	  if test "$$subdir" = .; then :; else \
-	    test ! -f $$subdir/TAGS || \
-	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
-	  fi; \
-	done; \
-	$(am__define_uniq_tagged_files); \
-	shift; \
-	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
-	  test -n "$$unique" || unique=$$empty_fix; \
-	  if test $$# -gt 0; then \
-	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	      "$$@" $$unique; \
-	  else \
-	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
-	      $$unique; \
-	  fi; \
-	fi
-ctags: ctags-recursive
-
-CTAGS: ctags
-ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
-	$(am__define_uniq_tagged_files); \
-	test -z "$(CTAGS_ARGS)$$unique" \
-	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
-	     $$unique
-
-GTAGS:
-	here=`$(am__cd) $(top_builddir) && pwd` \
-	  && $(am__cd) $(top_srcdir) \
-	  && gtags -i $(GTAGS_ARGS) "$$here"
-cscope: cscope.files
-	test ! -s cscope.files \
-	  || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
-clean-cscope:
-	-rm -f cscope.files
-cscope.files: clean-cscope cscopelist
-cscopelist: cscopelist-recursive
-
-cscopelist-am: $(am__tagged_files)
-	list='$(am__tagged_files)'; \
-	case "$(srcdir)" in \
-	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
-	  *) sdir=$(subdir)/$(srcdir) ;; \
-	esac; \
-	for i in $$list; do \
-	  if test -f "$$i"; then \
-	    echo "$(subdir)/$$i"; \
-	  else \
-	    echo "$$sdir/$$i"; \
-	  fi; \
-	done >> $(top_builddir)/cscope.files
-
-distclean-tags:
-	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
-	-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
-
-distdir: $(DISTFILES)
-	$(am__remove_distdir)
-	test -d "$(distdir)" || mkdir "$(distdir)"
-	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
-	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
-	list='$(DISTFILES)'; \
-	  dist_files=`for file in $$list; do echo $$file; done | \
-	  sed -e "s|^$$srcdirstrip/||;t" \
-	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
-	case $$dist_files in \
-	  */*) $(MKDIR_P) `echo "$$dist_files" | \
-			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
-			   sort -u` ;; \
-	esac; \
-	for file in $$dist_files; do \
-	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
-	  if test -d $$d/$$file; then \
-	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
-	    if test -d "$(distdir)/$$file"; then \
-	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
-	    fi; \
-	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
-	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
-	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
-	    fi; \
-	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
-	  else \
-	    test -f "$(distdir)/$$file" \
-	    || cp -p $$d/$$file "$(distdir)/$$file" \
-	    || exit 1; \
-	  fi; \
-	done
-	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
-	  if test "$$subdir" = .; then :; else \
-	    $(am__make_dryrun) \
-	      || test -d "$(distdir)/$$subdir" \
-	      || $(MKDIR_P) "$(distdir)/$$subdir" \
-	      || exit 1; \
-	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
-	    $(am__relativize); \
-	    new_distdir=$$reldir; \
-	    dir1=$$subdir; dir2="$(top_distdir)"; \
-	    $(am__relativize); \
-	    new_top_distdir=$$reldir; \
-	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
-	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
-	    ($(am__cd) $$subdir && \
-	      $(MAKE) $(AM_MAKEFLAGS) \
-	        top_distdir="$$new_top_distdir" \
-	        distdir="$$new_distdir" \
-		am__remove_distdir=: \
-		am__skip_length_check=: \
-		am__skip_mode_fix=: \
-	        distdir) \
-	      || exit 1; \
-	  fi; \
-	done
-	-test -n "$(am__skip_mode_fix)" \
-	|| find "$(distdir)" -type d ! -perm -755 \
-		-exec chmod u+rwx,go+rx {} \; -o \
-	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
-	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
-	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
-	|| chmod -R a+r "$(distdir)"
-dist-gzip: distdir
-	tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
-	$(am__post_remove_distdir)
-
-dist-bzip2: distdir
-	tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
-	$(am__post_remove_distdir)
-
-dist-lzip: distdir
-	tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
-	$(am__post_remove_distdir)
-dist-xz: distdir
-	tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
-	$(am__post_remove_distdir)
-
-dist-tarZ: distdir
-	@echo WARNING: "Support for distribution archives compressed with" \
-		       "legacy program 'compress' is deprecated." >&2
-	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
-	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
-	$(am__post_remove_distdir)
-
-dist-shar: distdir
-	@echo WARNING: "Support for shar distribution archives is" \
-	               "deprecated." >&2
-	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
-	shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
-	$(am__post_remove_distdir)
-
-dist-zip: distdir
-	-rm -f $(distdir).zip
-	zip -rq $(distdir).zip $(distdir)
-	$(am__post_remove_distdir)
-
-dist dist-all:
-	$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
-	$(am__post_remove_distdir)
-
-# This target untars the dist file and tries a VPATH configuration.  Then
-# it guarantees that the distribution is self-contained by making another
-# tarfile.
+# Copyright 2005-2018 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+####################################################################
+
+check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
+	then echo "$(1)"; else echo "$(2)"; fi)
+istrue = $(if $(filter 1 yes true on,$(strip $1)),1,0)
+
+####################################################
+WFLAGS    := -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
+             -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
+             -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
+             -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
+             $(call check_gcc, -Wsequence-point) \
+             $(call check_gcc, -Wextra) \
+             $(call check_gcc, -Wno-sign-compare) \
+             $(call check_gcc, -Wold-style-definition)
+
+CFLAGS    ?= -O2 -g -pipe
+CFLAGS    += -std=gnu99
+CPPFLAGS  ?=
+CPPFLAGS  += -DENABLE_NLS=$(call istrue,$(NLS))
+DBG_CFLAGS = -O0 -DEBUG -g3 -ggdb -fno-pie $(call check_gcc, -fsanitize=address -fsanitize=leak -fsanitize=undefined)
+#CFLAGS   += -Os -DOPTIMIZE_FOR_SIZE=2 -falign-functions=2 -falign-jumps=2 -falign-labels=2 -falign-loops=2
+LDFLAGS_static_1 = -static
+LDFLAGS   += $(LDFLAGS_static_$(call istrue,$(STATIC)))
+LIBADD    += $(shell echo | $(CC) -dM -E - | grep -q ' __FreeBSD__' && echo '-lkvm')
+LIBADD    += -liniparser
+DESTDIR   :=
+PREFIX    := $(DESTDIR)/usr
+ETCDIR    := $(DESTDIR)/etc
+STRIP     := strip
+MKDIR     := mkdir -p
+CP        := cp
+INSTALL_EXE := install -m755
+
+ifndef V
+Q = @
+else
+Q =
+endif
+export Q
+ifdef PV
+CPPFLAGS  += -DVERSION=\"$(PV)\"
+else
+PV        := git
+VCSID     := $(shell git describe --tags HEAD)
+CPPFLAGS  += -DVCSID='"$(VCSID)"'
+endif
+ifndef PF
+PF        := portage-utils-$(PV)
+endif
+DOCS      := TODO.md README.md qsync
+
+#ifdef PYTHON
+#PYFLAGS   ?= $(shell python-config) -DWANT_PYTHON -ldl -pthread -lutil /usr/lib/libpython2.4.so
+##PYFLAGS  += -lpython2.4
+#endif
+
+#####################################################
+APPLETS   := $(shell ./applets.sh)
+SRC       := $(APPLETS:%=%.c) main.c
+APP_FLAGS := $(foreach a,$(APPLETS),-DAPPLET_$a)
+CPPFLAGS  += $(APP_FLAGS)
+
+all: q
+	@true
+
+debug: clean
+	$(MAKE) CFLAGS="$(CFLAGS) $(DBG_CFLAGS)" symlinks
+	@-scanelf -o /dev/null -BXxz permsx q
+
+q: $(SRC) libq/*.c *.h libq/*.h
+ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS))
+	@printf ': %s ' $(APPLETS)
+	@echo ':'
+ifndef V
+	@echo $(CC) $(CFLAGS) $(PYFLAGS) $(LDFLAGS) main.c -o q $(LIBADD)
+endif
+endif
+	$(Q)$(CC) $(WFLAGS) $(PYFLAGS) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) main.c -o q $(LIBADD)
+
+.depend: $(SRC) applets.h
+	sed -n '/^DECLARE_APPLET/s:.*(\(.*\)).*:#include "\1.c":p' applets.h > include_applets.h
+	@#$(CC) $(CFLAGS) -MM $(SRC) > .depend
+	$(CC) $(CPPFLAGS) $(CFLAGS) -MM main.c > .depend
+
+check: symlinks
+	$(MAKE) -C tests $@
+
+dist:
+	./make-tarball.sh $(PV)
 distcheck: dist
-	case '$(DIST_ARCHIVES)' in \
-	*.tar.gz*) \
-	  eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
-	*.tar.bz2*) \
-	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
-	*.tar.lz*) \
-	  lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
-	*.tar.xz*) \
-	  xz -dc $(distdir).tar.xz | $(am__untar) ;;\
-	*.tar.Z*) \
-	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
-	*.shar.gz*) \
-	  eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
-	*.zip*) \
-	  unzip $(distdir).zip ;;\
-	esac
-	chmod -R a-w $(distdir)
-	chmod u+w $(distdir)
-	mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
-	chmod a-w $(distdir)
-	test -d $(distdir)/_build || exit 0; \
-	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
-	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
-	  && am__cwd=`pwd` \
-	  && $(am__cd) $(distdir)/_build/sub \
-	  && ../../configure \
-	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
-	    $(DISTCHECK_CONFIGURE_FLAGS) \
-	    --srcdir=../.. --prefix="$$dc_install_base" \
-	  && $(MAKE) $(AM_MAKEFLAGS) \
-	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
-	  && $(MAKE) $(AM_MAKEFLAGS) check \
-	  && $(MAKE) $(AM_MAKEFLAGS) install \
-	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
-	  && $(MAKE) $(AM_MAKEFLAGS) uninstall \
-	  && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
-	        distuninstallcheck \
-	  && chmod -R a-w "$$dc_install_base" \
-	  && ({ \
-	       (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
-	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
-	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
-	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
-	            distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
-	      } || { rm -rf "$$dc_destdir"; exit 1; }) \
-	  && rm -rf "$$dc_destdir" \
-	  && $(MAKE) $(AM_MAKEFLAGS) dist \
-	  && rm -rf $(DIST_ARCHIVES) \
-	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
-	  && cd "$$am__cwd" \
-	  || exit 1
-	$(am__post_remove_distdir)
-	@(echo "$(distdir) archives ready for distribution: "; \
-	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
-	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
-distuninstallcheck:
-	@test -n '$(distuninstallcheck_dir)' || { \
-	  echo 'ERROR: trying to run $@ with an empty' \
-	       '$$(distuninstallcheck_dir)' >&2; \
-	  exit 1; \
-	}; \
-	$(am__cd) '$(distuninstallcheck_dir)' || { \
-	  echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
-	  exit 1; \
-	}; \
-	test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
-	   || { echo "ERROR: files left after uninstall:" ; \
-	        if test -n "$(DESTDIR)"; then \
-	          echo "  (check DESTDIR support)"; \
-	        fi ; \
-	        $(distuninstallcheck_listfiles) ; \
-	        exit 1; } >&2
-distcleancheck: distclean
-	@if test '$(srcdir)' = . ; then \
-	  echo "ERROR: distcleancheck can only run from a VPATH build" ; \
-	  exit 1 ; \
-	fi
-	@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
-	  || { echo "ERROR: files left in build directory after distclean:" ; \
-	       $(distcleancheck_listfiles) ; \
-	       exit 1; } >&2
-check-am: all-am
-check: check-recursive
-all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(MANS) config.h
-installdirs: installdirs-recursive
-installdirs-am:
-	for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(postsyncddir)" "$(DESTDIR)$(man1dir)"; do \
-	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
-	done
-install: install-recursive
-install-exec: install-exec-recursive
-install-data: install-data-recursive
-uninstall: uninstall-recursive
-
-install-am: all-am
-	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
-
-installcheck: installcheck-recursive
-install-strip:
-	if test -z '$(STRIP)'; then \
-	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	      install; \
-	else \
-	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
-	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
-	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
-	fi
-mostlyclean-generic:
-
-clean-generic:
-
-distclean-generic:
-	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
-	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
-
-maintainer-clean-generic:
-	@echo "This command is intended for maintainers to use"
-	@echo "it deletes files that may require special tools to rebuild."
-clean: clean-recursive
-
-clean-am: clean-binPROGRAMS clean-generic clean-local mostlyclean-am
-
-distclean: distclean-recursive
-	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-	-rm -rf ./$(DEPDIR)
-	-rm -f Makefile
-distclean-am: clean-am distclean-compile distclean-generic \
-	distclean-hdr distclean-tags
-
-dvi: dvi-recursive
-
-dvi-am:
-
-html: html-recursive
-
-html-am:
-
-info: info-recursive
-
-info-am:
-
-install-data-am: install-dist_postsyncdSCRIPTS install-man
-
-install-dvi: install-dvi-recursive
-
-install-dvi-am:
-
-install-exec-am: install-binPROGRAMS
-	@$(NORMAL_INSTALL)
-	$(MAKE) $(AM_MAKEFLAGS) install-exec-hook
-install-html: install-html-recursive
-
-install-html-am:
-
-install-info: install-info-recursive
-
-install-info-am:
-
-install-man: install-man1
-
-install-pdf: install-pdf-recursive
-
-install-pdf-am:
-
-install-ps: install-ps-recursive
-
-install-ps-am:
-
-installcheck-am:
-
-maintainer-clean: maintainer-clean-recursive
-	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
-	-rm -rf $(top_srcdir)/autom4te.cache
-	-rm -rf ./$(DEPDIR)
-	-rm -f Makefile
-maintainer-clean-am: distclean-am maintainer-clean-generic
-
-mostlyclean: mostlyclean-recursive
-
-mostlyclean-am: mostlyclean-compile mostlyclean-generic
-
-pdf: pdf-recursive
-
-pdf-am:
-
-ps: ps-recursive
-
-ps-am:
-
-uninstall-am: uninstall-binPROGRAMS uninstall-dist_postsyncdSCRIPTS \
-	uninstall-man
-
-uninstall-man: uninstall-man1
-
-.MAKE: $(am__recursive_targets) all install-am install-exec-am \
-	install-strip
-
-.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
-	am--refresh check check-am clean clean-binPROGRAMS \
-	clean-cscope clean-generic clean-local cscope cscopelist-am \
-	ctags ctags-am dist dist-all dist-bzip2 dist-gzip dist-lzip \
-	dist-shar dist-tarZ dist-xz dist-zip distcheck distclean \
-	distclean-compile distclean-generic distclean-hdr \
-	distclean-tags distcleancheck distdir distuninstallcheck dvi \
-	dvi-am html html-am info info-am install install-am \
-	install-binPROGRAMS install-data install-data-am \
-	install-dist_postsyncdSCRIPTS install-dvi install-dvi-am \
-	install-exec install-exec-am install-exec-hook install-html \
-	install-html-am install-info install-info-am install-man \
-	install-man1 install-pdf install-pdf-am install-ps \
-	install-ps-am install-strip installcheck installcheck-am \
-	installdirs installdirs-am maintainer-clean \
-	maintainer-clean-generic mostlyclean mostlyclean-compile \
-	mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
-	uninstall-am uninstall-binPROGRAMS \
-	uninstall-dist_postsyncdSCRIPTS uninstall-man uninstall-man1
-
-.PRECIOUS: Makefile
-
-
-install-exec-hook:
-	cd $(DESTDIR)$(bindir); \
-	for applet in $(APPLETS) ; do \
-		[ ! -e "$$applet" ] && ln -s q $${applet} ; \
+	rm -rf portage-utils-$(PV)
+	tar xf portage-utils-$(PV).tar.xz
+	$(MAKE) -C portage-utils-$(PV)
+	$(MAKE) -C portage-utils-$(PV) check
+	rm -rf portage-utils-$(PV)
+
+clean:
+	-rm -f q $(APPLETS)
+	$(MAKE) -C tests clean
+distclean: clean testclean
+	-rm -f *~ core .#*
+	-rm -f `find . -type l`
+
+testclean:
+	cd tests && $(MAKE) clean
+
+install: all
+	$(MKDIR) $(PREFIX)/bin/
+	$(INSTALL_EXE) q $(PREFIX)/bin/
+
+	set -e ; \
+	for applet in $(filter-out q,$(APPLETS)) ; do \
+		ln -sf q $(PREFIX)/bin/$${applet} ; \
 	done
-check-hook:
-	$(TMAKE) check
-clean-local:
-	$(TMAKE) clean
-	-rmdir tests/*/ tests/
-	rm -f $(APPLETS)
-check: check-hook
-# @@@ GEN START @@@ #
 
-# Tell versions [3.59,3.63) of GNU make to not export all variables.
-# Otherwise a system limit (for SysV at least) may be exceeded.
-.NOEXPORT:
+	$(MKDIR) $(ETCDIR)/portage/repo.postsync.d
+	$(INSTALL_EXE) repo.postsync/* $(ETCDIR)/portage/repo.postsync.d/
+
+ifneq ($(wildcard man/*.1),)
+	$(MKDIR) $(PREFIX)/share/man/man1/
+	cp $(wildcard man/*.1) $(PREFIX)/share/man/man1/
+endif
+
+	$(MKDIR) $(PREFIX)/share/doc/$(PF)
+	cp $(DOCS) $(PREFIX)/share/doc/$(PF)/
+
+man: q
+	./man/mkman.py
+
+symlinks: q
+	./q --install
+
+-include .depend
+
+.PHONY: all check clean debug dist distclean install man symlinks testclean
+
+#
+# All logic related to autotools is below here
+#
+GEN_MARK_START = \# @@@ GEN START @@@ \#
+GEN_MARK_END   = \# @@@ GEN START @@@ \#
+EXTRA_DIST = \
+	$(SRC) \
+	qglsa.c \
+	$(wildcard libq/*.c *.h libq/*.h) \
+	$(shell find tests -type f)
+MAKE_MULTI_LINES = $(patsubst %,\\\\\n\t%,$(sort $(1)))
+# 2nd level of indirection here is so the $(find) doesn't pick up
+# files in EXTRA_DIST that get cleaned up ...
+autotools-update: clean
+	$(MAKE) _autotools-update
+_autotools-update:
+	sed -i '/^$(GEN_MARK_START)$$/,/^$(GEN_MARK_END)$$/d' Makefile.am
+	printf '%s\nq_CPPFLAGS += %b\ndist_man_MANS += %b\nAPPLETS += %b\nEXTRA_DIST += %b\n%s\n' \
+		"$(GEN_MARK_START)" \
+		"$(call MAKE_MULTI_LINES,$(APP_FLAGS))" \
+		"$(call MAKE_MULTI_LINES,$(wildcard man/*.1))" \
+		"$(call MAKE_MULTI_LINES,$(APPLETS))" \
+		"$(call MAKE_MULTI_LINES,$(EXTRA_DIST))" \
+		"$(GEN_MARK_END)" \
+		>> Makefile.am
+autotools: autotools-update
+	./autogen.sh --from=make
+
+.PHONY: autotools autotools-update _autotools-update


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-04-15 15:38 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-04-15 15:38 UTC (permalink / raw
  To: gentoo-commits

commit:     054b993a9433a45c00086fb2841a8150d85eb437
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Apr 15 15:38:20 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Apr 15 15:38:20 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=054b993a

qlop: fix offsets for today and yesterday dates

 Makefile | 2466 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
 qlop.c   |    4 +-
 2 files changed, 2303 insertions(+), 167 deletions(-)

diff --git a/Makefile b/Makefile
index 2afb67d..bcde52c 100644
--- a/Makefile
+++ b/Makefile
@@ -1,168 +1,2304 @@
-# Copyright 2005-2018 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-####################################################################
-
-check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
-	then echo "$(1)"; else echo "$(2)"; fi)
-istrue = $(if $(filter 1 yes true on,$(strip $1)),1,0)
-
-####################################################
-WFLAGS    := -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
-             -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings \
-             -Wbad-function-cast -Wnested-externs -Wcomment -Winline \
-             -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
-             $(call check_gcc, -Wsequence-point) \
-             $(call check_gcc, -Wextra) \
-             $(call check_gcc, -Wno-sign-compare) \
-             $(call check_gcc, -Wold-style-definition)
-
-CFLAGS    ?= -O2 -g -pipe
-CFLAGS    += -std=gnu99
-CPPFLAGS  ?=
-CPPFLAGS  += -DENABLE_NLS=$(call istrue,$(NLS))
-DBG_CFLAGS = -O0 -DEBUG -g3 -ggdb -fno-pie $(call check_gcc, -fsanitize=address -fsanitize=leak -fsanitize=undefined)
-#CFLAGS   += -Os -DOPTIMIZE_FOR_SIZE=2 -falign-functions=2 -falign-jumps=2 -falign-labels=2 -falign-loops=2
-LDFLAGS_static_1 = -static
-LDFLAGS   += $(LDFLAGS_static_$(call istrue,$(STATIC)))
-LIBADD    += $(shell echo | $(CC) -dM -E - | grep -q ' __FreeBSD__' && echo '-lkvm')
-LIBADD    += -liniparser
-DESTDIR   :=
-PREFIX    := $(DESTDIR)/usr
-ETCDIR    := $(DESTDIR)/etc
-STRIP     := strip
-MKDIR     := mkdir -p
-CP        := cp
-INSTALL_EXE := install -m755
-
-ifndef V
-Q = @
-else
-Q =
-endif
-export Q
-ifdef PV
-CPPFLAGS  += -DVERSION=\"$(PV)\"
-else
-PV        := git
-VCSID     := $(shell git describe --tags HEAD)
-CPPFLAGS  += -DVCSID='"$(VCSID)"'
-endif
-ifndef PF
-PF        := portage-utils-$(PV)
-endif
-DOCS      := TODO.md README.md qsync
-
-#ifdef PYTHON
-#PYFLAGS   ?= $(shell python-config) -DWANT_PYTHON -ldl -pthread -lutil /usr/lib/libpython2.4.so
-##PYFLAGS  += -lpython2.4
-#endif
-
-#####################################################
-APPLETS   := $(shell ./applets.sh)
-SRC       := $(APPLETS:%=%.c) main.c
-APP_FLAGS := $(foreach a,$(APPLETS),-DAPPLET_$a)
-CPPFLAGS  += $(APP_FLAGS)
-
-all: q
-	@true
-
-debug: clean
-	$(MAKE) CFLAGS="$(CFLAGS) $(DBG_CFLAGS)" symlinks
-	@-scanelf -o /dev/null -BXxz permsx q
-
-q: $(SRC) libq/*.c *.h libq/*.h
-ifeq ($(subst s,,$(MAKEFLAGS)),$(MAKEFLAGS))
-	@printf ': %s ' $(APPLETS)
-	@echo ':'
-ifndef V
-	@echo $(CC) $(CFLAGS) $(PYFLAGS) $(LDFLAGS) main.c -o q $(LIBADD)
-endif
-endif
-	$(Q)$(CC) $(WFLAGS) $(PYFLAGS) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) main.c -o q $(LIBADD)
-
-.depend: $(SRC) applets.h
-	sed -n '/^DECLARE_APPLET/s:.*(\(.*\)).*:#include "\1.c":p' applets.h > include_applets.h
-	@#$(CC) $(CFLAGS) -MM $(SRC) > .depend
-	$(CC) $(CPPFLAGS) $(CFLAGS) -MM main.c > .depend
-
-check: symlinks
-	$(MAKE) -C tests $@
-
-dist:
-	./make-tarball.sh $(PV)
+# Makefile.in generated by automake 1.15.1 from Makefile.am.
+# Makefile.  Generated from Makefile.in by configure.
+
+# Copyright (C) 1994-2017 Free Software Foundation, Inc.
+
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+
+
+
+
+am__is_gnu_make = { \
+  if test -z '$(MAKELEVEL)'; then \
+    false; \
+  elif test -n '$(MAKE_HOST)'; then \
+    true; \
+  elif test -n '$(MAKE_VERSION)' && test -n '$(CURDIR)'; then \
+    true; \
+  else \
+    false; \
+  fi; \
+}
+am__make_running_with_option = \
+  case $${target_option-} in \
+      ?) ;; \
+      *) echo "am__make_running_with_option: internal error: invalid" \
+              "target option '$${target_option-}' specified" >&2; \
+         exit 1;; \
+  esac; \
+  has_opt=no; \
+  sane_makeflags=$$MAKEFLAGS; \
+  if $(am__is_gnu_make); then \
+    sane_makeflags=$$MFLAGS; \
+  else \
+    case $$MAKEFLAGS in \
+      *\\[\ \	]*) \
+        bs=\\; \
+        sane_makeflags=`printf '%s\n' "$$MAKEFLAGS" \
+          | sed "s/$$bs$$bs[$$bs $$bs	]*//g"`;; \
+    esac; \
+  fi; \
+  skip_next=no; \
+  strip_trailopt () \
+  { \
+    flg=`printf '%s\n' "$$flg" | sed "s/$$1.*$$//"`; \
+  }; \
+  for flg in $$sane_makeflags; do \
+    test $$skip_next = yes && { skip_next=no; continue; }; \
+    case $$flg in \
+      *=*|--*) continue;; \
+        -*I) strip_trailopt 'I'; skip_next=yes;; \
+      -*I?*) strip_trailopt 'I';; \
+        -*O) strip_trailopt 'O'; skip_next=yes;; \
+      -*O?*) strip_trailopt 'O';; \
+        -*l) strip_trailopt 'l'; skip_next=yes;; \
+      -*l?*) strip_trailopt 'l';; \
+      -[dEDm]) skip_next=yes;; \
+      -[JT]) skip_next=yes;; \
+    esac; \
+    case $$flg in \
+      *$$target_option*) has_opt=yes; break;; \
+    esac; \
+  done; \
+  test $$has_opt = yes
+am__make_dryrun = (target_option=n; $(am__make_running_with_option))
+am__make_keepgoing = (target_option=k; $(am__make_running_with_option))
+pkgdatadir = $(datadir)/portage-utils
+pkgincludedir = $(includedir)/portage-utils
+pkglibdir = $(libdir)/portage-utils
+pkglibexecdir = $(libexecdir)/portage-utils
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = x86_64-pc-solaris2.11
+host_triplet = x86_64-pc-solaris2.11
+bin_PROGRAMS = q$(EXEEXT)
+subdir = .
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/autotools/m4/00gnulib.m4 \
+	$(top_srcdir)/autotools/m4/absolute-header.m4 \
+	$(top_srcdir)/autotools/m4/alloca.m4 \
+	$(top_srcdir)/autotools/m4/canonicalize.m4 \
+	$(top_srcdir)/autotools/m4/chdir-long.m4 \
+	$(top_srcdir)/autotools/m4/clock_time.m4 \
+	$(top_srcdir)/autotools/m4/close.m4 \
+	$(top_srcdir)/autotools/m4/closedir.m4 \
+	$(top_srcdir)/autotools/m4/dirent_h.m4 \
+	$(top_srcdir)/autotools/m4/dirfd.m4 \
+	$(top_srcdir)/autotools/m4/dirname.m4 \
+	$(top_srcdir)/autotools/m4/double-slash-root.m4 \
+	$(top_srcdir)/autotools/m4/dup.m4 \
+	$(top_srcdir)/autotools/m4/dup2.m4 \
+	$(top_srcdir)/autotools/m4/eealloc.m4 \
+	$(top_srcdir)/autotools/m4/errno_h.m4 \
+	$(top_srcdir)/autotools/m4/error.m4 \
+	$(top_srcdir)/autotools/m4/euidaccess.m4 \
+	$(top_srcdir)/autotools/m4/exponentd.m4 \
+	$(top_srcdir)/autotools/m4/exponentf.m4 \
+	$(top_srcdir)/autotools/m4/exponentl.m4 \
+	$(top_srcdir)/autotools/m4/extensions.m4 \
+	$(top_srcdir)/autotools/m4/extern-inline.m4 \
+	$(top_srcdir)/autotools/m4/faccessat.m4 \
+	$(top_srcdir)/autotools/m4/fchdir.m4 \
+	$(top_srcdir)/autotools/m4/fcntl-o.m4 \
+	$(top_srcdir)/autotools/m4/fcntl.m4 \
+	$(top_srcdir)/autotools/m4/fcntl_h.m4 \
+	$(top_srcdir)/autotools/m4/fdopendir.m4 \
+	$(top_srcdir)/autotools/m4/filenamecat.m4 \
+	$(top_srcdir)/autotools/m4/float_h.m4 \
+	$(top_srcdir)/autotools/m4/fpieee.m4 \
+	$(top_srcdir)/autotools/m4/frexp.m4 \
+	$(top_srcdir)/autotools/m4/frexpl.m4 \
+	$(top_srcdir)/autotools/m4/fstat.m4 \
+	$(top_srcdir)/autotools/m4/fstatat.m4 \
+	$(top_srcdir)/autotools/m4/futimens.m4 \
+	$(top_srcdir)/autotools/m4/getcwd.m4 \
+	$(top_srcdir)/autotools/m4/getdelim.m4 \
+	$(top_srcdir)/autotools/m4/getdtablesize.m4 \
+	$(top_srcdir)/autotools/m4/getgroups.m4 \
+	$(top_srcdir)/autotools/m4/getline.m4 \
+	$(top_srcdir)/autotools/m4/getopt.m4 \
+	$(top_srcdir)/autotools/m4/getprogname.m4 \
+	$(top_srcdir)/autotools/m4/gettime.m4 \
+	$(top_srcdir)/autotools/m4/gettimeofday.m4 \
+	$(top_srcdir)/autotools/m4/gnulib-common.m4 \
+	$(top_srcdir)/autotools/m4/gnulib-comp.m4 \
+	$(top_srcdir)/autotools/m4/group-member.m4 \
+	$(top_srcdir)/autotools/m4/include_next.m4 \
+	$(top_srcdir)/autotools/m4/intmax_t.m4 \
+	$(top_srcdir)/autotools/m4/inttypes-pri.m4 \
+	$(top_srcdir)/autotools/m4/inttypes.m4 \
+	$(top_srcdir)/autotools/m4/inttypes_h.m4 \
+	$(top_srcdir)/autotools/m4/isnand.m4 \
+	$(top_srcdir)/autotools/m4/isnanf.m4 \
+	$(top_srcdir)/autotools/m4/isnanl.m4 \
+	$(top_srcdir)/autotools/m4/largefile.m4 \
+	$(top_srcdir)/autotools/m4/ldexpl.m4 \
+	$(top_srcdir)/autotools/m4/limits-h.m4 \
+	$(top_srcdir)/autotools/m4/localtime-buffer.m4 \
+	$(top_srcdir)/autotools/m4/longlong.m4 \
+	$(top_srcdir)/autotools/m4/lstat.m4 \
+	$(top_srcdir)/autotools/m4/malloc.m4 \
+	$(top_srcdir)/autotools/m4/malloca.m4 \
+	$(top_srcdir)/autotools/m4/math_h.m4 \
+	$(top_srcdir)/autotools/m4/memchr.m4 \
+	$(top_srcdir)/autotools/m4/mempcpy.m4 \
+	$(top_srcdir)/autotools/m4/memrchr.m4 \
+	$(top_srcdir)/autotools/m4/mkdir.m4 \
+	$(top_srcdir)/autotools/m4/mkdirat.m4 \
+	$(top_srcdir)/autotools/m4/mmap-anon.m4 \
+	$(top_srcdir)/autotools/m4/mode_t.m4 \
+	$(top_srcdir)/autotools/m4/msvc-inval.m4 \
+	$(top_srcdir)/autotools/m4/msvc-nothrow.m4 \
+	$(top_srcdir)/autotools/m4/multiarch.m4 \
+	$(top_srcdir)/autotools/m4/nocrash.m4 \
+	$(top_srcdir)/autotools/m4/off_t.m4 \
+	$(top_srcdir)/autotools/m4/open-cloexec.m4 \
+	$(top_srcdir)/autotools/m4/open.m4 \
+	$(top_srcdir)/autotools/m4/openat.m4 \
+	$(top_srcdir)/autotools/m4/opendir.m4 \
+	$(top_srcdir)/autotools/m4/pathmax.m4 \
+	$(top_srcdir)/autotools/m4/printf-frexp.m4 \
+	$(top_srcdir)/autotools/m4/printf-frexpl.m4 \
+	$(top_srcdir)/autotools/m4/printf.m4 \
+	$(top_srcdir)/autotools/m4/readlink.m4 \
+	$(top_srcdir)/autotools/m4/readlinkat.m4 \
+	$(top_srcdir)/autotools/m4/realloc.m4 \
+	$(top_srcdir)/autotools/m4/rename.m4 \
+	$(top_srcdir)/autotools/m4/renameat.m4 \
+	$(top_srcdir)/autotools/m4/rmdir.m4 \
+	$(top_srcdir)/autotools/m4/save-cwd.m4 \
+	$(top_srcdir)/autotools/m4/signbit.m4 \
+	$(top_srcdir)/autotools/m4/size_max.m4 \
+	$(top_srcdir)/autotools/m4/ssize_t.m4 \
+	$(top_srcdir)/autotools/m4/stat-time.m4 \
+	$(top_srcdir)/autotools/m4/stat.m4 \
+	$(top_srcdir)/autotools/m4/stdbool.m4 \
+	$(top_srcdir)/autotools/m4/stddef_h.m4 \
+	$(top_srcdir)/autotools/m4/stdint.m4 \
+	$(top_srcdir)/autotools/m4/stdint_h.m4 \
+	$(top_srcdir)/autotools/m4/stdio_h.m4 \
+	$(top_srcdir)/autotools/m4/stdlib_h.m4 \
+	$(top_srcdir)/autotools/m4/stpcpy.m4 \
+	$(top_srcdir)/autotools/m4/strcase.m4 \
+	$(top_srcdir)/autotools/m4/strcasestr.m4 \
+	$(top_srcdir)/autotools/m4/strdup.m4 \
+	$(top_srcdir)/autotools/m4/strerror.m4 \
+	$(top_srcdir)/autotools/m4/string_h.m4 \
+	$(top_srcdir)/autotools/m4/strings_h.m4 \
+	$(top_srcdir)/autotools/m4/strncat.m4 \
+	$(top_srcdir)/autotools/m4/symlink.m4 \
+	$(top_srcdir)/autotools/m4/symlinkat.m4 \
+	$(top_srcdir)/autotools/m4/sys_socket_h.m4 \
+	$(top_srcdir)/autotools/m4/sys_stat_h.m4 \
+	$(top_srcdir)/autotools/m4/sys_time_h.m4 \
+	$(top_srcdir)/autotools/m4/sys_types_h.m4 \
+	$(top_srcdir)/autotools/m4/time_h.m4 \
+	$(top_srcdir)/autotools/m4/timespec.m4 \
+	$(top_srcdir)/autotools/m4/unistd-safer.m4 \
+	$(top_srcdir)/autotools/m4/unistd_h.m4 \
+	$(top_srcdir)/autotools/m4/unlink.m4 \
+	$(top_srcdir)/autotools/m4/unlinkat.m4 \
+	$(top_srcdir)/autotools/m4/utime.m4 \
+	$(top_srcdir)/autotools/m4/utime_h.m4 \
+	$(top_srcdir)/autotools/m4/utimens.m4 \
+	$(top_srcdir)/autotools/m4/utimensat.m4 \
+	$(top_srcdir)/autotools/m4/utimes.m4 \
+	$(top_srcdir)/autotools/m4/vasnprintf.m4 \
+	$(top_srcdir)/autotools/m4/vasprintf-posix.m4 \
+	$(top_srcdir)/autotools/m4/vasprintf.m4 \
+	$(top_srcdir)/autotools/m4/warn-on-use.m4 \
+	$(top_srcdir)/autotools/m4/wchar_h.m4 \
+	$(top_srcdir)/autotools/m4/wchar_t.m4 \
+	$(top_srcdir)/autotools/m4/wint_t.m4 \
+	$(top_srcdir)/autotools/m4/xsize.m4 $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+DIST_COMMON = $(srcdir)/Makefile.am $(top_srcdir)/configure \
+	$(am__configure_deps) $(dist_postsyncd_SCRIPTS) \
+	$(am__DIST_COMMON)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(postsyncddir)" \
+	"$(DESTDIR)$(man1dir)"
+PROGRAMS = $(bin_PROGRAMS)
+am_q_OBJECTS = q-main.$(OBJEXT)
+q_OBJECTS = $(am_q_OBJECTS)
+am__DEPENDENCIES_1 =
+q_DEPENDENCIES = $(top_builddir)/autotools/gnulib/libgnu.a \
+	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__uninstall_files_from_dir = { \
+  test -z "$$files" \
+    || { test ! -d "$$dir" && test ! -f "$$dir" && test ! -r "$$dir"; } \
+    || { echo " ( cd '$$dir' && rm -f" $$files ")"; \
+         $(am__cd) "$$dir" && rm -f $$files; }; \
+  }
+SCRIPTS = $(dist_postsyncd_SCRIPTS)
+AM_V_P = $(am__v_P_$(V))
+am__v_P_ = $(am__v_P_$(AM_DEFAULT_VERBOSITY))
+am__v_P_0 = false
+am__v_P_1 = :
+AM_V_GEN = $(am__v_GEN_$(V))
+am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
+am__v_GEN_0 = @echo "  GEN     " $@;
+am__v_GEN_1 = 
+AM_V_at = $(am__v_at_$(V))
+am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
+am__v_at_0 = @
+am__v_at_1 = 
+DEFAULT_INCLUDES = -I.
+depcomp = $(SHELL) $(top_srcdir)/autotools/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+AM_V_lt = $(am__v_lt_$(V))
+am__v_lt_ = $(am__v_lt_$(AM_DEFAULT_VERBOSITY))
+am__v_lt_0 = --silent
+am__v_lt_1 = 
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+AM_V_CC = $(am__v_CC_$(V))
+am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
+am__v_CC_0 = @echo "  CC      " $@;
+am__v_CC_1 = 
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+AM_V_CCLD = $(am__v_CCLD_$(V))
+am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
+am__v_CCLD_0 = @echo "  CCLD    " $@;
+am__v_CCLD_1 = 
+SOURCES = $(q_SOURCES)
+DIST_SOURCES = $(q_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive cscopelist-recursive \
+	ctags-recursive dvi-recursive html-recursive info-recursive \
+	install-data-recursive install-dvi-recursive \
+	install-exec-recursive install-html-recursive \
+	install-info-recursive install-pdf-recursive \
+	install-ps-recursive install-recursive installcheck-recursive \
+	installdirs-recursive pdf-recursive ps-recursive \
+	tags-recursive uninstall-recursive
+am__can_run_installinfo = \
+  case $$AM_UPDATE_INFO_DIR in \
+    n|no|NO) false;; \
+    *) (install-info --version) >/dev/null 2>&1;; \
+  esac
+man1dir = $(mandir)/man1
+NROFF = nroff
+MANS = $(dist_man_MANS)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive	\
+  distclean-recursive maintainer-clean-recursive
+am__recursive_targets = \
+  $(RECURSIVE_TARGETS) \
+  $(RECURSIVE_CLEAN_TARGETS) \
+  $(am__extra_recursive_targets)
+AM_RECURSIVE_TARGETS = $(am__recursive_targets:-recursive=) TAGS CTAGS \
+	cscope distdir dist dist-all distcheck
+am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) \
+	$(LISP)config.h.in
+# Read a list of newline-separated strings from the standard input,
+# and print each of them once, without duplicates.  Input order is
+# *not* preserved.
+am__uniquify_input = $(AWK) '\
+  BEGIN { nonempty = 0; } \
+  { items[$$0] = 1; nonempty = 1; } \
+  END { if (nonempty) { for (i in items) print i; }; } \
+'
+# Make sure the list of sources is unique.  This is necessary because,
+# e.g., the same source file might be shared among _SOURCES variables
+# for different programs/libraries.
+am__define_uniq_tagged_files = \
+  list='$(am__tagged_files)'; \
+  unique=`for i in $$list; do \
+    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+  done | $(am__uniquify_input)`
+ETAGS = etags
+CTAGS = ctags
+CSCOPE = cscope
+DIST_SUBDIRS = $(SUBDIRS)
+am__DIST_COMMON = $(dist_man_MANS) $(srcdir)/Makefile.in \
+	$(srcdir)/config.h.in $(top_srcdir)/autotools/compile \
+	$(top_srcdir)/autotools/config.guess \
+	$(top_srcdir)/autotools/config.sub \
+	$(top_srcdir)/autotools/depcomp \
+	$(top_srcdir)/autotools/install-sh \
+	$(top_srcdir)/autotools/missing COPYING autotools/compile \
+	autotools/config.guess autotools/config.sub autotools/depcomp \
+	autotools/install-sh autotools/missing
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  if test -d "$(distdir)"; then \
+    find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+      && rm -rf "$(distdir)" \
+      || { sleep 5 && rm -rf "$(distdir)"; }; \
+  else :; fi
+am__post_remove_distdir = $(am__remove_distdir)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+GZIP_ENV = --best
+DIST_ARCHIVES = $(distdir).tar.xz
+DIST_TARGETS = dist-xz
+distuninstallcheck_listfiles = find . -type f -print
+am__distuninstallcheck_listfiles = $(distuninstallcheck_listfiles) \
+  | sed 's|^\./|$(prefix)/|' | grep -v '$(infodir)/dir$$'
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = ${SHELL} /net/ptah/export/gentoo/working-repos/portage-utils/autotools/missing aclocal-1.15
+ALLOCA = 
+ALLOCA_H = alloca.h
+AMTAR = $${TAR-tar}
+AM_DEFAULT_VERBOSITY = 0
+APPLE_UNIVERSAL_BUILD = 0
+AR = ar
+ARFLAGS = cr
+AUTOCONF = ${SHELL} /net/ptah/export/gentoo/working-repos/portage-utils/autotools/missing autoconf
+AUTOHEADER = ${SHELL} /net/ptah/export/gentoo/working-repos/portage-utils/autotools/missing autoheader
+AUTOMAKE = ${SHELL} /net/ptah/export/gentoo/working-repos/portage-utils/autotools/missing automake-1.15
+AWK = gawk
+BITSIZEOF_PTRDIFF_T = 
+BITSIZEOF_SIG_ATOMIC_T = 
+BITSIZEOF_SIZE_T = 
+BITSIZEOF_WCHAR_T = 
+BITSIZEOF_WINT_T = 
+CC = gcc
+CCDEPMODE = depmode=gcc3
+CFLAGS = -g -O2 -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 -Wmissing-declarations -Wno-missing-prototypes -Wwrite-strings -Wbad-function-cast -Wnested-externs -Wcomment -Winline -Wchar-subscripts -Wcast-align -Wno-format-nonliteral -Wsequence-point -Wold-style-definition -Wextra
+CPP = gcc -E
+CPPFLAGS = 
+CYGPATH_W = echo
+DEFS = -DHAVE_CONFIG_H
+DEPDIR = .deps
+ECHO_C = \c
+ECHO_N = 
+ECHO_T = 
+EGREP = /gentoo/prefix64/usr/bin/grep -E
+EMULTIHOP_HIDDEN = 
+EMULTIHOP_VALUE = 
+ENOLINK_HIDDEN = 
+ENOLINK_VALUE = 
+EOVERFLOW_HIDDEN = 
+EOVERFLOW_VALUE = 
+ERRNO_H = 
+EXEEXT = 
+FLOAT_H = 
+GETOPT_CDEFS_H = 
+GETOPT_H = 
+GNULIB_ACOSF = 0
+GNULIB_ACOSL = 0
+GNULIB_ALPHASORT = 0
+GNULIB_ASINF = 0
+GNULIB_ASINL = 0
+GNULIB_ATAN2F = 0
+GNULIB_ATANF = 0
+GNULIB_ATANL = 0
+GNULIB_ATOLL = 0
+GNULIB_BTOWC = 0
+GNULIB_CALLOC_POSIX = 0
+GNULIB_CANONICALIZE_FILE_NAME = 1
+GNULIB_CBRT = 0
+GNULIB_CBRTF = 0
+GNULIB_CBRTL = 0
+GNULIB_CEIL = 0
+GNULIB_CEILF = 0
+GNULIB_CEILL = 0
+GNULIB_CHDIR = 1
+GNULIB_CHOWN = 0
+GNULIB_CLOSE = 1
+GNULIB_CLOSEDIR = 1
+GNULIB_COPYSIGN = 0
+GNULIB_COPYSIGNF = 0
+GNULIB_COPYSIGNL = 0
+GNULIB_COSF = 0
+GNULIB_COSHF = 0
+GNULIB_COSL = 0
+GNULIB_CTIME = 0
+GNULIB_DIRFD = 1
+GNULIB_DPRINTF = 0
+GNULIB_DUP = 1
+GNULIB_DUP2 = 1
+GNULIB_DUP3 = 0
+GNULIB_ENVIRON = 0
+GNULIB_EUIDACCESS = 1
+GNULIB_EXP2 = 0
+GNULIB_EXP2F = 0
+GNULIB_EXP2L = 0
+GNULIB_EXPF = 0
+GNULIB_EXPL = 0
+GNULIB_EXPLICIT_BZERO = 0
+GNULIB_EXPM1 = 0
+GNULIB_EXPM1F = 0
+GNULIB_EXPM1L = 0
+GNULIB_FABSF = 0
+GNULIB_FABSL = 0
+GNULIB_FACCESSAT = 1
+GNULIB_FCHDIR = 1
+GNULIB_FCHMODAT = 0
+GNULIB_FCHOWNAT = 0
+GNULIB_FCLOSE = 0
+GNULIB_FCNTL = 1
+GNULIB_FDATASYNC = 0
+GNULIB_FDOPEN = 0
+GNULIB_FDOPENDIR = 1
+GNULIB_FFLUSH = 0
+GNULIB_FFS = 0
+GNULIB_FFSL = 0
+GNULIB_FFSLL = 0
+GNULIB_FGETC = 1
+GNULIB_FGETS = 1
+GNULIB_FLOOR = 0
+GNULIB_FLOORF = 0
+GNULIB_FLOORL = 0
+GNULIB_FMA = 0
+GNULIB_FMAF = 0
+GNULIB_FMAL = 0
+GNULIB_FMOD = 0
+GNULIB_FMODF = 0
+GNULIB_FMODL = 0
+GNULIB_FOPEN = 0
+GNULIB_FPRINTF = 1
+GNULIB_FPRINTF_POSIX = 0
+GNULIB_FPURGE = 0
+GNULIB_FPUTC = 1
+GNULIB_FPUTS = 1
+GNULIB_FREAD = 1
+GNULIB_FREOPEN = 0
+GNULIB_FREXP = 1
+GNULIB_FREXPF = 0
+GNULIB_FREXPL = 1
+GNULIB_FSCANF = 1
+GNULIB_FSEEK = 0
+GNULIB_FSEEKO = 0
+GNULIB_FSTAT = 1
+GNULIB_FSTATAT = 1
+GNULIB_FSYNC = 0
+GNULIB_FTELL = 0
+GNULIB_FTELLO = 0
+GNULIB_FTRUNCATE = 0
+GNULIB_FUTIMENS = 1
+GNULIB_FWRITE = 1
+GNULIB_GETC = 1
+GNULIB_GETCHAR = 1
+GNULIB_GETCWD = 1
+GNULIB_GETDELIM = 1
+GNULIB_GETDOMAINNAME = 0
+GNULIB_GETDTABLESIZE = 1
+GNULIB_GETGROUPS = 1
+GNULIB_GETHOSTNAME = 0
+GNULIB_GETLINE = 1
+GNULIB_GETLOADAVG = 0
+GNULIB_GETLOGIN = 0
+GNULIB_GETLOGIN_R = 0
+GNULIB_GETPAGESIZE = 0
+GNULIB_GETSUBOPT = 0
+GNULIB_GETTIMEOFDAY = 1
+GNULIB_GETUSERSHELL = 0
+GNULIB_GL_UNISTD_H_GETOPT = 
+GNULIB_GRANTPT = 0
+GNULIB_GROUP_MEMBER = 1
+GNULIB_HYPOT = 0
+GNULIB_HYPOTF = 0
+GNULIB_HYPOTL = 0
+GNULIB_ILOGB = 0
+GNULIB_ILOGBF = 0
+GNULIB_ILOGBL = 0
+GNULIB_IMAXABS = 0
+GNULIB_IMAXDIV = 0
+GNULIB_ISATTY = 0
+GNULIB_ISFINITE = 0
+GNULIB_ISINF = 0
+GNULIB_ISNAN = 0
+GNULIB_ISNAND = 0
+GNULIB_ISNANF = 0
+GNULIB_ISNANL = 0
+GNULIB_LCHMOD = 0
+GNULIB_LCHOWN = 0
+GNULIB_LDEXPF = 0
+GNULIB_LDEXPL = 0
+GNULIB_LINK = 0
+GNULIB_LINKAT = 0
+GNULIB_LOCALTIME = 0
+GNULIB_LOG = 0
+GNULIB_LOG10 = 0
+GNULIB_LOG10F = 0
+GNULIB_LOG10L = 0
+GNULIB_LOG1P = 0
+GNULIB_LOG1PF = 0
+GNULIB_LOG1PL = 0
+GNULIB_LOG2 = 0
+GNULIB_LOG2F = 0
+GNULIB_LOG2L = 0
+GNULIB_LOGB = 0
+GNULIB_LOGBF = 0
+GNULIB_LOGBL = 0
+GNULIB_LOGF = 0
+GNULIB_LOGL = 0
+GNULIB_LSEEK = 0
+GNULIB_LSTAT = 1
+GNULIB_MALLOC_POSIX = 1
+GNULIB_MBRLEN = 0
+GNULIB_MBRTOWC = 0
+GNULIB_MBSCASECMP = 0
+GNULIB_MBSCASESTR = 0
+GNULIB_MBSCHR = 0
+GNULIB_MBSCSPN = 0
+GNULIB_MBSINIT = 0
+GNULIB_MBSLEN = 0
+GNULIB_MBSNCASECMP = 0
+GNULIB_MBSNLEN = 0
+GNULIB_MBSNRTOWCS = 0
+GNULIB_MBSPBRK = 0
+GNULIB_MBSPCASECMP = 0
+GNULIB_MBSRCHR = 0
+GNULIB_MBSRTOWCS = 0
+GNULIB_MBSSEP = 0
+GNULIB_MBSSPN = 0
+GNULIB_MBSSTR = 0
+GNULIB_MBSTOK_R = 0
+GNULIB_MBTOWC = 0
+GNULIB_MEMCHR = 1
+GNULIB_MEMMEM = 0
+GNULIB_MEMPCPY = 1
+GNULIB_MEMRCHR = 1
+GNULIB_MKDIRAT = 1
+GNULIB_MKDTEMP = 0
+GNULIB_MKFIFO = 0
+GNULIB_MKFIFOAT = 0
+GNULIB_MKNOD = 0
+GNULIB_MKNODAT = 0
+GNULIB_MKOSTEMP = 0
+GNULIB_MKOSTEMPS = 0
+GNULIB_MKSTEMP = 0
+GNULIB_MKSTEMPS = 0
+GNULIB_MKTIME = 0
+GNULIB_MODF = 0
+GNULIB_MODFF = 0
+GNULIB_MODFL = 0
+GNULIB_NANOSLEEP = 0
+GNULIB_NONBLOCKING = 0
+GNULIB_OBSTACK_PRINTF = 0
+GNULIB_OBSTACK_PRINTF_POSIX = 0
+GNULIB_OPEN = 1
+GNULIB_OPENAT = 1
+GNULIB_OPENDIR = 1
+GNULIB_OVERRIDES_STRUCT_STAT = 0
+GNULIB_OVERRIDES_WINT_T = 0
+GNULIB_PCLOSE = 0
+GNULIB_PERROR = 0
+GNULIB_PIPE = 0
+GNULIB_PIPE2 = 0
+GNULIB_POPEN = 0
+GNULIB_POSIX_OPENPT = 0
+GNULIB_POWF = 0
+GNULIB_PREAD = 0
+GNULIB_PRINTF = 1
+GNULIB_PRINTF_POSIX = 0
+GNULIB_PTSNAME = 0
+GNULIB_PTSNAME_R = 0
+GNULIB_PUTC = 1
+GNULIB_PUTCHAR = 1
+GNULIB_PUTENV = 0
+GNULIB_PUTS = 1
+GNULIB_PWRITE = 0
+GNULIB_QSORT_R = 0
+GNULIB_RANDOM = 0
+GNULIB_RANDOM_R = 0
+GNULIB_RAWMEMCHR = 0
+GNULIB_READ = 0
+GNULIB_READDIR = 0
+GNULIB_READLINK = 1
+GNULIB_READLINKAT = 1
+GNULIB_REALLOCARRAY = 0
+GNULIB_REALLOC_POSIX = 1
+GNULIB_REALPATH = 1
+GNULIB_REMAINDER = 0
+GNULIB_REMAINDERF = 0
+GNULIB_REMAINDERL = 0
+GNULIB_REMOVE = 0
+GNULIB_RENAME = 1
+GNULIB_RENAMEAT = 1
+GNULIB_REWINDDIR = 0
+GNULIB_RINT = 0
+GNULIB_RINTF = 0
+GNULIB_RINTL = 0
+GNULIB_RMDIR = 1
+GNULIB_ROUND = 0
+GNULIB_ROUNDF = 0
+GNULIB_ROUNDL = 0
+GNULIB_RPMATCH = 0
+GNULIB_SCANDIR = 0
+GNULIB_SCANF = 1
+GNULIB_SECURE_GETENV = 0
+GNULIB_SETENV = 0
+GNULIB_SETHOSTNAME = 0
+GNULIB_SIGNBIT = 1
+GNULIB_SINF = 0
+GNULIB_SINHF = 0
+GNULIB_SINL = 0
+GNULIB_SLEEP = 0
+GNULIB_SNPRINTF = 0
+GNULIB_SPRINTF_POSIX = 0
+GNULIB_SQRTF = 0
+GNULIB_SQRTL = 0
+GNULIB_STAT = 1
+GNULIB_STDIO_H_NONBLOCKING = 0
+GNULIB_STDIO_H_SIGPIPE = 0
+GNULIB_STPCPY = 1
+GNULIB_STPNCPY = 0
+GNULIB_STRCASESTR = 1
+GNULIB_STRCHRNUL = 0
+GNULIB_STRDUP = 1
+GNULIB_STRERROR = 1
+GNULIB_STRERROR_R = 0
+GNULIB_STRFTIME = 0
+GNULIB_STRNCAT = 1
+GNULIB_STRNDUP = 0
+GNULIB_STRNLEN = 0
+GNULIB_STRPBRK = 0
+GNULIB_STRPTIME = 0
+GNULIB_STRSEP = 0
+GNULIB_STRSIGNAL = 0
+GNULIB_STRSTR = 0
+GNULIB_STRTOD = 0
+GNULIB_STRTOIMAX = 0
+GNULIB_STRTOK_R = 0
+GNULIB_STRTOLL = 0
+GNULIB_STRTOULL = 0
+GNULIB_STRTOUMAX = 0
+GNULIB_STRVERSCMP = 0
+GNULIB_SYMLINK = 1
+GNULIB_SYMLINKAT = 1
+GNULIB_SYSTEM_POSIX = 0
+GNULIB_TANF = 0
+GNULIB_TANHF = 0
+GNULIB_TANL = 0
+GNULIB_TIMEGM = 0
+GNULIB_TIME_R = 0
+GNULIB_TIME_RZ = 0
+GNULIB_TMPFILE = 0
+GNULIB_TRUNC = 0
+GNULIB_TRUNCATE = 0
+GNULIB_TRUNCF = 0
+GNULIB_TRUNCL = 0
+GNULIB_TTYNAME_R = 0
+GNULIB_TZSET = 0
+GNULIB_UNISTD_H_NONBLOCKING = 0
+GNULIB_UNISTD_H_SIGPIPE = 0
+GNULIB_UNLINK = 1
+GNULIB_UNLINKAT = 1
+GNULIB_UNLOCKPT = 0
+GNULIB_UNSETENV = 0
+GNULIB_USLEEP = 0
+GNULIB_UTIME = 1
+GNULIB_UTIMENSAT = 1
+GNULIB_VASPRINTF = 1
+GNULIB_VDPRINTF = 0
+GNULIB_VFPRINTF = 1
+GNULIB_VFPRINTF_POSIX = 0
+GNULIB_VFSCANF = 0
+GNULIB_VPRINTF = 1
+GNULIB_VPRINTF_POSIX = 0
+GNULIB_VSCANF = 0
+GNULIB_VSNPRINTF = 0
+GNULIB_VSPRINTF_POSIX = 0
+GNULIB_WCPCPY = 0
+GNULIB_WCPNCPY = 0
+GNULIB_WCRTOMB = 0
+GNULIB_WCSCASECMP = 0
+GNULIB_WCSCAT = 0
+GNULIB_WCSCHR = 0
+GNULIB_WCSCMP = 0
+GNULIB_WCSCOLL = 0
+GNULIB_WCSCPY = 0
+GNULIB_WCSCSPN = 0
+GNULIB_WCSDUP = 0
+GNULIB_WCSFTIME = 0
+GNULIB_WCSLEN = 0
+GNULIB_WCSNCASECMP = 0
+GNULIB_WCSNCAT = 0
+GNULIB_WCSNCMP = 0
+GNULIB_WCSNCPY = 0
+GNULIB_WCSNLEN = 0
+GNULIB_WCSNRTOMBS = 0
+GNULIB_WCSPBRK = 0
+GNULIB_WCSRCHR = 0
+GNULIB_WCSRTOMBS = 0
+GNULIB_WCSSPN = 0
+GNULIB_WCSSTR = 0
+GNULIB_WCSTOK = 0
+GNULIB_WCSWIDTH = 0
+GNULIB_WCSXFRM = 0
+GNULIB_WCTOB = 0
+GNULIB_WCTOMB = 0
+GNULIB_WCWIDTH = 0
+GNULIB_WMEMCHR = 0
+GNULIB_WMEMCMP = 0
+GNULIB_WMEMCPY = 0
+GNULIB_WMEMMOVE = 0
+GNULIB_WMEMSET = 0
+GNULIB_WRITE = 0
+GNULIB__EXIT = 0
+GREP = /gentoo/prefix64/usr/bin/grep
+HAVE_ACOSF = 1
+HAVE_ACOSL = 1
+HAVE_ALPHASORT = 1
+HAVE_ASINF = 1
+HAVE_ASINL = 1
+HAVE_ATAN2F = 1
+HAVE_ATANF = 1
+HAVE_ATANL = 1
+HAVE_ATOLL = 1
+HAVE_BTOWC = 1
+HAVE_C99_STDINT_H = 1
+HAVE_CANONICALIZE_FILE_NAME = 1
+HAVE_CBRT = 1
+HAVE_CBRTF = 1
+HAVE_CBRTL = 1
+HAVE_CHOWN = 1
+HAVE_CLOSEDIR = 1
+HAVE_COPYSIGN = 1
+HAVE_COPYSIGNL = 1
+HAVE_COSF = 1
+HAVE_COSHF = 1
+HAVE_COSL = 1
+HAVE_CRTDEFS_H = 0
+HAVE_DECL_ACOSL = 1
+HAVE_DECL_ASINL = 1
+HAVE_DECL_ATANL = 1
+HAVE_DECL_CBRTF = 1
+HAVE_DECL_CBRTL = 1
+HAVE_DECL_CEILF = 1
+HAVE_DECL_CEILL = 1
+HAVE_DECL_COPYSIGNF = 1
+HAVE_DECL_COSL = 1
+HAVE_DECL_DIRFD = 1
+HAVE_DECL_ENVIRON = 1
+HAVE_DECL_EXP2 = 1
+HAVE_DECL_EXP2F = 1
+HAVE_DECL_EXP2L = 1
+HAVE_DECL_EXPL = 1
+HAVE_DECL_EXPM1L = 1
+HAVE_DECL_FCHDIR = 1
+HAVE_DECL_FDATASYNC = 1
+HAVE_DECL_FDOPENDIR = 1
+HAVE_DECL_FLOORF = 1
+HAVE_DECL_FLOORL = 1
+HAVE_DECL_FPURGE = 1
+HAVE_DECL_FREXPL = 1
+HAVE_DECL_FSEEKO = 1
+HAVE_DECL_FTELLO = 1
+HAVE_DECL_GETDELIM = 1
+HAVE_DECL_GETDOMAINNAME = 1
+HAVE_DECL_GETLINE = 1
+HAVE_DECL_GETLOADAVG = 1
+HAVE_DECL_GETLOGIN = 1
+HAVE_DECL_GETLOGIN_R = 1
+HAVE_DECL_GETPAGESIZE = 1
+HAVE_DECL_GETUSERSHELL = 1
+HAVE_DECL_IMAXABS = 1
+HAVE_DECL_IMAXDIV = 1
+HAVE_DECL_INITSTATE = 1
+HAVE_DECL_LDEXPL = 1
+HAVE_DECL_LOCALTIME_R = 1
+HAVE_DECL_LOG10L = 1
+HAVE_DECL_LOG2 = 1
+HAVE_DECL_LOG2F = 1
+HAVE_DECL_LOG2L = 1
+HAVE_DECL_LOGB = 1
+HAVE_DECL_LOGL = 1
+HAVE_DECL_MEMMEM = 1
+HAVE_DECL_MEMRCHR = 0
+HAVE_DECL_OBSTACK_PRINTF = 1
+HAVE_DECL_REMAINDER = 1
+HAVE_DECL_REMAINDERL = 1
+HAVE_DECL_RINTF = 1
+HAVE_DECL_ROUND = 1
+HAVE_DECL_ROUNDF = 1
+HAVE_DECL_ROUNDL = 1
+HAVE_DECL_SETENV = 1
+HAVE_DECL_SETHOSTNAME = 1
+HAVE_DECL_SETSTATE = 1
+HAVE_DECL_SINL = 1
+HAVE_DECL_SNPRINTF = 1
+HAVE_DECL_SQRTL = 1
+HAVE_DECL_STRDUP = 1
+HAVE_DECL_STRERROR_R = 1
+HAVE_DECL_STRNCASECMP = 1
+HAVE_DECL_STRNDUP = 1
+HAVE_DECL_STRNLEN = 1
+HAVE_DECL_STRSIGNAL = 1
+HAVE_DECL_STRTOIMAX = 1
+HAVE_DECL_STRTOK_R = 1
+HAVE_DECL_STRTOUMAX = 1
+HAVE_DECL_TANL = 1
+HAVE_DECL_TRUNC = 1
+HAVE_DECL_TRUNCF = 1
+HAVE_DECL_TRUNCL = 1
+HAVE_DECL_TTYNAME_R = 1
+HAVE_DECL_UNSETENV = 1
+HAVE_DECL_VSNPRINTF = 1
+HAVE_DECL_WCTOB = 1
+HAVE_DECL_WCWIDTH = 1
+HAVE_DIRENT_H = 1
+HAVE_DPRINTF = 1
+HAVE_DUP2 = 1
+HAVE_DUP3 = 1
+HAVE_EUIDACCESS = 0
+HAVE_EXPF = 1
+HAVE_EXPL = 1
+HAVE_EXPLICIT_BZERO = 1
+HAVE_EXPM1 = 1
+HAVE_EXPM1F = 1
+HAVE_FABSF = 1
+HAVE_FABSL = 1
+HAVE_FACCESSAT = 1
+HAVE_FCHDIR = 1
+HAVE_FCHMODAT = 1
+HAVE_FCHOWNAT = 1
+HAVE_FCNTL = 1
+HAVE_FDATASYNC = 1
+HAVE_FDOPENDIR = 1
+HAVE_FEATURES_H = 0
+HAVE_FFS = 1
+HAVE_FFSL = 1
+HAVE_FFSLL = 1
+HAVE_FMA = 1
+HAVE_FMAF = 1
+HAVE_FMAL = 1
+HAVE_FMODF = 1
+HAVE_FMODL = 1
+HAVE_FREXPF = 1
+HAVE_FSEEKO = 1
+HAVE_FSTATAT = 1
+HAVE_FSYNC = 1
+HAVE_FTELLO = 1
+HAVE_FTRUNCATE = 1
+HAVE_FUTIMENS = 1
+HAVE_GETDTABLESIZE = 1
+HAVE_GETGROUPS = 1
+HAVE_GETHOSTNAME = 1
+HAVE_GETLOGIN = 1
+HAVE_GETOPT_H = 1
+HAVE_GETPAGESIZE = 1
+HAVE_GETSUBOPT = 1
+HAVE_GETTIMEOFDAY = 1
+HAVE_GRANTPT = 1
+HAVE_GROUP_MEMBER = 0
+HAVE_HYPOTF = 1
+HAVE_HYPOTL = 1
+HAVE_ILOGB = 1
+HAVE_ILOGBF = 1
+HAVE_ILOGBL = 1
+HAVE_INTTYPES_H = 1
+HAVE_ISNAND = 1
+HAVE_ISNANF = 1
+HAVE_ISNANL = 1
+HAVE_LCHMOD = 1
+HAVE_LCHOWN = 1
+HAVE_LDEXPF = 1
+HAVE_LINK = 1
+HAVE_LINKAT = 1
+HAVE_LOG10F = 1
+HAVE_LOG10L = 1
+HAVE_LOG1P = 1
+HAVE_LOG1PF = 1
+HAVE_LOG1PL = 1
+HAVE_LOGBF = 1
+HAVE_LOGBL = 1
+HAVE_LOGF = 1
+HAVE_LOGL = 1
+HAVE_LONG_LONG_INT = 1
+HAVE_LSTAT = 1
+HAVE_MAX_ALIGN_T = 1
+HAVE_MBRLEN = 1
+HAVE_MBRTOWC = 1
+HAVE_MBSINIT = 1
+HAVE_MBSLEN = 0
+HAVE_MBSNRTOWCS = 1
+HAVE_MBSRTOWCS = 1
+HAVE_MEMCHR = 1
+HAVE_MEMPCPY = 0
+HAVE_MKDIRAT = 1
+HAVE_MKDTEMP = 1
+HAVE_MKFIFO = 1
+HAVE_MKFIFOAT = 1
+HAVE_MKNOD = 1
+HAVE_MKNODAT = 1
+HAVE_MKOSTEMP = 1
+HAVE_MKOSTEMPS = 1
+HAVE_MKSTEMP = 1
+HAVE_MKSTEMPS = 1
+HAVE_MODFF = 1
+HAVE_MODFL = 1
+HAVE_MSVC_INVALID_PARAMETER_HANDLER = 0
+HAVE_NANOSLEEP = 1
+HAVE_OPENAT = 1
+HAVE_OPENDIR = 1
+HAVE_OS_H = 0
+HAVE_PCLOSE = 1
+HAVE_PIPE = 1
+HAVE_PIPE2 = 1
+HAVE_POPEN = 1
+HAVE_POSIX_OPENPT = 1
+HAVE_POWF = 1
+HAVE_PREAD = 1
+HAVE_PTSNAME = 1
+HAVE_PTSNAME_R = 1
+HAVE_PWRITE = 1
+HAVE_QSORT_R = 1
+HAVE_RANDOM = 1
+HAVE_RANDOM_H = 1
+HAVE_RANDOM_R = 1
+HAVE_RAWMEMCHR = 1
+HAVE_READDIR = 1
+HAVE_READLINK = 1
+HAVE_READLINKAT = 1
+HAVE_REALLOCARRAY = 1
+HAVE_REALPATH = 1
+HAVE_REMAINDER = 1
+HAVE_REMAINDERF = 1
+HAVE_RENAMEAT = 1
+HAVE_REWINDDIR = 1
+HAVE_RINT = 1
+HAVE_RINTL = 1
+HAVE_RPMATCH = 1
+HAVE_SAME_LONG_DOUBLE_AS_DOUBLE = 0
+HAVE_SCANDIR = 1
+HAVE_SECURE_GETENV = 1
+HAVE_SETENV = 1
+HAVE_SETHOSTNAME = 1
+HAVE_SIGNED_SIG_ATOMIC_T = 
+HAVE_SIGNED_WCHAR_T = 
+HAVE_SIGNED_WINT_T = 
+HAVE_SINF = 1
+HAVE_SINHF = 1
+HAVE_SINL = 1
+HAVE_SLEEP = 1
+HAVE_SQRTF = 1
+HAVE_SQRTL = 1
+HAVE_STDINT_H = 1
+HAVE_STPCPY = 1
+HAVE_STPNCPY = 1
+HAVE_STRCASECMP = 1
+HAVE_STRCASESTR = 1
+HAVE_STRCHRNUL = 1
+HAVE_STRINGS_H = 1
+HAVE_STRPBRK = 1
+HAVE_STRPTIME = 1
+HAVE_STRSEP = 1
+HAVE_STRTOD = 1
+HAVE_STRTOLL = 1
+HAVE_STRTOULL = 1
+HAVE_STRUCT_RANDOM_DATA = 1
+HAVE_STRUCT_TIMEVAL = 1
+HAVE_STRVERSCMP = 1
+HAVE_SYMLINK = 1
+HAVE_SYMLINKAT = 1
+HAVE_SYS_BITYPES_H = 0
+HAVE_SYS_CDEFS_H = 
+HAVE_SYS_INTTYPES_H = 0
+HAVE_SYS_LOADAVG_H = 0
+HAVE_SYS_PARAM_H = 0
+HAVE_SYS_TIME_H = 1
+HAVE_SYS_TYPES_H = 1
+HAVE_TANF = 1
+HAVE_TANHF = 1
+HAVE_TANL = 1
+HAVE_TIMEGM = 1
+HAVE_TIMEZONE_T = 0
+HAVE_TRUNCATE = 1
+HAVE_TZSET = 1
+HAVE_UNISTD_H = 1
+HAVE_UNLINKAT = 1
+HAVE_UNLOCKPT = 1
+HAVE_UNSIGNED_LONG_LONG_INT = 1
+HAVE_USLEEP = 1
+HAVE_UTIME = 1
+HAVE_UTIMENSAT = 1
+HAVE_UTIME_H = 1
+HAVE_VASPRINTF = 1
+HAVE_VDPRINTF = 1
+HAVE_WCHAR_H = 1
+HAVE_WCHAR_T = 1
+HAVE_WCPCPY = 1
+HAVE_WCPNCPY = 1
+HAVE_WCRTOMB = 1
+HAVE_WCSCASECMP = 1
+HAVE_WCSCAT = 1
+HAVE_WCSCHR = 1
+HAVE_WCSCMP = 1
+HAVE_WCSCOLL = 1
+HAVE_WCSCPY = 1
+HAVE_WCSCSPN = 1
+HAVE_WCSDUP = 1
+HAVE_WCSFTIME = 1
+HAVE_WCSLEN = 1
+HAVE_WCSNCASECMP = 1
+HAVE_WCSNCAT = 1
+HAVE_WCSNCMP = 1
+HAVE_WCSNCPY = 1
+HAVE_WCSNLEN = 1
+HAVE_WCSNRTOMBS = 1
+HAVE_WCSPBRK = 1
+HAVE_WCSRCHR = 1
+HAVE_WCSRTOMBS = 1
+HAVE_WCSSPN = 1
+HAVE_WCSSTR = 1
+HAVE_WCSTOK = 1
+HAVE_WCSWIDTH = 1
+HAVE_WCSXFRM = 1
+HAVE_WINSOCK2_H = 0
+HAVE_WINT_T = 1
+HAVE_WMEMCHR = 1
+HAVE_WMEMCMP = 1
+HAVE_WMEMCPY = 1
+HAVE_WMEMMOVE = 1
+HAVE_WMEMSET = 1
+HAVE__BOOL = 1
+HAVE__EXIT = 1
+INCLUDE_NEXT = include_next
+INCLUDE_NEXT_AS_FIRST_DIRECTIVE = include_next
+INSTALL = /gentoo/prefix64/usr/bin/install -c
+INSTALL_DATA = ${INSTALL} -m 644
+INSTALL_PROGRAM = ${INSTALL}
+INSTALL_SCRIPT = ${INSTALL}
+INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
+INT32_MAX_LT_INTMAX_MAX = 1
+INT64_MAX_EQ_LONG_MAX = 1
+LDFLAGS = 
+LIBGNU_LIBDEPS = 
+LIBGNU_LTLIBDEPS = 
+LIBINTL = 
+LIBOBJS = 
+LIBS = -lkvm 
+LIB_CLOCK_GETTIME = 
+LIB_EACCESS = -lgen
+LIMITS_H = limits.h
+LTLIBINTL = 
+LTLIBOBJS = 
+MAKEINFO = ${SHELL} /net/ptah/export/gentoo/working-repos/portage-utils/autotools/missing makeinfo
+MKDIR_P = /gentoo/prefix64/usr/bin/mkdir -p
+NEXT_AS_FIRST_DIRECTIVE_DIRENT_H = <dirent.h>
+NEXT_AS_FIRST_DIRECTIVE_ERRNO_H = 
+NEXT_AS_FIRST_DIRECTIVE_FCNTL_H = <fcntl.h>
+NEXT_AS_FIRST_DIRECTIVE_FLOAT_H = 
+NEXT_AS_FIRST_DIRECTIVE_GETOPT_H = <getopt.h>
+NEXT_AS_FIRST_DIRECTIVE_INTTYPES_H = <inttypes.h>
+NEXT_AS_FIRST_DIRECTIVE_LIMITS_H = <limits.h>
+NEXT_AS_FIRST_DIRECTIVE_MATH_H = <math.h>
+NEXT_AS_FIRST_DIRECTIVE_STDDEF_H = 
+NEXT_AS_FIRST_DIRECTIVE_STDINT_H = <stdint.h>
+NEXT_AS_FIRST_DIRECTIVE_STDIO_H = <stdio.h>
+NEXT_AS_FIRST_DIRECTIVE_STDLIB_H = <stdlib.h>
+NEXT_AS_FIRST_DIRECTIVE_STRINGS_H = <strings.h>
+NEXT_AS_FIRST_DIRECTIVE_STRING_H = <string.h>
+NEXT_AS_FIRST_DIRECTIVE_SYS_STAT_H = <sys/stat.h>
+NEXT_AS_FIRST_DIRECTIVE_SYS_TIME_H = <sys/time.h>
+NEXT_AS_FIRST_DIRECTIVE_SYS_TYPES_H = <sys/types.h>
+NEXT_AS_FIRST_DIRECTIVE_TIME_H = <time.h>
+NEXT_AS_FIRST_DIRECTIVE_UNISTD_H = <unistd.h>
+NEXT_AS_FIRST_DIRECTIVE_UTIME_H = <utime.h>
+NEXT_AS_FIRST_DIRECTIVE_WCHAR_H = <wchar.h>
+NEXT_DIRENT_H = <dirent.h>
+NEXT_ERRNO_H = 
+NEXT_FCNTL_H = <fcntl.h>
+NEXT_FLOAT_H = 
+NEXT_GETOPT_H = <getopt.h>
+NEXT_INTTYPES_H = <inttypes.h>
+NEXT_LIMITS_H = <limits.h>
+NEXT_MATH_H = <math.h>
+NEXT_STDDEF_H = 
+NEXT_STDINT_H = <stdint.h>
+NEXT_STDIO_H = <stdio.h>
+NEXT_STDLIB_H = <stdlib.h>
+NEXT_STRINGS_H = <strings.h>
+NEXT_STRING_H = <string.h>
+NEXT_SYS_STAT_H = <sys/stat.h>
+NEXT_SYS_TIME_H = <sys/time.h>
+NEXT_SYS_TYPES_H = <sys/types.h>
+NEXT_TIME_H = <time.h>
+NEXT_UNISTD_H = <unistd.h>
+NEXT_UTIME_H = <utime.h>
+NEXT_WCHAR_H = <wchar.h>
+OBJEXT = o
+PACKAGE = portage-utils
+PACKAGE_BUGREPORT = 
+PACKAGE_NAME = portage-utils
+PACKAGE_STRING = portage-utils git
+PACKAGE_TARNAME = portage-utils
+PACKAGE_URL = 
+PACKAGE_VERSION = git
+PATH_SEPARATOR = :
+PRAGMA_COLUMNS = 
+PRAGMA_SYSTEM_HEADER = #pragma GCC system_header
+PRIPTR_PREFIX = "l"
+PRI_MACROS_BROKEN = 0
+PTHREAD_H_DEFINES_STRUCT_TIMESPEC = 0
+PTRDIFF_T_SUFFIX = 
+RANLIB = ranlib
+REPLACE_ACOSF = 0
+REPLACE_ASINF = 0
+REPLACE_ATAN2F = 0
+REPLACE_ATANF = 0
+REPLACE_BTOWC = 0
+REPLACE_CALLOC = 0
+REPLACE_CANONICALIZE_FILE_NAME = 0
+REPLACE_CBRTF = 0
+REPLACE_CBRTL = 0
+REPLACE_CEIL = 0
+REPLACE_CEILF = 0
+REPLACE_CEILL = 0
+REPLACE_CHOWN = 0
+REPLACE_CLOSE = 0
+REPLACE_CLOSEDIR = 0
+REPLACE_COSF = 0
+REPLACE_COSHF = 0
+REPLACE_CTIME = GNULIB_PORTCHECK
+REPLACE_DIRFD = 0
+REPLACE_DPRINTF = 0
+REPLACE_DUP = 0
+REPLACE_DUP2 = 0
+REPLACE_EXP2 = 0
+REPLACE_EXP2L = 0
+REPLACE_EXPF = 0
+REPLACE_EXPM1 = 0
+REPLACE_EXPM1F = 0
+REPLACE_FABSL = 0
+REPLACE_FACCESSAT = 0
+REPLACE_FCHOWNAT = 0
+REPLACE_FCLOSE = 0
+REPLACE_FCNTL = 0
+REPLACE_FDOPEN = 0
+REPLACE_FDOPENDIR = 0
+REPLACE_FFLUSH = 0
+REPLACE_FLOOR = 0
+REPLACE_FLOORF = 0
+REPLACE_FLOORL = 0
+REPLACE_FMA = 0
+REPLACE_FMAF = 0
+REPLACE_FMAL = 0
+REPLACE_FMOD = 0
+REPLACE_FMODF = 0
+REPLACE_FMODL = 0
+REPLACE_FOPEN = 0
+REPLACE_FPRINTF = 0
+REPLACE_FPURGE = 0
+REPLACE_FREOPEN = 0
+REPLACE_FREXP = 0
+REPLACE_FREXPF = 0
+REPLACE_FREXPL = 1
+REPLACE_FSEEK = 0
+REPLACE_FSEEKO = 0
+REPLACE_FSTAT = 1
+REPLACE_FSTATAT = 1
+REPLACE_FTELL = 0
+REPLACE_FTELLO = 0
+REPLACE_FTRUNCATE = 0
+REPLACE_FUTIMENS = 1
+REPLACE_GETCWD = 1
+REPLACE_GETDELIM = 0
+REPLACE_GETDOMAINNAME = 0
+REPLACE_GETDTABLESIZE = 0
+REPLACE_GETGROUPS = 0
+REPLACE_GETLINE = 0
+REPLACE_GETLOGIN_R = 0
+REPLACE_GETPAGESIZE = 0
+REPLACE_GETTIMEOFDAY = 0
+REPLACE_GMTIME = 0
+REPLACE_HUGE_VAL = 0
+REPLACE_HYPOT = 0
+REPLACE_HYPOTF = 0
+REPLACE_HYPOTL = 0
+REPLACE_ILOGB = 0
+REPLACE_ILOGBF = 0
+REPLACE_ILOGBL = 0
+REPLACE_ISATTY = 0
+REPLACE_ISFINITE = 0
+REPLACE_ISINF = 0
+REPLACE_ISNAN = 0
+REPLACE_ITOLD = 0
+REPLACE_LCHOWN = 0
+REPLACE_LDEXPL = 0
+REPLACE_LINK = 0
+REPLACE_LINKAT = 0
+REPLACE_LOCALTIME = 0
+REPLACE_LOCALTIME_R = GNULIB_PORTCHECK
+REPLACE_LOG = 0
+REPLACE_LOG10 = 0
+REPLACE_LOG10F = 0
+REPLACE_LOG10L = 0
+REPLACE_LOG1P = 0
+REPLACE_LOG1PF = 0
+REPLACE_LOG1PL = 0
+REPLACE_LOG2 = 0
+REPLACE_LOG2F = 0
+REPLACE_LOG2L = 0
+REPLACE_LOGB = 0
+REPLACE_LOGBF = 0
+REPLACE_LOGBL = 0
+REPLACE_LOGF = 0
+REPLACE_LOGL = 0
+REPLACE_LSEEK = 0
+REPLACE_LSTAT = 1
+REPLACE_MALLOC = 0
+REPLACE_MBRLEN = 0
+REPLACE_MBRTOWC = 0
+REPLACE_MBSINIT = 0
+REPLACE_MBSNRTOWCS = 0
+REPLACE_MBSRTOWCS = 0
+REPLACE_MBSTATE_T = 0
+REPLACE_MBTOWC = 0
+REPLACE_MEMCHR = 0
+REPLACE_MEMMEM = 0
+REPLACE_MKDIR = 0
+REPLACE_MKFIFO = 0
+REPLACE_MKNOD = 0
+REPLACE_MKSTEMP = 0
+REPLACE_MKTIME = GNULIB_PORTCHECK
+REPLACE_MODF = 0
+REPLACE_MODFF = 0
+REPLACE_MODFL = 0
+REPLACE_NAN = 0
+REPLACE_NANOSLEEP = GNULIB_PORTCHECK
+REPLACE_NULL = 0
+REPLACE_OBSTACK_PRINTF = 0
+REPLACE_OPEN = 0
+REPLACE_OPENAT = 0
+REPLACE_OPENDIR = 0
+REPLACE_PERROR = 0
+REPLACE_POPEN = 0
+REPLACE_PREAD = 0
+REPLACE_PRINTF = 0
+REPLACE_PTSNAME = 0
+REPLACE_PTSNAME_R = 0
+REPLACE_PUTENV = 0
+REPLACE_PWRITE = 0
+REPLACE_QSORT_R = 0
+REPLACE_RANDOM_R = 0
+REPLACE_READ = 0
+REPLACE_READLINK = 0
+REPLACE_READLINKAT = 0
+REPLACE_REALLOC = 0
+REPLACE_REALPATH = 0
+REPLACE_REMAINDER = 0
+REPLACE_REMAINDERF = 0
+REPLACE_REMAINDERL = 0
+REPLACE_REMOVE = 0
+REPLACE_RENAME = 1
+REPLACE_RENAMEAT = 1
+REPLACE_RMDIR = 0
+REPLACE_ROUND = 0
+REPLACE_ROUNDF = 0
+REPLACE_ROUNDL = 0
+REPLACE_SETENV = 0
+REPLACE_SIGNBIT = 0
+REPLACE_SIGNBIT_USING_GCC = 1
+REPLACE_SINF = 0
+REPLACE_SINHF = 0
+REPLACE_SLEEP = 0
+REPLACE_SNPRINTF = 0
+REPLACE_SPRINTF = 0
+REPLACE_SQRTF = 0
+REPLACE_SQRTL = 0
+REPLACE_STAT = 0
+REPLACE_STDIO_READ_FUNCS = 0
+REPLACE_STDIO_WRITE_FUNCS = 0
+REPLACE_STPNCPY = 0
+REPLACE_STRCASESTR = 0
+REPLACE_STRCHRNUL = 0
+REPLACE_STRDUP = 0
+REPLACE_STRERROR = 0
+REPLACE_STRERROR_R = 0
+REPLACE_STRFTIME = GNULIB_PORTCHECK
+REPLACE_STRNCAT = 0
+REPLACE_STRNDUP = 0
+REPLACE_STRNLEN = 0
+REPLACE_STRSIGNAL = 0
+REPLACE_STRSTR = 0
+REPLACE_STRTOD = 0
+REPLACE_STRTOIMAX = 0
+REPLACE_STRTOK_R = 0
+REPLACE_STRTOUMAX = 0
+REPLACE_STRUCT_TIMEVAL = 0
+REPLACE_SYMLINK = 0
+REPLACE_SYMLINKAT = 0
+REPLACE_TANF = 0
+REPLACE_TANHF = 0
+REPLACE_TIMEGM = GNULIB_PORTCHECK
+REPLACE_TMPFILE = 0
+REPLACE_TRUNC = 0
+REPLACE_TRUNCATE = 0
+REPLACE_TRUNCF = 0
+REPLACE_TRUNCL = 0
+REPLACE_TTYNAME_R = 0
+REPLACE_TZSET = GNULIB_PORTCHECK
+REPLACE_UNLINK = 0
+REPLACE_UNLINKAT = 0
+REPLACE_UNSETENV = 0
+REPLACE_USLEEP = 0
+REPLACE_UTIME = 0
+REPLACE_UTIMENSAT = 0
+REPLACE_VASPRINTF = 1
+REPLACE_VDPRINTF = 0
+REPLACE_VFPRINTF = 0
+REPLACE_VPRINTF = 0
+REPLACE_VSNPRINTF = 0
+REPLACE_VSPRINTF = 0
+REPLACE_WCRTOMB = 0
+REPLACE_WCSFTIME = 0
+REPLACE_WCSNRTOMBS = 0
+REPLACE_WCSRTOMBS = 0
+REPLACE_WCSWIDTH = 0
+REPLACE_WCTOB = 0
+REPLACE_WCTOMB = 0
+REPLACE_WCWIDTH = 0
+REPLACE_WRITE = 0
+SET_MAKE = 
+SHELL = /bin/sh
+SIG_ATOMIC_T_SUFFIX = 
+SIZE_T_SUFFIX = 
+STDBOOL_H = 
+STDDEF_H = 
+STDINT_H = stdint.h
+STRIP = 
+SYS_TIME_H_DEFINES_STRUCT_TIMESPEC = 0
+TIME_H_DEFINES_STRUCT_TIMESPEC = 1
+UINT32_MAX_LT_UINTMAX_MAX = 1
+UINT64_MAX_EQ_ULONG_MAX = 1
+UNDEFINE_STRTOK_R = 0
+UNISTD_H_DEFINES_STRUCT_TIMESPEC = 0
+UNISTD_H_HAVE_WINSOCK2_H = 0
+UNISTD_H_HAVE_WINSOCK2_H_AND_USE_SOCKETS = 0
+UTIME_H = 
+VERSION = git
+WCHAR_T_SUFFIX = 
+WINDOWS_64_BIT_OFF_T = 0
+WINDOWS_64_BIT_ST_SIZE = 0
+WINDOWS_STAT_INODES = 0
+WINDOWS_STAT_TIMESPEC = 0
+WINT_T_SUFFIX = 
+abs_builddir = /net/ptah/export/gentoo/working-repos/portage-utils
+abs_srcdir = /net/ptah/export/gentoo/working-repos/portage-utils
+abs_top_builddir = /net/ptah/export/gentoo/working-repos/portage-utils
+abs_top_srcdir = /net/ptah/export/gentoo/working-repos/portage-utils
+ac_ct_CC = gcc
+am__include = include
+am__leading_dot = .
+am__quote = 
+am__tar = $${TAR-tar} chof - "$$tardir"
+am__untar = $${TAR-tar} xf -
+bindir = ${exec_prefix}/bin
+build = x86_64-pc-solaris2.11
+build_alias = 
+build_cpu = x86_64
+build_os = solaris2.11
+build_vendor = pc
+builddir = .
+datadir = ${datarootdir}
+datarootdir = ${prefix}/share
+docdir = ${datarootdir}/doc/${PACKAGE_TARNAME}
+dvidir = ${docdir}
+exec_prefix = ${prefix}
+gl_LIBOBJS =  asnprintf.o asprintf.o chdir-long.o error.o euidaccess.o frexpl.o fstat.o fstatat.o futimens.o getcwd-lgpl.o group-member.o localtime-buffer.o lstat.o mempcpy.o memrchr.o openat-proc.o printf-args.o printf-parse.o rename.o renameat.o vasnprintf.o vasprintf.o
+gl_LTLIBOBJS =  asnprintf.lo asprintf.lo chdir-long.lo error.lo euidaccess.lo frexpl.lo fstat.lo fstatat.lo futimens.lo getcwd-lgpl.lo group-member.lo localtime-buffer.lo lstat.lo mempcpy.lo memrchr.lo openat-proc.lo printf-args.lo printf-parse.lo rename.lo renameat.lo vasnprintf.lo vasprintf.lo
+gltests_LIBOBJS = 
+gltests_LTLIBOBJS = 
+gltests_WITNESS = IN_PORTAGE_UTILS_GNULIB_TESTS
+host = x86_64-pc-solaris2.11
+host_alias = 
+host_cpu = x86_64
+host_os = solaris2.11
+host_vendor = pc
+htmldir = ${docdir}
+includedir = ${prefix}/include
+infodir = ${datarootdir}/info
+install_sh = ${SHELL} /net/ptah/export/gentoo/working-repos/portage-utils/autotools/install-sh
+libdir = ${exec_prefix}/lib
+libexecdir = ${exec_prefix}/libexec
+localedir = ${datarootdir}/locale
+localstatedir = ${prefix}/var
+mandir = ${datarootdir}/man
+mkdir_p = $(MKDIR_P)
+oldincludedir = /usr/include
+pdfdir = ${docdir}
+prefix = /usr/local
+program_transform_name = s,x,x,
+psdir = ${docdir}
+sbindir = ${exec_prefix}/sbin
+sharedstatedir = ${prefix}/com
+srcdir = .
+sysconfdir = ${prefix}/etc
+target_alias = 
+top_build_prefix = 
+top_builddir = .
+top_srcdir = .
+ACLOCAL_AMFLAGS = -I autotools/m4
+SUBDIRS = autotools/gnulib
+portagedir = $(sysconfdir)/portage
+postsyncddir = $(portagedir)/repo.postsync.d
+dist_postsyncd_SCRIPTS = repo.postsync/q-reinit
+q_SOURCES = main.c
+
+# @@@ GEN START @@@ #
+q_CPPFLAGS = -I$(top_builddir)/autotools/gnulib \
+	-I$(top_srcdir)/autotools/gnulib -DAPPLET_q -DAPPLET_qatom \
+	-DAPPLET_qcache -DAPPLET_qcheck -DAPPLET_qdepends \
+	-DAPPLET_qfile -DAPPLET_qgrep -DAPPLET_qlist -DAPPLET_qlop \
+	-DAPPLET_qmerge -DAPPLET_qpkg -DAPPLET_qsearch -DAPPLET_qsize \
+	-DAPPLET_qtbz2 -DAPPLET_quse -DAPPLET_qxpak
+q_LDADD = \
+	$(top_builddir)/autotools/gnulib/libgnu.a \
+	-liniparser \
+	$(LIB_CLOCK_GETTIME) \
+	$(LIB_EACCESS)
+
+TMAKE = \
+	$(MAKE) -C $(abs_top_srcdir)/tests \
+		AUTOTOOLS=true \
+		abs_top_builddir="$(abs_top_builddir)" \
+		abs_top_srcdir="$(abs_top_srcdir)"
+
+
+# Start off with base values which we append below
+dist_man_MANS = man/q.1 man/qatom.1 man/qcache.1 man/qcheck.1 \
+	man/qdepends.1 man/qfile.1 man/qgrep.1 man/qlist.1 man/qlop.1 \
+	man/qmerge.1 man/qpkg.1 man/qsearch.1 man/qsize.1 man/qtbz2.1 \
+	man/quse.1 man/qxpak.1
+APPLETS = q qatom qcache qcheck qdepends qfile qgrep qlist qlop qmerge \
+	qpkg qsearch qsize qtbz2 quse qxpak
+EXTRA_DIST = autotools/m4/gnulib-cache.m4 applets.h config.h \
+	include_applets.h libq/atom_compare.c libq/atom_explode.c \
+	libq/basename.c libq/busybox.h libq/colors.c libq/compat.c \
+	libq/copy_file.c libq/hash_fd.c libq/human_readable.c \
+	libq/i18n.h libq/libq.c libq/libq.h libq/md5_sha1_sum.c \
+	libq/prelink.c libq/profile.c libq/rmspace.c libq/safe_io.c \
+	libq/scandirat.c libq/vdb.c libq/vdb_get_next_dir.c \
+	libq/virtuals.c libq/xarray.c libq/xasprintf.c libq/xchdir.c \
+	libq/xmalloc.c libq/xmkdir.c libq/xregex.c libq/xstrdup.c \
+	libq/xsystem.c main.c main.h porting.h q.c qatom.c qcache.c \
+	qcheck.c qdepends.c qfile.c qglsa.c qgrep.c qlist.c qlop.c \
+	qmerge.c qpkg.c qsearch.c qsize.c qtbz2.c quse.c qxpak.c \
+	tests/Makefile tests/atom_compare/.gitignore \
+	tests/atom_compare/Makefile tests/atom_compare/atom-compare.py \
+	tests/atom_compare/static.good \
+	tests/atom_compare/static.q.good \
+	tests/atom_compare/static.q.tests \
+	tests/atom_compare/static.tests tests/atom_explode/.gitignore \
+	tests/atom_explode/Makefile tests/atom_explode/atom-explode.py \
+	tests/atom_explode/basic.good tests/atom_explode/basic.tests \
+	tests/atom_explode/dotest tests/atom_explode/test.c \
+	tests/copy_file/.gitignore tests/copy_file/Makefile \
+	tests/copy_file/dotest tests/copy_file/test.c tests/init.sh \
+	tests/install/.gitignore tests/install/Makefile \
+	tests/install/dotest tests/mkdir/.gitignore \
+	tests/mkdir/Makefile tests/mkdir/dotest tests/mkdir/test.c \
+	tests/profile/Makefile tests/profile/dotest \
+	tests/profile/profile1/etc/parent.conf \
+	tests/profile/profile1/etc/portage/make.conf \
+	tests/profile/profile1/etc/portage/subdir/file.conf \
+	tests/profile/profile1/etc/portage/this.level.conf \
+	tests/qatom/Makefile tests/qatom/dotest tests/qcheck/Makefile \
+	tests/qcheck/dotest tests/qcheck/list01.good \
+	tests/qcheck/list02.good tests/qcheck/list03.good \
+	tests/qcheck/list04.good tests/qcheck/list05.good \
+	tests/qcheck/list06.good tests/qcheck/list07.good \
+	tests/qcheck/list08.good tests/qcheck/list09.good \
+	tests/qcheck/root/a-b/pkg-1.0/CONTENTS \
+	tests/qcheck/root/a-b/pkg-1.0/SLOT \
+	tests/qcheck/root/a-b/pkg-1.0/repository \
+	tests/qcheck/root/bin/bad-md5 tests/qcheck/root/bin/bad-mtime \
+	tests/qcheck/root/bin/bad-mtime-obj \
+	tests/qcheck/root/bin/bad-sha1 tests/qcheck/root/bin/good-md5 \
+	tests/qcheck/root/bin/good-sha1 \
+	tests/qcheck/root/cat/pkg-1/CONTENTS \
+	tests/qcheck/root/cat/pkg-1/SLOT \
+	tests/qcheck/root/cat/pkg-1/repository tests/qdepends/Makefile \
+	tests/qdepends/dotest tests/qdepends/list01.good \
+	tests/qdepends/list02.good tests/qdepends/list03.good \
+	tests/qdepends/list04.good tests/qdepends/list05.good \
+	tests/qdepends/list06.good tests/qdepends/list07.good \
+	tests/qdepends/list08.good \
+	tests/qdepends/root/app-arch/cpio-2.11/CONTENTS \
+	tests/qdepends/root/app-arch/cpio-2.11/SLOT \
+	tests/qdepends/root/app-arch/cpio-2.11/repository \
+	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/DEPEND \
+	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/RDEPEND \
+	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/USE \
+	tests/qfile/Makefile tests/qfile/dotest tests/qlist/Makefile \
+	tests/qlist/dotest tests/qlist/list01.good \
+	tests/qlist/list02.good tests/qlist/list03.good \
+	tests/qlist/list04.good tests/qlist/list05.good \
+	tests/qlist/list06.good tests/qlist/list07.good \
+	tests/qlist/list08.good tests/qlist/list09.good \
+	tests/qlist/list10.good tests/qlist/list11.good \
+	tests/qlist/list12.good tests/qlist/list13.good \
+	tests/qlist/list14.good tests/qlist/list15.good \
+	tests/qlist/list16.good tests/qlist/root/-merge-foo/CONTENTS \
+	tests/qlist/root/a-b/a-0/CONTENTS \
+	tests/qlist/root/a-b/a-0/SLOT \
+	tests/qlist/root/a-b/a-0/repository \
+	tests/qlist/root/a-b/b-0/CONTENTS \
+	tests/qlist/root/a-b/b-0/SLOT \
+	tests/qlist/root/a-b/b-0/repository \
+	tests/qlist/root/app-arch/cpio-2.11/CONTENTS \
+	tests/qlist/root/app-arch/cpio-2.11/SLOT \
+	tests/qlist/root/app-arch/cpio-2.11/repository \
+	tests/qlist/root/cat/pkg-1/CONTENTS \
+	tests/qlist/root/cat/pkg-1/SLOT \
+	tests/qlist/root/cat/pkg-1/repository \
+	tests/qlist/root/cat/sub-2/CONTENTS \
+	tests/qlist/root/cat/sub-2/SLOT \
+	tests/qlist/root/cat/sub-2/repository \
+	tests/qlist/root/sys-fs/mtools-4.0.13/CONTENTS \
+	tests/qlist/root/sys-fs/mtools-4.0.13/SLOT \
+	tests/qlist/root/sys-fs/mtools-4.0.13/repository \
+	tests/qlop/Makefile tests/qlop/dotest tests/qlop/list01.good \
+	tests/qlop/list02.good tests/qlop/list03.good \
+	tests/qlop/list04.good tests/qlop/list05.good \
+	tests/qlop/list06.good tests/qlop/list07.good \
+	tests/qlop/list08.good tests/qlop/sync.log \
+	tests/qlop/test04.good tests/qmerge/Makefile \
+	tests/qmerge/dotest tests/qmerge/packages/Packages \
+	tests/qmerge/packages/sys-devel/qmerge-test-1.3.tbz2 \
+	tests/qtbz2/Makefile tests/qtbz2/dotest tests/quse/Makefile \
+	tests/quse/dotest tests/quse/list01.good \
+	tests/quse/portdir/profiles/arch.list \
+	tests/quse/portdir/profiles/desc/elibc.desc \
+	tests/quse/portdir/profiles/desc/one.desc \
+	tests/quse/portdir/profiles/desc/two.desc \
+	tests/quse/portdir/profiles/use.desc \
+	tests/quse/portdir/profiles/use.local.desc \
+	tests/qxpak/Makefile tests/qxpak/dotest \
+	tests/qxpak/list01.good tests/qxpak/list02.good \
+	tests/reinitialize/Makefile tests/reinitialize/dotest \
+	tests/rmspace/.gitignore tests/rmspace/Makefile \
+	tests/rmspace/dotest tests/rmspace/test.c \
+	tests/source/Makefile tests/source/dotest tests/source/space \
+	tests/subdir.mk tests/tests.h
+all: config.h
+	$(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
+am--refresh: Makefile
+	@:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
+	      $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
+	$(am__cd) $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    echo ' $(SHELL) ./config.status'; \
+	    $(SHELL) ./config.status;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	$(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	$(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	$(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+
+config.h: stamp-h1
+	@test -f $@ || rm -f stamp-h1
+	@test -f $@ || $(MAKE) $(AM_MAKEFLAGS) stamp-h1
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+	@rm -f stamp-h1
+	cd $(top_builddir) && $(SHELL) ./config.status config.h
+$(srcdir)/config.h.in:  $(am__configure_deps) 
+	($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+	rm -f stamp-h1
+	touch $@
+
+distclean-hdr:
+	-rm -f config.h stamp-h1
+install-binPROGRAMS: $(bin_PROGRAMS)
+	@$(NORMAL_INSTALL)
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(bindir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(bindir)" || exit 1; \
+	fi; \
+	for p in $$list; do echo "$$p $$p"; done | \
+	sed 's/$(EXEEXT)$$//' | \
+	while read p p1; do if test -f $$p \
+	  ; then echo "$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n;h' \
+	    -e 's|.*|.|' \
+	    -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+	sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) files[d] = files[d] " " $$1; \
+	    else { print "f", $$3 "/" $$4, $$1; } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	    if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	    test -z "$$files" || { \
+	      echo " $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+	      $(INSTALL_PROGRAM_ENV) $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+	    } \
+	; done
+
+uninstall-binPROGRAMS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	  sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+	      -e 's/$$/$(EXEEXT)/' \
+	`; \
+	test -n "$$list" || exit 0; \
+	echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+	cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+	-test -z "$(bin_PROGRAMS)" || rm -f $(bin_PROGRAMS)
+
+q$(EXEEXT): $(q_OBJECTS) $(q_DEPENDENCIES) $(EXTRA_q_DEPENDENCIES) 
+	@rm -f q$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(q_OBJECTS) $(q_LDADD) $(LIBS)
+install-dist_postsyncdSCRIPTS: $(dist_postsyncd_SCRIPTS)
+	@$(NORMAL_INSTALL)
+	@list='$(dist_postsyncd_SCRIPTS)'; test -n "$(postsyncddir)" || list=; \
+	if test -n "$$list"; then \
+	  echo " $(MKDIR_P) '$(DESTDIR)$(postsyncddir)'"; \
+	  $(MKDIR_P) "$(DESTDIR)$(postsyncddir)" || exit 1; \
+	fi; \
+	for p in $$list; do \
+	  if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+	  if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+	done | \
+	sed -e 'p;s,.*/,,;n' \
+	    -e 'h;s|.*|.|' \
+	    -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+	$(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+	  { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+	    if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+	      if (++n[d] == $(am__install_max)) { \
+		print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+	    else { print "f", d "/" $$4, $$1 } } \
+	  END { for (d in files) print "f", d, files[d] }' | \
+	while read type dir files; do \
+	     if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+	     test -z "$$files" || { \
+	       echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(postsyncddir)$$dir'"; \
+	       $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(postsyncddir)$$dir" || exit $$?; \
+	     } \
+	; done
+
+uninstall-dist_postsyncdSCRIPTS:
+	@$(NORMAL_UNINSTALL)
+	@list='$(dist_postsyncd_SCRIPTS)'; test -n "$(postsyncddir)" || exit 0; \
+	files=`for p in $$list; do echo "$$p"; done | \
+	       sed -e 's,.*/,,;$(transform)'`; \
+	dir='$(DESTDIR)$(postsyncddir)'; $(am__uninstall_files_from_dir)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+include ./$(DEPDIR)/q-main.Po
+
+.c.o:
+	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
+	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+#	$(AM_V_CC)source='$<' object='$@' libtool=no \
+#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+#	$(AM_V_CC_no)$(COMPILE) -c -o $@ $<
+
+.c.obj:
+	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ `$(CYGPATH_W) '$<'`
+	$(AM_V_at)$(am__mv) $(DEPDIR)/$*.Tpo $(DEPDIR)/$*.Po
+#	$(AM_V_CC)source='$<' object='$@' libtool=no \
+#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+#	$(AM_V_CC_no)$(COMPILE) -c -o $@ `$(CYGPATH_W) '$<'`
+
+q-main.o: main.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(q_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT q-main.o -MD -MP -MF $(DEPDIR)/q-main.Tpo -c -o q-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
+	$(AM_V_at)$(am__mv) $(DEPDIR)/q-main.Tpo $(DEPDIR)/q-main.Po
+#	$(AM_V_CC)source='main.c' object='q-main.o' libtool=no \
+#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+#	$(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(q_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o q-main.o `test -f 'main.c' || echo '$(srcdir)/'`main.c
+
+q-main.obj: main.c
+	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(q_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT q-main.obj -MD -MP -MF $(DEPDIR)/q-main.Tpo -c -o q-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
+	$(AM_V_at)$(am__mv) $(DEPDIR)/q-main.Tpo $(DEPDIR)/q-main.Po
+#	$(AM_V_CC)source='main.c' object='q-main.obj' libtool=no \
+#	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) \
+#	$(AM_V_CC_no)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(q_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o q-main.obj `if test -f 'main.c'; then $(CYGPATH_W) 'main.c'; else $(CYGPATH_W) '$(srcdir)/main.c'; fi`
+install-man1: $(dist_man_MANS)
+	@$(NORMAL_INSTALL)
+	@list1=''; \
+	list2='$(dist_man_MANS)'; \
+	test -n "$(man1dir)" \
+	  && test -n "`echo $$list1$$list2`" \
+	  || exit 0; \
+	echo " $(MKDIR_P) '$(DESTDIR)$(man1dir)'"; \
+	$(MKDIR_P) "$(DESTDIR)$(man1dir)" || exit 1; \
+	{ for i in $$list1; do echo "$$i"; done;  \
+	if test -n "$$list2"; then \
+	  for i in $$list2; do echo "$$i"; done \
+	    | sed -n '/\.1[a-z]*$$/p'; \
+	fi; \
+	} | while read p; do \
+	  if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+	  echo "$$d$$p"; echo "$$p"; \
+	done | \
+	sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+	sed 'N;N;s,\n, ,g' | { \
+	list=; while read file base inst; do \
+	  if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+	    echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+	    $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
+	  fi; \
+	done; \
+	for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+	while read files; do \
+	  test -z "$$files" || { \
+	    echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
+	    $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
+	done; }
+
+uninstall-man1:
+	@$(NORMAL_UNINSTALL)
+	@list=''; test -n "$(man1dir)" || exit 0; \
+	files=`{ for i in $$list; do echo "$$i"; done; \
+	l2='$(dist_man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+	  sed -n '/\.1[a-z]*$$/p'; \
+	} | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+	      -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+	dir='$(DESTDIR)$(man1dir)'; $(am__uninstall_files_from_dir)
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run 'make' without going through this Makefile.
+# To change the values of 'make' variables: instead of editing Makefiles,
+# (1) if the variable is set in 'config.status', edit 'config.status'
+#     (which will cause the Makefiles to be regenerated when you run 'make');
+# (2) otherwise, pass the desired values on the 'make' command line.
+$(am__recursive_targets):
+	@fail=; \
+	if $(am__make_keepgoing); then \
+	  failcom='fail=yes'; \
+	else \
+	  failcom='exit 1'; \
+	fi; \
+	dot_seen=no; \
+	target=`echo $@ | sed s/-recursive//`; \
+	case "$@" in \
+	  distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+	  *) list='$(SUBDIRS)' ;; \
+	esac; \
+	for subdir in $$list; do \
+	  echo "Making $$target in $$subdir"; \
+	  if test "$$subdir" = "."; then \
+	    dot_seen=yes; \
+	    local_target="$$target-am"; \
+	  else \
+	    local_target="$$target"; \
+	  fi; \
+	  ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+	  || eval $$failcom; \
+	done; \
+	if test "$$dot_seen" = "no"; then \
+	  $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+	fi; test -z "$$fail"
+
+ID: $(am__tagged_files)
+	$(am__define_uniq_tagged_files); mkid -fID $$unique
+tags: tags-recursive
+TAGS: tags
+
+tags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	set x; \
+	here=`pwd`; \
+	if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+	  include_option=--etags-include; \
+	  empty_fix=.; \
+	else \
+	  include_option=--include; \
+	  empty_fix=; \
+	fi; \
+	list='$(SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    test ! -f $$subdir/TAGS || \
+	      set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+	  fi; \
+	done; \
+	$(am__define_uniq_tagged_files); \
+	shift; \
+	if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  if test $$# -gt 0; then \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      "$$@" $$unique; \
+	  else \
+	    $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	      $$unique; \
+	  fi; \
+	fi
+ctags: ctags-recursive
+
+CTAGS: ctags
+ctags-am: $(TAGS_DEPENDENCIES) $(am__tagged_files)
+	$(am__define_uniq_tagged_files); \
+	test -z "$(CTAGS_ARGS)$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && $(am__cd) $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) "$$here"
+cscope: cscope.files
+	test ! -s cscope.files \
+	  || $(CSCOPE) -b -q $(AM_CSCOPEFLAGS) $(CSCOPEFLAGS) -i cscope.files $(CSCOPE_ARGS)
+clean-cscope:
+	-rm -f cscope.files
+cscope.files: clean-cscope cscopelist
+cscopelist: cscopelist-recursive
+
+cscopelist-am: $(am__tagged_files)
+	list='$(am__tagged_files)'; \
+	case "$(srcdir)" in \
+	  [\\/]* | ?:[\\/]*) sdir="$(srcdir)" ;; \
+	  *) sdir=$(subdir)/$(srcdir) ;; \
+	esac; \
+	for i in $$list; do \
+	  if test -f "$$i"; then \
+	    echo "$(subdir)/$$i"; \
+	  else \
+	    echo "$$sdir/$$i"; \
+	  fi; \
+	done >> $(top_builddir)/cscope.files
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+	-rm -f cscope.out cscope.in.out cscope.po.out cscope.files
+
+distdir: $(DISTFILES)
+	$(am__remove_distdir)
+	test -d "$(distdir)" || mkdir "$(distdir)"
+	@srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+	list='$(DISTFILES)'; \
+	  dist_files=`for file in $$list; do echo $$file; done | \
+	  sed -e "s|^$$srcdirstrip/||;t" \
+	      -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+	case $$dist_files in \
+	  */*) $(MKDIR_P) `echo "$$dist_files" | \
+			   sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+			   sort -u` ;; \
+	esac; \
+	for file in $$dist_files; do \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  if test -d $$d/$$file; then \
+	    dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+	    if test -d "$(distdir)/$$file"; then \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+	      find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+	    fi; \
+	    cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+	  else \
+	    test -f "$(distdir)/$$file" \
+	    || cp -p $$d/$$file "$(distdir)/$$file" \
+	    || exit 1; \
+	  fi; \
+	done
+	@list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+	  if test "$$subdir" = .; then :; else \
+	    $(am__make_dryrun) \
+	      || test -d "$(distdir)/$$subdir" \
+	      || $(MKDIR_P) "$(distdir)/$$subdir" \
+	      || exit 1; \
+	    dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+	    $(am__relativize); \
+	    new_distdir=$$reldir; \
+	    dir1=$$subdir; dir2="$(top_distdir)"; \
+	    $(am__relativize); \
+	    new_top_distdir=$$reldir; \
+	    echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+	    echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+	    ($(am__cd) $$subdir && \
+	      $(MAKE) $(AM_MAKEFLAGS) \
+	        top_distdir="$$new_top_distdir" \
+	        distdir="$$new_distdir" \
+		am__remove_distdir=: \
+		am__skip_length_check=: \
+		am__skip_mode_fix=: \
+	        distdir) \
+	      || exit 1; \
+	  fi; \
+	done
+	-test -n "$(am__skip_mode_fix)" \
+	|| find "$(distdir)" -type d ! -perm -755 \
+		-exec chmod u+rwx,go+rx {} \; -o \
+	  ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+	  ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+	|| chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+	tardir=$(distdir) && $(am__tar) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).tar.gz
+	$(am__post_remove_distdir)
+
+dist-bzip2: distdir
+	tardir=$(distdir) && $(am__tar) | BZIP2=$${BZIP2--9} bzip2 -c >$(distdir).tar.bz2
+	$(am__post_remove_distdir)
+
+dist-lzip: distdir
+	tardir=$(distdir) && $(am__tar) | lzip -c $${LZIP_OPT--9} >$(distdir).tar.lz
+	$(am__post_remove_distdir)
+dist-xz: distdir
+	tardir=$(distdir) && $(am__tar) | XZ_OPT=$${XZ_OPT--e} xz -c >$(distdir).tar.xz
+	$(am__post_remove_distdir)
+
+dist-tarZ: distdir
+	@echo WARNING: "Support for distribution archives compressed with" \
+		       "legacy program 'compress' is deprecated." >&2
+	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
+	tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+	$(am__post_remove_distdir)
+
+dist-shar: distdir
+	@echo WARNING: "Support for shar distribution archives is" \
+	               "deprecated." >&2
+	@echo WARNING: "It will be removed altogether in Automake 2.0" >&2
+	shar $(distdir) | eval GZIP= gzip $(GZIP_ENV) -c >$(distdir).shar.gz
+	$(am__post_remove_distdir)
+
+dist-zip: distdir
+	-rm -f $(distdir).zip
+	zip -rq $(distdir).zip $(distdir)
+	$(am__post_remove_distdir)
+
+dist dist-all:
+	$(MAKE) $(AM_MAKEFLAGS) $(DIST_TARGETS) am__post_remove_distdir='@:'
+	$(am__post_remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
 distcheck: dist
-	rm -rf portage-utils-$(PV)
-	tar xf portage-utils-$(PV).tar.xz
-	$(MAKE) -C portage-utils-$(PV)
-	$(MAKE) -C portage-utils-$(PV) check
-	rm -rf portage-utils-$(PV)
-
-clean:
-	-rm -f q $(APPLETS)
-	$(MAKE) -C tests clean
-distclean: clean testclean
-	-rm -f *~ core .#*
-	-rm -f `find . -type l`
-
-testclean:
-	cd tests && $(MAKE) clean
-
-install: all
-	$(MKDIR) $(PREFIX)/bin/
-	$(INSTALL_EXE) q $(PREFIX)/bin/
-
-	set -e ; \
-	for applet in $(filter-out q,$(APPLETS)) ; do \
-		ln -sf q $(PREFIX)/bin/$${applet} ; \
+	case '$(DIST_ARCHIVES)' in \
+	*.tar.gz*) \
+	  eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).tar.gz | $(am__untar) ;;\
+	*.tar.bz2*) \
+	  bzip2 -dc $(distdir).tar.bz2 | $(am__untar) ;;\
+	*.tar.lz*) \
+	  lzip -dc $(distdir).tar.lz | $(am__untar) ;;\
+	*.tar.xz*) \
+	  xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+	*.tar.Z*) \
+	  uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+	*.shar.gz*) \
+	  eval GZIP= gzip $(GZIP_ENV) -dc $(distdir).shar.gz | unshar ;;\
+	*.zip*) \
+	  unzip $(distdir).zip ;;\
+	esac
+	chmod -R a-w $(distdir)
+	chmod u+w $(distdir)
+	mkdir $(distdir)/_build $(distdir)/_build/sub $(distdir)/_inst
+	chmod a-w $(distdir)
+	test -d $(distdir)/_build || exit 0; \
+	dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+	  && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+	  && am__cwd=`pwd` \
+	  && $(am__cd) $(distdir)/_build/sub \
+	  && ../../configure \
+	    $(AM_DISTCHECK_CONFIGURE_FLAGS) \
+	    $(DISTCHECK_CONFIGURE_FLAGS) \
+	    --srcdir=../.. --prefix="$$dc_install_base" \
+	  && $(MAKE) $(AM_MAKEFLAGS) \
+	  && $(MAKE) $(AM_MAKEFLAGS) dvi \
+	  && $(MAKE) $(AM_MAKEFLAGS) check \
+	  && $(MAKE) $(AM_MAKEFLAGS) install \
+	  && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+	  && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+	  && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+	        distuninstallcheck \
+	  && chmod -R a-w "$$dc_install_base" \
+	  && ({ \
+	       (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+	       && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+	            distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+	      } || { rm -rf "$$dc_destdir"; exit 1; }) \
+	  && rm -rf "$$dc_destdir" \
+	  && $(MAKE) $(AM_MAKEFLAGS) dist \
+	  && rm -rf $(DIST_ARCHIVES) \
+	  && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+	  && cd "$$am__cwd" \
+	  || exit 1
+	$(am__post_remove_distdir)
+	@(echo "$(distdir) archives ready for distribution: "; \
+	  list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+	  sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+	@test -n '$(distuninstallcheck_dir)' || { \
+	  echo 'ERROR: trying to run $@ with an empty' \
+	       '$$(distuninstallcheck_dir)' >&2; \
+	  exit 1; \
+	}; \
+	$(am__cd) '$(distuninstallcheck_dir)' || { \
+	  echo 'ERROR: cannot chdir into $(distuninstallcheck_dir)' >&2; \
+	  exit 1; \
+	}; \
+	test `$(am__distuninstallcheck_listfiles) | wc -l` -eq 0 \
+	   || { echo "ERROR: files left after uninstall:" ; \
+	        if test -n "$(DESTDIR)"; then \
+	          echo "  (check DESTDIR support)"; \
+	        fi ; \
+	        $(distuninstallcheck_listfiles) ; \
+	        exit 1; } >&2
+distcleancheck: distclean
+	@if test '$(srcdir)' = . ; then \
+	  echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+	  exit 1 ; \
+	fi
+	@test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+	  || { echo "ERROR: files left in build directory after distclean:" ; \
+	       $(distcleancheck_listfiles) ; \
+	       exit 1; } >&2
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(PROGRAMS) $(SCRIPTS) $(MANS) config.h
+installdirs: installdirs-recursive
+installdirs-am:
+	for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(postsyncddir)" "$(DESTDIR)$(man1dir)"; do \
+	  test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+	done
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+install-strip:
+	if test -z '$(STRIP)'; then \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	      install; \
+	else \
+	  $(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	    install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	    "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'" install; \
+	fi
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-binPROGRAMS clean-generic clean-local mostlyclean-am
+
+distclean: distclean-recursive
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-hdr distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am: install-dist_postsyncdSCRIPTS install-man
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+	@$(NORMAL_INSTALL)
+	$(MAKE) $(AM_MAKEFLAGS) install-exec-hook
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man: install-man1
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+	-rm -f $(am__CONFIG_DISTCLEAN_FILES)
+	-rm -rf $(top_srcdir)/autom4te.cache
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-dist_postsyncdSCRIPTS \
+	uninstall-man
+
+uninstall-man: uninstall-man1
+
+.MAKE: $(am__recursive_targets) all install-am install-exec-am \
+	install-strip
+
+.PHONY: $(am__recursive_targets) CTAGS GTAGS TAGS all all-am \
+	am--refresh check check-am clean clean-binPROGRAMS \
+	clean-cscope clean-generic clean-local cscope cscopelist-am \
+	ctags ctags-am dist dist-all dist-bzip2 dist-gzip dist-lzip \
+	dist-shar dist-tarZ dist-xz dist-zip distcheck distclean \
+	distclean-compile distclean-generic distclean-hdr \
+	distclean-tags distcleancheck distdir distuninstallcheck dvi \
+	dvi-am html html-am info info-am install install-am \
+	install-binPROGRAMS install-data install-data-am \
+	install-dist_postsyncdSCRIPTS install-dvi install-dvi-am \
+	install-exec install-exec-am install-exec-hook install-html \
+	install-html-am install-info install-info-am install-man \
+	install-man1 install-pdf install-pdf-am install-ps \
+	install-ps-am install-strip installcheck installcheck-am \
+	installdirs installdirs-am maintainer-clean \
+	maintainer-clean-generic mostlyclean mostlyclean-compile \
+	mostlyclean-generic pdf pdf-am ps ps-am tags tags-am uninstall \
+	uninstall-am uninstall-binPROGRAMS \
+	uninstall-dist_postsyncdSCRIPTS uninstall-man uninstall-man1
+
+.PRECIOUS: Makefile
+
+
+install-exec-hook:
+	cd $(DESTDIR)$(bindir); \
+	for applet in $(APPLETS) ; do \
+		[ ! -e "$$applet" ] && ln -s q $${applet} ; \
 	done
+check-hook:
+	$(TMAKE) check
+clean-local:
+	$(TMAKE) clean
+	-rmdir tests/*/ tests/
+	rm -f $(APPLETS)
+check: check-hook
+# @@@ GEN START @@@ #
 
-	$(MKDIR) $(ETCDIR)/portage/repo.postsync.d
-	$(INSTALL_EXE) repo.postsync/* $(ETCDIR)/portage/repo.postsync.d/
-
-ifneq ($(wildcard man/*.1),)
-	$(MKDIR) $(PREFIX)/share/man/man1/
-	cp $(wildcard man/*.1) $(PREFIX)/share/man/man1/
-endif
-
-	$(MKDIR) $(PREFIX)/share/doc/$(PF)
-	cp $(DOCS) $(PREFIX)/share/doc/$(PF)/
-
-man: q
-	./man/mkman.py
-
-symlinks: q
-	./q --install
-
--include .depend
-
-.PHONY: all check clean debug dist distclean install man symlinks testclean
-
-#
-# All logic related to autotools is below here
-#
-GEN_MARK_START = \# @@@ GEN START @@@ \#
-GEN_MARK_END   = \# @@@ GEN START @@@ \#
-EXTRA_DIST = \
-	$(SRC) \
-	qglsa.c \
-	$(wildcard libq/*.c *.h libq/*.h) \
-	$(shell find tests -type f)
-MAKE_MULTI_LINES = $(patsubst %,\\\\\n\t%,$(sort $(1)))
-# 2nd level of indirection here is so the $(find) doesn't pick up
-# files in EXTRA_DIST that get cleaned up ...
-autotools-update: clean
-	$(MAKE) _autotools-update
-_autotools-update:
-	sed -i '/^$(GEN_MARK_START)$$/,/^$(GEN_MARK_END)$$/d' Makefile.am
-	printf '%s\nq_CPPFLAGS += %b\ndist_man_MANS += %b\nAPPLETS += %b\nEXTRA_DIST += %b\n%s\n' \
-		"$(GEN_MARK_START)" \
-		"$(call MAKE_MULTI_LINES,$(APP_FLAGS))" \
-		"$(call MAKE_MULTI_LINES,$(wildcard man/*.1))" \
-		"$(call MAKE_MULTI_LINES,$(APPLETS))" \
-		"$(call MAKE_MULTI_LINES,$(EXTRA_DIST))" \
-		"$(GEN_MARK_END)" \
-		>> Makefile.am
-autotools: autotools-update
-	./autogen.sh --from=make
-
-.PHONY: autotools autotools-update _autotools-update
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:

diff --git a/qlop.c b/qlop.c
index 7bac8c2..a042fa7 100644
--- a/qlop.c
+++ b/qlop.c
@@ -760,10 +760,10 @@ parse_date(const char *sdate, time_t *t)
 
 			if (ret < 2) {
 				if (strcmp(sdate, "today") == 0) {
-					num = 0;
+					num = 1;
 					snprintf(dur, len, "%s", "day");
 				} else if (strcmp(sdate, "yesterday") == 0) {
-					num = 1;
+					num = 2;
 					snprintf(dur, len, "%s", "day");
 				} else {
 					return false;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-04-09  7:15 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-04-09  7:15 UTC (permalink / raw
  To: gentoo-commits

commit:     3ba7c294e8aa701c38a251728843c1a954f68c38
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr  5 18:23:54 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr  5 18:23:54 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3ba7c294

Revert "qmerge: Only fetch Packages if -f/-F is specified"

This commit changed the logic from fetching Packages when -f is set, to
forcing when -F is set.  This is contradicting the documented behaviour
and broke the tests.

It is not clear to me anymore why this change was necessary, so I'm
reverging it.

This reverts commit eedb0ea266b78efd84bc34bc2c6602fb713ba590.

 qmerge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 960a9a4..583e4fb 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -190,8 +190,8 @@ qmerge_initialize(void)
 	mkdir_p(buf, 0755);
 	xchdir(buf);
 
-	if (force_download) {
-		if (force_download == 2)
+	if (force_download != 2) {
+		if (force_download)
 			unlink(Packages);
 
 		if (access(Packages, R_OK) != 0)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-04-09  7:15 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-04-09  7:15 UTC (permalink / raw
  To: gentoo-commits

commit:     975186ebc35cc417c198ec922bcbc77226cdb05f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr  5 18:46:03 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr  5 18:49:34 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=975186eb

make-tarball: use numeric uid/gid

 make-tarball.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/make-tarball.sh b/make-tarball.sh
index 02cc501..4f8eed7 100755
--- a/make-tarball.sh
+++ b/make-tarball.sh
@@ -43,7 +43,7 @@ rm -rf autom4te.cache
 cd ..
 
 einfo "Generating tarball ..."
-tar cf - "${p}" | xz > "${p}".tar.xz
+tar --numeric-owner -cf - "${p}" | xz > "${p}".tar.xz
 rm -r "${p}"
 du -b "${p}".tar.*
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-04-04 13:16 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-04-04 13:16 UTC (permalink / raw
  To: gentoo-commits

commit:     80d7de29b2c1f977e84bc653933545a6eb589694
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Apr  4 13:13:15 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Apr  4 13:13:15 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=80d7de29

show_merge_times: start counting parallel merges from start of the file

If we start counting parallel merges only once we found something
interesting, we might not be aware of other emerges at that time,
drawing wrong conclusions when seeing a termination message.

Bug: https://bugs.gentoo.org/603024

 qlop.c | 30 ++++++++++++++++++++++++++----
 1 file changed, 26 insertions(+), 4 deletions(-)

diff --git a/qlop.c b/qlop.c
index 464a488..63bdb7f 100644
--- a/qlop.c
+++ b/qlop.c
@@ -105,6 +105,7 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
 	}
 
 	/* loop over lines searching for cat/pkg */
+	parallel_emerge = 0;
 	while (fgets(buf[0], sizeof(buf[0]), fp) != NULL) {
 		if ((p = strchr(buf[0], '\n')) != NULL)
 			*p = '\0';
@@ -121,6 +122,25 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
 		/* copy message (stripping timestamp) */
 		strncpy(buf[1], p, BUFSIZ);
 		rmspace(buf[1]);
+
+		if (strncmp(buf[1], "Started emerge on:", 18) == 0) {
+			/* a parallel emerge was launched */
+			parallel_emerge++;
+			continue;
+		}
+
+		if (strncmp(buf[1], "*** terminating.", 16) == 0) {
+			if (parallel_emerge > 0) {
+				/* a parallel emerge has finished */
+				parallel_emerge--;
+				continue;
+			} else {
+				/* the main emerge was stopped? if there's more lines
+				 * this file is just corrupt or truncated at the front */
+				continue;
+			}
+		}
+
 		if (strncmp(buf[1], ">>> emerge (", 12) == 0) {
 			/* construct the matching end marker */
 			snprintf(ep, BUFSIZ, "completed %s", &buf[1][4]);
@@ -150,7 +170,6 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
 							(strcmp(pkg, atom->PN) == 0))) ||
 					(strcmp(pkg, atom->PN) == 0))
 			{
-				parallel_emerge = 0;
 				while (fgets(buf[0], sizeof(buf[0]), fp) != NULL) {
 					if ((p = strchr(buf[0], '\n')) != NULL)
 						*p = '\0';
@@ -173,14 +192,17 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
 							/* a parallel emerge has finished */
 							parallel_emerge--;
 							continue;
-						} else
-							/* the main emerge was stopped */
+						} else {
+							/* the main emerge was stopped? if there's
+							 * more lines this file is just corrupt or
+							 * truncated at the front */
 							break;
+						}
 					}
 
 					/* pay attention to malformed log files (when the
 					 * end of an emerge process is not indicated by the
-					 * line '*** terminating'). We assume than the log
+					 * line '*** terminating'). We assume that the log
 					 * is malformed when we find a parallel emerge
 					 * process which is trying to emerge the same
 					 * package


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-04-03 20:13 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-04-03 20:13 UTC (permalink / raw
  To: gentoo-commits

commit:     0baddddc111c7fba7a8a087a2905ca645a27f5f8
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Apr  3 20:12:16 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Apr  3 20:12:16 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0baddddc

qfile_main: use q_vdb_foreach_pkg_sorted, bug #607498

For consistency with almost all other output, use sorted output variant
for qfile as well.  The little sorting/memory overhead due to this is
probably ok, given how much it is used already.

Bug: https://bugs.gentoo.org/607498

 qfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qfile.c b/qfile.c
index ec08491..3f13df6 100644
--- a/qfile.c
+++ b/qfile.c
@@ -462,7 +462,7 @@ int qfile_main(int argc, char **argv)
 	nb_of_queries = prepare_qfile_args(argc, (const char **) argv, &state);
 	/* Now do the actual `qfile` checking */
 	if (nb_of_queries > 0)
-		found += q_vdb_foreach_pkg(qfile_cb, &state, NULL);
+		found += q_vdb_foreach_pkg_sorted(qfile_cb, &state);
 
 	if (state.args.non_orphans) {
 		/* display orphan files */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-04-03 13:39 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-04-03 13:39 UTC (permalink / raw
  To: gentoo-commits

commit:     d01affcd8541a539a7e5b329efef1cc49f31569f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Apr  3 13:25:30 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Apr  3 13:25:30 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d01affcd

qsize: use make_human_readable_str to format sizes by default

This way, sizes are by default converted to the unit that matches the
quantity of the value.  This behaviour can be overridden by the -b, -k
and -m options for constant values.  Simplifies code, and makes it
easier to grasp for humans.

 qsize.c | 27 ++++++++-------------------
 1 file changed, 8 insertions(+), 19 deletions(-)

diff --git a/qsize.c b/qsize.c
index 9cd66cf..c485aa6 100644
--- a/qsize.c
+++ b/qsize.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2014 Gentoo Foundation
+ * Copyright 2005-2018 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
@@ -120,15 +120,9 @@ qsize_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 		       num_files, num_nonfiles);
 		if (num_ignored)
 			printf("%'zu names-ignored, ", num_ignored);
-		if (state->disp_units)
-			printf("%s %s\n",
-			       make_human_readable_str(num_bytes, 1, state->disp_units),
-			       state->str_disp_units);
-		else
-			printf("%'"PRIu64"%s%"PRIu64" KiB\n",
-			       num_bytes / KILOBYTE,
-			       decimal_point,
-			       ((num_bytes % KILOBYTE) * 1000) / KILOBYTE);
+		printf("%s %s\n",
+			   make_human_readable_str(num_bytes, 1, state->disp_units),
+			   state->disp_units ? state->str_disp_units : "");
 	}
 
 	return EXIT_SUCCESS;
@@ -194,15 +188,10 @@ int qsize_main(int argc, char **argv)
 		       state.num_all_files, state.num_all_nonfiles);
 		if (state.num_all_ignored)
 			printf("%'zu names-ignored, ", state.num_all_ignored);
-		if (state.disp_units)
-			printf("%s %s\n",
-			       make_human_readable_str(state.num_all_bytes, 1, state.disp_units),
-			       state.str_disp_units);
-		else
-			printf("%'"PRIu64"%s%"PRIu64" MiB\n",
-			       state.num_all_bytes / MEGABYTE,
-			       decimal_point,
-			       ((state.num_all_bytes % MEGABYTE) * 1000) / MEGABYTE);
+		printf("%s %s\n",
+			   make_human_readable_str(
+				   state.num_all_bytes, 1, state.disp_units),
+			   state.disp_units ? state.str_disp_units : "");
 	}
 
 	array_for_each(state.atoms, i, atom)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-04-02 17:27 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-04-02 17:27 UTC (permalink / raw
  To: gentoo-commits

commit:     e8d6478d5fb0b5c9d33318fff9387d7cb27620f7
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Apr  2 17:21:21 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Apr  2 17:21:21 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e8d6478d

qatom_printf: support REPO expansion

 qatom.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qatom.c b/qatom.c
index b542de8..9e4b40c 100644
--- a/qatom.c
+++ b/qatom.c
@@ -87,6 +87,9 @@ qatom_printf(const char *format, const depend_atom *atom, int pverbose)
 				} else if (!strncmp("SLOT", fmt, len)) {
 					if (showit || atom->SLOT)
 						printf(":%s", atom->SLOT ? atom->SLOT : "-");
+				} else if (!strncmp("REPO", fmt, len)) {
+					if (showit || atom->REPO)
+						printf("::%s", HN(atom->REPO));
 				} else if (!strncmp("pfx", fmt, len)) {
 					if (showit || atom->pfx_op != ATOM_OP_NONE)
 						fputs(atom->pfx_op == ATOM_OP_NONE ?


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-04-01 10:22 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-04-01 10:22 UTC (permalink / raw
  To: gentoo-commits

commit:     69286497c1b4c8559c638228bb2c9f4359a9c94d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Apr  1 10:21:59 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Apr  1 10:21:59 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=69286497

read_repos_conf: exclude empty strings as file too

 main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c
index 023b42e..4f9f467 100644
--- a/main.c
+++ b/main.c
@@ -516,11 +516,11 @@ read_repos_conf(const char *configroot, const char *repos_conf)
 		for (i = 0; i < count; ++i) {
 			const char *name = confs[i]->d_name;
 
-			if (name[0] == '.')
+			if (name[0] == '.' || name[0] == '\0')
 				continue;
 
 			/* Exclude backup files (aka files with ~ as postfix). */
-			if (name[0] != '\0' && name[strlen(name) - 1] == '~')
+			if (name[strlen(name) - 1] == '~')
 				continue;
 
 #ifdef DT_UNKNOWN


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-04-01 10:22 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-04-01 10:22 UTC (permalink / raw
  To: gentoo-commits

commit:     cd7c5018d4bffa34bd5aab6848525fd83d392de7
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Apr  1 10:20:12 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Apr  1 10:20:12 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=cd7c5018

read_portage_env_file: properly ignore backup files

backup files are suffixed by '~', not prefixed

 main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 85740b8..023b42e 100644
--- a/main.c
+++ b/main.c
@@ -670,7 +670,8 @@ read_portage_env_file(const char *configroot, const char *file, env_vars vars[])
 		/* recurse through all files */
 		for (di = 0; di < dentslen; di++) {
 			d = dents[di];
-			if (d->d_name[0] == '.' || d->d_name[0] == '~')
+			if (d->d_name[0] == '.' || d->d_name[0] == '\0' ||
+					d->d_name[strlen(d->d_name) - 1] == '~')
 				continue;
 			snprintf(npath, sizeof(npath), "%s/%s", file, d->d_name);
 			read_portage_env_file(configroot, npath, vars);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-31  6:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-31  6:54 UTC (permalink / raw
  To: gentoo-commits

commit:     553d512900e5d83ec643475344f57118d8b4ed3f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 31 06:52:40 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Mar 31 06:52:40 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=553d5129

read_portage_env_file: support reading directories, bug #558306

In particular /etc/portage/make.conf can be a directory.  If it is,
process it recursively in sorted order.

Bug: https://bugs.gentoo.org/558306

 main.c | 22 +++++++++++++++++++++-
 1 file changed, 21 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 8000540..85740b8 100644
--- a/main.c
+++ b/main.c
@@ -639,12 +639,15 @@ set_portage_env_var(env_vars *var, const char *value)
 	}
 }
 
-/* Helper to read a portage env file (e.g. make.conf) */
+/* Helper to read a portage env file (e.g. make.conf), or recursively if
+ * it points to a directory */
 static void
 read_portage_env_file(const char *configroot, const char *file, env_vars vars[])
 {
 	size_t i, buflen, line, configroot_len, file_len;
 	FILE *fp;
+	struct dirent **dents;
+	int dentslen;
 	char *buf, *s, *p;
 
 	if (getenv("DEBUG"))
@@ -659,6 +662,23 @@ read_portage_env_file(const char *configroot, const char *file, env_vars vars[])
 	memcpy(buf + configroot_len, file, file_len);
 	buf[buflen - 1] = '\0';
 
+	if ((dentslen = scandir(buf, &dents, NULL, alphasort)) > 0) {
+		int di;
+		struct dirent *d;
+		char npath[_Q_PATH_MAX];
+
+		/* recurse through all files */
+		for (di = 0; di < dentslen; di++) {
+			d = dents[di];
+			if (d->d_name[0] == '.' || d->d_name[0] == '~')
+				continue;
+			snprintf(npath, sizeof(npath), "%s/%s", file, d->d_name);
+			read_portage_env_file(configroot, npath, vars);
+		}
+		scandir_free(dents, dentslen);
+		goto done;
+	}
+
 	fp = fopen(buf, "r");
 	if (fp == NULL)
 		goto done;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-31  6:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-31  6:54 UTC (permalink / raw
  To: gentoo-commits

commit:     b05c690acf8e97890471f4ef45eee821699f13b3
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 30 20:13:28 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 30 20:16:41 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b05c690a

initialize_portage_env: move debug var printing after repos.conf

in particular PORTDIR may get set, so ensure we print the value that's
going to be used

 main.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/main.c b/main.c
index 7c55358..8000540 100644
--- a/main.c
+++ b/main.c
@@ -943,18 +943,6 @@ initialize_portage_env(void)
 		}
 	}
 
-	if (getenv("DEBUG")) {
-		for (i = 0; vars_to_read[i].name; ++i) {
-			var = &vars_to_read[i];
-			fprintf(stderr, "%s = ", var->name);
-			switch (var->type) {
-			case _Q_BOOL: fprintf(stderr, "%i\n", *var->value.b); break;
-			case _Q_STR:
-			case _Q_ISTR: fprintf(stderr, "%s\n", *var->value.s); break;
-			}
-		}
-	}
-
 	/* Make sure ROOT always ends in a slash */
 	var = &vars_to_read[0];
 	if ((*var->value.s)[var->value_len - 1] != '/') {
@@ -970,6 +958,18 @@ initialize_portage_env(void)
 	if (array_cnt(overlays) == 0)
 		xarraypush_str(overlays, main_overlay);
 
+	if (getenv("DEBUG")) {
+		for (i = 0; vars_to_read[i].name; ++i) {
+			var = &vars_to_read[i];
+			fprintf(stderr, "%s = ", var->name);
+			switch (var->type) {
+			case _Q_BOOL: fprintf(stderr, "%i\n", *var->value.b); break;
+			case _Q_STR:
+			case _Q_ISTR: fprintf(stderr, "%s\n", *var->value.s); break;
+			}
+		}
+	}
+
 	if (getenv("PORTAGE_QUIET") != NULL)
 		setup_quiet();
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-31  6:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-31  6:54 UTC (permalink / raw
  To: gentoo-commits

commit:     32d16662a911ff06991a3b0bfb2c833df365457a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 30 20:11:17 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 30 20:16:40 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=32d16662

read_portage_env_file: make debug print the real location

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 6ed2566..7c55358 100644
--- a/main.c
+++ b/main.c
@@ -648,7 +648,7 @@ read_portage_env_file(const char *configroot, const char *file, env_vars vars[])
 	char *buf, *s, *p;
 
 	if (getenv("DEBUG"))
-		fprintf(stderr, "profile %s\n", file);
+		fprintf(stderr, "profile %s/%s\n", configroot, file);
 
 	configroot_len = strlen(configroot);
 	file_len = strlen(file);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-31  6:54 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-31  6:54 UTC (permalink / raw
  To: gentoo-commits

commit:     16e36c085ce6e9a72690f518baf62852b9196ee7
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 30 20:08:34 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 30 20:16:38 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=16e36c08

initialize_portage_env: avoid double prefix for repos.conf location

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index ec903fe..6ed2566 100644
--- a/main.c
+++ b/main.c
@@ -964,7 +964,7 @@ initialize_portage_env(void)
 	}
 
 	char *orig_main_overlay = main_overlay;
-	read_repos_conf(configroot, CONFIG_EPREFIX "etc/portage/repos.conf");
+	read_repos_conf(configroot, "/etc/portage/repos.conf");
 	if (orig_main_overlay != main_overlay)
 		free(orig_main_overlay);
 	if (array_cnt(overlays) == 0)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-30  5:56 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-30  5:56 UTC (permalink / raw
  To: gentoo-commits

commit:     aec94e4d236fb91b04d21bde5f622c2af39ddee8
Author:     Matija Skala <mskala <AT> gmx <DOT> com>
AuthorDate: Thu Aug 17 16:03:14 2017 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Mar 29 18:17:33 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=aec94e4d

fix compile on hurd

Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qlop.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/qlop.c b/qlop.c
index babcc74..c01b3be 100644
--- a/qlop.c
+++ b/qlop.c
@@ -382,6 +382,8 @@ show_sync_history(const char *logfile, time_t start_time, time_t end_time)
 static void show_current_emerge(void);
 #ifdef __linux__
 # include <asm/param.h>
+#endif
+#if defined __linux__ || defined __GNU__
 # include <elf.h>
 static unsigned long hz = 0;
 static void init_hz(void)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-30  5:56 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-30  5:56 UTC (permalink / raw
  To: gentoo-commits

commit:     98cf71419ec081e02677f314f26c6b3d5aaf7ad7
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Mar 29 18:14:04 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Mar 29 18:14:04 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=98cf7141

qlop: break some long lines, no code changes

 qlop.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/qlop.c b/qlop.c
index 33e8d37..babcc74 100644
--- a/qlop.c
+++ b/qlop.c
@@ -448,7 +448,9 @@ void show_current_emerge(void)
 		if (!eat_file(path, &cmdline, &cmdline_len))
 			continue;
 
-		if (cmdline[0] == '[' && (p = strchr(cmdline, ']')) != NULL && strstr(cmdline, "sandbox") != NULL) {
+		if (cmdline[0] == '[' && (p = strchr(cmdline, ']')) != NULL &&
+				strstr(cmdline, "sandbox") != NULL)
+		{
 			*p = '\0';
 			p = cmdline + 1;
 			q = p + strlen(p) + 1;
@@ -511,7 +513,9 @@ void show_current_emerge(void)
 	char *p, *q;
 	time_t start_date = 0;
 
-	if (! (kd = kvm_open("/dev/null", "/dev/null", "/dev/null", O_RDONLY, "kvm_open"))) {
+	if (! (kd = kvm_open("/dev/null", "/dev/null", "/dev/null",
+					O_RDONLY, "kvm_open")))
+	{
 		warnp("Could not open kvm: %s", kvm_geterr(kd));
 		return;
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-26 19:08 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-26 19:08 UTC (permalink / raw
  To: gentoo-commits

commit:     e8c0e327e7e1ec83a63c2c7a6b44567773ec7d94
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 26 19:06:19 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Mar 26 19:06:19 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e8c0e327

qlist_cb: exclude /usr/src/debug by default too

This is an somewhat alternative take to the patch by
Niklas Haas <bgo <AT> nand.wakku.to>.

Also exclude /usr/src/debug by default, because it contains a lot of
clutter.

Bug: https://bugs.gentoo.org/646310

 qlist.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/qlist.c b/qlist.c
index cda4ca7..1f8757c 100644
--- a/qlist.c
+++ b/qlist.c
@@ -335,8 +335,9 @@ qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 			continue;
 
 		if (!state->show_dbg) {
-			if (!strncmp(e->name, "/usr/lib/debug", 14) &&
-			    (e->name[14] == '/' || e->name[14] == '\0'))
+			if ((strncmp(e->name, "/usr/lib/debug", 14) == 0
+						|| strncmp(e->name, "/usr/src/debug", 14) == 0)
+					&& (e->name[14] == '/' || e->name[14] == '\0'))
 				continue;
 		}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-25 14:00 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-25 14:00 UTC (permalink / raw
  To: gentoo-commits

commit:     3d00cad113975b02ece79892eb5f752d818aaa73
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 25 13:57:56 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sun Mar 25 13:57:56 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3d00cad1

qdepends_vdb_deep_cb: use atom matching when possible, bug #608960

When the argument is an atom-parsable thing, match whatever we find in
the vdb as atom, such that version and range can be taken into account.

Bug: https://bugs.gentoo.org/608960

 qdepends.c | 118 +++++++++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 95 insertions(+), 23 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index d5a8ef5..cd5e851 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -475,13 +475,17 @@ qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	const char *pkgname = pkg_ctx->name;
 	size_t len;
 	char *ptr;
-	char buf[_Q_PATH_MAX];
+	char qbuf[_Q_PATH_MAX];
 	static char *depend, *use;
 	static size_t depend_len, use_len;
 	dep_node *dep_tree;
 	int ret;
 	regex_t preg;
 	regmatch_t match;
+	depend_atom *aq;
+	depend_atom *as;
+	depend_atom *ac;
+	char firstmatch = 0;
 
 	if (!q_vdb_pkg_eat(pkg_ctx, state->depend_file, &depend, &depend_len))
 		return 0;
@@ -508,36 +512,104 @@ qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 
 	dep_prune_use(dep_tree, use);
 
-	ptr = dep_flatten_tree(dep_tree);
+	if ((ptr = dep_flatten_tree(dep_tree)) == NULL) {
+		dep_burn_tree(dep_tree);
+		return 1;
+	}
 
-	ret = -2;
-	if (ptr && wregcomp(&preg, state->query, REG_EXTENDED) == 0)
-		ret = regexec(&preg, ptr, 1, &match, 0);
-	if (ret > -2)
-		regfree(&preg);
+	snprintf(qbuf, sizeof(qbuf), "%s/%s", catname, pkgname);
+	as = atom_explode(qbuf);
+	if (!as) {
+		dep_burn_tree(dep_tree);
+		return 1;
+	}
 
-	if (ptr && ret == 0) {
-		if (qdep_name_only) {
-			depend_atom *atom = NULL;
-			snprintf(buf, sizeof(buf), "%s/%s", catname, pkgname);
-			if ((atom = atom_explode(buf)) != NULL) {
-				printf("%s%s/%s%s%s%c", BOLD, catname, BLUE, atom->PN, NORM, verbose ? ':' : '\n');
-				atom_implode(atom);
-			}
+	aq = atom_explode(state->query);
+	if (!aq) {
+		/* "fall" back to old behaviour of just performing an extended
+		 * regular expression match */
+		if (wregcomp(&preg, state->query, REG_EXTENDED) != 0) {
+			dep_burn_tree(dep_tree);
+			return 1;
+		}
+	}
+
+	match.rm_eo = 0;
+	firstmatch = 1;
+	do {  /* find all matches */
+		if (!aq) {
+			ret = regexec(&preg, ptr + match.rm_eo, 1, &match, 0);
 		} else {
-			printf("%s%s/%s%s%s%c", BOLD, catname, BLUE, pkgname, NORM, verbose ? ':' : '\n');
+			char *loc;
+			ret = -1;
+			snprintf(qbuf, sizeof(qbuf), "%s%s%s",
+					aq->CATEGORY ? aq->CATEGORY : "",
+					aq->CATEGORY ? "/" : "",
+					aq->PN);
+			if ((loc = strstr(ptr + match.rm_eo, qbuf)) != NULL) {
+				ret = 0;
+				match.rm_so = loc - ptr;
+				match.rm_eo = match.rm_so + strlen(qbuf);
+			}
 		}
-		if (verbose) {
-			/* find the boundaries for this atom */
-			while (match.rm_so > 0 && !isspace(ptr[match.rm_so - 1]))
-				match.rm_so--;
-			while (ptr[match.rm_eo] != '\0' && !isspace(ptr[match.rm_eo]))
-				match.rm_eo++;
-			printf(" %.*s\n",
+		if (ret != 0)
+			break;
+
+		/* find the boundaries for matched atom */
+		while (match.rm_so > 0 && !isspace(ptr[match.rm_so - 1]))
+			match.rm_so--;
+		while (ptr[match.rm_eo] != '\0' && !isspace(ptr[match.rm_eo]))
+			match.rm_eo++;
+
+		snprintf(qbuf, sizeof(qbuf), "%.*s",
 					(int)(match.rm_eo - match.rm_so),
 					ptr + match.rm_so);
+		ac = atom_explode(qbuf);
+
+		ret = atom_compare(ac, aq);
+		if (ret != EQUAL) {
+			atom_implode(ac);
+			break;
+		}
+
+		if (firstmatch == 1) {
+			firstmatch = 0;
+			printf("%s%s/%s%s%s%c", BOLD, catname, BLUE,
+					qdep_name_only ? as->PN : pkgname, NORM,
+					verbose ? ':' : '\n');
+		}
+
+		if (verbose) {
+			printf(" ");
+			if (ac) {
+				printf("%s", atom_op_str[ac->pfx_op]);
+				if (ac->CATEGORY)
+					printf("%s/", ac->CATEGORY);
+				printf("%s", ac->P);
+				if (ac->PR_int)
+					printf("-r%i", ac->PR_int);
+				printf("%s", atom_op_str[ac->sfx_op]);
+				if (ac->SLOT)
+					printf(":%s", ac->SLOT);
+				atom_implode(ac);
+			} else {
+				printf("%s", qbuf);
+			}
+		} else {
+			/* if not verbose, we don't care about any extra matches */
+			atom_implode(ac);
+			break;
 		}
+	} while (1);
+	if (verbose && firstmatch == 0)
+		printf("\n");
+
+	if (!aq) {
+		regfree(&preg);
+	} else {
+		atom_implode(aq);
 	}
+	atom_implode(as);
 	dep_burn_tree(dep_tree);
 
 	return 1;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-23 20:17 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-23 20:17 UTC (permalink / raw
  To: gentoo-commits

commit:     bbf9f4b708e1368a86c7978681e4a82604587fbc
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 23 20:11:35 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 23 20:11:35 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bbf9f4b7

fix some more signedness problems

 q.c        | 2 +-
 qcheck.c   | 4 ++--
 qdepends.c | 4 ++--
 qlop.c     | 5 +++--
 qsize.c    | 4 ++--
 5 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/q.c b/q.c
index ff79643..9c06e2a 100644
--- a/q.c
+++ b/q.c
@@ -126,7 +126,7 @@ int q_main(int argc, char **argv)
 #elif defined(__sun) && defined(__SVR4)
 		prog = getexecname();
 		rret = strlen(prog);
-		if (rret > sizeof(buf) - 1) {
+		if ((size_t)rret > sizeof(buf) - 1) {
 			rret = -1;
 		} else {
 			strncpy(buf, prog, rret);

diff --git a/qcheck.c b/qcheck.c
index 66589a3..c6e1ccb 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -354,8 +354,8 @@ int qcheck_main(int argc, char **argv)
 		.undo_prelink = false,
 	};
 
-	while ((i = GETOPT_LONG(QCHECK, qcheck, "")) != -1) {
-		switch (i) {
+	while ((ret = GETOPT_LONG(QCHECK, qcheck, "")) != -1) {
+		switch (ret) {
 		COMMON_GETOPTS_CASES(qcheck)
 		case 's': {
 			regex_t regex;

diff --git a/qdepends.c b/qdepends.c
index 117ca71..d5a8ef5 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -560,8 +560,8 @@ int qdepends_main(int argc, char **argv)
 
 	depend_file = depend_files[0];
 
-	while ((i = GETOPT_LONG(QDEPENDS, qdepends, "")) != -1) {
-		switch (i) {
+	while ((ret = GETOPT_LONG(QDEPENDS, qdepends, "")) != -1) {
+		switch (ret) {
 		COMMON_GETOPTS_CASES(qdepends)
 
 		case 'd': depend_file = depend_files[0]; break;

diff --git a/qlop.c b/qlop.c
index 410a94b..33e8d37 100644
--- a/qlop.c
+++ b/qlop.c
@@ -753,6 +753,7 @@ parse_date(const char *sdate, time_t *t)
 int qlop_main(int argc, char **argv)
 {
 	size_t i;
+	int ret;
 	int average = 1;
 	time_t start_time, end_time;
 	char do_time, do_list, do_unlist, do_sync, do_current, do_human_readable = 0;
@@ -765,8 +766,8 @@ int qlop_main(int argc, char **argv)
 	end_time = LONG_MAX;
 	do_time = do_list = do_unlist = do_sync = do_current = 0;
 
-	while ((i = GETOPT_LONG(QLOP, qlop, "")) != -1) {
-		switch (i) {
+	while ((ret = GETOPT_LONG(QLOP, qlop, "")) != -1) {
+		switch (ret) {
 			COMMON_GETOPTS_CASES(qlop)
 
 			case 't': do_time = 1; break;

diff --git a/qsize.c b/qsize.c
index acf74bf..9cd66cf 100644
--- a/qsize.c
+++ b/qsize.c
@@ -156,8 +156,8 @@ int qsize_main(int argc, char **argv)
 		.num_all_ignored = 0,
 	};
 
-	while ((i = GETOPT_LONG(QSIZE, qsize, "")) != -1) {
-		switch (i) {
+	while ((ret = GETOPT_LONG(QSIZE, qsize, "")) != -1) {
+		switch (ret) {
 		COMMON_GETOPTS_CASES(qsize)
 		case 'f': state.fs_size = 1; break;
 		case 's': state.summary = 1; break;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-23 20:17 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-23 20:17 UTC (permalink / raw
  To: gentoo-commits

commit:     ca282deea01374d6f01746432ce3f450bcf6ac9f
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 23 20:16:58 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 23 20:16:58 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ca282dee

getopt: add workaround for Solaris to silence compiler

 porting.h | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/porting.h b/porting.h
index 206c6e3..b0225df 100644
--- a/porting.h
+++ b/porting.h
@@ -32,7 +32,6 @@
 #include <errno.h>
 #include <fcntl.h>
 #include <fnmatch.h>
-#include <getopt.h>
 #include <glob.h>
 #include <inttypes.h>
 #include <libgen.h>
@@ -52,6 +51,24 @@
 
 #include <iniparser.h>
 
+#if defined(__sun) && defined(__SVR4)
+/* workaround non-const defined name in option struct, such that we
+ * don't get a zillion of warnings */
+#define	no_argument		0
+#define	required_argument	1
+#define	optional_argument	2
+struct option {
+	const char *name;
+	int has_arg;
+	int *flag;
+	int val;
+};
+extern int	getopt_long(int, char * const *, const char *,
+		    const struct option *, int *);
+#else
+#include <getopt.h>
+#endif
+
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*(arr)))
 
 #ifndef BUFSIZE


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-23 15:27 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-23 15:27 UTC (permalink / raw
  To: gentoo-commits

commit:     967b86446d70038ccdf3d014d5554be41d981edc
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 23 15:07:55 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 23 15:07:55 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=967b8644

qdepends_vdb_deep_cb: show atom that matched

This extracts the atom that matched the regular expression.

 qdepends.c | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index e8b2190..117ca71 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -479,6 +479,9 @@ qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	static char *depend, *use;
 	static size_t depend_len, use_len;
 	dep_node *dep_tree;
+	int ret;
+	regex_t preg;
+	regmatch_t match;
 
 	if (!q_vdb_pkg_eat(pkg_ctx, state->depend_file, &depend, &depend_len))
 		return 0;
@@ -506,7 +509,14 @@ qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	dep_prune_use(dep_tree, use);
 
 	ptr = dep_flatten_tree(dep_tree);
-	if (ptr && rematch(state->query, ptr, REG_EXTENDED) == 0) {
+
+	ret = -2;
+	if (ptr && wregcomp(&preg, state->query, REG_EXTENDED) == 0)
+		ret = regexec(&preg, ptr, 1, &match, 0);
+	if (ret > -2)
+		regfree(&preg);
+
+	if (ptr && ret == 0) {
 		if (qdep_name_only) {
 			depend_atom *atom = NULL;
 			snprintf(buf, sizeof(buf), "%s/%s", catname, pkgname);
@@ -517,8 +527,16 @@ qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 		} else {
 			printf("%s%s/%s%s%s%c", BOLD, catname, BLUE, pkgname, NORM, verbose ? ':' : '\n');
 		}
-		if (verbose)
-			printf(" %s\n", ptr);
+		if (verbose) {
+			/* find the boundaries for this atom */
+			while (match.rm_so > 0 && !isspace(ptr[match.rm_so - 1]))
+				match.rm_so--;
+			while (ptr[match.rm_eo] != '\0' && !isspace(ptr[match.rm_eo]))
+				match.rm_eo++;
+			printf(" %.*s\n",
+					(int)(match.rm_eo - match.rm_so),
+					ptr + match.rm_so);
+		}
 	}
 	dep_burn_tree(dep_tree);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-23 15:27 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-23 15:27 UTC (permalink / raw
  To: gentoo-commits

commit:     be23ddefad2d4843dc5fd9db5cd0d2f840ce0fc0
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 23 15:27:06 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 23 15:27:06 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=be23ddef

version_barf: show EPREFIX configured with, if present

 main.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 44226db..ec903fe 100644
--- a/main.c
+++ b/main.c
@@ -189,15 +189,21 @@ usage(int status, const char *flags, struct option const opts[],
 static void
 version_barf(void)
 {
+	const char *eprefixid = "";
+
 #ifndef VERSION
 # define VERSION "git"
 #endif
 #ifndef VCSID
 # define VCSID "<unknown>"
 #endif
+
+	if (strlen(CONFIG_EPREFIX) > 1)
+		eprefixid = "configured for " CONFIG_EPREFIX "\n";
 	printf("portage-utils-%s: %s\n"
+	       "%s"
 	       "%s written for Gentoo by <solar and vapier @ gentoo.org>\n",
-	       VERSION, VCSID, argv0);
+	       VERSION, VCSID, eprefixid, argv0);
 	exit(EXIT_SUCCESS);
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-23 13:17 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-23 13:17 UTC (permalink / raw
  To: gentoo-commits

commit:     bf111d7d5464f8a6b3a251d3d12fe9e39357bc6e
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Mar 23 13:16:31 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 23 13:16:31 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bf111d7d

fix signedness warnings

 main.c     | 8 +++++---
 qcheck.c   | 2 +-
 qdepends.c | 2 +-
 qgrep.c    | 5 +++--
 qlop.c     | 7 ++++---
 qsearch.c  | 2 +-
 qsize.c    | 2 +-
 qxpak.c    | 8 +++++---
 8 files changed, 21 insertions(+), 15 deletions(-)

diff --git a/main.c b/main.c
index b11fe83..44226db 100644
--- a/main.c
+++ b/main.c
@@ -1420,9 +1420,11 @@ get_vdb_atoms(int fullcpv)
 		if ((dfd = scandirat(ctx->vdb_fd, cat[j]->d_name, &pf, q_vdb_filter_pkg, alphasort)) < 0)
 			continue;
 		for (i = 0; i < dfd; i++) {
-			int blen = snprintf(buf, sizeof(buf), "%s/%s/SLOT", cat[j]->d_name, pf[i]->d_name);
-			if (blen >= sizeof(buf)) {
-				warnf("unable to parse long package: %s/%s", cat[j]->d_name, pf[i]->d_name);
+			int blen = snprintf(buf, sizeof(buf), "%s/%s/SLOT",
+					cat[j]->d_name, pf[i]->d_name);
+			if (blen < 0 || (size_t)blen >= sizeof(buf)) {
+				warnf("unable to parse long package: %s/%s",
+						cat[j]->d_name, pf[i]->d_name);
 				continue;
 			}
 

diff --git a/qcheck.c b/qcheck.c
index 26b820e..66589a3 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -375,7 +375,7 @@ int qcheck_main(int argc, char **argv)
 
 	argc -= optind;
 	argv += optind;
-	for (i = 0; i < argc; ++i) {
+	for (i = 0; i < (size_t)argc; ++i) {
 		atom = atom_explode(argv[i]);
 		if (!atom)
 			warn("invalid atom: %s", argv[i]);

diff --git a/qdepends.c b/qdepends.c
index a614704..e8b2190 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -579,7 +579,7 @@ int qdepends_main(int argc, char **argv)
 	else {
 		cb = qdepends_main_vdb_cb;
 
-		for (i = 0; i < argc; ++i) {
+		for (i = 0; i < (size_t)argc; ++i) {
 			atom = atom_explode(argv[i]);
 			if (!atom)
 				warn("invalid atom: %s", argv[i]);

diff --git a/qgrep.c b/qgrep.c
index 0680035..fe53ea2 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -153,9 +153,10 @@ qgrep_print_line(qgrep_buf_t *current, const char *label,
 		int regexec_flags = 0;
 		while ((*p != '\0') && !regexec(preg, p, 1, &match, regexec_flags)) {
 			if (match.rm_so > 0)
-				printf("%.*s", match.rm_so, p);
+				printf("%.*s", (int)match.rm_so, p);
 			if (match.rm_eo > match.rm_so) {
-				printf("%s%.*s%s", RED, match.rm_eo - match.rm_so, p + match.rm_so, NORM);
+				printf("%s%.*s%s", RED, (int)(match.rm_eo - match.rm_so),
+						p + match.rm_so, NORM);
 				p += match.rm_eo;
 			} else {
 				p += match.rm_eo;

diff --git a/qlop.c b/qlop.c
index 5be2ddd..410a94b 100644
--- a/qlop.c
+++ b/qlop.c
@@ -580,7 +580,8 @@ void show_current_emerge(void)
 			raip = realloc(ip, sizeof(struct kinfo_proc) * size);
 			if (raip == NULL) {
 				free(ip);
-				warnp("Could not extend allocated block to %d bytes for process information",
+				warnp("Could not extend allocated block to "
+						"%zd bytes for process information",
 						sizeof(struct kinfo_proc) * size);
 				return;
 			}
@@ -798,7 +799,7 @@ int qlop_main(int argc, char **argv)
 
 	argc -= optind;
 	argv += optind;
-	for (i = 0; i < argc; ++i) {
+	for (i = 0; i < (size_t)argc; ++i) {
 		atom = atom_explode(argv[i]);
 		if (!atom)
 			warn("invalid atom: %s", argv[i]);
@@ -820,7 +821,7 @@ int qlop_main(int argc, char **argv)
 		show_sync_history(logfile, start_time, end_time);
 
 	if (do_time) {
-		for (i = 0; i < argc; ++i)
+		for (i = 0; i < (size_t)argc; ++i)
 			show_merge_times(argv[i], logfile, average, do_human_readable,
 				start_time, end_time);
 	}

diff --git a/qsearch.c b/qsearch.c
index c2b2ebe..a620f95 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -104,7 +104,7 @@ qsearch_ebuild_ebuild(int overlay_fd, const char *ebuild, const char *search_me,
 	int linelen;
 	size_t buflen;
 	while ((linelen = getline(&buf, &buflen, ebuildfp)) >= 0) {
-		if (linelen <= search_len)
+		if ((size_t)linelen <= search_len)
 			continue;
 		if (strncmp(buf, search_var, search_len) != 0)
 			continue;

diff --git a/qsize.c b/qsize.c
index b92f533..acf74bf 100644
--- a/qsize.c
+++ b/qsize.c
@@ -176,7 +176,7 @@ int qsize_main(int argc, char **argv)
 
 	argc -= optind;
 	argv += optind;
-	for (i = 0; i < argc; ++i) {
+	for (i = 0; i < (size_t)argc; ++i) {
 		atom = atom_explode(argv[i]);
 		if (!atom)
 			warn("invalid atom: %s", argv[i]);

diff --git a/qxpak.c b/qxpak.c
index 95fb779..ada9767 100644
--- a/qxpak.c
+++ b/qxpak.c
@@ -341,9 +341,11 @@ xpak_create(int dir_fd, const char *file, int argc, char **argv)
 			if ((numfiles = scandir(argv[i], &dir, filter_hidden, alphasort)) < 0)
 				warn("Directory '%s' is empty; skipping", argv[i]);
 			for (fidx = 0; fidx < numfiles; ++fidx) {
-				int ret = snprintf(path, sizeof(path), "%s/%s", argv[i], dir[fidx]->d_name);
-				if (ret >= sizeof(path)) {
-					warn("skipping path too long: %s/%s", argv[i], dir[fidx]->d_name);
+				int ret = snprintf(path, sizeof(path), "%s/%s",
+						argv[i], dir[fidx]->d_name);
+				if (ret < 0 || (size_t)ret >= sizeof(path)) {
+					warn("skipping path too long: %s/%s",
+							argv[i], dir[fidx]->d_name);
 					continue;
 				}
 				if (stat(path, &st) < 0) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-23 11:29 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-23 11:29 UTC (permalink / raw
  To: gentoo-commits

commit:     7fa57849a692a2900417ed13f67b6c6385a2932e
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Thu Mar  8 21:53:52 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 23 11:18:49 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7fa57849

qmerge: Choose SLOTed packages correctly

Ex. packages are readeline, ncurses which can be installed
in several SLOTs

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 22 ++++++++++++++--------
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index ebd4960..1f75acc 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -203,6 +203,7 @@ qmerge_initialize(void)
 struct qmerge_bv_state {
 	const char *catname;
 	const char *pkgname;
+	const char *slot;
 	char buf[4096];
 	char *retbuf;
 };
@@ -219,19 +220,20 @@ qmerge_best_version_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 {
 	struct qmerge_bv_state *state = priv;
 	if (qlist_match(pkg_ctx, state->buf, NULL, true))
-		snprintf(state->retbuf, sizeof(state->buf), "%s/%s",
-			pkg_ctx->cat_ctx->name, pkg_ctx->name);
+		snprintf(state->retbuf, sizeof(state->buf), "%s/%s:%s",
+			 pkg_ctx->cat_ctx->name, pkg_ctx->name, state->slot);
 	return 0;
 }
 
 static char *
-best_version(const char *catname, const char *pkgname)
+best_version(const char *catname, const char *pkgname, const char *slot)
 {
 	static int vdb_check = 1;
 	static char retbuf[4096];
 	struct qmerge_bv_state state = {
 		.catname = catname,
 		.pkgname = pkgname,
+		.slot = slot,
 		.retbuf = retbuf,
 	};
 
@@ -252,8 +254,8 @@ best_version(const char *catname, const char *pkgname)
 	}
 
 	retbuf[0] = '\0';
-	snprintf(state.buf, sizeof(state.buf), "%s%s%s",
-		catname ? : "", catname ? "/" : "", pkgname);
+	snprintf(state.buf, sizeof(state.buf), "%s%s%s:%s",
+		 catname ? : "", catname ? "/" : "", pkgname, slot);
 	q_vdb_foreach_pkg(qmerge_best_version_cb, &state, qmerge_filter_cat);
 
  done:
@@ -359,7 +361,8 @@ qprint_tree_node(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	if (!pretend)
 		return 0;
 
-	p = best_version(pkg->CATEGORY, atom->PN);
+	p = best_version(pkg->CATEGORY, atom->PN, pkg->SLOT);
+
 	if (strlen(p) < 1) {
 		c = 'N';
 		snprintf(buf, sizeof(buf), "%sN%s", GREEN, NORM);
@@ -844,7 +847,8 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 
 						ratom = atom_explode(buf);
 
-						p = best_version(subpkg->CATEGORY, subpkg->PF);
+						p = best_version(subpkg->CATEGORY, subpkg->PF, subpkg->SLOT);
+
 						/* we dont want to remerge equal versions here */
 						IF_DEBUG(fprintf(stderr, "+Installed: %s\n", p));
 						if (strlen(p) < 1)
@@ -1373,7 +1377,7 @@ print_Pkg(int full, const depend_atom *atom, const struct pkg_t *pkg)
 		if (strcmp(pkg->REPO, "gentoo") != 0)
 			printf(" %sRepo%s:%s %s\n", DKGREEN, YELLOW, NORM, pkg->REPO);
 
-	if ((p = best_version(pkg->CATEGORY, atom->PN)) != NULL) {
+	if ((p = best_version(pkg->CATEGORY, atom->PN, pkg->SLOT)) != NULL) {
 		if (*p) {
 			int ret;
 			const char *icolor = RED;
@@ -1475,6 +1479,7 @@ grab_binpkg_info(const char *name)
 	static char best_match[sizeof(Pkg.PF)+2+sizeof(Pkg.CATEGORY)];
 
 	best_match[0] = 0;
+	strcpy(pkg->SLOT,"0");
 
 	fp = open_binpkg_index();
 
@@ -1511,6 +1516,7 @@ grab_binpkg_info(const char *name)
 					atom_implode(atom);
 				}
 				memset(pkg, 0, sizeof(struct pkg_t));
+				strcpy(pkg->SLOT,"0");
 			}
 			continue;
 		}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-23 11:08 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-23 11:08 UTC (permalink / raw
  To: gentoo-commits

commit:     eedb0ea266b78efd84bc34bc2c6602fb713ba590
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Thu Mar  8 21:53:51 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 23 11:01:55 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=eedb0ea2

qmerge: Only fetch Packages if -f/-F is specified

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index ff55a0c..ebd4960 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -190,8 +190,8 @@ qmerge_initialize(void)
 	mkdir_p(buf, 0755);
 	xchdir(buf);
 
-	if (force_download != 2) {
-		if (force_download)
+	if (force_download) {
+		if (force_download == 2)
 			unlink(Packages);
 
 		if (access(Packages, R_OK) != 0)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-03-23  9:37 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-03-23  9:37 UTC (permalink / raw
  To: gentoo-commits

commit:     18966cfe95666636562a1b06b800b711a3e4ab9e
Author:     Joakim Tjernlund <joakim.tjernlund <AT> infinera <DOT> com>
AuthorDate: Thu Mar  8 21:53:50 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Mar 23 09:19:06 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=18966cfe

ED/EROOT needs '/' appended

Some pkgs does needs it, dev-lang/python-exec is one.

Signed-off-by: Joakim Tjernlund <joakim.tjernlund <AT> infinera.com>
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 qmerge.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 07da4cc..ff55a0c 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -466,9 +466,9 @@ pkg_run_func_at(int dirfd, const char *vdb_path, const char *phases, const char
 		"FILESDIR=/.does/not/exist/anywhere\n"
 		"MERGE_TYPE=binary\n"
 		"ROOT='%4$s'\n"
-		"EROOT=\"${EPREFIX%%/}/${ROOT#/}\"\n"
+		"EROOT=\"${EPREFIX%%/}/${ROOT#/}/\"\n"
 		"D=\"%5$s\"\n"
-		"ED=\"${EPREFIX%%/}/${D#/}\"\n"
+		"ED=\"${EPREFIX%%/}/${D#/}/\"\n"
 		"T=\"%6$s\"\n"
 		/* Finally run the func */
 		"%7$s%2$s\n"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-01-08 12:33 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-01-08 12:33 UTC (permalink / raw
  To: gentoo-commits

commit:     604df91aa544b65a6630b281b8a91d811c24e3f6
Author:     Matthew White <mehw.is.me <AT> inventati <DOT> org>
AuthorDate: Sun Jan  7 06:10:01 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Mon Jan  8 12:32:27 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=604df91a

read_repos_conf: reject ~ postfixed files (aka backup files)

* main.c (read_repos_conf): Exclude backup files (aka files with ~ as
  postfix) from processing when reading the repos_conf directory.

The old behaviour was to process any file found in repos_conf (i.e.
/etc/portage/repos.conf/*), except those beginning with '.'.  This
meant that '.', '..', and '.file' are rejected, but 'file.conf~' is
accepted. Since 'file.conf~' is a backup file, by default it should
rather not be processed.

Bug: https://bugs.gentoo.org/643820
Signed-off-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/main.c b/main.c
index b118ab8..b11fe83 100644
--- a/main.c
+++ b/main.c
@@ -513,6 +513,10 @@ read_repos_conf(const char *configroot, const char *repos_conf)
 			if (name[0] == '.')
 				continue;
 
+			/* Exclude backup files (aka files with ~ as postfix). */
+			if (name[0] != '\0' && name[strlen(name) - 1] == '~')
+				continue;
+
 #ifdef DT_UNKNOWN
 			if (confs[i]->d_type != DT_UNKNOWN &&
 			    confs[i]->d_type != DT_REG &&


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2018-01-08 12:33 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2018-01-08 12:33 UTC (permalink / raw
  To: gentoo-commits

commit:     73de0b4c50f9b36a01d81fd57211ff33b6df2c57
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 29 11:57:38 2017 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Dec 29 11:57:38 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=73de0b4c

README: mention the configure alternative

 README.md | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 3889ee2..fb8d800 100644
--- a/README.md
+++ b/README.md
@@ -13,7 +13,8 @@ of information.  The focus is on size and speed, so everything is in C.
 
 ## Building
 
-Just run `make`.  This should work on any recent POSIX compliant system.
+Just run `make`.  This should work on any recent Linux system.
+Alternatively, run `configure` followed by `make`.
 
 ## Helping out
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2017-12-29 11:45 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2017-12-29 11:45 UTC (permalink / raw
  To: gentoo-commits

commit:     145d84eaf87d95cb0ab581c573aff941fa4fe404
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 29 11:07:26 2017 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Dec 29 11:16:41 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=145d84ea

initialize_portage_env: fix PORTAGE_CONFIGROOT usage

All things on top of PORTAGE_CONFIGROOT need to be relative, so don't
add EPREFIX on top of it.

 main.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/main.c b/main.c
index dea03a8..b118ab8 100644
--- a/main.c
+++ b/main.c
@@ -844,16 +844,16 @@ initialize_portage_env(void)
 	/* figure out where to find our config files */
 	const char *configroot = getenv("PORTAGE_CONFIGROOT");
 	if (!configroot)
-		configroot = "/";
+		configroot = CONFIG_EPREFIX "/";
 
 	/* walk all the stacked profiles */
-	read_portage_profile(configroot, CONFIG_EPREFIX "etc/make.profile", vars_to_read);
-	read_portage_profile(configroot, CONFIG_EPREFIX "etc/portage/make.profile", vars_to_read);
+	read_portage_profile(configroot, "/etc/make.profile", vars_to_read);
+	read_portage_profile(configroot, "/etc/portage/make.profile", vars_to_read);
 
 	/* now read all the config files */
 	read_portage_env_file("", CONFIG_EPREFIX "usr/share/portage/config/make.globals", vars_to_read);
-	read_portage_env_file(configroot, CONFIG_EPREFIX "etc/make.conf", vars_to_read);
-	read_portage_env_file(configroot, CONFIG_EPREFIX "etc/portage/make.conf", vars_to_read);
+	read_portage_env_file(configroot, "/etc/make.conf", vars_to_read);
+	read_portage_env_file(configroot, "/etc/portage/make.conf", vars_to_read);
 
 	/* finally, check the env */
 	for (i = 0; vars_to_read[i].name; ++i) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2017-12-29 11:45 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2017-12-29 11:45 UTC (permalink / raw
  To: gentoo-commits

commit:     e423a9f20007493d134cae3f3bd0b665faedcf83
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 29 09:18:57 2017 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Dec 29 11:16:31 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e423a9f2

q_main: implement executable path resolution for Darwin and Solaris

 q.c | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/q.c b/q.c
index ea1fb4d..ff79643 100644
--- a/q.c
+++ b/q.c
@@ -6,6 +6,10 @@
  * Copyright 2005-2014 Mike Frysinger  - <vapier@gentoo.org>
  */
 
+#if defined(__MACH__)
+#include <libproc.h>
+#endif
+
 #define Q_FLAGS "irmM:" COMMON_FLAGS
 static struct option const q_long_opts[] = {
 	{"install",       no_argument, NULL, 'i'},
@@ -115,7 +119,21 @@ int q_main(int argc, char **argv)
 		if (!quiet)
 			printf("Installing symlinks:\n");
 
+#if defined(__MACH__)
+		rret = proc_pidpath(getpid(), buf, sizeof(buf));
+		if (rret != -1)
+			rret = strlen(buf);
+#elif defined(__sun) && defined(__SVR4)
+		prog = getexecname();
+		rret = strlen(prog);
+		if (rret > sizeof(buf) - 1) {
+			rret = -1;
+		} else {
+			strncpy(buf, prog, rret);
+		}
+#else
 		rret = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
+#endif
 		if (rret == -1) {
 			warnfp("haha no symlink love for you");
 			return 1;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2017-12-29 11:45 Fabian Groffen
  0 siblings, 0 replies; 592+ messages in thread
From: Fabian Groffen @ 2017-12-29 11:45 UTC (permalink / raw
  To: gentoo-commits

commit:     71c3f760cd6f19b89500abea08747edfa344699d
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 29 11:25:56 2017 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Dec 29 11:25:56 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=71c3f760

Makefile.am: update after autogen.sh run

 Makefile.am | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 7d4a301..d609b3f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -96,11 +96,11 @@ APPLETS += \
 	qxpak
 EXTRA_DIST += \
 	applets.h \
+	config.h \
 	include_applets.h \
 	libq/atom_compare.c \
 	libq/atom_explode.c \
 	libq/basename.c \
-	libq/binpackages.c \
 	libq/busybox.h \
 	libq/colors.c \
 	libq/compat.c \
@@ -162,6 +162,10 @@ EXTRA_DIST += \
 	tests/atom_explode/basic.tests \
 	tests/atom_explode/dotest \
 	tests/atom_explode/test.c \
+	tests/copy_file/.gitignore \
+	tests/copy_file/Makefile \
+	tests/copy_file/dotest \
+	tests/copy_file/test.c \
 	tests/init.sh \
 	tests/install/.gitignore \
 	tests/install/Makefile \


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2017-11-27  7:55 Robin H. Johnson
  0 siblings, 0 replies; 592+ messages in thread
From: Robin H. Johnson @ 2017-11-27  7:55 UTC (permalink / raw
  To: gentoo-commits

commit:     237d1b34166fea2e4cb0eb28098a5b2759548b86
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 27 07:50:58 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Nov 27 07:51:07 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=237d1b34

Fix PORTAGE_QUIET quiet result.

Having PORTAGE_QUIET set caused the quiet variable to be incremented,
but it did not also setup the warnout variable.

Add a common setup function for warnout quiet, and use consistently.

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 main.c | 13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c
index d124695..dea03a8 100644
--- a/main.c
+++ b/main.c
@@ -78,6 +78,15 @@ no_colors(void)
 	setenv("NOCOLOR", "true", 1);
 }
 
+static void
+setup_quiet(void)
+{
+	/* "e" for FD_CLOEXEC */
+	if (quiet == 0)
+		warnout = fopen("/dev/null", "we");
+	++quiet;
+}
+
 /* include common applet defs */
 #include "applets.h"
 
@@ -102,7 +111,7 @@ no_colors(void)
 #define COMMON_GETOPTS_CASES(applet) \
 	case 0x1: portroot = optarg; break; \
 	case 'v': ++verbose; break; \
-	case 'q': if (quiet == 0) { warnout = fopen("/dev/null", "we"); } ++quiet; break; \
+	case 'q': setup_quiet(); break; \
 	case 'V': version_barf(); break; \
 	case 'h': applet ## _usage(EXIT_SUCCESS); break; \
 	case 'C': no_colors(); break; \
@@ -952,7 +961,7 @@ initialize_portage_env(void)
 		xarraypush_str(overlays, main_overlay);
 
 	if (getenv("PORTAGE_QUIET") != NULL)
-		quiet = 1;
+		setup_quiet();
 
 	if (nocolor)
 		no_colors();


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2017-11-27  7:55 Robin H. Johnson
  0 siblings, 0 replies; 592+ messages in thread
From: Robin H. Johnson @ 2017-11-27  7:55 UTC (permalink / raw
  To: gentoo-commits

commit:     89524269b57888bb86a34c6fd7ef0422699fd30b
Author:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
AuthorDate: Mon Nov 27 07:53:57 2017 +0000
Commit:     Robin H. Johnson <robbat2 <AT> gentoo <DOT> org>
CommitDate: Mon Nov 27 07:53:57 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=89524269

Fix -Wmaybe-uninitialized.

In file included from include_applets.h:13:0,
                 from main.c:1485:
qgrep.c: In function ‘qgrep_main’:
qgrep.c:212:5: warning: ‘dentry’ may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (*cat_dirent_pt == NULL || *cat_dir_pt == NULL)
     ^
qgrep.c:245:17: note: ‘dentry’ was declared here
  struct dirent *dentry;

Signed-off-by: Robin H. Johnson <robbat2 <AT> gentoo.org>

 qgrep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qgrep.c b/qgrep.c
index 9d2752e..0680035 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -242,7 +242,7 @@ int qgrep_main(int argc, char **argv)
 	DIR *eclass_dir = NULL;
 	DIR *vdb_dir = NULL;
 	DIR *cat_dir = NULL;
-	struct dirent *dentry;
+	struct dirent *dentry = NULL;
 	char ebuild[_Q_PATH_MAX];
 	char name[_Q_PATH_MAX];
 	char *label;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2017-02-07  3:03 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2017-02-07  3:03 UTC (permalink / raw
  To: gentoo-commits

commit:     b7edba4e6c51901f40aefca78be5095e9dd434a4
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb  7 02:58:50 2017 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb  7 02:58:50 2017 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b7edba4e

avoid assert() with active code

Since assert can be compiled out via -DNDEBUG, make sure
we don't put function calls in there we need to work.

Reported-by: Ian Coolidge <icoolidge <AT> google.com>

 qmerge.c | 6 ++++--
 qxpak.c  | 4 +++-
 2 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index e84fcbb..07da4cc 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -902,11 +902,13 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 
 	/* split the tbz and xpak data */
 	xasprintf(&tbz2, "%s/%s/%s.tbz2", pkgdir, pkg->CATEGORY, pkg->PF);
-	assert(run_applet_l("qtbz2", "-s", tbz2, NULL) == 0);
+	if (run_applet_l("qtbz2", "-s", tbz2, NULL) != 0)
+		err("`qtbz2 -s %s` failed", tbz2);
 
 	mkdir("vdb", 0755);
 	sprintf(tbz2, "%s.xpak", pkg->PF);
-	assert(run_applet_l("qxpak", "-d", "vdb", "-x", tbz2, NULL) == 0);
+	if (run_applet_l("qxpak", "-d", "vdb", "-x", tbz2, NULL) != 0)
+		err("`qxpak -d vdb -x %s` failed", tbz2);
 
 	free(tbz2);
 

diff --git a/qxpak.c b/qxpak.c
index 58b29ef..95fb779 100644
--- a/qxpak.c
+++ b/qxpak.c
@@ -154,6 +154,7 @@ xpak_list(int dir_fd, const char *file, int argc, char **argv)
 {
 	_xpak_archive *x;
 	char buf[BUFSIZE];
+	size_t ret;
 
 	x = _xpak_open(file);
 	if (!x)
@@ -162,7 +163,8 @@ xpak_list(int dir_fd, const char *file, int argc, char **argv)
 	x->dir_fd = dir_fd;
 	x->index = buf;
 	assert((size_t)x->index_len < sizeof(buf));
-	assert(fread(x->index, 1, x->index_len, x->fp) == (size_t)x->index_len);
+	ret = fread(x->index, 1, x->index_len, x->fp);
+	assert(ret == (size_t)x->index_len);
 	_xpak_walk_index(x, argc, argv, &_xpak_list_callback);
 
 	_xpak_close(x);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-12-29  2:33 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-12-29  2:33 UTC (permalink / raw
  To: gentoo-commits

commit:     dd9b8dfe0752fd9422782312ba85b4229ee54722
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 29 02:32:25 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Dec 29 02:32:25 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=dd9b8dfe

qtbz2: improve cli a bit

Make -t/-x options autoselect the split action.
Allow -d to be specified more than once.
When given a bad -d path, diagnose it immediately.
When we can't autodetect actions, show a specific error message.

 qtbz2.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/qtbz2.c b/qtbz2.c
index 3c2e9f0..2161f99 100644
--- a/qtbz2.c
+++ b/qtbz2.c
@@ -252,13 +252,15 @@ int qtbz2_main(int argc, char **argv)
 		COMMON_GETOPTS_CASES(qtbz2)
 		case 'j': action = TBZ2_ACT_JOIN; break;
 		case 's': action = TBZ2_ACT_SPLIT; break;
-		case 't': split_xpak = 0; break;
-		case 'x': split_tarbz2 = 0; break;
+		case 't': action = TBZ2_ACT_SPLIT; split_xpak = 0; break;
+		case 'x': action = TBZ2_ACT_SPLIT; split_tarbz2 = 0; break;
 		case 'O': tbz2_stdout = 1; break;
 		case 'd':
 			if (dir_fd != AT_FDCWD)
-				err("Only use -d once");
+				close(dir_fd);
 			dir_fd = open(optarg, O_RDONLY|O_CLOEXEC|O_PATH);
+			if (unlikely(dir_fd == -1))
+				errp("could not open dir: %s", optarg);
 			break;
 		}
 	}
@@ -279,7 +281,8 @@ int qtbz2_main(int argc, char **argv)
 		else if (strstr(argv[optind], ".tbz2") != NULL)
 			action = TBZ2_ACT_SPLIT;
 		else
-			qtbz2_usage(EXIT_FAILURE);
+			err("%s: need to use -j or -s, or file must end in .tar.bz2 or .tbz2 to autodetect",
+				argv[optind]);
 	}
 
 	/* tbz2tool join .tar.bz2 .xpak .tbz2 */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-12-29  2:25 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-12-29  2:25 UTC (permalink / raw
  To: gentoo-commits

commit:     45f8462493056b8ca0634ac0c8942c171deee075
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 29 02:22:06 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Dec 29 02:22:06 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=45f84624

cache: add sanity check on malformed cache files

 main.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/main.c b/main.c
index 33db01a..d124695 100644
--- a/main.c
+++ b/main.c
@@ -1215,6 +1215,10 @@ cache_read_file_pms(const char *file)
 	next_line(EAPI, PROPERTIES)
 #undef next_line
 	ptr = strchr(ptr+1, '\n');
+	if (ptr == NULL) {
+		warn("Invalid cache file '%s' - could not find end of cache data", file);
+		goto err;
+	}
 	*ptr = '\0';
 
 	fclose(f);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-12-29  2:25 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-12-29  2:25 UTC (permalink / raw
  To: gentoo-commits

commit:     6b5210240228f6bbc67b3e32af1d840a8e66b645
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 29 02:16:54 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Dec 29 02:16:54 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6b521024

qmerge: pass struct by ref instead of value

Avoids having to create a copy of a large struct whenever we make a call.

 qmerge.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 2c92599..05e46b4 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -287,7 +287,7 @@ config_protected(const char *buf, int cp_argc, char **cp_argv,
 }
 
 static void
-crossmount_rm(const char *fname, const struct stat st)
+crossmount_rm(const char *fname, const struct stat * const st)
 {
 	struct stat lst;
 
@@ -295,7 +295,7 @@ crossmount_rm(const char *fname, const struct stat st)
 
 	if (lstat(fname, &lst) == -1)
 		return;
-	if (lst.st_dev != st.st_dev) {
+	if (lst.st_dev != st->st_dev) {
 		warn("skipping crossmount install masking: %s", fname);
 		return;
 	}
@@ -304,7 +304,7 @@ crossmount_rm(const char *fname, const struct stat st)
 }
 
 static void
-install_mask_pwd(int iargc, char **iargv, const struct stat st)
+install_mask_pwd(int iargc, char **iargv, const struct stat * const st)
 {
 	char buf[1024];
 	int i;
@@ -931,7 +931,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	makeargv(install_mask, &iargc, &iargv);
 	/* XXX: Would be better if INSTALL_MASK deleted from image/
 	 *      so we didn't have to parse it while doing merge_tree() */
-	install_mask_pwd(iargc, iargv, st);
+	install_mask_pwd(iargc, iargv, &st);
 
 	if (strstr(features, "noinfo")) rm_rf("./usr/share/info");
 	if (strstr(features, "noman" )) rm_rf("./usr/share/man");


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-12-29  2:25 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-12-29  2:25 UTC (permalink / raw
  To: gentoo-commits

commit:     b9978cef4d2844c2b7ee3cdaf90477259aa758fe
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 29 02:15:22 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Dec 29 02:15:22 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b9978cef

qpkg: fix leakage when using -P multiple times

 qpkg.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/qpkg.c b/qpkg.c
index c54d735..498299a 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -324,6 +324,7 @@ int qpkg_main(int argc, char **argv)
 		case 'p': pretend = 1; break;
 		case 'P':
 			restrict_chmod = 1;
+			free(qpkg_bindir);
 			qpkg_bindir = xstrdup(optarg);
 			if (access(qpkg_bindir, W_OK) != 0)
 				errp("%s", qpkg_bindir);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-12-29  2:25 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-12-29  2:25 UTC (permalink / raw
  To: gentoo-commits

commit:     ae34cc566f072a90ef3453978fee8b4adcd75adf
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 29 02:19:04 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Dec 29 02:19:04 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ae34cc56

qmerge: tweak case style to suppress coverity warning

 qmerge.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 05e46b4..e84fcbb 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1869,7 +1869,9 @@ int qmerge_main(int argc, char **argv)
 			case 'K': install = 1; break;
 			case 'U': uninstall = 1; break;
 			case 'p': pretend = 1; break;
-			case 'u': update_only = 1;
+			case 'u':
+				update_only = 1;
+				/* fall through */
 			case 'y': interactive = 0; break;
 			case 'O': follow_rdepends = 0; break;
 			case 128: debug = true; break;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-12-29  2:25 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-12-29  2:25 UTC (permalink / raw
  To: gentoo-commits

commit:     5afabfc0042833b548309a918ad84bbdebfefd05
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 29 02:13:43 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Dec 29 02:13:43 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5afabfc0

qtbz2: fix leakage of dir_fd via the -d option

 qtbz2.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/qtbz2.c b/qtbz2.c
index 723ad27..3c2e9f0 100644
--- a/qtbz2.c
+++ b/qtbz2.c
@@ -353,9 +353,14 @@ int qtbz2_main(int argc, char **argv)
 			warn("Could not decompose '%s'", tbz2);
 	}
 
+	/* We have to cleanup all resources as we're used indirectly
+	 * (e.g. via qmerge).
+	 */
 	free(heap_tbz2);
 	free(heap_xpak);
 	free(heap_tarbz2);
+	if (dir_fd != AT_FDCWD)
+		close(dir_fd);
 
 	return EXIT_SUCCESS;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-12-29  2:25 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-12-29  2:25 UTC (permalink / raw
  To: gentoo-commits

commit:     d6d33b2ef60f3700702e59f8cdf718b7dd3fb886
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Wed Dec 28 22:33:45 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed Dec 28 22:33:45 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d6d33b2e

move system headers to porting.h to avoid duplication

 porting.h |  3 +++
 qcache.c  | 10 ----------
 qmerge.c  |  3 ---
 qpkg.c    |  2 --
 4 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/porting.h b/porting.h
index 28b6317..b166bc1 100644
--- a/porting.h
+++ b/porting.h
@@ -30,7 +30,10 @@
 #include <ctype.h>
 #include <dirent.h>
 #include <errno.h>
+#include <fcntl.h>
+#include <fnmatch.h>
 #include <getopt.h>
+#include <glob.h>
 #include <inttypes.h>
 #include <libgen.h>
 #include <limits.h>

diff --git a/qcache.c b/qcache.c
index 535d7a2..c5421c7 100644
--- a/qcache.c
+++ b/qcache.c
@@ -7,16 +7,6 @@
 
 #ifdef APPLET_qcache
 
-#include <dirent.h>
-#include <fcntl.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <time.h>
-#include <unistd.h>
-
 /********************************************************************/
 /* Required portage-utils stuff                                     */
 /********************************************************************/

diff --git a/qmerge.c b/qmerge.c
index 68459c9..4ef156b 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -8,9 +8,6 @@
 
 #ifdef APPLET_qmerge
 
-#include <fnmatch.h>
-#include <glob.h>
-#include <sys/stat.h>
 /* This is a GNUlib hack, because GNUlib doesn't provide st_mtim members
  * of struct stat, but instead provides wrappers to retrieve the time
  * fields (stat-time module). We just define a macro in case people are

diff --git a/qpkg.c b/qpkg.c
index 2cc658e..1c18edc 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -8,8 +8,6 @@
 
 #ifdef APPLET_qpkg
 
-#include <fnmatch.h>
-
 #define QPKG_FLAGS "cEpP:" COMMON_FLAGS
 static struct option const qpkg_long_opts[] = {
 	{"clean",    no_argument, NULL, 'c'},


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-12-20 19:15 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-12-20 19:15 UTC (permalink / raw
  To: gentoo-commits

commit:     e2897872598b390b79e09d878738cfac3b3380ac
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 20 19:14:58 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Dec 20 19:14:58 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e2897872

main: rework path handling to avoid unsafe strncat

While this strncat shouldn't cause a problem, we can refactor the code
a bit to avoid it entirely, and check the earlier snprintf result to
boot.  This also avoids warnings from clang about bad args to strncat.

 main.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/main.c b/main.c
index af2ccce..543ac36 100644
--- a/main.c
+++ b/main.c
@@ -1382,14 +1382,20 @@ _q_static queue *get_vdb_atoms(int fullcpv)
 		if ((dfd = scandirat(ctx->vdb_fd, cat[j]->d_name, &pf, q_vdb_filter_pkg, alphasort)) < 0)
 			continue;
 		for (i = 0; i < dfd; i++) {
-			snprintf(buf, sizeof(buf), "%s/%s", cat[j]->d_name, pf[i]->d_name);
+			int blen = snprintf(buf, sizeof(buf), "%s/%s/SLOT", cat[j]->d_name, pf[i]->d_name);
+			if (blen >= sizeof(buf)) {
+				warnf("unable to parse long package: %s/%s", cat[j]->d_name, pf[i]->d_name);
+				continue;
+			}
+
+			/* Chop the SLOT for the atom parsing. */
+			buf[blen - 5] = '\0';
 			if ((atom = atom_explode(buf)) == NULL)
 				continue;
+			/* Restore the SLOT. */
+			buf[blen - 5] = '/';
 
-			/* XXX: This assumes static slot buf is big enough, but should be fine
-			 * until this is rewritten & merged into libq/vdb.c. */
 			slot_len = sizeof(slot);
-			strncat(buf, "/SLOT", sizeof(buf));
 			eat_file_at(ctx->vdb_fd, buf, &slotp, &slot_len);
 			rmspace(slot);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-12-20 16:55 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-12-20 16:55 UTC (permalink / raw
  To: gentoo-commits

commit:     9909f96b644a812e93916c91bac0fdc1a4c586c3
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Dec 20 16:54:52 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Dec 20 16:54:52 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9909f96b

qmerge: fix clang -Wpointer-bool-conversion warning

 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index c7b928e..68459c9 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -771,7 +771,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	if (!install || !pkg || !atom)
 		return;
 
-	if (!pkg->PF[0] || !pkg->CATEGORY) {
+	if (!pkg->PF[0] || !pkg->CATEGORY[0]) {
 		if (verbose) warn("CPF is really NULL at level %d", level);
 		return;
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-27  5:46 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-27  5:46 UTC (permalink / raw
  To: gentoo-commits

commit:     11e32f92d619d4b3769dce94f7a1bff0b9341444
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 27 03:56:47 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Nov 27 03:56:47 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=11e32f92

autotools: update source list

 Makefile.am | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 362ee21..7b9c35b 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -178,6 +178,8 @@ EXTRA_DIST += \
 	tests/profile/profile1/etc/portage/make.conf \
 	tests/profile/profile1/etc/portage/subdir/file.conf \
 	tests/profile/profile1/etc/portage/this.level.conf \
+	tests/qatom/Makefile \
+	tests/qatom/dotest \
 	tests/qcheck/Makefile \
 	tests/qcheck/dotest \
 	tests/qcheck/list01.good \
@@ -236,6 +238,7 @@ EXTRA_DIST += \
 	tests/qlist/list13.good \
 	tests/qlist/list14.good \
 	tests/qlist/list15.good \
+	tests/qlist/list16.good \
 	tests/qlist/root/-merge-foo/CONTENTS \
 	tests/qlist/root/a-b/a-0/CONTENTS \
 	tests/qlist/root/a-b/a-0/SLOT \
@@ -258,8 +261,15 @@ EXTRA_DIST += \
 	tests/qlop/Makefile \
 	tests/qlop/dotest \
 	tests/qlop/list01.good \
+	tests/qlop/list02.good \
+	tests/qlop/list03.good \
+	tests/qlop/list04.good \
+	tests/qlop/list05.good \
+	tests/qlop/list06.good \
+	tests/qlop/list07.good \
+	tests/qlop/list08.good \
 	tests/qlop/sync.log \
-	tests/qmerge/.gdb_history \
+	tests/qlop/test04.good \
 	tests/qmerge/Makefile \
 	tests/qmerge/dotest \
 	tests/qmerge/packages/Packages \
@@ -281,6 +291,10 @@ EXTRA_DIST += \
 	tests/qxpak/list02.good \
 	tests/reinitialize/Makefile \
 	tests/reinitialize/dotest \
+	tests/rmspace/.gitignore \
+	tests/rmspace/Makefile \
+	tests/rmspace/dotest \
+	tests/rmspace/test.c \
 	tests/source/Makefile \
 	tests/source/dotest \
 	tests/source/space \


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-27  5:46 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-27  5:46 UTC (permalink / raw
  To: gentoo-commits

commit:     4c9a3b2f82783e7a97c4503778aadb1d2b06e14b
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 27 05:04:57 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Nov 27 05:04:57 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4c9a3b2f

build: add lazy support for STATIC=yes builds

 Makefile | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index baa27c2..949b375 100644
--- a/Makefile
+++ b/Makefile
@@ -22,7 +22,8 @@ CPPFLAGS  ?=
 CPPFLAGS  += -DENABLE_NLS=$(call istrue,$(NLS))
 DBG_CFLAGS = -O0 -DEBUG -g3 -ggdb -fno-pie $(call check_gcc, -fsanitize=address -fsanitize=leak -fsanitize=undefined)
 #CFLAGS   += -Os -DOPTIMIZE_FOR_SIZE=2 -falign-functions=2 -falign-jumps=2 -falign-labels=2 -falign-loops=2
-#LDFLAGS  := -pie
+LDFLAGS_static_1 = -static
+LDFLAGS   += $(LDFLAGS_static_$(call istrue,$(STATIC)))
 LIBADD    += $(shell echo | $(CC) -dM -E - | grep -q ' __FreeBSD__' && echo '-lkvm')
 LIBADD    += -liniparser
 DESTDIR   :=


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-27  5:46 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-27  5:46 UTC (permalink / raw
  To: gentoo-commits

commit:     1fef622745ef3ce4c8baaf6aef46686e91c7c5ed
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 27 05:20:44 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Nov 27 05:20:44 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1fef6227

build: update names of docs after markdown conversion

 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 949b375..7c64fe9 100644
--- a/Makefile
+++ b/Makefile
@@ -50,7 +50,7 @@ endif
 ifndef PF
 PF        := portage-utils-$(PV)
 endif
-DOCS      := TODO README qsync
+DOCS      := TODO.md README.md qsync
 
 #ifdef PYTHON
 #PYFLAGS   ?= $(shell python-config) -DWANT_PYTHON -ldl -pthread -lutil /usr/lib/libpython2.4.so


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-27  1:52 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-27  1:52 UTC (permalink / raw
  To: gentoo-commits

commit:     e2e85efc16e3bc2bc7defccc8f184a704f533988
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 27 01:52:02 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Nov 27 01:52:02 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e2e85efc

cache: fix open cache file leakage

 main.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/main.c b/main.c
index b99768d..af2ccce 100644
--- a/main.c
+++ b/main.c
@@ -1206,6 +1206,7 @@ portage_cache *cache_read_file_pms(const char *file)
 	return ret;
 
 err:
+	if (f) fclose(f);
 	if (ret) cache_free(ret);
 	return NULL;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-27  1:50 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-27  1:50 UTC (permalink / raw
  To: gentoo-commits

commit:     e61179d1b30ac9b95d85788c320b6cfcb567171a
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 27 01:50:36 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Nov 27 01:50:36 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e61179d1

cache: fix fclose(NULL) error when cache reading fails

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index ff7648d..b99768d 100644
--- a/main.c
+++ b/main.c
@@ -1303,7 +1303,7 @@ portage_cache *cache_read_file_md5(const char *file)
 	return ret;
 
 err:
-	fclose(f);
+	if (f) fclose(f);
 	if (ret) cache_free(ret);
 	return NULL;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-27  0:00 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-27  0:00 UTC (permalink / raw
  To: gentoo-commits

commit:     e98d5c97eef7533ec49ad46bbecba60ac38f430f
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 27 00:00:02 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Nov 27 00:00:02 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e98d5c97

qxpak: check -d argument

 qxpak.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/qxpak.c b/qxpak.c
index baceda9..aa1a281 100644
--- a/qxpak.c
+++ b/qxpak.c
@@ -393,6 +393,8 @@ int qxpak_main(int argc, char **argv)
 			if (dir_fd != AT_FDCWD)
 				err("Only use -d once");
 			dir_fd = open(optarg, O_RDONLY|O_CLOEXEC|O_PATH);
+			if (dir_fd < 0)
+				errp("Could not open directory %s", optarg);
 			break;
 		}
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-26 23:48 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-26 23:48 UTC (permalink / raw
  To: gentoo-commits

commit:     e1da9e5bde6c18bd9bd411ce20cdacdcb97e135c
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 26 23:34:33 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Nov 26 23:34:33 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e1da9e5b

rewrite docs in markdown for github integration

 HACKING    | 32 --------------------------
 HACKING.md | 20 ++++++++++++++++
 README     | 31 -------------------------
 README.md  | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 TODO       | 59 -----------------------------------------------
 TODO.md    | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 169 insertions(+), 122 deletions(-)

diff --git a/HACKING b/HACKING
deleted file mode 100644
index 67dbbaf..0000000
--- a/HACKING
+++ /dev/null
@@ -1,32 +0,0 @@
-- Adding applets is easy using the q framework.
-  Note: Please try to keep applet names under 8 chars.
-	* cp template.c qmyapplet.c (all applets use the prefix of the letter 'q') 
-	* applets.h: add your prototype (see DECLARE_APPLET macro)
-	* applets.h: add a new line to applets[] following the existing syntax
-	* run `make depend` to auto regenerate dependent files
-
-When and where you can please try to use an existing applet and extend 
-on its functionality by adding more options vs adding a bunch of new 
-little applets.
-
-- Keep behavior consistent
-	* matching:
-		default is sloppy match
-		-e exact match
-		-r regex match
-
-## Examples:
-	* find elf files linking to old openssl
-	qlist -ao | scanelf -BqgN libssl.so.0.9.6 -f -
-
-	* print a package.use
-	qlist -UCq | grep ' ' > package.use
-
-	* find orphan files not owned by any package in /lib and /usr/lib
-	qfile -o {,/usr}/lib/*
-	
-	# get PORTDIR
-	DEBUG=: ./q -Ch 2>&1 | grep ^PORTDIR | awk '{print $3}
-
-	# Verify all packages
-	qcheck -a

diff --git a/HACKING.md b/HACKING.md
new file mode 100644
index 0000000..e0536fa
--- /dev/null
+++ b/HACKING.md
@@ -0,0 +1,20 @@
+# New applets
+
+Adding applets is easy using the q framework.
+
+Note: Please try to keep applet names under 8 chars.
+
+- cp template.c qmyapplet.c (all applets use the prefix of the letter 'q') 
+- applets.h: add your prototype (see DECLARE_APPLET macro)
+- applets.h: add a new line to applets[] following the existing syntax
+- run `make depend` to auto regenerate dependent files
+
+When and where you can please try to use an existing applet and extend 
+on its functionality by adding more options vs adding a bunch of new 
+little applets.
+
+- Keep behavior consistent
+	- matching:
+		- default is sloppy match
+		- -e exact match
+		- -r regex match

diff --git a/README b/README
deleted file mode 100644
index 1a8dc3d..0000000
--- a/README
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2005-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-Contact:
-  Please file bugs at:
-	https://bugs.gentoo.org/enter_bug.cgi?product=Portage%20Development&format=guided
-  Use Component of "Third-Party Tools".
-
-Current developer list:
-	solar@gentoo.org
-	vapier@gentoo.org
-
-
-- Speed is everything.
-  Having your PORTDIR and VDB on the right file system helps dramatically
-
-  IDE raid with PORTDIR on reiserfs:
-    q -r
-    q: Finished 20655 entries in 1.990951 seconds
-
-  IDE raid with PORTDIR on ext3:
-    q -r
-    q: Finished 20655 entries in 203.664252 seconds
-
-
-- Fetching via anon git:
-
-  git clone git://anongit.gentoo.org/proj/portage-utils.git
-
-You can view it online via gitweb:
-	https://gitweb.gentoo.org/proj/portage-utils.git/

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..3889ee2
--- /dev/null
+++ b/README.md
@@ -0,0 +1,72 @@
+# Gentoo Portage Utilities
+
+| What     | How                                                       |
+| -------- | --------------------------------------------------------- |
+| HOMEPAGE | https://wiki.gentoo.org/wiki/Portage-utils                |
+| GIT      | git clone git://anongit.gentoo.org/proj/portage-utils.git |
+| VIEWVCS  | https://gitweb.gentoo.org/proj/portage-utils.git/         |
+| STATUS   | [![Build Status](https://travis-ci.org/gentoo/portage-utils.svg?branch=master)](https://travis-ci.org/gentoo/portage-utils) [![Coverity Status](https://scan.coverity.com/projects/9213/badge.svg)](https://scan.coverity.com/projects/gentoo-portage-utils) |
+
+portage-utils is a small set of utilities for working with Portage, Gentoo
+ebuilds, Gentoo ebuild overlays, installed packages (vdb), and similar sources
+of information.  The focus is on size and speed, so everything is in C.
+
+## Building
+
+Just run `make`.  This should work on any recent POSIX compliant system.
+
+## Helping out
+
+There's a large [TODO](./TODO.md) list with various ideas for improvements.
+
+There's also a [HACKING](./HACKING.md) doc to help you get started.
+
+## Examples
+
+* find elf files linking to old openssl<br>
+  `qlist -ao | scanelf -BqgN libssl.so.0.9.6 -f -`
+
+* print a package.use<br>
+  `qlist -UCq | grep ' ' > package.use`
+
+* find orphan files not owned by any package in /lib and /usr/lib<br>
+  `qfile -o {,/usr}/lib/*`
+	
+* get PORTDIR<br>
+  `DEBUG=: ./q -Ch 2>&1 | grep ^PORTDIR | awk '{print $3}`
+
+* Verify all packages<br>
+  `qcheck -a`
+
+## Contact
+
+### Bugs
+
+Please file bugs at:
+	https://bugs.gentoo.org/enter_bug.cgi?product=Portage%20Development&format=guided
+
+Use Component of "Third-Party Tools".
+
+### Developers
+
+* solar@gentoo.org
+* vapier@gentoo.org
+
+## Notes
+
+### Speed is everything.
+
+Having your PORTDIR and VDB on the right file system helps dramatically
+
+IDE raid with PORTDIR on reiserfs:
+
+```
+$ q -r
+q: Finished 20655 entries in 1.990951 seconds
+
+IDE raid with PORTDIR on ext3:
+
+```
+$ q -r
+q: Finished 20655 entries in 203.664252 seconds
+```

diff --git a/TODO b/TODO
deleted file mode 100644
index 08e8bc3..0000000
--- a/TODO
+++ /dev/null
@@ -1,59 +0,0 @@
-- unify match behavior:
- default *foo*
- -e foo
- -r (-R ?) regexp foo.*
-
-- disable color when tty = NULL; may break less?
-
-- multiline reads don't yet work for quse/qsearch
-
-- standardize/unify/clean up misc handling of colors
-
-- speed up queue structure ... append walks the whole list
-
-- qmerge
-	- dep resolver needs spanktastic love.
-	- needs safe deleting (merge in place rather than unmerge;merge)
-	- multiple binary repos (talk to zmedico)
-	- handle compressed Packages file (talk to zmedico)
-	- handle binary Packages file (talk to zmedico)
-	- gpg sign the packages file (before compression)
-	- binary vdb (sqlite) ... talk to zmedico
-	- remote vdb
-	- don't bother emitting any "DIR" entries to CONTENTS ?
-		- auto rmdir any empty dirs
-	- avoid Packages fetching all the damned time
-	- parallel fetch tbz2s
-	- check order of pkg_{pre,post}{inst,rm} during install, unmerge, and upgrade
-	- env is not saved/restored between pkg_{pre,post}inst (see portage and REPO_LAYOUT_CONF_WARN)
-	- support installing via path to tbz2 package
-	- support TTL field in binpkgs file
-
-- atoms:
-	- only 32bit values are supported for revision (-r#)
-	- only 64bit values are supported in any individual version component
-		foo-(1234)_alpha(56789)
-	- these limits should not be an issue for all practical purposes
-	- need to handle USE deps like: cat/pkg-123[foo(+)]
-	- show support slots like: qmerge -U automake:1.12
-
-- qcache:
-	- need to convert it to new metadata/md5 style
-
-- qdepends:
-	- support querying uninstalled packages (via metadata/md5 cache)
-
-- env vars only get expanded once, so this fails:
-	ACCEPT_LICENSE="foo"
-	ACCEPT_LICENSE="${ACCEPT_LICENSE} bar"
-  we end up getting just:
-	ACCEPT_LICENSE=" bar"
-
-- qpkg:
-	- fix "would be freed" message when --pretend is *not* active
-	- add a verbose output that describes why a package is cleaned
-		- newer binpkgs available
-		- newer installed version available
-
-- qsync:
-	- rewrite to use new repos.conf standard

diff --git a/TODO.md b/TODO.md
new file mode 100644
index 0000000..86ebbd7
--- /dev/null
+++ b/TODO.md
@@ -0,0 +1,77 @@
+# Common
+
+- unify match behavior:
+	- default *foo*
+	- -e foo
+	- -r (-R ?) regexp foo.*
+
+- disable color when tty = NULL; may break less?
+
+- multiline reads don't yet work for quse/qsearch
+
+- standardize/unify/clean up misc handling of colors
+
+- speed up queue structure ... append walks the whole list
+
+- equiv of `equery m` (metadata)
+
+- env vars only get expanded once, so this fails:<br>
+  `ACCEPT_LICENSE="foo"`<br>
+  `ACCEPT_LICENSE="${ACCEPT_LICENSE} bar"`<br>
+  we end up getting just:<br>
+  `ACCEPT_LICENSE=" bar"`
+
+# Atoms
+
+- only 32bit values are supported for revision (-r#)
+- only 64bit values are supported in any individual version component
+  foo-(1234)_alpha(56789)
+- these limits should not be an issue for all practical purposes
+- need to handle USE deps like: cat/pkg-123[foo(+)]
+- show support slots like: qmerge -U automake:1.12
+
+# qmerge
+
+- dep resolver needs spanktastic love.
+- needs safe deleting (merge in place rather than unmerge;merge)
+- multiple binary repos (talk to zmedico)
+- handle compressed Packages file (talk to zmedico)
+- handle binary Packages file (talk to zmedico)
+- gpg sign the packages file (before compression)
+- binary vdb (sqlite) ... talk to zmedico
+- remote vdb
+- don't bother emitting any "DIR" entries to CONTENTS ?
+	- auto rmdir any empty dirs
+- avoid Packages fetching all the damned time
+- parallel fetch tbz2s
+- check order of pkg_{pre,post}{inst,rm} during install, unmerge, and upgrade
+- env is not saved/restored between pkg_{pre,post}inst (see portage and REPO_LAYOUT_CONF_WARN)
+- support installing via path to tbz2 package
+- support TTL field in binpkgs file
+- merge duplicate atoms on the CLI (`qmerge -Uq nano nano nano`)
+- unmerging should clean out @world set
+
+# qcache
+
+- need to convert it to new metadata/md5 style
+
+# qdepends
+
+- support querying uninstalled packages (via metadata/md5 cache)
+- support atoms like `qdepends -rQ qtsql:4` (should match unslotted deps)
+- add -S/-v/-R behavior like qlist #574934
+
+# qpkg
+
+- fix "would be freed" message when --pretend is *not* active
+- add a verbose output that describes why a package is cleaned
+	- newer binpkgs available
+	- newer installed version available
+
+# qsync
+
+- rewrite to use new repos.conf standard
+
+# qlist
+
+- support atoms instead of exact matches


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-26 23:46 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-26 23:46 UTC (permalink / raw
  To: gentoo-commits

commit:     ba9b4e7ce385dd12e3cac131d6997d1ef84ee162
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 26 23:34:33 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Nov 26 23:34:33 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ba9b4e7c

rewrite docs in markdown for github integration

 HACKING    | 32 --------------------------
 HACKING.md | 20 ++++++++++++++++
 README     | 31 -------------------------
 README.md  | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 TODO       | 59 -----------------------------------------------
 TODO.md    | 77 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 6 files changed, 169 insertions(+), 122 deletions(-)

diff --git a/HACKING b/HACKING
deleted file mode 100644
index 67dbbaf..0000000
--- a/HACKING
+++ /dev/null
@@ -1,32 +0,0 @@
-- Adding applets is easy using the q framework.
-  Note: Please try to keep applet names under 8 chars.
-	* cp template.c qmyapplet.c (all applets use the prefix of the letter 'q') 
-	* applets.h: add your prototype (see DECLARE_APPLET macro)
-	* applets.h: add a new line to applets[] following the existing syntax
-	* run `make depend` to auto regenerate dependent files
-
-When and where you can please try to use an existing applet and extend 
-on its functionality by adding more options vs adding a bunch of new 
-little applets.
-
-- Keep behavior consistent
-	* matching:
-		default is sloppy match
-		-e exact match
-		-r regex match
-
-## Examples:
-	* find elf files linking to old openssl
-	qlist -ao | scanelf -BqgN libssl.so.0.9.6 -f -
-
-	* print a package.use
-	qlist -UCq | grep ' ' > package.use
-
-	* find orphan files not owned by any package in /lib and /usr/lib
-	qfile -o {,/usr}/lib/*
-	
-	# get PORTDIR
-	DEBUG=: ./q -Ch 2>&1 | grep ^PORTDIR | awk '{print $3}
-
-	# Verify all packages
-	qcheck -a

diff --git a/HACKING.md b/HACKING.md
new file mode 100644
index 0000000..e0536fa
--- /dev/null
+++ b/HACKING.md
@@ -0,0 +1,20 @@
+# New applets
+
+Adding applets is easy using the q framework.
+
+Note: Please try to keep applet names under 8 chars.
+
+- cp template.c qmyapplet.c (all applets use the prefix of the letter 'q') 
+- applets.h: add your prototype (see DECLARE_APPLET macro)
+- applets.h: add a new line to applets[] following the existing syntax
+- run `make depend` to auto regenerate dependent files
+
+When and where you can please try to use an existing applet and extend 
+on its functionality by adding more options vs adding a bunch of new 
+little applets.
+
+- Keep behavior consistent
+	- matching:
+		- default is sloppy match
+		- -e exact match
+		- -r regex match

diff --git a/README b/README
deleted file mode 100644
index 1a8dc3d..0000000
--- a/README
+++ /dev/null
@@ -1,31 +0,0 @@
-# Copyright 2005-2014 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-
-Contact:
-  Please file bugs at:
-	https://bugs.gentoo.org/enter_bug.cgi?product=Portage%20Development&format=guided
-  Use Component of "Third-Party Tools".
-
-Current developer list:
-	solar@gentoo.org
-	vapier@gentoo.org
-
-
-- Speed is everything.
-  Having your PORTDIR and VDB on the right file system helps dramatically
-
-  IDE raid with PORTDIR on reiserfs:
-    q -r
-    q: Finished 20655 entries in 1.990951 seconds
-
-  IDE raid with PORTDIR on ext3:
-    q -r
-    q: Finished 20655 entries in 203.664252 seconds
-
-
-- Fetching via anon git:
-
-  git clone git://anongit.gentoo.org/proj/portage-utils.git
-
-You can view it online via gitweb:
-	https://gitweb.gentoo.org/proj/portage-utils.git/

diff --git a/README.md b/README.md
new file mode 100644
index 0000000..fc9448c
--- /dev/null
+++ b/README.md
@@ -0,0 +1,72 @@
+# Gentoo Portage Utilities
+
+| What     | How                                                       |
+| -------- | --------------------------------------------------------- |
+| HOMEPAGE | https://wiki.gentoo.org/wiki/Portage-utils                |
+| GIT      | git clone git://anongit.gentoo.org/proj/portage-utils.git |
+| VIEWVCS  | https://gitweb.gentoo.org/proj/portage-utils.git/         |
+| STATUS   | [![Build Status](https://travis-ci.org/gentoo/portage-utils.svg?branch=master)](https://travis-ci.org/gentoo/portage-utils) [![Coverity Status](https://scan.coverity.com/projects/9213/badge.svg)](https://scan.coverity.com/projects/gentoo-portage-utils) |
+
+portage-utils is a small set of utilities for working with Portage, Gentoo
+ebuilds, Gentoo ebuild overlays, installed packages (vdb), and similar sources
+of information.  The focus is on size and speed, so everything is in C.
+
+## Building
+
+Just run `make`.  This should work on any recent POSIX compliant system.
+
+## Helping out
+
+There's a large [TODO.md] list with various ideas for improvements.
+
+There's also a [HACKING.md] doc to help you get started.
+
+## Examples
+
+* find elf files linking to old openssl<br>
+  `qlist -ao | scanelf -BqgN libssl.so.0.9.6 -f -`
+
+* print a package.use<br>
+  `qlist -UCq | grep ' ' > package.use`
+
+* find orphan files not owned by any package in /lib and /usr/lib<br>
+  `qfile -o {,/usr}/lib/*`
+	
+* get PORTDIR<br>
+  `DEBUG=: ./q -Ch 2>&1 | grep ^PORTDIR | awk '{print $3}`
+
+* Verify all packages<br>
+  `qcheck -a`
+
+## Contact
+
+### Bugs
+
+Please file bugs at:
+	https://bugs.gentoo.org/enter_bug.cgi?product=Portage%20Development&format=guided
+
+Use Component of "Third-Party Tools".
+
+### Developers
+
+* solar@gentoo.org
+* vapier@gentoo.org
+
+## Notes
+
+### Speed is everything.
+
+Having your PORTDIR and VDB on the right file system helps dramatically
+
+IDE raid with PORTDIR on reiserfs:
+
+```
+$ q -r
+q: Finished 20655 entries in 1.990951 seconds
+
+IDE raid with PORTDIR on ext3:
+
+```
+$ q -r
+q: Finished 20655 entries in 203.664252 seconds
+```

diff --git a/TODO b/TODO
deleted file mode 100644
index 08e8bc3..0000000
--- a/TODO
+++ /dev/null
@@ -1,59 +0,0 @@
-- unify match behavior:
- default *foo*
- -e foo
- -r (-R ?) regexp foo.*
-
-- disable color when tty = NULL; may break less?
-
-- multiline reads don't yet work for quse/qsearch
-
-- standardize/unify/clean up misc handling of colors
-
-- speed up queue structure ... append walks the whole list
-
-- qmerge
-	- dep resolver needs spanktastic love.
-	- needs safe deleting (merge in place rather than unmerge;merge)
-	- multiple binary repos (talk to zmedico)
-	- handle compressed Packages file (talk to zmedico)
-	- handle binary Packages file (talk to zmedico)
-	- gpg sign the packages file (before compression)
-	- binary vdb (sqlite) ... talk to zmedico
-	- remote vdb
-	- don't bother emitting any "DIR" entries to CONTENTS ?
-		- auto rmdir any empty dirs
-	- avoid Packages fetching all the damned time
-	- parallel fetch tbz2s
-	- check order of pkg_{pre,post}{inst,rm} during install, unmerge, and upgrade
-	- env is not saved/restored between pkg_{pre,post}inst (see portage and REPO_LAYOUT_CONF_WARN)
-	- support installing via path to tbz2 package
-	- support TTL field in binpkgs file
-
-- atoms:
-	- only 32bit values are supported for revision (-r#)
-	- only 64bit values are supported in any individual version component
-		foo-(1234)_alpha(56789)
-	- these limits should not be an issue for all practical purposes
-	- need to handle USE deps like: cat/pkg-123[foo(+)]
-	- show support slots like: qmerge -U automake:1.12
-
-- qcache:
-	- need to convert it to new metadata/md5 style
-
-- qdepends:
-	- support querying uninstalled packages (via metadata/md5 cache)
-
-- env vars only get expanded once, so this fails:
-	ACCEPT_LICENSE="foo"
-	ACCEPT_LICENSE="${ACCEPT_LICENSE} bar"
-  we end up getting just:
-	ACCEPT_LICENSE=" bar"
-
-- qpkg:
-	- fix "would be freed" message when --pretend is *not* active
-	- add a verbose output that describes why a package is cleaned
-		- newer binpkgs available
-		- newer installed version available
-
-- qsync:
-	- rewrite to use new repos.conf standard

diff --git a/TODO.md b/TODO.md
new file mode 100644
index 0000000..86ebbd7
--- /dev/null
+++ b/TODO.md
@@ -0,0 +1,77 @@
+# Common
+
+- unify match behavior:
+	- default *foo*
+	- -e foo
+	- -r (-R ?) regexp foo.*
+
+- disable color when tty = NULL; may break less?
+
+- multiline reads don't yet work for quse/qsearch
+
+- standardize/unify/clean up misc handling of colors
+
+- speed up queue structure ... append walks the whole list
+
+- equiv of `equery m` (metadata)
+
+- env vars only get expanded once, so this fails:<br>
+  `ACCEPT_LICENSE="foo"`<br>
+  `ACCEPT_LICENSE="${ACCEPT_LICENSE} bar"`<br>
+  we end up getting just:<br>
+  `ACCEPT_LICENSE=" bar"`
+
+# Atoms
+
+- only 32bit values are supported for revision (-r#)
+- only 64bit values are supported in any individual version component
+  foo-(1234)_alpha(56789)
+- these limits should not be an issue for all practical purposes
+- need to handle USE deps like: cat/pkg-123[foo(+)]
+- show support slots like: qmerge -U automake:1.12
+
+# qmerge
+
+- dep resolver needs spanktastic love.
+- needs safe deleting (merge in place rather than unmerge;merge)
+- multiple binary repos (talk to zmedico)
+- handle compressed Packages file (talk to zmedico)
+- handle binary Packages file (talk to zmedico)
+- gpg sign the packages file (before compression)
+- binary vdb (sqlite) ... talk to zmedico
+- remote vdb
+- don't bother emitting any "DIR" entries to CONTENTS ?
+	- auto rmdir any empty dirs
+- avoid Packages fetching all the damned time
+- parallel fetch tbz2s
+- check order of pkg_{pre,post}{inst,rm} during install, unmerge, and upgrade
+- env is not saved/restored between pkg_{pre,post}inst (see portage and REPO_LAYOUT_CONF_WARN)
+- support installing via path to tbz2 package
+- support TTL field in binpkgs file
+- merge duplicate atoms on the CLI (`qmerge -Uq nano nano nano`)
+- unmerging should clean out @world set
+
+# qcache
+
+- need to convert it to new metadata/md5 style
+
+# qdepends
+
+- support querying uninstalled packages (via metadata/md5 cache)
+- support atoms like `qdepends -rQ qtsql:4` (should match unslotted deps)
+- add -S/-v/-R behavior like qlist #574934
+
+# qpkg
+
+- fix "would be freed" message when --pretend is *not* active
+- add a verbose output that describes why a package is cleaned
+	- newer binpkgs available
+	- newer installed version available
+
+# qsync
+
+- rewrite to use new repos.conf standard
+
+# qlist
+
+- support atoms instead of exact matches


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-26 23:24 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-26 23:24 UTC (permalink / raw
  To: gentoo-commits

commit:     3aa4c173d3fb52c700109cb625dbefb5d3e45628
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 26 23:23:59 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Nov 26 23:23:59 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3aa4c173

--quiet: only open /dev/null once (in case of -qqqqqqq)

 main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 8e0e2ad..ff7648d 100644
--- a/main.c
+++ b/main.c
@@ -107,7 +107,7 @@ void no_colors(void)
 #define COMMON_GETOPTS_CASES(applet) \
 	case 0x1: portroot = optarg; break; \
 	case 'v': ++verbose; break; \
-	case 'q': ++quiet; warnout = fopen("/dev/null", "we"); break; \
+	case 'q': if (quiet == 0) { warnout = fopen("/dev/null", "we"); } ++quiet; break; \
 	case 'V': version_barf(); break; \
 	case 'h': applet ## _usage(EXIT_SUCCESS); break; \
 	case 'C': no_colors(); break; \


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-26 23:17 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-26 23:17 UTC (permalink / raw
  To: gentoo-commits

commit:     15ccfc885d054d312b7d6d20ec0b91988f1b139d
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 26 22:54:06 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Nov 26 22:54:06 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=15ccfc88

repos.conf: add some debug printing

 main.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/main.c b/main.c
index f6e5184..76e5bad 100644
--- a/main.c
+++ b/main.c
@@ -451,6 +451,9 @@ static void read_one_repos_conf(const char *repos_conf)
 	const char *main_repo, *repo, *path;
 	dictionary *dict;
 
+	if (getenv("DEBUG"))
+		fprintf(stderr, "  parse %s\n", repos_conf);
+
 	dict = iniparser_load(repos_conf);
 
 	main_repo = iniparser_getstring(dict, "DEFAULT:main-repo", NULL);
@@ -482,6 +485,8 @@ static void read_repos_conf(const char *configroot, const char *repos_conf)
 	struct dirent **confs;
 
 	xasprintf(&top_conf, "%s%s", configroot, repos_conf);
+	if (getenv("DEBUG"))
+		fprintf(stderr, "repos.conf.d scanner %s\n", top_conf);
 	count = scandir(top_conf, &confs, NULL, alphasort);
 	if (count == -1) {
 		if (errno == ENOTDIR)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-15  3:34 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-15  3:34 UTC (permalink / raw
  To: gentoo-commits

commit:     d97f4bbcd072d15d1754b27aa55a4999b831fe24
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 15 03:34:10 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Nov 15 03:34:10 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d97f4bbc

qmerge: fix a few misc leaks

 qmerge.c | 28 ++++++++++++++++------------
 1 file changed, 16 insertions(+), 12 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 8a5d329..c7b928e 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -187,7 +187,7 @@ _q_static void qmerge_initialize(void)
 	}
 
 	char *buf;
-	xasprintf(&buf, "%s/portage", port_tmpdir);
+	xasprintf(&buf, "%s/portage/", port_tmpdir);
 	mkdir_p(buf, 0755);
 	xchdir(buf);
 
@@ -195,13 +195,10 @@ _q_static void qmerge_initialize(void)
 		if (force_download)
 			unlink(Packages);
 
-		if (access(Packages, R_OK) != 0) {
-			xasprintf(&buf, "%s/portage/", port_tmpdir);
-			if (access(Packages, R_OK) != 0)
-				fetch(buf, Packages);
-			free(buf);
-		}
+		if (access(Packages, R_OK) != 0)
+			fetch(buf, Packages);
 	}
+	free(buf);
 }
 
 struct qmerge_bv_state {
@@ -871,12 +868,16 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 		return;
 	cat_ctx = q_vdb_open_cat(vdb_ctx, pkg->CATEGORY);
 	if (!cat_ctx) {
-		if (errno != ENOENT)
+		if (errno != ENOENT) {
+			q_vdb_close(vdb_ctx);
 			return;
+		}
 		mkdirat(vdb_ctx->vdb_fd, pkg->CATEGORY, 0755);
 		cat_ctx = q_vdb_open_cat(vdb_ctx, pkg->CATEGORY);
-		if (!cat_ctx)
+		if (!cat_ctx) {
+			q_vdb_close(vdb_ctx);
 			return;
+		}
 	}
 
 	/* Set up our temp dir to unpack this stuff */
@@ -983,13 +984,15 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 				warn("no idea how we reached here.");
 			case ERROR:
 			case NOT_EQUAL:
-				continue;
+				goto next_pkg;
 		}
 
 		qprintf("%s+++%s %s/%s %s %s/%s\n", GREEN, NORM, atom->CATEGORY, pkg->PF,
 			booga[ret], cat_ctx->name, pkg_ctx->name);
 
 		pkg_unmerge(pkg_ctx, objs);
+ next_pkg:
+		q_vdb_close_pkg(pkg_ctx);
 	}
 
 	/* Clean up the package state */
@@ -1020,6 +1023,8 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	rmdir("../qmerge");
 
 	printf("%s>>>%s %s%s%s/%s%s%s\n", YELLOW, NORM, WHITE, atom->CATEGORY, NORM, CYAN, atom->PN, NORM);
+
+	q_vdb_close(vdb_ctx);
 }
 
 _q_static int
@@ -1051,7 +1056,7 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
 	/* First get a handle on the things to clean up */
 	fp = q_vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS");
 	if (fp == NULL)
-		goto done;
+		return ret;
 
 	portroot_fd = cat_ctx->ctx->portroot_fd;
 
@@ -1199,7 +1204,6 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
 	}
 
 	ret = 0;
- done:
 	free(phases);
 	free(buf);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-15  3:34 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-15  3:34 UTC (permalink / raw
  To: gentoo-commits

commit:     00bd72f7753299b7b4ba8da6d0471bf09f13b09f
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 15 03:02:01 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Nov 15 03:02:01 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=00bd72f7

qmerge: fix mem leak w/hash_file calls

 qmerge.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/qmerge.c b/qmerge.c
index b734a87..8a5d329 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -588,6 +588,7 @@ merge_tree_at(int fd_src, const char *src, int fd_dst, const char *dst,
 			/* syntax: obj filename hash mtime */
 			hash = hash_file_at(subfd_src, name, HASH_MD5);
 			fprintf(contents, "obj %s %s %"PRIu64"\n", cpath, hash, (uint64_t)st.st_mtime);
+			free(hash);
 
 			/* Check CONFIG_PROTECT */
 			if (config_protected(cpath, cp_argc, cp_argv, cpm_argc, cpm_argv)) {
@@ -1102,6 +1103,7 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
 					/* If the file wasn't modified, unmerge it */
 					unsigned char *hash = hash_file_at(portroot_fd, e->name + 1, HASH_MD5);
 					protected = strcmp(e->digest, (const char *)hash);
+					free(hash);
 				}
 				break;
 
@@ -1232,6 +1234,7 @@ pkg_verify_checksums(char *fname, const struct pkg_t *pkg, const depend_atom *at
 				warn("MD5:  [%sER%s] (%s) != (%s) %s/%s", RED, NORM, hash, pkg->MD5, atom->CATEGORY, pkg->PF);
 			ret++;
 		}
+		free(hash);
 	}
 
 	if (pkg->SHA1[0]) {
@@ -1244,6 +1247,7 @@ pkg_verify_checksums(char *fname, const struct pkg_t *pkg, const depend_atom *at
 				warn("SHA1: [%sER%s] (%s) != (%s) %s/%s", RED, NORM, hash, pkg->SHA1, atom->CATEGORY, pkg->PF);
 			ret++;
 		}
+		free(hash);
 	}
 
 	if (!pkg->SHA1[0] && !pkg->MD5[0])


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-15  3:34 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-15  3:34 UTC (permalink / raw
  To: gentoo-commits

commit:     6925dd5d04d79ea510a9de620d00fcdd54f30394
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 15 02:36:19 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Nov 15 02:36:19 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6925dd5d

qlist: fix leakage with matched atoms

 qlist.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qlist.c b/qlist.c
index 4ea3810..91ed45c 100644
--- a/qlist.c
+++ b/qlist.c
@@ -411,6 +411,9 @@ int qlist_main(int argc, char **argv)
 	state.atoms = xcalloc(argc - optind, sizeof(*state.atoms));
 	ret = q_vdb_foreach_pkg_sorted(qlist_cb, &state);
 	free(state.buf);
+	for (i = optind; i < state.argc; ++i)
+		if (state.atoms[i - optind])
+			atom_implode(state.atoms[i - optind]);
 	free(state.atoms);
 
 	/* The return value is whether we matched anything. */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-15  3:34 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-15  3:34 UTC (permalink / raw
  To: gentoo-commits

commit:     2020f99b795192c9aff24fe6b1c3e3d8220d1ae0
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 15 02:24:10 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Nov 15 02:24:10 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2020f99b

qcheck: fix leakage with --skip regex array

 qcheck.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/qcheck.c b/qcheck.c
index 79f52a9..40968a6 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -382,6 +382,11 @@ int qcheck_main(int argc, char **argv)
 	}
 
 	ret = q_vdb_foreach_pkg_sorted(qcheck_cb, &state);
+	{
+		void *regex;
+		array_for_each(regex_arr, i, regex)
+			regfree(regex);
+	}
 	xarrayfree(regex_arr);
 	array_for_each(atoms, i, atom)
 		atom_implode(atom);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-15  3:34 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-15  3:34 UTC (permalink / raw
  To: gentoo-commits

commit:     743d4fe35a8d6029bc0da10b5b3d9f095a07f2c1
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Nov 15 02:12:16 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Nov 15 02:12:16 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=743d4fe3

qpkg: fix bad pointer passing

Taking an address of a stack buffer doesn't do what we want.
Create a local variable to hold the address to pass down.

URL: https://bugs.gentoo.org/598974
Reported-by: Alexander Wetzel <alexander.wetzel <AT> web.de>

 main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index e9e65b4..f6e5184 100644
--- a/main.c
+++ b/main.c
@@ -1356,6 +1356,7 @@ _q_static queue *get_vdb_atoms(int fullcpv)
 
 	char buf[_Q_PATH_MAX];
 	char slot[_Q_PATH_MAX];
+	char *slotp = slot;
 	size_t slot_len;
 
 	struct dirent **cat;
@@ -1384,7 +1385,7 @@ _q_static queue *get_vdb_atoms(int fullcpv)
 			 * until this is rewritten & merged into libq/vdb.c. */
 			slot_len = sizeof(slot);
 			strncat(buf, "/SLOT", sizeof(buf));
-			eat_file_at(ctx->vdb_fd, buf, (char **)&slot, &slot_len);
+			eat_file_at(ctx->vdb_fd, buf, &slotp, &slot_len);
 			rmspace(slot);
 
 			if (fullcpv) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-11-12 17:17 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-11-12 17:17 UTC (permalink / raw
  To: gentoo-commits

commit:     0cd1766c6aac6965666797dd875b1fdc0ea91b47
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 12 17:16:36 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Nov 12 17:16:36 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0cd1766c

qcache: handle DT_UNKNOWN and cases where DT_xxx are not available #580354

URL: https://bugs.gentoo.org/580354
Reported-by: Fabian Groffen <grobian <AT> gentoo.org>

 qcache.c | 22 ++++++++++++++++++++--
 1 file changed, 20 insertions(+), 2 deletions(-)

diff --git a/qcache.c b/qcache.c
index 222c8ae..535d7a2 100644
--- a/qcache.c
+++ b/qcache.c
@@ -750,13 +750,31 @@ void qcache_stats(qcache_data *data)
 
 		xasprintf(&catpath, "%s/dep/%s", portedb, data->overlay);
 		dir = opendir(catpath);
-		while ((de = readdir(dir)))
-			if (de->d_type == DT_DIR && de->d_name[0] != '.') {
+		while ((de = readdir(dir))) {
+			/* Look for all the directories in this path. */
+#ifdef DT_UNKNOWN
+			if (de->d_type == DT_UNKNOWN)
+#endif
+			{
+				struct stat s;
+				if (lstat(de->d_name, &s))
+					continue;
+				if (!S_ISDIR(s.st_mode))
+					continue;
+			}
+
+#ifdef DT_DIR
+			if (de->d_type != DT_DIR)
+				continue;
+#endif
+
+			if (de->d_name[0] != '.') {
 				bool ok;
 				allcats = add_set_unique(de->d_name, allcats, &ok);
 				if (ok)
 					++numcat;
 			}
+		}
 		closedir(dir);
 		free(catpath);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-06-21 20:53 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-06-21 20:53 UTC (permalink / raw
  To: gentoo-commits

commit:     9ec380a6048391850c97e0a7359e8c25745899c9
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 21 20:51:47 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Jun 21 20:51:47 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9ec380a6

qlist: fix repo length calculation w/slots

 qlist.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qlist.c b/qlist.c
index d238259..4ea3810 100644
--- a/qlist.c
+++ b/qlist.c
@@ -145,11 +145,11 @@ qlist_match(q_vdb_pkg_ctx *pkg_ctx, const char *name, depend_atom **name_atom, b
 	if (urepo) {
 		if (!pkg_ctx->repo)
 			q_vdb_pkg_eat(pkg_ctx, "repository", &pkg_ctx->repo, &pkg_ctx->repo_len);
-		urepo_len = strlen(urepo);
 		urepo += 2;
+		urepo_len = strlen(urepo);
 
 		if (uslot_len)
-			uslot_len -= urepo_len;
+			uslot_len -= (urepo_len + 2);
 	}
 
 	/* maybe they're using a version range */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-06-20  3:22 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-06-20  3:22 UTC (permalink / raw
  To: gentoo-commits

commit:     cf604a35700ef2b673e9fe9ce931f3833efab4d5
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 20 03:12:57 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Jun 20 03:12:57 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=cf604a35

README: update repo URLs

 README | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/README b/README
index cf45a7d..1a8dc3d 100644
--- a/README
+++ b/README
@@ -25,7 +25,7 @@ Current developer list:
 
 - Fetching via anon git:
 
-  git clone git://git.overlays.gentoo.org/proj/portage-utils.git
+  git clone git://anongit.gentoo.org/proj/portage-utils.git
 
 You can view it online via gitweb:
-	http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git
+	https://gitweb.gentoo.org/proj/portage-utils.git/


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-04-04 15:47 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-04-04 15:47 UTC (permalink / raw
  To: gentoo-commits

commit:     7c64d59b55c1681a022f7b774590f512d35782c2
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Apr  4 15:45:40 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Apr  4 15:45:40 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7c64d59b

repos.conf: fix fallback logic

Invert the S_ISREG check so we don't ignore regular files, and avoid
leaking the path buffer when we do skip the non-regular files.

Reported-by: consus <AT> gmx.com

 main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 8e6d4fd..e9e65b4 100644
--- a/main.c
+++ b/main.c
@@ -507,8 +507,10 @@ static void read_repos_conf(const char *configroot, const char *repos_conf)
 #endif
 			{
 				struct stat st;
-				if (stat(sub_conf, &st) || S_ISREG(st.st_mode))
+				if (stat(sub_conf, &st) || !S_ISREG(st.st_mode)) {
+					free(sub_conf);
 					continue;
+				}
 			}
 
 			read_one_repos_conf(sub_conf);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-04-01 21:42 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-04-01 21:42 UTC (permalink / raw
  To: gentoo-commits

commit:     40ec23a61a89940dca84f0616703cc4f7225f2fd
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Apr  1 21:38:47 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Apr  1 21:38:47 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=40ec23a6

change reinitialize type

We started using negative values in commit 26d038ae9c2f499cfb52486913c,
but some targets define "char" as "unsigned".  Switch to "int" to avoid
that issue.

 main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c
index a50b451..8e6d4fd 100644
--- a/main.c
+++ b/main.c
@@ -31,8 +31,8 @@ int verbose = 0;
 int quiet = 0;
 int portcachedir_type = 0;
 char pretend = 0;
-char reinitialize = 0;
-char reinitialize_metacache = 0;
+static int reinitialize = 0;
+static int reinitialize_metacache = 0;
 static char *portlogdir;
 static char *main_overlay;
 static char *portarch;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-04-01 21:42 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-04-01 21:42 UTC (permalink / raw
  To: gentoo-commits

commit:     46aea99b4b973d29db4f717fa72bcf3e1cb80f22
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Apr  1 21:40:11 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Apr  1 21:40:11 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=46aea99b

qsearch: fix dirname/basename calls

Since dirname might modify its argument, make sure we call basename
first so we don't end up with the dirname twice.

URL: https://bugs.gentoo.org/578758
Reported-by: Kolbjørn Barmen <gentoo <AT> kolla.no>

 qsearch.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qsearch.c b/qsearch.c
index e23642b..1ebfccf 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -119,8 +119,9 @@ qsearch_ebuild_ebuild(int overlay_fd, const char *ebuild, const char *search_me,
 	}
 
 	if (show_it) {
+		const char *pkg = basename(p);
 		printf("%s%s/%s%s%s %s\n",
-			BOLD, dirname(p), BLUE, basename(p), NORM,
+			BOLD, dirname(p), BLUE, pkg, NORM,
 			(show_name_only ? "" : q ? : "<no DESCRIPTION found>"));
 	}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-03-28  4:53 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-03-28  4:53 UTC (permalink / raw
  To: gentoo-commits

commit:     87859bc7eb6e05744bcf4c325d7ee322cf9c8546
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 27 17:52:44 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Mar 27 17:52:44 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=87859bc7

TODO: add qsync idea

 TODO | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/TODO b/TODO
index 74bffac..08e8bc3 100644
--- a/TODO
+++ b/TODO
@@ -54,3 +54,6 @@
 	- add a verbose output that describes why a package is cleaned
 		- newer binpkgs available
 		- newer installed version available
+
+- qsync:
+	- rewrite to use new repos.conf standard


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-03-28  4:53 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-03-28  4:53 UTC (permalink / raw
  To: gentoo-commits

commit:     d2341937bd97afa24f09742f0ccf5e5e3bf053d3
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 28 02:58:12 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Mar 28 02:58:12 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d2341937

qlop: drop redundant headers

These are already pulled in via porting.h.

 qlop.c | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/qlop.c b/qlop.c
index ad62474..319d767 100644
--- a/qlop.c
+++ b/qlop.c
@@ -8,24 +8,6 @@
 
 #ifdef APPLET_qlop
 
-#ifdef __linux__
-# include <asm/param.h>
-#endif
-
-#ifdef __FreeBSD__
-# include <kvm.h>
-# include <sys/param.h>
-# include <sys/sysctl.h>
-# include <sys/user.h>
-# include <sys/time.h>
-#endif
-
-#ifdef __MACH__
-# include <stdlib.h>
-# include <sys/types.h>
-# include <sys/sysctl.h>
-#endif
-
 #define QLOP_DEFAULT_LOGFILE "emerge.log"
 
 #define QLOP_FLAGS "gtHluscf:" COMMON_FLAGS
@@ -379,7 +361,8 @@ show_sync_history(const char *logfile)
 
 _q_static void show_current_emerge(void);
 #ifdef __linux__
-#include <elf.h>
+# include <asm/param.h>
+# include <elf.h>
 static unsigned long hz = 0;
 static void init_hz(void)
 {
@@ -495,6 +478,10 @@ void show_current_emerge(void)
 		puts("No emerge processes located");
 }
 #elif defined(__FreeBSD__)
+# include <kvm.h>
+# include <sys/param.h>
+# include <sys/sysctl.h>
+# include <sys/user.h>
 void show_current_emerge(void)
 {
 	kvm_t *kd = NULL;
@@ -545,6 +532,7 @@ void show_current_emerge(void)
 		puts("No emerge processes located");
 }
 #elif defined(__MACH__)
+# include <sys/sysctl.h>
 void show_current_emerge(void)
 {
 	int mib[3];


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-03-28  4:53 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-03-28  4:53 UTC (permalink / raw
  To: gentoo-commits

commit:     faaf0b2f02f3403cc727cd360e4dbf5509812735
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 27 18:22:58 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Mar 27 18:22:58 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=faaf0b2f

qlop: slight ctime speedup

 qlop.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/qlop.c b/qlop.c
index dbbae06..ad62474 100644
--- a/qlop.c
+++ b/qlop.c
@@ -75,10 +75,9 @@ _q_static const char *
 chop_ctime(time_t t)
 {
 	static char ctime_out[50];
-	char *p;
-	snprintf(ctime_out, sizeof(ctime_out), "%s", ctime(&t));
-	if ((p = strchr(ctime_out, '\n')) != NULL)
-		*p = '\0';
+	int ret = snprintf(ctime_out, sizeof(ctime_out), "%s", ctime(&t));
+	/* Assume no error! */
+	ctime_out[ret - 1] = '\0';
 	return ctime_out;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-02-22 20:37 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-02-22 20:37 UTC (permalink / raw
  To: gentoo-commits

commit:     3d4a141fd4bf94190f9e453304d68b965df85633
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 22 18:17:20 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Feb 22 18:17:20 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3d4a141f

qsize: clean up stat logic a bit

By using the *at style func, we can avoid the fixed static buffer
and doing a string copy all the time.

 qsize.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/qsize.c b/qsize.c
index b9f3afb..2df2fce 100644
--- a/qsize.c
+++ b/qsize.c
@@ -37,7 +37,6 @@ int qsize_main(int argc, char **argv)
 	q_vdb_cat_ctx *cat_ctx;
 	q_vdb_pkg_ctx *pkg_ctx;
 	size_t i;
-	struct stat st;
 	char fs_size = 0, summary = 0, summary_only = 0;
 	size_t num_all_files, num_all_nonfiles, num_all_ignored;
 	size_t num_files, num_nonfiles, num_ignored;
@@ -46,7 +45,6 @@ int qsize_main(int argc, char **argv)
 	const char *str_disp_units = NULL;
 	size_t buflen;
 	char *buf;
-	char filename[_Q_PATH_MAX], *filename_root;
 	depend_atom *atom;
 	DECLARE_ARRAY(atoms);
 	DECLARE_ARRAY(ignore_regexp);
@@ -81,8 +79,6 @@ int qsize_main(int argc, char **argv)
 
 	num_all_bytes = num_all_files = num_all_nonfiles = num_all_ignored = 0;
 
-	strcpy(filename, portroot);
-	filename_root = filename + strlen(filename);
 	buflen = _Q_PATH_MAX;
 	buf = xmalloc(buflen);
 
@@ -138,9 +134,9 @@ int qsize_main(int argc, char **argv)
 					continue;
 
 				if (e->type == CONTENTS_OBJ || e->type == CONTENTS_SYM) {
-					strcpy(filename_root, e->name);
+					struct stat st;
 					++num_files;
-					if (!lstat(filename, &st))
+					if (!fstatat(ctx->portroot_fd, e->name + 1, &st, AT_SYMLINK_NOFOLLOW))
 						num_bytes += (fs_size ? st.st_blocks * S_BLKSIZE : st.st_size);
 				} else
 					++num_nonfiles;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-02-22 20:37 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-02-22 20:37 UTC (permalink / raw
  To: gentoo-commits

commit:     704d05c0829aaf03abb95273308116786046b891
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 22 18:28:25 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Feb 22 18:28:25 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=704d05c0

qsize: rework code to use vdb callbacks

This helps reduce some of the boiler plate code for vdb walking.
There should be no real functional changes.

 qsize.c | 268 +++++++++++++++++++++++++++++++++++-----------------------------
 1 file changed, 145 insertions(+), 123 deletions(-)

diff --git a/qsize.c b/qsize.c
index 2df2fce..db00247 100644
--- a/qsize.c
+++ b/qsize.c
@@ -31,37 +31,143 @@ static const char * const qsize_opts_help[] = {
 };
 #define qsize_usage(ret) usage(ret, QSIZE_FLAGS, qsize_long_opts, qsize_opts_help, lookup_applet_idx("qsize"))
 
-int qsize_main(int argc, char **argv)
+struct qsize_opt_state {
+	array_t *atoms;
+	char **argv;
+	char search_all;
+	char fs_size;
+	char summary;
+	char summary_only;
+	size_t disp_units;
+	const char *str_disp_units;
+	array_t *ignore_regexp;
+
+	size_t buflen;
+	char *buf;
+
+	size_t num_all_files, num_all_nonfiles, num_all_ignored;
+	uint64_t num_all_bytes;
+};
+
+_q_static int qsize_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 {
-	q_vdb_ctx *ctx;
-	q_vdb_cat_ctx *cat_ctx;
-	q_vdb_pkg_ctx *pkg_ctx;
+	struct qsize_opt_state *state = priv;
+	const char *catname = pkg_ctx->cat_ctx->name;
+	const char *pkgname = pkg_ctx->name;
 	size_t i;
-	char fs_size = 0, summary = 0, summary_only = 0;
-	size_t num_all_files, num_all_nonfiles, num_all_ignored;
+	depend_atom *atom;
+	FILE *fp;
 	size_t num_files, num_nonfiles, num_ignored;
-	uint64_t num_all_bytes, num_bytes;
-	size_t disp_units = 0;
-	const char *str_disp_units = NULL;
-	size_t buflen;
-	char *buf;
+	uint64_t num_bytes;
+	bool showit = false;
+
+	/* see if this cat/pkg is requested */
+	if (array_cnt(state->atoms)) {
+		depend_atom *qatom;
+
+		snprintf(state->buf, state->buflen, "%s/%s", catname, pkgname);
+		qatom = atom_explode(state->buf);
+		array_for_each(state->atoms, i, atom)
+			if (atom_compare(atom, qatom) == EQUAL) {
+				showit = true;
+				break;
+			}
+		atom_implode(qatom);
+	} else
+		showit = true;
+	if (!showit)
+		return EXIT_SUCCESS;
+
+	if ((fp = q_vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS")) == NULL)
+		return EXIT_SUCCESS;
+
+	num_ignored = num_files = num_nonfiles = num_bytes = 0;
+	while (getline(&state->buf, &state->buflen, fp) != -1) {
+		contents_entry *e;
+		regex_t *regex;
+		int ok = 0;
+
+		e = contents_parse_line(state->buf);
+		if (!e)
+			continue;
+
+		array_for_each(state->ignore_regexp, i, regex)
+			if (!regexec(regex, state->buf, 0, NULL, 0)) {
+				num_ignored += 1;
+				ok = 1;
+			}
+		if (ok)
+			continue;
+
+		if (e->type == CONTENTS_OBJ || e->type == CONTENTS_SYM) {
+			struct stat st;
+			++num_files;
+			if (!fstatat(pkg_ctx->cat_ctx->ctx->portroot_fd, e->name + 1, &st, AT_SYMLINK_NOFOLLOW))
+				num_bytes += (state->fs_size ? st.st_blocks * S_BLKSIZE : st.st_size);
+		} else
+			++num_nonfiles;
+	}
+	fclose(fp);
+	state->num_all_bytes += num_bytes;
+	state->num_all_files += num_files;
+	state->num_all_nonfiles += num_nonfiles;
+	state->num_all_ignored += num_ignored;
+
+	if (!state->summary_only) {
+		printf("%s%s/%s%s%s: %'zu files, %'zu non-files, ", BOLD,
+		       catname, BLUE, pkgname, NORM,
+		       num_files, num_nonfiles);
+		if (num_ignored)
+			printf("%'zu names-ignored, ", num_ignored);
+		if (state->disp_units)
+			printf("%s %s\n",
+			       make_human_readable_str(num_bytes, 1, state->disp_units),
+			       state->str_disp_units);
+		else
+			printf("%'"PRIu64"%s%"PRIu64" KiB\n",
+			       num_bytes / KILOBYTE,
+			       decimal_point,
+			       ((num_bytes % KILOBYTE) * 1000) / KILOBYTE);
+	}
+
+	return EXIT_SUCCESS;
+}
+
+int qsize_main(int argc, char **argv)
+{
+	size_t i;
+	int ret;
+	DECLARE_ARRAY(ignore_regexp);
 	depend_atom *atom;
 	DECLARE_ARRAY(atoms);
-	DECLARE_ARRAY(ignore_regexp);
+	struct qsize_opt_state state = {
+		.atoms = atoms,
+		.search_all = 0,
+		.fs_size = 0,
+		.summary = 0,
+		.summary_only = 0,
+		.disp_units = 0,
+		.str_disp_units = NULL,
+		.ignore_regexp = ignore_regexp,
+		.num_all_bytes = 0,
+		.num_all_files = 0,
+		.num_all_nonfiles = 0,
+		.num_all_ignored = 0,
+	};
 
 	while ((i = GETOPT_LONG(QSIZE, qsize, "")) != -1) {
 		switch (i) {
 		COMMON_GETOPTS_CASES(qsize)
-		case 'f': fs_size = 1; break;
-		case 's': summary = 1; break;
-		case 'S': summary = summary_only = 1; break;
-		case 'm': disp_units = MEGABYTE; str_disp_units = "MiB"; break;
-		case 'k': disp_units = KILOBYTE; str_disp_units = "KiB"; break;
-		case 'b': disp_units = 1; str_disp_units = "bytes"; break;
+		case 'f': state.fs_size = 1; break;
+		case 's': state.summary = 1; break;
+		case 'S': state.summary = state.summary_only = 1; break;
+		case 'm': state.disp_units = MEGABYTE; state.str_disp_units = "MiB"; break;
+		case 'k': state.disp_units = KILOBYTE; state.str_disp_units = "KiB"; break;
+		case 'b': state.disp_units = 1; state.str_disp_units = "bytes"; break;
 		case 'i': {
 			regex_t regex;
 			xregcomp(&regex, optarg, REG_EXTENDED|REG_NOSUB);
-			xarraypush(ignore_regexp, &regex, sizeof(regex));
+			xarraypush(state.ignore_regexp, &regex, sizeof(regex));
 			break;
 		}
 		}
@@ -74,121 +180,37 @@ int qsize_main(int argc, char **argv)
 		if (!atom)
 			warn("invalid atom: %s", argv[i]);
 		else
-			xarraypush_ptr(atoms, atom);
+			xarraypush_ptr(state.atoms, atom);
 	}
 
-	num_all_bytes = num_all_files = num_all_nonfiles = num_all_ignored = 0;
-
-	buflen = _Q_PATH_MAX;
-	buf = xmalloc(buflen);
-
-	ctx = q_vdb_open();
-	if (!ctx)
-		return EXIT_FAILURE;
-
-	/* open /var/db/pkg */
-	while ((cat_ctx = q_vdb_next_cat(ctx))) {
-		/* open the cateogry */
-		const char *catname = cat_ctx->name;
-		while ((pkg_ctx = q_vdb_next_pkg(cat_ctx))) {
-			const char *pkgname = pkg_ctx->name;
-			FILE *fp;
-			bool showit = false;
-
-			/* see if this cat/pkg is requested */
-			if (array_cnt(atoms)) {
-				depend_atom *qatom;
-
-				snprintf(buf, buflen, "%s/%s", catname, pkgname);
-				qatom = atom_explode(buf);
-				array_for_each(atoms, i, atom)
-					if (atom_compare(atom, qatom) == EQUAL) {
-						showit = true;
-						break;
-					}
-				atom_implode(qatom);
-			} else
-				showit = true;
-			if (!showit)
-				goto next_pkg;
-
-			if ((fp = q_vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS")) == NULL)
-				goto next_pkg;
-
-			num_ignored = num_files = num_nonfiles = num_bytes = 0;
-			while (getline(&buf, &buflen, fp) != -1) {
-				contents_entry *e;
-				regex_t *regex;
-				int ok = 0;
-
-				e = contents_parse_line(buf);
-				if (!e)
-					continue;
-
-				array_for_each(ignore_regexp, i, regex)
-					if (!regexec(regex, buf, 0, NULL, 0)) {
-						num_ignored += 1;
-						ok = 1;
-					}
-				if (ok)
-					continue;
-
-				if (e->type == CONTENTS_OBJ || e->type == CONTENTS_SYM) {
-					struct stat st;
-					++num_files;
-					if (!fstatat(ctx->portroot_fd, e->name + 1, &st, AT_SYMLINK_NOFOLLOW))
-						num_bytes += (fs_size ? st.st_blocks * S_BLKSIZE : st.st_size);
-				} else
-					++num_nonfiles;
-			}
-			fclose(fp);
-			num_all_bytes += num_bytes;
-			num_all_files += num_files;
-			num_all_nonfiles += num_nonfiles;
-			num_all_ignored += num_ignored;
-
-			if (!summary_only) {
-				printf("%s%s/%s%s%s: %'zu files, %'zu non-files, ", BOLD,
-				       catname, BLUE, pkgname, NORM,
-				       num_files, num_nonfiles);
-				if (num_ignored)
-					printf("%'zu names-ignored, ", num_ignored);
-				if (disp_units)
-					printf("%s %s\n",
-					       make_human_readable_str(num_bytes, 1, disp_units),
-					       str_disp_units);
-				else
-					printf("%'"PRIu64"%s%"PRIu64" KiB\n",
-					       num_bytes / KILOBYTE,
-					       decimal_point,
-					       ((num_bytes % KILOBYTE) * 1000) / KILOBYTE);
-			}
+	state.buflen = _Q_PATH_MAX;
+	state.buf = xmalloc(state.buflen);
 
- next_pkg:
-			q_vdb_close_pkg(pkg_ctx);
-		}
-	}
+	ret = q_vdb_foreach_pkg(qsize_cb, &state, NULL);
 
-	if (summary) {
+	if (state.summary) {
 		printf(" %sTotals%s: %'zu files, %'zu non-files, ", BOLD, NORM,
-		       num_all_files, num_all_nonfiles);
-		if (num_all_ignored)
-			printf("%'zu names-ignored, ", num_all_ignored);
-		if (disp_units)
+		       state.num_all_files, state.num_all_nonfiles);
+		if (state.num_all_ignored)
+			printf("%'zu names-ignored, ", state.num_all_ignored);
+		if (state.disp_units)
 			printf("%s %s\n",
-			       make_human_readable_str(num_all_bytes, 1, disp_units),
-			       str_disp_units);
+			       make_human_readable_str(state.num_all_bytes, 1, state.disp_units),
+			       state.str_disp_units);
 		else
 			printf("%'"PRIu64"%s%"PRIu64" MiB\n",
-			       num_all_bytes / MEGABYTE,
+			       state.num_all_bytes / MEGABYTE,
 			       decimal_point,
-			       ((num_all_bytes % MEGABYTE) * 1000) / MEGABYTE);
+			       ((state.num_all_bytes % MEGABYTE) * 1000) / MEGABYTE);
 	}
-	array_for_each(atoms, i, atom)
+
+	array_for_each(state.atoms, i, atom)
 		atom_implode(atom);
-	xarrayfree_int(atoms);
-	xarrayfree(ignore_regexp);
-	return EXIT_SUCCESS;
+	xarrayfree_int(state.atoms);
+	xarrayfree(state.ignore_regexp);
+	free(state.buf);
+
+	return ret;
 }
 
 #else


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-02-22 20:37 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-02-22 20:37 UTC (permalink / raw
  To: gentoo-commits

commit:     466b34112637d2f777a8d9873ec05f49cc3cb415
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 22 18:06:04 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Feb 22 18:06:04 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=466b3411

qsize: clean up printf formats

Use proper size flags like %zu for size_t instead of casting everything
to an unsigned long.

 qsize.c | 26 ++++++++++++--------------
 1 file changed, 12 insertions(+), 14 deletions(-)

diff --git a/qsize.c b/qsize.c
index 7a40141..b9f3afb 100644
--- a/qsize.c
+++ b/qsize.c
@@ -152,21 +152,20 @@ int qsize_main(int argc, char **argv)
 			num_all_ignored += num_ignored;
 
 			if (!summary_only) {
-				printf("%s%s/%s%s%s: %'lu files, %'lu non-files, ", BOLD,
+				printf("%s%s/%s%s%s: %'zu files, %'zu non-files, ", BOLD,
 				       catname, BLUE, pkgname, NORM,
-				       (unsigned long)num_files,
-				       (unsigned long)num_nonfiles);
+				       num_files, num_nonfiles);
 				if (num_ignored)
-					printf("%'lu names-ignored, ", (unsigned long)num_ignored);
+					printf("%'zu names-ignored, ", num_ignored);
 				if (disp_units)
 					printf("%s %s\n",
 					       make_human_readable_str(num_bytes, 1, disp_units),
 					       str_disp_units);
 				else
-					printf("%'lu%s%lu KiB\n",
-					       (unsigned long)(num_bytes / KILOBYTE),
+					printf("%'"PRIu64"%s%"PRIu64" KiB\n",
+					       num_bytes / KILOBYTE,
 					       decimal_point,
-					       (unsigned long)(((num_bytes%KILOBYTE)*1000)/KILOBYTE));
+					       ((num_bytes % KILOBYTE) * 1000) / KILOBYTE);
 			}
 
  next_pkg:
@@ -175,20 +174,19 @@ int qsize_main(int argc, char **argv)
 	}
 
 	if (summary) {
-		printf(" %sTotals%s: %'lu files, %'lu non-files, ", BOLD, NORM,
-		       (unsigned long)num_all_files,
-		       (unsigned long)num_all_nonfiles);
+		printf(" %sTotals%s: %'zu files, %'zu non-files, ", BOLD, NORM,
+		       num_all_files, num_all_nonfiles);
 		if (num_all_ignored)
-			printf("%'lu names-ignored, ", (unsigned long)num_all_ignored);
+			printf("%'zu names-ignored, ", num_all_ignored);
 		if (disp_units)
 			printf("%s %s\n",
 			       make_human_readable_str(num_all_bytes, 1, disp_units),
 			       str_disp_units);
 		else
-			printf("%'lu%s%lu MiB\n",
-			       (unsigned long)(num_all_bytes / MEGABYTE),
+			printf("%'"PRIu64"%s%"PRIu64" MiB\n",
+			       num_all_bytes / MEGABYTE,
 			       decimal_point,
-			       (unsigned long)(((num_all_bytes%MEGABYTE)*1000)/MEGABYTE));
+			       ((num_all_bytes % MEGABYTE) * 1000) / MEGABYTE);
 	}
 	array_for_each(atoms, i, atom)
 		atom_implode(atom);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-02-22 20:37 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-02-22 20:37 UTC (permalink / raw
  To: gentoo-commits

commit:     54a6bc76557216d67a21673b8f0e479efae21a79
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 22 17:41:41 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Feb 22 17:41:41 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=54a6bc76

qcheck: precompile ignore regexes

This should speed things up a bit.

 qsize.c | 20 ++++++++++++--------
 1 file changed, 12 insertions(+), 8 deletions(-)

diff --git a/qsize.c b/qsize.c
index 7a2503a..3a11842 100644
--- a/qsize.c
+++ b/qsize.c
@@ -38,7 +38,7 @@ int qsize_main(int argc, char **argv)
 	q_vdb_ctx *ctx;
 	q_vdb_cat_ctx *cat_ctx;
 	q_vdb_pkg_ctx *pkg_ctx;
-	int i;
+	size_t i;
 	char search_all = 0;
 	struct stat st;
 	char fs_size = 0, summary = 0, summary_only = 0;
@@ -50,7 +50,7 @@ int qsize_main(int argc, char **argv)
 	size_t buflen;
 	char *buf;
 	char filename[_Q_PATH_MAX], *filename_root;
-	queue *ignore_regexp = NULL;
+	DECLARE_ARRAY(ignore_regexp);
 
 	while ((i = GETOPT_LONG(QSIZE, qsize, "")) != -1) {
 		switch (i) {
@@ -62,7 +62,12 @@ int qsize_main(int argc, char **argv)
 		case 'm': disp_units = MEGABYTE; str_disp_units = "MiB"; break;
 		case 'k': disp_units = KILOBYTE; str_disp_units = "KiB"; break;
 		case 'b': disp_units = 1; str_disp_units = "bytes"; break;
-		case 'i': ignore_regexp = add_set(optarg, ignore_regexp); break;
+		case 'i': {
+			regex_t regex;
+			xregcomp(&regex, optarg, REG_EXTENDED|REG_NOSUB);
+			xarraypush(ignore_regexp, &regex, sizeof(regex));
+			break;
+		}
 		}
 	}
 	if ((argc == optind) && !search_all)
@@ -105,19 +110,18 @@ int qsize_main(int argc, char **argv)
 			num_ignored = num_files = num_nonfiles = num_bytes = 0;
 			while (getline(&buf, &buflen, fp) != -1) {
 				contents_entry *e;
-				queue *ll;
+				regex_t *regex;
 				int ok = 0;
 
 				e = contents_parse_line(buf);
 				if (!e)
 					continue;
 
-				for (ll = ignore_regexp; ll != NULL; ll = ll->next) {
-					if (rematch(ll->name, e->name, REG_EXTENDED) == 0) {
+				array_for_each(ignore_regexp, i, regex)
+					if (!regexec(regex, buf, 0, NULL, 0)) {
 						num_ignored += 1;
 						ok = 1;
 					}
-				}
 				if (ok)
 					continue;
 
@@ -174,7 +178,7 @@ int qsize_main(int argc, char **argv)
 			       decimal_point,
 			       (unsigned long)(((num_all_bytes%MEGABYTE)*1000)/MEGABYTE));
 	}
-	free_sets(ignore_regexp);
+	xarrayfree(ignore_regexp);
 	return EXIT_SUCCESS;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-02-17  7:15 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-02-17  7:15 UTC (permalink / raw
  To: gentoo-commits

commit:     82f1ea7634d6ac645a06545a2855966ee81a0867
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Wed Feb 17 07:15:22 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed Feb 17 07:15:22 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=82f1ea76

TODO: drop a few completed entries

 TODO | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/TODO b/TODO
index b6c3ae0..74bffac 100644
--- a/TODO
+++ b/TODO
@@ -42,7 +42,6 @@
 
 - qdepends:
 	- support querying uninstalled packages (via metadata/md5 cache)
-	- verify version matching works: qdepend =nano-2*
 
 - env vars only get expanded once, so this fails:
 	ACCEPT_LICENSE="foo"
@@ -55,6 +54,3 @@
 	- add a verbose output that describes why a package is cleaned
 		- newer binpkgs available
 		- newer installed version available
-
-- qlop:
-	- support atoms and version qualifiers `qlop '>gnuconfig-2015'`


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-02-14  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-02-14  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     db488105e8637cf64664aef44bce2e629ecce338
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 14 00:21:47 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Feb 14 00:21:47 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=db488105

qdepends: parse args as atoms

Update the arg parsing logic to treat them as atoms rather than as
ad-hoc substring parsing.  This makes the listing logic much more
natural and brings it inline with other applets.

URL: https://bugs.gentoo.org/390749
Reported-by: aditsu <AT> yahoo.com

 qdepends.c | 80 +++++++++++++++++++++++++++++++++++++++++---------------------
 1 file changed, 53 insertions(+), 27 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index 197c376..f5867f8 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -381,8 +381,7 @@ char *dep_flatten_tree(const dep_node *root)
 }
 
 struct qdepends_opt_state {
-	int argc;
-	char **argv;
+	array_t *atoms;
 	const char *depend_file;
 	const char *query;
 };
@@ -392,42 +391,44 @@ _q_static int qdepends_main_vdb_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	struct qdepends_opt_state *state = priv;
 	const char *catname = pkg_ctx->cat_ctx->name;
 	const char *pkgname = pkg_ctx->name;
-	size_t len;
-	int i;
+	size_t i, len;
+	int ret;
 	char *ptr;
 	char buf[_Q_PATH_MAX];
 	static char *depend, *use;
 	static size_t depend_len, use_len;
+	depend_atom *atom, *datom;
 	dep_node *dep_tree;
 
+	datom = NULL;
+	ret = 0;
+
 	/* see if this cat/pkg is requested */
-	for (i = optind; i < state->argc; ++i) {
+	array_for_each(state->atoms, i, atom) {
+		bool matched = false;
 		snprintf(buf, sizeof(buf), "%s/%s", catname, pkgname);
-		if (rematch(state->argv[i], buf, REG_EXTENDED) == 0)
-			break;
-		if (rematch(state->argv[i], pkgname, REG_EXTENDED) == 0)
-			break;
+		datom = atom_explode(buf);
+		if (datom) {
+			matched = (atom_compare(atom, datom) == EQUAL);
+			if (matched)
+				goto matched;
+		}
+		atom_implode(datom);
 	}
-	if (i == state->argc)
-		return 0;
+	return ret;
+ matched:
 
 	if (!q_vdb_pkg_eat(pkg_ctx, state->depend_file, &depend, &depend_len))
-		return 0;
+		goto done;
 
 	dep_tree = dep_grow_tree(depend);
 	if (dep_tree == NULL)
-		return 0;
+		goto done;
 
-	if (qdep_name_only) {
-		depend_atom *atom = NULL;
-		snprintf(buf, sizeof(buf), "%s/%s", catname, pkgname);
-		if ((atom = atom_explode(buf)) != NULL) {
-			printf("%s%s/%s%s%s: ", BOLD, catname, BLUE, atom->PN, NORM);
-			atom_implode(atom);
-		}
-	} else {
+	if (qdep_name_only)
+		printf("%s%s/%s%s%s: ", BOLD, catname, BLUE, atom->PN, NORM);
+	else
 		printf("%s%s/%s%s%s: ", BOLD, catname, BLUE, pkgname, NORM);
-	}
 
 	if (!q_vdb_pkg_eat(pkg_ctx, "USE", &use, &use_len)) {
 		warn("Could not eat_file(%s), you'll prob have incorrect output", buf);
@@ -454,7 +455,11 @@ _q_static int qdepends_main_vdb_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 
 	dep_burn_tree(dep_tree);
 
-	return 1;
+	ret = 1;
+
+ done:
+	atom_implode(datom);
+	return ret;
 }
 
 _q_static int qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
@@ -516,12 +521,14 @@ _q_static int qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 
 int qdepends_main(int argc, char **argv)
 {
+	depend_atom *atom;
+	DECLARE_ARRAY(atoms);
 	struct qdepends_opt_state state = {
-		.argc = argc,
-		.argv = argv,
+		.atoms = atoms,
 	};
 	q_vdb_pkg_cb *cb;
-	int i, ret;
+	size_t i;
+	int ret;
 	bool do_format = false;
 	const char *query = NULL;
 	const char *depend_file;
@@ -556,9 +563,24 @@ int qdepends_main(int argc, char **argv)
 		return EXIT_SUCCESS;
 	}
 
+	argc -= optind;
+	argv += optind;
+
 	state.depend_file = depend_file;
 	state.query = query;
-	cb = query ? qdepends_vdb_deep_cb : qdepends_main_vdb_cb;
+	if (query)
+		cb = qdepends_vdb_deep_cb;
+	else {
+		cb = qdepends_main_vdb_cb;
+
+		for (i = 0; i < argc; ++i) {
+			atom = atom_explode(argv[i]);
+			if (!atom)
+				warn("invalid atom: %s", argv[i]);
+			else
+				xarraypush_ptr(atoms, atom);
+		}
+	}
 
 	if (!depend_file) {
 		ret = 0;
@@ -570,6 +592,10 @@ int qdepends_main(int argc, char **argv)
 	} else
 		ret = q_vdb_foreach_pkg(cb, &state, NULL);
 
+	array_for_each(atoms, i, atom)
+		atom_implode(atom);
+	xarrayfree_int(atoms);
+
 	if (!ret && !quiet)
 		warn("no matches found for your query");
 	return ret ? EXIT_SUCCESS : EXIT_FAILURE;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-02-14  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-02-14  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     c5a20990bcae3acddcff18bb850cf28dbc2a4feb
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 13 23:04:24 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Feb 13 23:04:24 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c5a20990

autogen: pull in stpcpy as we use it

URL: https://bugs.gentoo.org/573902
Reported-by: Tupone Alfredo <tupone <AT> gentoo.org>

 autogen.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/autogen.sh b/autogen.sh
index 622ab16..9777b19 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -25,6 +25,7 @@ mods="
 	readlinkat
 	renameat
 	stat-time
+	stpcpy
 	strcasestr-simple
 	strncat
 	symlinkat


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-02-14  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-02-14  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     c4ef2269807b1168460393bad04fb632a4a378d5
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 13 23:10:52 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Feb 13 23:10:52 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c4ef2269

autogen: pull in dirent as we use it

 autogen.sh | 1 +
 1 file changed, 1 insertion(+)

diff --git a/autogen.sh b/autogen.sh
index 9777b19..dbb2aac 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -13,6 +13,7 @@ fi
 PATH=/usr/local/src/gnu/gnulib:${PATH}
 mods="
 	alloca
+	dirent
 	faccessat
 	fdopendir
 	fstatat


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-01-29  5:53 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-01-29  5:53 UTC (permalink / raw
  To: gentoo-commits

commit:     7aff0263204d80304108dbe4f0061f44ed8f189f
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Jan 29 05:52:10 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Jan 29 05:52:10 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7aff0263

qlop: fix crash w/corrupted log files

If a file is truncated/corrupted, make sure we don't read past the end
of the valid buffer.

URL: https://bugs.gentoo.org/573106
Reported-by: Agostino Sarubbo <ago <AT> gentoo.org>

 qlop.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qlop.c b/qlop.c
index 546c353..bb32474 100644
--- a/qlop.c
+++ b/qlop.c
@@ -265,6 +265,9 @@ show_emerge_history(char listflag, int argc, char **argv, const char *logfile)
 			continue;
 		*p = 0;
 		q = p + 3;
+		/* Make sure there's leading white space and not a truncated string. #573106 */
+		if (p[1] != ' ' || p[2] != ' ')
+			continue;
 
 		t = (time_t) atol(buf);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2016-01-05  0:25 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2016-01-05  0:25 UTC (permalink / raw
  To: gentoo-commits

commit:     391b8cf8bb3f06b40d108c157630657132a96131
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  5 00:24:50 2016 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Jan  5 00:24:50 2016 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=391b8cf8

qcheck: improve error reporting for unreadable files

We shouldn't flag files that are unreadable as AFK as that implies the
files are missing.

 qcheck.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/qcheck.c b/qcheck.c
index cdbc507..3718f94 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -37,7 +37,7 @@ static const char * const qcheck_opts_help[] = {
 };
 #define qcheck_usage(ret) usage(ret, QCHECK_FLAGS, qcheck_long_opts, qcheck_opts_help, lookup_applet_idx("qcheck"))
 
-#define qcprintf(fmt, args...) if (!state->bad_only) printf(_(fmt), ## args)
+#define qcprintf(fmt, args...) do { if (!state->bad_only) printf(_(fmt), ## args); } while (0)
 
 struct qcheck_opt_state {
 	int argc;
@@ -125,7 +125,10 @@ static int qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_sta
 		if (fstatat(pkg_ctx->cat_ctx->ctx->portroot_fd, e->name + 1, &st, AT_SYMLINK_NOFOLLOW)) {
 			/* make sure file exists */
 			if (state->chk_afk) {
-				qcprintf(" %sAFK%s: %s\n", RED, NORM, e->name);
+				if (errno == ENOENT)
+					qcprintf(" %sAFK%s: %s\n", RED, NORM, e->name);
+				else
+					qcprintf(" %sERROR (%s)%s: %s\n", RED, strerror(errno), NORM, e->name);
 			} else {
 				--num_files;
 				++num_files_ignored;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-12-17  5:06 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-12-17  5:06 UTC (permalink / raw
  To: gentoo-commits

commit:     dc82e50a316006d339eb0a4aa0d65a9502c41677
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 17 04:45:18 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Dec 17 04:45:18 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=dc82e50a

cache: avoid memleak warnings

We leak a bit of memory when reinitializing the caches, but we don't care
because we'll be exiting soon after.  Free the memory in debug builds.

 main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/main.c b/main.c
index c571ef7..d366bef 100644
--- a/main.c
+++ b/main.c
@@ -1071,15 +1071,19 @@ ret:
 void reinitialize_as_needed(void)
 {
 	size_t n;
-	const char *overlay;
+	const char *overlay, *ret = ret;
 
 	if (reinitialize)
-		array_for_each(overlays, n, overlay)
-			initialize_flat(overlay, CACHE_EBUILD, true);
+		array_for_each(overlays, n, overlay) {
+			ret = initialize_flat(overlay, CACHE_EBUILD, true);
+			IF_DEBUG(free((void *)ret));
+		}
 
 	if (reinitialize_metacache)
-		array_for_each(overlays, n, overlay)
-			initialize_flat(overlay, CACHE_METADATA, true);
+		array_for_each(overlays, n, overlay) {
+			ret = initialize_flat(overlay, CACHE_METADATA, true);
+			IF_DEBUG(free((void *)ret));
+		}
 }
 
 typedef struct {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-12-17  5:06 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-12-17  5:06 UTC (permalink / raw
  To: gentoo-commits

commit:     1d4228adcfe4489bd330076e2b1004905d97d6cc
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 17 04:40:23 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Dec 17 04:40:23 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1d4228ad

clean up old debug statements

Much of this debug output has outlived its usefulness now that the code
has stabilized.  Clean it all up to make the debug builds way less noisy
and keep from breaking the tests.

 main.c     |  5 +++--
 q.c        |  3 ---
 qatom.c    |  3 ---
 qcache.c   |  3 ---
 qcheck.c   |  3 ---
 qdepends.c | 13 -------------
 qfile.c    |  3 ---
 qglsa.c    |  3 ---
 qgrep.c    |  3 ---
 qlist.c    |  3 ---
 qlop.c     |  5 -----
 qpkg.c     |  2 --
 qsearch.c  |  3 ---
 qsize.c    |  3 ---
 qtbz2.c    |  3 ---
 quse.c     |  3 ---
 qxpak.c    |  3 ---
 template.c |  3 ---
 18 files changed, 3 insertions(+), 64 deletions(-)

diff --git a/main.c b/main.c
index be25d08..c571ef7 100644
--- a/main.c
+++ b/main.c
@@ -592,7 +592,8 @@ _q_static void read_portage_env_file(const char *configroot, const char *file, e
 	FILE *fp;
 	char *buf, *s, *p;
 
-	IF_DEBUG(fprintf(stderr, "profile %s\n", file));
+	if (getenv("DEBUG"))
+		fprintf(stderr, "profile %s\n", file);
 
 	configroot_len = strlen(configroot);
 	file_len = strlen(file);
@@ -885,7 +886,7 @@ void initialize_portage_env(void)
 		}
 	}
 
-	if (getenv("DEBUG") IF_DEBUG(|| 1)) {
+	if (getenv("DEBUG")) {
 		for (i = 0; vars_to_read[i].name; ++i) {
 			var = &vars_to_read[i];
 			fprintf(stderr, "%s = ", var->name);

diff --git a/q.c b/q.c
index 443ce4b..53b359f 100644
--- a/q.c
+++ b/q.c
@@ -32,7 +32,6 @@ static APPLET lookup_applet(const char *applet)
 
 	for (i = 0; applets[i].name; ++i) {
 		if (strcmp(applets[i].name, applet) == 0) {
-			DBG("found applet %s at %p", applets[i].name, applets[i].func);
 			argv0 = applets[i].name;
 			if (i && applets[i].desc != NULL) ++argv0; /* chop the leading 'q' */
 			return applets[i].func;
@@ -40,10 +39,8 @@ static APPLET lookup_applet(const char *applet)
 	}
 
 	/* No applet found? Search by shortname then... */
-	DBG("Looking up applet (%s) by short name", applet);
 	for (i = 1; applets[i].desc != NULL; ++i) {
 		if (strcmp(applets[i].name + 1, applet) == 0) {
-			DBG("found applet by short name %s", applets[i].name);
 			argv0 = applets[i].name + 1;
 			return applets[i].func;
 		}

diff --git a/qatom.c b/qatom.c
index 16445dd..acf9fd6 100644
--- a/qatom.c
+++ b/qatom.c
@@ -109,9 +109,6 @@ int qatom_main(int argc, char **argv)
 	depend_atom *atom;
 	int i;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	while ((i = GETOPT_LONG(QATOM, qatom, "")) != -1) {
 		switch (i) {
 		case 'F': format = optarg; break;

diff --git a/qcache.c b/qcache.c
index d4b7884..759e50a 100644
--- a/qcache.c
+++ b/qcache.c
@@ -912,9 +912,6 @@ int qcache_main(int argc, char **argv)
 {
 	int i, action = 0;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-		argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	while ((i = GETOPT_LONG(QCACHE, qcache, "")) != -1) {
 		switch (i) {
 			case 'p': qcache_matchpkg = optarg; break;

diff --git a/qcheck.c b/qcheck.c
index 6ad5f85..cdbc507 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -373,9 +373,6 @@ int qcheck_main(int argc, char **argv)
 		.exact = false,
 	};
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	while ((i = GETOPT_LONG(QCHECK, qcheck, "")) != -1) {
 		switch (i) {
 		COMMON_GETOPTS_CASES(qcheck)

diff --git a/qdepends.c b/qdepends.c
index 5ded84b..197c376 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -411,17 +411,12 @@ _q_static int qdepends_main_vdb_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	if (i == state->argc)
 		return 0;
 
-	IF_DEBUG(warn("matched %s/%s", catname, pkgname));
-
 	if (!q_vdb_pkg_eat(pkg_ctx, state->depend_file, &depend, &depend_len))
 		return 0;
 
-	IF_DEBUG(warn("growing tree..."));
 	dep_tree = dep_grow_tree(depend);
 	if (dep_tree == NULL)
 		return 0;
-	IF_DEBUG(puts(depend));
-	IF_DEBUG(dep_dump_tree(dep_tree));
 
 	if (qdep_name_only) {
 		depend_atom *atom = NULL;
@@ -474,17 +469,12 @@ _q_static int qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	static size_t depend_len, use_len;
 	dep_node *dep_tree;
 
-	IF_DEBUG(warn("matched %s/%s for %s", catname, pkgname, state->depend_file));
-
 	if (!q_vdb_pkg_eat(pkg_ctx, state->depend_file, &depend, &depend_len))
 		return 0;
 
-	IF_DEBUG(warn("growing tree..."));
 	dep_tree = dep_grow_tree(depend);
 	if (dep_tree == NULL)
 		return 0;
-	IF_DEBUG(puts(depend));
-	IF_DEBUG(dep_dump_tree(dep_tree));
 
 	if (q_vdb_pkg_eat(pkg_ctx, "USE", &use, &use_len))
 		use[0] = '\0';
@@ -539,9 +529,6 @@ int qdepends_main(int argc, char **argv)
 
 	depend_file = depend_files[0];
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	while ((i = GETOPT_LONG(QDEPENDS, qdepends, "")) != -1) {
 		switch (i) {
 		COMMON_GETOPTS_CASES(qdepends)

diff --git a/qfile.c b/qfile.c
index 6d36e96..5082093 100644
--- a/qfile.c
+++ b/qfile.c
@@ -407,9 +407,6 @@ int qfile_main(int argc, char **argv)
 	FILE *args_file = NULL;
 	int max_args = QFILE_DEFAULT_MAX_ARGS;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	while ((i = GETOPT_LONG(QFILE, qfile, "")) != -1) {
 		switch (i) {
 			COMMON_GETOPTS_CASES(qfile)

diff --git a/qglsa.c b/qglsa.c
index 7bc350f..885ce1e 100644
--- a/qglsa.c
+++ b/qglsa.c
@@ -285,9 +285,6 @@ int qglsa_main(int argc, char **argv)
 	qglsa_action action = GLSA_FUNKYTOWN;
 	bool all_glsas = false;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	while ((i = GETOPT_LONG(QGLSA, qglsa, "")) != -1) {
 #define set_action(a) { if (action == 0) action = a; else err("cannot specify more than one action at a time"); }
 		switch (i) {

diff --git a/qgrep.c b/qgrep.c
index e7c2c10..7551ebb 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -261,9 +261,6 @@ int qgrep_main(int argc, char **argv)
 
 	QGREP_STR_FUNC strfunc = strstr;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	do_count = do_regex = do_eclass = do_installed = do_list = 0;
 	show_filename = skip_comments = invert_list = show_name = 0;
 

diff --git a/qlist.c b/qlist.c
index d17ba5e..cd52bf0 100644
--- a/qlist.c
+++ b/qlist.c
@@ -379,9 +379,6 @@ int qlist_main(int argc, char **argv)
 	};
 	int i, ret;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	while ((i = GETOPT_LONG(QLIST, qlist, "")) != -1) {
 		switch (i) {
 		COMMON_GETOPTS_CASES(qlist)

diff --git a/qlop.c b/qlop.c
index f2f97c6..546c353 100644
--- a/qlop.c
+++ b/qlop.c
@@ -107,8 +107,6 @@ show_merge_times(char *package, const char *logfile, int average, char human_rea
 		pkg = package;
 	}
 
-	DBG("Searching for %s in %s\n", pkg, logfile);
-
 	if ((fp = fopen(logfile, "r")) == NULL) {
 		warnp("Could not open logfile '%s'", logfile);
 		return 1;
@@ -645,9 +643,6 @@ int qlop_main(int argc, char **argv)
 	char do_time, do_list, do_unlist, do_sync, do_current, do_human_readable = 0;
 	char *logfile = NULL;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-		argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	do_time = do_list = do_unlist = do_sync = do_current = 0;
 
 	while ((i = GETOPT_LONG(QLOP, qlop, "")) != -1) {

diff --git a/qpkg.c b/qpkg.c
index 2c9e774..996efcd 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -320,8 +320,6 @@ int qpkg_main(int argc, char **argv)
 	depend_atom *atom;
 	int restrict_chmod = 0;
 	int qclean = 0;
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
 
 	while ((i = GETOPT_LONG(QPKG, qpkg, "")) != -1) {
 		switch (i) {

diff --git a/qsearch.c b/qsearch.c
index b7c992e..2ba2d39 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -140,9 +140,6 @@ int qsearch_main(int argc, char **argv)
 	int i;
 	void (*search_func)(int, const char *, const char *, char *last, bool, bool, bool, bool, bool);
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	while ((i = GETOPT_LONG(QSEARCH, qsearch, "")) != -1) {
 		switch (i) {
 		COMMON_GETOPTS_CASES(qsearch)

diff --git a/qsize.c b/qsize.c
index 486edcf..7a2503a 100644
--- a/qsize.c
+++ b/qsize.c
@@ -52,9 +52,6 @@ int qsize_main(int argc, char **argv)
 	char filename[_Q_PATH_MAX], *filename_root;
 	queue *ignore_regexp = NULL;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	while ((i = GETOPT_LONG(QSIZE, qsize, "")) != -1) {
 		switch (i) {
 		COMMON_GETOPTS_CASES(qsize)

diff --git a/qtbz2.c b/qtbz2.c
index 9208097..da2e9ab 100644
--- a/qtbz2.c
+++ b/qtbz2.c
@@ -244,9 +244,6 @@ int qtbz2_main(int argc, char **argv)
 	char *heap_tbz2, *heap_xpak, *heap_tarbz2;
 	char *tbz2, *xpak, *tarbz2;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	action = TBZ2_ACT_NONE;
 	dir_fd = AT_FDCWD;
 

diff --git a/quse.c b/quse.c
index 2ac6cad..59db37a 100644
--- a/quse.c
+++ b/quse.c
@@ -242,9 +242,6 @@ int quse_main(int argc, char **argv)
 	size_t n;
 	const char *overlay;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	while ((i = GETOPT_LONG(QUSE, quse, "")) != -1) {
 		switch (i) {
 		case 'e': regexp_matching = 0; break;

diff --git a/qxpak.c b/qxpak.c
index d7cec6f..fb19ef9 100644
--- a/qxpak.c
+++ b/qxpak.c
@@ -379,9 +379,6 @@ int qxpak_main(int argc, char **argv)
 	char *xpak;
 	char action = XPAK_ACT_NONE;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	dir_fd = AT_FDCWD;
 	xpak_stdout = 0;
 

diff --git a/template.c b/template.c
index eff93e8..d4b9e98 100644
--- a/template.c
+++ b/template.c
@@ -21,9 +21,6 @@ int qtemp_main(int argc, char **argv)
 {
 	int i;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
 	while ((i = GETOPT_LONG(QTEMP, qtemp, "")) != -1) {
 		switch (i) {
 		COMMON_GETOPTS_CASES(qtemp)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-12-17  5:06 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-12-17  5:06 UTC (permalink / raw
  To: gentoo-commits

commit:     cc013611ef364a970f829df3c4ea7c919f2333dc
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 17 04:31:01 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Dec 17 04:31:01 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=cc013611

fix minor overlay memory leak w/repos.conf parsing

When repos.conf is active, we end up leaking the default main overlay
memory.  Make sure we free it if repos.conf was loaded.

Also drop the old closing of stderr so asan can write its output.  The
addition of this call was due to a bug in the old stderr reopen logic
that was rewritten in commit ba5f0328.

 main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 208f899..be25d08 100644
--- a/main.c
+++ b/main.c
@@ -905,7 +905,10 @@ void initialize_portage_env(void)
 		portroot[var->value_len + 1] = '\0';
 	}
 
+	char *orig_main_overlay = main_overlay;
 	read_repos_conf(configroot, CONFIG_EPREFIX "etc/portage/repos.conf");
+	if (orig_main_overlay != main_overlay)
+		free(orig_main_overlay);
 	if (array_cnt(overlays) == 0)
 		xarraypush_str(overlays, main_overlay);
 
@@ -1380,7 +1383,6 @@ _q_static queue *get_vdb_atoms(int fullcpv)
 void cleanup(void)
 {
 	reinitialize_as_needed();
-	fclose(stderr);
 }
 
 int main(int argc, char **argv)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-12-17  5:06 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-12-17  5:06 UTC (permalink / raw
  To: gentoo-commits

commit:     41afee726fb3f4e06eaf0d4f3ea47d2f15bd5d51
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 17 04:39:33 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Dec 17 04:39:33 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=41afee72

TODO: add more ideas

 TODO | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/TODO b/TODO
index ed72034..b6c3ae0 100644
--- a/TODO
+++ b/TODO
@@ -27,6 +27,7 @@
 	- check order of pkg_{pre,post}{inst,rm} during install, unmerge, and upgrade
 	- env is not saved/restored between pkg_{pre,post}inst (see portage and REPO_LAYOUT_CONF_WARN)
 	- support installing via path to tbz2 package
+	- support TTL field in binpkgs file
 
 - atoms:
 	- only 32bit values are supported for revision (-r#)
@@ -54,3 +55,6 @@
 	- add a verbose output that describes why a package is cleaned
 		- newer binpkgs available
 		- newer installed version available
+
+- qlop:
+	- support atoms and version qualifiers `qlop '>gnuconfig-2015'`


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-28  2:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-28  2:44 UTC (permalink / raw
  To: gentoo-commits

commit:     13e441fc15740844749c1c9930f348d4aab53a8d
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 27 21:15:40 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov 27 21:15:40 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=13e441fc

qcache: print elapse time nicer

 qcache.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qcache.c b/qcache.c
index 25f8651..0891918 100644
--- a/qcache.c
+++ b/qcache.c
@@ -735,7 +735,9 @@ void qcache_stats(qcache_data *data)
 
 		printf("+%.*s+\n\n", (int)(arch_longest_len + 46), border);
 
-		printf("Completed in %s%d%s seconds.\n", BLUE, (int)(time(NULL)-runtime), NORM);
+		printf("Completed in ");
+		print_seconds_for_earthlings(time(NULL) - runtime);
+		printf("\n");
 
 		free(packages_stable);
 		free(packages_testing);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-28  2:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-28  2:44 UTC (permalink / raw
  To: gentoo-commits

commit:     a0c3ddab026e271b3eb2e66e64b9e9a24eb6f708
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 27 23:26:17 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov 27 23:26:17 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a0c3ddab

qgrep/quse: add multiple overlay support

This is a pretty straight forward extension.  The code hasn't seen
any clean ups in the process (although it probably should).

URL: https://bugs.gentoo.org/553260

 qgrep.c | 366 +++++++++++++++++++++++++++++++++-------------------------------
 quse.c  | 268 ++++++++++++++++++++++++-----------------------
 2 files changed, 329 insertions(+), 305 deletions(-)

diff --git a/qgrep.c b/qgrep.c
index de018ea..e7c2c10 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -259,7 +259,7 @@ int qgrep_main(int argc, char **argv)
 	int need_separator = 0;
 	char status = 1;
 
-	QGREP_STR_FUNC strfunc = (QGREP_STR_FUNC) strstr;
+	QGREP_STR_FUNC strfunc = strstr;
 
 	DBG("argc=%d argv[0]=%s argv[1]=%s",
 	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
@@ -271,7 +271,7 @@ int qgrep_main(int argc, char **argv)
 		switch (i) {
 		case 'I': invert_match = 1; break;
 		case 'i':
-			strfunc = (QGREP_STR_FUNC) strcasestr;
+			strfunc = strcasestr;
 			reflags |= REG_ICASE;
 			break;
 		case 'c': do_count = 1; break;
@@ -369,203 +369,216 @@ int qgrep_main(int argc, char **argv)
 			xregcomp(&skip_preg, skip_pattern, reflags);
 	}
 
-	/* go look either in ebuilds or eclasses or VDB */
-	if (!do_eclass && !do_installed) {
-		if ((fp = fopen(initialize_ebuild_flat(), "r")) == NULL)
-			return 1;
-		xchdir(portdir);
-	} else if (do_eclass) {
-		xchdir(portdir);
-		if ((eclass_dir = opendir("eclass")) == NULL)
-			errp("opendir(\"%s/eclass\") failed", portdir);
-	} else { /* if (do_install) */
-		char buf[_Q_PATH_MAX];
-		snprintf(buf, sizeof(buf), "%s/%s", portroot, portvdb);
-		xchdir(buf);
-		if ((vdb_dir = opendir(".")) == NULL)
-			errp("could not opendir(%s/%s) for ROOT/VDB", portroot, portvdb);
-	}
-
 	/* allocate a circular buffers list for --before */
 	buf_list = qgrep_buf_list_alloc(num_lines_before + 1);
 
-	/* iteration is either over ebuilds or eclasses */
-	while (do_eclass
-			? ((dentry = readdir(eclass_dir))
-				&& snprintf(ebuild, sizeof(ebuild), "eclass/%s", dentry->d_name))
-			: (do_installed
-				? (get_next_installed_ebuild(ebuild, vdb_dir, &dentry, &cat_dir) != NULL)
-				: (fgets(ebuild, sizeof(ebuild), fp) != NULL))) {
-		FILE *newfp;
-
-		/* filter badly named files, prepare eclass or package name, etc. */
-		if (do_eclass) {
-			if ((p = strrchr(ebuild, '.')) == NULL)
+	size_t n;
+	char *overlay;
+	array_for_each(overlays, n, overlay) {
+
+		/* go look either in ebuilds or eclasses or VDB */
+		if (!do_eclass && !do_installed) {
+			fp = fopen(initialize_flat(overlay, CACHE_EBUILD, false), "re");
+			if (fp == NULL)
 				continue;
-			if (strcmp(p, ".eclass"))
+			xchdir(overlay);
+		} else if (do_eclass) {
+			xchdir(overlay);
+			if ((eclass_dir = opendir("eclass")) == NULL) {
+				if (errno != ENOENT)
+					warnp("opendir(\"%s/eclass\") failed", overlay);
 				continue;
-			if (show_name || (include_atoms != NULL)) {
-				/* cut ".eclass" */
-				*p = '\0';
-				/* and skip "eclass/" */
-				snprintf(name, sizeof(name), "%s", ebuild + 7);
-				/* restore the filepath */
-				*p = '.';
 			}
-		} else {
-			if ((p = strchr(ebuild, '\n')) != NULL)
-				*p = '\0';
-			if (show_name || (include_atoms != NULL)) {
-				/* cut ".ebuild" */
-				if (p == NULL)
-					p = ebuild + strlen(ebuild);
-				*(p-7) = '\0';
-				/* cut "/foo/" from "cat/foo/foo-x.y" */
-				if ((p = strchr(ebuild, '/')) == NULL)
+		} else { /* if (do_install) */
+			char buf[_Q_PATH_MAX];
+			snprintf(buf, sizeof(buf), "%s/%s", portroot, portvdb);
+			xchdir(buf);
+			if ((vdb_dir = opendir(".")) == NULL)
+				errp("could not opendir(%s/%s) for ROOT/VDB", portroot, portvdb);
+		}
+
+		/* iteration is either over ebuilds or eclasses */
+		while (do_eclass
+				? ((dentry = readdir(eclass_dir))
+					&& snprintf(ebuild, sizeof(ebuild), "eclass/%s", dentry->d_name))
+				: (do_installed
+					? (get_next_installed_ebuild(ebuild, vdb_dir, &dentry, &cat_dir) != NULL)
+					: (fgets(ebuild, sizeof(ebuild), fp) != NULL))) {
+			FILE *newfp;
+
+			/* filter badly named files, prepare eclass or package name, etc. */
+			if (do_eclass) {
+				if ((p = strrchr(ebuild, '.')) == NULL)
 					continue;
-				*(p++) = '\0';
-				/* find head of the ebuild basename */
-				if ((p = strchr(p, '/')) == NULL)
+				if (strcmp(p, ".eclass"))
 					continue;
-				/* find	start of the pkg name */
-				snprintf(name, sizeof(name), "%s/%s", ebuild, (p+1));
-				/* restore the filepath */
-				*p = '/';
-				*(p + strlen(p)) = '.';
-				ebuild[strlen(ebuild)] = '/';
+				if (show_name || (include_atoms != NULL)) {
+					/* cut ".eclass" */
+					*p = '\0';
+					/* and skip "eclass/" */
+					snprintf(name, sizeof(name), "%s", ebuild + 7);
+					/* restore the filepath */
+					*p = '.';
+				}
+			} else {
+				if ((p = strchr(ebuild, '\n')) != NULL)
+					*p = '\0';
+				if (show_name || (include_atoms != NULL)) {
+					/* cut ".ebuild" */
+					if (p == NULL)
+						p = ebuild + strlen(ebuild);
+					*(p-7) = '\0';
+					/* cut "/foo/" from "cat/foo/foo-x.y" */
+					if ((p = strchr(ebuild, '/')) == NULL)
+						continue;
+					*(p++) = '\0';
+					/* find head of the ebuild basename */
+					if ((p = strchr(p, '/')) == NULL)
+						continue;
+					/* find	start of the pkg name */
+					snprintf(name, sizeof(name), "%s/%s", ebuild, (p+1));
+					/* restore the filepath */
+					*p = '/';
+					*(p + strlen(p)) = '.';
+					ebuild[strlen(ebuild)] = '/';
+				}
 			}
-		}
 
-		/* filter the files we grep when there are extra args */
-		if (include_atoms != NULL)
-			if (!qgrep_name_match(name, (argc - optind - 1), include_atoms))
-				continue;
-
-		if ((newfp = fopen(ebuild, "r")) != NULL) {
-			int lineno = 0;
-			char remaining_after_context = 0;
-			count = 0;
-			/* if there have been some matches already, then a separator will be needed */
-			need_separator = (!status) && (num_lines_before || num_lines_after);
-			/* whatever is in the circular buffers list is no more a valid context */
-			qgrep_buf_list_invalidate(buf_list);
-
-			/* reading a new line always happen in the next buffer of the list */
-			while ((buf_list = buf_list->next)
-					&& (fgets(buf_list->buf, sizeof(buf_list->buf), newfp)) != NULL) {
-				lineno++;
-				buf_list->valid = 1;
-
-				/* cleanup EOL */
-				if ((p = strrchr(buf_list->buf, '\n')) != NULL)
-					*p = 0;
-				if ((p = strrchr(buf_list->buf, '\r')) != NULL)
-					*p = 0;
-
-				if (skip_comments) {
-					/* reject comments line ("^[ \t]*#") */
-					p = buf_list->buf;
-					while (*p == ' ' || *p == '\t') p++;
-					if (*p == '#')
-						goto print_after_context;
-				}
+			/* filter the files we grep when there are extra args */
+			if (include_atoms != NULL)
+				if (!qgrep_name_match(name, (argc - optind - 1), include_atoms))
+					continue;
 
-				if (skip_pattern) {
-					/* reject some other lines which match an optional pattern */
-					if (!do_regex) {
-						if (strfunc(buf_list->buf, skip_pattern) != NULL)
-							goto print_after_context;
-					} else {
-						if (regexec(&skip_preg, buf_list->buf, 0, NULL, 0) == 0)
+			if ((newfp = fopen(ebuild, "r")) != NULL) {
+				int lineno = 0;
+				char remaining_after_context = 0;
+				count = 0;
+				/* if there have been some matches already, then a separator will be needed */
+				need_separator = (!status) && (num_lines_before || num_lines_after);
+				/* whatever is in the circular buffers list is no more a valid context */
+				qgrep_buf_list_invalidate(buf_list);
+
+				/* reading a new line always happen in the next buffer of the list */
+				while ((buf_list = buf_list->next)
+						&& (fgets(buf_list->buf, sizeof(buf_list->buf), newfp)) != NULL) {
+					lineno++;
+					buf_list->valid = 1;
+
+					/* cleanup EOL */
+					if ((p = strrchr(buf_list->buf, '\n')) != NULL)
+						*p = 0;
+					if ((p = strrchr(buf_list->buf, '\r')) != NULL)
+						*p = 0;
+
+					if (skip_comments) {
+						/* reject comments line ("^[ \t]*#") */
+						p = buf_list->buf;
+						while (*p == ' ' || *p == '\t') p++;
+						if (*p == '#')
 							goto print_after_context;
 					}
-				}
 
-				/* four ways to match a line (with/without inversion and regexp) */
-				if (!invert_match) {
-					if (do_regex == 0) {
-						if (strfunc(buf_list->buf, argv[optind]) == NULL)
-							goto print_after_context;
-					} else {
-						if (regexec(&preg, buf_list->buf, 0, NULL, 0) != 0)
-							goto print_after_context;
+					if (skip_pattern) {
+						/* reject some other lines which match an optional pattern */
+						if (!do_regex) {
+							if (strfunc(buf_list->buf, skip_pattern) != NULL)
+								goto print_after_context;
+						} else {
+							if (regexec(&skip_preg, buf_list->buf, 0, NULL, 0) == 0)
+								goto print_after_context;
+						}
 					}
-				} else {
-					if (do_regex == 0) {
-						if (strfunc(buf_list->buf, argv[optind]) != NULL)
-							goto print_after_context;
+
+					/* four ways to match a line (with/without inversion and regexp) */
+					if (!invert_match) {
+						if (do_regex == 0) {
+							if (strfunc(buf_list->buf, argv[optind]) == NULL)
+								goto print_after_context;
+						} else {
+							if (regexec(&preg, buf_list->buf, 0, NULL, 0) != 0)
+								goto print_after_context;
+						}
 					} else {
-						if (regexec(&preg, buf_list->buf, 0, NULL, 0) == 0)
-							goto print_after_context;
+						if (do_regex == 0) {
+							if (strfunc(buf_list->buf, argv[optind]) != NULL)
+								goto print_after_context;
+						} else {
+							if (regexec(&preg, buf_list->buf, 0, NULL, 0) == 0)
+								goto print_after_context;
+						}
 					}
-				}
 
-				count++;
-				status = 0; /* got a match, exit status should be 0 */
-				if (per_file_output)
-					continue; /* matching files are listed out of this loop */
-
-				if ((need_separator > 0)
-						&& (num_lines_before || num_lines_after))
-					printf("--\n");
-				/* "need_separator" is not a flag, but a counter, so that
-				 * adjacent contextes are not separated */
-				need_separator = 0 - num_lines_before;
-				if (!do_list) {
-					/* print the leading context */
-					qgrep_print_before_context(buf_list, num_lines_before, label,
-							((verbose > 1) ? lineno : -1));
-					/* print matching line */
-					if (invert_match || *RED == '\0')
-						qgrep_print_matching_line_nocolor(buf_list, label,
-							((verbose > 1) ? lineno : -1));
-					else if (do_regex)
-						qgrep_print_matching_line_regcolor(buf_list, label,
-							((verbose > 1) ? lineno : -1), &preg);
-					else
-						qgrep_print_matching_line_strcolor(buf_list, label,
-							((verbose > 1) ? lineno : -1), strfunc, argv[optind]);
-				} else {
-					/* in verbose do_list mode, list the file once per match */
-					printf("%s", label);
-					if (verbose > 1)
-						printf(":%d", lineno);
-					putchar('\n');
-				}
-				/* init count down of trailing context lines */
-				remaining_after_context = num_lines_after;
-				continue;
+					count++;
+					status = 0; /* got a match, exit status should be 0 */
+					if (per_file_output)
+						continue; /* matching files are listed out of this loop */
+
+					if ((need_separator > 0)
+							&& (num_lines_before || num_lines_after))
+						printf("--\n");
+					/* "need_separator" is not a flag, but a counter, so that
+					 * adjacent contextes are not separated */
+					need_separator = 0 - num_lines_before;
+					if (!do_list) {
+						/* print the leading context */
+						qgrep_print_before_context(buf_list, num_lines_before, label,
+								((verbose > 1) ? lineno : -1));
+						/* print matching line */
+						if (invert_match || *RED == '\0')
+							qgrep_print_matching_line_nocolor(buf_list, label,
+								((verbose > 1) ? lineno : -1));
+						else if (do_regex)
+							qgrep_print_matching_line_regcolor(buf_list, label,
+								((verbose > 1) ? lineno : -1), &preg);
+						else
+							qgrep_print_matching_line_strcolor(buf_list, label,
+								((verbose > 1) ? lineno : -1), strfunc, argv[optind]);
+					} else {
+						/* in verbose do_list mode, list the file once per match */
+						printf("%s", label);
+						if (verbose > 1)
+							printf(":%d", lineno);
+						putchar('\n');
+					}
+					/* init count down of trailing context lines */
+					remaining_after_context = num_lines_after;
+					continue;
 
-print_after_context:
-				/* print some trailing context lines when needed */
-				if (!remaining_after_context) {
-					if (!status)
-						/* we're getting closer to the need of a separator between
-						 * current match block and the next one */
-						++need_separator;
-				} else {
-					qgrep_print_context_line(buf_list, label,
-							((verbose > 1) ? lineno : -1));
-					--remaining_after_context;
+ print_after_context:
+					/* print some trailing context lines when needed */
+					if (!remaining_after_context) {
+						if (!status)
+							/* we're getting closer to the need of a separator between
+							 * current match block and the next one */
+							++need_separator;
+					} else {
+						qgrep_print_context_line(buf_list, label,
+								((verbose > 1) ? lineno : -1));
+						--remaining_after_context;
+					}
 				}
+				fclose(newfp);
+				if (!per_file_output)
+					continue; /* matches were already displayed, line per line */
+				if (do_count && count) {
+					if (label != NULL)
+						/* -c without -v/-N/-H only outputs
+						 * the matches count of the file */
+						printf("%s:", label);
+					printf("%d\n", count);
+				} else if ((count && !invert_list) || (!count && invert_list))
+					printf("%s\n", label); /* do_list == 1, or we wouldn't be here */
 			}
-			fclose(newfp);
-			if (!per_file_output)
-				continue; /* matches were already displayed, line per line */
-			if (do_count && count) {
-				if (label != NULL)
-					/* -c without -v/-N/-H only outputs
-					 * the matches count of the file */
-					printf("%s:", label);
-				printf("%d\n", count);
-			} else if ((count && !invert_list) || (!count && invert_list))
-				printf("%s\n", label); /* do_list == 1, or we wouldn't be here */
 		}
+		if (do_eclass)
+			closedir(eclass_dir);
+		else if (!do_installed)
+			fclose(fp);
+
+		if (do_installed)
+			break;
 	}
-	if (do_eclass)
-		closedir(eclass_dir);
-	else if (!do_installed)
-		fclose(fp);
+
 	if (do_regex)
 		regfree(&preg);
 	if (do_regex && skip_pattern)
@@ -577,6 +590,7 @@ print_after_context:
 		free(include_atoms);
 	}
 	qgrep_buf_list_free(buf_list);
+
 	return status;
 }
 

diff --git a/quse.c b/quse.c
index 8ba0be1..2ac6cad 100644
--- a/quse.c
+++ b/quse.c
@@ -239,6 +239,8 @@ int quse_main(int argc, char **argv)
 	short quse_all = 0;
 	int regexp_matching = 1, i, idx = 0;
 	size_t search_len;
+	size_t n;
+	const char *overlay;
 
 	DBG("argc=%d argv[0]=%s argv[1]=%s",
 	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
@@ -259,179 +261,187 @@ int quse_main(int argc, char **argv)
 		quse_usage(EXIT_FAILURE);
 
 	if (idx == -1) {
-		size_t n;
-		const char *overlay;
 		array_for_each(overlays, n, overlay)
 			quse_describe_flag(overlay, optind, argc, argv);
 		return 0;
 	}
 
 	if (quse_all) optind = argc;
-	cache_file = initialize_ebuild_flat();
 
 	search_len = strlen(search_vars[idx]);
 	assert(search_len < sizeof(buf0));
 
-	if ((fp = fopen(cache_file, "r")) == NULL) {
-		warnp("could not read cache: %s", cache_file);
-		return 1;
-	}
+	array_for_each(overlays, n, overlay) {
+		cache_file = initialize_flat(overlay, CACHE_EBUILD, false);
 
-	int portdir_fd = open(portdir, O_RDONLY|O_CLOEXEC|O_PATH);
+		if ((fp = fopen(cache_file, "re")) == NULL) {
+			warnp("could not read cache: %s", cache_file);
+			continue;
+		}
 
-	ebuild = NULL;
-	while ((linelen = getline(&ebuild, &ebuildlen, fp)) != -1) {
-		FILE *newfp;
-		int fd;
+		int overlay_fd = open(overlay, O_RDONLY|O_CLOEXEC|O_PATH);
 
-		rmspace_len(ebuild, linelen);
+		ebuild = NULL;
+		while ((linelen = getline(&ebuild, &ebuildlen, fp)) != -1) {
+			FILE *newfp;
+			int fd;
 
-		fd = openat(portdir_fd, ebuild, O_RDONLY|O_CLOEXEC);
-		if (fd < 0)
-			continue;
-		newfp = fdopen(fd, "r");
-		if (newfp != NULL) {
-			unsigned int lineno = 0;
-			char revision[sizeof(buf0)];
-			char date[sizeof(buf0)];
-			char user[sizeof(buf0)];
-
-			revision[0] = 0;
-			user[0] = 0;
-			date[0] = 0;
-			while (fgets(buf0, sizeof(buf0), newfp) != NULL) {
-				int ok = 0;
-				char warned = 0;
-				lineno++;
-
-				if (*buf0 == '#') {
-					if (strncmp(buf0, "# $Header: /", 12) == 0)
-						sscanf(buf0, "%*s %*s %*s %s %s %*s %s %*s %*s", (char *) &revision, (char *) &date, (char *) &user);
-					continue;
-				}
-				if (strncmp(buf0, search_vars[idx], search_len) != 0)
-					continue;
+			rmspace_len(ebuild, linelen);
+
+			fd = openat(overlay_fd, ebuild, O_RDONLY|O_CLOEXEC);
+			if (fd < 0)
+				continue;
+			newfp = fdopen(fd, "r");
+			if (newfp != NULL) {
+				unsigned int lineno = 0;
+				char revision[sizeof(buf0)];
+				char date[sizeof(buf0)];
+				char user[sizeof(buf0)];
+
+				revision[0] = 0;
+				user[0] = 0;
+				date[0] = 0;
+				while (fgets(buf0, sizeof(buf0), newfp) != NULL) {
+					int ok = 0;
+					char warned = 0;
+					lineno++;
+
+					if (*buf0 == '#') {
+						if (strncmp(buf0, "# $Header: /", 12) == 0)
+							sscanf(buf0, "%*s %*s %*s %s %s %*s %s %*s %*s",
+								revision, date, user);
+						continue;
+					}
+					if (strncmp(buf0, search_vars[idx], search_len) != 0)
+						continue;
 
-				if ((p = strchr(buf0, '\n')) != NULL)
-					*p = 0;
-				if ((p = strchr(buf0, '#')) != NULL) {
-					if (buf0 != p && p[-1] == ' ')
-						p[-1] = 0;
-					else
+					if ((p = strchr(buf0, '\n')) != NULL)
 						*p = 0;
-				}
-				if (verbose > 1) {
-					if ((strchr(buf0, '\t') != NULL)
-					    || (strchr(buf0, '$') != NULL)
-					    || (strchr(buf0, '\\') != NULL)
-					    || (strchr(buf0, '\'') != NULL)
-					    || (strstr(buf0, "  ") != NULL)) {
-						warned = 1;
-						warn("# Line %d of %s has an annoying %s", lineno, ebuild, buf0);
+					if ((p = strchr(buf0, '#')) != NULL) {
+						if (buf0 != p && p[-1] == ' ')
+							p[-1] = 0;
+						else
+							*p = 0;
+					}
+					if (verbose > 1) {
+						if ((strchr(buf0, '\t') != NULL)
+						    || (strchr(buf0, '$') != NULL)
+						    || (strchr(buf0, '\\') != NULL)
+						    || (strchr(buf0, '\'') != NULL)
+						    || (strstr(buf0, "  ") != NULL)) {
+							warned = 1;
+							warn("# Line %d of %s has an annoying %s",
+								lineno, ebuild, buf0);
+						}
 					}
-				}
 #ifdef THIS_SUCKS
-				if ((p = strrchr(&buf0[search_len + 1], '\\')) != NULL) {
+					if ((p = strrchr(&buf0[search_len + 1], '\\')) != NULL) {
 
-				multiline:
-					*p = ' ';
+					multiline:
+						*p = ' ';
 
-					if (fgets(buf1, sizeof(buf1), newfp) == NULL)
-						continue;
-					lineno++;
+						if (fgets(buf1, sizeof(buf1), newfp) == NULL)
+							continue;
+						lineno++;
 
-					if ((p = strchr(buf1, '\n')) != NULL)
-						*p = 0;
-					snprintf(buf2, sizeof(buf2), "%s %s", buf0, buf1);
-					remove_extra_space(buf2);
-					strcpy(buf0, buf2);
-					if ((p = strrchr(buf1, '\\')) != NULL)
-						goto multiline;
-				}
+						if ((p = strchr(buf1, '\n')) != NULL)
+							*p = 0;
+						snprintf(buf2, sizeof(buf2), "%s %s", buf0, buf1);
+						remove_extra_space(buf2);
+						strcpy(buf0, buf2);
+						if ((p = strrchr(buf1, '\\')) != NULL)
+							goto multiline;
+					}
 #else
-				remove_extra_space(buf0);
+					remove_extra_space(buf0);
 #endif
-				while ((p = strrchr(&buf0[search_len + 1], '"')) != NULL)  *p = 0;
-				while ((p = strrchr(&buf0[search_len + 1], '\'')) != NULL) *p = 0;
-				while ((p = strrchr(&buf0[search_len + 1], '\\')) != NULL) *p = ' ';
-
-				if (verbose && warned == 0) {
-					if ((strchr(buf0, '$') != NULL) || (strchr(buf0, '\\') != NULL)) {
-						warned = 1;
-						warn("# Line %d of %s has an annoying %s", lineno, ebuild, buf0);
+					while ((p = strrchr(&buf0[search_len + 1], '"')) != NULL)  *p = 0;
+					while ((p = strrchr(&buf0[search_len + 1], '\'')) != NULL) *p = 0;
+					while ((p = strrchr(&buf0[search_len + 1], '\\')) != NULL) *p = ' ';
+
+					if (verbose && warned == 0) {
+						if ((strchr(buf0, '$') != NULL) || (strchr(buf0, '\\') != NULL)) {
+							warned = 1;
+							warn("# Line %d of %s has an annoying %s",
+								lineno, ebuild, buf0);
+						}
 					}
-				}
 
-				if (strlen(buf0) < search_len + 1) {
-					/* warnf("err '%s'/%zu <= %zu; line %u\n", buf0, strlen(buf0), search_len + 1, lineno); */
-					continue;
-				}
+					if (strlen(buf0) < search_len + 1) {
+						/* warnf("err '%s'/%zu <= %zu; line %u\n", buf0, strlen(buf0), search_len + 1, lineno); */
+						continue;
+					}
 
-				if ((argc == optind) || (quse_all)) {
-					ok = 1;
-				} else {
-					ok = 0;
-					if (regexp_matching) {
-						for (i = optind; i < argc; ++i) {
-							if (rematch(argv[i], &buf0[search_len + 1], REG_NOSUB) == 0) {
-								ok = 1;
-								break;
-							}
-						}
+					if ((argc == optind) || (quse_all)) {
+						ok = 1;
 					} else {
-						remove_extra_space(buf0);
-						strcpy(buf1, &buf0[search_len + 1]);
-
-						for (i = (size_t) optind; i < argc && argv[i] != NULL; i++) {
-							if (strcmp(buf1, argv[i]) == 0) {
-								ok = 1;
-								break;
+						ok = 0;
+						if (regexp_matching) {
+							for (i = optind; i < argc; ++i) {
+								if (rematch(argv[i], &buf0[search_len + 1], REG_NOSUB) == 0) {
+									ok = 1;
+									break;
+								}
 							}
-						}
-						if (ok == 0) while ((p = strchr(buf1, ' ')) != NULL) {
-							*p = 0;
+						} else {
+							remove_extra_space(buf0);
+							strcpy(buf1, &buf0[search_len + 1]);
+
 							for (i = (size_t) optind; i < argc && argv[i] != NULL; i++) {
 								if (strcmp(buf1, argv[i]) == 0) {
 									ok = 1;
 									break;
 								}
 							}
-							strcpy(buf2, p + 1);
-							strcpy(buf1, buf2);
-							if (strchr(buf1, ' ') == NULL)
+							if (ok == 0) while ((p = strchr(buf1, ' ')) != NULL) {
+								*p = 0;
 								for (i = (size_t) optind; i < argc && argv[i] != NULL; i++) {
-									if (strcmp(buf1, argv[i]) == 0)
+									if (strcmp(buf1, argv[i]) == 0) {
 										ok = 1;
+										break;
+									}
 								}
+								strcpy(buf2, p + 1);
+								strcpy(buf1, buf2);
+								if (strchr(buf1, ' ') == NULL)
+									for (i = (size_t) optind; i < argc && argv[i] != NULL; i++) {
+										if (strcmp(buf1, argv[i]) == 0)
+											ok = 1;
+									}
+							}
 						}
 					}
-				}
-				if (ok) {
-					if (verbose > 3)
-						printf("%s %s %s ", *user ? user : "MISSING", *revision ? revision : "MISSING", *date ? date : "MISSING");
-
-					printf("%s%s%s ", CYAN, ebuild, NORM);
-					print_highlighted_use_flags(&buf0[search_len + 1], optind, argc, argv);
-					puts(NORM);
-					if (verbose > 1) {
-						char **ARGV;
-						int ARGC;
-						makeargv(&buf0[search_len + 1], &ARGC, &ARGV);
-						quse_describe_flag(portdir, 1, ARGC, ARGV);
-						freeargv(ARGC, ARGV);
+					if (ok) {
+						if (verbose > 3)
+							printf("%s %s %s ",
+								*user ? user : "MISSING",
+								*revision ? revision : "MISSING",
+								*date ? date : "MISSING");
+
+						printf("%s%s%s ", CYAN, ebuild, NORM);
+						print_highlighted_use_flags(&buf0[search_len + 1], optind, argc, argv);
+						puts(NORM);
+						if (verbose > 1) {
+							char **ARGV;
+							int ARGC;
+							makeargv(&buf0[search_len + 1], &ARGC, &ARGV);
+							quse_describe_flag(overlay, 1, ARGC, ARGV);
+							freeargv(ARGC, ARGV);
+						}
 					}
+					break;
 				}
-				break;
+				fclose(newfp);
+			} else {
+				if (!reinitialize)
+					warnfp("(cache update pending) %s", ebuild);
+				reinitialize = 1;
 			}
-			fclose(newfp);
-		} else {
-			if (!reinitialize)
-				warnfp("(cache update pending) %s", ebuild);
-			reinitialize = 1;
 		}
+		fclose(fp);
+		close(overlay_fd);
 	}
-	fclose(fp);
-	close(portdir_fd);
+
 	return EXIT_SUCCESS;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-28  2:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-28  2:44 UTC (permalink / raw
  To: gentoo-commits

commit:     48aac66f8c73c63926868317f9a47d5582d5bbd5
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 27 23:27:34 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov 27 23:27:34 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=48aac66f

main: change "portdir" to "main_overlay"

Since we no longer use portdir anywhere, rename it to main_overlay.
Add some fallback logic though so we use PORTDIR when repos.conf does
not exist at all.

URL: https://bugs.gentoo.org/553260

 main.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/main.c b/main.c
index 9361b98..208f899 100644
--- a/main.c
+++ b/main.c
@@ -34,7 +34,7 @@ char pretend = 0;
 char reinitialize = 0;
 char reinitialize_metacache = 0;
 static char *portlogdir;
-static char *portdir;
+static char *main_overlay;
 static char *portarch;
 static char *portvdb;
 static char *portedb;
@@ -447,7 +447,7 @@ static void read_one_repos_conf(const char *repos_conf)
 		if (path) {
 			void *ele = xarraypush_str(overlays, path);
 			if (main_repo && !strcmp(repo, main_repo))
-				portdir = ele;
+				main_overlay = ele;
 		}
 		free(conf);
 	}
@@ -775,7 +775,7 @@ void initialize_portage_env(void)
 		_Q_EVS(ISTR, FEATURES,            features,            "noman noinfo nodoc")
 		_Q_EVS(STR,  EPREFIX,             eprefix,             CONFIG_EPREFIX)
 		_Q_EVS(STR,  EMERGE_LOG_DIR,      portlogdir,          CONFIG_EPREFIX "var/log")
-		_Q_EVS(STR,  PORTDIR,             portdir,             CONFIG_EPREFIX "usr/portage")
+		_Q_EVS(STR,  PORTDIR,             main_overlay,        CONFIG_EPREFIX "usr/portage")
 		_Q_EVS(STR,  PORTAGE_BINHOST,     binhost,             DEFAULT_PORTAGE_BINHOST)
 		_Q_EVS(STR,  PORTAGE_TMPDIR,      port_tmpdir,         CONFIG_EPREFIX "var/tmp/portage/")
 		_Q_EVS(STR,  PKGDIR,              pkgdir,              CONFIG_EPREFIX "usr/portage/packages/")
@@ -906,6 +906,8 @@ void initialize_portage_env(void)
 	}
 
 	read_repos_conf(configroot, CONFIG_EPREFIX "etc/portage/repos.conf");
+	if (array_cnt(overlays) == 0)
+		xarraypush_str(overlays, main_overlay);
 
 	if (getenv("PORTAGE_QUIET") != NULL)
 		quiet = 1;
@@ -1061,8 +1063,6 @@ ret:
 		close(overlay_fd);
 	return cache_file;
 }
-#define initialize_ebuild_flat() initialize_flat(portdir, CACHE_EBUILD, false)
-#define initialize_metadata_flat() initialize_flat(portdir, CACHE_METADATA, false)
 
 void reinitialize_as_needed(void)
 {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-28  2:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-28  2:44 UTC (permalink / raw
  To: gentoo-commits

commit:     cc1410da0856fea37f421d57ec2e3633918d5f7f
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 27 22:43:53 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov 27 22:43:53 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=cc1410da

qcache: make missing KEYWORDS a verbose message

These only warn about ebuilds that shouldn't have them set (such as
9999 ebuilds), so making the warning a verbose one for now.

 qcache.c | 24 ++++++++++++++++++------
 1 file changed, 18 insertions(+), 6 deletions(-)

diff --git a/qcache.c b/qcache.c
index 091a510..5cac394 100644
--- a/qcache.c
+++ b/qcache.c
@@ -525,7 +525,9 @@ void qcache_imlate(qcache_data *data)
 	keywords = xmalloc(sizeof(*keywords) * archlist_count);
 
 	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
-		warn("Failed to read keywords for %s%s/%s%s%s", BOLD, data->category, BLUE, data->ebuild, NORM);
+		if (verbose)
+			warn("Failed to read keywords for %s%s/%s%s%s",
+				BOLD, data->category, BLUE, data->ebuild, NORM);
 		free(keywords);
 		return;
 	}
@@ -559,7 +561,9 @@ void qcache_not(qcache_data *data)
 	keywords = xmalloc(sizeof(*keywords) * archlist_count);
 
 	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
-		warn("Failed to read keywords for %s%s/%s%s%s", BOLD, data->category, BLUE, data->ebuild, NORM);
+		if (verbose)
+			warn("Failed to read keywords for %s%s/%s%s%s",
+				BOLD, data->category, BLUE, data->ebuild, NORM);
 		free(keywords);
 		return;
 	}
@@ -584,7 +588,9 @@ void qcache_all(qcache_data *data)
 	keywords = xmalloc(sizeof(*keywords) * archlist_count);
 
 	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
-		warn("Failed to read keywords for %s%s/%s%s%s", BOLD, data->category, BLUE, data->ebuild, NORM);
+		if (verbose)
+			warn("Failed to read keywords for %s%s/%s%s%s",
+				BOLD, data->category, BLUE, data->ebuild, NORM);
 		free(keywords);
 		return;
 	}
@@ -612,7 +618,9 @@ void qcache_dropped(qcache_data *data)
 	keywords = xmalloc(sizeof(*keywords) * archlist_count);
 
 	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
-		warn("Failed to read keywords for %s%s/%s%s%s", BOLD, data->category, BLUE, data->ebuild, NORM);
+		if (verbose)
+			warn("Failed to read keywords for %s%s/%s%s%s",
+				BOLD, data->category, BLUE, data->ebuild, NORM);
 		free(keywords);
 		return;
 	}
@@ -727,7 +735,9 @@ void qcache_stats(qcache_data *data)
 
 	memset(keywords, 0, archlist_count * sizeof(*keywords));
 	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
-		warn("Failed to read keywords for %s%s/%s%s%s", BOLD, data->category, BLUE, data->ebuild, NORM);
+		if (verbose)
+			warn("Failed to read keywords for %s%s/%s%s%s",
+				BOLD, data->category, BLUE, data->ebuild, NORM);
 		return;
 	}
 
@@ -774,7 +784,9 @@ void qcache_testing_only(qcache_data *data)
 	keywords = xmalloc(sizeof(*keywords) * archlist_count);
 
 	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
-		warn("Failed to read keywords for %s%s/%s%s%s", BOLD, data->category, BLUE, data->ebuild, NORM);
+		if (verbose)
+			warn("Failed to read keywords for %s%s/%s%s%s",
+				BOLD, data->category, BLUE, data->ebuild, NORM);
 		free(keywords);
 		return;
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-28  2:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-28  2:44 UTC (permalink / raw
  To: gentoo-commits

commit:     186af28f41cadc29027ef900c3b8622af7d3b4a0
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 27 21:10:04 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov 27 21:10:04 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=186af28f

qcache: fix cache table display w/longer arches

The table code has a hardcoded width of 12 bytes which breaks with the
newer arch values in the tree.  Rework the code to calculate the width
dynamically based on the longest value in the list.

 qcache.c | 32 ++++++++++++++++++++------------
 1 file changed, 20 insertions(+), 12 deletions(-)

diff --git a/qcache.c b/qcache.c
index 8dbeaa3..25f8651 100644
--- a/qcache.c
+++ b/qcache.c
@@ -65,6 +65,7 @@ typedef struct {
 
 static char **archlist; /* Read from PORTDIR/profiles/arch.list in qcache_init() */
 static int archlist_count;
+static size_t arch_longest_len;
 const char status[3] = {'-', '~', '+'};
 int qcache_skip, qcache_test_arch, qcache_last = 0;
 char *qcache_matchpkg = NULL, *qcache_matchcat = NULL;
@@ -703,31 +704,36 @@ void qcache_stats(qcache_data *data)
 	}
 
 	if (qcache_last) {
-		printf("+-------------------------+\n");
+		const char border[] = "------------------------------------------------------------------";
+		printf("+%.*s+\n", 25, border);
 		printf("|   general statistics    |\n");
-		printf("+-------------------------+\n");
+		printf("+%.*s+\n", 25, border);
 		printf("| %s%13s%s | %s%7d%s |\n", GREEN, "architectures", NORM, BLUE, archlist_count, NORM);
 		printf("| %s%13s%s | %s%7d%s |\n", GREEN, "categories", NORM, BLUE, numcat, NORM);
 		printf("| %s%13s%s | %s%7d%s |\n", GREEN, "packages", NORM, BLUE, numpkg, NORM);
 		printf("| %s%13s%s | %s%7d%s |\n", GREEN, "ebuilds", NORM, BLUE, numebld, NORM);
-		printf("+-------------------------+\n\n");
-
-		printf("+----------------------------------------------------------+\n");
-		printf("|                   keyword distribution                   |\n");
-		printf("+----------------------------------------------------------+\n");
-		printf("| %s%12s%s |%s%8s%s |%s%8s%s |%s%8s%s | %s%8s%s |\n", RED, "architecture", NORM, RED, "stable", NORM, RED, "~arch", NORM, RED, "total", NORM, RED, "total/#pkgs", NORM);
-		printf("|              |         |%s%8s%s |         |             |\n", RED, "only", NORM);
-		printf("+----------------------------------------------------------+\n");
+		printf("+%.*s+\n\n", 25, border);
+
+		printf("+%.*s+\n", (int)(arch_longest_len + 46), border);
+		printf("|%*skeyword distribution                          |\n",
+			(int)arch_longest_len, "");
+		printf("+%.*s+\n", (int)(arch_longest_len + 46), border);
+		printf("| %s%*s%s |%s%8s%s |%s%8s%s |%s%8s%s | %s%8s%s |\n",
+			RED, (int)arch_longest_len, "architecture", NORM, RED, "stable", NORM,
+			RED, "~arch", NORM, RED, "total", NORM, RED, "total/#pkgs", NORM);
+		printf("| %*s |         |%s%8s%s |         |             |\n",
+			(int)arch_longest_len, "", RED, "only", NORM);
+		printf("+%.*s+\n", (int)(arch_longest_len + 46), border);
 
 		for (a = 0; a < archlist_count; ++a) {
-			printf("| %s%12s%s |", GREEN, archlist[a], NORM);
+			printf("| %s%*s%s |", GREEN, (int)arch_longest_len, archlist[a], NORM);
 			printf("%s%8d%s |", BLUE, packages_stable[a], NORM);
 			printf("%s%8d%s |", BLUE, packages_testing[a], NORM);
 			printf("%s%8d%s |", BLUE, packages_testing[a]+packages_stable[a], NORM);
 			printf("%s%11.2f%s%% |\n", BLUE, (100.0*(packages_testing[a]+packages_stable[a]))/numpkg, NORM);
 		}
 
-		printf("+----------------------------------------------------------+\n\n");
+		printf("+%.*s+\n\n", (int)(arch_longest_len + 46), border);
 
 		printf("Completed in %s%d%s seconds.\n", BLUE, (int)(time(NULL)-runtime), NORM);
 
@@ -801,6 +807,7 @@ bool qcache_init(void)
 		goto done;
 
 	archlist_count = 0;
+	arch_longest_len = 0;
 	buf = NULL;
 	while ((linelen = getline(&buf, &buflen, fp)) != -1) {
 		rmspace_len(buf, linelen);
@@ -813,6 +820,7 @@ bool qcache_init(void)
 		++archlist_count;
 		archlist = xrealloc_array(archlist, sizeof(*archlist), archlist_count);
 		archlist[archlist_count - 1] = xstrdup(buf);
+		arch_longest_len = MAX(arch_longest_len, strlen(buf));
 	}
 	free(buf);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-28  2:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-28  2:44 UTC (permalink / raw
  To: gentoo-commits

commit:     b4db839907e96b8346ecb27dbc231dab1c335704
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 27 22:37:02 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov 27 22:37:02 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b4db8399

qcache: rework last traversal callback

Rather than packing the last entry in at the same time as a valid
call, make a dedicated call with a NULL argument.  This way the
callback funcs are forced to deal with this up front cleanly.

 qcache.c | 112 ++++++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 64 insertions(+), 48 deletions(-)

diff --git a/qcache.c b/qcache.c
index 0891918..091a510 100644
--- a/qcache.c
+++ b/qcache.c
@@ -67,7 +67,7 @@ static char **archlist; /* Read from PORTDIR/profiles/arch.list in qcache_init()
 static int archlist_count;
 static size_t arch_longest_len;
 const char status[3] = {'-', '~', '+'};
-int qcache_skip, qcache_test_arch, qcache_last = 0;
+int qcache_skip, qcache_test_arch;
 char *qcache_matchpkg = NULL, *qcache_matchcat = NULL;
 
 /********************************************************************/
@@ -462,6 +462,7 @@ int qcache_traverse(void (*func)(qcache_data*))
 			qcache_skip = 0;
 
 			/* traverse ebuilds */
+			data.num = num_ebuild;
 			for (k = 0; k < num_ebuild; k++) {
 				len = xasprintf(&cachepath, "%s/%s/%s", catpath, categories[i]->d_name, ebuilds[k]->d_name);
 				cachepath[len - 7] = '\0'; /* remove ".ebuild" */
@@ -470,14 +471,9 @@ int qcache_traverse(void (*func)(qcache_data*))
 				data.package = packages[j]->d_name;
 				data.ebuild = ebuilds[k]->d_name;
 				data.cur = k + 1;
-				data.num = num_ebuild;
 				data.cache_data = qcache_read_cache_file(cachepath);
 
 				if (data.cache_data != NULL) {
-					/* is this the last ebuild? */
-					if (i+1 == num_cat && j+1 == num_pkg && k+1 == num_ebuild)
-						qcache_last = 1;
-
 					if (!qcache_skip)
 						func(&data);
 
@@ -508,6 +504,8 @@ int qcache_traverse(void (*func)(qcache_data*))
 	free(categories);
 	free(catpath);
 
+	func(NULL);
+
 	return 0;
 }
 
@@ -521,6 +519,9 @@ void qcache_imlate(qcache_data *data)
 	int *keywords;
 	int a;
 
+	if (!data)
+		return;
+
 	keywords = xmalloc(sizeof(*keywords) * archlist_count);
 
 	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
@@ -552,6 +553,9 @@ void qcache_not(qcache_data *data)
 {
 	int *keywords;
 
+	if (!data)
+		return;
+
 	keywords = xmalloc(sizeof(*keywords) * archlist_count);
 
 	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
@@ -574,6 +578,9 @@ void qcache_all(qcache_data *data)
 {
 	int *keywords;
 
+	if (!data)
+		return;
+
 	keywords = xmalloc(sizeof(*keywords) * archlist_count);
 
 	if (read_keywords(data->cache_data->KEYWORDS, keywords) < 0) {
@@ -596,6 +603,9 @@ void qcache_dropped(qcache_data *data)
 	static int possible = 0;
 	int *keywords, i;
 
+	if (!data)
+		return;
+
 	if (data->cur == 1)
 		possible = 0;
 
@@ -644,6 +654,51 @@ void qcache_stats(qcache_data *data)
 	static int *keywords;
 	int a;
 
+	/* Is this the last time we'll be called? */
+	if (!data) {
+		const char border[] = "------------------------------------------------------------------";
+
+		printf("+%.*s+\n", 25, border);
+		printf("|   general statistics    |\n");
+		printf("+%.*s+\n", 25, border);
+		printf("| %s%13s%s | %s%7d%s |\n", GREEN, "architectures", NORM, BLUE, archlist_count, NORM);
+		printf("| %s%13s%s | %s%7d%s |\n", GREEN, "categories", NORM, BLUE, numcat, NORM);
+		printf("| %s%13s%s | %s%7d%s |\n", GREEN, "packages", NORM, BLUE, numpkg, NORM);
+		printf("| %s%13s%s | %s%7d%s |\n", GREEN, "ebuilds", NORM, BLUE, numebld, NORM);
+		printf("+%.*s+\n\n", 25, border);
+
+		printf("+%.*s+\n", (int)(arch_longest_len + 46), border);
+		printf("|%*skeyword distribution                          |\n",
+			(int)arch_longest_len, "");
+		printf("+%.*s+\n", (int)(arch_longest_len + 46), border);
+		printf("| %s%*s%s |%s%8s%s |%s%8s%s |%s%8s%s | %s%8s%s |\n",
+			RED, (int)arch_longest_len, "architecture", NORM, RED, "stable", NORM,
+			RED, "~arch", NORM, RED, "total", NORM, RED, "total/#pkgs", NORM);
+		printf("| %*s |         |%s%8s%s |         |             |\n",
+			(int)arch_longest_len, "", RED, "only", NORM);
+		printf("+%.*s+\n", (int)(arch_longest_len + 46), border);
+
+		for (a = 0; a < archlist_count; ++a) {
+			printf("| %s%*s%s |", GREEN, (int)arch_longest_len, archlist[a], NORM);
+			printf("%s%8d%s |", BLUE, packages_stable[a], NORM);
+			printf("%s%8d%s |", BLUE, packages_testing[a], NORM);
+			printf("%s%8d%s |", BLUE, packages_testing[a]+packages_stable[a], NORM);
+			printf("%s%11.2f%s%% |\n", BLUE, (100.0*(packages_testing[a]+packages_stable[a]))/numpkg, NORM);
+		}
+
+		printf("+%.*s+\n\n", (int)(arch_longest_len + 46), border);
+
+		printf("Completed in ");
+		print_seconds_for_earthlings(time(NULL) - runtime);
+		printf("\n");
+
+		free(packages_stable);
+		free(packages_testing);
+		free(keywords);
+		free(current_package_keywords);
+		return;
+	}
+
 	if (!numpkg) {
 		struct dirent **categories;
 		char *catpath;
@@ -702,48 +757,6 @@ void qcache_stats(qcache_data *data)
 			}
 		}
 	}
-
-	if (qcache_last) {
-		const char border[] = "------------------------------------------------------------------";
-		printf("+%.*s+\n", 25, border);
-		printf("|   general statistics    |\n");
-		printf("+%.*s+\n", 25, border);
-		printf("| %s%13s%s | %s%7d%s |\n", GREEN, "architectures", NORM, BLUE, archlist_count, NORM);
-		printf("| %s%13s%s | %s%7d%s |\n", GREEN, "categories", NORM, BLUE, numcat, NORM);
-		printf("| %s%13s%s | %s%7d%s |\n", GREEN, "packages", NORM, BLUE, numpkg, NORM);
-		printf("| %s%13s%s | %s%7d%s |\n", GREEN, "ebuilds", NORM, BLUE, numebld, NORM);
-		printf("+%.*s+\n\n", 25, border);
-
-		printf("+%.*s+\n", (int)(arch_longest_len + 46), border);
-		printf("|%*skeyword distribution                          |\n",
-			(int)arch_longest_len, "");
-		printf("+%.*s+\n", (int)(arch_longest_len + 46), border);
-		printf("| %s%*s%s |%s%8s%s |%s%8s%s |%s%8s%s | %s%8s%s |\n",
-			RED, (int)arch_longest_len, "architecture", NORM, RED, "stable", NORM,
-			RED, "~arch", NORM, RED, "total", NORM, RED, "total/#pkgs", NORM);
-		printf("| %*s |         |%s%8s%s |         |             |\n",
-			(int)arch_longest_len, "", RED, "only", NORM);
-		printf("+%.*s+\n", (int)(arch_longest_len + 46), border);
-
-		for (a = 0; a < archlist_count; ++a) {
-			printf("| %s%*s%s |", GREEN, (int)arch_longest_len, archlist[a], NORM);
-			printf("%s%8d%s |", BLUE, packages_stable[a], NORM);
-			printf("%s%8d%s |", BLUE, packages_testing[a], NORM);
-			printf("%s%8d%s |", BLUE, packages_testing[a]+packages_stable[a], NORM);
-			printf("%s%11.2f%s%% |\n", BLUE, (100.0*(packages_testing[a]+packages_stable[a]))/numpkg, NORM);
-		}
-
-		printf("+%.*s+\n\n", (int)(arch_longest_len + 46), border);
-
-		printf("Completed in ");
-		print_seconds_for_earthlings(time(NULL) - runtime);
-		printf("\n");
-
-		free(packages_stable);
-		free(packages_testing);
-		free(keywords);
-		free(current_package_keywords);
-	}
 }
 
 _q_static
@@ -752,6 +765,9 @@ void qcache_testing_only(qcache_data *data)
 	static int possible = 0;
 	int *keywords;
 
+	if (!data)
+		return;
+
 	if (data->cur == 1)
 		possible = 0;
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-28  2:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-28  2:44 UTC (permalink / raw
  To: gentoo-commits

commit:     29afc5efc0ae2cd9977b0b44469d741c1c2066d3
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 27 20:49:47 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov 27 20:49:47 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=29afc5ef

qcache: fix ebuild traversal error path

We were freeing the wrong vars for this loop.

Also do not dump a warning when we try to scan a path that isn't a
directory.  Random files in there shouldn't cause us to complain.

 qcache.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/qcache.c b/qcache.c
index af64bc5..8dbeaa3 100644
--- a/qcache.c
+++ b/qcache.c
@@ -441,9 +441,11 @@ int qcache_traverse(void (*func)(qcache_data*))
 			xasprintf(&ebuildpath, "%s/%s/%s", portdir, categories[i]->d_name, packages[j]->d_name);
 
 			if (-1 == (num_ebuild = scandir(ebuildpath, &ebuilds, qcache_ebuild_select, qcache_vercmp))) {
-				warnp("%s", ebuildpath);
-				free(packages[i]);
-				free(pkgpath);
+				/* Do not complain about spurious files */
+				if (errno != ENOTDIR)
+					warnp("%s", ebuildpath);
+				free(packages[j]);
+				free(ebuildpath);
 				continue;
 			}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-28  2:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-28  2:44 UTC (permalink / raw
  To: gentoo-commits

commit:     6c142af26118bd69597860582c27934238334749
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 27 19:12:13 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov 27 19:12:13 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6c142af2

qcache: use scandir_free

 qcache.c | 15 ++++-----------
 1 file changed, 4 insertions(+), 11 deletions(-)

diff --git a/qcache.c b/qcache.c
index 5f65fe0..5d915bd 100644
--- a/qcache.c
+++ b/qcache.c
@@ -528,10 +528,8 @@ int qcache_traverse(void (*func)(qcache_data*))
 
 		if (qcache_matchcat) {
 			if (strcmp(categories[i]->d_name, qcache_matchcat) != 0) {
-				for (j = 0; j < num_pkg; j++)
-					free(packages[j]);
+				scandir_free(packages, num_pkg);
 				free(categories[i]);
-				free(packages);
 				free(pkgpath);
 				continue;
 			}
@@ -552,10 +550,8 @@ int qcache_traverse(void (*func)(qcache_data*))
 
 			if (qcache_matchpkg) {
 				if (strcmp(packages[j]->d_name, qcache_matchpkg) != 0) {
-					for (k = 0; k < num_ebuild; k++)
-						free(ebuilds[k]);
+					scandir_free(ebuilds, num_ebuild);
 					free(packages[j]);
-					free(ebuilds);
 					free(ebuildpath);
 					continue;
 				}
@@ -741,7 +737,7 @@ void qcache_stats(qcache_data *data)
 	static int *packages_testing;
 	static int *current_package_keywords;
 	static int *keywords;
-	int a, i;
+	int a;
 
 	if (!numpkg) {
 		struct dirent **categories;
@@ -753,10 +749,7 @@ void qcache_stats(qcache_data *data)
 			errp("%s", catpath);
 			free(catpath);
 		}
-
-		for (i = 0; i < numcat; i++)
-			free(categories[i]);
-		free(categories);
+		scandir_free(categories, numcat);
 
 		runtime = time(NULL);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-28  2:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-28  2:44 UTC (permalink / raw
  To: gentoo-commits

commit:     f162c6a9219deacfe23c8e21b732f8594a938130
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 27 19:04:10 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov 27 19:04:10 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f162c6a9

qsearch: add multiple overlay support

We ractor some of the main code into helper funcs to make iterating
over the overlays easier to manage.

URL: https://bugs.gentoo.org/553260

 qsearch.c | 268 +++++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 152 insertions(+), 116 deletions(-)

diff --git a/qsearch.c b/qsearch.c
index 02d43ca..b7c992e 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -31,18 +31,114 @@ static const char * const qsearch_opts_help[] = {
 };
 #define qsearch_usage(ret) usage(ret, QSEARCH_FLAGS, qsearch_long_opts, qsearch_opts_help, lookup_applet_idx("qsearch"))
 
-int qsearch_main(int argc, char **argv)
+#define LAST_BUF_SIZE 256
+
+/* Search an ebuild's details via the metadata cache. */
+static void
+qsearch_ebuild_metadata(_q_unused_ int overlay_fd, const char *ebuild, const char *search_me, char *last,
+                        bool search_desc, bool search_all, _q_unused_ bool search_name, bool show_name_only, bool show_homepage)
+{
+	portage_cache *pcache = cache_read_file(ebuild);
+
+	if (pcache == NULL) {
+		if (!reinitialize)
+			warnf("(cache update pending) %s", ebuild);
+		reinitialize = 1;
+		return;
+	}
+
+	if (strcmp(pcache->atom->PN, last) != 0) {
+		strncpy(last, pcache->atom->PN, LAST_BUF_SIZE);
+		if (search_all || rematch(search_me, (search_desc ? pcache->DESCRIPTION : ebuild), REG_EXTENDED | REG_ICASE) == 0)
+			printf("%s%s/%s%s%s %s\n", BOLD, pcache->atom->CATEGORY, BLUE,
+			       pcache->atom->PN, NORM,
+			       (show_name_only ? "" :
+			        (show_homepage ? pcache->HOMEPAGE : pcache->DESCRIPTION)));
+	}
+	cache_free(pcache);
+}
+
+/* Search an ebuild's details via the ebuild cache. */
+static void
+qsearch_ebuild_ebuild(int overlay_fd, const char *ebuild, const char *search_me, char *last,
+                      _q_unused_ bool search_desc, bool search_all, bool search_name, bool show_name_only, _q_unused_ bool show_homepage)
 {
-	FILE *fp;
-	char *ebuild = NULL;
-	char last[126] = "";
+	const char * const search_vars[] = { "DESCRIPTION=", "HOMEPAGE=" };
+	const char *search_var = search_vars[show_homepage ? 1 : 0];
+	size_t search_len = strlen(search_var);
 	char *p, *q, *str;
+
+	FILE *ebuildfp;
+	str = xstrdup(ebuild);
+	p = dirname(str);
+
+	if (strcmp(p, last) == 0)
+		goto no_cache_ebuild_match;
+
+	bool show_it = false;
+	strncpy(last, p, LAST_BUF_SIZE);
+	if (search_name) {
+		if (rematch(search_me, basename(last), REG_EXTENDED | REG_ICASE) != 0) {
+			goto no_cache_ebuild_match;
+		} else {
+			q = NULL;
+			show_it = true;
+		}
+	}
+
+	int fd = openat(overlay_fd, ebuild, O_RDONLY|O_CLOEXEC);
+	if (fd != -1) {
+		ebuildfp = fdopen(fd, "r");
+		if (ebuildfp == NULL) {
+			close(fd);
+			goto no_cache_ebuild_match;
+		}
+	} else {
+		if (!reinitialize)
+			warnfp("(cache update pending) %s", ebuild);
+		reinitialize = 1;
+		goto no_cache_ebuild_match;
+	}
+
+	char *buf = NULL;
+	size_t buflen, linelen;
+	while ((linelen = getline(&buf, &buflen, ebuildfp)) != -1) {
+		if (linelen <= search_len)
+			continue;
+		if (strncmp(buf, search_var, search_len) != 0)
+			continue;
+		if ((q = strrchr(buf, '"')) != NULL)
+			*q = 0;
+		if (strlen(buf) <= search_len)
+			break;
+		q = buf + search_len + 1;
+		if (!search_all && !search_name && rematch(search_me, q, REG_EXTENDED | REG_ICASE) != 0)
+			break;
+		show_it = true;
+		break;
+	}
+
+	if (show_it) {
+		printf("%s%s/%s%s%s %s\n",
+			BOLD, dirname(p), BLUE, basename(p), NORM,
+			(show_name_only ? "" : q ? : "<no DESCRIPTION found>"));
+	}
+
+	free(buf);
+	fclose(ebuildfp);
+ no_cache_ebuild_match:
+	free(str);
+}
+
+int qsearch_main(int argc, char **argv)
+{
+	char last[LAST_BUF_SIZE];
 	char *search_me = NULL;
-	char show_homepage = 0, show_name_only = 0;
-	char search_desc = 0, search_all = 0, search_name = 1, search_cache = CACHE_EBUILD;
-	const char *search_vars[] = { "DESCRIPTION=", "HOMEPAGE=" };
-	size_t search_len, ebuild_len, linelen;
-	int i, idx=0;
+	bool show_homepage = false, show_name_only = false;
+	bool search_desc = false, search_all = false, search_name = true;
+	int search_cache = CACHE_EBUILD;
+	int i;
+	void (*search_func)(int, const char *, const char *, char *last, bool, bool, bool, bool, bool);
 
 	DBG("argc=%d argv[0]=%s argv[1]=%s",
 	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
@@ -50,132 +146,72 @@ int qsearch_main(int argc, char **argv)
 	while ((i = GETOPT_LONG(QSEARCH, qsearch, "")) != -1) {
 		switch (i) {
 		COMMON_GETOPTS_CASES(qsearch)
-		case 'a': search_all = 1; break;
+		case 'a': search_all = true; break;
 		case 'c': search_cache = CACHE_METADATA; break;
 		case 'e': search_cache = CACHE_EBUILD; break;
-		case 's': search_desc = 0; search_name = 1; break;
-		case 'S': search_desc = 1; search_name = 0; break;
-		case 'N': show_name_only = 1; break;
-		case 'H': show_homepage = 1, idx = 1; break;
+		case 's': search_desc = false; search_name = true; break;
+		case 'S': search_desc = true; search_name = false; break;
+		case 'N': show_name_only = true; break;
+		case 'H': show_homepage = true; break;
 		}
 	}
 
+	switch (search_cache) {
+	case CACHE_METADATA:
+		search_func = qsearch_ebuild_metadata;
+		break;
+	case CACHE_EBUILD:
+		search_func = qsearch_ebuild_ebuild;
+		break;
+	default:
+		err("unknown cache %i", search_cache);
+	}
+
 	if (search_all) {
-		search_desc = 1;
-		search_name = 0;
+		search_desc = true;
+		search_name = false;
 	} else {
 		if (argc == optind)
 			qsearch_usage(EXIT_FAILURE);
 		search_me = argv[optind];
 	}
 	last[0] = 0;
-	fp = fopen(initialize_flat(portdir, search_cache, false), "r");
-	if (!fp)
-		return 1;
-
-	int portdir_fd = open(portdir, O_RDONLY|O_CLOEXEC|O_PATH);
-	if (portdir_fd < 0)
-		errp("open(%s) failed", portdir);
-
-	q = NULL; /* Silence a gcc warning. */
-	search_len = strlen(search_vars[idx]);
 
-	while ((linelen = getline(&ebuild, &ebuild_len, fp)) != -1) {
-		rmspace_len(ebuild, linelen);
-		if (!ebuild[0])
+	int ret = 0;
+	size_t n;
+	const char *overlay;
+	array_for_each(overlays, n, overlay) {
+		FILE *fp = fopen(initialize_flat(overlay, search_cache, false), "r");
+		if (!fp) {
+			warnp("opening cache for %s failed", overlay);
+			ret = 1;
 			continue;
+		}
 
-		switch (search_cache) {
-
-		case CACHE_METADATA: {
-			portage_cache *pcache;
-			if ((pcache = cache_read_file(ebuild)) != NULL) {
-				if (strcmp(pcache->atom->PN, last) != 0) {
-					strncpy(last, pcache->atom->PN, sizeof(last));
-					if ((rematch(search_me, (search_desc ? pcache->DESCRIPTION : ebuild), REG_EXTENDED | REG_ICASE) == 0) || search_all)
-						printf("%s%s/%s%s%s %s\n", BOLD, pcache->atom->CATEGORY, BLUE,
-						       pcache->atom->PN, NORM,
-						       (show_name_only ? "" :
-						        (show_homepage ? pcache->HOMEPAGE : pcache->DESCRIPTION)));
-				}
-				cache_free(pcache);
-			} else {
-				if (!reinitialize)
-					warnf("(cache update pending) %s", ebuild);
-				reinitialize = 1;
-			}
-			break;
+		int overlay_fd = open(overlay, O_RDONLY|O_CLOEXEC|O_PATH);
+		if (overlay_fd < 0) {
+			fclose(fp);
+			warnp("open failed: %s", overlay);
+			ret = 1;
+			continue;
 		}
 
-		case CACHE_EBUILD: {
-			FILE *ebuildfp;
-			str = xstrdup(ebuild);
-			p = dirname(str);
-
-			if (strcmp(p, last) != 0) {
-				bool show_it = false;
-				strncpy(last, p, sizeof(last));
-				if (search_name) {
-					if (rematch(search_me, basename(last), REG_EXTENDED | REG_ICASE) != 0) {
-						goto no_cache_ebuild_match;
-					} else {
-						q = NULL;
-						show_it = true;
-					}
-				}
-
-				int fd = openat(portdir_fd, ebuild, O_RDONLY|O_CLOEXEC);
-				if (fd != -1) {
-					ebuildfp = fdopen(fd, "r");
-					if (ebuildfp == NULL) {
-						close(fd);
-						continue;
-					}
-				} else {
-					if (!reinitialize)
-						warnfp("(cache update pending) %s", ebuild);
-					reinitialize = 1;
-					goto no_cache_ebuild_match;
-				}
-
-				char *buf = NULL;
-				size_t buflen;
-				while ((linelen = getline(&buf, &buflen, ebuildfp)) != -1) {
-					if (linelen <= search_len)
-						continue;
-					if (strncmp(buf, search_vars[idx], search_len) != 0)
-						continue;
-					if ((q = strrchr(buf, '"')) != NULL)
-						*q = 0;
-					if (strlen(buf) <= search_len)
-						break;
-					q = buf + search_len + 1;
-					if (!search_all && !search_name && rematch(search_me, q, REG_EXTENDED | REG_ICASE) != 0)
-						break;
-					show_it = true;
-					break;
-				}
-
-				if (show_it) {
-					printf("%s%s/%s%s%s %s\n",
-						BOLD, dirname(p), BLUE, basename(p), NORM,
-						(show_name_only ? "" : q ? : "<no DESCRIPTION found>"));
-				}
-
-				free(buf);
-				fclose(ebuildfp);
-			}
-no_cache_ebuild_match:
-			free(str);
+		size_t buflen, linelen;
+		char *buf = NULL;
+		while ((linelen = getline(&buf, &buflen, fp)) != -1) {
+			rmspace_len(buf, linelen);
+			if (!buf[0])
+				continue;
 
-			break;
-		} /* case CACHE_EBUILD */
-		} /* switch (search_cache) */
+			search_func(overlay_fd, buf, search_me, last, search_desc,
+				search_all, search_name, show_name_only, show_homepage);
+		}
+		free(buf);
+		close(overlay_fd);
+		fclose(fp);
 	}
-	free(ebuild);
-	close(portdir_fd);
-	fclose(fp);
-	return EXIT_SUCCESS;
+
+	return ret;
 }
 
 #else


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-28  2:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-28  2:44 UTC (permalink / raw
  To: gentoo-commits

commit:     f031a1315e1363857959cdae24414a7845cc1660
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 27 20:10:10 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov 27 20:10:10 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=f031a131

qcache: only warn once per missing cache file

When the cache is out of date, we can spam hundreds of lines.
Only do it once.

 qcache.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/qcache.c b/qcache.c
index 9e41c3c..fed3534 100644
--- a/qcache.c
+++ b/qcache.c
@@ -578,9 +578,14 @@ int qcache_traverse(void (*func)(qcache_data*))
 						func(&data);
 
 					qcache_free_data(data.cache_data);
-				} else
-					warnp("unable to read cache '%s'\n"
-					      "\tperhaps you need to `egencache -j 4` ?", cachepath);
+				} else {
+					static bool warned = false;
+					if (!warned) {
+						warned = true;
+						warnp("unable to read cache '%s'\n"
+						      "\tperhaps you need to `egencache -j 4` ?", cachepath);
+					}
+				}
 
 				free(ebuilds[k]);
 				free(cachepath);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-28  2:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-28  2:44 UTC (permalink / raw
  To: gentoo-commits

commit:     be66cbd9a8e495972f1e85398ce6bde98c210c7b
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 27 20:14:07 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov 27 20:14:07 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=be66cbd9

qcache: rewrite arch.list loading to use getline()

This applet carries its own file reading utils that are inefficient
(they read 1 byte off the disk at a time) and are used by only one
piece of code -- the arch.list reader.  Punt the funcs so we can use
getline directly.

 qcache.c | 146 +++++++++++++++------------------------------------------------
 1 file changed, 33 insertions(+), 113 deletions(-)

diff --git a/qcache.c b/qcache.c
index fed3534..af64bc5 100644
--- a/qcache.c
+++ b/qcache.c
@@ -204,105 +204,6 @@ int read_keywords(char *s, int *keywords)
 	return 0;
 }
 
-/********************************************************************/
-/* File reading helper functions                                    */
-/********************************************************************/
-
-/*
- * inline unsigned int qcache_count_lines(char *filename);
- *
- * Count the number of new line characters '\n' in a file.
- *
- * IN:
- *  char *filename - name of the file to read.
- * OUT:
- *  unsigned int count - number of new lines counted.
- * ERR:
- *  -1 is returned if the file cannot be read.
- */
-_q_static
-unsigned int qcache_count_lines(char *filename)
-{
-	int count, fd;
-	char c;
-
-	if ((fd = open(filename, O_RDONLY|O_CLOEXEC)) != -1) {
-		count = 0;
-
-		while (read(fd, &c, 1) == 1)
-			if (c == '\n')
-				count++;
-
-		close(fd);
-		return count;
-	}
-
-	return -1;
-}
-
-/*
- * char **qcache_read_lines(char *filename);
- *
- * Reads in every line contained in a file
- *
- * IN:
- *  char *filename - name of the file to read.
- * OUT:
- *  char **lines - number of new lines counted.
- * ERR:
- *  NULL is returned if an error occurs.
- */
-_q_static
-char **qcache_read_lines(char *filename)
-{
-	int len, fd, count, i, num_lines;
-	char **lines, c;
-
-	if (-1 == (num_lines = qcache_count_lines(filename)))
-		return NULL;
-
-	len   = sizeof(char*) * (num_lines + 1);
-	lines = xzalloc(len);
-
-	if ((fd = open(filename, O_RDONLY|O_CLOEXEC)) != -1) {
-		for (i = 0; i < num_lines; i++) {
-			count = 0;
-
-			/* determine the space needed for storing the line */
-			while (read(fd, &c, 1) == 1 && c != '\n')
-				count++;
-			lseek(fd, (lseek(fd, 0, SEEK_CUR) - count - 1), SEEK_SET);
-
-			lines[i] = xzalloc(sizeof(char) * (count+1));
-
-			/* copy the line into lines[i] */
-			assert(read(fd, lines[i], count) == count);
-			assert(read(fd, &c, 1) == 1);	/* skip '\n' */
-		}
-
-		close(fd);
-		return lines;
-	}
-
-	return NULL;
-}
-
-/*
- * void qcache_free_lines(char **lines);
- *
- * free()'s memory allocated by qcache_read_lines
- */
-_q_static
-void qcache_free_lines(char **lines)
-{
-	int i;
-
-	for (i = 0; lines[i]; i++)
-		free(lines[i]);
-
-	free(lines);
-}
-
 /*
  * portage_cache *qcache_read_cache_file(const char *file);
  *
@@ -884,25 +785,40 @@ void qcache_testing_only(qcache_data *data)
  *  -1 is returned on error.
  */
 _q_static
-int qcache_init(void)
+bool qcache_init(void)
 {
-	char *filename;
-	int len;
+	bool ret = false;
+	FILE *fp;
+	char *filename, *s;
+	size_t buflen, linelen;
+	char *buf;
 
 	xasprintf(&filename, "%s/profiles/arch.list", portdir);
+	fp = fopen(filename, "re");
+	if (!fp)
+		goto done;
 
-	if (NULL == (archlist = qcache_read_lines(filename))) {
-		free(filename);
-		return -1;
-	}
+	archlist_count = 0;
+	buf = NULL;
+	while ((linelen = getline(&buf, &buflen, fp)) != -1) {
+		rmspace_len(buf, linelen);
 
-	len = 0;
-	while (archlist[len])
-		++len;
-	archlist_count = len;
+		if ((s = strchr(buf, '#')) != NULL)
+			*s = '\0';
+		if (buf[0] == '\0')
+			continue;
+
+		++archlist_count;
+		archlist = xrealloc_array(archlist, sizeof(*archlist), archlist_count);
+		archlist[archlist_count - 1] = xstrdup(buf);
+	}
+	free(buf);
 
+	ret = true;
+	fclose(fp);
+ done:
 	free(filename);
-	return 0;
+	return ret;
 }
 
 /*
@@ -913,7 +829,11 @@ int qcache_init(void)
 _q_static
 void qcache_free(void)
 {
-	qcache_free_lines(archlist);
+	size_t a;
+
+	for (a = 0; a < archlist_count; ++a)
+		free(archlist[a]);
+	free(archlist);
 }
 
 /********************************************************************/
@@ -946,7 +866,7 @@ int qcache_main(int argc, char **argv)
 		}
 	}
 
-	if (-1 == qcache_init())
+	if (!qcache_init())
 		err("Could not initialize arch list");
 
 	if (optind < argc)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-28  2:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-28  2:44 UTC (permalink / raw
  To: gentoo-commits

commit:     c1a168f95699da8d2ac659cb6ea0c7fb3f4c0df9
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Nov 27 20:02:38 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Nov 27 20:02:38 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c1a168f9

qcache: use xasprintf instead of alloc+snprintf

 qcache.c | 17 +++++------------
 1 file changed, 5 insertions(+), 12 deletions(-)

diff --git a/qcache.c b/qcache.c
index 5d915bd..9e41c3c 100644
--- a/qcache.c
+++ b/qcache.c
@@ -537,9 +537,7 @@ int qcache_traverse(void (*func)(qcache_data*))
 
 		/* traverse packages */
 		for (j = 0; j < num_pkg; j++) {
-			len = sizeof(char) * (strlen(portdir) + strlen("/") + strlen(categories[i]->d_name) + strlen("/") + strlen(packages[j]->d_name) + 1);
-			ebuildpath = xzalloc(len);
-			snprintf(ebuildpath, len, "%s/%s/%s", portdir, categories[i]->d_name, packages[j]->d_name);
+			xasprintf(&ebuildpath, "%s/%s/%s", portdir, categories[i]->d_name, packages[j]->d_name);
 
 			if (-1 == (num_ebuild = scandir(ebuildpath, &ebuilds, qcache_ebuild_select, qcache_vercmp))) {
 				warnp("%s", ebuildpath);
@@ -561,10 +559,8 @@ int qcache_traverse(void (*func)(qcache_data*))
 
 			/* traverse ebuilds */
 			for (k = 0; k < num_ebuild; k++) {
-				len = sizeof(char) * (strlen(catpath) + strlen("/") + strlen(categories[i]->d_name) + strlen("/") + strlen(ebuilds[k]->d_name) + 1);
-				cachepath = xzalloc(len);
-				snprintf(cachepath, len, "%s/%s/%s", catpath, categories[i]->d_name, ebuilds[k]->d_name);
-				cachepath[len-8] = '\0'; /* remove ".ebuild" */
+				len = xasprintf(&cachepath, "%s/%s/%s", catpath, categories[i]->d_name, ebuilds[k]->d_name);
+				cachepath[len - 7] = '\0'; /* remove ".ebuild" */
 
 				data.category = categories[i]->d_name;
 				data.package = packages[j]->d_name;
@@ -886,12 +882,9 @@ _q_static
 int qcache_init(void)
 {
 	char *filename;
-	unsigned int len;
+	int len;
 
-	len      = sizeof(char) * (strlen(portdir) + strlen("/profiles/arch.list") + 1);
-	filename = xzalloc(len);
-
-	snprintf(filename, len, "%s/profiles/arch.list", portdir);
+	xasprintf(&filename, "%s/profiles/arch.list", portdir);
 
 	if (NULL == (archlist = qcache_read_lines(filename))) {
 		free(filename);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-26 10:52 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-26 10:52 UTC (permalink / raw
  To: gentoo-commits

commit:     dab9ae7d90f2b51f2d1abb4700b025c14ab77ef5
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 26 10:51:40 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Nov 26 10:51:40 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=dab9ae7d

qpkg: add multiple overlay support

This one is easy as it doesn't actually scan portdir and the cache
logic is simple & self contained.

URL: https://bugs.gentoo.org/553260

 qpkg.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/qpkg.c b/qpkg.c
index 50d79f6..2c9e774 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -122,7 +122,14 @@ int qpkg_clean(char *dirp)
 	}
 
 	if (eclean) {
-		if ((fp = fopen(initialize_ebuild_flat(), "r")) != NULL) {
+		size_t n;
+		const char *overlay;
+
+		array_for_each(overlays, n, overlay) {
+			fp = fopen(initialize_flat(overlay, CACHE_EBUILD, false), "re");
+			if (fp == NULL)
+				continue;
+
 			size_t buflen;
 			char *buf;
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-26 10:52 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-26 10:52 UTC (permalink / raw
  To: gentoo-commits

commit:     0c159907e39135f1b213e38e3a3a8d87fcaef8f6
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 26 10:52:15 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Nov 26 10:52:15 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0c159907

TODO: qpkg: add some thoughts

 TODO | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/TODO b/TODO
index 86445a4..ed72034 100644
--- a/TODO
+++ b/TODO
@@ -48,3 +48,9 @@
 	ACCEPT_LICENSE="${ACCEPT_LICENSE} bar"
   we end up getting just:
 	ACCEPT_LICENSE=" bar"
+
+- qpkg:
+	- fix "would be freed" message when --pretend is *not* active
+	- add a verbose output that describes why a package is cleaned
+		- newer binpkgs available
+		- newer installed version available


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-26 10:39 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-26 10:39 UTC (permalink / raw
  To: gentoo-commits

commit:     cb952155e5a9b5d3af533a9d46c561fee47c22f9
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 26 10:36:49 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Nov 26 10:36:49 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=cb952155

cache: support multiple overlays

This isn't terribly useful as-is since all callers still assume only
a single cache exists (portdir).  But we can cut utils over now.

URL: https://bugs.gentoo.org/553260

 main.c    | 36 +++++++++++++++++++++---------------
 qsearch.c |  2 +-
 2 files changed, 22 insertions(+), 16 deletions(-)

diff --git a/main.c b/main.c
index 8c7403b..10af2db 100644
--- a/main.c
+++ b/main.c
@@ -934,7 +934,7 @@ int filter_hidden(const struct dirent *dentry)
 }
 
 static const char *
-initialize_flat(int cache_type, bool force)
+initialize_flat(const char *overlay, int cache_type, bool force)
 {
 	struct dirent **category, **pn, **eb;
 	struct stat st;
@@ -945,7 +945,7 @@ initialize_flat(int cache_type, bool force)
 	int frac, secs, count;
 	FILE *fp;
 
-	xasprintf(&cache_file, "%s/dep/%s/%s", portedb, portdir,
+	xasprintf(&cache_file, "%s/dep/%s/%s", portedb, overlay,
 		(cache_type == CACHE_EBUILD ? ".ebuild.x" : ".metadata.x"));
 
 	/* If we aren't forcing a regen, make sure the file is somewhat sane. */
@@ -960,22 +960,22 @@ initialize_flat(int cache_type, bool force)
 
 	count = frac = secs = 0;
 
-	int portdir_fd, subdir_fd;
-	portdir_fd = open(portdir, O_RDONLY|O_CLOEXEC|O_PATH);
+	int overlay_fd, subdir_fd;
+	overlay_fd = open(overlay, O_RDONLY|O_CLOEXEC|O_PATH);
 
 	if (cache_type == CACHE_METADATA) {
-		subdir_fd = openat(portdir_fd, portcachedir_md5, O_RDONLY|O_CLOEXEC);
+		subdir_fd = openat(overlay_fd, portcachedir_md5, O_RDONLY|O_CLOEXEC);
 		if (subdir_fd == -1) {
-			subdir_fd = openat(portdir_fd, portcachedir_pms, O_RDONLY|O_CLOEXEC);
+			subdir_fd = openat(overlay_fd, portcachedir_pms, O_RDONLY|O_CLOEXEC);
 			if (subdir_fd == -1) {
-				warnp("could not read md5 or pms cache dirs in %s", portdir);
+				warnp("could not read md5 or pms cache dirs in %s", overlay);
 				goto ret;
 			}
 			portcachedir_type = CACHE_METADATA_PMS;
 		} else
 			portcachedir_type = CACHE_METADATA_MD5;
 	} else
-		subdir_fd = portdir_fd;
+		subdir_fd = overlay_fd;
 
 	if ((fp = fopen(cache_file, "we")) == NULL) {
 		warnfp("opening cache failed: %s", cache_file);
@@ -1056,22 +1056,28 @@ initialize_flat(int cache_type, bool force)
 
 	warn("Finished %u entries in %d.%06d seconds", count, secs, frac);
 	if (secs > 120)
-		warn("You should consider using the noatime mount option for PORTDIR='%s' if it's not already enabled", portdir);
+		warn("You should consider using the noatime mount option for '%s' if it's not already enabled", overlay);
 ret:
 	close(subdir_fd);
-	if (subdir_fd != portdir_fd)
-		close(portdir_fd);
+	if (subdir_fd != overlay_fd)
+		close(overlay_fd);
 	return cache_file;
 }
-#define initialize_ebuild_flat() initialize_flat(CACHE_EBUILD, false)
-#define initialize_metadata_flat() initialize_flat(CACHE_METADATA, false)
+#define initialize_ebuild_flat() initialize_flat(portdir, CACHE_EBUILD, false)
+#define initialize_metadata_flat() initialize_flat(portdir, CACHE_METADATA, false)
 
 void reinitialize_as_needed(void)
 {
+	size_t n;
+	const char *overlay;
+
 	if (reinitialize)
-		initialize_flat(CACHE_EBUILD, true);
+		array_for_each(overlays, n, overlay)
+			initialize_flat(overlay, CACHE_EBUILD, true);
+
 	if (reinitialize_metacache)
-		initialize_flat(CACHE_METADATA, true);
+		array_for_each(overlays, n, overlay)
+			initialize_flat(overlay, CACHE_METADATA, true);
 }
 
 typedef struct {

diff --git a/qsearch.c b/qsearch.c
index baaed37..427580d 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -69,7 +69,7 @@ int qsearch_main(int argc, char **argv)
 		search_me = argv[optind];
 	}
 	last[0] = 0;
-	fp = fopen(initialize_flat(search_cache, false), "r");
+	fp = fopen(initialize_flat(portdir, search_cache, false), "r");
 	if (!fp)
 		return 1;
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-26 10:39 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-26 10:39 UTC (permalink / raw
  To: gentoo-commits

commit:     7c3b484d601e6c06cfc692bbf011fca338697725
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 26 09:43:52 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Nov 26 09:43:52 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7c3b484d

quse: move file warnings behind verbose

Usually missing desc files are not errors but normal behavior:
people have trimmed the files or are using repos w/out them.
Move the warnings related to them behind --verbose so we don't
clutter up normal output.

 quse.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/quse.c b/quse.c
index 049b6e9..c7c1863 100644
--- a/quse.c
+++ b/quse.c
@@ -97,8 +97,9 @@ quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 
 	for (i = 0; i < NUM_SEARCH_FILES; ++i) {
 		snprintf(buf, buflen, "%s/profiles/%s", portdir, search_files[i]);
-		if ((fp[i] = fopen(buf, "r")) == NULL)
-			warnp("skipping %s", search_files[i]);
+		fp[i] = fopen(buf, "r");
+		if (verbose && fp[i] == NULL)
+			warnp("skipping %s", buf);
 	}
 
 	for (i = ind; i < argc; i++) {
@@ -157,7 +158,8 @@ quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 	/* now scan the desc dir */
 	snprintf(buf, buflen, "%s/profiles/desc/", portdir);
 	if ((d = opendir(buf)) == NULL) {
-		warnp("skipping profiles/desc/");
+		if (verbose)
+			warnp("skipping %s", buf);
 		goto done;
 	}
 
@@ -171,7 +173,8 @@ quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 
 		snprintf(buf, buflen, "%s/profiles/desc/%s", portdir, de->d_name);
 		if ((fp[0] = fopen(buf, "r")) == NULL) {
-			warn("Could not open '%s' for reading; skipping", de->d_name);
+			if (verbose)
+				warnp("skipping %s", buf);
 			continue;
 		}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-26 10:39 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-26 10:39 UTC (permalink / raw
  To: gentoo-commits

commit:     6c23cea972914761a0b1d4c79326da9f0352e758
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 26 09:39:13 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Nov 26 09:39:13 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6c23cea9

main: load all overlays from repos.conf

No code currently uses this, but we'll start to cut over utils.

URL: https://bugs.gentoo.org/553260

 main.c | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/main.c b/main.c
index c4b9bcc..8c7403b 100644
--- a/main.c
+++ b/main.c
@@ -72,6 +72,8 @@ void init_coredumps(void)
 /* include common library code */
 #include "libq/libq.c"
 
+static DECLARE_ARRAY(overlays);
+
 _q_static
 void no_colors(void)
 {
@@ -424,19 +426,30 @@ contents_entry *contents_parse_line(char *line)
 /* Handle a single file in the repos.conf format. */
 static void read_one_repos_conf(const char *repos_conf)
 {
+	int nsec;
 	char *conf;
-	const char *repo, *path;
+	const char *main_repo, *repo, *path;
 	dictionary *dict;
 
 	dict = iniparser_load(repos_conf);
 
-	repo = iniparser_getstring(dict, "DEFAULT:main-repo", NULL);
-	if (repo) {
+	main_repo = iniparser_getstring(dict, "DEFAULT:main-repo", NULL);
+
+	nsec = iniparser_getnsec(dict);
+	while (nsec-- > 0) {
+		repo = iniparser_getsecname(dict, nsec);
+		if (!strcmp(repo, "DEFAULT"))
+			continue;
+
 		xasprintf(&conf, "%s:location", repo);
 		path = iniparser_getstring(dict, conf, NULL);
 		if (path) {
-			free(portdir);
-			portdir = xstrdup(path);
+			if (main_repo && !strcmp(repo, main_repo)) {
+				free(portdir);
+				portdir = xstrdup(path);
+			}
+
+			xarraypush_str(overlays, path);
 		}
 		free(conf);
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-26 10:39 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-26 10:39 UTC (permalink / raw
  To: gentoo-commits

commit:     089d4340bdc41d35eab5ba961e8d9d2266e14cbd
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 26 09:19:36 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Nov 26 09:19:36 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=089d4340

quse: use freeargv helper

 quse.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/quse.c b/quse.c
index dddbf5b..049b6e9 100644
--- a/quse.c
+++ b/quse.c
@@ -400,15 +400,11 @@ int quse_main(int argc, char **argv)
 					print_highlighted_use_flags(&buf0[search_len + 1], optind, argc, argv);
 					puts(NORM);
 					if (verbose > 1) {
-						char **ARGV = NULL;
-						int ARGC = 0;
+						char **ARGV;
+						int ARGC;
 						makeargv(&buf0[search_len + 1], &ARGC, &ARGV);
-						if (ARGC > 0) {
-							quse_describe_flag(1, ARGC, ARGV);
-							for (i = 0; i < ARGC; i++)
-								free(ARGV[i]);
-							free(ARGV);
-						}
+						quse_describe_flag(1, ARGC, ARGV);
+						freeargv(ARGC, ARGV);
 					}
 				}
 				break;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-26 10:39 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-26 10:39 UTC (permalink / raw
  To: gentoo-commits

commit:     e5bc6a0ac189c60e2329a6b8eb00ffbddb8d015d
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 26 10:30:18 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Nov 26 10:30:18 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e5bc6a0a

qsearch: drop dead testing code

 qsearch.c | 18 ------------------
 1 file changed, 18 deletions(-)

diff --git a/qsearch.c b/qsearch.c
index 05a54e6..baaed37 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -68,24 +68,6 @@ int qsearch_main(int argc, char **argv)
 			qsearch_usage(EXIT_FAILURE);
 		search_me = argv[optind];
 	}
-#ifdef TESTING
-	/* FIXME: hardcoded */
-	if ((search_cache == CACHE_EBUILD) && (access("/usr/portage/.qsearch.x", R_OK) == 0)) {
-		if ((fp = fopen("/usr/portage/.qsearch.x", "r")) != NULL) {
-			search_len = strlen(search_me);
-			while (fgets(buf, sizeof(buf), fp) != NULL) {
-				if (strlen(buf) <= search_len)
-					continue;
-				/* add regexp, color highlighting and basename checks */
-				if (strncmp(buf, search_me, search_len) == 0) {
-					fputs(buf, stdout);
-				}
-			}
-			fclose(fp);
-			return 0;
-		}
-	}
-#endif
 	last[0] = 0;
 	fp = fopen(initialize_flat(search_cache, false), "r");
 	if (!fp)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-26 10:39 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-26 10:39 UTC (permalink / raw
  To: gentoo-commits

commit:     58513b6cba580354031623c11049ab8e0a8e6970
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 26 09:48:28 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Nov 26 09:48:28 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=58513b6c

quse: fix invalid close

This happens to work normally as we only have fds {0,1,2} open
and {3} is the active file we're working on.  Since the f loop
contains 3 (for an unrelated reason), we close the right fd.
But if there are more/fewer fd's open at start, it might fail,
and we leak the FILE* structure.  Switch to closing the right
file pointer to avoid all this mess.

 quse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/quse.c b/quse.c
index c7c1863..5ef88da 100644
--- a/quse.c
+++ b/quse.c
@@ -205,7 +205,7 @@ quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 				if (!strcmp(argv[i], buf))
 					printf(" %s%s%s:%s%s%s: %s\n", BOLD, de->d_name, NORM, BLUE, argv[i], NORM, p);
 		}
-		close(f);
+		fclose(fp[0]);
 	}
 	closedir(d);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-26 10:39 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-26 10:39 UTC (permalink / raw
  To: gentoo-commits

commit:     9ff62a4efd3cc34e852c55b3c52441a2a481d7cf
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 26 10:23:21 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Nov 26 10:23:21 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9ff62a4e

qglsa: rewrite main body to support overlays

Mostly mechanical changes to split the large body of code out of
main and into a standalone function.  Don't spend time splitting
this up into smaller commits as qglsa has been disabled for quite
some time.

URL: https://bugs.gentoo.org/553260

 qglsa.c | 115 +++++++++++++++++++++++++++++++++++++---------------------------
 1 file changed, 66 insertions(+), 49 deletions(-)

diff --git a/qglsa.c b/qglsa.c
index 7fba5c7..7bc350f 100644
--- a/qglsa.c
+++ b/qglsa.c
@@ -29,6 +29,10 @@ static const char * const qglsa_opts_help[] = {
 };
 #define qglsa_usage(ret) usage(ret, QGLSA_FLAGS, qglsa_long_opts, qglsa_opts_help, lookup_applet_idx("qglsa"))
 
+typedef enum {
+	GLSA_FUNKYTOWN, GLSA_LIST, GLSA_DUMP, GLSA_TEST, GLSA_FIX, GLSA_INJECT
+} qglsa_action;
+
 static char *qglsa_load_list(void);
 static char *qglsa_load_list(void)
 {
@@ -146,69 +150,35 @@ static void qglsa_act_list(char *glsa)
 
 }
 */
-int qglsa_main(int argc, char **argv)
+
+static int
+qglsa_run_action(const char *overlay, qglsa_action action, const char *fixed_list,
+                 bool all_glsas, unsigned int ind, int argc, char **argv)
 {
-	enum { GLSA_FUNKYTOWN, GLSA_LIST, GLSA_DUMP, GLSA_TEST, GLSA_FIX, GLSA_INJECT };
 	int i;
 	DIR *dir;
 	struct dirent *dentry;
 	char *buf;
 	size_t buflen = 0;
-	char *s, *p, *glsa_fixed_list;
-	int action = GLSA_FUNKYTOWN;
-	int all_glsas = 0;
+	char *s, *p;
+	int overlay_fd, glsa_fd;
 
-	DBG("argc=%d argv[0]=%s argv[1]=%s",
-	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
-
-	while ((i = GETOPT_LONG(QGLSA, qglsa, "")) != -1) {
-#define set_action(a) { if (action == 0) action = a; else err("cannot specify more than one action at a time"); }
-		switch (i) {
-		case 'l': set_action(GLSA_LIST); break;
-		case 'd': set_action(GLSA_DUMP); break;
-		case 't': set_action(GLSA_TEST); break;
-		case 'p': pretend = 1; break;
-		case 'f': set_action(GLSA_FIX); break;
-		case 'i': set_action(GLSA_INJECT); break;
-		COMMON_GETOPTS_CASES(qglsa)
-		}
-	}
-	if (action == GLSA_FUNKYTOWN)
-		qglsa_usage(EXIT_FAILURE);
-	if (action != GLSA_LIST && optind == argc)
-		err("specified action requires a list, either 'all', 'new', or GLSA numbers");
-
-	glsa_fixed_list = NULL;
-	for (i = optind; i < argc; ++i) {
-		if (!strcmp(argv[i], "all")) {
-			all_glsas = 1;
-			if (optind+1 != argc)
-				err("You may only use class names by themselves");
-		} else if (!strcmp(argv[i], "new")) {
-			all_glsas = 0;
-			if (optind+1 != argc)
-				err("You may only use class names by themselves");
-		}
-	}
-	glsa_fixed_list = qglsa_load_list();
-
-	int portdir_fd, glsa_fd;
-	portdir_fd = open(portdir, O_RDONLY|O_CLOEXEC|O_PATH);
-	glsa_fd = openat(portdir_fd, "metadata/glsa", O_RDONLY|O_CLOEXEC);
+	overlay_fd = open(overlay, O_RDONLY|O_CLOEXEC|O_PATH);
+	glsa_fd = openat(overlay_fd, "metadata/glsa", O_RDONLY|O_CLOEXEC);
 
 	switch (action) {
 	/*case GLSA_FIX:*/
 	case GLSA_INJECT:
 		buf = NULL;
-		for (i = optind; i < argc; ++i) {
+		for (i = ind; i < argc; ++i) {
 			free(buf);
 			xasprintf(&buf, "glsa-%s.xml", argv[i]);
 			if (faccessat(glsa_fd, buf, R_OK, 0)) {
 				warnp("Skipping invalid GLSA '%s'", argv[i]);
 				continue;
 			}
-			if (glsa_fixed_list) {
-				if (strstr(glsa_fixed_list, argv[i])) {
+			if (fixed_list) {
+				if (strstr(fixed_list, argv[i])) {
 					warn("Skipping already installed GLSA %s", argv[i]);
 					continue;
 				}
@@ -243,8 +213,8 @@ int qglsa_main(int argc, char **argv)
 			glsa_id[len - 5] = '\0';
 
 			/* see if we want to skip glsa's already fixed */
-			if (!all_glsas && glsa_fixed_list) {
-				if (strstr(glsa_fixed_list, glsa_id))
+			if (!all_glsas && fixed_list) {
+				if (strstr(fixed_list, glsa_id))
 					continue;
 			}
 
@@ -302,13 +272,60 @@ int qglsa_main(int argc, char **argv)
 		closedir(dir);
 	}
 
-	free(glsa_fixed_list);
 	close(glsa_fd);
-	close(portdir_fd);
+	close(overlay_fd);
 
 	return EXIT_SUCCESS;
 }
 
+int qglsa_main(int argc, char **argv)
+{
+	int i;
+	char *fixed_list;
+	qglsa_action action = GLSA_FUNKYTOWN;
+	bool all_glsas = false;
+
+	DBG("argc=%d argv[0]=%s argv[1]=%s",
+	    argc, argv[0], argc > 1 ? argv[1] : "NULL?");
+
+	while ((i = GETOPT_LONG(QGLSA, qglsa, "")) != -1) {
+#define set_action(a) { if (action == 0) action = a; else err("cannot specify more than one action at a time"); }
+		switch (i) {
+		case 'l': set_action(GLSA_LIST); break;
+		case 'd': set_action(GLSA_DUMP); break;
+		case 't': set_action(GLSA_TEST); break;
+		case 'p': pretend = 1; break;
+		case 'f': set_action(GLSA_FIX); break;
+		case 'i': set_action(GLSA_INJECT); break;
+		COMMON_GETOPTS_CASES(qglsa)
+		}
+	}
+	if (action == GLSA_FUNKYTOWN)
+		qglsa_usage(EXIT_FAILURE);
+	if (action != GLSA_LIST && optind == argc)
+		err("specified action requires a list, either 'all', 'new', or GLSA numbers");
+
+	for (i = optind; i < argc; ++i) {
+		if (!strcmp(argv[i], "all")) {
+			all_glsas = true;
+			if (optind+1 != argc)
+				err("You may only use class names by themselves");
+		} else if (!strcmp(argv[i], "new")) {
+			all_glsas = false;
+			if (optind+1 != argc)
+				err("You may only use class names by themselves");
+		}
+	}
+	fixed_list = qglsa_load_list();
+
+	int ret = 0;
+	size_t n;
+	const char *overlay;
+	array_for_each(overlays, n, overlay)
+		ret |= qglsa_run_action(overlay, action, fixed_list, all_glsas, optind, argc, argv);
+	return ret;
+}
+
 #else
 DEFINE_APPLET_STUB(qglsa)
 #endif


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-26  8:59 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-26  8:59 UTC (permalink / raw
  To: gentoo-commits

commit:     9a800fe6ba0176691c81f42ef50dcf37976e74ca
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 26 08:49:06 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Nov 26 08:49:06 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9a800fe6

q: disable colors for pipes

There's no way to detect whether the output is going to a pager (and
we want color) or to another program (and we don't want color), so
turn off color for all pipes.  This matches standard *nix behavior.

URL: https://bugs.gentoo.org/550556
Reported-by: Toralf Förster <toralf.foerster <AT> gmx.de>

 main.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/main.c b/main.c
index 609ed54..c4b9bcc 100644
--- a/main.c
+++ b/main.c
@@ -1376,12 +1376,9 @@ int main(int argc, char **argv)
 	bindtextdomain(argv0, CONFIG_EPREFIX "usr/share/locale");
 	textdomain(argv0);
 
-#if 1
 	if (fstat(fileno(stdout), &st) != -1)
 		if (!isatty(fileno(stdout)))
-			if (S_ISFIFO(st.st_mode) == 0)
-				no_colors();
-#endif
+			no_colors();
 	if ((getenv("TERM") == NULL) || (strcmp(getenv("TERM"), "dumb") == 0))
 		no_colors();
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-11-26  8:00 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-11-26  8:00 UTC (permalink / raw
  To: gentoo-commits

commit:     a30baf6e2163eb4ed4dd6c9b5beee2473c775377
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Nov 26 07:58:21 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Nov 26 07:58:21 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=a30baf6e

qdepends: rework dep tree flattening

By leveraging stpcpy, we don't need to call strlen at all, or update the
length of the buffer we've written to.  Instead, make the func recursive
and pass around the start of the buffer that is ready to accept more data.

While we're here, increase the static buffer to 1MiB.  Some packages (e.g.
qemu) are larger than the 8KiB we have which causes corruption/crashes.
There's no way we'd exceed 1MiB! </last-words>

 qdepends.c | 27 +++++++++++++--------------
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index bcdeaa5..5ded84b 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -70,7 +70,6 @@ _q_static void _dep_print_tree(FILE *fp, const dep_node *root, size_t space);
 void dep_burn_tree(dep_node *root);
 char *dep_flatten_tree(const dep_node *root);
 _q_static void _dep_attach(dep_node *root, dep_node *attach_me, int type);
-_q_static void _dep_flatten_tree(const dep_node *root, char *buf, size_t *pos);
 _q_static void _dep_burn_node(dep_node *node);
 int qdepends_main_vdb(const char *depend_file, int argc, char **argv);
 int qdepends_vdb_deep(const char *depend_file, const char *query);
@@ -352,33 +351,33 @@ _q_static void dep_prune_use(dep_node *root, const char *use)
 	if (root->children) dep_prune_use(root->children, use);
 }
 
-void _dep_flatten_tree(const dep_node *root, char *buf, size_t *pos)
+_q_static char *
+_dep_flatten_tree(const dep_node *root, char *buf)
 {
 	if (root->type == DEP_NULL) goto this_node_sucks;
 	if (root->type == DEP_NORM) {
-		size_t len = strlen(root->info);
-		memcpy(buf + *pos, root->info, len);
-		*pos += len+1;
-		buf[*pos-1] = ' ';
+		buf[0] = ' ';
+		buf = stpcpy(buf + 1, root->info);
 	}
-	if (root->children) _dep_flatten_tree(root->children, buf, pos);
+	if (root->children)
+		buf = _dep_flatten_tree(root->children, buf);
 this_node_sucks:
-	if (root->neighbor) _dep_flatten_tree(root->neighbor, buf, pos);
+	if (root->neighbor)
+		buf = _dep_flatten_tree(root->neighbor, buf);
+	return buf;
 }
 
 char *dep_flatten_tree(const dep_node *root)
 {
-	static char flat[8192];
-	size_t pos = 0;
-	_dep_flatten_tree(root, flat, &pos);
-	if (pos == 0) {
+	static char flat[1024 * 1024];
+	char *buf = _dep_flatten_tree(root, flat);
+	if (buf == flat) {
 		/* all the nodes were squashed ... for example:
 		 * USE=-selinux RDEPEND="selinux? ( sys-libs/libselinux )"
 		 */
 		return NULL;
 	}
-	flat[pos-1] = '\0';
-	return flat;
+	return flat + 1;
 }
 
 struct qdepends_opt_state {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-09-15 18:27 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-09-15 18:27 UTC (permalink / raw
  To: gentoo-commits

commit:     e275dfedc41cecf51d96484eb34505d12dca5678
Author:     Jeroen Roovers <jer <AT> gentoo <DOT> org>
AuthorDate: Tue Sep 15 18:27:02 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Sep 15 18:27:02 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e275dfed

qatom: always display SLOT in verbose mode

URL: https://bugs.gentoo.org/560320

 qatom.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/qatom.c b/qatom.c
index 25eee8e..f2c7ae4 100644
--- a/qatom.c
+++ b/qatom.c
@@ -56,8 +56,8 @@ int qatom_main(int argc, char **argv)
 			printf("%s %s %s", atom->CATEGORY, atom->PN, atom->PV);
 			if (verbose || atom->PR_int)
 				printf(" r%i", atom->PR_int);
-			if (atom->SLOT)
-				printf(" :%s", atom->SLOT);
+			if (verbose || atom->SLOT)
+				printf(" :%s", atom->SLOT ? atom->SLOT : "-");
 			if (verbose || atom->pfx_op != ATOM_OP_NONE)
 				printf(" %s", atom->pfx_op == ATOM_OP_NONE ? "-" : atom_op_str[atom->pfx_op]);
 			if (verbose || atom->sfx_op != ATOM_OP_NONE)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-06-23  8:58 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-06-23  8:58 UTC (permalink / raw
  To: gentoo-commits

commit:     bb47adc4544369167b931113600d292d2b77c97a
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Jun 23 08:57:17 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Jun 23 08:57:17 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bb47adc4

repos.conf: fix behavior on systems w/out d_type

URL: https://bugs.gentoo.org/551696
Reported-by: Fabian Groffen <grobian <AT> gentoo.org>

 main.c | 19 ++++++++++++++++++-
 1 file changed, 18 insertions(+), 1 deletion(-)

diff --git a/main.c b/main.c
index 66b3b30..609ed54 100644
--- a/main.c
+++ b/main.c
@@ -460,10 +460,27 @@ static void read_repos_conf(const char *configroot, const char *repos_conf)
 		for (i = 0; i < count; ++i) {
 			const char *name = confs[i]->d_name;
 
-			if (name[0] == '.' || confs[i]->d_type != DT_REG)
+			if (name[0] == '.')
 				continue;
 
+#ifdef DT_UNKNOWN
+			if (confs[i]->d_type != DT_UNKNOWN &&
+			    confs[i]->d_type != DT_REG &&
+			    confs[i]->d_type != DT_LNK)
+				continue;
+#endif
+
 			xasprintf(&sub_conf, "%s/%s", top_conf, name);
+
+#ifdef DT_UNKNOWN
+			if (confs[i]->d_type != DT_REG)
+#endif
+			{
+				struct stat st;
+				if (stat(sub_conf, &st) || S_ISREG(st.st_mode))
+					continue;
+			}
+
 			read_one_repos_conf(sub_conf);
 			free(sub_conf);
 		}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-06-06  6:20 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-06-06  6:20 UTC (permalink / raw
  To: gentoo-commits

commit:     7772431040d65329435a08ac31e7d4e4beec056a
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Jun  6 06:11:46 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Jun  6 06:11:46 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=77724310

autotools: also add -liniparser

 Makefile.am | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Makefile.am b/Makefile.am
index 5ffa339..225c979 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,6 +9,7 @@ q_CPPFLAGS = \
 	-I$(top_srcdir)/autotools/gnulib
 q_LDADD = \
 	$(top_builddir)/autotools/gnulib/libgnu.a \
+	-liniparser \
 	$(LIB_CLOCK_GETTIME) \
 	$(LIB_EACCESS)
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-06-06  6:20 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-06-06  6:20 UTC (permalink / raw
  To: gentoo-commits

commit:     248e2d0ba29dad806840b151ae80d4c0fe728724
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Jun  6 05:33:49 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Jun  6 05:33:49 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=248e2d0b

qsearch: update cache handling

The cache rewrite dropped the implicit chdir (by design), but the qsearch
code was still relying on that.  Update qsearch to use *at style functions
and also convert the fgets usage to getline.

URL: https://bugs.gentoo.org/551206
Reported-by: Guilherme Amadio <amadio <AT> gentoo.org>

 qsearch.c | 61 +++++++++++++++++++++++++++++++++++++++----------------------
 1 file changed, 39 insertions(+), 22 deletions(-)

diff --git a/qsearch.c b/qsearch.c
index ce36df2..05a54e6 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -34,15 +34,14 @@ static const char * const qsearch_opts_help[] = {
 int qsearch_main(int argc, char **argv)
 {
 	FILE *fp;
-	char buf[_Q_PATH_MAX];
-	char ebuild[_Q_PATH_MAX];
+	char *ebuild = NULL;
 	char last[126] = "";
 	char *p, *q, *str;
 	char *search_me = NULL;
 	char show_homepage = 0, show_name_only = 0;
 	char search_desc = 0, search_all = 0, search_name = 1, search_cache = CACHE_EBUILD;
 	const char *search_vars[] = { "DESCRIPTION=", "HOMEPAGE=" };
-	size_t search_len;
+	size_t search_len, ebuild_len;
 	int i, idx=0;
 
 	DBG("argc=%d argv[0]=%s argv[1]=%s",
@@ -92,9 +91,14 @@ int qsearch_main(int argc, char **argv)
 	if (!fp)
 		return 1;
 
+	int portdir_fd = open(portdir, O_RDONLY|O_CLOEXEC|O_PATH);
+	if (portdir_fd < 0)
+		errp("open(%s) failed", portdir);
+
+	q = NULL; /* Silence a gcc warning. */
 	search_len = strlen(search_vars[idx]);
 
-	while (fgets(ebuild, sizeof(ebuild), fp) != NULL) {
+	while (getline(&ebuild, &ebuild_len, fp) != -1) {
 		if ((p = strchr(ebuild, '\n')) != NULL)
 			*p = 0;
 		if (!ebuild[0])
@@ -139,35 +143,46 @@ int qsearch_main(int argc, char **argv)
 					}
 				}
 
-				if ((ebuildfp = fopen(ebuild, "r")) != NULL) {
-					while (fgets(buf, sizeof(buf), ebuildfp) != NULL) {
-						if (strlen(buf) <= search_len)
-							continue;
-						if (strncmp(buf, search_vars[idx], search_len) == 0) {
-							if ((q = strrchr(buf, '"')) != NULL)
-								*q = 0;
-							if (strlen(buf) <= search_len)
-								break;
-							q = buf + search_len + 1;
-							if (!search_all && !search_name && rematch(search_me, q, REG_EXTENDED | REG_ICASE) != 0)
-								break;
-							show_it = true;
-							break;
-						}
+				int fd = openat(portdir_fd, ebuild, O_RDONLY|O_CLOEXEC);
+				if (fd != -1) {
+					ebuildfp = fdopen(fd, "r");
+					if (ebuildfp == NULL) {
+						close(fd);
+						continue;
 					}
-					fclose(ebuildfp);
 				} else {
 					if (!reinitialize)
 						warnfp("(cache update pending) %s", ebuild);
 					reinitialize = 1;
+					goto no_cache_ebuild_match;
+				}
+
+				char *buf = NULL;
+				size_t buflen;
+				while (getline(&buf, &buflen, ebuildfp) != -1) {
+					if (strlen(buf) <= search_len)
+						continue;
+					if (strncmp(buf, search_vars[idx], search_len) != 0)
+						continue;
+					if ((q = strrchr(buf, '"')) != NULL)
+						*q = 0;
+					if (strlen(buf) <= search_len)
+						break;
+					q = buf + search_len + 1;
+					if (!search_all && !search_name && rematch(search_me, q, REG_EXTENDED | REG_ICASE) != 0)
+						break;
+					show_it = true;
+					break;
 				}
 
 				if (show_it) {
-					const char *b = basename(p);
 					printf("%s%s/%s%s%s %s\n",
-						BOLD, dirname(p), BLUE, b, NORM,
+						BOLD, dirname(p), BLUE, basename(p), NORM,
 						(show_name_only ? "" : q ? : "<no DESCRIPTION found>"));
 				}
+
+				free(buf);
+				fclose(ebuildfp);
 			}
 no_cache_ebuild_match:
 			free(str);
@@ -176,6 +191,8 @@ no_cache_ebuild_match:
 		} /* case CACHE_EBUILD */
 		} /* switch (search_cache) */
 	}
+	free(ebuild);
+	close(portdir_fd);
 	fclose(fp);
 	return EXIT_SUCCESS;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-06-06  6:20 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-06-06  6:20 UTC (permalink / raw
  To: gentoo-commits

commit:     b9a5aef5d7c6b7ed55c1441a7f74221bda694a23
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Jun  6 05:31:44 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Jun  6 05:31:44 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b9a5aef5

cache: do not reinit every time

The rework accidentally changed the behavior so we would rebuild the
cache everytime we tried to load it.

 main.c | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)

diff --git a/main.c b/main.c
index cb180df..df1e309 100644
--- a/main.c
+++ b/main.c
@@ -936,12 +936,11 @@ initialize_flat(int cache_type, bool force)
 	xasprintf(&cache_file, "%s/dep/%s/%s", portedb, portdir,
 		(cache_type == CACHE_EBUILD ? ".ebuild.x" : ".metadata.x"));
 
-	if (stat(cache_file, &st) != -1) {
-		if (st.st_size == 0)
-			unlink(cache_file);
-	} else if (!force) {
-		/* assuming --sync is used with --delete this will get recreated after every merge */
-		goto ret;
+	/* If we aren't forcing a regen, make sure the file is somewhat sane. */
+	if (!force) {
+		if (stat(cache_file, &st) != -1)
+			if (st.st_size)
+				goto ret;
 	}
 	if (!quiet)
 		warn("Updating ebuild %scache ... ", cache_type == CACHE_EBUILD ? "" : "meta");


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-06-06  6:20 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-06-06  6:20 UTC (permalink / raw
  To: gentoo-commits

commit:     5d20d5da741d6e6665b7c1e4fb6873d22f186222
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Jun  6 05:54:34 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Jun  6 05:54:34 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5d20d5da

cache: optimize the common case slightly

Do the cache sanity check immediately on the assumption that it will be
sane the majority of the time.  No point in opening the portdir and such
just to close it immediately.

 main.c | 24 +++++++++++++-----------
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/main.c b/main.c
index df1e309..66b3b30 100644
--- a/main.c
+++ b/main.c
@@ -915,6 +915,19 @@ initialize_flat(int cache_type, bool force)
 	int frac, secs, count;
 	FILE *fp;
 
+	xasprintf(&cache_file, "%s/dep/%s/%s", portedb, portdir,
+		(cache_type == CACHE_EBUILD ? ".ebuild.x" : ".metadata.x"));
+
+	/* If we aren't forcing a regen, make sure the file is somewhat sane. */
+	if (!force) {
+		if (stat(cache_file, &st) != -1)
+			if (st.st_size)
+				return cache_file;
+	}
+
+	if (!quiet)
+		warn("Updating ebuild %scache ... ", cache_type == CACHE_EBUILD ? "" : "meta");
+
 	count = frac = secs = 0;
 
 	int portdir_fd, subdir_fd;
@@ -933,17 +946,6 @@ initialize_flat(int cache_type, bool force)
 			portcachedir_type = CACHE_METADATA_MD5;
 	} else
 		subdir_fd = portdir_fd;
-	xasprintf(&cache_file, "%s/dep/%s/%s", portedb, portdir,
-		(cache_type == CACHE_EBUILD ? ".ebuild.x" : ".metadata.x"));
-
-	/* If we aren't forcing a regen, make sure the file is somewhat sane. */
-	if (!force) {
-		if (stat(cache_file, &st) != -1)
-			if (st.st_size)
-				goto ret;
-	}
-	if (!quiet)
-		warn("Updating ebuild %scache ... ", cache_type == CACHE_EBUILD ? "" : "meta");
 
 	if ((fp = fopen(cache_file, "we")) == NULL) {
 		warnfp("opening cache failed: %s", cache_file);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-06-03 15:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-06-03 15:44 UTC (permalink / raw
  To: gentoo-commits

commit:     facaa636947ceeffce0c7a5a5dd52fee8e9175ca
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  3 15:40:42 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed Jun  3 15:40:42 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=facaa636

support repos.conf files

Since the system is moving away from PORTDIR/etc... and to a more
flexible repos.conf setup, make sure we support that stuff.

This pulls in an external dependency which is new for us, but the
iniparser library is very small (<20k on x86_64), written in pure
C, and is used by big projects already (like samba).  Doing an NIH
thing here would be a waste of time.

URL: https://bugs.gentoo.org/540620
Reported-by: Elias Probst <mail <AT> eliasprobst.eu>

 Makefile  |  1 +
 main.c    | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 porting.h |  2 ++
 3 files changed, 63 insertions(+), 7 deletions(-)

diff --git a/Makefile b/Makefile
index 7304559..fe6092f 100644
--- a/Makefile
+++ b/Makefile
@@ -24,6 +24,7 @@ DBG_CFLAGS = -O0 -DEBUG -g3 -ggdb -fno-pie $(call check_gcc, -fsanitize=address
 #CFLAGS   += -Os -DOPTIMIZE_FOR_SIZE=2 -falign-functions=2 -falign-jumps=2 -falign-labels=2 -falign-loops=2
 #LDFLAGS  := -pie
 LIBADD    += $(shell echo | $(CC) -dM -E - | grep -q ' __FreeBSD__' && echo '-lkvm')
+LIBADD    += -liniparser
 DESTDIR   :=
 PREFIX    := $(DESTDIR)/usr
 STRIP     := strip

diff --git a/main.c b/main.c
index 29a889f..cb180df 100644
--- a/main.c
+++ b/main.c
@@ -421,6 +421,57 @@ contents_entry *contents_parse_line(char *line)
 	return &e;
 }
 
+/* Handle a single file in the repos.conf format. */
+static void read_one_repos_conf(const char *repos_conf)
+{
+	char *conf;
+	const char *repo, *path;
+	dictionary *dict;
+
+	dict = iniparser_load(repos_conf);
+
+	repo = iniparser_getstring(dict, "DEFAULT:main-repo", NULL);
+	if (repo) {
+		xasprintf(&conf, "%s:location", repo);
+		path = iniparser_getstring(dict, conf, NULL);
+		if (path) {
+			free(portdir);
+			portdir = xstrdup(path);
+		}
+		free(conf);
+	}
+
+	iniparser_freedict(dict);
+}
+
+/* Handle a possible directory of files. */
+static void read_repos_conf(const char *configroot, const char *repos_conf)
+{
+	char *top_conf, *sub_conf;
+	int i, count;
+	struct dirent **confs;
+
+	xasprintf(&top_conf, "%s%s", configroot, repos_conf);
+	count = scandir(top_conf, &confs, NULL, alphasort);
+	if (count == -1) {
+		if (errno == ENOTDIR)
+			read_one_repos_conf(top_conf);
+	} else {
+		for (i = 0; i < count; ++i) {
+			const char *name = confs[i]->d_name;
+
+			if (name[0] == '.' || confs[i]->d_type != DT_REG)
+				continue;
+
+			xasprintf(&sub_conf, "%s/%s", top_conf, name);
+			read_one_repos_conf(sub_conf);
+			free(sub_conf);
+		}
+		scandir_free(confs, count);
+	}
+	free(top_conf);
+}
+
 static void strincr_var(const char *name, const char *s, char **value, size_t *value_len)
 {
 	size_t len;
@@ -715,18 +766,18 @@ void initialize_portage_env(void)
 	}
 
 	/* figure out where to find our config files */
-	s = getenv("PORTAGE_CONFIGROOT");
-	if (!s)
-		s = "/";
+	const char *configroot = getenv("PORTAGE_CONFIGROOT");
+	if (!configroot)
+		configroot = "/";
 
 	/* walk all the stacked profiles */
-	read_portage_profile(s, CONFIG_EPREFIX "etc/make.profile", vars_to_read);
-	read_portage_profile(s, CONFIG_EPREFIX "etc/portage/make.profile", vars_to_read);
+	read_portage_profile(configroot, CONFIG_EPREFIX "etc/make.profile", vars_to_read);
+	read_portage_profile(configroot, CONFIG_EPREFIX "etc/portage/make.profile", vars_to_read);
 
 	/* now read all the config files */
 	read_portage_env_file("", CONFIG_EPREFIX "usr/share/portage/config/make.globals", vars_to_read);
-	read_portage_env_file(s, CONFIG_EPREFIX "etc/make.conf", vars_to_read);
-	read_portage_env_file(s, CONFIG_EPREFIX "etc/portage/make.conf", vars_to_read);
+	read_portage_env_file(configroot, CONFIG_EPREFIX "etc/make.conf", vars_to_read);
+	read_portage_env_file(configroot, CONFIG_EPREFIX "etc/portage/make.conf", vars_to_read);
 
 	/* finally, check the env */
 	for (i = 0; vars_to_read[i].name; ++i) {
@@ -826,6 +877,8 @@ void initialize_portage_env(void)
 		portroot[var->value_len + 1] = '\0';
 	}
 
+	read_repos_conf(configroot, CONFIG_EPREFIX "etc/portage/repos.conf");
+
 	if (getenv("PORTAGE_QUIET") != NULL)
 		quiet = 1;
 

diff --git a/porting.h b/porting.h
index 3235542..8045813 100644
--- a/porting.h
+++ b/porting.h
@@ -49,6 +49,8 @@
 #include <sys/time.h>
 #include <sys/types.h>
 
+#include <iniparser.h>
+
 #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof(*(arr)))
 
 #ifndef BUFSIZE


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-06-03 15:44 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-06-03 15:44 UTC (permalink / raw
  To: gentoo-commits

commit:     baa1bfde6b1210ee37a193d3cd258477e02457b5
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Wed Jun  3 15:33:36 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Wed Jun  3 15:33:36 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=baa1bfde

tweak s390/sh ARCH defaults

 main.h | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/main.h b/main.h
index 0b125ac..877c1ec 100644
--- a/main.h
+++ b/main.h
@@ -64,12 +64,8 @@
 #   define URL_ARCH "ppc"
 #  endif
 # elif defined(__s390__)
-#  if defined(__s390x__)
-#   define URL_ARCH "s390x"
-#  else
-#   define URL_ARCH "s390"
-#  endif
-# elif defined(__sh4__)
+#  define URL_ARCH "s390"
+# elif defined(__sh__)
 #  define URL_ARCH "sh"
 # elif defined(__sparc__)
 #  define URL_ARCH "sparc"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-05-31  8:31 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-05-31  8:31 UTC (permalink / raw
  To: gentoo-commits

commit:     ed40d1927d6bed3dc8f0cd5eb10e2bdc65397cfb
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun May 31 08:11:54 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun May 31 08:14:17 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ed40d192

qmerge: do not warn about missing symlinks when unmerging

We were going to delete them anyways, so if they weren't found, it's
not actually a problem we should warn about.

 qmerge.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index a3e2fd2..ddc0a10 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1107,8 +1107,11 @@ pkg_unmerge(q_vdb_pkg_ctx *pkg_ctx, queue *keep)
 
 			case CONTENTS_SYM:
 				if (fstatat(portroot_fd, e->name + 1, &st, AT_SYMLINK_NOFOLLOW)) {
-					warnp("stat failed for %s -> '%s'", e->name, e->sym_target);
-					continue;
+					if (errno != ENOENT) {
+						warnp("stat failed for %s -> '%s'", e->name, e->sym_target);
+						continue;
+					} else
+						break;
 				}
 
 				/* Hrm, if it isn't a symlink anymore, then leave it be */


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-05-19 17:37 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-05-19 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     eeb816f6dcf9a634303e3f1bd1e43d472a3fcff6
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue May 19 16:56:10 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue May 19 16:56:10 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=eeb816f6

qlop: support $EMERGE_LOG_DIR

Portage stores its emerge.log in the $EMERGE_LOG_DIR dir, so try loading
that setting instead of hardcoding /var/log ourselves.

URL: https://bugs.gentoo.org/513592
Reported-by: Kerin Millar <kerframil <AT> fastmail.co.uk>

 main.c |  2 ++
 qlop.c | 18 ++++++++----------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/main.c b/main.c
index d127621..29a889f 100644
--- a/main.c
+++ b/main.c
@@ -32,6 +32,7 @@ int portcachedir_type = 0;
 char pretend = 0;
 char reinitialize = 0;
 char reinitialize_metacache = 0;
+static char *portlogdir;
 static char *portdir;
 static char *portarch;
 static char *portvdb;
@@ -694,6 +695,7 @@ void initialize_portage_env(void)
 		_Q_EVB(BOOL, NOCOLOR,             nocolor,             0)
 		_Q_EVS(ISTR, FEATURES,            features,            "noman noinfo nodoc")
 		_Q_EVS(STR,  EPREFIX,             eprefix,             CONFIG_EPREFIX)
+		_Q_EVS(STR,  EMERGE_LOG_DIR,      portlogdir,          CONFIG_EPREFIX "var/log")
 		_Q_EVS(STR,  PORTDIR,             portdir,             CONFIG_EPREFIX "usr/portage")
 		_Q_EVS(STR,  PORTAGE_BINHOST,     binhost,             DEFAULT_PORTAGE_BINHOST)
 		_Q_EVS(STR,  PORTAGE_TMPDIR,      port_tmpdir,         CONFIG_EPREFIX "var/tmp/portage/")

diff --git a/qlop.c b/qlop.c
index 93dbcc8..390865a 100644
--- a/qlop.c
+++ b/qlop.c
@@ -26,7 +26,7 @@
 # include <sys/sysctl.h>
 #endif
 
-#define QLOP_DEFAULT_LOGFILE CONFIG_EPREFIX "var/log/emerge.log"
+#define QLOP_DEFAULT_LOGFILE "emerge.log"
 
 #define QLOP_FLAGS "gtHluscf:" COMMON_FLAGS
 static struct option const qlop_long_opts[] = {
@@ -48,7 +48,7 @@ static const char * const qlop_opts_help[] = {
 	"Show unmerge history",
 	"Show sync history",
 	"Show current emerging packages",
-	"Read emerge logfile instead of " QLOP_DEFAULT_LOGFILE,
+	"Read emerge logfile instead of $EMERGE_LOG_DIR/" QLOP_DEFAULT_LOGFILE,
 	COMMON_OPTS_HELP
 };
 #define qlop_usage(ret) usage(ret, QLOP_FLAGS, qlop_long_opts, qlop_opts_help, lookup_applet_idx("qlop"))
@@ -646,13 +646,11 @@ int qlop_main(int argc, char **argv)
 {
 	int i, average = 1;
 	char do_time, do_list, do_unlist, do_sync, do_current, do_human_readable = 0;
-	char *opt_logfile;
-	const char *logfile = QLOP_DEFAULT_LOGFILE;
+	char *logfile = NULL;
 
 	DBG("argc=%d argv[0]=%s argv[1]=%s",
 		argc, argv[0], argc > 1 ? argv[1] : "NULL?");
 
-	opt_logfile = NULL;
 	do_time = do_list = do_unlist = do_sync = do_current = 0;
 
 	while ((i = GETOPT_LONG(QLOP, qlop, "")) != -1) {
@@ -667,15 +665,15 @@ int qlop_main(int argc, char **argv)
 			case 'g': do_time = 1; average = 0; break;
 			case 'H': do_human_readable = 1; break;
 			case 'f':
-				if (opt_logfile) err("Only use -f once");
-				opt_logfile = xstrdup(optarg);
+				if (logfile) err("Only use -f once");
+				logfile = xstrdup(optarg);
 				break;
 		}
 	}
 	if (!do_list && !do_unlist && !do_time && !do_sync && !do_current)
 		qlop_usage(EXIT_FAILURE);
-	if (opt_logfile != NULL)
-		logfile = opt_logfile;
+	if (logfile == NULL)
+		xasprintf(&logfile, "%s/%s", portlogdir, QLOP_DEFAULT_LOGFILE);
 
 	argc -= optind;
 	argv += optind;
@@ -696,7 +694,7 @@ int qlop_main(int argc, char **argv)
 			show_merge_times(argv[i], logfile, average, do_human_readable);
 	}
 
-	if (opt_logfile) free(opt_logfile);
+	free(logfile);
 
 	return EXIT_SUCCESS;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-05-19 17:37 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-05-19 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     3044a7a90ef35ae564bfdf2d44fbb75920ce0c61
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue May 19 16:58:22 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue May 19 16:58:22 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=3044a7a9

regen autotools

 Makefile.am | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 3a33bbe..5ffa339 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -94,6 +94,7 @@ EXTRA_DIST += \
 	libq/atom_compare.c \
 	libq/atom_explode.c \
 	libq/basename.c \
+	libq/binpackages.c \
 	libq/busybox.h \
 	libq/colors.c \
 	libq/compat.c \
@@ -171,6 +172,29 @@ EXTRA_DIST += \
 	tests/profile/profile1/etc/portage/make.conf \
 	tests/profile/profile1/etc/portage/subdir/file.conf \
 	tests/profile/profile1/etc/portage/this.level.conf \
+	tests/qcheck/Makefile \
+	tests/qcheck/dotest \
+	tests/qcheck/list01.good \
+	tests/qcheck/list02.good \
+	tests/qcheck/list03.good \
+	tests/qcheck/list04.good \
+	tests/qcheck/list05.good \
+	tests/qcheck/list06.good \
+	tests/qcheck/list07.good \
+	tests/qcheck/list08.good \
+	tests/qcheck/list09.good \
+	tests/qcheck/root/a-b/pkg-1.0/CONTENTS \
+	tests/qcheck/root/a-b/pkg-1.0/SLOT \
+	tests/qcheck/root/a-b/pkg-1.0/repository \
+	tests/qcheck/root/bin/bad-md5 \
+	tests/qcheck/root/bin/bad-mtime \
+	tests/qcheck/root/bin/bad-mtime-obj \
+	tests/qcheck/root/bin/bad-sha1 \
+	tests/qcheck/root/bin/good-md5 \
+	tests/qcheck/root/bin/good-sha1 \
+	tests/qcheck/root/cat/pkg-1/CONTENTS \
+	tests/qcheck/root/cat/pkg-1/SLOT \
+	tests/qcheck/root/cat/pkg-1/repository \
 	tests/qdepends/Makefile \
 	tests/qdepends/dotest \
 	tests/qdepends/list01.good \
@@ -205,6 +229,7 @@ EXTRA_DIST += \
 	tests/qlist/list12.good \
 	tests/qlist/list13.good \
 	tests/qlist/list14.good \
+	tests/qlist/list15.good \
 	tests/qlist/root/-merge-foo/CONTENTS \
 	tests/qlist/root/a-b/a-0/CONTENTS \
 	tests/qlist/root/a-b/a-0/SLOT \
@@ -224,6 +249,11 @@ EXTRA_DIST += \
 	tests/qlist/root/sys-fs/mtools-4.0.13/CONTENTS \
 	tests/qlist/root/sys-fs/mtools-4.0.13/SLOT \
 	tests/qlist/root/sys-fs/mtools-4.0.13/repository \
+	tests/qlop/Makefile \
+	tests/qlop/dotest \
+	tests/qlop/list01.good \
+	tests/qlop/sync.log \
+	tests/qmerge/.gdb_history \
 	tests/qmerge/Makefile \
 	tests/qmerge/dotest \
 	tests/qmerge/packages/Packages \


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-05-19 17:37 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-05-19 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     28d0df0c3be0042006fbf39ff83d4d0342832caa
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue May 19 16:04:57 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue May 19 16:04:57 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=28d0df0c

qgrep/qpkg: use the cache file given

The qgrep code needs a rework to avoid chdir assumptions, but that's
much larger than fixing the cache file name, so punt for later.

 qgrep.c |  4 ++--
 qpkg.c  | 14 +-------------
 2 files changed, 3 insertions(+), 15 deletions(-)

diff --git a/qgrep.c b/qgrep.c
index 982672d..de018ea 100644
--- a/qgrep.c
+++ b/qgrep.c
@@ -371,9 +371,9 @@ int qgrep_main(int argc, char **argv)
 
 	/* go look either in ebuilds or eclasses or VDB */
 	if (!do_eclass && !do_installed) {
-		initialize_ebuild_flat();	/* sets our pwd to $PORTDIR */
-		if ((fp = fopen(CACHE_EBUILD_FILE, "r")) == NULL)
+		if ((fp = fopen(initialize_ebuild_flat(), "r")) == NULL)
 			return 1;
+		xchdir(portdir);
 	} else if (do_eclass) {
 		xchdir(portdir);
 		if ((eclass_dir = opendir("eclass")) == NULL)

diff --git a/qpkg.c b/qpkg.c
index 5b63ec2..50d79f6 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -122,19 +122,7 @@ int qpkg_clean(char *dirp)
 	}
 
 	if (eclean) {
-		char fname[_Q_PATH_MAX] = "";
-		const char *ecache;
-
-		/* CACHE_EBUILD_FILE is a macro so don't put it in the .bss */
-		ecache = CACHE_EBUILD_FILE;
-
-		if (ecache) {
-			if (*ecache != '/')
-				snprintf(fname, sizeof(fname), "%s/%s", portdir, ecache);
-			else
-				strncpy(fname, ecache, sizeof(fname));
-		}
-		if ((fp = fopen(fname, "r")) != NULL) {
+		if ((fp = fopen(initialize_ebuild_flat(), "r")) != NULL) {
 			size_t buflen;
 			char *buf;
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-05-19 17:37 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-05-19 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     d9eb678ae9f359a1b8e22ab3eca2d70a886b497e
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue May 19 15:55:14 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue May 19 15:55:14 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d9eb678a

qglsa: update code to latest APIs

 qglsa.c | 51 ++++++++++++++++++++++++++-------------------------
 1 file changed, 26 insertions(+), 25 deletions(-)

diff --git a/qglsa.c b/qglsa.c
index 4ac3d19..328bbd8 100644
--- a/qglsa.c
+++ b/qglsa.c
@@ -34,19 +34,9 @@ static const char * const qglsa_opts_help[] = {
 static char *qglsa_load_list(void);
 static char *qglsa_load_list(void)
 {
-	char *ret;
-	struct stat st;
-
-	if (stat(QGLSA_DB, &st))
-		return NULL;
-
-	ret = xmalloc(st.st_size+1);
-
-	if (!eat_file(QGLSA_DB, ret, st.st_size)) {
-		free(ret);
-		return NULL;
-	}
-
+	char *ret = NULL;
+	size_t size = 0;
+	eat_file(QGLSA_DB, &ret, &size);
 	return ret;
 }
 static void qglsa_append_to_list(const char *glsa);
@@ -158,8 +148,8 @@ int qglsa_main(int argc, char **argv)
 	int i;
 	DIR *dir;
 	struct dirent *dentry;
-	struct stat st;
-	char buf[BUFSIZE*4];
+	char *buf;
+	size_t buflen = 0;
 	char *s, *p, *glsa_fixed_list;
 	int action = GLSA_FUNKYTOWN;
 	int all_glsas = 0;
@@ -198,16 +188,19 @@ int qglsa_main(int argc, char **argv)
 	}
 	glsa_fixed_list = qglsa_load_list();
 
-	xchdir(portdir);
-	xchdir("./metadata/glsa");
+	int portdir_fd, glsa_fd;
+	portdir_fd = open(portdir, O_RDONLY|O_CLOEXEC|O_PATH);
+	glsa_fd = openat(portdir_fd, "metadata/glsa", O_RDONLY|O_CLOEXEC);
 
 	switch (action) {
 	/*case GLSA_FIX:*/
 	case GLSA_INJECT:
+		buf = NULL;
 		for (i = optind; i < argc; ++i) {
-			snprintf(buf, sizeof(buf), "glsa-%s.xml", argv[i]);
-			if (stat(buf, &st)) {
-				warn("Skipping invalid GLSA '%s'", argv[i]);
+			free(buf);
+			xasprintf(&buf, "glsa-%s.xml", argv[i]);
+			if (faccessat(glsa_fd, buf, R_OK, 0)) {
+				warnp("Skipping invalid GLSA '%s'", argv[i]);
 				continue;
 			}
 			if (glsa_fixed_list) {
@@ -223,21 +216,27 @@ int qglsa_main(int argc, char **argv)
 				printf("Injecting GLSA %s%s%s\n", GREEN, argv[i], NORM);
 			qglsa_append_to_list(argv[i]);
 		}
+		free(buf);
 		break;
 
 	default:
-		if ((dir = opendir(".")) == NULL)
+		if ((dir = fdopendir(glsa_fd)) == NULL)
 			return EXIT_FAILURE;
 
+		buf = NULL;
+		buflen = 0;
 		while ((dentry = readdir(dir)) != NULL) {
 			/* validate this file as a proper glsa */
 			char glsa_id[20];
 			if (strncmp(dentry->d_name, "glsa-", 5))
 				continue;
-			strcpy(glsa_id, dentry->d_name + 5);
-			if ((s = strchr(glsa_id, '.')) == NULL || memcmp(s, ".xml\0", 5))
+			if ((s = strchr(dentry->d_name, '.')) == NULL || memcmp(s, ".xml\0", 5))
+				continue;
+			size_t len = s - dentry->d_name;
+			if (len >= sizeof(glsa_id) || len <= 5)
 				continue;
-			*s = '\0';
+			memcpy(glsa_id, dentry->d_name + 5, len - 5);
+			glsa_id[len - 5] = '\0';
 
 			/* see if we want to skip glsa's already fixed */
 			if (!all_glsas && glsa_fixed_list) {
@@ -246,7 +245,7 @@ int qglsa_main(int argc, char **argv)
 			}
 
 			/* load the glsa into memory */
-			if (eat_file(dentry->d_name, buf, sizeof(buf)) == 0)
+			if (!eat_file_at(glsa_fd, dentry->d_name, &buf, &buflen))
 				errp("could not eat %s", dentry->d_name);
 
 			/* now lets figure out what to do with this memory */
@@ -300,6 +299,8 @@ int qglsa_main(int argc, char **argv)
 	}
 
 	free(glsa_fixed_list);
+	close(glsa_fd);
+	close(portdir_fd);
 
 	return EXIT_SUCCESS;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-05-19 17:37 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-05-19 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     357a4c2d329ccf46cddb96e07c9308105e977fd3
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue May 19 16:17:05 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue May 19 16:17:05 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=357a4c2d

cache: rework and move to /var/cache/edb

Since we want the portdir to be read-only when possible, move our
cache files to /var/cache/edb.  This means the cache regeneration
logic isn't as robust (as we can't rely on rsync deleting it), but
so be it.  We can see about improving this in the future.

URL: https://bugs.gentoo.org/548052
Reported-by: Martin Väth <martin <AT> mvath.de>

 main.c    | 125 ++++++++++++++++++++++++++++----------------------------------
 qcache.c  |  14 +------
 qglsa.c   |  16 +++++---
 qsearch.c |   2 +-
 4 files changed, 69 insertions(+), 88 deletions(-)

diff --git a/main.c b/main.c
index 51c48aa..d127621 100644
--- a/main.c
+++ b/main.c
@@ -35,6 +35,7 @@ char reinitialize_metacache = 0;
 static char *portdir;
 static char *portarch;
 static char *portvdb;
+static char *portedb;
 const char portcachedir_pms[] = "metadata/cache";
 const char portcachedir_md5[] = "metadata/md5-cache";
 static char *portroot;
@@ -698,6 +699,7 @@ void initialize_portage_env(void)
 		_Q_EVS(STR,  PORTAGE_TMPDIR,      port_tmpdir,         CONFIG_EPREFIX "var/tmp/portage/")
 		_Q_EVS(STR,  PKGDIR,              pkgdir,              CONFIG_EPREFIX "usr/portage/packages/")
 		_Q_EVS(STR,  Q_VDB,               portvdb,             CONFIG_EPREFIX "var/db/pkg")
+		_Q_EVS(STR,  Q_EDB,               portedb,             CONFIG_EPREFIX "var/cache/edb")
 		{ NULL, 0, _Q_BOOL, { NULL }, 0, NULL, }
 
 #undef _Q_EV
@@ -846,92 +848,83 @@ int filter_hidden(const struct dirent *dentry)
 	return 1;
 }
 
-#define CACHE_EBUILD_FILE (getenv("CACHE_EBUILD_FILE") ? getenv("CACHE_EBUILD_FILE") : ".ebuild.x")
-#define CACHE_METADATA_FILE ".metadata.x"
-const char *initialize_flat(int cache_type);
-const char *initialize_flat(int cache_type)
+static const char *
+initialize_flat(int cache_type, bool force)
 {
 	struct dirent **category, **pn, **eb;
 	struct stat st;
 	struct timeval start, finish;
-	static const char *cache_file;
-	const char *portcachedir_actual;
+	char *cache_file;
 	char *p;
-	int a, b, c, d, e, i;
+	int i;
 	int frac, secs, count;
 	FILE *fp;
 
-	a = b = c = d = e = i = 0;
 	count = frac = secs = 0;
 
-	cache_file = (cache_type == CACHE_EBUILD ? CACHE_EBUILD_FILE : CACHE_METADATA_FILE);
-
-	if (chdir(portdir) != 0) {
-		warnp("chdir to PORTDIR '%s' failed", portdir);
-		goto ret;
-	}
+	int portdir_fd, subdir_fd;
+	portdir_fd = open(portdir, O_RDONLY|O_CLOEXEC|O_PATH);
 
 	if (cache_type == CACHE_METADATA) {
-		if (chdir(portcachedir_md5) == 0) {
-			portcachedir_type = CACHE_METADATA_MD5;
-			portcachedir_actual = portcachedir_md5;
-		} else if (chdir(portcachedir_pms) == 0) {
+		subdir_fd = openat(portdir_fd, portcachedir_md5, O_RDONLY|O_CLOEXEC);
+		if (subdir_fd == -1) {
+			subdir_fd = openat(portdir_fd, portcachedir_pms, O_RDONLY|O_CLOEXEC);
+			if (subdir_fd == -1) {
+				warnp("could not read md5 or pms cache dirs in %s", portdir);
+				goto ret;
+			}
 			portcachedir_type = CACHE_METADATA_PMS;
-			portcachedir_actual = portcachedir_pms;
-		} else {
-			warnp("chdir to portage cache '%s/%s' or '%s/%s' failed", portdir, portcachedir_md5, portdir, portcachedir_pms);
-			goto ret;
-		}
-	}
+		} else
+			portcachedir_type = CACHE_METADATA_MD5;
+	} else
+		subdir_fd = portdir_fd;
+	xasprintf(&cache_file, "%s/dep/%s/%s", portedb, portdir,
+		(cache_type == CACHE_EBUILD ? ".ebuild.x" : ".metadata.x"));
 
-	if (stat(cache_file, &st) != -1)
+	if (stat(cache_file, &st) != -1) {
 		if (st.st_size == 0)
 			unlink(cache_file);
-
-	/* assuming --sync is used with --delete this will get recreated after every merge */
-	if (access(cache_file, R_OK) == 0)
+	} else if (!force) {
+		/* assuming --sync is used with --delete this will get recreated after every merge */
 		goto ret;
+	}
 	if (!quiet)
 		warn("Updating ebuild %scache ... ", cache_type == CACHE_EBUILD ? "" : "meta");
 
-	unlink(cache_file);
-	if (errno != ENOENT) {
-		warnfp("unlinking '%s/%s' failed", portdir, cache_file);
-		goto ret;
-	}
-
-	if ((fp = fopen(cache_file, "w")) == NULL) {
-		if (cache_type == CACHE_EBUILD)
-			warnfp("opening '%s/%s' failed", portdir, cache_file);
-		else
-			warnfp("opening '%s/%s/%s' failed", portdir, portcachedir_actual, cache_file);
+	if ((fp = fopen(cache_file, "we")) == NULL) {
+		warnfp("opening cache failed: %s", cache_file);
 		if (errno == EACCES)
 			warnf("You should run this command as root: q -%c",
-					cache_type == CACHE_EBUILD ? 'r' : 'm');
+				cache_type == CACHE_EBUILD ? 'r' : 'm');
 		goto ret;
 	}
 
 	gettimeofday(&start, NULL);
 
-	if ((a = scandir(".", &category, q_vdb_filter_cat, alphasort)) < 0)
+	int cat_cnt;
+	cat_cnt = scandirat(subdir_fd, ".", &category, q_vdb_filter_cat, alphasort);
+	if (cat_cnt < 0)
 		goto ret;
 
-	for (i = 0; i < a; i++) {
-		stat(category[i]->d_name, &st);
+	for (i = 0; i < cat_cnt; i++) {
+		if (fstatat(subdir_fd, category[i]->d_name, &st, 0))
+			continue;
 		if (!S_ISDIR(st.st_mode))
 			continue;
 		if (strchr(category[i]->d_name, '-') == NULL)
 			if (strncmp(category[i]->d_name, "virtual", 7) != 0)
 				continue;
 
-		if ((b = scandir(category[i]->d_name, &pn, q_vdb_filter_pkg, alphasort)) < 0)
+		int c, pkg_cnt;
+		pkg_cnt = scandirat(subdir_fd, category[i]->d_name, &pn, q_vdb_filter_pkg, alphasort);
+		if (pkg_cnt < 0)
 			continue;
-		for (c = 0; c < b; c++) {
+		for (c = 0; c < pkg_cnt; c++) {
 			char de[_Q_PATH_MAX];
 
 			snprintf(de, sizeof(de), "%s/%s", category[i]->d_name, pn[c]->d_name);
 
-			if (stat(de, &st) < 0)
+			if (fstatat(subdir_fd, de, &st, 0) < 0)
 				continue;
 
 			switch (cache_type) {
@@ -943,24 +936,25 @@ const char *initialize_flat(int cache_type)
 				if (S_ISREG(st.st_mode))
 					fprintf(fp, "%s\n", de);
 				continue;
-				break;
 			}
-			if ((e = scandir(de, &eb, filter_hidden, alphasort)) < 0)
+
+			int e, ebuild_cnt;
+			ebuild_cnt = scandirat(subdir_fd, de, &eb, filter_hidden, alphasort);
+			if (ebuild_cnt < 0)
 				continue;
-			for (d = 0; d < e; d++) {
-				if ((p = strrchr(eb[d]->d_name, '.')) != NULL)
+			for (e = 0; e < ebuild_cnt; ++e) {
+				if ((p = strrchr(eb[e]->d_name, '.')) != NULL)
 					if (strcmp(p, ".ebuild") == 0) {
 						count++;
-						fprintf(fp, "%s/%s/%s\n", category[i]->d_name, pn[c]->d_name, eb[d]->d_name);
+						fprintf(fp, "%s/%s\n", de, eb[e]->d_name);
 					}
 			}
-			while (d--) free(eb[d]);
-			free(eb);
+			scandir_free(eb, ebuild_cnt);
 		}
-		scandir_free(pn, b);
+		scandir_free(pn, pkg_cnt);
 	}
 	fclose(fp);
-	scandir_free(category, a);
+	scandir_free(category, cat_cnt);
 
 	if (quiet) goto ret;
 
@@ -978,27 +972,20 @@ const char *initialize_flat(int cache_type)
 	if (secs > 120)
 		warn("You should consider using the noatime mount option for PORTDIR='%s' if it's not already enabled", portdir);
 ret:
+	close(subdir_fd);
+	if (subdir_fd != portdir_fd)
+		close(portdir_fd);
 	return cache_file;
 }
-#define initialize_ebuild_flat() initialize_flat(CACHE_EBUILD)
-#define initialize_metadata_flat() initialize_flat(CACHE_METADATA)
-
-void reinitialize_ebuild_flat(void)
-{
-	if (chdir(portdir) != 0) {
-		warnp("chdir to PORTDIR '%s' failed", portdir);
-		return;
-	}
-	unlink(CACHE_EBUILD_FILE);
-	initialize_ebuild_flat();
-}
+#define initialize_ebuild_flat() initialize_flat(CACHE_EBUILD, false)
+#define initialize_metadata_flat() initialize_flat(CACHE_METADATA, false)
 
 void reinitialize_as_needed(void)
 {
 	if (reinitialize)
-		reinitialize_ebuild_flat();
+		initialize_flat(CACHE_EBUILD, true);
 	if (reinitialize_metacache)
-		initialize_metadata_flat();
+		initialize_flat(CACHE_METADATA, true);
 }
 
 typedef struct {

diff --git a/qcache.c b/qcache.c
index d0bab3b..0968d33 100644
--- a/qcache.c
+++ b/qcache.c
@@ -47,13 +47,6 @@ static const char * const qcache_opts_help[] = {
 #define qcache_usage(ret) usage(ret, QCACHE_FLAGS, qcache_long_opts, qcache_opts_help, lookup_applet_idx("qcache"))
 
 /********************************************************************/
-/* Constants                                                        */
-/********************************************************************/
-
-/* TODO: allow the user to override this value if s/he wishes */
-#define QCACHE_EDB "/var/cache/edb/dep"
-
-/********************************************************************/
 /* Structs                                                          */
 /********************************************************************/
 
@@ -512,7 +505,7 @@ int qcache_traverse(void (*func)(qcache_data*))
 	int i, j, k, len, num_cat, num_pkg, num_ebuild;
 	struct dirent **categories, **packages, **ebuilds;
 
-	xasprintf(&catpath, "%s%s", QCACHE_EDB, portdir);
+	xasprintf(&catpath, "%s/dep/%s", portedb, portdir);
 
 	if (-1 == (num_cat = scandir(catpath, &categories, qcache_file_select, alphasort))) {
 		errp("%s", catpath);
@@ -754,11 +747,8 @@ void qcache_stats(qcache_data *data)
 	if (!numpkg) {
 		struct dirent **categories;
 		char *catpath;
-		int len;
 
-		len = sizeof(char) * (strlen(QCACHE_EDB) + strlen(portdir) + 1);
-		catpath = xzalloc(len);
-		snprintf(catpath, len, "%s%s", QCACHE_EDB, portdir);
+		xasprintf(&catpath, "%s/dep/%s", portedb, portdir);
 
 		if (-1 == (numcat = scandir(catpath, &categories, qcache_file_select, alphasort))) {
 			errp("%s", catpath);

diff --git a/qglsa.c b/qglsa.c
index 328bbd8..7fba5c7 100644
--- a/qglsa.c
+++ b/qglsa.c
@@ -8,8 +8,6 @@
 
 #ifdef APPLET_qglsa
 
-#define QGLSA_DB "/var/cache/edb/glsa"
-
 #define QGLSA_FLAGS "ldtpfi" COMMON_FLAGS
 static struct option const qglsa_long_opts[] = {
 	{"list",      no_argument, NULL, 'l'},
@@ -34,19 +32,25 @@ static const char * const qglsa_opts_help[] = {
 static char *qglsa_load_list(void);
 static char *qglsa_load_list(void)
 {
-	char *ret = NULL;
+	char *file, *ret = NULL;
 	size_t size = 0;
-	eat_file(QGLSA_DB, &ret, &size);
+	xasprintf(&file, "%s/glsa", portedb);
+	eat_file(file, &ret, &size);
+	free(file);
 	return ret;
 }
 static void qglsa_append_to_list(const char *glsa);
 static void qglsa_append_to_list(const char *glsa)
 {
+	char *file;
 	FILE *f;
-	if ((f = fopen(QGLSA_DB, "a")) != NULL) {
-		fprintf(f, "%s\n", glsa);
+	xasprintf(&file, "%s/glsa", portedb);
+	if ((f = fopen(file, "a")) != NULL) {
+		fputs(glsa, f);
+		fputc('\n', f);
 		fclose(f);
 	}
+	free(file);
 }
 
 static void qglsa_decode_entities(char *xml_buf, size_t len);

diff --git a/qsearch.c b/qsearch.c
index e1285a3..ce36df2 100644
--- a/qsearch.c
+++ b/qsearch.c
@@ -88,7 +88,7 @@ int qsearch_main(int argc, char **argv)
 	}
 #endif
 	last[0] = 0;
-	fp = fopen(initialize_flat(search_cache), "r");
+	fp = fopen(initialize_flat(search_cache, false), "r");
 	if (!fp)
 		return 1;
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-05-19 17:37 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-05-19 17:37 UTC (permalink / raw
  To: gentoo-commits

commit:     c6bd6041822a9f968c068757722858f6e481c341
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue May 19 15:57:54 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue May 19 15:57:54 2015 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c6bd6041

quse: use the cache file given and avoid cwd assumptions

This allows us to rework the internals of the cache funcs and not need
any specific chdir configuration by switching to the *at style funcs.

 quse.c | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/quse.c b/quse.c
index 534cf41..dddbf5b 100644
--- a/quse.c
+++ b/quse.c
@@ -214,6 +214,7 @@ quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 int quse_main(int argc, char **argv)
 {
 	FILE *fp;
+	const char *cache_file;
 	char *p;
 
 	char buf0[_Q_PATH_MAX];
@@ -251,19 +252,31 @@ int quse_main(int argc, char **argv)
 		return quse_describe_flag(optind, argc, argv);
 
 	if (quse_all) optind = argc;
-	initialize_ebuild_flat();	/* sets our pwd to $PORTDIR */
+	cache_file = initialize_ebuild_flat();
 
 	search_len = strlen(search_vars[idx]);
 	assert(search_len < sizeof(buf0));
 
-	if ((fp = fopen(CACHE_EBUILD_FILE, "r")) == NULL)
+	if ((fp = fopen(cache_file, "r")) == NULL) {
+		warnp("could not read cache: %s", cache_file);
 		return 1;
+	}
+
+	int portdir_fd = open(portdir, O_RDONLY|O_CLOEXEC|O_PATH);
+
 	ebuild = NULL;
 	while (getline(&ebuild, &ebuildlen, fp) != -1) {
 		FILE *newfp;
+		int fd;
+
 		if ((p = strchr(ebuild, '\n')) != NULL)
 			*p = 0;
-		if ((newfp = fopen(ebuild, "r")) != NULL) {
+
+		fd = openat(portdir_fd, ebuild, O_RDONLY|O_CLOEXEC);
+		if (fd < 0)
+			continue;
+		newfp = fdopen(fd, "r");
+		if (newfp != NULL) {
 			unsigned int lineno = 0;
 			char revision[sizeof(buf0)];
 			char date[sizeof(buf0)];
@@ -408,6 +421,7 @@ int quse_main(int argc, char **argv)
 		}
 	}
 	fclose(fp);
+	close(portdir_fd);
 	return EXIT_SUCCESS;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     4db515ff005a0107d4f25d6d6889d05a920ac435
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 24 01:01:53 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 24 01:01:53 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=4db515ff

main: drop __DATE__ from version info to let ccache work better

---
 main.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/main.c b/main.c
index 1ee8816..51c48aa 100644
--- a/main.c
+++ b/main.c
@@ -165,10 +165,9 @@ static void version_barf(void)
 #ifndef VCSID
 # define VCSID "<unknown>"
 #endif
-	printf("portage-utils-%s: compiled on %s\n"
-	       "vcs id: %s\n"
+	printf("portage-utils-%s: %s\n"
 	       "%s written for Gentoo by <solar and vapier @ gentoo.org>\n",
-	       VERSION, __DATE__, VCSID, argv0);
+	       VERSION, VCSID, argv0);
 	exit(EXIT_SUCCESS);
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     f23fa9375a936d3d7d565175dfe39a2dd209d45e
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 24 00:21:25 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 24 00:21:25 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=f23fa937

qmerge: parse the binpkg header first

This contains common details (like REPO) that are not repeated for every
entry.  We'll propagate that back out whenever we reset the Pkg state.

Also seed the SLOT value with 0 every time.  Its value is omitted when it
is the default, so we have to do this ourselves.

---
 qmerge.c | 31 ++++++++++++++++++++++++++++++-
 1 file changed, 30 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index be28cb7..1bd860d 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1675,13 +1675,40 @@ parse_packages(queue *todo)
 	char *buf, *p;
 	struct pkg_t Pkg;
 	depend_atom *pkg_atom;
+	char repo[sizeof(Pkg.REPO)];
 
 	fp = open_binpkg_index();
 
+	buf = NULL;
+	repo[0] = '\0';
+
+	/* First consume the header with the common data. */
+	while (getline(&buf, &buflen, fp) != -1) {
+		if (*buf == '\n')
+			break;
+
+		if ((p = strchr(buf, '\n')) != NULL)
+			*p = 0;
+		if ((p = strchr(buf, ':')) == NULL)
+			continue;
+		if (p[1] != ' ')
+			continue;
+		*p = 0;
+		p += 2;
+
+		switch (*buf) {
+		case 'R':
+			if (!strcmp(buf, "REPO"))
+				strncpy(repo, p, sizeof(repo));
+			break;
+		}
+	}
+
 	pkg_atom = NULL;
 	memset(&Pkg, 0, sizeof(Pkg));
+	strcpy(Pkg.SLOT, "0");
 
-	buf = NULL;
+	/* Then walk all the package entries. */
 	while (getline(&buf, &buflen, fp) != -1) {
 		if (*buf == '\n') {
 			if (pkg_atom) {
@@ -1706,6 +1733,8 @@ parse_packages(queue *todo)
 				pkg_atom = NULL;
 			}
 			memset(&Pkg, 0, sizeof(Pkg));
+			strcpy(Pkg.SLOT, "0");
+			strcpy(Pkg.REPO, repo);
 			continue;
 		}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     c85ef7b89c7b7bf9a7b462e76c309855b1be4e4e
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 24 00:03:15 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 24 00:08:07 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=c85ef7b8

qmerge: pull atom up a level in the merge logic

---
 qmerge.c | 75 ++++++++++++++++++++++------------------------------------------
 1 file changed, 26 insertions(+), 49 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 4660eff..be28cb7 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1210,15 +1210,12 @@ _q_static int unlink_empty(const char *buf)
 	return -1;
 }
 
-_q_static int match_pkg(queue *ll, const struct pkg_t *pkg)
+_q_static int match_pkg(const queue *ll, const depend_atom *atom, const struct pkg_t *pkg)
 {
-	depend_atom *atom;
-	char buf[255], buf2[255];
+	char buf[255];
 	int match = 0;
 
 	snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF);
-	if ((atom = atom_explode(buf)) == NULL)
-		errf("%s/%s is not a valid atom", pkg->CATEGORY, pkg->PF);
 
 	/* verify this is the requested package */
 	if (strcmp(ll->name, buf) == 0)
@@ -1227,20 +1224,14 @@ _q_static int match_pkg(queue *ll, const struct pkg_t *pkg)
 	if (strcmp(ll->name, pkg->PF) == 0)
 		match = 2;
 
-	snprintf(buf2, sizeof(buf2), "%s/%s", pkg->CATEGORY, atom->PN);
+	snprintf(buf, sizeof(buf), "%s/%s", atom->CATEGORY, atom->PN);
 
-	if (strcmp(ll->name, buf2) == 0)
+	if (strcmp(ll->name, buf) == 0)
 		match = 3;
 
 	if (strcmp(ll->name, atom->PN) == 0)
 		match = 4;
 
-	if (match)
-		goto match_done;
-
-match_done:
-	atom_implode(atom);
-
 	return match;
 }
 
@@ -1287,28 +1278,19 @@ pkg_verify_checksums(char *fname, const struct pkg_t *pkg, const depend_atom *at
 }
 
 _q_static
-void pkg_process(queue *todo, const struct pkg_t *pkg)
+void pkg_process(const queue *todo, const depend_atom *atom, const struct pkg_t *pkg)
 {
-	queue *ll;
-	depend_atom *atom;
-	char buf[255];
-
-	snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF);
-	if ((atom = atom_explode(buf)) == NULL)
-		errf("%s/%s is not a valid atom", pkg->CATEGORY, pkg->PF);
+	const queue *ll;
 
 	ll = todo;
 	while (ll) {
-		if (ll->name[0] != '-' && match_pkg(ll, pkg)) {
+		if (ll->name[0] != '-' && match_pkg(ll, atom, pkg)) {
 			/* fetch all requested packages */
 			pkg_fetch(0, atom, pkg);
 		}
 
 		ll = ll->next;
 	}
-
-	/* free the atom */
-	atom_implode(atom);
 }
 
 _q_static void
@@ -1382,19 +1364,15 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 }
 
 _q_static void
-print_Pkg(int full, struct pkg_t *pkg)
+print_Pkg(int full, const depend_atom *atom, const struct pkg_t *pkg)
 {
 	char *p = NULL;
 	char buf[512];
-	depend_atom *atom = NULL;
-
-	if (!pkg->CATEGORY[0]) errf("CATEGORY is NULL");
-	if (!pkg->PF[0]) errf("PF is NULL");
 
-	printf("%s%s/%s%s%s%s%s%s\n", BOLD, pkg->CATEGORY, BLUE, pkg->PF, NORM,
+	printf("%s%s/%s%s%s%s%s%s\n", BOLD, atom->CATEGORY, BLUE, pkg->PF, NORM,
 		!quiet ? " [" : "",
 		!quiet ? make_human_readable_str(pkg->SIZE, 1, KILOBYTE) : "",
-		!quiet ? "KiB]" : "");
+		!quiet ? " KiB]" : "");
 
 	if (full == 0)
 		return;
@@ -1419,10 +1397,6 @@ print_Pkg(int full, struct pkg_t *pkg)
 		if (strcmp(pkg->REPO, "gentoo") != 0)
 			printf(" %sRepo%s:%s %s\n", DKGREEN, YELLOW, NORM, pkg->REPO);
 
-	snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF);
-	atom = atom_explode(buf);
-	if ((atom = atom_explode(buf)) == NULL)
-		return;
 	if ((p = best_version(pkg->CATEGORY, atom->PN)) != NULL) {
 		if (*p) {
 			int ret;
@@ -1437,7 +1411,6 @@ print_Pkg(int full, struct pkg_t *pkg)
 			printf(" %sInstalled%s:%s %s%s%s\n", DKGREEN, YELLOW, NORM, icolor, p, NORM);
 		}
 	}
-	atom_implode(atom);
 }
 
 _q_static int
@@ -1701,15 +1674,17 @@ parse_packages(queue *todo)
 	size_t buflen;
 	char *buf, *p;
 	struct pkg_t Pkg;
+	depend_atom *pkg_atom;
 
 	fp = open_binpkg_index();
 
+	pkg_atom = NULL;
 	memset(&Pkg, 0, sizeof(Pkg));
 
 	buf = NULL;
 	while (getline(&buf, &buflen, fp) != -1) {
 		if (*buf == '\n') {
-			if ((strlen(Pkg.PF) > 0) && (strlen(Pkg.CATEGORY) > 0)) {
+			if (pkg_atom) {
 				struct pkg_t *pkg = xmalloc(sizeof(*pkg));
 				*pkg = Pkg;
 
@@ -1717,16 +1692,18 @@ parse_packages(queue *todo)
 					if (todo) {
 						queue *ll = todo;
 						while (ll) {
-							if ((match_pkg(ll, pkg) > 0) || (strcmp(ll->name, pkg->CATEGORY) == 0))
-								print_Pkg(verbose, pkg);
+							if ((match_pkg(ll, pkg_atom, pkg) > 0) || (strcmp(ll->name, pkg->CATEGORY) == 0))
+								print_Pkg(verbose, pkg_atom, pkg);
 							ll = ll->next;
 						}
 					} else
-						print_Pkg(verbose, pkg);
+						print_Pkg(verbose, pkg_atom, pkg);
 				} else
-					pkg_process(todo, pkg);
+					pkg_process(todo, pkg_atom, pkg);
 
 				free(pkg);
+				atom_implode(pkg_atom);
+				pkg_atom = NULL;
 			}
 			memset(&Pkg, 0, sizeof(Pkg));
 			continue;
@@ -1766,14 +1743,12 @@ parse_packages(queue *todo)
 			case 'C':
 				if (strcmp(buf, "CATEGORY") == 0) strncpy(Pkg.CATEGORY, p, sizeof(Pkg.CATEGORY));
 				if (strcmp(buf, "CPV") == 0) {
-					depend_atom *atom;
-					if ((atom = atom_explode(p)) != NULL) {
-						if (atom->PR_int)
-							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s-r%i", atom->PN, atom->PV, atom->PR_int);
+					if ((pkg_atom = atom_explode(p)) != NULL) {
+						if (pkg_atom->PR_int)
+							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s-r%i", pkg_atom->PN, pkg_atom->PV, pkg_atom->PR_int);
 						else
-							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s", atom->PN, atom->PV);
-						strncpy(Pkg.CATEGORY, atom->CATEGORY, sizeof(Pkg.CATEGORY));
-						atom_implode(atom);
+							snprintf(Pkg.PF, sizeof(Pkg.PF), "%s-%s", pkg_atom->PN, pkg_atom->PV);
+						strncpy(Pkg.CATEGORY, pkg_atom->CATEGORY, sizeof(Pkg.CATEGORY));
 					}
 				}
 				break;
@@ -1787,6 +1762,8 @@ parse_packages(queue *todo)
 
 	free(buf);
 	fclose(fp);
+	if (pkg_atom)
+		atom_implode(pkg_atom);
 
 	return EXIT_SUCCESS;
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     f72c81d161a174d683d81aa8747e38f3a364dc58
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 24 01:02:15 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 24 01:02:15 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=f72c81d1

regen .depend when applets.h updates since we pull from that

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 137b505..7304559 100644
--- a/Makefile
+++ b/Makefile
@@ -76,7 +76,7 @@ endif
 endif
 	$(Q)$(CC) $(WFLAGS) $(PYFLAGS) $(LDFLAGS) $(CFLAGS) $(CPPFLAGS) main.c -o q $(LIBADD)
 
-.depend: $(SRC)
+.depend: $(SRC) applets.h
 	sed -n '/^DECLARE_APPLET/s:.*(\(.*\)).*:#include "\1.c":p' applets.h > include_applets.h
 	@#$(CC) $(CFLAGS) -MM $(SRC) > .depend
 	$(CC) $(CPPFLAGS) $(CFLAGS) -MM main.c > .depend


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     f61120de1a713ae221e9a5b869bb75c74301f6bd
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 24 00:33:43 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 24 00:33:43 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=f61120de

qmerge: use atom_compare to figure out matches

This brings proper version/slot/etc... matching when installing packages:
	qmerge nano:0
	qmerge '>python-3.1'

---
 qmerge.c | 74 ++++++++++++++++------------------------------------------------
 1 file changed, 18 insertions(+), 56 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 1bd860d..9df9384 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1210,31 +1210,6 @@ _q_static int unlink_empty(const char *buf)
 	return -1;
 }
 
-_q_static int match_pkg(const queue *ll, const depend_atom *atom, const struct pkg_t *pkg)
-{
-	char buf[255];
-	int match = 0;
-
-	snprintf(buf, sizeof(buf), "%s/%s", pkg->CATEGORY, pkg->PF);
-
-	/* verify this is the requested package */
-	if (strcmp(ll->name, buf) == 0)
-		match = 1;
-
-	if (strcmp(ll->name, pkg->PF) == 0)
-		match = 2;
-
-	snprintf(buf, sizeof(buf), "%s/%s", atom->CATEGORY, atom->PN);
-
-	if (strcmp(ll->name, buf) == 0)
-		match = 3;
-
-	if (strcmp(ll->name, atom->PN) == 0)
-		match = 4;
-
-	return match;
-}
-
 _q_static int
 pkg_verify_checksums(char *fname, const struct pkg_t *pkg, const depend_atom *atom,
                      int strict, int display)
@@ -1277,22 +1252,6 @@ pkg_verify_checksums(char *fname, const struct pkg_t *pkg, const depend_atom *at
 	return ret;
 }
 
-_q_static
-void pkg_process(const queue *todo, const depend_atom *atom, const struct pkg_t *pkg)
-{
-	const queue *ll;
-
-	ll = todo;
-	while (ll) {
-		if (ll->name[0] != '-' && match_pkg(ll, atom, pkg)) {
-			/* fetch all requested packages */
-			pkg_fetch(0, atom, pkg);
-		}
-
-		ll = ll->next;
-	}
-}
-
 _q_static void
 pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 {
@@ -1712,23 +1671,26 @@ parse_packages(queue *todo)
 	while (getline(&buf, &buflen, fp) != -1) {
 		if (*buf == '\n') {
 			if (pkg_atom) {
-				struct pkg_t *pkg = xmalloc(sizeof(*pkg));
-				*pkg = Pkg;
-
-				if (search_pkgs) {
-					if (todo) {
-						queue *ll = todo;
-						while (ll) {
-							if ((match_pkg(ll, pkg_atom, pkg) > 0) || (strcmp(ll->name, pkg->CATEGORY) == 0))
-								print_Pkg(verbose, pkg_atom, pkg);
-							ll = ll->next;
+				if (search_pkgs && !todo) {
+					print_Pkg(verbose, pkg_atom, &Pkg);
+				} else {
+					const queue *ll = todo;
+					depend_atom *todo_atom;
+					while (ll) {
+						todo_atom = atom_explode(ll->name);
+						pkg_atom->REPO = todo_atom->REPO ? Pkg.REPO : NULL;
+						pkg_atom->SLOT = todo_atom->SLOT ? Pkg.SLOT : NULL;
+						if (atom_compare(todo_atom, pkg_atom) == EQUAL) {
+							if (search_pkgs)
+								print_Pkg(verbose, pkg_atom, &Pkg);
+							else
+								pkg_fetch(0, pkg_atom, &Pkg);
 						}
-					} else
-						print_Pkg(verbose, pkg_atom, pkg);
-				} else
-					pkg_process(todo, pkg_atom, pkg);
+						atom_implode(todo_atom);
+						ll = ll->next;
+					}
+				}
 
-				free(pkg);
 				atom_implode(pkg_atom);
 				pkg_atom = NULL;
 			}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     dca0ef37f0895f169be61657b5704b45d124e6dd
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 23 23:02:11 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Feb 23 23:02:11 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=dca0ef37

qmerge: simplify Packages parsing slightly

---
 qmerge.c | 66 ++++++++++++++++++++++++++++++++--------------------------------
 1 file changed, 33 insertions(+), 33 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 314a114..4660eff 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1565,28 +1565,28 @@ grab_binpkg_info(const char *name)
 			}
 			continue;
 		}
+
 		if ((p = strchr(buf, '\n')) != NULL)
 			*p = 0;
-
 		if ((p = strchr(buf, ':')) == NULL)
 			continue;
-		if ((p = strchr(buf, ' ')) == NULL)
+		if (p[1] != ' ')
 			continue;
 		*p = 0;
-		++p;
+		p += 2;
 
 		if (*buf) {
 			/* we dont need all the info */
-			if (strcmp(buf, "RDEPEND:") == 0)
+			if (strcmp(buf, "RDEPEND") == 0)
 				strncpy(pkg->RDEPEND, p, sizeof(Pkg.RDEPEND));
-			if (strcmp(buf, "PF:") == 0)
+			if (strcmp(buf, "PF") == 0)
 				strncpy(pkg->PF, p, sizeof(Pkg.PF));
-			if (strcmp(buf, "CATEGORY:") == 0)
+			if (strcmp(buf, "CATEGORY") == 0)
 				strncpy(pkg->CATEGORY, p, sizeof(Pkg.CATEGORY));
-			if (strcmp(buf, "REPO:") == 0)
+			if (strcmp(buf, "REPO") == 0)
 				strncpy(pkg->REPO, p, sizeof(Pkg.REPO));
 
-			if (strcmp(buf, "CPV:") == 0) {
+			if (strcmp(buf, "CPV") == 0) {
 				if ((atom = atom_explode(p)) != NULL) {
 					snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
 					if (atom->PR_int)
@@ -1596,15 +1596,15 @@ grab_binpkg_info(const char *name)
 					atom_implode(atom);
 				}
 			}
-			if (strcmp(buf, "SLOT:") == 0)
+			if (strcmp(buf, "SLOT") == 0)
 				strncpy(pkg->SLOT, p, sizeof(Pkg.SLOT));
-			if (strcmp(buf, "USE:") == 0)
+			if (strcmp(buf, "USE") == 0)
 				strncpy(pkg->USE, p, sizeof(Pkg.USE));
 
 			/* checksums. We must have 1 or the other unless --*/
-			if (strcmp(buf, "MD5:") == 0)
+			if (strcmp(buf, "MD5") == 0)
 				strncpy(pkg->MD5, p, sizeof(Pkg.MD5));
-			if (strcmp(buf, "SHA1:") == 0)
+			if (strcmp(buf, "SHA1") == 0)
 				strncpy(pkg->SHA1, p, sizeof(Pkg.SHA1));
 		}
 	}
@@ -1662,18 +1662,18 @@ find_binpkg(const char *name)
 			}
 			continue;
 		}
+
 		if ((p = strchr(buf, '\n')) != NULL)
 			*p = 0;
-
 		if ((p = strchr(buf, ':')) == NULL)
 			continue;
-		if ((p = strchr(buf, ' ')) == NULL)
+		if (p[1] != ' ')
 			continue;
 		*p = 0;
-		++p;
+		p += 2;
 
 		if (*buf) {
-			if (strcmp(buf, "CPV:") == 0) {
+			if (strcmp(buf, "CPV") == 0) {
 				depend_atom *atom;
 				if ((atom = atom_explode(p)) != NULL) {
 					snprintf(buf, sizeof(buf), "%s-%s", atom->PN, atom->PV);
@@ -1684,9 +1684,9 @@ find_binpkg(const char *name)
 					atom_implode(atom);
 				}
 			}
-			if (strcmp(buf, "PF:") == 0)
+			if (strcmp(buf, "PF") == 0)
 				strncpy(PF, p, sizeof(PF));
-			if (strcmp(buf, "CATEGORY:") == 0)
+			if (strcmp(buf, "CATEGORY") == 0)
 				strncpy(CATEGORY, p, sizeof(CATEGORY));
 		}
 	}
@@ -1731,41 +1731,41 @@ parse_packages(queue *todo)
 			memset(&Pkg, 0, sizeof(Pkg));
 			continue;
 		}
+
 		if ((p = strchr(buf, '\n')) != NULL)
 			*p = 0;
-
 		if ((p = strchr(buf, ':')) == NULL)
 			continue;
-		if ((p = strchr(buf, ' ')) == NULL)
+		if (p[1] != ' ')
 			continue;
 		*p = 0;
-		++p;
+		p += 2;
 
 		switch (*buf) {
 			case 'U':
-				if (strcmp(buf, "USE:") == 0) strncpy(Pkg.USE, p, sizeof(Pkg.USE));
+				if (strcmp(buf, "USE") == 0) strncpy(Pkg.USE, p, sizeof(Pkg.USE));
 				break;
 			case 'P':
-				if (strcmp(buf, "PF:") == 0) strncpy(Pkg.PF, p, sizeof(Pkg.PF));
+				if (strcmp(buf, "PF") == 0) strncpy(Pkg.PF, p, sizeof(Pkg.PF));
 				break;
 			case 'S':
-				if (strcmp(buf, "SIZE:") == 0) Pkg.SIZE = atol(p);
-				if (strcmp(buf, "SLOT:") == 0) strncpy(Pkg.SLOT, p, sizeof(Pkg.SLOT));
-				if (strcmp(buf, "SHA1:") == 0) strncpy(Pkg.SHA1, p, sizeof(Pkg.SHA1));
+				if (strcmp(buf, "SIZE") == 0) Pkg.SIZE = atol(p);
+				if (strcmp(buf, "SLOT") == 0) strncpy(Pkg.SLOT, p, sizeof(Pkg.SLOT));
+				if (strcmp(buf, "SHA1") == 0) strncpy(Pkg.SHA1, p, sizeof(Pkg.SHA1));
 				break;
 			case 'M':
-				if (strcmp(buf, "MD5:") == 0) strncpy(Pkg.MD5, p, sizeof(Pkg.MD5));
+				if (strcmp(buf, "MD5") == 0) strncpy(Pkg.MD5, p, sizeof(Pkg.MD5));
 				break;
 			case 'R':
-				if (strcmp(buf, "REPO:") == 0) strncpy(Pkg.REPO, p, sizeof(Pkg.REPO));
-				if (strcmp(buf, "RDEPEND:") == 0) strncpy(Pkg.RDEPEND, p, sizeof(Pkg.RDEPEND));
+				if (strcmp(buf, "REPO") == 0) strncpy(Pkg.REPO, p, sizeof(Pkg.REPO));
+				if (strcmp(buf, "RDEPEND") == 0) strncpy(Pkg.RDEPEND, p, sizeof(Pkg.RDEPEND));
 				break;
 			case 'L':
-				if (strcmp(buf, "LICENSE:") == 0) strncpy(Pkg.LICENSE, p, sizeof(Pkg.LICENSE));
+				if (strcmp(buf, "LICENSE") == 0) strncpy(Pkg.LICENSE, p, sizeof(Pkg.LICENSE));
 				break;
 			case 'C':
-				if (strcmp(buf, "CATEGORY:") == 0) strncpy(Pkg.CATEGORY, p, sizeof(Pkg.CATEGORY));
-				if (strcmp(buf, "CPV:") == 0) {
+				if (strcmp(buf, "CATEGORY") == 0) strncpy(Pkg.CATEGORY, p, sizeof(Pkg.CATEGORY));
+				if (strcmp(buf, "CPV") == 0) {
 					depend_atom *atom;
 					if ((atom = atom_explode(p)) != NULL) {
 						if (atom->PR_int)
@@ -1778,7 +1778,7 @@ parse_packages(queue *todo)
 				}
 				break;
 			case 'D':
-				if (strcmp(buf, "DESC:") == 0) strncpy(Pkg.DESC, p, sizeof(Pkg.DESC));
+				if (strcmp(buf, "DESC") == 0) strncpy(Pkg.DESC, p, sizeof(Pkg.DESC));
 				break;
 			default:
 				break;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     8db61f8ea34c8b306aca3518c4a4d4e6ca674b4f
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 23 22:52:25 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Feb 23 22:52:25 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=8db61f8e

qmerge: drop unused lineno var

---
 qmerge.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 3281424..314a114 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1700,7 +1700,6 @@ parse_packages(queue *todo)
 	FILE *fp;
 	size_t buflen;
 	char *buf, *p;
-	long lineno = 0;
 	struct pkg_t Pkg;
 
 	fp = open_binpkg_index();
@@ -1709,7 +1708,6 @@ parse_packages(queue *todo)
 
 	buf = NULL;
 	while (getline(&buf, &buflen, fp) != -1) {
-		lineno++;
 		if (*buf == '\n') {
 			if ((strlen(Pkg.PF) > 0) && (strlen(Pkg.CATEGORY) > 0)) {
 				struct pkg_t *pkg = xmalloc(sizeof(*pkg));


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     8c6955ca99d10ebae0b7431c3ec572f55b9daa6f
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 22 20:34:04 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Feb 22 20:34:04 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=8c6955ca

qmerge: drop --nomd5 flag

---
 qmerge.c | 9 +--------
 1 file changed, 1 insertion(+), 8 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 7556b4b..3281424 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -35,7 +35,7 @@
 
 int old_repo = 0;
 
-#define QMERGE_FLAGS "fFsKUpuyO5" COMMON_FLAGS
+#define QMERGE_FLAGS "fFsKUpuyO" COMMON_FLAGS
 static struct option const qmerge_long_opts[] = {
 	{"fetch",   no_argument, NULL, 'f'},
 	{"force",   no_argument, NULL, 'F'},
@@ -46,7 +46,6 @@ static struct option const qmerge_long_opts[] = {
 	{"update",  no_argument, NULL, 'u'},
 	{"yes",     no_argument, NULL, 'y'},
 	{"nodeps",  no_argument, NULL, 'O'},
-	{"nomd5",   no_argument, NULL, '5'},
 	{"debug",   no_argument, NULL, 128},
 	COMMON_LONG_OPTS
 };
@@ -60,7 +59,6 @@ static const char * const qmerge_opts_help[] = {
 	"Update only",
 	"Don't prompt before overwriting",
 	"Don't merge dependencies",
-	"Don't verify MD5 digest of files",
 	"Run shell funcs with `set -x`",
 	COMMON_OPTS_HELP
 };
@@ -72,7 +70,6 @@ char install = 0;
 char uninstall = 0;
 char force_download = 0;
 char follow_rdepends = 1;
-char nomd5 = 0;
 char qmerge_strict = 0;
 char update_only = 0;
 bool debug = false;
@@ -1254,9 +1251,6 @@ pkg_verify_checksums(char *fname, const struct pkg_t *pkg, const depend_atom *at
 	char *hash = NULL;
 	int ret = 0;
 
-	if (nomd5)
-		return ret;
-
 	if (pkg->MD5[0]) {
 		if ((hash = (char*) hash_file(fname, HASH_MD5)) == NULL) {
 			errf("hash is NULL for %s", fname);
@@ -1898,7 +1892,6 @@ int qmerge_main(int argc, char **argv)
 			case 'u': update_only = 1;
 			case 'y': interactive = 0; break;
 			case 'O': follow_rdepends = 0; break;
-			case '5': nomd5 = 1; break;
 			case 128: debug = true; break;
 			COMMON_GETOPTS_CASES(qmerge)
 		}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     3ab82ae3e1773915e25b3a3dafe57ef97375982a
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 23 22:48:29 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Feb 23 22:48:35 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=3ab82ae3

fix debug/symlinks targets to work in parallel

---
 Makefile | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 4e65396..137b505 100644
--- a/Makefile
+++ b/Makefile
@@ -62,8 +62,8 @@ CPPFLAGS  += $(APP_FLAGS)
 all: q
 	@true
 
-debug:
-	$(MAKE) CFLAGS="$(CFLAGS) $(DBG_CFLAGS)" clean symlinks
+debug: clean
+	$(MAKE) CFLAGS="$(CFLAGS) $(DBG_CFLAGS)" symlinks
 	@-scanelf -o /dev/null -BXxz permsx q
 
 q: $(SRC) libq/*.c *.h libq/*.h
@@ -123,7 +123,7 @@ endif
 man: q
 	./man/mkman.py
 
-symlinks: all
+symlinks: q
 	./q --install
 
 -include .depend


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     667542314e66dda0897778b0ce75dd56d9adddc7
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 22 08:57:22 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Feb 22 08:57:22 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=66754231

qmerge: push down global Pkg state to funcs that use it

---
 qmerge.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 44b2f47..f713a7f 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -95,7 +95,7 @@ struct pkg_t {
 	size_t SIZE;
 	char USE[BUFSIZ];
 	char REPO[64];
-} Pkg;
+};
 
 struct llist_char_t {
 	char *data;
@@ -1579,6 +1579,7 @@ grab_binpkg_info(const char *name)
 	char *p;
 	depend_atom *atom;
 
+	struct pkg_t Pkg;
 	struct pkg_t *pkg = xzalloc(sizeof(struct pkg_t));
 	struct pkg_t *rpkg = xzalloc(sizeof(struct pkg_t));
 
@@ -1678,6 +1679,7 @@ find_binpkg(const char *name)
 	FILE *fp;
 	char buf[BUFSIZ];
 	char *p;
+	struct pkg_t Pkg;
 	char PF[sizeof(Pkg.PF)];
 	char CATEGORY[sizeof(Pkg.CATEGORY)];
 
@@ -1759,6 +1761,7 @@ parse_packages(queue *todo)
 	size_t buflen;
 	char *buf, *p;
 	long lineno = 0;
+	struct pkg_t Pkg;
 
 	fp = open_binpkg_index();
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     558fa6e799b8ffd919cf592b8d5802db13e05521
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 22 08:59:14 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Feb 22 08:59:14 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=558fa6e7

qmerge: run search in interactive mode

This mode never actually modifies anything, so no need to run it twice.

---
 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index f713a7f..c58e4f2 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1959,7 +1959,7 @@ int qmerge_main(int argc, char **argv)
 		switch (i) {
 			case 'f': force_download = 1; break;
 			case 'F': force_download = 2; break;
-			case 's': search_pkgs = 1; break;
+			case 's': search_pkgs = 1; interactive = 0; break;
 			/* case 'i': case 'g': */
 			case 'K': install = 1; break;
 			case 'U': uninstall = 1; break;


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     029a18c5e4ab408c7eadc10693bcf7056b8ab171
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 22 18:05:49 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Feb 22 18:05:49 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=029a18c5

qdepends: avoid warning when DEBUG is enabled

---
 qdepends.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/qdepends.c b/qdepends.c
index 648d8e2..bcdeaa5 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -76,7 +76,8 @@ int qdepends_main_vdb(const char *depend_file, int argc, char **argv);
 int qdepends_vdb_deep(const char *depend_file, const char *query);
 
 #ifdef EBUG
-_q_static void print_word(const char *ptr, size_t num)
+void print_word(const char *ptr, size_t num);
+void print_word(const char *ptr, size_t num)
 {
 	while (num--)
 		printf("%c", *ptr++);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     c77ee400e1be0c40d5fecdb85c168756d258f4d9
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 22 09:09:37 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Feb 22 09:09:37 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=c77ee400

qmerge: use free_sets helper

---
 qmerge.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index e125258..b2ef9a7 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -995,13 +995,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	}
 
 	/* Clean up the package state */
-	while (objs) {
-		queue *q = objs;
-		objs = q->next;
-		free(q->name);
-		free(q->item);
-		free(q);
-	}
+	free_sets(objs);
 	free(D);
 	free(T);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-24  1:26 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-24  1:26 UTC (permalink / raw
  To: gentoo-commits

commit:     b6e7aef905639342dea38511ccc413eaf9f9dbe8
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Feb 22 08:55:01 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Feb 22 08:55:01 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=b6e7aef9

debug: build with more sanitize modes

---
 Makefile | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Makefile b/Makefile
index 6c05dbd..4e65396 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ CFLAGS    ?= -O2 -g -pipe
 CFLAGS    += -std=gnu99
 CPPFLAGS  ?=
 CPPFLAGS  += -DENABLE_NLS=$(call istrue,$(NLS))
-DBG_CFLAGS = -O0 -DEBUG -g3 -ggdb -fno-pie $(call check_gcc, -fsanitize=address)
+DBG_CFLAGS = -O0 -DEBUG -g3 -ggdb -fno-pie $(call check_gcc, -fsanitize=address -fsanitize=leak -fsanitize=undefined)
 #CFLAGS   += -Os -DOPTIMIZE_FOR_SIZE=2 -falign-functions=2 -falign-jumps=2 -falign-labels=2 -falign-loops=2
 #LDFLAGS  := -pie
 LIBADD    += $(shell echo | $(CC) -dM -E - | grep -q ' __FreeBSD__' && echo '-lkvm')


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-21 18:06 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-21 18:06 UTC (permalink / raw
  To: gentoo-commits

commit:     b23f8bb7a222f06d89918601778581f21413fc38
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 21 18:01:09 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Feb 21 18:01:09 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=b23f8bb7

qmerge: fix use-after-freed error

---
 qmerge.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index e4b8f96..44b2f47 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1197,9 +1197,9 @@ pkg_unmerge(const char *cat, const char *pkgname, queue *keep)
 		qprintf("%s%s%s %s%s%s/\n", rm ? YELLOW : GREEN, rm ? "---" : "<<<",
 			NORM, DKBLUE, dir, NORM);
 
+		dirs = dirs->next;
 		free(list->data);
 		free(list);
-		dirs = dirs->next;
 	}
 
 	freeargv(cp_argc, cp_argv);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-21  0:00 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-21  0:00 UTC (permalink / raw
  To: gentoo-commits

commit:     d2e2f768505412f8c4bad0e799eaaffc694c8949
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 21 00:01:56 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Feb 21 00:01:56 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=d2e2f768

quse: various style fixes

No real functional changes in here.

---
 quse.c | 48 ++++++++++++++++++++++++------------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/quse.c b/quse.c
index 875733c..534cf41 100644
--- a/quse.c
+++ b/quse.c
@@ -36,11 +36,10 @@ static const char * const quse_opts_help[] = {
 };
 #define quse_usage(ret) usage(ret, QUSE_FLAGS, quse_long_opts, quse_opts_help, lookup_applet_idx("quse"))
 
-int quse_describe_flag(unsigned int ind, unsigned int argc, char **argv);
-
 char quse_name_only = 0;
 
-static void print_highlighted_use_flags(char *string, int ind, int argc, char **argv)
+static void
+print_highlighted_use_flags(char *string, int ind, int argc, char **argv)
 {
 	char *str, *p;
 	char buf[BUFSIZ];
@@ -79,7 +78,8 @@ static void print_highlighted_use_flags(char *string, int ind, int argc, char **
 	}
 }
 
-int quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
+static int
+quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 {
 #define NUM_SEARCH_FILES ARRAY_SIZE(search_files)
 	size_t buflen;
@@ -91,7 +91,8 @@ int quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 	DIR *d;
 	struct dirent *de;
 
-	buflen = _Q_PATH_MAX;
+	/* pick 1000 arbitrarily long enough for all files under desc/ */
+	buflen = strlen(portdir) + 1000;
 	buf = xmalloc(buflen);
 
 	for (i = 0; i < NUM_SEARCH_FILES; ++i) {
@@ -117,8 +118,8 @@ int quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 				switch (f) {
 					case 0: /* Global use.desc */
 						if (!strncmp(buf, argv[i], s))
-							if (buf[s] == ' ' && buf[s+1] == '-') {
-								printf(" %sglobal%s:%s%s%s: %s\n", BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
+							if (buf[s] == ' ' && buf[s + 1] == '-') {
+								printf(" %sglobal%s:%s%s%s: %s\n", BOLD, NORM, BLUE, argv[i], NORM, buf + s + 3);
 								goto skip_file;
 							}
 						break;
@@ -128,9 +129,9 @@ int quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 							break;
 						++p;
 						if (!strncmp(p, argv[i], s)) {
-							if (p[s] == ' ' && p[s+1] == '-') {
+							if (p[s] == ' ' && p[s + 1] == '-') {
 								*p = '\0';
-								printf(" %slocal%s:%s%s%s:%s%s%s %s\n", BOLD, NORM, BLUE, argv[i], NORM, BOLD, buf, NORM, p+s+3);
+								printf(" %slocal%s:%s%s%s:%s%s%s %s\n", BOLD, NORM, BLUE, argv[i], NORM, BOLD, buf, NORM, p + s + 3);
 							}
 						}
 						break;
@@ -144,12 +145,12 @@ int quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 				}
 			}
 
-skip_file:
+ skip_file:
 			rewind(fp[f]);
 		}
 	}
 
-	for (f=0; f < NUM_SEARCH_FILES; ++f)
+	for (f = 0; f < NUM_SEARCH_FILES; ++f)
 		if (fp[f] != NULL)
 			fclose(fp[f]);
 
@@ -185,13 +186,13 @@ skip_file:
 				*p = '\0';
 
 			if ((p = strchr(buf, '-')) == NULL) {
-invalid_line:
+ invalid_line:
 				warn("Invalid line in '%s': %s", de->d_name, buf);
 				continue;
 			}
 			while (p[-1] != ' ' && p[1] != ' ') {
 				/* maybe the flag has a '-' in it ... */
-				if ((p = strchr(p+1, '-')) == NULL)
+				if ((p = strchr(p + 1, '-')) == NULL)
 					goto invalid_line;
 			}
 			p[-1] = '\0';
@@ -303,7 +304,7 @@ int quse_main(int argc, char **argv)
 					}
 				}
 #ifdef THIS_SUCKS
-				if ((p = strrchr(&buf0[search_len+1], '\\')) != NULL) {
+				if ((p = strrchr(&buf0[search_len + 1], '\\')) != NULL) {
 
 				multiline:
 					*p = ' ';
@@ -323,13 +324,13 @@ int quse_main(int argc, char **argv)
 #else
 				remove_extra_space(buf0);
 #endif
-				while ((p = strrchr(&buf0[search_len+1], '"')) != NULL)  *p = 0;
-				while ((p = strrchr(&buf0[search_len+1], '\'')) != NULL) *p = 0;
-				while ((p = strrchr(&buf0[search_len+1], '\\')) != NULL) *p = ' ';
+				while ((p = strrchr(&buf0[search_len + 1], '"')) != NULL)  *p = 0;
+				while ((p = strrchr(&buf0[search_len + 1], '\'')) != NULL) *p = 0;
+				while ((p = strrchr(&buf0[search_len + 1], '\\')) != NULL) *p = ' ';
 
 				if (verbose && warned == 0) {
 					if ((strchr(buf0, '$') != NULL) || (strchr(buf0, '\\') != NULL)) {
-						warned=1;
+						warned = 1;
 						warn("# Line %d of %s has an annoying %s", lineno, ebuild, buf0);
 					}
 				}
@@ -345,14 +346,14 @@ int quse_main(int argc, char **argv)
 					ok = 0;
 					if (regexp_matching) {
 						for (i = optind; i < argc; ++i) {
-							if (rematch(argv[i], &buf0[search_len+1], REG_NOSUB) == 0) {
+							if (rematch(argv[i], &buf0[search_len + 1], REG_NOSUB) == 0) {
 								ok = 1;
 								break;
 							}
 						}
 					} else {
 						remove_extra_space(buf0);
-						strcpy(buf1, &buf0[search_len+1]);
+						strcpy(buf1, &buf0[search_len + 1]);
 
 						for (i = (size_t) optind; i < argc && argv[i] != NULL; i++) {
 							if (strcmp(buf1, argv[i]) == 0) {
@@ -372,9 +373,8 @@ int quse_main(int argc, char **argv)
 							strcpy(buf1, buf2);
 							if (strchr(buf1, ' ') == NULL)
 								for (i = (size_t) optind; i < argc && argv[i] != NULL; i++) {
-									if (strcmp(buf1, argv[i]) == 0) {
+									if (strcmp(buf1, argv[i]) == 0)
 										ok = 1;
-									}
 								}
 						}
 					}
@@ -384,12 +384,12 @@ int quse_main(int argc, char **argv)
 						printf("%s %s %s ", *user ? user : "MISSING", *revision ? revision : "MISSING", *date ? date : "MISSING");
 
 					printf("%s%s%s ", CYAN, ebuild, NORM);
-					print_highlighted_use_flags(&buf0[search_len+1], optind, argc, argv);
+					print_highlighted_use_flags(&buf0[search_len + 1], optind, argc, argv);
 					puts(NORM);
 					if (verbose > 1) {
 						char **ARGV = NULL;
 						int ARGC = 0;
-						makeargv(&buf0[search_len+1], &ARGC, &ARGV);
+						makeargv(&buf0[search_len + 1], &ARGC, &ARGV);
 						if (ARGC > 0) {
 							quse_describe_flag(1, ARGC, ARGV);
 							for (i = 0; i < ARGC; i++)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-21  0:00 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-21  0:00 UTC (permalink / raw
  To: gentoo-commits

commit:     39c083580b63e1e80d952e91ae3155739034632b
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 20 23:54:38 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Feb 20 23:54:38 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=39c08358

quse: drop lang.desc support

This file hasn't been generated in a long time since it was migrated
to the desc/linguas.desc file.

---
 quse.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/quse.c b/quse.c
index 8ee37f4..825fba3 100644
--- a/quse.c
+++ b/quse.c
@@ -86,7 +86,7 @@ int quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 	char *buf, *p;
 	unsigned int i, f;
 	size_t s;
-	const char *search_files[] = { "use.desc", "use.local.desc", "arch.list", "lang.desc" };
+	const char * const search_files[] = { "use.desc", "use.local.desc", "arch.list", };
 	FILE *fp[NUM_SEARCH_FILES];
 	DIR *d;
 	struct dirent *de;
@@ -97,8 +97,7 @@ int quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 	for (i = 0; i < NUM_SEARCH_FILES; ++i) {
 		snprintf(buf, buflen, "%s/profiles/%s", portdir, search_files[i]);
 		if ((fp[i] = fopen(buf, "r")) == NULL)
-			if (strcmp(search_files[i], "lang.desc") != 0)
-				warnp("skipping %s", search_files[i]);
+			warnp("skipping %s", search_files[i]);
 	}
 
 	for (i = ind; i < argc; i++) {
@@ -142,14 +141,6 @@ int quse_describe_flag(unsigned int ind, unsigned int argc, char **argv)
 							goto skip_file;
 						}
 						break;
-
-					case 3: /* Languages lang.desc */
-						if (!strncmp(buf, argv[i], s))
-							if (buf[s] == ' ' && buf[s+1] == '-') {
-								printf(" %slang%s:%s%s%s: %s lingua\n", BOLD, NORM, BLUE, argv[i], NORM, buf+s+3);
-								goto skip_file;
-							}
-						break;
 				}
 			}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-20 22:28 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-20 22:28 UTC (permalink / raw
  To: gentoo-commits

commit:     4e9fab3118078f618aceaa5f50131cc709701e84
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 20 22:30:10 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Feb 20 22:30:46 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=4e9fab31

qcheck: add a short option for --skip-protected

Reported-by: Ben Kohler <bkohler <AT> gmail.com>
URL: https://bugs.gentoo.org/505122

---
 qcheck.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/qcheck.c b/qcheck.c
index 0a98398..86d7aa6 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -8,7 +8,7 @@
 
 #ifdef APPLET_qcheck
 
-#define QCHECK_FLAGS "aes:uABHTp" COMMON_FLAGS
+#define QCHECK_FLAGS "aes:uABHTPp" COMMON_FLAGS
 static struct option const qcheck_long_opts[] = {
 	{"all",            no_argument, NULL, 'a'},
 	{"exact",          no_argument, NULL, 'e'},
@@ -18,7 +18,7 @@ static struct option const qcheck_long_opts[] = {
 	{"badonly",        no_argument, NULL, 'B'},
 	{"nohash",         no_argument, NULL, 'H'},
 	{"nomtime",        no_argument, NULL, 'T'},
-	{"skip-protected", no_argument, NULL, 128},
+	{"skip-protected", no_argument, NULL, 'P'},
 	{"prelink",        no_argument, NULL, 'p'},
 	COMMON_LONG_OPTS
 };
@@ -392,7 +392,7 @@ int qcheck_main(int argc, char **argv)
 		case 'B': state.bad_only = true; break;
 		case 'H': state.chk_hash = false; break;
 		case 'T': state.chk_mtime = false; break;
-		case 128: state.chk_config_protect = false; break;
+		case 'P': state.chk_config_protect = false; break;
 		case 'p': state.undo_prelink = prelink_available(); break;
 		}
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2015-02-19  7:49 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2015-02-19  7:49 UTC (permalink / raw
  To: gentoo-commits

commit:     502518899f60bde86ba2d2e5c0e400d7142d2096
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 19 07:48:53 2015 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Feb 19 07:48:53 2015 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=50251889

qmerge: add usev & nonfatal

---
 qmerge.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/qmerge.c b/qmerge.c
index 165caa9..e4b8f96 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -444,7 +444,8 @@ pkg_run_func(const char *vdb_path, const char *phases, const char *func, const c
 		/* best_version() */
 		"use() { useq \"$@\"; }\n"
 		"usex() { useq \"$1\" && echo \"${2-yes}$4\" || echo \"${3-no}$5\"; }\n"
-		"useq() { hasq \"$1\" $USE; }\n"
+		"useq() { hasq \"$1\" ${USE}; }\n"
+		"usev() { hasv \"$1\" ${USE}; }\n"
 		"has() { hasq \"$@\"; }\n"
 		"hasq() { local h=$1; shift; case \" $* \" in *\" $h \"*) return 0;; *) return 1;; esac; }\n"
 		"hasv() { hasq \"$@\" && echo \"$1\"; }\n"
@@ -454,8 +455,11 @@ pkg_run_func(const char *vdb_path, const char *phases, const char *func, const c
 		"eqawarn() { elog \"QA: \"\"$@\"; }\n"
 		"eerror() { elog \"$@\"; }\n"
 		"die() { eerror \"$@\"; exit 1; }\n"
+		/* TODO: This should suppress `die` */
+		"nonfatal() { \"$@\"; }\n"
 		"ebegin() { printf ' * %%b ...' \"$*\"; }\n"
 		"eend() { local r=${1:-$?}; [ $# -gt 0 ] && shift; [ $r -eq 0 ] && echo ' [ ok ]' || echo \" $* \"'[ !! ]'; return $r; }\n"
+		/* TODO: This should be fatal upon error */
 		"emake() { ${MAKE:-make} ${MAKEOPTS} \"$@\"; }\n"
 		/* Unpack the env if need be */
 		"[ -e '%1$s/environment' ] || { bzip2 -dc '%1$s/environment.bz2' > '%1$s/environment' || exit 1; }\n"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-10-19 16:56 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-10-19 16:56 UTC (permalink / raw
  To: gentoo-commits

commit:     4d13a78af43afe479799d2753254802c5f39740a
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Oct 19 16:56:04 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Oct 19 16:56:04 2014 +0000
URL:        http://sources.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=4d13a78a

gitignore: update

---
 .gitignore | 23 +++++++++++++++++------
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore
index 79ad336..769c4a1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,6 +1,11 @@
 *bz2
 *~
-*.o
+*.[adio]
+*.l[ao]
+*.gdb
+*.pyc
+*.deps
+*.libs
 
 *.patch
 *.orig
@@ -9,14 +14,25 @@
 /portage-utils-*
 contrib
 
+a.out*
+lib*.so*
+core
+.gdb_history
+.gdbinit
+
 aclocal.m4
 autom4te.cache
 build
+config.cache
 config.h
 config.h.in
+config.log
+config.status
 configure
 autotools
+libtool
 Makefile.in
+stamp-h1
 
 /*.old.c
 /q
@@ -35,8 +51,3 @@ Makefile.in
 /qsize
 /quse
 /qxpak
-
-a.out
-core
-.gdb_history
-.gdbinit


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-06-16 18:01 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-06-16 18:01 UTC (permalink / raw
  To: gentoo-commits

commit:     119ad4c193f5689953a32babbc6a3a7eed041f3a
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Jun 16 17:49:23 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Jun 16 17:49:23 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=119ad4c1

import more modules from gnulib to handle older systems

URL: https://bugs.gentoo.org/513484

---
 Makefile.am | 12 ++++++++++++
 autogen.sh  |  4 ++++
 porting.h   |  1 +
 3 files changed, 17 insertions(+)

diff --git a/Makefile.am b/Makefile.am
index 14bc649..3a33bbe 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -179,6 +179,14 @@ EXTRA_DIST += \
 	tests/qdepends/list04.good \
 	tests/qdepends/list05.good \
 	tests/qdepends/list06.good \
+	tests/qdepends/list07.good \
+	tests/qdepends/list08.good \
+	tests/qdepends/root/app-arch/cpio-2.11/CONTENTS \
+	tests/qdepends/root/app-arch/cpio-2.11/SLOT \
+	tests/qdepends/root/app-arch/cpio-2.11/repository \
+	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/DEPEND \
+	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/RDEPEND \
+	tests/qdepends/root/x11-apps/xdm-1.1.11-r3/USE \
 	tests/qfile/Makefile \
 	tests/qfile/dotest \
 	tests/qlist/Makefile \
@@ -196,6 +204,7 @@ EXTRA_DIST += \
 	tests/qlist/list11.good \
 	tests/qlist/list12.good \
 	tests/qlist/list13.good \
+	tests/qlist/list14.good \
 	tests/qlist/root/-merge-foo/CONTENTS \
 	tests/qlist/root/a-b/a-0/CONTENTS \
 	tests/qlist/root/a-b/a-0/SLOT \
@@ -209,6 +218,9 @@ EXTRA_DIST += \
 	tests/qlist/root/cat/pkg-1/CONTENTS \
 	tests/qlist/root/cat/pkg-1/SLOT \
 	tests/qlist/root/cat/pkg-1/repository \
+	tests/qlist/root/cat/sub-2/CONTENTS \
+	tests/qlist/root/cat/sub-2/SLOT \
+	tests/qlist/root/cat/sub-2/repository \
 	tests/qlist/root/sys-fs/mtools-4.0.13/CONTENTS \
 	tests/qlist/root/sys-fs/mtools-4.0.13/SLOT \
 	tests/qlist/root/sys-fs/mtools-4.0.13/repository \

diff --git a/autogen.sh b/autogen.sh
index 903a00c..622ab16 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -12,22 +12,26 @@ fi
 # reload the gnulib code if possible
 PATH=/usr/local/src/gnu/gnulib:${PATH}
 mods="
+	alloca
 	faccessat
 	fdopendir
 	fstatat
 	futimens
 	getline
+	getopt-posix
 	mkdirat
 	openat
 	progname
 	readlinkat
 	renameat
 	stat-time
+	strcasestr-simple
 	strncat
 	symlinkat
 	sys_stat
 	unlinkat
 	utimensat
+	vasprintf-posix
 "
 v gnulib-tool \
 	--source-base=autotools/gnulib --m4-base=autotools/m4 \

diff --git a/porting.h b/porting.h
index 352d3bf..3235542 100644
--- a/porting.h
+++ b/porting.h
@@ -25,6 +25,7 @@
 #define _LINUX_SOURCE_COMPAT
 #endif
 
+#include <alloca.h>
 #include <assert.h>
 #include <ctype.h>
 #include <dirent.h>


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-16  6:34 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-16  6:34 UTC (permalink / raw
  To: gentoo-commits

commit:     8e5479494a1df4b326ca9715ee72897d2b98b06f
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 16 06:22:38 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Mar 16 06:22:38 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=8e547949

q: fix up --install a little

Update the outdated chdir error message, and use O_PATH with the dirfd.

---
 q.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/q.c b/q.c
index 849f7ad..394a035 100644
--- a/q.c
+++ b/q.c
@@ -95,7 +95,7 @@ int q_main(int argc, char **argv)
 
 	if (install) {
 		char buf[_Q_PATH_MAX];
-		const char *prog;
+		const char *prog, *dir;
 		ssize_t rret;
 		int fd, ret;
 
@@ -115,9 +115,10 @@ int q_main(int argc, char **argv)
 			buf[rret] = '\0';
 
 		prog = basename(buf);
-		fd = open(dirname(buf), O_RDONLY|O_CLOEXEC);
+		dir = dirname(buf);
+		fd = open(dir, O_RDONLY|O_CLOEXEC|O_PATH);
 		if (fd < 0) {
-			warnfp("chdir(%s) failed", buf);
+			warnfp("open(%s) failed", dir);
 			return 1;
 		}
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-16  6:34 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-16  6:34 UTC (permalink / raw
  To: gentoo-commits

commit:     260d67e07284b53e4d982e071d8463187566f8b2
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 16 06:34:29 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Mar 16 06:34:29 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=260d67e0

qpkg: document the chdir() usage

---
 qpkg.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qpkg.c b/qpkg.c
index 512a4b9..4a5d9fd 100644
--- a/qpkg.c
+++ b/qpkg.c
@@ -348,8 +348,6 @@ int qpkg_main(int argc, char **argv)
 	if (argc == optind)
 		qpkg_usage(EXIT_FAILURE);
 
-	xchdir(portroot);
-
 	/* setup temp dirs */
 	i = 0;
 	bindir = qpkg_get_bindir();
@@ -368,6 +366,10 @@ retry_mkdir:
 				errp("could not chmod(0750) temp bindir '%s'", bindir);
 	}
 
+	/* we have to change to the root so that we can feed the full paths
+	 * to tar when we create the binary package. */
+	xchdir(portroot);
+
 	/* first process any arguments which point to /var/db/pkg */
 	pkgs_made = 0;
 	s = strlen(portvdb);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-16  6:14 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-16  6:14 UTC (permalink / raw
  To: gentoo-commits

commit:     8f59ad7b9e732fa41f29c9c23ea42f68546d32ec
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 16 06:07:49 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Mar 16 06:07:49 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=8f59ad7b

qlist: speed up -U flag slightly

No need to clear the whole buffer when we use this as a normal C string.

---
 qlist.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/qlist.c b/qlist.c
index 0b0714e..fa5e652 100644
--- a/qlist.c
+++ b/qlist.c
@@ -56,7 +56,7 @@ static char *grab_pkg_umap(const char *CAT, const char *PV)
 	if ((use = grab_vdb_item("USE", CAT, PV)) == NULL)
 		return NULL;
 
-	memset(umap, 0, sizeof(umap)); /* reset the buffer */
+	umap[0] = '\0'; /* reset the buffer */
 
 	/* grab_vdb is a static function so save it to memory right away */
 	makeargv(use, &use_argc, &use_argv);
@@ -85,8 +85,7 @@ static char *grab_pkg_umap(const char *CAT, const char *PV)
 		sets = del_set(use_argv[i], sets, &ok);
 		sets = add_set(use_argv[i], use_argv[i], sets);
 	}
-	memset(umap, 0, sizeof(umap)); /* reset the buffer */
-	strcpy(umap, "");
+	umap[0] = '\0'; /* reset the buffer */
 	for (ll = sets; ll != NULL; ll = ll->next) {
 		strncat(umap, ll->name, sizeof(umap)-strlen(umap)-1);
 		strncat(umap, " ", sizeof(umap)-strlen(umap)-1);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-16  6:14 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-16  6:14 UTC (permalink / raw
  To: gentoo-commits

commit:     b979418e34137c8044614bcbf3a2b25f775f353e
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 16 06:10:34 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Mar 16 06:10:34 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=b979418e

qlist: fix processing of IUSE

Stripping out all + and - chars is wrong as it means we turn "static-libs"
into "static libs".  Make sure we nuke these only when they're the first
char in the flag.

---
 qlist.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/qlist.c b/qlist.c
index 0ffa716..1373361 100644
--- a/qlist.c
+++ b/qlist.c
@@ -63,9 +63,11 @@ static char *grab_pkg_umap(q_vdb_pkg_ctx *pkg_ctx)
 	umap[0] = '\0'; /* reset the buffer */
 
 	makeargv(use, &use_argc, &use_argv);
+	/* strip out possible leading +/- flags in IUSE */
 	for (i = 0; i < (int)strlen(iuse); i++)
 		if (iuse[i] == '+' || iuse[i] == '-')
-			iuse[i] = ' ';
+			if (i == 0 || iuse[i - 1] == ' ')
+				iuse[i] = ' ';
 	makeargv(iuse, &iuse_argc, &iuse_argv);
 	for (u = 1; u < use_argc; u++) {
 		for (i = 1; i < iuse_argc; i++) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-16  6:14 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-16  6:14 UTC (permalink / raw
  To: gentoo-commits

commit:     f09d626416e60d9f87dc1aaf8bb59e1638b483e0
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Mar 16 06:09:12 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Mar 16 06:09:12 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=f09d6264

qlist: rewrite -U option to leverage q_vdb_pkg_eat

This lets us kill off most consumers of grab_vdb_item and use the new
vdb API which in turn makes the code cleaner and robust -- it can handle
any sized input file now and leverages the openat helpers.

---
 qlist.c | 42 +++++++++++++++++++++---------------------
 1 file changed, 21 insertions(+), 21 deletions(-)

diff --git a/qlist.c b/qlist.c
index fa5e652..0ffa716 100644
--- a/qlist.c
+++ b/qlist.c
@@ -42,39 +42,40 @@ static const char * const qlist_opts_help[] = {
 };
 #define qlist_usage(ret) usage(ret, QLIST_FLAGS, qlist_long_opts, qlist_opts_help, lookup_applet_idx("qlist"))
 
-static char *grab_pkg_umap(const char *CAT, const char *PV)
+static char *grab_pkg_umap(q_vdb_pkg_ctx *pkg_ctx)
 {
 	static char umap[BUFSIZ];
-	char *use = NULL;
-	char *iuse = NULL;
+	static char *use, *iuse;
+	static size_t use_len, iuse_len;
 	int use_argc = 0, iuse_argc = 0;
 	char **use_argv = NULL, **iuse_argv = NULL;
 	queue *ll = NULL;
 	queue *sets = NULL;
 	int i, u;
 
-	if ((use = grab_vdb_item("USE", CAT, PV)) == NULL)
+	q_vdb_pkg_eat(pkg_ctx, "USE", &use, &use_len);
+	if (!use[0])
+		return NULL;
+	q_vdb_pkg_eat(pkg_ctx, "IUSE", &iuse, &iuse_len);
+	if (!iuse[0])
 		return NULL;
 
 	umap[0] = '\0'; /* reset the buffer */
 
-	/* grab_vdb is a static function so save it to memory right away */
 	makeargv(use, &use_argc, &use_argv);
-	if ((iuse = grab_vdb_item("IUSE", CAT, PV)) != NULL) {
-		for (i = 0; i < (int)strlen(iuse); i++)
-			if (iuse[i] == '+' || iuse[i] == '-')
-				iuse[i] = ' ';
-		makeargv(iuse, &iuse_argc, &iuse_argv);
-		for (u = 1; u < use_argc; u++) {
-			for (i = 1; i < iuse_argc; i++) {
-				if (strcmp(use_argv[u], iuse_argv[i]) == 0) {
-					strncat(umap, use_argv[u], sizeof(umap)-strlen(umap)-1);
-					strncat(umap, " ", sizeof(umap)-strlen(umap)-1);
-				}
+	for (i = 0; i < (int)strlen(iuse); i++)
+		if (iuse[i] == '+' || iuse[i] == '-')
+			iuse[i] = ' ';
+	makeargv(iuse, &iuse_argc, &iuse_argv);
+	for (u = 1; u < use_argc; u++) {
+		for (i = 1; i < iuse_argc; i++) {
+			if (strcmp(use_argv[u], iuse_argv[i]) == 0) {
+				strncat(umap, use_argv[u], sizeof(umap)-strlen(umap)-1);
+				strncat(umap, " ", sizeof(umap)-strlen(umap)-1);
 			}
 		}
-		freeargv(iuse_argc, iuse_argv);
 	}
+	freeargv(iuse_argc, iuse_argv);
 	freeargv(use_argc, use_argv);
 
 	/* filter out the dup use flags */
@@ -97,7 +98,7 @@ static char *grab_pkg_umap(const char *CAT, const char *PV)
 	return umap;
 }
 
-static const char *umapstr(char display, const char *cat, const char *name)
+static const char *umapstr(char display, q_vdb_pkg_ctx *pkg_ctx)
 {
 	static char buf[BUFSIZ];
 	char *umap = NULL;
@@ -105,7 +106,7 @@ static const char *umapstr(char display, const char *cat, const char *name)
 	buf[0] = '\0';
 	if (!display)
 		return buf;
-	if ((umap = grab_pkg_umap(cat, name)) == NULL)
+	if ((umap = grab_pkg_umap(pkg_ctx)) == NULL)
 		return buf;
 	rmspace(umap);
 	if (!strlen(umap))
@@ -191,7 +192,6 @@ qlist_match(q_vdb_pkg_ctx *pkg_ctx, const char *name, depend_atom **name_atom, b
 			return false;
 	}
 
-	/* printf("buf=%s:%s\n", buf,grab_vdb_item("SLOT", catname, pkgname)); */
 	if (exact) {
 		int i;
 
@@ -296,7 +296,7 @@ _q_static int qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 				(state->columns ? " " : ""), (state->columns ? atom->PV : ""),
 				NORM, YELLOW, state->show_slots ? ":" : "", state->show_slots ? pkg_ctx->slot : "", NORM,
 				NORM, GREEN, state->show_repo ? "::" : "", state->show_repo ? pkg_ctx->repo : "", NORM,
-				umapstr(state->show_umap, catname, pkgname));
+				umapstr(state->show_umap, pkg_ctx));
 		}
 		if (atom)
 			atom_implode(atom);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-15  6:02 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-15  6:02 UTC (permalink / raw
  To: gentoo-commits

commit:     7edb85827c65468248d3d3352546fc076e822550
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sat Mar 15 05:54:06 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sat Mar 15 05:54:06 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=7edb8582

qdepends: fix assert after eat_file rework

The assert no longer makes sense since the buffer is dynamically
allocated.  Rework the logic to handle any sized buffer.

URL: https://bugs.gentoo.org/504636

---
 qdepends.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index bc51e02..96f757b 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -484,13 +484,16 @@ _q_static int qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	IF_DEBUG(dep_dump_tree(dep_tree));
 
 	if (q_vdb_pkg_eat(pkg_ctx, "USE", &use, &use_len))
-		use[0] = ' ';
+		use[0] = '\0';
 
 	for (ptr = use; *ptr; ++ptr)
 		if (*ptr == '\n' || *ptr == '\t')
 			*ptr = ' ';
-	len = strlen(use);
-	assert(len+1 < sizeof(use));
+	len = ptr - use;
+	if (len == use_len) {
+		use_len += BUFSIZE;
+		use = xrealloc(use, use_len);
+	}
 	use[len] = ' ';
 	use[len+1] = '\0';
 	memmove(use+1, use, len);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-11  4:53 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-11  4:53 UTC (permalink / raw
  To: gentoo-commits

commit:     206a802baa29af093ca086a08f1d9aa5d9c91737
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 11 04:34:36 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Mar 11 04:34:36 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=206a802b

build: use -fsanitize=address when doing a debug build

Will help track down memory errors nicely.

---
 Makefile | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index d202f54..79a19eb 100644
--- a/Makefile
+++ b/Makefile
@@ -20,7 +20,7 @@ CFLAGS    ?= -O2 -g -pipe
 CFLAGS    += -std=gnu99
 CPPFLAGS  ?=
 CPPFLAGS  += -DENABLE_NLS=$(call istrue,$(NLS))
-#CFLAGS   += -DEBUG -g
+DBG_CFLAGS = -O0 -DEBUG -g3 -ggdb -fno-pie $(call check_gcc, -fsanitize=address)
 #CFLAGS   += -Os -DOPTIMIZE_FOR_SIZE=2 -falign-functions=2 -falign-jumps=2 -falign-labels=2 -falign-loops=2
 #LDFLAGS  := -pie
 LIBADD    += $(shell echo | $(CC) -dM -E - | grep -q ' __FreeBSD__' && echo '-lkvm')
@@ -62,7 +62,7 @@ all: q
 	@true
 
 debug:
-	$(MAKE) CFLAGS="$(CFLAGS) -O0 -DEBUG -g3 -ggdb -fno-pie" clean symlinks
+	$(MAKE) CFLAGS="$(CFLAGS) $(DBG_CFLAGS)" clean symlinks
 	@-scanelf -o /dev/null -BXxz permsx q
 
 q: $(SRC) libq/*.c *.h libq/*.h


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-11  4:53 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-11  4:53 UTC (permalink / raw
  To: gentoo-commits

commit:     6f1994cabd7a3fe37ccb50d2036ebed5748bcf32
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Mar 11 04:46:41 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Mar 11 04:46:41 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=6f1994ca

qlist: punt --dups option

I'm not sure anyone really uses this option anymore now that packages
are actively using multiple SLOTs in the tree.  The code is also pretty
ugly, so it'd be nice if we didn't have to maintain it.

---
 qlist.c | 70 ++---------------------------------------------------------------
 1 file changed, 2 insertions(+), 68 deletions(-)

diff --git a/qlist.c b/qlist.c
index be5893d..0b0714e 100644
--- a/qlist.c
+++ b/qlist.c
@@ -16,7 +16,6 @@ static struct option const qlist_long_opts[] = {
 	{"repo",      no_argument, NULL, 'R'},
 	{"umap",      no_argument, NULL, 'U'},
 	{"columns",   no_argument, NULL, 'c'},
-	{"dups",      no_argument, NULL, 'D'},
 	{"showdebug", no_argument, NULL, 128},
 	{"exact",     no_argument, NULL, 'e'},
 	{"all",       no_argument, NULL, 'a'},
@@ -32,7 +31,6 @@ static const char * const qlist_opts_help[] = {
 	"Display installed packages with repository",
 	"Display installed packages with flags used",
 	"Display column view",
-	"Only show package dups",
 	"Show /usr/lib/debug files",
 	"Exact match (only CAT/PN or PN without PV)",
 	"Show every installed package",
@@ -44,25 +42,6 @@ static const char * const qlist_opts_help[] = {
 };
 #define qlist_usage(ret) usage(ret, QLIST_FLAGS, qlist_long_opts, qlist_opts_help, lookup_applet_idx("qlist"))
 
-_q_static queue *filter_dups(queue *sets)
-{
-	queue *ll = NULL;
-	queue *dups = NULL;
-	queue *list = NULL;
-
-	for (list = sets; list != NULL;  list = list->next) {
-		for (ll = sets; ll != NULL; ll = ll->next) {
-			if ((strcmp(ll->name, list->name) == 0) && (strcmp(ll->item, list->item) != 0)) {
-				int ok = 0;
-				dups = del_set(ll->item, dups, &ok);
-				ok = 0;
-				dups = add_set(ll->item, ll->item, dups);
-			}
-		}
-	}
-	return dups;
-}
-
 static char *grab_pkg_umap(const char *CAT, const char *PV)
 {
 	static char umap[BUFSIZ];
@@ -276,7 +255,6 @@ struct qlist_opt_state {
 	bool exact;
 	bool all;
 	bool just_pkgname;
-	bool dups_only;
 	bool show_dir;
 	bool show_obj;
 	bool show_repo;
@@ -307,15 +285,6 @@ _q_static int qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 
 	if (state->just_pkgname) {
 		depend_atom *atom;
-		if (state->dups_only) {
-			char swap[_Q_PATH_MAX];
-			atom = atom_explode(pkgname);
-			snprintf(state->buf, state->buflen, "%s/%s", catname, atom->P);
-			snprintf(swap, sizeof(swap), "%s/%s", catname, atom->PN);
-			state->sets = add_set(swap, state->buf, state->sets);
-			atom_implode(atom);
-			return 0;
-		}
 		atom = (verbose ? NULL : atom_explode(pkgname));
 		if ((state->all + state->just_pkgname) < 2) {
 			if (state->show_slots && !pkg_ctx->slot)
@@ -389,7 +358,6 @@ int qlist_main(int argc, char **argv)
 		.exact = false,
 		.all = false,
 		.just_pkgname = false,
-		.dups_only = false,
 		.show_dir = false,
 		.show_obj = false,
 		.show_repo = false,
@@ -419,12 +387,12 @@ int qlist_main(int argc, char **argv)
 		case 128: state.show_dbg = true; break;
 		case 'o': state.show_obj = true; break;
 		case 's': state.show_sym = true; break;
-		case 'D': state.dups_only = state.exact = state.just_pkgname = true; break;
 		case 'c': state.columns = true; break;
 		case 'f': break;
 		}
 	}
-	if (state.columns) verbose = 0; /* if not set to zero; atom wont be exploded; segv */
+	if (state.columns)
+		verbose = 0; /* if not set to zero; atom wont be exploded; segv */
 	/* default to showing syms and objs */
 	if (!state.show_dir && !state.show_obj && !state.show_sym)
 		state.show_obj = state.show_sym = true;
@@ -434,40 +402,6 @@ int qlist_main(int argc, char **argv)
 	state.buf = xmalloc(state.buflen);
 	state.atoms = xcalloc(argc - optind, sizeof(*state.atoms));
 	ret = q_vdb_foreach_pkg_sorted(qlist_cb, &state);
-
-	if (state.dups_only) {
-		char last[126];
-		depend_atom *atom;
-		queue *ll, *dups = filter_dups(state.sets);
-		last[0] = 0;
-
-		for (ll = dups; ll != NULL; ll = ll->next) {
-			int ok = 1;
-			atom = atom_explode(ll->item);
-			if (strcmp(last, atom->PN) == 0)
-				if (!verbose)
-					ok = 0;
-			strncpy(last, atom->PN, sizeof(last));
-			if (ok)	{
-				char *slot = NULL;
-				char *repo = NULL;
-				if (state.show_slots)
-					slot = grab_vdb_item("SLOT", atom->CATEGORY, atom->P);
-				if (state.show_repo)
-					repo = grab_vdb_item("repository", atom->CATEGORY, atom->P);
-				printf("%s%s/%s%s%s%s%s%s%s%s%s%s%s%s%s", BOLD, atom->CATEGORY, BLUE,
-					(!state.columns ? (verbose ? atom->P : atom->PN) : atom->PN),
-					(state.columns ? " " : ""), (state.columns ? atom->PV : ""),
-					NORM, YELLOW, slot ? ":" : "", slot ? slot : "",
-					NORM, GREEN, repo ? "::" : "", repo ? repo : "", NORM);
-				puts(umapstr(state.show_umap, atom->CATEGORY, atom->P));
-			}
-			atom_implode(atom);
-		}
-		free_sets(dups);
-		free_sets(state.sets);
-	}
-
 	free(state.buf);
 	free(state.atoms);
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-10  8:45 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-10  8:45 UTC (permalink / raw
  To: gentoo-commits

commit:     b5b6a47bc9d24bd8869b1e5562f786227a6b828b
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 10 08:41:56 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Mar 10 08:41:56 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=b5b6a47b

build: fix tarball/name creation with git tags

---
 make-tarball.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/make-tarball.sh b/make-tarball.sh
index 143a927..02cc501 100755
--- a/make-tarball.sh
+++ b/make-tarball.sh
@@ -26,7 +26,7 @@ git) ver="HEAD" ;;
 	fi
 	;;
 esac
-p="portage-utils-$ver"
+p="portage-utils-${ver#v}"
 
 rm -rf "${p}"
 mkdir "${p}"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-10  8:45 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-10  8:45 UTC (permalink / raw
  To: gentoo-commits

commit:     f9696bacb5d3feb2a1f7fce75e60ca1c692f37bf
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 10 07:08:43 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Mar 10 07:08:43 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=f9696bac

qmerge: fix color used in displaying downgrades

We want to use a darker blue for D status instead of using the same
blue color as U status.  This also matches portage behavior.

---
 qmerge.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 572365e..1e07347 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -357,6 +357,7 @@ qprint_tree_node(int level, const depend_atom *atom, const struct pkg_t *pkg)
 
 	char install_ver[126] = "";
 	char c = 'N';
+	const char *color;
 
 	if (!pretend)
 		return 0;
@@ -385,10 +386,13 @@ qprint_tree_node(int level, const depend_atom *atom, const struct pkg_t *pkg)
 			return c;
 		if ((c == 'R' || c == 'D') && update_only && level)
 			return c;
-		if (c == 'R')
-			snprintf(buf, sizeof(buf), "%s%c%s", YELLOW, c, NORM);
-		if (c == 'U' || c == 'D')
-			snprintf(buf, sizeof(buf), "%s%c%s", BLUE, c, NORM);
+		switch (c) {
+		case 'R': color = YELLOW; break;
+		case 'U': color = BLUE; break;
+		case 'D': color = DKBLUE; break;
+		default: color = RED; break;
+		}
+		snprintf(buf, sizeof(buf), "%s%c%s", color, c, NORM);
 #if 0
 		if (level) {
 			switch (c) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-10  8:45 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-10  8:45 UTC (permalink / raw
  To: gentoo-commits

commit:     054269125460aadf20059019a7a106800160c69a
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Mar 10 07:12:02 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Mar 10 07:12:02 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=05426912

eat_file: convert API to work on dynamic buffers

Rather than use static allocated buffers everywhere where we assume we
picked a size big enough for real world uses (and just silently truncate
or die in large edge cases), convert the API to use malloc instead.  We
will grow the buffers (never shrink) so that repeat calls should ramp up
to the max quickly and thus avoid having to call malloc() repeatedly.

This might report memory leaks with some funcs as we hold on to some
buffers indefinitely since we know the buffer isn't used outside the
context of the func.  Helps out when the func is called repeatedly.

This should make future enhancements (like eating more than one element
in a vdb pkg dir) a lot easier.

---
 main.c     | 108 +++++++++++++++++++++++++++++++++++++++++--------------------
 qdepends.c |  14 ++++----
 qfile.c    |   9 ++++--
 qlist.c    |   5 +--
 qlop.c     |  13 ++++----
 qmerge.c   |  12 ++++---
 6 files changed, 105 insertions(+), 56 deletions(-)

diff --git a/main.c b/main.c
index a9b5403..436387d 100644
--- a/main.c
+++ b/main.c
@@ -10,7 +10,9 @@
 #include "main.h"
 
 /* prototypes and such */
-static char eat_file(const char *file, char *buf, const size_t bufsize);
+static bool eat_file(const char *, char **, size_t *);
+static bool eat_file_fd(int, char **, size_t *);
+static bool eat_file_at(int, const char *, char **, size_t *);
 int rematch(const char *, const char *, int);
 static char *rmspace(char *);
 
@@ -170,47 +172,70 @@ static void version_barf(void)
 	exit(EXIT_SUCCESS);
 }
 
-static char eat_file_fd(int fd, char *buf, const size_t bufsize)
+static bool eat_file_fd(int fd, char **bufptr, size_t *bufsize)
 {
+	bool ret = true;
 	struct stat s;
+	char *buf;
+	size_t read_size;
+
+	/* First figure out how much data we should read from the fd. */
+	if (fd == -1 || fstat(fd, &s) != 0) {
+		ret = false;
+		read_size = 0;
+		/* Fall through so we set the first byte 0 */
+	} else if (!s.st_size) {
+		/* We might be trying to eat a virtual file like in /proc, so
+		 * read an arbitrary size that should be "enough". */
+		read_size = BUFSIZE;
+	} else
+		read_size = (size_t)s.st_size;
+
+	/* Now allocate enough space (at least 1 byte). */
+	if (!*bufptr || *bufsize < read_size) {
+		/* We assume a min allocation size so that repeat calls don't
+		 * hit ugly ramp ups -- if you read a file that is 1 byte, then
+		 * 5 bytes, then 10 bytes, then 20 bytes, ... you'll allocate
+		 * constantly.  So we round up a few pages as wasiting virtual
+		 * memory is cheap when it is unused.  */
+		*bufsize = ((read_size + 1) + BUFSIZE - 1) & -BUFSIZE;
+		*bufptr = xrealloc(*bufptr, *bufsize);
+	}
+	buf = *bufptr;
 
+	/* Finally do the actual read. */
 	buf[0] = '\0';
-	if (fstat(fd, &s) != 0)
-		return 0;
-	if (s.st_size) {
-		if (bufsize < (size_t)s.st_size)
-			return 0;
-		if (read(fd, buf, s.st_size) != (ssize_t)s.st_size)
-			return 0;
-		buf[s.st_size] = '\0';
-	} else {
-		if (read(fd, buf, bufsize) == 0)
-			return 0;
-		buf[bufsize - 1] = '\0';
+	if (read_size) {
+		if (s.st_size) {
+			if (read(fd, buf, read_size) != (ssize_t)read_size)
+				return false;
+			buf[read_size] = '\0';
+		} else {
+			if (read(fd, buf, read_size) == 0)
+				return false;
+			buf[read_size - 1] = '\0';
+		}
 	}
 
-	return 1;
+	return ret;
 }
 
-static char eat_file_at(int dfd, const char *file, char *buf, const size_t bufsize)
+static bool eat_file_at(int dfd, const char *file, char **bufptr, size_t *bufsize)
 {
+	bool ret;
 	int fd;
-	char ret;
 
-	if ((fd = openat(dfd, file, O_CLOEXEC|O_RDONLY)) == -1) {
-		buf[0] = '\0';
-		return 0;
-	}
-
-	ret = eat_file_fd(fd, buf, bufsize);
+	fd = openat(dfd, file, O_CLOEXEC|O_RDONLY);
+	ret = eat_file_fd(fd, bufptr, bufsize);
+	if (fd != -1)
+		close(fd);
 
-	close(fd);
 	return ret;
 }
 
-static char eat_file(const char *file, char *buf, const size_t bufsize)
+static bool eat_file(const char *file, char **bufptr, size_t *bufsize)
 {
-	return eat_file_at(AT_FDCWD, file, buf, bufsize);
+	return eat_file_at(AT_FDCWD, file, bufptr, bufsize);
 }
 
 static bool prompt(const char *p)
@@ -601,7 +626,10 @@ static void read_portage_profile(const char *configroot, const char *profile, en
 {
 	size_t configroot_len, profile_len, sub_len;
 	char *profile_file, *sub_file;
-	char buf[BUFSIZE], *s;
+	char *s;
+
+	static char *buf;
+	static size_t buf_len;
 
 	/* initialize the base profile path */
 	configroot_len = strlen(configroot);
@@ -620,7 +648,7 @@ static void read_portage_profile(const char *configroot, const char *profile, en
 
 	/* now walk all the parents */
 	strcpy(sub_file, "parent");
-	if (eat_file(profile_file, buf, sizeof(buf)) == 0)
+	if (eat_file(profile_file, &buf, &buf_len) == 0)
 		goto done;
 	rmspace(buf);
 
@@ -1212,17 +1240,25 @@ char *atom_to_pvr(depend_atom *atom) {
 	return (atom->PR_int == 0 ? atom->P : atom->PVR );
 }
 
+/* TODO: Delete this in favor of libq/vdb.c API. */
 static char *grab_vdb_item(const char *item, const char *CATEGORY, const char *PF)
 {
-	static char buf[_Q_PATH_MAX];
+	static char *buf;
+	static size_t buf_len;
+
+	if (buf == NULL) {
+		buf_len = _Q_PATH_MAX;
+		buf = xmalloc(buf_len);
+	}
 
-	snprintf(buf, sizeof(buf), "%s%s/%s/%s/%s", portroot, portvdb, CATEGORY, PF, item);
-	eat_file(buf, buf, sizeof(buf));
+	snprintf(buf, buf_len, "%s%s/%s/%s/%s", portroot, portvdb, CATEGORY, PF, item);
+	eat_file(buf, &buf, &buf_len);
 	rmspace(buf);
 
 	return buf;
 }
 
+/* TODO: Merge this into libq/vdb.c somehow. */
 _q_static queue *get_vdb_atoms(int fullcpv)
 {
 	q_vdb_ctx *ctx;
@@ -1232,6 +1268,7 @@ _q_static queue *get_vdb_atoms(int fullcpv)
 
 	char buf[_Q_PATH_MAX];
 	char slot[_Q_PATH_MAX];
+	size_t slot_len;
 
 	struct dirent **cat;
 	struct dirent **pf;
@@ -1255,11 +1292,12 @@ _q_static queue *get_vdb_atoms(int fullcpv)
 			if ((atom = atom_explode(buf)) == NULL)
 				continue;
 
-			slot[0] = '0';
-			slot[1] = 0;
+			/* XXX: This assumes static slot buf is big enough, but should be fine
+			 * until this is rewritten & merged into libq/vdb.c. */
+			slot_len = sizeof(slot);
 			strncat(buf, "/SLOT", sizeof(buf));
-			eat_file_at(ctx->vdb_fd, buf, buf, sizeof(buf));
-			rmspace(buf);
+			eat_file_at(ctx->vdb_fd, buf, (char **)&slot, &slot_len);
+			rmspace(slot);
 
 			if (fullcpv) {
 				if (atom->PR_int)

diff --git a/qdepends.c b/qdepends.c
index eba8304..8a176b6 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -396,7 +396,8 @@ _q_static int qdepends_main_vdb_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	int i;
 	char *ptr;
 	char buf[_Q_PATH_MAX];
-	char depend[65536], use[8192];
+	static char *depend, *use;
+	static size_t depend_len, use_len;
 	dep_node *dep_tree;
 
 	/* see if this cat/pkg is requested */
@@ -412,7 +413,7 @@ _q_static int qdepends_main_vdb_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 
 	IF_DEBUG(warn("matched %s/%s", catname, pkgname));
 
-	if (!eat_file_at(pkg_ctx->fd, state->depend_file, depend, sizeof(depend)))
+	if (!eat_file_at(pkg_ctx->fd, state->depend_file, &depend, &depend_len))
 		return 0;
 
 	IF_DEBUG(warn("growing tree..."));
@@ -433,7 +434,7 @@ _q_static int qdepends_main_vdb_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 		printf("%s%s/%s%s%s: ", BOLD, catname, BLUE, pkgname, NORM);
 	}
 
-	if (!eat_file_at(pkg_ctx->fd, "USE", use, sizeof(use))) {
+	if (!eat_file_at(pkg_ctx->fd, "USE", &use, &use_len)) {
 		warn("Could not eat_file(%s), you'll prob have incorrect output", buf);
 	} else {
 		for (ptr = use; *ptr; ++ptr)
@@ -466,12 +467,13 @@ _q_static int qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	size_t len;
 	char *ptr;
 	char buf[_Q_PATH_MAX];
-	char depend[16384], use[8192];
+	static char *depend, *use;
+	static size_t depend_len, use_len;
 	dep_node *dep_tree;
 
 	IF_DEBUG(warn("matched %s/%s for %s", catname, pkgname, state->depend_file));
 
-	if (!eat_file_at(pkg_ctx->fd, state->depend_file, depend, sizeof(depend)))
+	if (!eat_file_at(pkg_ctx->fd, state->depend_file, &depend, &depend_len))
 		return 0;
 
 	IF_DEBUG(warn("growing tree..."));
@@ -481,7 +483,7 @@ _q_static int qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	IF_DEBUG(puts(depend));
 	IF_DEBUG(dep_dump_tree(dep_tree));
 
-	if (eat_file_at(pkg_ctx->fd, "USE", use, sizeof(use)) == 1)
+	if (eat_file_at(pkg_ctx->fd, "USE", &use, &use_len))
 		use[0] = ' ';
 
 	for (ptr = use; *ptr; ++ptr)

diff --git a/qfile.c b/qfile.c
index 174cb7d..7094034 100644
--- a/qfile.c
+++ b/qfile.c
@@ -114,7 +114,7 @@ _q_static int qfile_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 		}
 		if (state->exclude_slot == NULL)
 			goto qlist_done; /* "(CAT/)?(PN|PF)" matches, and no SLOT specified */
-		eat_file_at(pkg_ctx->fd, "SLOT", state->buf, state->buflen);
+		eat_file_at(pkg_ctx->fd, "SLOT", &state->buf, &state->buflen);
 		rmspace(state->buf);
 		if (strcmp(state->exclude_slot, state->buf) == 0)
 			goto qlist_done; /* "(CAT/)?(PN|PF):SLOT" matches */
@@ -215,8 +215,11 @@ _q_static int qfile_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 					}
 				}
 				if (state->slotted) {
-					eat_file_at(pkg_ctx->fd, "SLOT", slot+1, sizeof(slot)-1);
-					rmspace(slot+1);
+					/* XXX: This assumes the buf is big enough. */
+					char *slot_hack = slot + 1;
+					size_t slot_len = sizeof(slot) - 1;
+					eat_file_at(pkg_ctx->fd, "SLOT", &slot_hack, &slot_len);
+					rmspace(slot_hack);
 					slot[0] = ':';
 				} else
 					slot[0] = '\0';

diff --git a/qlist.c b/qlist.c
index 5f8720f..cfb9d98 100644
--- a/qlist.c
+++ b/qlist.c
@@ -63,9 +63,10 @@ _q_static queue *filter_dups(queue *sets)
 
 _q_static char *q_vdb_pkg_eat(q_vdb_pkg_ctx *pkg_ctx, const char *item)
 {
-	static char buf[_Q_PATH_MAX];
+	static char *buf;
+	static size_t buf_len;
 
-	eat_file_at(pkg_ctx->fd, item, buf, sizeof(buf));
+	eat_file_at(pkg_ctx->fd, item, &buf, &buf_len);
 	rmspace(buf);
 
 	return buf;

diff --git a/qlop.c b/qlop.c
index 21e272d..d5e2226 100644
--- a/qlop.c
+++ b/qlop.c
@@ -385,7 +385,8 @@ void show_current_emerge(void)
 	DIR *proc;
 	struct dirent *de;
 	pid_t pid;
-	char buf[BUFSIZE], bufstat[300];
+	static char *cmdline, *bufstat;
+	static size_t cmdline_len, bufstat_len;
 	char path[50];
 	char *p, *q;
 	unsigned long long start_time = 0;
@@ -407,17 +408,17 @@ void show_current_emerge(void)
 
 		/* portage renames the cmdline so the package name is first */
 		snprintf(path, sizeof(path), "/proc/%i/cmdline", pid);
-		if (!eat_file(path, buf, sizeof(buf)))
+		if (!eat_file(path, &cmdline, &cmdline_len))
 			continue;
 
-		if (buf[0] == '[' && (p = strchr(buf, ']')) != NULL && strstr(buf, "sandbox") != NULL) {
+		if (cmdline[0] == '[' && (p = strchr(cmdline, ']')) != NULL && strstr(cmdline, "sandbox") != NULL) {
 			*p = '\0';
-			p = buf+1;
+			p = cmdline + 1;
 			q = p + strlen(p) + 1;
 
 			/* open the stat file to figure out how long we have been running */
 			snprintf(path, sizeof(path), "/proc/%i/stat", pid);
-			if (!eat_file(path, bufstat, sizeof(bufstat)))
+			if (!eat_file(path, &bufstat, &bufstat_len))
 				continue;
 
 			/* ripped from procps/proc/readproc.c */
@@ -435,7 +436,7 @@ void show_current_emerge(void)
 				"%llu ",
 				&start_time);
 			/* get uptime */
-			if (!eat_file("/proc/uptime", bufstat, sizeof(bufstat)))
+			if (!eat_file("/proc/uptime", &bufstat, &bufstat_len))
 				continue;
 			sscanf(bufstat, "%lf", &uptime_secs);
 

diff --git a/qmerge.c b/qmerge.c
index 1e07347..165caa9 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -754,7 +754,9 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 {
 	queue *objs;
 	FILE *fp, *contents;
-	char buf[1024], phases[128];
+	static char *phases;
+	static size_t phases_len;
+	char buf[1024];
 	char *tbz2, *p, *D, *T;
 	int i;
 	char **ARGV;
@@ -891,7 +893,7 @@ pkg_merge(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	xsystem(buf);
 	fflush(stdout);
 
-	eat_file("vdb/DEFINED_PHASES", phases, sizeof(phases));
+	eat_file("vdb/DEFINED_PHASES", &phases, &phases_len);
 	pkg_run_func("vdb", phases, "pkg_pretend", D, T);
 	pkg_run_func("vdb", phases, "pkg_setup", D, T);
 	pkg_run_func("vdb", phases, "pkg_preinst", D, T);
@@ -1019,7 +1021,9 @@ _q_static int
 pkg_unmerge(const char *cat, const char *pkgname, queue *keep)
 {
 	size_t buflen;
-	char *buf, *vdb_path, *T, phases[128];
+	static char *phases;
+	static size_t phases_len;
+	char *buf, *vdb_path, *T;
 	FILE *fp;
 	int ret, fd, vdb_fd, portroot_fd;
 	int cp_argc, cpm_argc;
@@ -1061,7 +1065,7 @@ pkg_unmerge(const char *cat, const char *pkgname, queue *keep)
 
 	/* First execute the pkg_prerm step */
 	if (!pretend) {
-		eat_file_at(vdb_fd, "DEFINED_PHASES", phases, sizeof(phases));
+		eat_file_at(vdb_fd, "DEFINED_PHASES", &phases, &phases_len);
 		mkdir_p(T, 0755);
 		pkg_run_func(vdb_path, phases, "pkg_prerm", T, T);
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-10  6:00 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-10  6:00 UTC (permalink / raw
  To: gentoo-commits

commit:     b4db4eeb7b8b5e3850fcdf931f1cf2f2b5375598
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Mar  9 21:09:45 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Mar  9 21:09:45 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=b4db4eeb

build: also use -Wold-style-definition w/configure

---
 configure.ac | 1 +
 1 file changed, 1 insertion(+)

diff --git a/configure.ac b/configure.ac
index 29063cf..8207189 100644
--- a/configure.ac
+++ b/configure.ac
@@ -45,6 +45,7 @@ m4_foreach_w([flag], [
 	-Wcast-align
 	-Wno-format-nonliteral
 	-Wsequence-point
+	-Wold-style-definition
 	-Wextra
 ], [
 	AX_CHECK_COMPILE_FLAG(flag, AS_VAR_APPEND([CFLAGS], " flag"))


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-10  6:00 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-10  6:00 UTC (permalink / raw
  To: gentoo-commits

commit:     e849f8b058188b5371cc656056eb0aa32298cd9e
Author:     Tim Harder <radhermit <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 28 03:09:39 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Feb 28 03:09:39 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=e849f8b0

qlist: fix minor memory leaks reported by valgrind

---
 qlist.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/qlist.c b/qlist.c
index a5a4908..5f8720f 100644
--- a/qlist.c
+++ b/qlist.c
@@ -437,6 +437,9 @@ int qlist_main(int argc, char **argv)
 		free_sets(state.sets);
 	}
 
+	free(state.buf);
+	free(state.atoms);
+
 	return ret;
 }
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-10  6:00 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-10  6:00 UTC (permalink / raw
  To: gentoo-commits

commit:     6cdfe87e10e9abbe03eba7a680dfb8aee1fafbf0
Author:     Tim Harder <radhermit <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 27 21:32:28 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Feb 27 21:32:28 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=6cdfe87e

qlist: drop old -L flag from options

---
 qlist.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/qlist.c b/qlist.c
index 5e2c365..a5a4908 100644
--- a/qlist.c
+++ b/qlist.c
@@ -9,7 +9,7 @@
 
 #ifdef APPLET_qlist
 
-#define QLIST_FLAGS "ISULcDeados" COMMON_FLAGS
+#define QLIST_FLAGS "ISUcDeados" COMMON_FLAGS
 static struct option const qlist_long_opts[] = {
 	{"installed", no_argument, NULL, 'I'},
 	{"slots",     no_argument, NULL, 'S'},


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-10  6:00 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-10  6:00 UTC (permalink / raw
  To: gentoo-commits

commit:     9884a55a9b8a14e03f9e8d9d73925cea8fc045e2
Author:     Tim Harder <radhermit <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 28 06:43:44 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Fri Feb 28 06:43:44 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=9884a55a

build: regen Makefile.am

---
 Makefile.am | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/Makefile.am b/Makefile.am
index 2be96c8..531c7a0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -125,6 +125,7 @@ EXTRA_DIST += \
 	libq/xsystem.c \
 	main.c \
 	main.h \
+	porting.h \
 	q.c \
 	qatom.c \
 	qcache.c \
@@ -171,6 +172,14 @@ EXTRA_DIST += \
 	tests/profile/profile1/etc/portage/make.conf \
 	tests/profile/profile1/etc/portage/subdir/file.conf \
 	tests/profile/profile1/etc/portage/this.level.conf \
+	tests/qdepends/Makefile \
+	tests/qdepends/dotest \
+	tests/qdepends/list01.good \
+	tests/qdepends/list02.good \
+	tests/qdepends/list03.good \
+	tests/qdepends/list04.good \
+	tests/qdepends/list05.good \
+	tests/qdepends/list06.good \
 	tests/qfile/Makefile \
 	tests/qfile/dotest \
 	tests/qlist/Makefile \
@@ -220,5 +229,6 @@ EXTRA_DIST += \
 	tests/source/Makefile \
 	tests/source/dotest \
 	tests/source/space \
-	tests/subdir.mk
+	tests/subdir.mk \
+	tests/tests.h
 # @@@ GEN START @@@ #


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-10  6:00 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-10  6:00 UTC (permalink / raw
  To: gentoo-commits

commit:     894976158d7c2cbc854304f05c9945626bb507fd
Author:     Tim Harder <radhermit <AT> gentoo <DOT> org>
AuthorDate: Thu Feb 27 00:52:10 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Thu Feb 27 00:52:10 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=89497615

fix indentation

---
 main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/main.c b/main.c
index bb510a8..a9b5403 100644
--- a/main.c
+++ b/main.c
@@ -807,8 +807,8 @@ void initialize_portage_env(void)
 enum {
 	CACHE_EBUILD = 1,
 	CACHE_METADATA = 2,
-    CACHE_METADATA_PMS = 10,
-    CACHE_METADATA_MD5 = 11,
+	CACHE_METADATA_PMS = 10,
+	CACHE_METADATA_MD5 = 11,
 };
 
 int filter_hidden(const struct dirent *dentry);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     be732fdeed85a315cf2f7e53ddd25354fd358c66
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 07:00:35 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 18 07:00:35 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=be732fde

add TODO for installing a binpkg directly

---
 TODO | 1 +
 1 file changed, 1 insertion(+)

diff --git a/TODO b/TODO
index 4bb86fb..86445a4 100644
--- a/TODO
+++ b/TODO
@@ -26,6 +26,7 @@
 	- parallel fetch tbz2s
 	- check order of pkg_{pre,post}{inst,rm} during install, unmerge, and upgrade
 	- env is not saved/restored between pkg_{pre,post}inst (see portage and REPO_LAYOUT_CONF_WARN)
+	- support installing via path to tbz2 package
 
 - atoms:
 	- only 32bit values are supported for revision (-r#)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     e0bf9bdb6a07eca93015f99731211c19eca002c5
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 25 21:30:50 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 25 21:30:50 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=e0bf9bdb

add support for setting ROOT via cmdline --root flag http://crbug.com/336871

---
 main.c |  7 +++++--
 q.c    | 17 +++++++++--------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/main.c b/main.c
index 828c10f..38a447e 100644
--- a/main.c
+++ b/main.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2013 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.231 2014/02/18 07:31:33 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.232 2014/02/25 21:30:50 vapier Exp $
  *
  * Copyright 2005-2008 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2013 Mike Frysinger  - <vapier@gentoo.org>
@@ -83,6 +83,7 @@ void no_colors(void)
 /* Common usage for all applets */
 #define COMMON_FLAGS "vqChV"
 #define COMMON_LONG_OPTS \
+	{"root",       a_argument, NULL, 0x1}, \
 	{"verbose",   no_argument, NULL, 'v'}, \
 	{"quiet",     no_argument, NULL, 'q'}, \
 	{"nocolor",   no_argument, NULL, 'C'}, \
@@ -90,6 +91,7 @@ void no_colors(void)
 	{"version",   no_argument, NULL, 'V'}, \
 	{NULL,        no_argument, NULL, 0x0}
 #define COMMON_OPTS_HELP \
+	"Set the ROOT env var", \
 	"Make a lot of noise", \
 	"Tighter output; suppress warnings", \
 	"Don't output color", \
@@ -97,6 +99,7 @@ void no_colors(void)
 	"Print version and exit", \
 	NULL
 #define COMMON_GETOPTS_CASES(applet) \
+	case 0x1: portroot = optarg; break; \
 	case 'v': ++verbose; break; \
 	case 'q': ++quiet; if (freopen("/dev/null", "w", stderr)) { /* ignore errors */ } break; \
 	case 'V': version_barf( applet ## _rcsid ); break; \
@@ -137,7 +140,7 @@ static void usage(int status, const char *flags, struct option const opts[],
 		assert(help[i] != NULL);
 
 		/* first output the short flag if it has one */
-		if (opts[i].val > '~')
+		if (opts[i].val > '~' || opts[i].val < ' ')
 			printf("      ");
 		else
 			printf("  -%c, ", opts[i].val);

diff --git a/q.c b/q.c
index c0494e4..a4a0012 100644
--- a/q.c
+++ b/q.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/q.c,v 1.52 2011/03/17 03:32:51 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/q.c,v 1.53 2014/02/25 21:30:50 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -22,7 +22,7 @@ static const char * const q_opts_help[] = {
 	"Module path",
 	COMMON_OPTS_HELP
 };
-static const char q_rcsid[] = "$Id: q.c,v 1.52 2011/03/17 03:32:51 vapier Exp $";
+static const char q_rcsid[] = "$Id: q.c,v 1.53 2014/02/25 21:30:50 vapier Exp $";
 #define q_usage(ret) usage(ret, Q_FLAGS, q_long_opts, q_opts_help, lookup_applet_idx("q"))
 
 static APPLET lookup_applet(const char *applet)
@@ -145,16 +145,17 @@ int q_main(int argc, char **argv)
 		return 1;
 
 	/* In case of "q --option ... appletname ...", remove appletname from the
-	 * applet's args, exchange "appletname" and "--option". */
+	 * applet's args. */
 	if (optind > 1) {
-		char* appletname = argv[optind];
-		argv[optind] = argv[1];
-		argv[1] = appletname;
-	}
+		argv[0] = argv[optind];
+		for (i = optind; i < argc; ++i)
+			argv[i] = argv[i + 1];
+	} else
+		++argv;
 
 	optind = 0; /* reset so the applets can call getopt */
 
-	return (func)(argc - 1, ++argv);
+	return (func)(argc - 1, argv);
 }
 
 static int run_applet_l(const char *arg, ...)


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     7b6a61e8015aa5790cd0a8e1f58a0bf442b88955
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 06:59:05 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 18 06:59:05 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=7b6a61e8

qmerge: add --debug option for auto running shell through `set -x`

---
 qmerge.c | 18 ++++++++++++++----
 1 file changed, 14 insertions(+), 4 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 479c551..1a44e46 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.137 2014/02/18 06:58:45 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.138 2014/02/18 06:59:05 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -48,6 +48,7 @@ static struct option const qmerge_long_opts[] = {
 	{"yes",     no_argument, NULL, 'y'},
 	{"nodeps",  no_argument, NULL, 'O'},
 	{"nomd5",   no_argument, NULL, '5'},
+	{"debug",   no_argument, NULL, 128},
 	COMMON_LONG_OPTS
 };
 
@@ -62,10 +63,11 @@ static const char * const qmerge_opts_help[] = {
 	"Don't prompt before overwriting",
 	"Don't merge dependencies",
 	"Don't verify MD5 digest of files",
+	"Run shell funcs with `set -x`",
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.137 2014/02/18 06:58:45 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.138 2014/02/18 06:59:05 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -77,6 +79,7 @@ char follow_rdepends = 1;
 char nomd5 = 0;
 char qmerge_strict = 0;
 char update_only = 0;
+bool debug = false;
 const char Packages[] = "Packages";
 
 /*
@@ -467,10 +470,16 @@ pkg_run_func(const char *vdb_path, const char *phases, const char *func, const c
 		"ED=\"${EPREFIX%%/}/${D#/}\"\n"
 		"T='%6$s'\n"
 		/* Finally run the func */
-		"%2$s\n"
+		"%7$s%2$s\n"
 		/* Ignore func return values (not exit values) */
 		":",
-		vdb_path, func, phase, portroot, D, T);
+		/*1*/ vdb_path,
+		/*2*/ func,
+		/*3*/ phase,
+		/*4*/ portroot,
+		/*5*/ D,
+		/*6*/ T,
+		/*7*/ debug ? "set -x;" : "");
 	xsystembash(script);
 	free(script);
 }
@@ -1961,6 +1970,7 @@ int qmerge_main(int argc, char **argv)
 			case 'y': interactive = 0; break;
 			case 'O': follow_rdepends = 0; break;
 			case '5': nomd5 = 1; break;
+			case 128: debug = true; break;
 			COMMON_GETOPTS_CASES(qmerge)
 		}
 	}


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     6164509ba7996db4d9752f8d7fbba59d165222fe
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 07:33:20 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 18 07:33:20 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=6164509b

update ignores of old files

---
 .cvsignore | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.cvsignore b/.cvsignore
index 54534d0..75310f6 100644
--- a/.cvsignore
+++ b/.cvsignore
@@ -18,13 +18,13 @@ configure
 autotools
 Makefile.in
 
+*.old.c
 q
 qatom
 qcache
 qcheck
 qdepends
 qfile
-qfile.old.c
 qglsa
 qgrep
 qlist


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     9158e82a16eb224d4654de94ea896037d332b13e
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 07:30:30 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 18 07:30:30 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=9158e82a

qcache: mark everything static

---
 qcache.c | 55 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 28 insertions(+), 27 deletions(-)

diff --git a/qcache.c b/qcache.c
index 1218417..e8eedd0 100644
--- a/qcache.c
+++ b/qcache.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qcache.c,v 1.47 2014/01/07 19:48:45 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qcache.c,v 1.48 2014/02/18 07:30:30 vapier Exp $
  *
  * Copyright 2006 Thomas A. Cort - <tcort@gentoo.org>
  */
@@ -47,7 +47,7 @@ static const char * const qcache_opts_help[] = {
 	COMMON_OPTS_HELP
 };
 
-static const char qcache_rcsid[] = "$Id: qcache.c,v 1.47 2014/01/07 19:48:45 vapier Exp $";
+static const char qcache_rcsid[] = "$Id: qcache.c,v 1.48 2014/02/18 07:30:30 vapier Exp $";
 #define qcache_usage(ret) usage(ret, QCACHE_FLAGS, qcache_long_opts, qcache_opts_help, lookup_applet_idx("qcache"))
 
 /********************************************************************/
@@ -100,7 +100,7 @@ enum { none = 0, testing, stable, minus };
  * OUT:
  *  int - one of the following enum { none = 0, testing, stable, minus };
  */
-int decode_status(char c);
+_q_static
 int decode_status(char c)
 {
 	switch (c) {
@@ -120,7 +120,7 @@ int decode_status(char c)
  * OUT:
  *  int pos - location of arch in archlist[]
  */
-int decode_arch(const char *arch);
+_q_static
 int decode_arch(const char *arch)
 {
 	int a;
@@ -146,8 +146,8 @@ int decode_arch(const char *arch)
  *  char *category - current category of the current package
  *  int *keywords - an array of keywords that coincides with archlist
  */
-void print_keywords(char *category, char *ebuild, int *keywords);
-void print_keywords(char *category, char *ebuild, int *keywords)
+_q_static
+void print_keywords(const char *category, const char *ebuild, int *keywords)
 {
 	int a;
 	char *package;
@@ -184,7 +184,7 @@ void print_keywords(char *category, char *ebuild, int *keywords)
  * ERR:
  *  int rc - -1 is returned on error (if !s || !keywords)
  */
-int read_keywords(char *s, int *keywords);
+_q_static
 int read_keywords(char *s, int *keywords)
 {
 	char *arch, delim[2] = { ' ', '\0' };
@@ -231,7 +231,8 @@ int read_keywords(char *s, int *keywords)
  * ERR:
  *  -1 is returned if the file cannot be read.
  */
-static unsigned int qcache_count_lines(char *filename)
+_q_static
+unsigned int qcache_count_lines(char *filename)
 {
 	int count, fd;
 	char c;
@@ -262,7 +263,7 @@ static unsigned int qcache_count_lines(char *filename)
  * ERR:
  *  NULL is returned if an error occurs.
  */
-char **qcache_read_lines(char *filename);
+_q_static
 char **qcache_read_lines(char *filename)
 {
 	int len, fd, count, i, num_lines;
@@ -302,7 +303,7 @@ char **qcache_read_lines(char *filename)
  *
  * free()'s memory allocated by qcache_read_lines
  */
-void qcache_free_lines(char **lines);
+_q_static
 void qcache_free_lines(char **lines)
 {
 	int i;
@@ -325,7 +326,7 @@ void qcache_free_lines(char **lines)
  * ERR:
  *  NULL is returned when an error occurs.
  */
-portage_cache *qcache_read_cache_file(const char *filename);
+_q_static
 portage_cache *qcache_read_cache_file(const char *filename)
 {
 	struct stat s;
@@ -396,7 +397,7 @@ portage_cache *qcache_read_cache_file(const char *filename)
 
 	return ret;
 
-err:
+ err:
 	if (ret)
 		cache_free(ret);
 	return NULL;
@@ -410,7 +411,7 @@ err:
  * IN:
  *  portage_cache *cache - the portage_cache to be free()'d
  */
-void qcache_free_data(portage_cache *cache);
+_q_static
 void qcache_free_data(portage_cache *cache)
 {
 	int i;
@@ -444,7 +445,7 @@ void qcache_free_data(portage_cache *cache)
  *   1 (OLDER)
  *   0 (SAME)
  */
-int qcache_vercmp(const struct dirent **x, const struct dirent **y);
+_q_static
 int qcache_vercmp(const struct dirent **x, const struct dirent **y)
 {
 	switch (atom_compare_str((*x)->d_name, (*y)->d_name)) {
@@ -469,7 +470,7 @@ int qcache_vercmp(const struct dirent **x, const struct dirent **y)
  * OUT:
  *  int - 0 if filename begins with '.' or is "metadata.xml", otherwise 1
  */
-int qcache_file_select(const struct dirent *entry);
+_q_static
 int qcache_file_select(const struct dirent *entry)
 {
 	return !(entry->d_name[0] == '.' || (strcmp(entry->d_name, "metadata.xml") == 0) || (strstr(entry->d_name, ".cpickle") != 0));
@@ -485,7 +486,7 @@ int qcache_file_select(const struct dirent *entry)
  * OUT:
  *  int - 1 if the filename ends in ".ebuild", otherwise 0
  */
-int qcache_ebuild_select(const struct dirent *entry);
+_q_static
 int qcache_ebuild_select(const struct dirent *entry)
 {
 	return ((strlen(entry->d_name) > 7) && !strcmp(entry->d_name+strlen(entry->d_name)-7, ".ebuild"));
@@ -507,7 +508,7 @@ int qcache_ebuild_select(const struct dirent *entry)
  * ERR:
  *  exit or return -1 on failure.
  */
-int qcache_traverse(void (*func)(qcache_data*));
+_q_static
 int qcache_traverse(void (*func)(qcache_data*))
 {
 	qcache_data data;
@@ -625,7 +626,7 @@ int qcache_traverse(void (*func)(qcache_data*))
 /* functors                                                         */
 /********************************************************************/
 
-void qcache_imlate(qcache_data *data);
+_q_static
 void qcache_imlate(qcache_data *data)
 {
 	int *keywords;
@@ -657,7 +658,7 @@ void qcache_imlate(qcache_data *data)
 	free(keywords);
 }
 
-void qcache_not(qcache_data *data);
+_q_static
 void qcache_not(qcache_data *data)
 {
 	int *keywords;
@@ -679,7 +680,7 @@ void qcache_not(qcache_data *data)
 	free(keywords);
 }
 
-void qcache_all(qcache_data *data);
+_q_static
 void qcache_all(qcache_data *data)
 {
 	int *keywords;
@@ -700,7 +701,7 @@ void qcache_all(qcache_data *data)
 	free(keywords);
 }
 
-void qcache_dropped(qcache_data *data);
+_q_static
 void qcache_dropped(qcache_data *data)
 {
 	static int possible = 0;
@@ -741,7 +742,7 @@ void qcache_dropped(qcache_data *data)
 	free(keywords);
 }
 
-void qcache_stats(qcache_data *data);
+_q_static
 void qcache_stats(qcache_data *data)
 {
 	static time_t runtime;
@@ -855,7 +856,7 @@ void qcache_stats(qcache_data *data)
 	}
 }
 
-void qcache_testing_only(qcache_data *data);
+_q_static
 void qcache_testing_only(qcache_data *data)
 {
 	static int possible = 0;
@@ -903,8 +904,8 @@ void qcache_testing_only(qcache_data *data)
  * ERR:
  *  -1 is returned on error.
  */
-int qcache_init();
-int qcache_init()
+_q_static
+int qcache_init(void)
 {
 	char *filename;
 	unsigned int len;
@@ -933,8 +934,8 @@ int qcache_init()
  *
  * Deallocate variables (archlist)
  */
-void qcache_free();
-void qcache_free()
+_q_static
+void qcache_free(void)
 {
 	qcache_free_lines(archlist);
 }


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     53eb581c73a37cee5dbff7dd36f6c47379d97c02
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 07:31:33 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 18 07:31:33 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=53eb581c

build with -Wold-style-definition to weed out old bad func definitions

---
 Makefile | 5 +++--
 main.c   | 6 +++---
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/Makefile b/Makefile
index 717352d..bda2deb 100644
--- a/Makefile
+++ b/Makefile
@@ -1,6 +1,6 @@
 # Copyright 2005-2008 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-projects/portage-utils/Makefile,v 1.76 2013/09/29 22:12:51 vapier Exp $
+# $Header: /var/cvsroot/gentoo-projects/portage-utils/Makefile,v 1.77 2014/02/18 07:31:33 vapier Exp $
 ####################################################################
 
 check_gcc=$(shell if $(CC) $(1) -S -o /dev/null -xc /dev/null > /dev/null 2>&1; \
@@ -13,7 +13,8 @@ WFLAGS    := -Wall -Wunused -Wimplicit -Wshadow -Wformat=2 \
              -Wchar-subscripts -Wcast-align -Wno-format-nonliteral \
              $(call check_gcc, -Wsequence-point) \
              $(call check_gcc, -Wextra) \
-             $(call check_gcc, -Wno-sign-compare)
+             $(call check_gcc, -Wno-sign-compare) \
+             $(call check_gcc, -Wold-style-definition)
 
 CFLAGS    ?= -O2 -g -pipe
 CFLAGS    += -std=gnu99

diff --git a/main.c b/main.c
index e87dbee..828c10f 100644
--- a/main.c
+++ b/main.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2013 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.230 2014/02/18 07:26:14 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.c,v 1.231 2014/02/18 07:31:33 vapier Exp $
  *
  * Copyright 2005-2008 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2013 Mike Frysinger  - <vapier@gentoo.org>
@@ -69,8 +69,8 @@ void init_coredumps(void)
 /* include common library code */
 #include "libq/libq.c"
 
-void no_colors(void);
-void no_colors()
+_q_static
+void no_colors(void)
 {
 	/* echo $(awk '{print $4,"="}' libq/colors.c  | grep ^* |cut -c 2-| grep ^[A-Z] |tr '\n' ' ') = \"\"\;  */
 	BOLD = NORM = BLUE = DKBLUE = CYAN = GREEN = DKGREEN = MAGENTA = RED = YELLOW = BRYELLOW = WHITE = "";


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     005c787741d0506fbbd497c91a6f643f178bb7da
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 06:58:45 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 18 06:58:45 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=005c7877

qmerge: auto fix local Packages files via `emaint binhost --fix`

---
 qmerge.c | 55 +++++++++++++++++++++++++++++++++++++++++++------------
 1 file changed, 43 insertions(+), 12 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 63855b6..479c551 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.136 2014/02/18 06:58:13 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.137 2014/02/18 06:58:45 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@ static const char * const qmerge_opts_help[] = {
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.136 2014/02/18 06:58:13 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.137 2014/02/18 06:58:45 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -1378,7 +1378,7 @@ pkg_fetch(int level, const depend_atom *atom, const struct pkg_t *pkg)
 	}
 	if (access(buf, R_OK) == 0) {
 		if (!pkg->SHA1[0] && !pkg->MD5[0]) {
-			warn("No checksum data for %s", buf);
+			warn("No checksum data for %s (try `emaint binhost --fix`)", buf);
 			return;
 		} else {
 			if (pkg_verify_checksums(buf, pkg, atom, qmerge_strict, !quiet) == 0) {
@@ -1520,20 +1520,51 @@ _q_static FILE *
 open_binpkg_index(void)
 {
 	FILE *fp;
-	char buf[BUFSIZ];
+	char *path;
 
-	snprintf(buf, sizeof(buf), "%s/portage/%s", port_tmpdir, Packages);
-	fp = fopen(buf, "r");
+	xasprintf(&path, "%s/portage/%s", port_tmpdir, Packages);
+	fp = fopen(path, "r");
 	if (fp)
-		return fp;
+		goto done;
+	free(path);
 
-	snprintf(buf, sizeof(buf), "%s/%s", pkgdir, Packages);
-	fp = fopen(buf, "r");
+	xasprintf(&path, "%s/%s", pkgdir, Packages);
+	fp = fopen(path, "r");
 	if (fp)
-		return fp;
+		goto done;
 
-	errp("Unable to open package file %s in %s/portage or %s",
+	/* This is normal when installing from local repo only. */
+	warnp("Unable to open package file %s in %s/portage or %s",
 		Packages, port_tmpdir, pkgdir);
+	warn("Attempting to manually regen via `emaint binhost`");
+
+	pid_t p;
+	int status;
+
+	char argv_emaint[] = "emaint";
+	char argv_binhost[] = "binhost";
+	char argv_fix[] = "--fix";
+	char *argv[] = {
+		argv_emaint,
+		argv_binhost,
+		argv_fix,
+		NULL,
+	};
+
+	p = vfork();
+	switch (p) {
+	case 0:
+		_exit(execvp(argv[0], argv));
+	case -1:
+		errp("vfork failed");
+	}
+	waitpid(p, &status, 0);
+
+	fp = fopen(path, "r");
+
+ done:
+	free(path);
+	return fp;
 }
 
 _q_static struct pkg_t *
@@ -1812,7 +1843,7 @@ parse_packages(queue *todo)
 	free(buf);
 	fclose(fp);
 
-	return 0;
+	return EXIT_SUCCESS;
 }
 
 _q_static queue *


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     4d597a585db0fa017b373d2e096906b3df85fee3
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  7 19:48:45 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Jan  7 19:48:45 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=4d597a58

qcache/qcheck: use O_CLOEXEC in more places

---
 qcache.c | 8 ++++----
 qcheck.c | 6 +++---
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/qcache.c b/qcache.c
index 1d9a6eb..1218417 100644
--- a/qcache.c
+++ b/qcache.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qcache.c,v 1.46 2013/09/29 18:40:22 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qcache.c,v 1.47 2014/01/07 19:48:45 vapier Exp $
  *
  * Copyright 2006 Thomas A. Cort - <tcort@gentoo.org>
  */
@@ -47,7 +47,7 @@ static const char * const qcache_opts_help[] = {
 	COMMON_OPTS_HELP
 };
 
-static const char qcache_rcsid[] = "$Id: qcache.c,v 1.46 2013/09/29 18:40:22 vapier Exp $";
+static const char qcache_rcsid[] = "$Id: qcache.c,v 1.47 2014/01/07 19:48:45 vapier Exp $";
 #define qcache_usage(ret) usage(ret, QCACHE_FLAGS, qcache_long_opts, qcache_opts_help, lookup_applet_idx("qcache"))
 
 /********************************************************************/
@@ -236,7 +236,7 @@ static unsigned int qcache_count_lines(char *filename)
 	int count, fd;
 	char c;
 
-	if ((fd = open(filename, O_RDONLY)) != -1) {
+	if ((fd = open(filename, O_RDONLY|O_CLOEXEC)) != -1) {
 		count = 0;
 
 		while (read(fd, &c, 1) == 1)
@@ -274,7 +274,7 @@ char **qcache_read_lines(char *filename)
 	len   = sizeof(char*) * (num_lines + 1);
 	lines = xzalloc(len);
 
-	if ((fd = open(filename, O_RDONLY)) != -1) {
+	if ((fd = open(filename, O_RDONLY|O_CLOEXEC)) != -1) {
 		for (i = 0; i < num_lines; i++) {
 			count = 0;
 

diff --git a/qcheck.c b/qcheck.c
index a224a72..0cb5afe 100644
--- a/qcheck.c
+++ b/qcheck.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2011 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qcheck.c,v 1.58 2013/04/21 04:28:10 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qcheck.c,v 1.59 2014/01/07 19:48:45 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2011 Mike Frysinger  - <vapier@gentoo.org>
@@ -36,7 +36,7 @@ static const char * const qcheck_opts_help[] = {
 	"Undo prelink when calculating checksums",
 	COMMON_OPTS_HELP
 };
-static const char qcheck_rcsid[] = "$Id: qcheck.c,v 1.58 2013/04/21 04:28:10 vapier Exp $";
+static const char qcheck_rcsid[] = "$Id: qcheck.c,v 1.59 2014/01/07 19:48:45 vapier Exp $";
 #define qcheck_usage(ret) usage(ret, QCHECK_FLAGS, qcheck_long_opts, qcheck_opts_help, lookup_applet_idx("qcheck"))
 
 #define qcprintf(fmt, args...) if (!state->bad_only) printf(_(fmt), ## args)
@@ -71,7 +71,7 @@ static int qcheck_process_contents(q_vdb_pkg_ctx *pkg_ctx, struct qcheck_opt_sta
 
 	fpx = NULL;
 
-	fd = q_vdb_pkg_openat(pkg_ctx, "CONTENTS", O_RDONLY);
+	fd = q_vdb_pkg_openat(pkg_ctx, "CONTENTS", O_RDONLY|O_CLOEXEC);
 	if (fd == -1)
 		return EXIT_SUCCESS;
 	if (fstat(fd, &cst)) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     6b7e1d8f6a033b8ee25d422be8053280b0e0f248
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 06:58:13 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 18 06:58:13 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=6b7e1d8f

qmerge: add emake/FILESDIR definitions

for now, we disable FILESDIR on the assumption there is no PORTDIR anywhere

---
 qmerge.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 35be0f3..63855b6 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.135 2014/02/18 06:57:41 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.136 2014/02/18 06:58:13 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@ static const char * const qmerge_opts_help[] = {
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.135 2014/02/18 06:57:41 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.136 2014/02/18 06:58:13 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -453,11 +453,13 @@ pkg_run_func(const char *vdb_path, const char *phases, const char *func, const c
 		"die() { eerror \"$@\"; exit 1; }\n"
 		"ebegin() { printf ' * %%b ...' \"$*\"; }\n"
 		"eend() { local r=${1:-$?}; [ $# -gt 0 ] && shift; [ $r -eq 0 ] && echo ' [ ok ]' || echo \" $* \"'[ !! ]'; return $r; }\n"
+		"emake() { ${MAKE:-make} ${MAKEOPTS} \"$@\"; }\n"
 		/* Unpack the env if need be */
 		"[ -e '%1$s/environment' ] || { bzip2 -dc '%1$s/environment.bz2' > '%1$s/environment' || exit 1; }\n"
 		/* Load the main env */
 		". '%1$s/environment'\n"
 		/* Reload env vars that matter to us */
+		"FILESDIR=/.does/not/exist/anywhere\n"
 		"MERGE_TYPE=binary\n"
 		"ROOT='%4$s'\n"
 		"EROOT=\"${EPREFIX%%/}/${ROOT#/}\"\n"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     bc4ec7b25478551ea150794f4990c01c2424c3cf
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 06:57:41 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 18 06:57:41 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=bc4ec7b2

qmerge: fix has_version definition -- qlist always exits 0, but writes updates to stdout

---
 qmerge.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 1c5aaaa..35be0f3 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.134 2014/02/18 04:32:52 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.135 2014/02/18 06:57:41 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@ static const char * const qmerge_opts_help[] = {
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.134 2014/02/18 04:32:52 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.135 2014/02/18 06:57:41 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -437,7 +437,7 @@ pkg_run_func(const char *vdb_path, const char *phases, const char *func, const c
 		"debug-print-function() { :; }\n"
 		"debug-print-section() { :; }\n"
 		/* Not quite right */
-		"has_version() { qlist -ICq -e '$1' >/dev/null; }\n"
+		"has_version() { [ -n \"$(qlist -ICqe \"$1\")\" ]; }\n"
 		/* best_version() */
 		"use() { useq \"$@\"; }\n"
 		"usex() { useq \"$1\" && echo \"${2-yes}$4\" || echo \"${3-no}$5\"; }\n"


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     42813bf37d0aba98b534639928cb370359846a7e
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Mon Feb 17 06:32:33 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Mon Feb 17 06:32:33 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=42813bf3

qmerge: do not require PORTAGE_BINHOST all the time

perfectly reasonable to only install local binpkgs

---
 qmerge.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 5ec9be8..9a42269 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.132 2014/02/16 21:14:24 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.133 2014/02/17 06:32:33 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@ static const char * const qmerge_opts_help[] = {
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.132 2014/02/16 21:14:24 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.133 2014/02/17 06:32:33 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -113,16 +113,15 @@ _q_static char *find_binpkg(const char *);
 
 _q_static void fetch(const char *destdir, const char *src)
 {
-	char buf[BUFSIZ];
-
 	if (!binhost[0])
-		errf("PORTAGE_BINHOST= does not appear to be valid");
+		return;
 
 	fflush(stdout);
 	fflush(stderr);
 
 #if 0
 	if (getenv("FETCHCOMMAND") != NULL) {
+		char buf[BUFSIZ];
 		snprintf(buf, sizeof(buf), "(export DISTDIR='%s' URI='%s/%s'; %s)",
 			destdir, binhost, src, getenv("FETCHCOMMAND"));
 		xsystem(buf);
@@ -131,6 +130,7 @@ _q_static void fetch(const char *destdir, const char *src)
 	{
 		pid_t p;
 		int status;
+		char *path;
 
 		char prog[] = "wget";
 		char argv_c[] = "-c";
@@ -142,18 +142,23 @@ _q_static void fetch(const char *destdir, const char *src)
 			argv_c,
 			argv_P,
 			argv_dir,
-			buf,
+			path,
 			quiet ? argv_q : NULL,
 			NULL,
 		};
 		if (!(force_download || install) && pretend)
 			strcpy(prog, "echo");
-		snprintf(buf, sizeof(buf), "%s/%s", binhost, src);
+		xasprintf(&path, "%s/%s", binhost, src);
 
 		p = vfork();
-		if (p == 0)
+		switch (p) {
+		case 0:
 			_exit(execvp(prog, argv));
+		case -1:
+			errp("vfork failed");
+		}
 
+		free(path);
 		free(argv_dir);
 
 		waitpid(p, &status, 0);


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     607b2fbe22eaecd7d9779fe08842291f56900696
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 04:32:52 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 18 04:32:52 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=607b2fbe

qmerge: fix path use -- assign it to argv after we init it

---
 qmerge.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 9a42269..1c5aaaa 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.133 2014/02/17 06:32:33 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.134 2014/02/18 04:32:52 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@ static const char * const qmerge_opts_help[] = {
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.133 2014/02/17 06:32:33 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.134 2014/02/18 04:32:52 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -132,6 +132,8 @@ _q_static void fetch(const char *destdir, const char *src)
 		int status;
 		char *path;
 
+		xasprintf(&path, "%s/%s", binhost, src);
+
 		char prog[] = "wget";
 		char argv_c[] = "-c";
 		char argv_P[] = "-P";
@@ -148,7 +150,6 @@ _q_static void fetch(const char *destdir, const char *src)
 		};
 		if (!(force_download || install) && pretend)
 			strcpy(prog, "echo");
-		xasprintf(&path, "%s/%s", binhost, src);
 
 		p = vfork();
 		switch (p) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     d4721df8434a3c56cf8a246dd634bc7af7eee019
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Feb 18 04:32:04 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Feb 18 04:32:04 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=d4721df8

update default URL list to match current tinderbox server

---
 main.h | 73 ++++++++++++++++++++++++++++++++++++++++++++++++++----------------
 1 file changed, 56 insertions(+), 17 deletions(-)

diff --git a/main.h b/main.h
index e2e82d1..43f219c 100644
--- a/main.h
+++ b/main.h
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.h,v 1.16 2013/09/29 22:42:36 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/main.h,v 1.17 2014/02/18 04:32:04 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -22,25 +22,64 @@
 /* http://tinderbox.dev.gentoo.org/default-linux/hppa */
 
 #ifdef __linux__
-#undef  URL
-#define URL "http://tinderbox.dev.gentoo.org"
-# ifdef __i386__
-#  ifdef __UCLIBC__
-#   define DEFAULT_PORTAGE_BINHOST URL "/uclibc/i386"
+# undef URL_BASE
+# define URL_BASE "http://tinderbox.dev.gentoo.org"
+
+# undef URL_PROFILE
+# ifdef __UCLIBC__
+#  define URL_PROFILE "uclibc"
+# else
+#  ifdef __SSP__
+#   define URL_PROFILE "hardened"
+#  else
+#   define URL_PROFILE "default/linux"
+#  endif
+# endif
+
+# undef URL_ARCH
+# if 0
+# elif defined(__alpha__)
+#  define URL_ARCH "alpha"
+# elif defined(__x86_64__)
+#  define URL_ARCH "amd64"
+# elif defined(__arm__)
+#  define URL_ARCH "arm"
+# elif defined(__aarch64__)
+#  define URL_ARCH "arm64"
+# elif defined(__bfin__)
+#  define URL_ARCH "bfin"
+# elif defined(__cris__)
+#  define URL_ARCH "cris"
+# elif defined(__hppa__)
+#  define URL_ARCH "hppa"
+# elif defined(__ia64__)
+#  define URL_ARCH "ia64"
+# elif defined(__m68k__)
+#  define URL_ARCH "m68k"
+# elif defined(__mips__)
+#  define URL_ARCH "mips"
+# elif defined(__powerpc__)
+#  if defined(__powerpc64__)
+#   define URL_ARCH "ppc64"
 #  else
-#   ifdef __SSP__
-#    define DEFAULT_PORTAGE_BINHOST URL "/hardened/x86"
-#   else
-#    define DEFAULT_PORTAGE_BINHOST URL "/default-linux/x86/All"
-#   endif
+#   define URL_ARCH "ppc"
 #  endif
-#  if defined(__powerpc__) && defined(__SSP__)
-#   if !defined(__UCLIBC__)
-#    define DEFAULT_PORTAGE_BINHOST URL "/hardened/ppc"
-#   else
-#    define DEFAULT_PORTAGE_BINHOST URL "/uclibc/ppc"
-#   endif
+# elif defined(__s390__)
+#  if defined(__s390x__)
+#   define URL_ARCH "s390x"
+#  else
+#   define URL_ARCH "s390"
 #  endif
+# elif defined(__sh4__)
+#  define URL_ARCH "sh"
+# elif defined(__sparc__)
+#  define URL_ARCH "sparc"
+# elif defined(__i386__)
+#  define URL_ARCH "x86"
+# endif
+
+# if defined(URL_PROFILE) && defined(URL_ARCH)
+#  define DEFAULT_PORTAGE_BINHOST URL_BASE "/" URL_PROFILE "/" URL_ARCH
 # endif
 #endif
 


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     66abc9176f7916222cfb694ba04abd43c3690d27
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 29 22:19:39 2013 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Sep 29 22:19:39 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=66abc917

qdepends: warn if no matches were found #459970

---
 qdepends.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/qdepends.c b/qdepends.c
index a7bb8d5..dad3f02 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2013 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.65 2013/09/29 10:36:08 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qdepends.c,v 1.66 2013/09/29 22:19:39 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2013 Mike Frysinger  - <vapier@gentoo.org>
@@ -32,7 +32,7 @@ static const char * const qdepends_opts_help[] = {
 	"Pretty format specified depend strings",
 	COMMON_OPTS_HELP
 };
-static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.65 2013/09/29 10:36:08 vapier Exp $";
+static const char qdepends_rcsid[] = "$Id: qdepends.c,v 1.66 2013/09/29 22:19:39 vapier Exp $";
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, qdepends_opts_help, lookup_applet_idx("qdepends"))
 
 static char qdep_name_only = 0;
@@ -465,7 +465,7 @@ _q_static int qdepends_main_vdb_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 
 	dep_burn_tree(dep_tree);
 
-	return EXIT_SUCCESS;
+	return 1;
 }
 
 _q_static int qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
@@ -523,7 +523,7 @@ _q_static int qdepends_vdb_deep_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 	}
 	dep_burn_tree(dep_tree);
 
-	return EXIT_SUCCESS;
+	return 1;
 }
 
 int qdepends_main(int argc, char **argv)
@@ -533,7 +533,7 @@ int qdepends_main(int argc, char **argv)
 		.argv = argv,
 	};
 	q_vdb_pkg_cb *cb;
-	int i;
+	int i, ret;
 	bool do_format = false;
 	const char *query = NULL;
 	const char *depend_file;
@@ -576,16 +576,18 @@ int qdepends_main(int argc, char **argv)
 	cb = query ? qdepends_vdb_deep_cb : qdepends_main_vdb_cb;
 
 	if (!depend_file) {
-		int ret = 0;
+		ret = 0;
 		for (i = 0; depend_files[i]; ++i) {
 			printf(" %s*%s %s\n", GREEN, NORM, depend_files[i]);
 			state.depend_file = depend_files[i];
-			ret += q_vdb_foreach_pkg(cb, &state, NULL);
+			ret |= q_vdb_foreach_pkg(cb, &state, NULL);
 		}
-		return ret;
-	}
+	} else
+		ret = q_vdb_foreach_pkg(cb, &state, NULL);
 
-	return q_vdb_foreach_pkg(cb, &state, NULL);
+	if (!ret && !quiet)
+		warn("no matches found for your query");
+	return ret ? EXIT_SUCCESS : EXIT_FAILURE;
 }
 
 #else


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     c366372b1b05c83844902c1bbe19e020471c9c73
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Tue Jan  7 19:17:25 2014 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Tue Jan  7 19:17:25 2014 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=c366372b

qmerge: ignore unmerge errors due to missing files in case someone already did `rm` on it

---
 qmerge.c | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/qmerge.c b/qmerge.c
index 9b7f152..40d4139 100644
--- a/qmerge.c
+++ b/qmerge.c
@@ -1,7 +1,7 @@
 /*
  * Copyright 2005-2010 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
- * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.130 2013/05/09 05:28:11 vapier Exp $
+ * $Header: /var/cvsroot/gentoo-projects/portage-utils/qmerge.c,v 1.131 2014/01/07 19:17:25 vapier Exp $
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
  * Copyright 2005-2010 Mike Frysinger  - <vapier@gentoo.org>
@@ -65,7 +65,7 @@ static const char * const qmerge_opts_help[] = {
 	COMMON_OPTS_HELP
 };
 
-static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.130 2013/05/09 05:28:11 vapier Exp $";
+static const char qmerge_rcsid[] = "$Id: qmerge.c,v 1.131 2014/01/07 19:17:25 vapier Exp $";
 #define qmerge_usage(ret) usage(ret, QMERGE_FLAGS, qmerge_long_opts, qmerge_opts_help, lookup_applet_idx("qmerge"))
 
 char search_pkgs = 0;
@@ -1157,8 +1157,11 @@ pkg_unmerge(const char *cat, const char *pkgname, queue *keep)
 		if (!keep || q) {
 			char *p;
 
-			if (unlinkat(portroot_fd, e->name + 1, 0))
-				errp("could not unlink: %s%s", portroot, e->name + 1);
+			if (unlinkat(portroot_fd, e->name + 1, 0)) {
+				/* If a file was already deleted, ignore the error */
+				if (errno != ENOENT)
+					errp("could not unlink: %s%s", portroot, e->name + 1);
+			}
 
 			p = strrchr(e->name, '/');
 			if (p) {


^ permalink raw reply related	[flat|nested] 592+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: /
@ 2014-03-08  5:51 Mike Frysinger
  0 siblings, 0 replies; 592+ messages in thread
From: Mike Frysinger @ 2014-03-08  5:51 UTC (permalink / raw
  To: gentoo-commits

commit:     c0117af5bc140fce36c76eb9f2ea70c23c352da5
Author:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
AuthorDate: Sun Sep 29 22:16:09 2013 +0000
Commit:     Mike Frysinger <vapier <AT> gentoo <DOT> org>
CommitDate: Sun Sep 29 22:16:09 2013 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage-utils.git;a=commit;h=c0117af5

add more todo stuff

---
 TODO | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/TODO b/TODO
index efa89c6..5f1f382 100644
--- a/TODO
+++ b/TODO
@@ -36,6 +36,13 @@
 	- these limits should not be an issue for all practical purposes
 	- need to handle USE deps like: cat/pkg-123[foo(+)]
 
+- qcache:
+	- need to convert it to new metadata/md5 style
+
+- qdepends:
+	- support querying uninstalled packages (via metadata/md5 cache)
+	- verify version matching works: qdepend =nano-2*
+
 - env vars only get expanded once, so this fails:
 	ACCEPT_LICENSE="foo"
 	ACCEPT_LICENSE="${ACCEPT_LICENSE} bar"


^ permalink raw reply related	[flat|nested] 592+ messages in thread

end of thread, other threads:[~2024-07-03 19:44 UTC | newest]

Thread overview: 592+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-13 14:27 [gentoo-commits] proj/portage-utils:master commit in: / Fabian Groffen
  -- strict thread matches above, loose matches on Subject: below --
2024-07-03 19:44 Fabian Groffen
2024-06-28 19:51 Fabian Groffen
2024-06-27 19:19 Fabian Groffen
2024-04-20 13:05 Fabian Groffen
2024-03-29 11:22 Fabian Groffen
2024-03-29 10:58 Fabian Groffen
2024-03-29 10:57 Fabian Groffen
2024-01-02 13:16 Fabian Groffen
2024-01-02 13:16 Fabian Groffen
2024-01-02  7:57 Fabian Groffen
2024-01-01 10:37 Fabian Groffen
2023-12-20 21:32 Mike Frysinger
2023-07-18  6:28 Fabian Groffen
2023-07-18  6:28 Fabian Groffen
2023-04-21 19:11 Fabian Groffen
2023-03-01 21:00 Fabian Groffen
2023-02-22 20:06 Fabian Groffen
2023-02-07  8:10 Fabian Groffen
2022-12-15  9:13 Fabian Groffen
2022-12-15  9:03 Fabian Groffen
2022-12-15  9:03 Fabian Groffen
2022-11-16  8:59 Fabian Groffen
2022-08-29  8:44 Fabian Groffen
2022-08-29  8:44 Fabian Groffen
2022-08-28 12:26 Fabian Groffen
2022-08-28 12:26 Fabian Groffen
2022-06-14  6:36 Fabian Groffen
2022-05-26 14:53 Fabian Groffen
2022-05-20 17:15 Fabian Groffen
2022-04-06 19:31 Fabian Groffen
2022-02-27 12:29 Fabian Groffen
2022-02-23 11:57 Fabian Groffen
2022-02-23 11:57 Fabian Groffen
2022-02-12 18:31 Fabian Groffen
2022-02-12 18:31 Fabian Groffen
2022-02-12 18:31 Fabian Groffen
2022-02-12 17:13 Fabian Groffen
2022-02-12 17:13 Fabian Groffen
2022-02-12 17:13 Fabian Groffen
2022-02-12 17:13 Fabian Groffen
2022-02-12 17:13 Fabian Groffen
2022-02-12 16:14 Fabian Groffen
2022-02-07  7:16 Fabian Groffen
2022-02-06 15:21 Fabian Groffen
2022-02-06 14:51 Fabian Groffen
2022-02-06 14:29 Fabian Groffen
2022-02-06 14:29 Fabian Groffen
2022-01-31  8:01 Fabian Groffen
2021-12-31 15:36 Fabian Groffen
2021-12-31 15:36 Fabian Groffen
2021-12-31 15:36 Fabian Groffen
2021-12-29 12:20 Fabian Groffen
2021-12-27 18:13 Fabian Groffen
2021-12-26 13:59 Fabian Groffen
2021-12-25  9:15 Fabian Groffen
2021-12-23 12:55 Fabian Groffen
2021-12-21 11:30 Fabian Groffen
2021-12-13  8:39 Fabian Groffen
2021-12-13  8:39 Fabian Groffen
2021-12-13  8:39 Fabian Groffen
2021-11-13 14:27 Fabian Groffen
2021-11-07 10:53 Fabian Groffen
2021-10-09 12:03 Fabian Groffen
2021-10-03 11:15 Fabian Groffen
2021-10-03  8:54 Fabian Groffen
2021-09-27 18:14 Fabian Groffen
2021-07-06  6:43 Fabian Groffen
2021-07-05  8:40 Fabian Groffen
2021-07-01 10:07 Fabian Groffen
2021-07-01 10:05 Fabian Groffen
2021-06-30  6:26 Fabian Groffen
2021-06-24  6:44 Fabian Groffen
2021-06-23  7:14 Fabian Groffen
2021-06-21 20:04 Fabian Groffen
2021-06-17  6:27 Fabian Groffen
2021-06-16 20:11 Fabian Groffen
2021-06-16 19:21 Fabian Groffen
2021-06-16 19:21 Fabian Groffen
2021-06-16 19:21 Fabian Groffen
2021-06-16 19:21 Fabian Groffen
2021-06-16 19:21 Fabian Groffen
2021-06-16 19:21 Fabian Groffen
2021-06-16 19:19 Fabian Groffen
2021-06-01 19:43 Fabian Groffen
2021-06-01 19:43 Fabian Groffen
2021-05-31 19:14 Fabian Groffen
2021-05-15 12:19 Fabian Groffen
2021-05-10  9:16 Fabian Groffen
2021-05-02 11:32 Fabian Groffen
2021-05-02 11:25 Fabian Groffen
2021-05-02 11:25 Fabian Groffen
2021-05-01 19:32 Fabian Groffen
2021-05-01  8:40 Fabian Groffen
2021-03-13 20:32 Fabian Groffen
2021-02-20 12:06 Fabian Groffen
2021-02-20 11:44 Fabian Groffen
2021-02-20 11:44 Fabian Groffen
2021-02-17 20:23 Fabian Groffen
2020-11-29  9:13 Fabian Groffen
2020-11-21 10:53 Fabian Groffen
2020-11-21 10:45 Fabian Groffen
2020-11-21 10:00 Fabian Groffen
2020-11-21  9:53 Fabian Groffen
2020-11-21  8:53 Fabian Groffen
2020-11-14 17:06 Fabian Groffen
2020-11-14 17:06 Fabian Groffen
2020-11-13  9:32 Fabian Groffen
2020-10-04 19:30 Fabian Groffen
2020-10-04 19:06 Fabian Groffen
2020-10-04 18:46 Fabian Groffen
2020-10-04 18:44 Fabian Groffen
2020-10-04 12:33 Fabian Groffen
2020-10-04 11:54 Fabian Groffen
2020-10-04 11:31 Fabian Groffen
2020-10-04 11:09 Fabian Groffen
2020-08-17 14:34 Fabian Groffen
2020-08-17 13:08 Fabian Groffen
2020-08-17 13:08 Fabian Groffen
2020-08-14 10:44 Fabian Groffen
2020-08-14 10:09 Fabian Groffen
2020-08-14  9:35 Fabian Groffen
2020-08-14  9:35 Fabian Groffen
2020-08-02  7:39 Fabian Groffen
2020-07-08  8:12 Fabian Groffen
2020-06-28 19:11 Fabian Groffen
2020-06-28 15:58 Fabian Groffen
2020-06-27  9:38 Fabian Groffen
2020-06-27  9:38 Fabian Groffen
2020-05-25 19:01 Fabian Groffen
2020-05-25 18:29 Fabian Groffen
2020-05-25 18:25 Fabian Groffen
2020-05-25 18:08 Fabian Groffen
2020-05-25 18:05 Fabian Groffen
2020-05-25 11:20 Fabian Groffen
2020-05-25 11:12 Fabian Groffen
2020-05-25 10:43 Fabian Groffen
2020-05-25 10:43 Fabian Groffen
2020-05-21 11:13 Fabian Groffen
2020-05-17 12:35 Fabian Groffen
2020-05-17 12:35 Fabian Groffen
2020-05-17 12:35 Fabian Groffen
2020-05-17 12:35 Fabian Groffen
2020-05-17  8:27 Fabian Groffen
2020-05-17  8:27 Fabian Groffen
2020-05-17  8:15 Fabian Groffen
2020-05-16 18:51 Fabian Groffen
2020-05-16 14:30 Fabian Groffen
2020-05-16 13:06 Fabian Groffen
2020-05-16 13:06 Fabian Groffen
2020-05-02  8:45 Fabian Groffen
2020-04-27  7:46 Fabian Groffen
2020-02-21  8:50 Fabian Groffen
2020-02-21  8:18 Fabian Groffen
2020-01-31 14:45 Fabian Groffen
2020-01-31 13:26 Fabian Groffen
2020-01-31 13:26 Fabian Groffen
2020-01-31 13:26 Fabian Groffen
2020-01-31 10:49 Fabian Groffen
2020-01-31 10:49 Fabian Groffen
2020-01-31 10:49 Fabian Groffen
2020-01-26 19:31 Fabian Groffen
2020-01-25 12:20 Fabian Groffen
2020-01-25 12:20 Fabian Groffen
2020-01-25 12:11 Fabian Groffen
2020-01-25 10:01 Fabian Groffen
2020-01-25  9:45 Fabian Groffen
2020-01-25  9:11 Fabian Groffen
2020-01-25  9:11 Fabian Groffen
2020-01-25  9:03 Fabian Groffen
2020-01-25  9:03 Fabian Groffen
2020-01-25  9:03 Fabian Groffen
2020-01-25  9:03 Fabian Groffen
2020-01-25  9:03 Fabian Groffen
2020-01-22 20:11 Fabian Groffen
2020-01-22 20:11 Fabian Groffen
2020-01-22 20:11 Fabian Groffen
2020-01-22 20:04 Fabian Groffen
2020-01-22 20:04 Fabian Groffen
2020-01-22 20:04 Fabian Groffen
2020-01-22 20:04 Fabian Groffen
2020-01-22 19:54 Fabian Groffen
2020-01-22 19:54 Fabian Groffen
2020-01-22 19:54 Fabian Groffen
2020-01-22 19:54 Fabian Groffen
2020-01-22 19:54 Fabian Groffen
2020-01-22 19:54 Fabian Groffen
2020-01-22 19:54 Fabian Groffen
2020-01-20 19:54 Fabian Groffen
2020-01-19 19:36 Fabian Groffen
2020-01-19 19:36 Fabian Groffen
2020-01-19 19:36 Fabian Groffen
2020-01-19 19:36 Fabian Groffen
2020-01-19 19:36 Fabian Groffen
2020-01-19 19:36 Fabian Groffen
2020-01-19 19:09 Fabian Groffen
2020-01-19 19:09 Fabian Groffen
2020-01-19 19:09 Fabian Groffen
2020-01-19 19:09 Fabian Groffen
2020-01-19 19:09 Fabian Groffen
2020-01-19 19:09 Fabian Groffen
2020-01-19 19:09 Fabian Groffen
2020-01-19 19:09 Fabian Groffen
2020-01-19 16:40 Fabian Groffen
2020-01-19 16:37 Fabian Groffen
2020-01-19 16:37 Fabian Groffen
2020-01-19 12:37 Fabian Groffen
2020-01-19 12:37 Fabian Groffen
2020-01-19 12:37 Fabian Groffen
2020-01-19 12:37 Fabian Groffen
2020-01-19 12:37 Fabian Groffen
2020-01-19 12:37 Fabian Groffen
2020-01-19 12:37 Fabian Groffen
2020-01-19 12:37 Fabian Groffen
2020-01-18 13:09 Fabian Groffen
2020-01-06  8:03 Fabian Groffen
2020-01-06  7:36 Fabian Groffen
2020-01-05 16:08 Fabian Groffen
2020-01-05 16:08 Fabian Groffen
2020-01-05 16:08 Fabian Groffen
2020-01-05 13:28 Fabian Groffen
2020-01-04 20:02 Fabian Groffen
2020-01-04 19:48 Fabian Groffen
2020-01-04 13:28 Fabian Groffen
2020-01-04 10:44 Fabian Groffen
2020-01-04 10:38 Fabian Groffen
2020-01-04 10:27 Fabian Groffen
2020-01-04 10:20 Fabian Groffen
2020-01-03 15:05 Fabian Groffen
2020-01-03 14:58 Fabian Groffen
2020-01-03 10:36 Fabian Groffen
2020-01-02 20:27 Fabian Groffen
2020-01-02 20:00 Fabian Groffen
2020-01-02 15:32 Fabian Groffen
2020-01-02 15:09 Fabian Groffen
2020-01-02 15:09 Fabian Groffen
2020-01-02 14:07 Fabian Groffen
2020-01-02 14:07 Fabian Groffen
2020-01-02 14:07 Fabian Groffen
2020-01-02 14:07 Fabian Groffen
2020-01-02 11:55 Fabian Groffen
2020-01-02  9:47 Fabian Groffen
2020-01-01 19:57 Fabian Groffen
2019-12-31  9:10 Fabian Groffen
2019-12-31  9:05 Fabian Groffen
2019-12-29 12:35 Fabian Groffen
2019-12-29  9:57 Fabian Groffen
2019-12-27 21:45 Fabian Groffen
2019-12-27 21:14 Fabian Groffen
2019-12-27 19:16 Fabian Groffen
2019-12-14 17:01 Fabian Groffen
2019-12-14 17:01 Fabian Groffen
2019-12-14 17:01 Fabian Groffen
2019-12-08 11:53 Fabian Groffen
2019-11-29 13:56 Fabian Groffen
2019-11-29 13:22 Fabian Groffen
2019-11-25 19:51 Fabian Groffen
2019-11-25 19:39 Fabian Groffen
2019-11-19 20:28 Fabian Groffen
2019-11-19 20:28 Fabian Groffen
2019-11-17 15:12 Fabian Groffen
2019-11-17 15:12 Fabian Groffen
2019-11-17 15:12 Fabian Groffen
2019-11-17 15:12 Fabian Groffen
2019-11-17 15:12 Fabian Groffen
2019-11-15 13:52 Fabian Groffen
2019-11-13 18:19 Fabian Groffen
2019-11-13 12:59 Fabian Groffen
2019-11-13 12:53 Fabian Groffen
2019-11-13 12:53 Fabian Groffen
2019-11-09 10:35 Fabian Groffen
2019-10-27 12:23 Fabian Groffen
2019-10-20 10:11 Fabian Groffen
2019-10-12 12:47 Fabian Groffen
2019-10-03 11:50 Fabian Groffen
2019-09-29 12:18 Fabian Groffen
2019-09-28 13:28 Fabian Groffen
2019-09-28 13:06 Fabian Groffen
2019-09-26 19:28 Fabian Groffen
2019-09-26 19:28 Fabian Groffen
2019-09-26 14:06 Fabian Groffen
2019-09-26 14:06 Fabian Groffen
2019-09-21 20:23 Fabian Groffen
2019-09-21 20:17 Fabian Groffen
2019-09-21 19:53 Fabian Groffen
2019-09-10 18:25 Fabian Groffen
2019-08-17  8:37 Fabian Groffen
2019-07-18 17:55 Fabian Groffen
2019-07-14 18:51 Fabian Groffen
2019-07-14 16:27 Fabian Groffen
2019-07-14 16:27 Fabian Groffen
2019-07-14 16:00 Fabian Groffen
2019-07-14 13:09 Fabian Groffen
2019-07-14 13:09 Fabian Groffen
2019-07-14  8:37 Fabian Groffen
2019-06-27  8:54 Fabian Groffen
2019-06-26 19:32 Fabian Groffen
2019-06-19 10:44 Fabian Groffen
2019-06-13 10:52 Fabian Groffen
2019-06-13  9:28 Fabian Groffen
2019-06-13  8:41 Fabian Groffen
2019-06-11 17:55 Fabian Groffen
2019-06-10 18:38 Fabian Groffen
2019-06-10 15:29 Fabian Groffen
2019-06-10 13:31 Fabian Groffen
2019-06-10 12:50 Fabian Groffen
2019-06-10 10:12 Fabian Groffen
2019-06-10 10:09 Fabian Groffen
2019-06-10 10:09 Fabian Groffen
2019-06-10 10:09 Fabian Groffen
2019-06-10 10:09 Fabian Groffen
2019-06-10 10:09 Fabian Groffen
2019-06-09  9:23 Fabian Groffen
2019-06-08 18:42 Fabian Groffen
2019-06-08 18:25 Fabian Groffen
2019-06-08 18:13 Fabian Groffen
2019-06-08 18:13 Fabian Groffen
2019-06-08 18:13 Fabian Groffen
2019-06-08 18:13 Fabian Groffen
2019-06-07 12:20 Fabian Groffen
2019-06-06 13:52 Fabian Groffen
2019-06-06 13:46 Fabian Groffen
2019-06-06 13:46 Fabian Groffen
2019-06-06  8:14 Fabian Groffen
2019-06-05  7:57 Fabian Groffen
2019-05-30 10:23 Fabian Groffen
2019-05-30 10:09 Fabian Groffen
2019-05-30  8:55 Fabian Groffen
2019-05-25 16:04 Fabian Groffen
2019-05-25 14:54 Fabian Groffen
2019-05-25 14:04 Fabian Groffen
2019-05-25 12:19 Fabian Groffen
2019-05-24 12:26 Fabian Groffen
2019-05-22  8:54 Fabian Groffen
2019-05-21 14:42 Fabian Groffen
2019-05-21 14:37 Fabian Groffen
2019-05-21 14:12 Fabian Groffen
2019-05-21 14:12 Fabian Groffen
2019-05-20 12:15 Fabian Groffen
2019-05-20 10:46 Fabian Groffen
2019-05-16 17:13 Fabian Groffen
2019-05-16 17:13 Fabian Groffen
2019-05-16 17:13 Fabian Groffen
2019-05-16 17:13 Fabian Groffen
2019-05-16 13:18 Fabian Groffen
2019-05-15  9:42 Fabian Groffen
2019-05-13 13:39 Fabian Groffen
2019-05-12  9:58 Fabian Groffen
2019-05-12  9:58 Fabian Groffen
2019-05-12  9:58 Fabian Groffen
2019-05-11 11:11 Fabian Groffen
2019-05-11  7:14 Fabian Groffen
2019-05-11  7:14 Fabian Groffen
2019-05-11  7:14 Fabian Groffen
2019-05-11  7:14 Fabian Groffen
2019-05-10 15:32 Fabian Groffen
2019-05-10 15:32 Fabian Groffen
2019-05-10  7:30 Fabian Groffen
2019-05-10  7:30 Fabian Groffen
2019-05-10  7:30 Fabian Groffen
2019-05-07  6:19 Fabian Groffen
2019-05-07  6:19 Fabian Groffen
2019-05-06 16:04 Fabian Groffen
2019-05-06  6:41 Fabian Groffen
2019-05-04 17:23 Fabian Groffen
2019-05-04 11:53 Fabian Groffen
2019-05-03 11:45 Fabian Groffen
2019-05-03  8:50 Fabian Groffen
2019-05-03  8:50 Fabian Groffen
2019-05-03  8:50 Fabian Groffen
2019-05-03  8:50 Fabian Groffen
2019-05-02 16:09 Fabian Groffen
2019-05-02  8:29 Fabian Groffen
2019-04-30  8:02 Fabian Groffen
2019-04-30  7:54 Fabian Groffen
2019-04-28 18:10 Fabian Groffen
2019-04-27  9:01 Fabian Groffen
2019-04-27  8:33 Fabian Groffen
2019-04-25 17:36 Fabian Groffen
2019-04-25  9:48 Fabian Groffen
2019-04-25  9:48 Fabian Groffen
2019-04-25  9:48 Fabian Groffen
2019-04-25  9:22 Fabian Groffen
2019-04-25  9:22 Fabian Groffen
2019-04-25  9:22 Fabian Groffen
2019-04-25  9:22 Fabian Groffen
2019-04-14 10:52 Fabian Groffen
2019-03-27 20:52 Fabian Groffen
2019-03-27 20:37 Fabian Groffen
2019-03-27 20:18 Fabian Groffen
2019-03-18 13:14 Fabian Groffen
2019-03-18 13:14 Fabian Groffen
2019-03-18 13:14 Fabian Groffen
2019-03-12  8:05 Fabian Groffen
2019-03-01 13:51 Fabian Groffen
2019-02-28 18:37 Fabian Groffen
2019-02-28 18:37 Fabian Groffen
2019-02-27 21:18 Fabian Groffen
2019-02-27 20:53 Fabian Groffen
2019-02-23 15:22 Fabian Groffen
2018-12-28  9:08 Fabian Groffen
2018-12-24 16:02 Fabian Groffen
2018-12-20 18:24 Fabian Groffen
2018-12-20 18:24 Fabian Groffen
2018-12-09 10:42 Fabian Groffen
2018-11-20 14:25 Fabian Groffen
2018-10-26 13:50 Fabian Groffen
2018-10-26 13:50 Fabian Groffen
2018-08-06  7:25 Fabian Groffen
2018-08-06  7:25 Fabian Groffen
2018-08-01 13:28 Fabian Groffen
2018-07-18 20:20 Fabian Groffen
2018-06-28  9:35 Fabian Groffen
2018-06-28  9:35 Fabian Groffen
2018-05-18 16:58 Fabian Groffen
2018-05-18 12:19 Fabian Groffen
2018-05-18 12:19 Fabian Groffen
2018-05-18 10:15 Fabian Groffen
2018-04-18 13:58 Fabian Groffen
2018-04-17 20:12 Fabian Groffen
2018-04-15 15:41 Fabian Groffen
2018-04-15 15:38 Fabian Groffen
2018-04-09  7:15 Fabian Groffen
2018-04-09  7:15 Fabian Groffen
2018-04-04 13:16 Fabian Groffen
2018-04-03 20:13 Fabian Groffen
2018-04-03 13:39 Fabian Groffen
2018-04-02 17:27 Fabian Groffen
2018-04-01 10:22 Fabian Groffen
2018-04-01 10:22 Fabian Groffen
2018-03-31  6:54 Fabian Groffen
2018-03-31  6:54 Fabian Groffen
2018-03-31  6:54 Fabian Groffen
2018-03-31  6:54 Fabian Groffen
2018-03-30  5:56 Fabian Groffen
2018-03-30  5:56 Fabian Groffen
2018-03-26 19:08 Fabian Groffen
2018-03-25 14:00 Fabian Groffen
2018-03-23 20:17 Fabian Groffen
2018-03-23 20:17 Fabian Groffen
2018-03-23 15:27 Fabian Groffen
2018-03-23 15:27 Fabian Groffen
2018-03-23 13:17 Fabian Groffen
2018-03-23 11:29 Fabian Groffen
2018-03-23 11:08 Fabian Groffen
2018-03-23  9:37 Fabian Groffen
2018-01-08 12:33 Fabian Groffen
2018-01-08 12:33 Fabian Groffen
2017-12-29 11:45 Fabian Groffen
2017-12-29 11:45 Fabian Groffen
2017-12-29 11:45 Fabian Groffen
2017-11-27  7:55 Robin H. Johnson
2017-11-27  7:55 Robin H. Johnson
2017-02-07  3:03 Mike Frysinger
2016-12-29  2:33 Mike Frysinger
2016-12-29  2:25 Mike Frysinger
2016-12-29  2:25 Mike Frysinger
2016-12-29  2:25 Mike Frysinger
2016-12-29  2:25 Mike Frysinger
2016-12-29  2:25 Mike Frysinger
2016-12-29  2:25 Mike Frysinger
2016-12-20 19:15 Mike Frysinger
2016-12-20 16:55 Mike Frysinger
2016-11-27  5:46 Mike Frysinger
2016-11-27  5:46 Mike Frysinger
2016-11-27  5:46 Mike Frysinger
2016-11-27  1:52 Mike Frysinger
2016-11-27  1:50 Mike Frysinger
2016-11-27  0:00 Mike Frysinger
2016-11-26 23:48 Mike Frysinger
2016-11-26 23:46 Mike Frysinger
2016-11-26 23:24 Mike Frysinger
2016-11-26 23:17 Mike Frysinger
2016-11-15  3:34 Mike Frysinger
2016-11-15  3:34 Mike Frysinger
2016-11-15  3:34 Mike Frysinger
2016-11-15  3:34 Mike Frysinger
2016-11-15  3:34 Mike Frysinger
2016-11-12 17:17 Mike Frysinger
2016-06-21 20:53 Mike Frysinger
2016-06-20  3:22 Mike Frysinger
2016-04-04 15:47 Mike Frysinger
2016-04-01 21:42 Mike Frysinger
2016-04-01 21:42 Mike Frysinger
2016-03-28  4:53 Mike Frysinger
2016-03-28  4:53 Mike Frysinger
2016-03-28  4:53 Mike Frysinger
2016-02-22 20:37 Mike Frysinger
2016-02-22 20:37 Mike Frysinger
2016-02-22 20:37 Mike Frysinger
2016-02-22 20:37 Mike Frysinger
2016-02-17  7:15 Mike Frysinger
2016-02-14  1:26 Mike Frysinger
2016-02-14  1:26 Mike Frysinger
2016-02-14  1:26 Mike Frysinger
2016-01-29  5:53 Mike Frysinger
2016-01-05  0:25 Mike Frysinger
2015-12-17  5:06 Mike Frysinger
2015-12-17  5:06 Mike Frysinger
2015-12-17  5:06 Mike Frysinger
2015-12-17  5:06 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-28  2:44 Mike Frysinger
2015-11-26 10:52 Mike Frysinger
2015-11-26 10:52 Mike Frysinger
2015-11-26 10:39 Mike Frysinger
2015-11-26 10:39 Mike Frysinger
2015-11-26 10:39 Mike Frysinger
2015-11-26 10:39 Mike Frysinger
2015-11-26 10:39 Mike Frysinger
2015-11-26 10:39 Mike Frysinger
2015-11-26 10:39 Mike Frysinger
2015-11-26  8:59 Mike Frysinger
2015-11-26  8:00 Mike Frysinger
2015-09-15 18:27 Mike Frysinger
2015-06-23  8:58 Mike Frysinger
2015-06-06  6:20 Mike Frysinger
2015-06-06  6:20 Mike Frysinger
2015-06-06  6:20 Mike Frysinger
2015-06-06  6:20 Mike Frysinger
2015-06-03 15:44 Mike Frysinger
2015-06-03 15:44 Mike Frysinger
2015-05-31  8:31 Mike Frysinger
2015-05-19 17:37 Mike Frysinger
2015-05-19 17:37 Mike Frysinger
2015-05-19 17:37 Mike Frysinger
2015-05-19 17:37 Mike Frysinger
2015-05-19 17:37 Mike Frysinger
2015-05-19 17:37 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-24  1:26 Mike Frysinger
2015-02-21 18:06 Mike Frysinger
2015-02-21  0:00 Mike Frysinger
2015-02-21  0:00 Mike Frysinger
2015-02-20 22:28 Mike Frysinger
2015-02-19  7:49 Mike Frysinger
2014-10-19 16:56 Mike Frysinger
2014-06-16 18:01 Mike Frysinger
2014-03-16  6:34 Mike Frysinger
2014-03-16  6:34 Mike Frysinger
2014-03-16  6:14 Mike Frysinger
2014-03-16  6:14 Mike Frysinger
2014-03-16  6:14 Mike Frysinger
2014-03-15  6:02 Mike Frysinger
2014-03-11  4:53 Mike Frysinger
2014-03-11  4:53 Mike Frysinger
2014-03-10  8:45 Mike Frysinger
2014-03-10  8:45 Mike Frysinger
2014-03-10  8:45 Mike Frysinger
2014-03-10  6:00 Mike Frysinger
2014-03-10  6:00 Mike Frysinger
2014-03-10  6:00 Mike Frysinger
2014-03-10  6:00 Mike Frysinger
2014-03-10  6:00 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger
2014-03-08  5:51 Mike Frysinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox