[gentoo-commits] proj/portage-utils:master commit in: /

2024-04-20 Thread Fabian Groffen
commit: 9cee7e77de1fb0d4d685c650e1643f2835d98dfe
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sat Apr 20 12:56:02 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sat Apr 20 12:56:02 2024 +
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  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
 



[gentoo-commits] proj/portage-utils:master commit in: libq/

2024-04-08 Thread Fabian Groffen
commit: 9594126239e0d21b88c3b8c535b6635b4a8b8892
Author: Boris Staletic  protonmail  com>
AuthorDate: Fri Mar 29 17:30:05 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Mon Apr  8 19:26:59 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=95941262

libq/xarray: Handle NULL arrays in xarraysort()

Some invocations of `q` may try to call `xarraysort(NULL, 0)`.
One example is `qlop -a foo` where `foo` was never unmerged.

Instead of requiring every call of `xarraysort()` to take care of `NULL`
arguments, `xarraysort()` now exits early if `arr->eles == NULL`.

Closes: https://github.com/gentoo/portage-utils/pull/28
Signed-off-by: Boris Staletic  protonmail.com>
Signed-off-by: Fabian Groffen  gentoo.org>

 libq/xarray.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libq/xarray.c b/libq/xarray.c
index 49b478b..3251a12 100644
--- a/libq/xarray.c
+++ b/libq/xarray.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2019 Gentoo Foundation
+ * Copyright 2003-2024 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2003-2007 Ned Ludd- 
@@ -46,7 +46,8 @@ void *xarraypush(array_t *arr, const void *ele, size_t 
ele_len)
 
 void xarraysort(array_t *arr, int (*compar)(const void *, const void *))
 {
-   qsort(arr->eles, arr->num, sizeof(void *), compar);
+   if (arr->num > 1)
+   qsort(arr->eles, arr->num, sizeof(void *), compar);
 }
 
 void xarraydelete_ptr(array_t *arr, size_t elem)



[gentoo-commits] proj/portage-utils:master commit in: tests/rmspace/

2024-04-08 Thread Fabian Groffen
commit: 80468f8d60b0761e9e993d245c7c2e9a40815437
Author: Boris Staletic  protonmail  com>
AuthorDate: Fri Mar 29 17:26:56 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Mon Apr  8 09:16:36 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=80468f8d

tests: Avoid buffer underflow when checking rmspace result

`s[len - 1]` is not allowed for strings whose length is 0.
Caught by clang's UBSAN.

PR: https://github.com/gentoo/portage-utils/pull/28
Signed-off-by: Fabian Groffen  gentoo.org>

 tests/rmspace/test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tests/rmspace/test.c b/tests/rmspace/test.c
index aac4fd9..843cccb 100644
--- a/tests/rmspace/test.c
+++ b/tests/rmspace/test.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2019 Gentoo Foundation
+ * Copyright 2005-2024 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2008 Ned Ludd- 
@@ -31,7 +31,7 @@ int main(int argc, char *argv[])
for (i = 1; i < argc; ++i) {
s = rmspace(argv[i]);
len = strlen(s);
-   if (isspace(s[0]) || isspace(s[len - 1])) {
+   if (isspace(s[0]) || (len && isspace(s[len - 1]))) {
fprintf(stderr, "FAIL {%s}\n", s);
return 1;
}



[gentoo-commits] proj/portage-utils:master commit in: /

2024-03-29 Thread Fabian Groffen
commit: cc4de0decf915ee76fcbf4420f15e68e6d10a17a
Author: Fabian Groffen  gentoo  org>
AuthorDate: Fri Mar 29 11:19:52 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Fri Mar 29 11:19:52 2024 +
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  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++;\



[gentoo-commits] proj/portage-utils:master commit in: tests/copy_file/

2024-03-29 Thread Fabian Groffen
commit: 26fe1cf9fc9d99e2ae9f4add01bccd1938656712
Author: Boris Staletic  protonmail  com>
AuthorDate: Thu Mar 28 22:08:32 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Fri Mar 29 10:58:26 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=26fe1cf9

tests: Avoid leaking buf in copy_file/test.c

Signed-off-by: Fabian Groffen  gentoo.org>

 tests/copy_file/test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/copy_file/test.c b/tests/copy_file/test.c
index 4482237..aa0edaa 100644
--- a/tests/copy_file/test.c
+++ b/tests/copy_file/test.c
@@ -72,6 +72,7 @@ int main(int argc, char *argv[])
assert(buf != NULL);
memset(buf, 0xaf, len);
testone(buf, len);
+   free(buf);
 
return 0;
 }



[gentoo-commits] proj/portage-utils:master commit in: tests/atom_explode/

2024-03-29 Thread Fabian Groffen
commit: 06d9fb823e99cce2c66c5c4888b91538e66d166e
Author: Boris Staletic  protonmail  com>
AuthorDate: Thu Mar 28 20:30:40 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Fri Mar 29 10:58:25 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=06d9fb82

tests: avoid leaking buf after exiting the loop in atom_explode

Signed-off-by: Fabian Groffen  gentoo.org>

 tests/atom_explode/test.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/tests/atom_explode/test.c b/tests/atom_explode/test.c
index b794d3b..ff1c58d 100644
--- a/tests/atom_explode/test.c
+++ b/tests/atom_explode/test.c
@@ -64,6 +64,7 @@ int main(int argc, char *argv[])
boom(a, buf);
atom_implode(a);
}
+   free(buf);
}
 
return EXIT_SUCCESS;



[gentoo-commits] proj/portage-utils:master commit in: /

2024-03-29 Thread Fabian Groffen
commit: ad4eb81f3fda3b3df705c48c875c901f814ec74a
Author: Boris Staletic  protonmail  com>
AuthorDate: Thu Mar 28 19:57:26 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Fri Mar 29 10:58:23 2024 +
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  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);
}
 
{



[gentoo-commits] proj/portage-utils:master commit in: libq/, /

2024-03-29 Thread Fabian Groffen
commit: 268c2076b5276fbce37df3f751619646c4b8d7a4
Author: Boris Staletic  protonmail  com>
AuthorDate: Thu Mar 28 18:08:00 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Fri Mar 29 10:57:17 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=268c2076

qlop: Properly handle atom_compar_cb when called from qsort

`qsort` passes pointers to elements ("iterators" in C++ lingo) to the
callback, not elements directly.
Hence `l` and `r` in `atom_compar_cb` actually receives `depend_atom**`,
but only when called from `qsort`. The other two call sites
(`tree_pkg_compar` and `pkg_sort_cb`) actually apssed `depend_atom*`.

This leads to type casting confusion and undefined behaviour for any
invocation of `qlop -p`.

First discovered by SEGFAULT-ing with the following invocation:

qlop -p `cat /var/lib/portage/world`

Valgrind and ASAN made triggering the SEGFAULT easier - any invocation
with two or more atoms triggered a NULL dereference.

This commit addresses the above problem:

1. Expect that `atom_compar_cb` is actually called with two
   `depend_atom**`.
2. Make `tree_pkg_compar` and `pkg_sort_cb` comply with the above
   change, by passing  `` and ``, instead of `al` and `ar`.

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/atom.c | 4 ++--
 libq/tree.c | 2 +-
 qlop.c  | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/libq/atom.c b/libq/atom.c
index b1a150a..3cc2100 100644
--- a/libq/atom.c
+++ b/libq/atom.c
@@ -1242,8 +1242,8 @@ atom_format(const char *format, const depend_atom *atom)
 inline int
 atom_compar_cb(const void *l, const void *r)
 {
-   const depend_atom *al = l;
-   const depend_atom *ar = r;
+   const depend_atom *al = *(const depend_atom**)l;
+   const depend_atom *ar = *(const depend_atom**)r;
 
switch (atom_compare(al, ar)) {
case EQUAL:  return  0;

diff --git a/libq/tree.c b/libq/tree.c
index 4678634..335ac79 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -463,7 +463,7 @@ tree_pkg_compar(const void *l, const void *r)
depend_atom *al = tree_get_atom(pl, false);
depend_atom *ar = tree_get_atom(pr, false);
 
-   return atom_compar_cb(al, ar);
+   return atom_compar_cb(, );
 }
 
 static tree_pkg_ctx *

diff --git a/qlop.c b/qlop.c
index 3e6db53..cfad246 100644
--- a/qlop.c
+++ b/qlop.c
@@ -309,7 +309,7 @@ pkg_sort_cb(const void *l, const void *r)
depend_atom *al = pl->atom;
depend_atom *ar = pr->atom;
 
-   return atom_compar_cb(al, ar);
+   return atom_compar_cb(, );
 }
 
 /* The format of the sync log has changed over time.



[gentoo-commits] proj/portage-utils:master commit in: /

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

qmerge: add reminder for myself

Signed-off-by: Fabian Groffen  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,
, , cp_argc, cp_argv, cpm_argc, 
cpm_argv);



[gentoo-commits] proj/portage-utils:master commit in: libq/

2024-02-01 Thread Fabian Groffen
commit: b4ace2f3443e6746a54eb14c7f50aa719540181c
Author: Fabian Groffen  gentoo  org>
AuthorDate: Thu Feb  1 08:19:01 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu Feb  1 08:19:01 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b4ace2f3

libq/contents: fix invalid access problem pointed out by valgrind

len represents the entire string length, but we start scanning after the
line identifier, so substract that size from len, such that we don't
start scanning after the end of the input string.

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/contents.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/libq/contents.c b/libq/contents.c
index feb1c0b..6ec4491 100644
--- a/libq/contents.c
+++ b/libq/contents.c
@@ -34,6 +34,9 @@ contents_parse_line_len(char *line, size_t len)
len--;
}
 
+   if (len <= 4)  /* minimal: "dir /" */
+   return NULL;
+
memset(, 0x00, sizeof(e));
e._data = line;
 
@@ -47,6 +50,7 @@ contents_parse_line_len(char *line, size_t len)
return NULL;
 
e.name = e._data + 4;
+   len   -= 4;
 
switch (e.type) {
/* dir /bin */



[gentoo-commits] proj/portage-utils:master commit in: libq/

2024-02-01 Thread Fabian Groffen
commit: 13b0eecccaeae428c5fcd58b9c7edf9854e154a3
Author: Fabian Groffen  gentoo  org>
AuthorDate: Thu Feb  1 08:20:42 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu Feb  1 08:20:42 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=13b0eecc

libq/tree: handle hypothetical fail in tree_pkg_meta_get_int

When we cannot read all bytes from a file, return an empty string, not
partial garbage.

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/tree.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/libq/tree.c b/libq/tree.c
index 15d8267..4678634 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -1233,6 +1233,12 @@ tree_pkg_meta_get_int(tree_pkg_ctx *pkg_ctx, size_t 
offset, const char *keyn)
p[--s.st_size] = '\0';
m->storage->pos += s.st_size + 1;
}
+   else
+   {
+   /* hmmm, couldn't read the whole file?!? */
+   p[0] = '\0';
+   m->storage->pos++;
+   }
close(fd);
}
} else {



[gentoo-commits] proj/portage-utils:master commit in: libq/

2024-01-31 Thread Fabian Groffen
commit: 17e518250d3cabfec9ecc417275a42858b590297
Author: Fabian Groffen  gentoo  org>
AuthorDate: Wed Jan 31 20:39:24 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Wed Jan 31 20:39:24 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=17e51825

libq/contents: add variant specifying buffer length

This seems necessary for PR #21, but keep the original code structure
largely in-tact.

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/contents.c | 53 +++--
 libq/contents.h |  5 +++--
 2 files changed, 38 insertions(+), 20 deletions(-)

diff --git a/libq/contents.c b/libq/contents.c
index 7f4351d..feb1c0b 100644
--- a/libq/contents.c
+++ b/libq/contents.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2020 Gentoo Foundation
+ * Copyright 2005-2024 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2008 Ned Ludd- 
@@ -19,18 +19,20 @@
  * Parse a line of CONTENTS file and provide access to the individual fields
  */
 contents_entry *
-contents_parse_line(char *line)
+contents_parse_line_len(char *line, size_t len)
 {
static contents_entry e;
char *p;
 
-   if (line == NULL || *line == '\0' || *line == '\n')
+   if (len == 0 || line == NULL || *line == '\0' || *line == '\n')
return NULL;
 
/* chop trailing newline */
-   p = [strlen(line) - 1];
-   if (*p == '\n')
+   p = [len - 1];
+   if (*p == '\n') {
*p = '\0';
+   len--;
+   }
 
memset(, 0x00, sizeof(e));
e._data = line;
@@ -53,23 +55,38 @@ contents_parse_line(char *line)
 
/* obj /bin/bash 62ed51c8b23866777552643ec57614b0 1120707577 */
case CONTENTS_OBJ:
-   if ((e.mtime_str = strrchr(e.name, ' ')) == NULL)
-   return NULL;
-   *e.mtime_str++ = '\0';
-   if ((e.digest = strrchr(e.name, ' ')) == NULL)
-   return NULL;
-   *e.digest++ = '\0';
+   for (p = [len - 1]; p >= e.name; p--) {
+   if (*p == ' ') {
+   if (e.mtime_str == NULL)
+   e.mtime_str = p + 1;
+   else if (e.digest == NULL)
+   e.digest = p + 1;
+   *p = '\0';
+
+   if (e.digest != NULL)
+   break;
+   }
+   }
break;
 
/* sym /bin/sh -> bash 1120707577 */
case CONTENTS_SYM:
-   if ((e.mtime_str = strrchr(e.name, ' ')) == NULL)
-   return NULL;
-   *e.mtime_str++ = '\0';
-   if ((e.sym_target = strstr(e.name, " -> ")) == NULL)
-   return NULL;
-   *e.sym_target = '\0';
-   e.sym_target += 4;
+   for (p = [len - 1]; p >= e.name; p--) {
+   if (*p == ' ') {
+   if (e.mtime_str == NULL) {
+   e.mtime_str = p + 1;
+   } else if (e.sym_target == NULL) {
+   if (strncmp(p, " -> ", sizeof(" 
-> ") - 1) == 0)
+   e.sym_target = p + 
sizeof(" -> ") - 1;
+   else
+   continue;
+   }
+   *p = '\0';
+
+   if (e.sym_target != NULL)
+   break;
+   }
+   }
break;
}
 

diff --git a/libq/contents.h b/libq/contents.h
index c766827..a0a5a63 100644
--- a/libq/contents.h
+++ b/libq/contents.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2019 Gentoo Foundation
+ * Copyright 2005-2024 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2008 Ned Ludd- 
@@ -24,6 +24,7 @@ typedef struct {
long mtime;
 } contents_entry;
 
-contents_entry *contents_parse_line(char *line);
+contents_entry *contents_parse_line_len(char *line, size_t len);
+#define contents_parse_line(L) contents_parse_line_len(L, strlen(L))
 
 #endif



[gentoo-commits] proj/portage-utils:master commit in: libq/

2024-01-31 Thread Fabian Groffen
commit: 014a97249e20e77f3e0ba5b9def194682ef8ecbd
Author: Fabian Groffen  gentoo  org>
AuthorDate: Wed Jan 31 19:30:24 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Wed Jan 31 19:30:24 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=014a9724

libq/hash.h: update copyright for previous commit

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/hash.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libq/hash.h b/libq/hash.h
index ffbd2ef..bc72e52 100644
--- a/libq/hash.h
+++ b/libq/hash.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2018-2020 Gentoo Foundation
+ * Copyright 2018-2024 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2018- Fabian Groffen  - 



[gentoo-commits] proj/portage-utils:master commit in: libq/

2024-01-31 Thread Fabian Groffen
commit: bc4321f30bb95ab1c2112f045a4cde811045ed59
Author: Fabian Groffen  gentoo  org>
AuthorDate: Wed Jan 31 19:24:41 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Wed Jan 31 19:24:41 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=bc4321f3

libq/hash: add hash_string function

Alternative to the implementation in PR #21, so as to reuse the same
hashing code.

We could add the interface to compute multiple hashes from the same
string when that's actually necessary.

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/hash.c | 137 +---
 libq/hash.h |   1 +
 2 files changed, 114 insertions(+), 24 deletions(-)

diff --git a/libq/hash.c b/libq/hash.c
index 9b36bb9..f3a440f 100644
--- a/libq/hash.c
+++ b/libq/hash.c
@@ -98,29 +98,54 @@ hash_hex(char *out, const unsigned char *buf, const int 
length)
}
 }
 
-/**
- * Computes the hashes for file fname and writes the hex-representation
- * for those hashes into the address space pointed to by the return
- * pointers for these hashes.  The caller should ensure enough space is
- * available.  Only those hashes which are in the global hashes variable
- * are computed, the address space pointed to for non-used hashes are
- * left untouched, e.g. they can be NULL.  The number of bytes read from
- * the file pointed to by fname is returned in the flen argument.
- */
-int
-hash_multiple_file_fd(
-   int fd,
-   char *md5,
-   char *sha1,
-   char *sha256,
-   char *sha512,
-   char *blak2b,
+/* len func(dest,destlen,cbctx) */
+typedef size_t (*read_cb)(char *,size_t,void *);
+
+static size_t read_stdio(char *dest, size_t destlen, void *ctx)
+{
+   FILE *io = ctx;
+
+   return fread(dest, 1, destlen, io);
+}
+
+struct bufctx {
+   const char *buf;
+   size_t  buflen;
+};
+
+static size_t read_buffer(char *dest, size_t destlen, void *ctx)
+{
+   struct bufctx *membuf = ctx;
+   size_t readlen;
+
+   readlen = destlen;
+   if (readlen > membuf->buflen)
+   readlen = membuf->buflen;
+
+   memcpy(dest, membuf->buf, readlen);
+
+   /* update buffer to the remainder */
+   membuf->buf+= readlen;
+   membuf->buflen -= readlen;
+
+   return readlen;
+}
+
+static int
+hash_multiple_internal(
+   read_cb rcb,
+   void   *ctx,
+   char   *md5,
+   char   *sha1,
+   char   *sha256,
+   char   *sha512,
+   char   *blak2b,
size_t *flen,
-   int hashes)
+   int hashes)
 {
-   FILE *f;
-   char  data[8192];
size_tlen;
+   char  data[8192];
+
struct md5_ctxm5;
struct sha1_ctx   s1;
struct sha256_ctx s256;
@@ -132,8 +157,6 @@ hash_multiple_file_fd(
 #endif
 
*flen = 0;
-   if ((f = fdopen(fd, "r")) == NULL)
-   return -1;
 
md5_init_ctx();
sha1_init_ctx();
@@ -143,7 +166,7 @@ hash_multiple_file_fd(
blake2b_init(, BLAKE2B_OUTBYTES);
 #endif
 
-   while ((len = fread(data, 1, sizeof(data), f)) > 0) {
+   while ((len = rcb(data, sizeof(data), ctx)) > 0) {
*flen += len;
 #pragma omp parallel sections
{
@@ -176,7 +199,6 @@ hash_multiple_file_fd(
 #endif
}
}
-   fclose(f);
 
 #pragma omp parallel sections
{
@@ -227,6 +249,41 @@ hash_multiple_file_fd(
return 0;
 }
 
+/**
+ * Computes the hashes for file fname and writes the hex-representation
+ * for those hashes into the address space pointed to by the return
+ * pointers for these hashes.  The caller should ensure enough space is
+ * available.  Only those hashes which are in the global hashes variable
+ * are computed, the address space pointed to for non-used hashes are
+ * left untouched, e.g. they can be NULL.  The number of bytes read from
+ * the file pointed to by fname is returned in the flen argument.
+ */
+int
+hash_multiple_file_fd(
+   int fd,
+   char *md5,
+   char *sha1,
+   char *sha256,
+   char *sha512,
+   char *blak2b,
+   size_t *flen,
+   int hashes)
+{
+   FILE *f;
+   int   ret;
+
+   if ((f = fdopen(fd, "r")) == NULL)
+   return -1;
+
+   ret = hash_multiple_internal(read_stdio, f,
+md5, sha1, 
sha256, sha512, blak2b,
+flen, hashes);
+
+   fclose(f);
+
+   return ret;
+}
+
 int
 hash_multiple_file_at_cb(
int pfd,
@@ -285,3 +342,35 @@ hash_file_at_cb(int pfd, const char *fname, int hash, 
hash_cb_t cb)
 
return 

[gentoo-commits] proj/portage-utils:master commit in: libq/

2024-01-27 Thread Fabian Groffen
commit: e05b6baf296397bc2a10dad728f2840ab242b833
Author: Pavel Kalugin  pavelthebest  me>
AuthorDate: Tue Dec 12 19:32:35 2023 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sat Jan 27 13:27:30 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e05b6baf

libq/atom: fix atom comparison bug

qlop SEGFAULTed when predict on a package without category was called

Closes: https://github.com/gentoo/portage-utils/pull/24
Signed-off-by: Pavel Kalugin  pavelthebest.me>
Signed-off-by: Fabian Groffen  gentoo.org>

 libq/atom.c | 10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/libq/atom.c b/libq/atom.c
index 31299f1..b1a150a 100644
--- a/libq/atom.c
+++ b/libq/atom.c
@@ -1252,7 +1252,15 @@ atom_compar_cb(const void *l, const void *r)
default:
{
int ret;
-   ret = strcmp(al->CATEGORY, ar->CATEGORY);
+   if (!al->CATEGORY && !ar->CATEGORY) {
+   ret = 0;
+   } else if (!al->CATEGORY) {
+   ret = -1;
+   } else if (!ar->CATEGORY) {
+   ret = 1;
+   } else {
+   ret = strcmp(al->CATEGORY, ar->CATEGORY);
+   }
if (ret == 0)
ret = strcasecmp(al->PN, ar->PN);
return ret;



[gentoo-commits] proj/portage-utils:master commit in: /

2024-01-02 Thread Fabian Groffen
commit: e023e57e23cffce91451e64086bb748ce44fbc80
Author: Fabian Groffen  gentoo  org>
AuthorDate: Tue Jan  2 13:15:34 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Tue Jan  2 13:15:34 2024 +
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  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;



[gentoo-commits] proj/portage-utils:master commit in: /

2024-01-02 Thread Fabian Groffen
commit: af1d54e9a8bf517e566091a8c60762ebfcb534d7
Author: Fabian Groffen  gentoo  org>
AuthorDate: Tue Jan  2 13:07:45 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Tue Jan  2 13:07:45 2024 +
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  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, ) == -1) {
+   if (imagefd == -1) {
+   err("Failed to open image dir");
+   } else if (fstat(imagefd, ) == -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))



[gentoo-commits] proj/portage-utils:master commit in: /, libq/

2024-01-01 Thread Fabian Groffen
commit: 5b790bbd7eb6e02702e422d9bdcb640b10a3e447
Author: Fabian Groffen  gentoo  org>
AuthorDate: Tue Jan  2 07:50:51 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Tue Jan  2 07:50:51 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=5b790bbd

libq/hash: switch from OpenSSL/custom to gnulib-based hash impls

OpenSSL deprecated most (if not all) of the hashes we use from it, and
we don't have our own implementations for e.g. SHA512, so switch to
gnulib's versions, which makes this all simpler.

Signed-off-by: Fabian Groffen  gentoo.org>

 autogen.sh   |   4 +
 libq/Makefile.am |   6 -
 libq/hash.c  | 123 +++-
 libq/hash_md5_sha1.c | 770 ---
 libq/hash_md5_sha1.h |  35 ---
 5 files changed, 41 insertions(+), 897 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index df6e574..dc41d69 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -28,6 +28,10 @@ done
 # reload the gnulib code
 PATH=/usr/local/src/gnu/gnulib:${PATH}
 mods="
+   crypto/md5-buffer
+   crypto/sha1-buffer
+   crypto/sha256-buffer
+   crypto/sha512-buffer
dirent
faccessat
fdopendir

diff --git a/libq/Makefile.am b/libq/Makefile.am
index 879d4a7..e65bb47 100644
--- a/libq/Makefile.am
+++ b/libq/Makefile.am
@@ -28,12 +28,6 @@ QFILES = \
xsystem.c xsystem.h \
$(NULL)
 
-if !QMANIFEST_ENABLED
-if !QTEGRITY_ENABLED
-QFILES += hash_md5_sha1.c hash_md5_sha1.h
-endif
-endif
-
 noinst_LIBRARIES = libq.a
 libq_a_SOURCES = $(QFILES)
 libq_a_CPPFLAGS = \

diff --git a/libq/hash.c b/libq/hash.c
index 4a1202a..9b36bb9 100644
--- a/libq/hash.c
+++ b/libq/hash.c
@@ -12,24 +12,22 @@
 
 #include "main.h"
 
-#ifdef HAVE_SSL
-# include 
-# include 
-#else
-# include "hash_md5_sha1.h"
-#endif
 #ifdef HAVE_BLAKE2B
 # include 
 #endif
 
+#include "md5.h"
+#include "sha1.h"
+#include "sha256.h"
+#include "sha512.h"
+
 #include "hash.h"
 
 void
 hash_hex(char *out, const unsigned char *buf, const int length)
 {
switch (length) {
-   /* MD5_DIGEST_LENGTH */
-   case 16:
+   case 16: /* MD5_DIGEST_SIZE */
snprintf(out, 32 + 1,

"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
"%02x%02x%02x%02x%02x%02x",
@@ -39,8 +37,7 @@ hash_hex(char *out, const unsigned char *buf, const int 
length)
buf[15]
);
break;
-   /* SHA1_DIGEST_LENGTH */
-   case 20:
+   case 20: /* SHA1_DIGEST_SIZE */
snprintf(out, 40 + 1,

"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"

"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x",
@@ -50,8 +47,7 @@ hash_hex(char *out, const unsigned char *buf, const int 
length)
buf[15], buf[16], buf[17], buf[18], 
buf[19]
);
break;
-   /* SHA256_DIGEST_LENGTH */
-   case 32:
+   case 32: /* SHA256_DIGEST_SIZE */
snprintf(out, 64 + 1,

"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"

"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
@@ -66,8 +62,7 @@ hash_hex(char *out, const unsigned char *buf, const int 
length)
buf[30], buf[31]
);
break;
-   /* SHA512_DIGEST_LENGTH, WHIRLPOOL_DIGEST_LENGTH, 
BLAKE2B_OUTBYTES */
-   case 64:
+   case 64: /* SHA512_DIGEST_SIZE, BLAKE2B_OUTBYTES */
snprintf(out, 128 + 1,

"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"

"%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x"
@@ -123,22 +118,15 @@ hash_multiple_file_fd(
size_t *flen,
int hashes)
 {
-   FILE *f;
-   char data[8192];
-   size_t len;
-#ifdef HAVE_SSL
-   MD5_CTX m5;
-   SHA_CTX s1;
-   SHA256_CTX s256;
-   SHA512_CTX s512;
-#else
-   struct md5_ctx_t m5;
-   struct sha1_ctx_t s1;
-   (void)sha256;
-   (void)sha512;
-#endif
+   FILE *f;
+   char  data[8192];
+   size_tlen;
+   struct md5_ctxm5;
+   struct sha1_ctx   s1;
+   struct sha256_ctx s256;
+   struct sha512_ctx s512;
 #ifdef HAVE_BLAKE2B
-   blake2b_state bl2b;
+   blake2b_state bl2b;
 #else
(void)blak2b;
 #endif
@@ -147,15 +135,10 @@ hash_multiple_file_fd(
if ((f = fdopen(fd, "r")) == NULL)
return -1;
 
-#ifdef HAVE_SSL
-   

[gentoo-commits] proj/portage-utils:master commit in: libq/, /

2024-01-01 Thread Fabian Groffen
commit: 92920dd0b9efed3e7467b4b18b68df86f9eee9d8
Author: Fabian Groffen  gentoo  org>
AuthorDate: Mon Jan  1 13:17:56 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Mon Jan  1 13:17:56 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=92920dd0

*: remove WHIRLPOOL hash support

WHIRLPOOL has not been in use since mid 2017, and its support is bound
to be removed from OpenSSL.

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/hash.c | 26 +++---
 libq/hash.h | 14 +++---
 libq/tree.c |  2 +-
 qcheck.c|  2 +-
 qmanifest.c | 31 +--
 qmerge.c|  4 ++--
 qpkg.c  |  2 +-
 qtegrity.c  |  4 ++--
 8 files changed, 26 insertions(+), 59 deletions(-)

diff --git a/libq/hash.c b/libq/hash.c
index b5aec46..4a1202a 100644
--- a/libq/hash.c
+++ b/libq/hash.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2018-2020 Gentoo Foundation
+ * Copyright 2018-2024 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2018- Fabian Groffen  - 
@@ -15,7 +15,6 @@
 #ifdef HAVE_SSL
 # include 
 # include 
-# include 
 #else
 # include "hash_md5_sha1.h"
 #endif
@@ -120,7 +119,6 @@ hash_multiple_file_fd(
char *sha1,
char *sha256,
char *sha512,
-   char *whrlpl,
char *blak2b,
size_t *flen,
int hashes)
@@ -133,13 +131,11 @@ hash_multiple_file_fd(
SHA_CTX s1;
SHA256_CTX s256;
SHA512_CTX s512;
-   WHIRLPOOL_CTX whrl;
 #else
struct md5_ctx_t m5;
struct sha1_ctx_t s1;
(void)sha256;
(void)sha512;
-   (void)whrlpl;
 #endif
 #ifdef HAVE_BLAKE2B
blake2b_state bl2b;
@@ -156,7 +152,6 @@ hash_multiple_file_fd(
SHA1_Init();
SHA256_Init();
SHA512_Init();
-   WHIRLPOOL_Init();
 #else
md5_begin();
sha1_begin();
@@ -190,11 +185,6 @@ hash_multiple_file_fd(
if (hashes & HASH_SHA512)
SHA512_Update(, data, len);
}
-#pragma omp section
-   {
-   if (hashes & HASH_WHIRLPOOL)
-   WHIRLPOOL_Update(, data, len);
-   }
 #else
 #pragma omp section
{
@@ -253,14 +243,6 @@ hash_multiple_file_fd(
hash_hex(sha512, sha512buf, 
SHA512_DIGEST_LENGTH);
}
}
-#pragma omp section
-   {
-   if (hashes & HASH_WHIRLPOOL) {
-   unsigned char 
whrlplbuf[WHIRLPOOL_DIGEST_LENGTH];
-   WHIRLPOOL_Final(whrlplbuf, );
-   hash_hex(whrlpl, whrlplbuf, 
WHIRLPOOL_DIGEST_LENGTH);
-   }
-   }
 #else
 #pragma omp section
{
@@ -303,7 +285,6 @@ hash_multiple_file_at_cb(
char *sha1,
char *sha256,
char *sha512,
-   char *whrlpl,
char *blak2b,
size_t *flen,
int hashes)
@@ -321,7 +302,7 @@ hash_multiple_file_at_cb(
}
 
ret = hash_multiple_file_fd(fd, md5, sha1, sha256, sha512,
-   whrlpl, blak2b, flen, hashes);
+   blak2b, flen, hashes);
 
if (ret != 0)
close(fd);
@@ -340,11 +321,10 @@ hash_file_at_cb(int pfd, const char *fname, int hash, 
hash_cb_t cb)
case HASH_SHA1:
case HASH_SHA256:
case HASH_SHA512:
-   case HASH_WHIRLPOOL:
case HASH_BLAKE2B:
if (hash_multiple_file_at_cb(pfd, fname, cb,
_hash_file_buf, _hash_file_buf, 
_hash_file_buf,
-   _hash_file_buf, _hash_file_buf, 
_hash_file_buf,
+   _hash_file_buf, _hash_file_buf,
, hash) != 0)
return NULL;
break;

diff --git a/libq/hash.h b/libq/hash.h
index f85080d..fb4ab5f 100644
--- a/libq/hash.h
+++ b/libq/hash.h
@@ -18,7 +18,7 @@ enum hash_impls {
HASH_SHA1  = 1<<1,
HASH_SHA256= 1<<2,
HASH_SHA512= 1<<3,
-   HASH_WHIRLPOOL = 1<<4,
+   HASH_WHIRLPOOL = 1<<4,  /* removed */
HASH_BLAKE2B   = 1<<5
 };
 
@@ -32,15 +32,15 @@ typedef int (*hash_cb_t) (int, const char *);
 void hash_hex(char *out, const unsigned char *buf, const int length);
 int hash_multiple_file_fd(
int fd, char *md5, char *sha1, char *sha256, char *sha512,
-   char *whrlpl, char *blak2b, size_t *flen, int hashes);
+   char *blak2b, size_t *flen, int hashes);
 int 

[gentoo-commits] proj/portage-utils:master commit in: /

2024-01-01 Thread Fabian Groffen
commit: d07c7b639103c1dd50851f3f3b974fabfc2a33a2
Author: Fabian Groffen  gentoo  org>
AuthorDate: Tue Jan  2 07:53:09 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Tue Jan  2 07:53:09 2024 +
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  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,   "", "search pkgname/desc"},
{"qsize", qsize_main, "",   "calculate size 
usage"},
{"qtbz2", qtbz2_main, "", "manipulate tbz2 
packages"},
-#ifdef ENABLE_QTEGRITY
{"qtegrity",  qtegrity_main,  "", "verify files with 
IMA"},
-#endif
{"quse",  quse_main,  "",   "find pkgs using 
useflags"},
{"qwhich",qwhich_main,"",   "find path to pkg"},
{"qxpak", qxpak_main, "", "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
 

[gentoo-commits] proj/portage-utils:master commit in: man/

2024-01-01 Thread Fabian Groffen
commit: 9420acbcc4cc0a9800bd6c602ea20e572e357f64
Author: Fabian Groffen  gentoo  org>
AuthorDate: Mon Jan  1 10:43:06 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Mon Jan  1 10:43:06 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=9420acbc

man: regen for updated footer

Signed-off-by: Fabian Groffen  gentoo.org>

 man/q.1 |  7 +--
 man/qatom.1 |  7 +--
 man/qcheck.1|  7 +--
 man/qdepends.1  |  4 ++--
 man/qfile.1 |  7 +--
 man/qgrep.1 |  7 +--
 man/qkeyword.1  |  4 ++--
 man/qlist.1 |  7 +--
 man/qlop.1  | 10 --
 man/qmanifest.1 |  7 +--
 man/qmerge.1|  7 +--
 man/qpkg.1  |  7 +--
 man/qsearch.1   |  7 +--
 man/qsize.1 |  7 +--
 man/qtbz2.1 |  7 +--
 man/qtegrity.1  |  7 +--
 man/quse.1  |  7 +--
 man/qwhich.1|  7 +--
 man/qxpak.1 |  7 +--
 19 files changed, 92 insertions(+), 38 deletions(-)

diff --git a/man/q.1 b/man/q.1
index f43be6f..98d4cfe 100644
--- a/man/q.1
+++ b/man/q.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH q "1" "Mar 2021" "Gentoo Foundation" "q"
+.TH q "1" "Jan 2024" "Gentoo Foundation" "q"
 .SH NAME
 q \- invoke a portage utility applet
 .SH SYNOPSIS
@@ -51,6 +51,9 @@ Tighter output; suppress warnings.
 \fB\-C\fR, \fB\-\-nocolor\fR
 Don't output color.
 .TP
+\fB\-\-color\fR
+Force color in output.
+.TP
 \fB\-h\fR, \fB\-\-help\fR
 Print this help and exit.
 .TP
@@ -82,7 +85,7 @@ Print version and exit.
 .SH "REPORTING BUGS"
 Please report bugs via http://bugs.gentoo.org/
 .br
-Product: Portage Development; Component: Tools
+Product: Gentoo Linux; Component: Current packages
 .SH AUTHORS
 .nf
 Ned Ludd 

diff --git a/man/qatom.1 b/man/qatom.1
index 99bf67a..cb1c972 100644
--- a/man/qatom.1
+++ b/man/qatom.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qatom "1" "Feb 2021" "Gentoo Foundation" "qatom"
+.TH qatom "1" "Jan 2024" "Gentoo Foundation" "qatom"
 .SH NAME
 qatom \- split atom strings
 .SH SYNOPSIS
@@ -88,6 +88,9 @@ Ignored for compatibility with other qapplets.
 \fB\-C\fR, \fB\-\-nocolor\fR
 Ignored for compatibility with other qapplets.
 .TP
+\fB\-\-color\fR
+Force color in output.
+.TP
 \fB\-h\fR, \fB\-\-help\fR
 Print this help and exit.
 .TP
@@ -133,7 +136,7 @@ option:
 .SH "REPORTING BUGS"
 Please report bugs via http://bugs.gentoo.org/
 .br
-Product: Portage Development; Component: Tools
+Product: Gentoo Linux; Component: Current packages
 .SH AUTHORS
 .nf
 Ned Ludd 

diff --git a/man/qcheck.1 b/man/qcheck.1
index 2d98408..2c7234c 100644
--- a/man/qcheck.1
+++ b/man/qcheck.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qcheck "1" "Feb 2021" "Gentoo Foundation" "qcheck"
+.TH qcheck "1" "Jan 2024" "Gentoo Foundation" "qcheck"
 .SH NAME
 qcheck \- verify integrity of installed packages
 .SH SYNOPSIS
@@ -48,6 +48,9 @@ Tighter output; suppress warnings.
 \fB\-C\fR, \fB\-\-nocolor\fR
 Don't output color.
 .TP
+\fB\-\-color\fR
+Force color in output.
+.TP
 \fB\-h\fR, \fB\-\-help\fR
 Print this help and exit.
 .TP
@@ -57,7 +60,7 @@ Print version and exit.
 .SH "REPORTING BUGS"
 Please report bugs via http://bugs.gentoo.org/
 .br
-Product: Portage Development; Component: Tools
+Product: Gentoo Linux; Component: Current packages
 .SH AUTHORS
 .nf
 Ned Ludd 

diff --git a/man/qdepends.1 b/man/qdepends.1
index 95e2b37..2f7ec83 100644
--- a/man/qdepends.1
+++ b/man/qdepends.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qdepends "1" "Jan 2023" "Gentoo Foundation" "qdepends"
+.TH qdepends "1" "Jan 2024" "Gentoo Foundation" "qdepends"
 .SH NAME
 qdepends \- show dependency info
 .SH SYNOPSIS
@@ -154,7 +154,7 @@ the newly installed version of Perl.
 .SH "REPORTING BUGS"
 Please report bugs via http://bugs.gentoo.org/
 .br
-Product: Portage Development; Component: Tools
+Product: Gentoo Linux; Component: Current packages
 .SH AUTHORS
 .nf
 Ned Ludd 

diff --git a/man/qfile.1 b/man/qfile.1
index 1f261d4..21aa77d 100644
--- a/man/qfile.1
+++ b/man/qfile.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qfile "1" "Feb 2021" "Gentoo Foundation" "qfile"
+.TH qfile "1" "Jan 2024" "Gentoo Foundation" "qfile"
 .SH NAME
 qfile \- list all pkgs owning files
 .SH SYNOPSIS
@@ -73,6 +73,9 @@ report about orphan files.
 \fB\-C\fR, \fB\-\-nocolor\fR
 Don't output color.
 .TP
+\fB\-\-color\fR
+Force color in output.
+.TP
 \fB\-h\fR, \fB\-\-help\fR
 Print this help and exit.
 .TP
@@ -231,7 +234,7 @@ rm -rf "${tmpdir}"
 .SH "REPORTING BUGS"
 Please report bugs via http://bugs.gentoo.org/
 .br
-Product: Portage Development; Component: Tools
+Product: Gentoo Linux; Component: Current packages
 .SH AUTHORS
 .nf
 Ned Ludd 

diff --git a/man/qgrep.1 b/man/qgrep.1
index 196a741..22b0858 100644
--- a/man/qgrep.1
+++ b/man/qgrep.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qgrep "1" 

[gentoo-commits] proj/portage-utils:master commit in: man/

2024-01-01 Thread Fabian Groffen
commit: 0fdf76776377c707d06a4b2e85c9f8ec4abdc26a
Author: Fabian Groffen  gentoo  org>
AuthorDate: Mon Jan  1 10:41:09 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Mon Jan  1 10:41:09 2024 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0fdf7677

man: fix product/component for reporting bugs

Closes: https://bugs.gentoo.org/916949
Signed-off-by: Fabian Groffen  gentoo.org>

 man/mkman.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/man/mkman.py b/man/mkman.py
index 13cd1c9..0ebf774 100755
--- a/man/mkman.py
+++ b/man/mkman.py
@@ -49,7 +49,7 @@ TEMPLATE = r""".\" generated by mkman.py, please do NOT edit!
 .SH "REPORTING BUGS"
 Please report bugs via http://bugs.gentoo.org/
 .br
-Product: Portage Development; Component: Tools
+Product: Gentoo Linux; Component: Current packages
 .SH AUTHORS
 .nf
 %(authors)s



[gentoo-commits] proj/portage-utils:master commit in: /

2024-01-01 Thread Fabian Groffen
commit: 13577b18e6ae5f6f1a5abf067d351f2ffc6148cc
Author: Fabian Groffen  gentoo  org>
AuthorDate: Mon Jan  1 10:33:11 2024 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Mon Jan  1 10:36:54 2024 +
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  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 - 
@@ -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, _argc, _argv);
makeargv(iuse, _argc, _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(_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;
}



[gentoo-commits] proj/portage-utils:master commit in: /

2023-12-20 Thread Mike Frysinger
commit: 23d47fe0ead50e4a98eb4b1a02f68d350f53a166
Author: Brian Norris  chromium  org>
AuthorDate: Tue Dec  5 23:19:50 2023 +
Commit: Mike Frysinger  gentoo  org>
CommitDate: Wed Dec 20 21:30:56 2023 +
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  chromium.org>
Signed-off-by: Mike Frysinger  chromium.org>
Signed-off-by: Mike Frysinger  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 */



[gentoo-commits] proj/portage-utils:master commit in: /

2023-07-18 Thread Fabian Groffen
commit: 68e1d30bcd977396f1db41be800f0a80ff03467a
Author: Fabian Groffen  gentoo  org>
AuthorDate: Tue Jul 18 06:26:52 2023 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Tue Jul 18 06:26:52 2023 +
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  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 = _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([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);
 }



[gentoo-commits] proj/portage-utils:master commit in: /

2023-07-18 Thread Fabian Groffen
commit: 360d18ba7cfbbd285f5ed6d97892778685b8a106
Author: Fabian Groffen  gentoo  org>
AuthorDate: Mon Jul 17 17:29:55 2023 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Mon Jul 17 17:29:55 2023 +
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  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 = _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);



[gentoo-commits] proj/portage-utils:master commit in: /

2023-04-21 Thread Fabian Groffen
commit: b9592db1c04cafcdfaaff8f44ab2d6fc7d6dd5fa
Author: Fabian Groffen  gentoo  org>
AuthorDate: Fri Apr 21 19:10:23 2023 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Fri Apr 21 19:10:23 2023 +
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  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;
}
 }



[gentoo-commits] proj/portage-utils:master commit in: libq/

2023-04-21 Thread Fabian Groffen
commit: e322a78cbfd6d51aefe26425dff1cb99c3d307bc
Author: Fabian Groffen  gentoo  org>
AuthorDate: Fri Apr 21 19:09:05 2023 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Fri Apr 21 19:09:05 2023 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e322a78c

libq/tree: add commetns on file checks (research for bug #898194)

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/tree.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/libq/tree.c b/libq/tree.c
index f308c8d..1922b7d 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -1109,8 +1109,17 @@ tree_pkg_read(tree_pkg_ctx *pkg_ctx)
 
if (ctx->cachetype == CACHE_METADATA_MD5) {
ret = tree_read_file_md5(pkg_ctx);
+   /* md5-cache, is sort of documented in egencache man-page
+* key-points are that an md5 is provided for the ebuild itself,
+* and if it includes eclasses, the md5s for each eclass.  These
+* are available as _md5_ and _eclasses_ keys.  The latter uses
+* tab-separation of form \t\t... */
} else if (ctx->cachetype == CACHE_METADATA_PMS) {
ret = tree_read_file_pms(pkg_ctx);
+   /* PMS implies to do an mtime and existence check (the cache may
+* contain extra stuff) but since this form of metadata in fact
+* is extinct, because these checks are insufficient and
+* impossible on e.g. a git-based tree. */
} else if (ctx->cachetype == CACHE_EBUILD) {
ret = tree_read_file_ebuild(pkg_ctx);
} else if (ctx->cachetype == CACHE_BINPKGS) {



[gentoo-commits] proj/portage-utils:master commit in: /

2023-03-01 Thread Fabian Groffen
commit: 5f5f6983b159b970ad619c4ef53d4b94361d1b5d
Author: Fabian Groffen  gentoo  org>
AuthorDate: Wed Mar  1 20:59:24 2023 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Wed Mar  1 20:59:24 2023 +
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  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(_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;



[gentoo-commits] proj/portage-utils:master commit in: /

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

main: workaround hypothetical resource leak

Signed-off-by: Fabian Groffen  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, , masks);
if (e != NULL)
free(p);



[gentoo-commits] proj/portage-utils:master commit in: libq/, /

2023-02-07 Thread Fabian Groffen
commit: 067af6b9098858e786e71ef20cb91ad75c6e4ba4
Author: Fabian Groffen  gentoo  org>
AuthorDate: Tue Feb  7 08:24:21 2023 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Tue Feb  7 08:24:21 2023 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=067af6b9

set: try to silence Coverity

Now add_set_value can allocate a new set, Coverity thinks this will
actually happen, despite in these cases the input set not being NULL.
Help Coverity by adding a redundant if.

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/tree.c |  3 ++-
 main.c  | 12 +---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/libq/tree.c b/libq/tree.c
index a05a86e..f308c8d 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -1709,7 +1709,8 @@ tree_match_atom_cache_populate_cb(tree_pkg_ctx *ctx, void 
*priv)
cat_ctx = get_set(atom->CATEGORY, cache);
if (cat_ctx == NULL) {
cat_ctx = tree_open_cat(tctx, ".");
-   cache = add_set_value(atom->CATEGORY, cat_ctx, NULL, cache);
+   if (cache != NULL)  /* for static code analysers */
+   add_set_value(atom->CATEGORY, cat_ctx, NULL, cache);
/* get a pointer from the set */
cat_ctx->name = contains_set(atom->CATEGORY, cache);
}

diff --git a/main.c b/main.c
index c5b27fe..884d6da 100644
--- a/main.c
+++ b/main.c
@@ -585,9 +585,15 @@ read_portage_file(const char *file, enum portage_file_type 
type, void *data)
snprintf(npath, sizeof(npath), "%s:%zu:%zu-%zu",
file, line, cbeg, cend);
p = xstrdup(npath);
-   masks = add_set_value(buf, p, , masks);
-   if (e != NULL)
-   free(p);
+   /* 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) {
+   add_set_value(buf, p, , masks);
+   if (e != NULL)
+   free(p);
+   }
}
}
}



[gentoo-commits] proj/portage-utils:master commit in: libq/, /

2023-02-07 Thread Fabian Groffen
commit: e2ebb44db31d4e0e9bfc0a9974d36eff63c8b2b1
Author: Fabian Groffen  gentoo  org>
AuthorDate: Tue Feb  7 08:08:13 2023 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Tue Feb  7 08:08:13 2023 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e2ebb44d

set: ensure NULL is empty behaviour is retained throughout

Not all set functions respected NULL is empty behaviour, changed
add_set_value signature to return a set instead so it can conform.

Bug: https://bugs.gentoo.org/893424
Signed-off-by: Fabian Groffen  gentoo.org>

 libq/set.c  | 47 +++
 libq/set.h  |  4 ++--
 libq/tree.c |  5 +++--
 main.c  |  6 --
 qkeyword.c  |  6 +++---
 qlop.c  | 12 
 6 files changed, 59 insertions(+), 21 deletions(-)

diff --git a/libq/set.c b/libq/set.c
index 6c9fae0..fa485c7 100644
--- a/libq/set.c
+++ b/libq/set.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2019 Gentoo Foundation
+ * Copyright 2005-2023 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd- 
@@ -112,17 +112,22 @@ add_set_unique(const char *name, set *q, bool *unique)
 
 /* add ptr to set with name as key, return existing value when key
  * already exists or NULL otherwise */
-void *
-add_set_value(const char *name, void *ptr, set *q)
+set *
+add_set_value(const char *name, void *ptr, void **prevptr, set *q)
 {
unsigned int hash;
int pos;
set_elem *ll;
set_elem *w;
 
+   if (q == NULL)
+   q = create_set();
+
hash = fnv1a32(name);
pos = hash % _SET_HASH_SIZE;
 
+   if (prevptr != NULL)
+   *prevptr = NULL;
if (q->buckets[pos] == NULL) {
q->buckets[pos] = ll = xmalloc(sizeof(*ll));
ll->next = NULL;
@@ -132,8 +137,11 @@ add_set_value(const char *name, void *ptr, set *q)
} else {
ll = NULL;
for (w = q->buckets[pos]; w != NULL; ll = w, w = w->next) {
-   if (w->hash == hash && strcmp(w->name, name) == 0)
-   return w->val;
+   if (w->hash == hash && strcmp(w->name, name) == 0) {
+   if (prevptr != NULL)
+   *prevptr = w->val;
+   return q;
+   }
}
if (w == NULL) {
ll = ll->next = xmalloc(sizeof(*ll));
@@ -145,7 +153,7 @@ add_set_value(const char *name, void *ptr, set *q)
}
 
q->len++;
-   return NULL;
+   return q;
 }
 
 /* returns whether name is in set, and if so, the set-internal key
@@ -158,6 +166,9 @@ contains_set(const char *name, set *q)
set_elem *w;
const char *found;
 
+   if (q == NULL)
+   return NULL;
+
hash = fnv1a32(name);
pos = hash % _SET_HASH_SIZE;
 
@@ -183,6 +194,9 @@ get_set(const char *name, set *q)
int pos;
set_elem *w;
 
+   if (q == NULL)
+   return NULL;
+
hash = fnv1a32(name);
pos = hash % _SET_HASH_SIZE;
 
@@ -211,6 +225,12 @@ del_set(const char *s, set *q, bool *removed)
void *ret;
bool rmd;
 
+   if (q == NULL) {
+   if (removed != NULL)
+   *removed = false;
+   return NULL;
+   }
+
hash = fnv1a32(s);
pos = hash % _SET_HASH_SIZE;
 
@@ -252,8 +272,8 @@ list_set(set *q, char ***l)
set_elem *w;
char **ret;
 
-   ret = *l = xmalloc(sizeof(char *) * (q->len + 1));
-   for (i = 0; i < _SET_HASH_SIZE; i++) {
+   ret = *l = xmalloc(sizeof(char *) * (cnt_set(q) + 1));
+   for (i = 0; q != NULL && i < _SET_HASH_SIZE; i++) {
for (w = q->buckets[i]; w != NULL; w = w->next) {
*ret = w->name;
ret++;
@@ -292,6 +312,11 @@ values_set(set *q, array_t *ret)
array_t blank = array_init_decl;
 
*ret = blank;
+
+   /* allow using empty set */
+   if (q == NULL)
+   return 0;
+
for (i = 0; i < _SET_HASH_SIZE; i++) {
for (w = q->buckets[i]; w != NULL; w = w->next)
xarraypush_ptr(ret, w->val);
@@ -314,6 +339,9 @@ clear_set(set *q)
set_elem *w;
set_elem *e;
 
+   if (q == NULL)
+   return;
+
for (i = 0; i < _SET_HASH_SIZE; i++) {
for (w = q->buckets[i]; w != NULL; w = e) {
e = w->next;
@@ -329,6 +357,9 @@ clear_set(set *q)
 void
 free_set(set *q)
 {
+   if (q == NULL)
+   return;
+
clear_set(q);
free(q);
 }

diff --git a/libq/set.h b/libq/set.h
index 5d53f95..219602e 100644
--- a/libq/set.h
+++ b/libq/set.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2019 Gentoo Foundation
+ * Copyright 2005-2023 Gentoo 

[gentoo-commits] proj/portage-utils:master commit in: /

2023-02-07 Thread Fabian Groffen
commit: 1102e2e474a24cffa6cab5118ab757b89ebf5be7
Author: Fabian Groffen  gentoo  org>
AuthorDate: Tue Feb  7 07:32:13 2023 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Tue Feb  7 07:32:13 2023 +
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  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 

[gentoo-commits] proj/portage-utils:master commit in: libq/

2023-01-30 Thread Fabian Groffen
commit: 933b7cdbd8e15c6b120aec9cb5bec3ec36a27485
Author: Fabian Groffen  gentoo  org>
AuthorDate: Mon Jan 30 14:08:37 2023 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Mon Jan 30 14:08:37 2023 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=933b7cdb

libq/tree: add support IDEPEND

Bug: https://bugs.gentoo.org/892533
Signed-off-by: Fabian Groffen  gentoo.org>

 libq/tree.c | 6 +-
 libq/tree.h | 5 +++--
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/libq/tree.c b/libq/tree.c
index 2a457ce..76190ed 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2022 Gentoo Foundation
+ * Copyright 2005-2023 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2008 Ned Ludd- 
@@ -824,6 +824,7 @@ tree_read_file_md5(tree_pkg_ctx *pkg_ctx)
assign_var(DEFINED_PHASES);
assign_var(REQUIRED_USE);
assign_var(BDEPEND);
+   assign_var(IDEPEND);
assign_var(EPREFIX);
assign_var(_eclasses_);
assign_var(_md5_);
@@ -901,6 +902,7 @@ tree_read_file_ebuild(tree_pkg_ctx *pkg_ctx)
match_key(EAPI);
match_key(REQUIRED_USE);
match_key(BDEPEND);
+   match_key(IDEPEND);
 #undef match_key
}
 
@@ -1004,6 +1006,7 @@ tree_read_file_binpkg_xpak_cb(
match_path(DEFINED_PHASES);
match_path(REQUIRED_USE);
match_path(BDEPEND);
+   match_path(IDEPEND);
match_path(CONTENTS);
match_path(USE);
match_path(EPREFIX);
@@ -1513,6 +1516,7 @@ tree_foreach_packages(tree_ctx *ctx, tree_pkg_cb 
callback, void *priv)
match_key2(REPO, repository);
match_key(SIZE);
match_key(BDEPEND);
+   match_key(IDEPEND);
match_key(PATH);
match_key2(BUILD_ID, BUILDID);
 #undef match_key

diff --git a/libq/tree.h b/libq/tree.h
index 2f2c81f..efafe73 100644
--- a/libq/tree.h
+++ b/libq/tree.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2022 Gentoo Foundation
+ * Copyright 2005-2023 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  */
 
@@ -96,8 +96,9 @@ struct tree_pkg_meta {
char *Q_PDEPEND;
char *Q_PROVIDE;   /* line 14 */
char *Q_EAPI;
-   char *Q_PROPERTIES;
+   char *Q_PROPERTIES;/* last line from metadata */
char *Q_BDEPEND;
+   char *Q_IDEPEND;
/* binpkgs/vdb */
char *Q_DEFINED_PHASES;
char *Q_REQUIRED_USE;



[gentoo-commits] proj/portage-utils:master commit in: man/, /, man/include/

2023-01-30 Thread Fabian Groffen
commit: 49da23ddba819dcf41bc3e5c1a2fb1c8801895d3
Author: Fabian Groffen  gentoo  org>
AuthorDate: Mon Jan 30 14:14:11 2023 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Mon Jan 30 14:14:11 2023 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=49da23dd

qdepends: add support for IDEPEND, #892533

Bug: https://bugs.gentoo.org/892533
Signed-off-by: Fabian Groffen  gentoo.org>

 man/include/qdepends.desc |  3 ++-
 man/qdepends.1|  8 ++--
 qdepends.c| 38 +-
 3 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/man/include/qdepends.desc b/man/include/qdepends.desc
index 19000d0..70b27be 100644
--- a/man/include/qdepends.desc
+++ b/man/include/qdepends.desc
@@ -4,7 +4,8 @@ applet has two different modes, forward and reverse dependency 
querying.
 Default operation is forward mode, answering the queries "what does
 package X depend on", while reverse mode answers "what packages depend
 on X".  Both modes can be further specified into build (DEPEND), run
-(RDEPEND), post (PDEPEND) and EAPI7's BDEPEND dependencies.
+(RDEPEND), post (PDEPEND), EAPI7's build (BDEPEND) and EAPI8's
+install-time (IDEPEND) dependencies.
 .P
 By default, \fIqdepends\fR returns the unique set of atoms that match
 all dependency variables.  To split this out per variable, use \fB-v\fR

diff --git a/man/qdepends.1 b/man/qdepends.1
index 5e5b00a..95e2b37 100644
--- a/man/qdepends.1
+++ b/man/qdepends.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qdepends "1" "May 2022" "Gentoo Foundation" "qdepends"
+.TH qdepends "1" "Jan 2023" "Gentoo Foundation" "qdepends"
 .SH NAME
 qdepends \- show dependency info
 .SH SYNOPSIS
@@ -12,7 +12,8 @@ applet has two different modes, forward and reverse 
dependency querying.
 Default operation is forward mode, answering the queries "what does
 package X depend on", while reverse mode answers "what packages depend
 on X".  Both modes can be further specified into build (DEPEND), run
-(RDEPEND), post (PDEPEND) and EAPI7's BDEPEND dependencies.
+(RDEPEND), post (PDEPEND), EAPI7's build (BDEPEND) and EAPI8's
+install-time (IDEPEND) dependencies.
 .P
 By default, \fIqdepends\fR returns the unique set of atoms that match
 all dependency variables.  To split this out per variable, use \fB-v\fR
@@ -52,6 +53,9 @@ Show PDEPEND info.
 \fB\-b\fR, \fB\-\-bdepend\fR
 Show BDEPEND info.
 .TP
+\fB\-I\fR, \fB\-\-idepend\fR
+Show IDEPEND info.
+.TP
 \fB\-Q\fR, \fB\-\-query\fR
 Query reverse deps.  This basically reverses the search to any
 package that references \fI\fR in DEPEND, RDEPEND, PDEPEND or BDEPEND.

diff --git a/qdepends.c b/qdepends.c
index f222011..1ecfab5 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2022 Gentoo Authors
+ * Copyright 2005-2023 Gentoo Authors
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd- 
@@ -22,12 +22,13 @@
 #include "xasprintf.h"
 #include "xregex.h"
 
-#define QDEPENDS_FLAGS "drpbQitUF:SR" COMMON_FLAGS
+#define QDEPENDS_FLAGS "drpbIQitUF:SR" COMMON_FLAGS
 static struct option const qdepends_long_opts[] = {
{"depend",no_argument, NULL, 'd'},
{"rdepend",   no_argument, NULL, 'r'},
{"pdepend",   no_argument, NULL, 'p'},
{"bdepend",   no_argument, NULL, 'b'},
+   {"idepend",   no_argument, NULL, 'I'},
{"query", no_argument, NULL, 'Q'},
{"installed", no_argument, NULL, 'i'},
{"tree",  no_argument, NULL, 't'},
@@ -42,6 +43,7 @@ static const char * const qdepends_opts_help[] = {
"Show RDEPEND info",
"Show PDEPEND info",
"Show BDEPEND info",
+   "Show IDEPEND info",
"Query reverse deps",
"Search installed packages using VDB",
"Search available ebuilds in the tree",
@@ -71,17 +73,22 @@ struct qdepends_opt_state {
 #define QMODE_RDEPEND(1<<1)
 #define QMODE_PDEPEND(1<<2)
 #define QMODE_BDEPEND(1<<3)
+#define QMODE_IDEPEND(1<<4)
 #define QMODE_INSTALLED  (1<<5)
 #define QMODE_TREE   (1<<6)
 #define QMODE_REVERSE(1<<7)
 #define QMODE_FILTERUSE  (1<<8)
 
+#define QMODE_DEP_FIRST  QMODE_DEPEND
+#define QMODE_DEP_LAST   QMODE_IDEPEND
+
 const char *depend_files[] = {  /* keep *DEPEND aligned with above defines */
/* 0 */ "DEPEND",
/* 1 */ "RDEPEND",
/* 2 */ "PDEPEND",
/* 3 */ "BDEPEND",
-   /* 4 */ NULL
+   /* 4 */ "IDEPEND",
+   /* 5 */ NULL
 };
 
 static bool
@@ -161,15 +168,19 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
xarrayfree_int(state->deps);
clear_set(state->udeps);
 
+#define get_depstr(X) \
+   i == QMODE_DEPEND  ? tree_pkg_meta_get(pkg_ctx, DEPEND)  : \
+   i == QMODE_RDEPEND ? tree_pkg_meta_get(pkg_ctx, RDEPEND) : \
+   i == QMODE_PDEPEND ? tree_pkg_meta_get(pkg_ctx, PDEPEND) : \
+   i == QMODE_BDEPEND ? 

[gentoo-commits] proj/portage-utils:master commit in: man/, /

2022-12-15 Thread Fabian Groffen
commit: 05e24fdd5fda7fdee37c7f48d398e15f3ba56514
Author: Fabian Groffen  gentoo  org>
AuthorDate: Thu Dec 15 09:35:57 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu Dec 15 09:35:57 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=05e24fdd

qkeyword: add -A option to show the current arch

Signed-off-by: Fabian Groffen  gentoo.org>

 man/qkeyword.1 |  8 +++-
 qkeyword.c | 31 +++
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/man/qkeyword.1 b/man/qkeyword.1
index 2c7eaf5..476a6fa 100644
--- a/man/qkeyword.1
+++ b/man/qkeyword.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qkeyword "1" "Feb 2021" "Gentoo Foundation" "qkeyword"
+.TH qkeyword "1" "Dec 2022" "Gentoo Foundation" "qkeyword"
 .SH NAME
 qkeyword \- list packages based on keywords
 .SH SYNOPSIS
@@ -37,6 +37,9 @@ match catname.
 \fB\-m\fR \fI\fR, \fB\-\-matchmaint\fR \fI\fR
 match maintainer email from metadata.xml (slow).
 .TP
+\fB\-A\fR, \fB\-\-showarch\fR
+show selected arch from profile configuration.
+.TP
 \fB\-i\fR, \fB\-\-imlate\fR
 list packages that can be marked stable for .
 .TP
@@ -76,6 +79,9 @@ Tighter output; suppress warnings.
 \fB\-C\fR, \fB\-\-nocolor\fR
 Don't output color.
 .TP
+\fB\-\-color\fR
+Force color in output.
+.TP
 \fB\-h\fR, \fB\-\-help\fR
 Print this help and exit.
 .TP

diff --git a/qkeyword.c b/qkeyword.c
index 0989e20..5bc1010 100644
--- a/qkeyword.c
+++ b/qkeyword.c
@@ -28,11 +28,12 @@
 /* Required portage-utils stuff */
 //
 
-#define QKEYWORD_FLAGS "p:c:m:idtsanSTF:" COMMON_FLAGS
+#define QKEYWORD_FLAGS "p:c:m:AidtsanSTF:" COMMON_FLAGS
 static struct option const qkeyword_long_opts[] = {
{"matchpkg", a_argument, NULL, 'p'},
{"matchcat", a_argument, NULL, 'c'},
{"matchmaint",   a_argument, NULL, 'm'},
+   {"showarch",no_argument, NULL, 'A'},
{"imlate",  no_argument, NULL, 'i'},
{"dropped", no_argument, NULL, 'd'},
{"needsstable", no_argument, NULL, 't'},
@@ -48,6 +49,7 @@ static const char * const qkeyword_opts_help[] = {
"match pkgname",
"match catname",
"match maintainer email from metadata.xml (slow)",
+   "show selected arch from profile configuration",
"list packages that can be marked stable for ",
"list packages that have dropped keywords for ",
"list packages that have ~arch versions, but no stable versions for 
",
@@ -818,19 +820,22 @@ qkeyword_traverse(tree_pkg_cb func, void *priv)
 
 int qkeyword_main(int argc, char **argv)
 {
-   int i;
-   char action = '\0';
+   int   i;
+   char  action   = '\0';
+   char *pkg  = NULL;
+   char *cat  = NULL;
+   char *maint= NULL;
+   bool  showarch = false;
qkeyword_data data;
-   char *pkg = NULL;
-   char *cat = NULL;
-   char *maint = NULL;
 
data.fmt = NULL;
while ((i = GETOPT_LONG(QKEYWORD, qkeyword, "")) != -1) {
switch (i) {
-   case 'p': pkg = optarg; break;
-   case 'c': cat = optarg; break;
-   case 'm': maint = optarg; break;
+   case 'p':  pkg  = optarg;  break;
+   case 'c':  cat  = optarg;  break;
+   case 'm':  maint= optarg;  break;
+   case 'A':  showarch = true;break;
+   case 'F':  data.fmt = optarg;  break;
case 'i':
case 'd':
case 't':
@@ -844,9 +849,6 @@ int qkeyword_main(int argc, char **argv)
qkeyword_usage(EXIT_FAILURE);
action = i;
break;
-   case 'F':
-   data.fmt = optarg;
-   break;
 
COMMON_GETOPTS_CASES(qkeyword)
}
@@ -860,6 +862,11 @@ int qkeyword_main(int argc, char **argv)
optind + 1 < argc)
qkeyword_usage(EXIT_FAILURE);
 
+   if (showarch) {
+   printf("%s\n", data.arch);
+   return EXIT_SUCCESS;
+   }
+
if (cat != NULL) {
data.qatom = atom_explode_cat(pkg == NULL ? "" : pkg, cat);
if (data.qatom == NULL) {



[gentoo-commits] proj/portage-utils:master commit in: /

2022-12-15 Thread Fabian Groffen
commit: 25853d2ea35884a7f4cf6fefa2a2c53610fc6164
Author: Fabian Groffen  gentoo  org>
AuthorDate: Thu Dec 15 09:12:10 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu Dec 15 09:12:10 2022 +
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  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 - 
@@ -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,



[gentoo-commits] proj/portage-utils:master commit in: /

2022-12-15 Thread Fabian Groffen
commit: 9c67a37fc7709c9e314bc56ccdf7727bee02fc92
Author: Krzesimir Nowak  microsoft  com>
AuthorDate: Wed Dec 14 11:52:25 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu Dec 15 09:02:33 2022 +
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  microsoft.com>
Signed-off-by: Fabian Groffen  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;



[gentoo-commits] proj/portage-utils:master commit in: /

2022-12-15 Thread Fabian Groffen
commit: 8f7064fdf7aa08e00bb24e5e479c1df4be9ae5e7
Author: Krzesimir Nowak  microsoft  com>
AuthorDate: Wed Dec 14 11:53:33 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu Dec 15 09:02:42 2022 +
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  microsoft.com>
Signed-off-by: Fabian Groffen  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, _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",
-   

[gentoo-commits] proj/portage-utils:master commit in: /

2022-11-16 Thread Fabian Groffen
commit: 72f679853cbec7a34a358e9c67f70b672ee86bee
Author: sfrolov  google  com>
AuthorDate: Wed Nov 16 08:53:37 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Wed Nov 16 08:53:37 2022 +
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  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"



[gentoo-commits] proj/portage-utils:master commit in: /

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

build-sys: regenerate

Signed-off-by: Fabian Groffen  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; }



[gentoo-commits] proj/portage-utils:master commit in: /

2022-08-29 Thread Fabian Groffen
commit: efff7e86cececb54493a2d5f9210ffa72651d8ce
Author: Fabian Groffen  gentoo  org>
AuthorDate: Mon Aug 29 08:10:08 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Mon Aug 29 08:10:08 2022 +
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  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"])])



[gentoo-commits] proj/portage-utils:master commit in: tests/rmspace/, /, tests/mkdir/, tests/atom_explode/, libq/, tests/copy_file/

2022-08-28 Thread Fabian Groffen
commit: 1ad6040d95a9c8733cec4388ac6cb3c73e8ddf0d
Author: David Seifert  gentoo  org>
AuthorDate: Sun Aug 28 11:40:31 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Aug 28 11:51:06 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=1ad6040d

Remove libtool

* Libtool was only used for convenience libraries, which can
  be done in vanilla Automake. This allows passing `static`
  in LDFLAGS.

Bug: https://bugs.gentoo.org/841898
Signed-off-by: David Seifert  gentoo.org>
Signed-off-by: Fabian Groffen  gentoo.org>

 Makefile.am| 2 +-
 configure.ac   | 3 +--
 libq/Makefile.am   | 6 +++---
 tests/atom_explode/Makefile.am | 2 +-
 tests/copy_file/Makefile.am| 2 +-
 tests/mkdir/Makefile.am| 2 +-
 tests/rmspace/Makefile.am  | 2 +-
 7 files changed, 9 insertions(+), 10 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 13a6044..7dbcf42 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -78,7 +78,7 @@ q_CPPFLAGS = \
$(LIBZ_CFLAGS) \
$(NULL)
 q_LDADD = \
-   $(top_builddir)/libq/libq.la \
+   $(top_builddir)/libq/libq.a \
$(top_builddir)/autotools/gnulib/libgnu.a \
$(OPENMP_CFLAGS) \
$(LIBSSL_LIBS) \

diff --git a/configure.ac b/configure.ac
index 5378795..9f892c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -21,8 +21,7 @@ gl_EARLY
 gl_INIT
 
 AM_PROG_AR
-LT_INIT
-AC_SUBST([LIBTOOL_DEPS])
+AC_PROG_LN_S
 
 headers='#ifdef HAVE_STDDEF_H
 #include 

diff --git a/libq/Makefile.am b/libq/Makefile.am
index c0402a4..879d4a7 100644
--- a/libq/Makefile.am
+++ b/libq/Makefile.am
@@ -34,9 +34,9 @@ QFILES += hash_md5_sha1.c hash_md5_sha1.h
 endif
 endif
 
-noinst_LTLIBRARIES = libq.la
-libq_la_SOURCES = $(QFILES)
-libq_la_CPPFLAGS = \
+noinst_LIBRARIES = libq.a
+libq_a_SOURCES = $(QFILES)
+libq_a_CPPFLAGS = \
$(OPENMP_CFLAGS) \
-I$(top_builddir)/autotools/gnulib \
-I$(top_srcdir)/autotools/gnulib

diff --git a/tests/atom_explode/Makefile.am b/tests/atom_explode/Makefile.am
index ecdcc58..03f5754 100644
--- a/tests/atom_explode/Makefile.am
+++ b/tests/atom_explode/Makefile.am
@@ -7,7 +7,7 @@ e_CPPFLAGS = -I$(top_srcdir) \
 -I$(top_srcdir)/libq \
 -I$(top_builddir)/autotools/gnulib \
 -I$(top_srcdir)/autotools/gnulib
-e_LDADD = $(top_builddir)/libq/libq.la \
+e_LDADD = $(top_builddir)/libq/libq.a \
  $(top_builddir)/autotools/gnulib/libgnu.a \
  $(LIB_CLOCK_GETTIME) \
  $(LIB_EACCESS)

diff --git a/tests/copy_file/Makefile.am b/tests/copy_file/Makefile.am
index 5fbdf15..41bbc72 100644
--- a/tests/copy_file/Makefile.am
+++ b/tests/copy_file/Makefile.am
@@ -7,7 +7,7 @@ m_CPPFLAGS = -I$(top_srcdir) \
 -I$(top_srcdir)/libq \
 -I$(top_builddir)/autotools/gnulib \
 -I$(top_srcdir)/autotools/gnulib
-m_LDADD = $(top_builddir)/libq/libq.la \
+m_LDADD = $(top_builddir)/libq/libq.a \
  $(top_builddir)/autotools/gnulib/libgnu.a \
  $(LIB_CLOCK_GETTIME) \
  $(LIB_EACCESS) \

diff --git a/tests/mkdir/Makefile.am b/tests/mkdir/Makefile.am
index e9d1536..4b17004 100644
--- a/tests/mkdir/Makefile.am
+++ b/tests/mkdir/Makefile.am
@@ -7,7 +7,7 @@ m_CPPFLAGS = -I$(top_srcdir) \
 -I$(top_srcdir)/libq \
 -I$(top_builddir)/autotools/gnulib \
 -I$(top_srcdir)/autotools/gnulib
-m_LDADD = $(top_builddir)/libq/libq.la \
+m_LDADD = $(top_builddir)/libq/libq.a \
  $(top_builddir)/autotools/gnulib/libgnu.a \
  $(LIB_CLOCK_GETTIME) \
  $(LIB_EACCESS)

diff --git a/tests/rmspace/Makefile.am b/tests/rmspace/Makefile.am
index cb54f32..0cb689d 100644
--- a/tests/rmspace/Makefile.am
+++ b/tests/rmspace/Makefile.am
@@ -7,7 +7,7 @@ m_CPPFLAGS = -I$(top_srcdir) \
 -I$(top_srcdir)/libq \
 -I$(top_builddir)/autotools/gnulib \
 -I$(top_srcdir)/autotools/gnulib
-m_LDADD = $(top_builddir)/libq/libq.la \
+m_LDADD = $(top_builddir)/libq/libq.a \
  $(top_builddir)/autotools/gnulib/libgnu.a \
  $(LIB_CLOCK_GETTIME) \
  $(LIB_EACCESS)



[gentoo-commits] proj/portage-utils:master commit in: /

2022-08-28 Thread Fabian Groffen
commit: e2b0dfcb3a678f74454fd2b651dd3aab0b5539ae
Author: David Seifert  gentoo  org>
AuthorDate: Sun Aug 28 11:40:29 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Aug 28 11:50:11 2022 +
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  gentoo.org>
Signed-off-by: Fabian Groffen  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])



[gentoo-commits] proj/portage-utils:master commit in: /

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

Use pkg-config for dependencies

Signed-off-by: David Seifert  gentoo.org>
Signed-off-by: Fabian Groffen  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
- 

[gentoo-commits] proj/portage-utils:master commit in: tests/atom_compare/, libq/

2022-06-15 Thread Fabian Groffen
commit: 62503bbd9e82a5b0fdeec6e357a95e724ec3cef6
Author: Fabian Groffen  gentoo  org>
AuthorDate: Wed Jun 15 19:53:43 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Wed Jun 15 19:53:43 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=62503bbd

libq/atom: fix atom_compare for "0" version components

Bug: https://bugs.gentoo.org/852197
Signed-off-by: Fabian Groffen  gentoo.org>

 libq/atom.c | 36 ++--
 tests/atom_compare/static.good  |  1 +
 tests/atom_compare/static.tests |  1 +
 3 files changed, 28 insertions(+), 10 deletions(-)

diff --git a/libq/atom.c b/libq/atom.c
index 50e9520..31299f1 100644
--- a/libq/atom.c
+++ b/libq/atom.c
@@ -784,22 +784,38 @@ atom_compare_flg(const depend_atom *data, const 
depend_atom *query, int flags)
 *ends1 != '_';
 ends1++)
;
+   if (ends1 != s1)
+   ends1--;
for (ends2 = s2;
 *ends2 != '\0' &&
 *ends2 != '.' &&
 *ends2 != '_';
 ends2++)
;
-   /* 3.3L2-3: remove *trailing* 
zeros */
-   for (ends1--; ends1 > s1 && 
*ends1 == '0'; ends1--)
-   ;
-   for (ends2--; ends2 > s2 && 
*ends2 == '0'; ends2--)
-   ;
-   /* 3.3L4 ASCII stringwise 
comparison */
-   n1 = ends1 - s1;
-   n2 = ends2 - s2;
-   n1 = strncmp(s1, s2, n1 > n2 ? 
n1 : n2);
-   n2 = 0;
+   if (ends2 != s2)
+   ends2--;
+   /* bug 852197: leading 0 means 
something else
+*  must follow */
+   if (ends1 - s1 > 1 || ends2 - 
s2 > 1) {
+   /* 3.3L2-3: remove 
*trailing* zeros */
+   for (; ends1 > s1 && 
*ends1 == '0'; ends1--)
+   ;
+   for (; ends2 > s2 && 
*ends2 == '0'; ends2--)
+   ;
+   /* 3.3L4 ASCII 
stringwise comparison */
+   n1 = ends1 - s1;
+   n2 = ends2 - s2;
+   n1 = strncmp(s1, s2, n1 
> n2 ? n1 : n2);
+   n2 = 0;
+   } else {
+   /* repeat of 3.3#L9 
(else case below) */
+   n1 = strtoll(s1, 
, 10);
+   if (ends1 == s1)
+   n1 = -1;
+   n2 = strtoll(s2, 
, 10);
+   if (ends2 == s2)
+   n2 = -1;
+   }
} else {  /* 3.3#L9 */
n1 = strtoll(s1, , 10);
if (ends1 == s1)

diff --git a/tests/atom_compare/static.good b/tests/atom_compare/static.good
index 6da5553..83bf7ec 100644
--- a/tests/atom_compare/static.good
+++ b/tests/atom_compare/static.good
@@ -52,3 +52,4 @@ a-1 != =a-1.2z*
 a-1_alpha1 == =a-1*
 a-1 != =a-1_alpha1*
 a-1_alpha-r1 == =a-1_alpha*
+a-3.10.5 == >=a-3.10.0_p1_r1

diff --git a/tests/atom_compare/static.tests b/tests/atom_compare/static.tests
index 168f358..213fb5e 100644
--- a/tests/atom_compare/static.tests
+++ b/tests/atom_compare/static.tests
@@ -52,3 +52,4 @@ a-1 =a-1.2z*
 a-1_alpha1 

[gentoo-commits] proj/portage-utils:master commit in: /

2022-06-14 Thread Fabian Groffen
commit: 2100df5c171029d6c347650fdaf098b67df0f059
Author: Fabian Groffen  gentoo  org>
AuthorDate: Tue Jun 14 06:35:35 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Tue Jun 14 06:35:35 2022 +
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  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- 
@@ -747,7 +747,8 @@ read_one_repos_conf(const char *repos_conf, char **primary)
repo = NULL;
for (p = strtok_r(buf, "\n", ); p != NULL; p = strtok_r(NULL, "\n", 
))
{
-   /* 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) {



[gentoo-commits] proj/portage-utils:master commit in: /

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

qdepends: plug Coverity CID 269971 (resource leak)

Signed-off-by: Fabian Groffen  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);
}



[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-05-26 Thread Fabian Groffen
commit: 84804b1dfcf6e5f3b7a7cca2212c8b2d5a7e4f4b
Author: Fabian Groffen  gentoo  org>
AuthorDate: Thu May 26 09:30:28 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu May 26 09:30:28 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=84804b1d

libq/dep: allow resolving multiple times (e.g. for overlays)

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/dep.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libq/dep.c b/libq/dep.c
index 4138a1c..389e506 100644
--- a/libq/dep.c
+++ b/libq/dep.c
@@ -355,7 +355,7 @@ void
 dep_resolve_tree(dep_node *root, tree_ctx *t)
 {
if (root->type != DEP_NULL) {
-   if (root->type == DEP_NORM && root->atom) {
+   if (root->type == DEP_NORM && root->atom && 
!root->atom_resolved) {
depend_atom*d = root->atom;
tree_match_ctx *r = tree_match_atom(t, d,

TREE_MATCH_DEFAULT |



[gentoo-commits] proj/portage-utils:master commit in: man/, /

2022-05-26 Thread Fabian Groffen
commit: d301ed27e28417f185c374a044cfabeb32beb607
Author: Fabian Groffen  gentoo  org>
AuthorDate: Thu May 26 14:32:32 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu May 26 14:32:32 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d301ed27

qdepends: add --resolve flag to lookup depstrings

This doesn't respect keywords or masks, but with installed packages
shows which packages currently match the deps as expressed

Signed-off-by: Fabian Groffen  gentoo.org>

 man/qdepends.1 | 11 ++-
 qdepends.c | 51 +++
 2 files changed, 45 insertions(+), 17 deletions(-)

diff --git a/man/qdepends.1 b/man/qdepends.1
index 0690f16..5e5b00a 100644
--- a/man/qdepends.1
+++ b/man/qdepends.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qdepends "1" "Feb 2021" "Gentoo Foundation" "qdepends"
+.TH qdepends "1" "May 2022" "Gentoo Foundation" "qdepends"
 .SH NAME
 qdepends \- show dependency info
 .SH SYNOPSIS
@@ -68,6 +68,9 @@ Search installed packages using VDB.
 \fB\-t\fR, \fB\-\-tree\fR
 Search available ebuilds in the tree.
 .TP
+\fB\-U\fR, \fB\-\-use\fR
+Apply profile USE-flags to conditional deps.
+.TP
 \fB\-F\fR \fI\fR, \fB\-\-format\fR \fI\fR
 Pretty-print DEPEND declaration to be used in an ebuild.  This
 option initiates a very different mode of operation.  Instead of
@@ -82,6 +85,9 @@ e.g.\ the DEPEND= part is skipped.
 \fB\-S\fR, \fB\-\-pretty\fR
 Pretty format specified depend strings.
 .TP
+\fB\-R\fR, \fB\-\-resolve\fR
+Resolve found dependencies to package versions.
+.TP
 \fB\-\-root\fR \fI\fR
 Set the ROOT env var.
 .TP
@@ -97,6 +103,9 @@ Suppress DEPEND= output for \fB\-f\fR.  Only print the 
matching atom for \fB\-Q\
 \fB\-C\fR, \fB\-\-nocolor\fR
 Don't output color.
 .TP
+\fB\-\-color\fR
+Force color in output.
+.TP
 \fB\-h\fR, \fB\-\-help\fR
 Print this help and exit.
 .TP

diff --git a/qdepends.c b/qdepends.c
index f1bc3ad..bd7c379 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -22,7 +22,7 @@
 #include "xasprintf.h"
 #include "xregex.h"
 
-#define QDEPENDS_FLAGS "drpbQitUF:S" COMMON_FLAGS
+#define QDEPENDS_FLAGS "drpbQitUF:SR" COMMON_FLAGS
 static struct option const qdepends_long_opts[] = {
{"depend",no_argument, NULL, 'd'},
{"rdepend",   no_argument, NULL, 'r'},
@@ -34,6 +34,7 @@ static struct option const qdepends_long_opts[] = {
{"use",   no_argument, NULL, 'U'},
{"format", a_argument, NULL, 'F'},
{"pretty",no_argument, NULL, 'S'},
+   {"resolve",   no_argument, NULL, 'R'},
COMMON_LONG_OPTS
 };
 static const char * const qdepends_opts_help[] = {
@@ -47,20 +48,23 @@ static const char * const qdepends_opts_help[] = {
"Apply profile USE-flags to conditional deps",
"Print matched atom using given format string",
"Pretty format specified depend strings",
+   "Resolve found dependencies to package versions",
COMMON_OPTS_HELP
 };
 #define qdepends_usage(ret) usage(ret, QDEPENDS_FLAGS, qdepends_long_opts, 
qdepends_opts_help, NULL, lookup_applet_idx("qdepends"))
 
 /* structures / types / etc ... */
 struct qdepends_opt_state {
-   unsigned int qmode;
-   array_t *atoms;
-   array_t *deps;
-   set *udeps;
-   char *depend;
-   size_t depend_len;
-   const char *format;
-   tree_ctx *vdb;
+   unsigned int  qmode;
+   array_t  *atoms;
+   array_t  *deps;
+   set  *udeps;
+   char *depend;
+   size_tdepend_len;
+   const char   *format;
+   char  resolve:1;
+   tree_ctx *vdb;
+   tree_ctx *rtree;
 };
 
 #define QMODE_DEPEND (1<<0)
@@ -174,6 +178,10 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
continue;
}
 
+   /* try and resolve expressions to real package atoms */
+   if (state->resolve)
+   dep_resolve_tree(dep_tree, state->rtree);
+
if (state->qmode & QMODE_TREE &&
!(state->qmode & QMODE_REVERSE) &&
verbose)
@@ -301,12 +309,14 @@ int qdepends_main(int argc, char **argv)
DECLARE_ARRAY(atoms);
DECLARE_ARRAY(deps);
struct qdepends_opt_state state = {
-   .atoms = atoms,
-   .deps = deps,
-   .udeps = create_set(),
-   .qmode = 0,
-   .format = "%[CATEGORY]%[PF]",
-   .vdb = NULL,
+   .atoms   = atoms,
+   .deps= deps,
+   .udeps   = create_set(),
+   .qmode   = 0,
+   .format  = "%[CATEGORY]%[PF]",
+   .resolve = false,
+   .vdb = NULL,
+   .rtree   = NULL,
};
size_t i;
int ret;
@@ -328,6 +338,7 @@ int qdepends_main(int argc, char **argv)
case 't': 

[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-05-26 Thread Fabian Groffen
commit: 8ca9d1625448544f72aa0d45a1cbbdfa8dcfb22e
Author: Fabian Groffen  gentoo  org>
AuthorDate: Thu May 26 09:27:11 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu May 26 09:27:11 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8ca9d162

libq/dep: add dep_resolve_tree function

allow resolving a dep-specification to atoms found in a tree, e.g. see
what would get selected

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/dep.c | 77 +++---
 libq/dep.h | 12 ++
 2 files changed, 56 insertions(+), 33 deletions(-)

diff --git a/libq/dep.c b/libq/dep.c
index 99629e7..4138a1c 100644
--- a/libq/dep.c
+++ b/libq/dep.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2019 Gentoo Foundation
+ * Copyright 2005-2022 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd- 
@@ -20,6 +20,7 @@
 #include "atom.h"
 #include "dep.h"
 #include "set.h"
+#include "tree.h"
 #include "xarray.h"
 #include "xasprintf.h"
 
@@ -62,8 +63,6 @@ static void
 _dep_burn_node(dep_node *node)
 {
assert(node);
-   if (node->info_on_heap)
-   free(node->info);
if (node->atom)
atom_implode(node->atom);
free(node);
@@ -237,7 +236,6 @@ dep_print_tree(
 {
size_t s;
int indent = 4;  /* Gentoo 4-wide indent standard */
-   depend_atom *d = NULL;
bool singlechild = false;
bool nonewline = false;
 
@@ -260,33 +258,31 @@ dep_print_tree(
if (root->type == DEP_OR)
fprintf(fp, "|| (");
if (root->info) {
-   if (hlatoms != NULL && array_cnt(hlatoms) > 0 &&
-   root->type == DEP_NORM)
-   {
-   size_t i;
-   depend_atom *m;
-   char *oslot;
-
-   d = root->atom;
-   d->pfx_op = d->sfx_op = ATOM_OP_NONE;
-
-   array_for_each(hlatoms, i, m) {
-   oslot = d->SLOT;
-   if (m->SLOT == NULL)
-   d->SLOT = NULL;
-
-   if (atom_compare(m, d) == EQUAL) {
-   m = NULL;
-   break;
+   if (root->type == DEP_NORM) {
+   bool dohl = false;
+
+   if (hlatoms != NULL && array_cnt(hlatoms) > 0)
+   {
+   size_t   i;
+   depend_atom *m;
+
+   array_for_each(hlatoms, i, m) {
+   /* make m query, such that any 
specifics (SLOT,
+* pfx/sfx) from the depstring are 
ignored while
+* highlighting */
+   if (atom_compare(root->atom, m) == 
EQUAL) {
+   dohl = true;
+   break;
+   }
}
-   d->SLOT = oslot;
}
 
-   if (m == NULL) { /* match found */
-   fprintf(fp, "%s%s%s", hlcolor, root->info, 
NORM);
-   } else {
-   fprintf(fp, "%s", root->info);
-   }
+   fprintf(fp, "%s%s%s",
+   dohl ? hlcolor : "",
+   atom_to_string(root->atom),
+   dohl ? NORM : "");
+   if (root->atom_resolved && verbose > 0)
+   fprintf(fp, "  # %s", root->info);
} else {
fprintf(fp, "%s", root->info);
}
@@ -355,6 +351,31 @@ dep_prune_use(dep_node *root, set *use)
dep_prune_use(root->children, use);
 }
 
+void
+dep_resolve_tree(dep_node *root, tree_ctx *t)
+{
+   if (root->type != DEP_NULL) {
+   if (root->type == DEP_NORM && root->atom) {
+   depend_atom*d = root->atom;
+   tree_match_ctx *r = tree_match_atom(t, d,
+   
TREE_MATCH_DEFAULT |
+   
TREE_MATCH_LATEST);
+   if (r != NULL) {
+   atom_implode(d);
+   root->atom = atom_clone(r->atom);
+   root->atom_resolved = 1;
+   tree_match_close(r);
+  

[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-05-20 Thread Fabian Groffen
commit: e1a3cb832e35df4656e64b3385823d1ffd8ab848
Author: Fabian Groffen  gentoo  org>
AuthorDate: Fri May 20 17:14:54 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Fri May 20 17:14:54 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e1a3cb83

libq/atom: make atom_to_string_r produce BUILD_ID when set

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/atom.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libq/atom.c b/libq/atom.c
index 3d9d31f..50e9520 100644
--- a/libq/atom.c
+++ b/libq/atom.c
@@ -1015,6 +1015,8 @@ atom_to_string_r(char *buf, size_t buflen, depend_atom *a)
off += snprintf(buf + off, buflen - off, "-%s", a->PV);
if (a->PR_int > 0)
off += snprintf(buf + off, buflen - off, "-r%d", a->PR_int);
+   if (a->BUILDID > 0)
+   off += snprintf(buf + off, buflen - off, "~%u", a->BUILDID);
off += snprintf(buf + off, buflen - off, "%s", atom_op_str[a->sfx_op]);
if (a->SLOT != NULL || a->slotdep != ATOM_SD_NONE)
off += snprintf(buf + off, buflen - off, ":%s%s%s%s",



[gentoo-commits] proj/portage-utils:master commit in: /

2022-05-20 Thread Fabian Groffen
commit: 4f3a79cc3e9399a723dc0a08c4122ed12e2f1001
Author: Fabian Groffen  gentoo  org>
AuthorDate: Fri May 20 17:02:14 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Fri May 20 17:02:14 2022 +
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  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 - 
@@ -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 : "",



[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-05-20 Thread Fabian Groffen
commit: b868d22a6c731449ccfec344508458cf9f7a5abf
Author: Fabian Groffen  gentoo  org>
AuthorDate: Fri May 20 17:02:56 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Fri May 20 17:02:56 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b868d22a

libq/tree: support FEATURES=binpkg-multi-instance Packages file

Based on the work of genbtc in GitHub PR #16

Add BUILD_ID to atom when parsing and use PATH to get the appropriate
location.

Closes: https://github.com/gentoo/portage-utils/pull/16
Signed-off-by: Fabian Groffen  gentoo.org>

 libq/tree.c | 23 ++-
 libq/tree.h |  4 +++-
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git a/libq/tree.c b/libq/tree.c
index d71ee74..2a457ce 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -1440,6 +1440,8 @@ tree_foreach_packages(tree_ctx *ctx, tree_pkg_cb 
callback, void *priv)
}
cat->pkg_ctxs = (tree_pkg_ctx **)atom;  
/* for name */
}
+   if (meta.Q_BUILDID != NULL)
+   atom->BUILDID = atoi(meta.Q_BUILDID);
pkgnamelen = snprintf(pkgname, sizeof(pkgname),
"%s.tbz2", atom->PF);
pkgname[pkgnamelen - (sizeof(".tbz2") - 1)] = 
'\0';
@@ -1510,6 +1512,9 @@ tree_foreach_packages(tree_ctx *ctx, tree_pkg_cb 
callback, void *priv)
match_key(PDEPEND);
match_key2(REPO, repository);
match_key(SIZE);
+   match_key(BDEPEND);
+   match_key(PATH);
+   match_key2(BUILD_ID, BUILDID);
 #undef match_key
 #undef match_key2
}
@@ -1812,11 +1817,19 @@ tree_match_atom(tree_ctx *ctx, const depend_atom 
*query, int flags)
n = xzalloc(sizeof(tree_match_ctx)); \
n->atom = atom; \
n->pkg = pkg_ctx; \
-   snprintf(n->path, sizeof(n->path), "%s/%s/%s%s", \
-   (char *)C->ctx->path, C->name, 
pkg_ctx->name, \
-   C->ctx->cachetype == CACHE_EBUILD ? 
".ebuild" : \
-   C->ctx->cachetype == CACHE_BINPKGS ? 
".tbz2" : \
-   C->ctx->cachetype == CACHE_PACKAGES ? 
".tbz2" : ""); \
+   if (C->ctx->cachetype == CACHE_PACKAGES && \
+   pkg_ctx->meta->Q_PATH != NULL) \
+   { \
+   /* binpkg-multi-instance has a PATH ready for 
us */ \
+   snprintf(n->path, sizeof(n->path), "%s/%s", \
+(char *)C->ctx->path, 
pkg_ctx->meta->Q_PATH); \
+   } else { \
+   snprintf(n->path, sizeof(n->path), 
"%s/%s/%s%s", \
+(char *)C->ctx->path, C->name, 
pkg_ctx->name, \
+C->ctx->cachetype == 
CACHE_EBUILD   ? ".ebuild" : \
+C->ctx->cachetype == 
CACHE_BINPKGS  ? ".tbz2" : \
+C->ctx->cachetype == 
CACHE_PACKAGES ? ".tbz2" : ""); \
+   } \
if (flags & TREE_MATCH_METADATA) \
n->meta = tree_pkg_read(pkg_ctx); \
if (C->ctx->cachetype == CACHE_BINPKGS || \

diff --git a/libq/tree.h b/libq/tree.h
index 8279281..2f2c81f 100644
--- a/libq/tree.h
+++ b/libq/tree.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2021 Gentoo Foundation
+ * Copyright 2005-2022 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  */
 
@@ -104,6 +104,8 @@ struct tree_pkg_meta {
char *Q_CONTENTS;
char *Q_USE;
char *Q_EPREFIX;
+   char *Q_PATH; /* binpkg-multi-instance */
+   char *Q_BUILDID;  /* binpkg-multi-instance */
char *Q_repository;
char *Q_MD5;
char *Q_SHA1;



[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-05-19 Thread Fabian Groffen
commit: 566c8b8db5bc0f7ae4636a1d3387ddb6de41692f
Author: Fabian Groffen  gentoo  org>
AuthorDate: Thu May 19 08:31:40 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu May 19 08:31:40 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=566c8b8d

libq/atom: allow including BUILDID in atom_format

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/atom.c | 15 +++
 1 file changed, 15 insertions(+)

diff --git a/libq/atom.c b/libq/atom.c
index 6f88698..3d9d31f 100644
--- a/libq/atom.c
+++ b/libq/atom.c
@@ -1045,6 +1045,7 @@ atom_to_string_r(char *buf, size_t buflen, depend_atom *a)
  *- any prefix of these (e.g. CAT, CA, C) will match as well
  *  pfx - the version qualifier if set (e.g. > < = !)
  *  sfx - the version qualifier if set (e.g. *)
+ *  BUILDID - the binpkg-multi-instance id
  */
 char *
 atom_format_r(
@@ -1174,6 +1175,20 @@ atom_format_r(
append_buf(buf, 
buflen, "%s", "]");
}
}
+   } else if (strncmp("BUILDID", fmt, len) == 0) {
+   if (showit || atom->BUILDID > 0) {
+   /* this is really shitty, '-' 
is not feasible,
+* but used by Portage
+* 
https://archives.gentoo.org/gentoo-portage-dev/message/054f5f1f334b60bdb1b7f80ff4755bd4
+* using this we cannot parse 
what we would
+* produce, but look more like 
the original
+* since it's not clear this is 
necessary at
+* all, I decided to avoid any 
confusion and use
+* '~' so we can see this is 
not a version bit */
+   append_buf(buf, buflen, 
"%s%s%u%s",
+  RED, 
connected ? "~" : "",
+  
atom->BUILDID, NORM);
+   }
} else
append_buf(buf, buflen, "", 
(int)len, fmt);
p++;



[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-05-19 Thread Fabian Groffen
commit: be7090b77585c7c4af0d46ca0cde805d370c6cc0
Author: Fabian Groffen  gentoo  org>
AuthorDate: Thu May 19 08:15:34 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu May 19 08:15:34 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=be7090b7

libq/atom: make atom_compare consider BUILDID

PR: https://github.com/gentoo/portage-utils/pull/16
Signed-off-by: Fabian Groffen  gentoo.org>

 libq/atom.c | 18 +-
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/libq/atom.c b/libq/atom.c
index d1eb9a4..6f88698 100644
--- a/libq/atom.c
+++ b/libq/atom.c
@@ -954,16 +954,24 @@ atom_compare_flg(const depend_atom *data, const 
depend_atom *query, int flags)
 * 6:return  A < B
 * 7:  end if
 */
-   /* Make sure the -r# is the same. 3.7 */
+   /* first handle wildcarding cases */
if ((sfx_op == ATOM_OP_STAR && query->PR_int == 0) ||
pfx_op == ATOM_OP_PV_EQUAL ||
-   flags & ATOM_COMP_NOREV ||
-   data->PR_int == query->PR_int)
+   flags & ATOM_COMP_NOREV)
return _atom_compare_match(EQUAL, pfx_op);
-   else if (data->PR_int < query->PR_int)
+   /* Make sure the -r# is the same. 3.7 */
+   if (data->PR_int < query->PR_int)
+   return _atom_compare_match(OLDER, pfx_op);
+   else if (data->PR_int > query->PR_int)
+   return _atom_compare_match(NEWER, pfx_op);
+
+   /* binpkg-multi-instance support */
+   if (data->BUILDID < query->BUILDID)
return _atom_compare_match(OLDER, pfx_op);
-   else
+   if (data->BUILDID > query->BUILDID)
return _atom_compare_match(NEWER, pfx_op);
+
+   return _atom_compare_match(EQUAL, pfx_op);
 }
 
 atom_equality



[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-05-19 Thread Fabian Groffen
commit: 74aaef62c0bfad13cf528497faf4b12cbe3d52a5
Author: Fabian Groffen  gentoo  org>
AuthorDate: Thu May 19 07:43:08 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu May 19 07:43:08 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=74aaef62

libq/atom.h: add BUILDID to atom for binpkg-multi-instance support

References: https://github.com/gentoo/portage-utils/pull/16
Signed-off-by: Fabian Groffen  gentoo.org>

 libq/atom.h | 33 +
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/libq/atom.h b/libq/atom.h
index 8291daf..fcfa0bd 100644
--- a/libq/atom.h
+++ b/libq/atom.h
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2021 Gentoo Foundation
+ * Copyright 2005-2022 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2008 Ned Ludd- 
@@ -68,23 +68,24 @@ typedef struct _atom_usedep {
 } atom_usedep;
 
 typedef struct {
-   atom_blocker blocker;
+   atom_blocker  blocker;
atom_operator pfx_op;
atom_operator sfx_op;
-   char *CATEGORY;
-   char *PN;
-   char *PV;
-   char *PF;
-   unsigned int PR_int;
-   char letter;
-   atom_suffix *suffixes;
-   char *PVR;
-   char *P;
-   atom_usedep *usedeps;
-   char *SLOT;
-   char *SUBSLOT;
-   atom_slotdep slotdep;
-   char *REPO;
+   char *CATEGORY;
+   char *PN;
+   char *PV;
+   char *PF;
+   unsigned int  PR_int;
+   char  letter;
+   atom_suffix  *suffixes;
+   char *PVR;
+   char *P;
+   atom_usedep  *usedeps;
+   char *SLOT;
+   char *SUBSLOT;
+   atom_slotdep  slotdep;
+   char *REPO;
+   unsigned int  BUILDID;
 } depend_atom;
 
 extern const char * const booga[];



[gentoo-commits] proj/portage-utils:master commit in: tests/atom_compare/, /, libq/

2022-04-18 Thread Fabian Groffen
commit: 7de2f154c775e9de276f2fc1f619922f48a13b90
Author: Fabian Groffen  gentoo  org>
AuthorDate: Mon Apr 18 09:35:48 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Mon Apr 18 09:35:48 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7de2f154

libq/atom: implement strict PMS 3.3 in atom_compare

Version comparisons are complex, stick with strict PMS definition for
it, so we produce the same results as Portage.

Bug: https://bugs.gentoo.org/838856
Signed-off-by: Fabian Groffen  gentoo.org>

 autogen.sh|   1 +
 libq/atom.c   | 249 --
 tests/atom_compare/static.q.good  |   3 +-
 tests/atom_compare/static.q.tests |   1 +
 4 files changed, 219 insertions(+), 35 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index ea564e0..df6e574 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -43,6 +43,7 @@ mods="
stat-time
strcasestr-simple
strncat
+   strtoll
symlinkat
sys_stat
unlinkat

diff --git a/libq/atom.c b/libq/atom.c
index 0b5fcdd..d1eb9a4 100644
--- a/libq/atom.c
+++ b/libq/atom.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- 
@@ -694,41 +694,170 @@ atom_compare_flg(const depend_atom *data, const 
depend_atom *query, int flags)
 
/* check version */
if (data->PV && query->PV) {
-   char *s1, *s2;
-   uint64_t n1, n2;
-   /* first we compare the version [1.0]z_alpha1 */
-   s1 = data->PV;
-   s2 = query->PV;
-   while (s1 || s2) {
-   if (s1 && s2) {
-   /* deal with leading zeros */
-   while (*s1 == '0' && *s2 == '0') {
-   ++s1;
-   ++s2;
+   char  *s1;
+   char  *ends1;
+   char  *s2;
+   char  *ends2;
+   long long  n1;
+   long long  n2;
+   const atom_suffix *as1;
+   const atom_suffix *as2;
+
+   /* PMS 3.3 Version Comparison
+*
+* Algorithm 3.1: Version comparison top-level logic
+* 1:  let A and B be the versions to be compared
+* 2:  compare numeric components using Algorithm 3.2
+* 3:  compare letter components using Algorithm 3.4
+* 4:  compare suffixes using Algorithm 3.5
+* 5:  compare revision components using Algorithm 3.7
+* 6:  return  A = B
+*/
+
+   /* step 2: numeric components
+*
+* Algorithm 3.2: Version comparison logic for numeric
+* components
+*  1:  define the notations Ank and Bnk to mean the kth numeric
+*  component of A and B respectively, using 0-based 
indexing
+*  2:  if An0 > Bn0 using integer comparison then
+*  3:return  A > B
+*  4:  else if An0 < Bn0 using integer comparison then
+*  5:return  A < B
+*  6:  end if
+*  7:  let Ann be the number of numeric components of A
+*  8:  let Bnn be the number of numeric components of B
+*  9:  for all i such that i ≥ 1 and i < Ann and i < Bnn, in
+*  ascending order do
+* 10:compare Ani and Bni using Algorithm 3.3
+* 11:  end for
+* 12:  if Ann > Bnn then
+* 13:return  A > B
+* 14:  else if Ann < Bnn then
+* 15:return  A < B
+* 16:  end if
+*
+* Algorithm 3.3: Version comparison logic for each numeric
+* component after the first
+*  1:  if either Ani or Bni has a leading 0 then
+*  2:let An′i be Ani with any trailing 0s removed
+*  3:let Bn′i be Bni with any trailing 0s removed
+*  4:if An′i > Bn′i using ASCII stringwise comparison then
+*  5:  return  A > B
+*  6:else if An′i < Bn′i using ASCII stringwise comparison 
then
+*  7:  return  A < B
+*  8:end if
+*  9:  else
+* 10:if Ani > Bni using integer comparison then
+* 11:  return  A > B
+* 12:else if Ani < Bni using integer comparison then
+* 13:  return  A < B
+* 14:end if
+* 15:  

[gentoo-commits] proj/portage-utils:master commit in: tests/qcheck/, /

2022-04-09 Thread Fabian Groffen
commit: ede72d3cf08df8ffe7e59c4819d9a6c84ab1659f
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sat Apr  9 11:17:39 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sat Apr  9 11:32:30 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=ede72d3c

qcheck: fix config-protect check, bug #837188

ensure we break out of the config-protect directories loop, instead of
just skipping one directory, such that we don't produce bogus amounts of
files, and also don't check despite we were told not to check (-P)

Bug: https://bugs.gentoo.org/837188
Signed-off-by: Fabian Groffen  gentoo.org>

 qcheck.c | 253 ---
 tests/qcheck/list05.good |   2 +-
 tests/qcheck/list07.good |   2 +-
 3 files changed, 156 insertions(+), 101 deletions(-)

diff --git a/qcheck.c b/qcheck.c
index 9d9a86c..813c1f7 100644
--- a/qcheck.c
+++ b/qcheck.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 2005-2010 Ned Ludd- 
@@ -74,30 +74,30 @@ static int
 qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 {
struct qcheck_opt_state *state = priv;
-   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 */
+   struct stat  st;
+   depend_atom *atom;
+   FILE*fp_contents_update = NULL;
+   size_t   num_files  = 0;
+   size_t   num_files_ok   = 0;
+   size_t   num_files_unknown  = 0;
+   size_t   num_files_ignored  = 0;
+   char*buffer;
+   char*line;
+   char*savep;
+   char*eprefix= NULL;
+   size_t   eprefix_len= 0;
+   int  cp_argc;
+   int  cpm_argc;
+   char   **cp_argv;
+   char   **cpm_argv;
+
+   /* get CONTENTS from meta */
line = tree_pkg_meta_get(pkg_ctx, CONTENTS);
if (line == NULL)
return EXIT_FAILURE;
 
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));
@@ -124,6 +124,10 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
if (!state->chk_config_protect) {
makeargv(config_protect, _argc, _argv);
makeargv(config_protect_mask, _argc, _argv);
+
+   eprefix = tree_pkg_meta_get(pkg_ctx, EPREFIX);
+   if (eprefix != NULL)
+   eprefix_len = strlen(eprefix);
}
 
buffer = NULL;
@@ -136,8 +140,9 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
if (!entry)
continue;
 
-   /* run initial checks */
-   ++num_files;
+   num_files++;
+
+   /* handle skips */
if (array_cnt(state->regex_arr)) {
size_t n;
regex_t *regex;
@@ -145,15 +150,55 @@ qcheck_cb(tree_pkg_ctx *pkg_ctx, void *priv)
if (!regexec(regex, entry->name, 0, NULL, 0))
break;
if (n < array_cnt(state->regex_arr)) {
-   --num_files;
-   ++num_files_ignored;
+   num_files--;
+   num_files_ignored++;
+   if (verbose)
+   qcprintf(" %sSKIP%s %s: matches 
regex\n",
+YELLOW, NORM, 
entry->name);
+   if (state->qc_update)
+   fprintf(fp_contents_update, "%s\n", 
buffer);
continue;
}
}
+
+   /* handle CONFIG_PROTECT-ed files */
+   if (!state->chk_config_protect) {
+   inti;
+   char  *p;
+
+   /* compute path without EPREFIX */
+   p = entry->name;
+   if (strlen(p) > eprefix_len)
+   p += eprefix_len;
+
+  

[gentoo-commits] proj/portage-utils:master commit in: libq/, tests/qdepends/

2022-04-07 Thread Fabian Groffen
commit: 82f8dc2ee9ba0ff97924df0dcc3feba3935b979c
Author: Fabian Groffen  gentoo  org>
AuthorDate: Thu Apr  7 17:14:08 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Thu Apr  7 17:14:08 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=82f8dc2e

libq/dep: print single nodes on a single line

condense conditional and use-deps to a single line when there's a single
target, e.g.:

use? ( cat/pkg )

instead of

use? (
cat/pkg
)

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/dep.c | 34 +-
 tests/qdepends/list03.good |  4 +---
 tests/qdepends/list04.good |  4 +---
 tests/qdepends/list05.good |  4 +---
 4 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/libq/dep.c b/libq/dep.c
index d431367..99629e7 100644
--- a/libq/dep.c
+++ b/libq/dep.c
@@ -238,6 +238,13 @@ dep_print_tree(
size_t s;
int indent = 4;  /* Gentoo 4-wide indent standard */
depend_atom *d = NULL;
+   bool singlechild = false;
+   bool nonewline = false;
+
+   if (verbose < 0) {
+   nonewline = true;
+   verbose = -verbose - 1;
+   }
 
assert(root);
if (root->type == DEP_NULL)
@@ -248,7 +255,8 @@ dep_print_tree(
 
if (verbose > 0)
fprintf(fp, "Node [%s]: ", _dep_names[root->type]);
-   /*printf("Node %p [%s] %p %p %p: ", root, _dep_names[root->type], 
root->parent, root->neighbor, root->children);*/
+   /*printf("Node %p [%s] %p %p %p: ", root, _dep_names[root->type],
+*   root->parent, root->neighbor, root->children);*/
if (root->type == DEP_OR)
fprintf(fp, "|| (");
if (root->info) {
@@ -286,14 +294,30 @@ dep_print_tree(
if (root->type == DEP_USE)
fprintf(fp, "? (");
}
-   fprintf(fp, "\n");
+
+   if (root->children &&
+   root->children->children == NULL &&
+   root->children->neighbor == NULL)
+   {
+   singlechild = true;
+   }
+
+   if (singlechild)
+   fprintf(fp, " ");
+   else if (!nonewline)
+   fprintf(fp, "\n");
 
if (root->children)
-   dep_print_tree(fp, root->children, space+1, hlatoms, hlcolor, 
verbose);
+   dep_print_tree(fp, root->children,
+  singlechild ? 0 : space + 1,
+  hlatoms, hlcolor, singlechild ? 
-verbose - 1 : verbose);
 
if (root->type == DEP_OR || root->type == DEP_USE) {
-   for (s = space; s; --s)
-   fprintf(fp, "%*s", indent, "");
+   if (singlechild)
+   fprintf(fp, " ");
+   else
+   for (s = space; s; --s)
+   fprintf(fp, "%*s", indent, "");
fprintf(fp, ")\n");
}
  this_node_sucks:

diff --git a/tests/qdepends/list03.good b/tests/qdepends/list03.good
index f66b636..d0eb5d2 100644
--- a/tests/qdepends/list03.good
+++ b/tests/qdepends/list03.good
@@ -1,5 +1,3 @@
 DEPEND="
-foo? (
-a/b
-)
+foo? ( a/b )
 "

diff --git a/tests/qdepends/list04.good b/tests/qdepends/list04.good
index 2457caf..7f0887a 100644
--- a/tests/qdepends/list04.good
+++ b/tests/qdepends/list04.good
@@ -1,5 +1,3 @@
 DEPEND="
-|| (
-a/b
-)
+|| ( a/b )
 "

diff --git a/tests/qdepends/list05.good b/tests/qdepends/list05.good
index 0b7d420..868efae 100644
--- a/tests/qdepends/list05.good
+++ b/tests/qdepends/list05.good
@@ -1,9 +1,7 @@
 DEPEND="
 || (
 || (
-|| (
-x
-)
+|| ( x )
 a
 )
 )



[gentoo-commits] proj/portage-utils:master commit in: /

2022-04-06 Thread Fabian Groffen
commit: a9476140700f50fa3d1cae79e7aed8d019591197
Author: Fabian Groffen  gentoo  org>
AuthorDate: Wed Apr  6 19:20:24 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Wed Apr  6 19:20:24 2022 +
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 ,
where one would probably not expect the local USE-configuration to
exclude matches.

Bug: https://bugs.gentoo.org/836590
Signed-off-by: Fabian Groffen  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 

[gentoo-commits] proj/portage-utils:master commit in: tests/mkdir/, libq/, tests/qatom/, tests/copy_file/, tests/atom_explode/, ...

2022-04-06 Thread Fabian Groffen
commit: 51ffbbc074affa45e9f82e0bd857fad4c15ad0f5
Author: Fabian Groffen  gentoo  org>
AuthorDate: Wed Apr  6 19:31:35 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Wed Apr  6 19:31:35 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=51ffbbc0

buildsys: regenerate

Signed-off-by: Fabian Groffen  gentoo.org>

 Makefile.in|   1 +
 autotools/gnulib/Makefile.in   |   1 +
 autotools/m4/libtool.m4| 227 ++-
 autotools/m4/ltoptions.m4  |   4 +-
 autotools/m4/ltsugar.m4|   2 +-
 autotools/m4/ltversion.m4  |  13 +-
 autotools/m4/lt~obsolete.m4|   4 +-
 configure  | 320 ++-
 libq/Makefile.in   |   1 +
 ltmain.sh  | 890 ++---
 tests/Makefile.in  |   1 +
 tests/atom_compare/Makefile.in |   1 +
 tests/atom_explode/Makefile.in |   1 +
 tests/copy_file/Makefile.in|   1 +
 tests/install/Makefile.in  |   1 +
 tests/mkdir/Makefile.in|   1 +
 tests/profile/Makefile.in  |   1 +
 tests/qatom/Makefile.in|   1 +
 tests/qcheck/Makefile.in   |   1 +
 tests/qdepends/Makefile.in |   1 +
 tests/qfile/Makefile.in|   1 +
 tests/qlist/Makefile.in|   1 +
 tests/qlop/Makefile.in |   1 +
 tests/qmanifest/Makefile.in|   1 +
 tests/qmerge/Makefile.in   |   1 +
 tests/qtbz2/Makefile.in|   1 +
 tests/quse/Makefile.in |   1 +
 tests/qxpak/Makefile.in|   1 +
 tests/rmspace/Makefile.in  |   1 +
 tests/source/Makefile.in   |   1 +
 30 files changed, 958 insertions(+), 525 deletions(-)

diff --git a/Makefile.in b/Makefile.in
index bdeefb9..35403dd 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -496,6 +496,7 @@ ERRNO_H = @ERRNO_H@
 ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
+FILECMD = @FILECMD@
 FLOAT_H = @FLOAT_H@
 GETOPT_CDEFS_H = @GETOPT_CDEFS_H@
 GETOPT_H = @GETOPT_H@

diff --git a/autotools/gnulib/Makefile.in b/autotools/gnulib/Makefile.in
index 0a271a7..7749a48 100644
--- a/autotools/gnulib/Makefile.in
+++ b/autotools/gnulib/Makefile.in
@@ -785,6 +785,7 @@ ERRNO_H = @ERRNO_H@
 ETAGS = @ETAGS@
 EXEEXT = @EXEEXT@
 FGREP = @FGREP@
+FILECMD = @FILECMD@
 FLOAT_H = @FLOAT_H@
 GETOPT_CDEFS_H = @GETOPT_CDEFS_H@
 GETOPT_H = @GETOPT_H@

diff --git a/autotools/m4/libtool.m4 b/autotools/m4/libtool.m4
index fd06b14..bf5d8bc 100644
--- a/autotools/m4/libtool.m4
+++ b/autotools/m4/libtool.m4
@@ -1,6 +1,7 @@
 # libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
 #
-#   Copyright (C) 1996-2001, 2003-2015 Free Software Foundation, Inc.
+#   Copyright (C) 1996-2001, 2003-2019, 2021-2022 Free Software
+#   Foundation, Inc.
 #   Written by Gordon Matzigkeit, 1996
 #
 # This file is free software; the Free Software Foundation gives
@@ -31,7 +32,7 @@ m4_define([_LT_COPYING], [dnl
 # along with this program.  If not, see .
 ])
 
-# serial 58 LT_INIT
+# serial 59 LT_INIT
 
 
 # LT_PREREQ(VERSION)
@@ -181,6 +182,7 @@ m4_require([_LT_FILEUTILS_DEFAULTS])dnl
 m4_require([_LT_CHECK_SHELL_FEATURES])dnl
 m4_require([_LT_PATH_CONVERSION_FUNCTIONS])dnl
 m4_require([_LT_CMD_RELOAD])dnl
+m4_require([_LT_DECL_FILECMD])dnl
 m4_require([_LT_CHECK_MAGIC_METHOD])dnl
 m4_require([_LT_CHECK_SHAREDLIB_FROM_LINKLIB])dnl
 m4_require([_LT_CMD_OLD_ARCHIVE])dnl
@@ -219,8 +221,8 @@ esac
 ofile=libtool
 can_build_shared=yes
 
-# All known linkers require a '.a' archive for static linking (except MSVC,
-# which needs '.lib').
+# All known linkers require a '.a' archive for static linking (except MSVC and
+# ICC, which need '.lib').
 libext=a
 
 with_gnu_ld=$lt_cv_prog_gnu_ld
@@ -778,7 +780,7 @@ _LT_EOF
   # if finds mixed CR/LF and LF-only lines.  Since sed operates in
   # text mode, it properly converts lines to CR/LF.  This bash problem
   # is reportedly fixed, but why not run on old versions too?
-  sed '$q' "$ltmain" >> "$cfgfile" \
+  $SED '$q' "$ltmain" >> "$cfgfile" \
  || (rm -f "$cfgfile"; exit 1)
 
mv -f "$cfgfile" "$ofile" ||
@@ -1042,8 +1044,8 @@ int forced_loaded() { return 2;}
 _LT_EOF
   echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >_MESSAGE_LOG_FD
   $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>_MESSAGE_LOG_FD
-  echo "$AR cru libconftest.a conftest.o" >_MESSAGE_LOG_FD
-  $AR cru libconftest.a conftest.o 2>_MESSAGE_LOG_FD
+  echo "$AR $AR_FLAGS libconftest.a conftest.o" >_MESSAGE_LOG_FD
+  $AR $AR_FLAGS libconftest.a conftest.o 2>_MESSAGE_LOG_FD
   echo "$RANLIB libconftest.a" >_MESSAGE_LOG_FD
   $RANLIB libconftest.a 2>_MESSAGE_LOG_FD
   cat > conftest.c << _LT_EOF
@@ -1067,17 +1069,12 @@ _LT_EOF
   _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;
 darwin1.*)
   _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' 
;;
-darwin*) # darwin 5.x on
-  # if running on 10.5 or later, the deployment target 

[gentoo-commits] proj/portage-utils:master commit in: /

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

gitignore: do NOT ignore gnulib files

Signed-off-by: Fabian Groffen  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
 



[gentoo-commits] proj/portage-utils:master commit in: autotools/m4/, autotools/gnulib/

2022-02-27 Thread Fabian Groffen
commit: 6f4c4106d8fa5af3ec3ee772df7783268eb68908
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb 27 12:17:24 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb 27 12:17:24 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6f4c4106

buildsys: add gnulib missing files

Signed-off-by: Fabian Groffen  gentoo.org>

 autotools/gnulib/localtime-buffer.c |  60 +++
 autotools/m4/dirname.m4 |  19 ++
 autotools/m4/inttypes-pri.m4|  42 ++
 autotools/m4/localtime-buffer.m4|  21 +++
 autotools/m4/longlong.m4| 113 
 5 files changed, 255 insertions(+)

diff --git a/autotools/gnulib/localtime-buffer.c 
b/autotools/gnulib/localtime-buffer.c
new file mode 100644
index 000..b65ea45
--- /dev/null
+++ b/autotools/gnulib/localtime-buffer.c
@@ -0,0 +1,60 @@
+/* Provide access to the last buffer returned by localtime() or gmtime().
+
+   Copyright (C) 2001-2003, 2005-2007, 2009-2019 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, see .  */
+
+/* written by Jim Meyering */
+
+#include 
+
+/* Specification.  */
+#include "localtime-buffer.h"
+
+#if GETTIMEOFDAY_CLOBBERS_LOCALTIME || TZSET_CLOBBERS_LOCALTIME
+
+static struct tm tm_zero_buffer;
+struct tm *localtime_buffer_addr = _zero_buffer;
+
+/* This is a wrapper for localtime.
+
+   On the first call, record the address of the static buffer that
+   localtime uses for its result.  */
+
+struct tm *
+rpl_localtime (time_t const *timep)
+#undef localtime
+{
+  struct tm *tm = localtime (timep);
+
+  if (localtime_buffer_addr == _zero_buffer)
+localtime_buffer_addr = tm;
+
+  return tm;
+}
+
+/* Same as above, since gmtime and localtime use the same buffer.  */
+struct tm *
+rpl_gmtime (time_t const *timep)
+#undef gmtime
+{
+  struct tm *tm = gmtime (timep);
+
+  if (localtime_buffer_addr == _zero_buffer)
+localtime_buffer_addr = tm;
+
+  return tm;
+}
+
+#endif

diff --git a/autotools/m4/dirname.m4 b/autotools/m4/dirname.m4
new file mode 100644
index 000..32141ae
--- /dev/null
+++ b/autotools/m4/dirname.m4
@@ -0,0 +1,19 @@
+#serial 10   -*- autoconf -*-
+dnl Copyright (C) 2002-2006, 2009-2019 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+AC_DEFUN([gl_DIRNAME],
+[
+  AC_REQUIRE([gl_DIRNAME_LGPL])
+])
+
+AC_DEFUN([gl_DIRNAME_LGPL],
+[
+  dnl Prerequisites of lib/dirname.h.
+  AC_REQUIRE([gl_DOUBLE_SLASH_ROOT])
+
+  dnl No prerequisites of lib/basename-lgpl.c, lib/dirname-lgpl.c,
+  dnl lib/stripslash.c.
+])

diff --git a/autotools/m4/inttypes-pri.m4 b/autotools/m4/inttypes-pri.m4
new file mode 100644
index 000..38fe118
--- /dev/null
+++ b/autotools/m4/inttypes-pri.m4
@@ -0,0 +1,42 @@
+# inttypes-pri.m4 serial 7 (gettext-0.18.2)
+dnl Copyright (C) 1997-2002, 2006, 2008-2019 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl From Bruno Haible.
+
+AC_PREREQ([2.53])
+
+# Define PRI_MACROS_BROKEN if  exists and defines the PRI*
+# macros to non-string values.  This is the case on AIX 4.3.3.
+
+AC_DEFUN([gt_INTTYPES_PRI],
+[
+  AC_CHECK_HEADERS([inttypes.h])
+  if test $ac_cv_header_inttypes_h = yes; then
+AC_CACHE_CHECK([whether the inttypes.h PRIxNN macros are broken],
+  [gt_cv_inttypes_pri_broken],
+  [
+AC_COMPILE_IFELSE(
+  [AC_LANG_PROGRAM(
+ [[
+#include 
+#ifdef PRId32
+char *p = PRId32;
+#endif
+ ]],
+ [[]])],
+  [gt_cv_inttypes_pri_broken=no],
+  [gt_cv_inttypes_pri_broken=yes])
+  ])
+  fi
+  if test "$gt_cv_inttypes_pri_broken" = yes; then
+AC_DEFINE_UNQUOTED([PRI_MACROS_BROKEN], [1],
+  [Define if  exists and defines unusable PRI* macros.])
+PRI_MACROS_BROKEN=1
+  else
+PRI_MACROS_BROKEN=0
+  fi
+  AC_SUBST([PRI_MACROS_BROKEN])
+])

diff --git a/autotools/m4/localtime-buffer.m4 b/autotools/m4/localtime-buffer.m4
new file mode 100644
index 000..6d99828
--- /dev/null
+++ b/autotools/m4/localtime-buffer.m4
@@ 

[gentoo-commits] proj/portage-utils:master commit in: autotools/gnulib/malloc/, autotools/m4/, autotools/gnulib/, /

2022-02-27 Thread Fabian Groffen
commit: 2a9ab33940b301a572dc12f817d2c66161bfd9bc
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb 27 10:42:45 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb 27 10:42:45 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=2a9ab339

buildsys: attempt to fix Linux build

import basename-lgpl which doesn't exist or something in linux builds,
pretty odd

Signed-off-by: Fabian Groffen  gentoo.org>

 autogen.sh  |   1 +
 autotools/gnulib/Makefile.am|   1 +
 autotools/gnulib/Makefile.in|   1 +
 autotools/gnulib/malloc/.dirstamp   |   0
 autotools/gnulib/malloc/scratch_buffer.gl.h | 148 
 autotools/m4/gnulib-cache.m4|   2 +
 6 files changed, 5 insertions(+), 148 deletions(-)

diff --git a/autogen.sh b/autogen.sh
index ea564e0..75645de 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -28,6 +28,7 @@ done
 # reload the gnulib code
 PATH=/usr/local/src/gnu/gnulib:${PATH}
 mods="
+   basename-lgpl
dirent
faccessat
fdopendir

diff --git a/autotools/gnulib/Makefile.am b/autotools/gnulib/Makefile.am
index 75a456f..dd83446 100644
--- a/autotools/gnulib/Makefile.am
+++ b/autotools/gnulib/Makefile.am
@@ -33,6 +33,7 @@
 #  --no-libtool \
 #  --macro-prefix=gl \
 #  --no-vc-files \
+#  basename-lgpl \
 #  dirent \
 #  faccessat \
 #  fdopendir \

diff --git a/autotools/gnulib/Makefile.in b/autotools/gnulib/Makefile.in
index 0a271a7..78592fa 100644
--- a/autotools/gnulib/Makefile.in
+++ b/autotools/gnulib/Makefile.in
@@ -47,6 +47,7 @@
 #  --no-libtool \
 #  --macro-prefix=gl \
 #  --no-vc-files \
+#  basename-lgpl \
 #  dirent \
 #  faccessat \
 #  fdopendir \

diff --git a/autotools/gnulib/malloc/.dirstamp 
b/autotools/gnulib/malloc/.dirstamp
deleted file mode 100644
index e69de29..000

diff --git a/autotools/gnulib/malloc/scratch_buffer.gl.h 
b/autotools/gnulib/malloc/scratch_buffer.gl.h
deleted file mode 100644
index 3de567c..000
--- a/autotools/gnulib/malloc/scratch_buffer.gl.h
+++ /dev/null
@@ -1,148 +0,0 @@
-/* DO NOT EDIT! GENERATED AUTOMATICALLY! */
-/* Variable-sized buffer with on-stack default allocation.
-   Copyright (C) 2015-2022 Free Software Foundation, Inc.
-   This file is part of the GNU C Library.
-
-   The GNU C Library is free software; you can redistribute it and/or
-   modify it under the terms of the GNU Lesser General Public
-   License as published by the Free Software Foundation; either
-   version 2.1 of the License, or (at your option) any later version.
-
-   The GNU C Library is distributed in the hope that it will be useful,
-   but WITHOUT ANY WARRANTY; without even the implied warranty of
-   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-   Lesser General Public License for more details.
-
-   You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, see
-   .  */
-
-#ifndef _SCRATCH_BUFFER_H
-#define _SCRATCH_BUFFER_H
-
-/* Scratch buffers with a default stack allocation and fallback to
-   heap allocation.  It is expected that this function is used in this
-   way:
-
- struct scratch_buffer tmpbuf;
- scratch_buffer_init ();
-
- while (!function_that_uses_buffer (tmpbuf.data, tmpbuf.length))
-   if (!scratch_buffer_grow ())
-return -1;
-
- scratch_buffer_free ();
- return 0;
-
-   The allocation functions (scratch_buffer_grow,
-   scratch_buffer_grow_preserve, scratch_buffer_set_array_size) make
-   sure that the heap allocation, if any, is freed, so that the code
-   above does not have a memory leak.  The buffer still remains in a
-   state that can be deallocated using scratch_buffer_free, so a loop
-   like this is valid as well:
-
- struct scratch_buffer tmpbuf;
- scratch_buffer_init ();
-
- while (!function_that_uses_buffer (tmpbuf.data, tmpbuf.length))
-   if (!scratch_buffer_grow ())
-break;
-
- scratch_buffer_free ();
-
-   scratch_buffer_grow and scratch_buffer_grow_preserve are guaranteed
-   to grow the buffer by at least 512 bytes.  This means that when
-   using the scratch buffer as a backing store for a non-character
-   array whose element size, in bytes, is 512 or smaller, the scratch
-   buffer only has to grow once to make room for at least one more
-   element.
-*/
-
-#include 
-#include 
-#include 
-
-/* Scratch buffer.  Must be initialized with scratch_buffer_init
-   before its use.  */
-struct scratch_buffer {
-  void *data;/* Pointer to the beginning of the scratch area.  */
-  size_t length; /* Allocated space at the data pointer, in bytes.  */
-  union { max_align_t __align; char __c[1024]; } __space;
-};
-
-/* Initializes *BUFFER so that BUFFER->data points to BUFFER->__space
-   and BUFFER->length reflects the available space.  */
-static inline void
-scratch_buffer_init (struct 

[gentoo-commits] proj/portage-utils:master commit in: /

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

configure.ac: add copyright header

Signed-off-by: Fabian Groffen  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  - 
+# Copyright 2011- Fabian Groffen  - 
+
 AC_PREREQ([2.71])
 AC_INIT([portage-utils],[git])
 AM_INIT_AUTOMAKE([1.11 dist-xz no-dist-gzip silent-rules -Wall])



[gentoo-commits] proj/portage-utils:master commit in: /

2022-02-23 Thread Fabian Groffen
commit: b59cdb9849c6528922664fcc1c07537ac71e05b1
Author: Fabian Groffen  gentoo  org>
AuthorDate: Wed Feb 23 11:55:55 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Wed Feb 23 11:55:55 2022 +
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  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([1], (char 
**), 10);
+   localtime_r(, );
} else if (strchr(sdate, '-') == NULL) {
-   fmt = "%s";
+   time_t d = (time_t)strtoll(sdate, (char **), 
10);
+   localtime_r(, );
} else if ((s = strchr(sdate, 'T')) == NULL) {
-   fmt = "%Y-%m-%d";
+   s = strptime(sdate, "%Y-%m-%d", );
} else {
-   fmt = "%Y-%m-%dT%H:%M:%S";
+   s = strptime(sdate, "%Y-%m-%dT%H:%M:%S", );
}
 
-   s = strptime(sdate, fmt, );
if (s == NULL || s[0] != '\0')
return false;
} else {



[gentoo-commits] proj/portage-utils:master commit in: /

2022-02-12 Thread Fabian Groffen
commit: 219ba2dd9f748c6065c6485020f7de56623e1bc9
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sat Feb 12 18:15:40 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sat Feb 12 18:15:40 2022 +
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  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, ) != -1) {
if (st.st_size == 0)
ret = unlink(buf);
-   close(fd);
}
+   if (fd != -1)
+   close(fd);
return ret;
 }
 



[gentoo-commits] proj/portage-utils:master commit in: /

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

qmanifest: fix Coverity resource leak CID 206540

Signed-off-by: Fabian Groffen  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  - 
@@ -438,8 +438,10 @@ generate_dir(const char *dir, enum type_manifest mtype)
return NULL;
}
 
-   if (list_dir(, , dir) != 0)
+   if (list_dir(, , dir) != 0) {
+   gzclose(mf);
return NULL;
+   }
 
for (i = 0; i < dentrieslen; i++) {
/* ignore existing Manifests */



[gentoo-commits] proj/portage-utils:master commit in: /

2022-02-12 Thread Fabian Groffen
commit: 618db8bdc8f82972815a9f717a4be0df71f0e52c
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sat Feb 12 18:04:10 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sat Feb 12 18:04:10 2022 +
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  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- 
@@ -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 */



[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-02-12 Thread Fabian Groffen
commit: d314b816ef29bf1948cd9f747a22c2565e88bf76
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sat Feb 12 17:03:56 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sat Feb 12 17:03:56 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d314b816

libq/tree: fix Coverity uninitialised memory use CID 248874

tree_read_file_pms was using buf, which was never initialised after
some changes from the past

remove entire buf, and use the paths from pkg and cat ctxs in the
printfs directly

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/tree.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/libq/tree.c b/libq/tree.c
index 1e0e623..d71ee74 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -676,7 +676,6 @@ tree_read_file_pms(tree_pkg_ctx *pkg_ctx)
FILE *f;
tree_pkg_meta *ret = NULL;
size_t len;
-   char buf[_Q_PATH_MAX];
 
if ((f = fdopen(pkg_ctx->fd, "r")) == NULL)
goto err;
@@ -695,7 +694,8 @@ tree_read_file_pms(tree_pkg_ctx *pkg_ctx)
ret->Q_DEPEND = ptr;
 #define next_line(curr, next) \
if ((ptr = strchr(ret->Q_##curr, '\n')) == NULL) { \
-   warn("Invalid cache file for '%s'", buf); \
+   warn("Invalid cache file for '%s/%s'", \
+pkg_ctx->cat_ctx->name, pkg_ctx->name); \
goto err; \
} \
ret->Q_##next = ptr+1; \
@@ -718,8 +718,8 @@ tree_read_file_pms(tree_pkg_ctx *pkg_ctx)
 #undef next_line
ptr = strchr(ptr+1, '\n');
if (ptr == NULL) {
-   warn("Invalid cache file for '%s' - could not find end of cache 
data",
-   buf);
+   warn("Invalid cache file for '%s/%s' - could not find end of 
cache data",
+pkg_ctx->cat_ctx->name, pkg_ctx->name);
goto err;
}
*ptr = '\0';



[gentoo-commits] proj/portage-utils:master commit in: /

2022-02-12 Thread Fabian Groffen
commit: 84f4920ae807927fc0774b5e468797134903554a
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sat Feb 12 16:58:38 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sat Feb 12 16:58:38 2022 +
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  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- 
@@ -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);
}
}
 



[gentoo-commits] proj/portage-utils:master commit in: /

2022-02-12 Thread Fabian Groffen
commit: 48f667375565491d9151ae10137909303cef7685
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sat Feb 12 16:38:16 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sat Feb 12 16:38:16 2022 +
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  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(, "%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;
}
}



[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-02-12 Thread Fabian Groffen
commit: 4b8b0aa52cac041938a08a310f40b6de16b8c3b0
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sat Feb 12 17:12:02 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sat Feb 12 17:12:02 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=4b8b0aa5

libq/move_file: fix Coverity uninitialised use CID 248870

Coverity correctly deduced here, that if we used cached stat, we didn't
use the cache, but a bogus memory struct instead.  Ensure we always use
a populated stat value.

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/move_file.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/libq/move_file.c b/libq/move_file.c
index b98c8e2..104ca25 100644
--- a/libq/move_file.c
+++ b/libq/move_file.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- 
@@ -86,8 +86,8 @@ move_file(int rootfd_src, const char *name_src,
}
 
/* preserve the file times */
-   times[0] = get_stat_atime();
-   times[1] = get_stat_mtime();
+   times[0] = get_stat_atime(stat_src);
+   times[1] = get_stat_mtime(stat_src);
futimens(fd_dst, times);
 
close(fd_src);



[gentoo-commits] proj/portage-utils:master commit in: /

2022-02-12 Thread Fabian Groffen
commit: ea84ef6ee024de6a24e0ee2f0cf557213a05c6b9
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sat Feb 12 17:08:42 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sat Feb 12 17:08:42 2022 +
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  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,



[gentoo-commits] proj/portage-utils:master commit in: /

2022-02-12 Thread Fabian Groffen
commit: 6474196695f7092f7725af8565507fad9b7cf961
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sat Feb 12 16:21:55 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sat Feb 12 16:21:55 2022 +
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  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, ".");



[gentoo-commits] proj/portage-utils:master commit in: /

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

qtbz2: attempt to fix Coverity taint warning

Signed-off-by: Fabian Groffen  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- 
  * Copyright 2005-2014 Mike Frysinger  - 
+ * Copyright 2020- Fabian Groffen  - 
  */
 
 #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 */



[gentoo-commits] proj/portage-utils:master commit in: /

2022-02-12 Thread Fabian Groffen
commit: fc71a04651ab56b0133c61d839169a0cabf6f092
Author: Jaak Ristioja  ristioja  ee>
AuthorDate: Fri Feb 11 15:31:05 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sat Feb 12 16:14:11 2022 +
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  ristioja.ee>
Signed-off-by: Fabian Groffen  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 {



[gentoo-commits] proj/portage-utils:master commit in: /

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

README: use github badge for build status

Signed-off-by: Fabian Groffen  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



[gentoo-commits] proj/portage-utils:master commit in: .github/workflows/

2022-02-06 Thread Fabian Groffen
commit: c6d843bd1ed50bf20d145c9101146f5cf561baa4
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 15:38:51 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 15:38:51 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=c6d843bd

.github: disable macOS build, I give up for the day

Signed-off-by: Fabian Groffen  gentoo.org>

 .github/workflows/build-test-ci.yml | 65 +++--
 1 file changed, 33 insertions(+), 32 deletions(-)

diff --git a/.github/workflows/build-test-ci.yml 
b/.github/workflows/build-test-ci.yml
index d3d1ae2..8c6c54e 100644
--- a/.github/workflows/build-test-ci.yml
+++ b/.github/workflows/build-test-ci.yml
@@ -47,38 +47,39 @@ jobs:
   - name: make variant ${{ matrix.features }}
 run: make CFLAGS="-O3 -Wall -Wshadow -pipe" V=1 check
 
-  make-check-macos-x64:
-strategy:
-  matrix:
-os:
-  - macos-latest
-cc:
-  - clang
-runs-on: ${{ matrix.os }}
-env:
-  CC: ${{ matrix.cc }}
-steps:
-  - name: install deps
-run: brew install gpgme gnupg gnu-sed coreutils bash openssl
-  - name: add homebrew utils to PATH
-run: |
-  echo "$(brew --prefix)/opt/coreutils/libexec/gnubin" >> $GITHUB_PATH
-  echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH
-  echo "$(brew --prefix)/opt/openssl@3/bin" >> $GITHUB_PATH
-  - name: add homebrew utils to ENV
-run: |
-  echo 'LDFLAGS="-L'"$(brew --prefix)/opt/openssl@3/lib ${LDFLAGS}"'"' 
>> $GITHUB_ENV
-  echo 'CPPFLAGS="-I'"$(brew --prefix)/opt/openssl@3/include 
${CPPFLAGS}"'"' >> $GITHUB_ENV
-  echo 'PKG_CONFIG_PATH="'"$(brew 
--prefix)/opt/openssl@3/lib/pkgconfig:${PKG_CONFIG_PATH}"'"' >> $GITHUB_ENV
-  - uses: actions/checkout@v2
-  - name: configure
-# we need to disable qmanifest for we cannot get b2sum and
-# coreutils installed at the same time :/
-run: >
-  ./configure
-  --disable-maintainer-mode --disable-openmp --disable-qmanifest
-  - name: make
-run: make CFLAGS="-O3 -Wall -Wshadow -pipe" V=1 check
+# I'm too tired for now to make it work
+#  make-check-macos-x64:
+#strategy:
+#  matrix:
+#os:
+#  - macos-latest
+#cc:
+#  - clang
+#runs-on: ${{ matrix.os }}
+#env:
+#  CC: ${{ matrix.cc }}
+#steps:
+#  - name: install deps
+#run: brew install gpgme gnupg gnu-sed coreutils bash openssl
+#  - name: add homebrew utils to PATH
+#run: |
+#  echo "$(brew --prefix)/opt/coreutils/libexec/gnubin" >> $GITHUB_PATH
+#  echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH
+#  echo "$(brew --prefix)/opt/openssl@3/bin" >> $GITHUB_PATH
+#  - name: add homebrew utils to ENV
+#run: |
+#  echo 'LDFLAGS="-L'"$(brew --prefix)/opt/openssl@3/lib 
${LDFLAGS}"'"' >> $GITHUB_ENV
+#  echo 'CPPFLAGS="-I'"$(brew --prefix)/opt/openssl@3/include 
${CPPFLAGS}"'"' >> $GITHUB_ENV
+#  echo 'PKG_CONFIG_PATH="'"$(brew 
--prefix)/opt/openssl@3/lib/pkgconfig:${PKG_CONFIG_PATH}"'"' >> $GITHUB_ENV
+#  - uses: actions/checkout@v2
+#  - name: configure
+## we need to disable qmanifest for we cannot get b2sum and
+## coreutils installed at the same time :/
+#run: >
+#  ./configure
+#  --disable-maintainer-mode --disable-openmp --disable-qmanifest
+#  - name: make
+#run: make CFLAGS="-O3 -Wall -Wshadow -pipe" V=1 check
 
   coverity:
 runs-on: ubuntu-latest



[gentoo-commits] proj/portage-utils:master commit in: tests/

2022-02-06 Thread Fabian Groffen
commit: d57f8516cfad348c7871ebeee81b11ef6fcf4acf
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 15:32:15 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 15:32:15 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d57f8516

tests/init: remove last Travis cruft

Signed-off-by: Fabian Groffen  gentoo.org>

 tests/init.sh.in | 7 ++-
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tests/init.sh.in b/tests/init.sh.in
index 248e343..2b0a65f 100644
--- a/tests/init.sh.in
+++ b/tests/init.sh.in
@@ -32,12 +32,9 @@ export TZ='UTC 0'
 q -i -q
 
 # inject valgrind wrapper if necessary, unfortunately valgrind on Ubuntu
-# used by Travis segfaults on qmanifest and qcheck, so disable there to
-# be able to run the rest regularly
+# causes qmanifest to print stuff double, so skip it for that applet
 dovalgrind=${Q_RUN_WITH_VALGRIND}
-[[ ${TRAVIS_OS_NAME}:${as##*/} == linux:qmanifest ]] && dovalgrind=
-[[ ${TRAVIS_OS_NAME}:${as##*/} == linux:qcheck ]] && dovalgrind=
-[[ ${TRAVIS_OS_NAME}:${as##*/} == linux:qmerge ]] && dovalgrind=
+[[ ${RUNNER_OS}:${as##*/} == Linux:qmanifest ]] && dovalgrind=
 if [[ -n ${dovalgrind} ]] ; then
chmod 755 "@abs_top_srcdir@/tests/valgrind-wrapper/qvalgrind"
for f in @abs_top_builddir@/q?* ; do



[gentoo-commits] proj/portage-utils:master commit in: .github/workflows/

2022-02-06 Thread Fabian Groffen
commit: 074b7d518fff59cc19b5a92b89be0aa365d449eb
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 15:26:08 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 15:26:08 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=074b7d51

.github: b2sum and coreutils conflict

Signed-off-by: Fabian Groffen  gentoo.org>

 .github/workflows/build-test-ci.yml | 10 ++
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/.github/workflows/build-test-ci.yml 
b/.github/workflows/build-test-ci.yml
index fd445bd..d3d1ae2 100644
--- a/.github/workflows/build-test-ci.yml
+++ b/.github/workflows/build-test-ci.yml
@@ -59,7 +59,7 @@ jobs:
   CC: ${{ matrix.cc }}
 steps:
   - name: install deps
-run: brew install gpgme gnupg gnu-sed coreutils bash openssl b2sum
+run: brew install gpgme gnupg gnu-sed coreutils bash openssl
   - name: add homebrew utils to PATH
 run: |
   echo "$(brew --prefix)/opt/coreutils/libexec/gnubin" >> $GITHUB_PATH
@@ -70,11 +70,13 @@ jobs:
   echo 'LDFLAGS="-L'"$(brew --prefix)/opt/openssl@3/lib ${LDFLAGS}"'"' 
>> $GITHUB_ENV
   echo 'CPPFLAGS="-I'"$(brew --prefix)/opt/openssl@3/include 
${CPPFLAGS}"'"' >> $GITHUB_ENV
   echo 'PKG_CONFIG_PATH="'"$(brew 
--prefix)/opt/openssl@3/lib/pkgconfig:${PKG_CONFIG_PATH}"'"' >> $GITHUB_ENV
-  echo 'LDFLAGS="-L'"$(brew --prefix)/opt/b2sum/lib ${LDFLAGS}"'"' >> 
$GITHUB_ENV
-  echo 'CPPFLAGS="-I'"$(brew --prefix)/opt/b2sum/include 
${CPPFLAGS}"'"' >> $GITHUB_ENV
   - uses: actions/checkout@v2
   - name: configure
-run: ./configure --disable-maintainer-mode --disable-openmp
+# we need to disable qmanifest for we cannot get b2sum and
+# coreutils installed at the same time :/
+run: >
+  ./configure
+  --disable-maintainer-mode --disable-openmp --disable-qmanifest
   - name: make
 run: make CFLAGS="-O3 -Wall -Wshadow -pipe" V=1 check
 



[gentoo-commits] proj/portage-utils:master commit in: /

2022-02-06 Thread Fabian Groffen
commit: 65e6273199327ea2f6b12bc1dd7959758df4
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 15:21:32 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 15:21:32 2022 +
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  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);



[gentoo-commits] proj/portage-utils:master commit in: .github/workflows/

2022-02-06 Thread Fabian Groffen
commit: d6f203d4f250a4d2f0eabf4370971ad070ea92a9
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 15:15:06 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 15:15:06 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d6f203d4

.github: another attempt at actions

Signed-off-by: Fabian Groffen  gentoo.org>

 .github/workflows/build-test-ci.yml | 15 +--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build-test-ci.yml 
b/.github/workflows/build-test-ci.yml
index 7f3a262..fd445bd 100644
--- a/.github/workflows/build-test-ci.yml
+++ b/.github/workflows/build-test-ci.yml
@@ -57,10 +57,21 @@ jobs:
 runs-on: ${{ matrix.os }}
 env:
   CC: ${{ matrix.cc }}
-  PATH: "$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH"
 steps:
   - name: install deps
-run: brew install gpgme gnupg gnu-sed coreutils bash openssl
+run: brew install gpgme gnupg gnu-sed coreutils bash openssl b2sum
+  - name: add homebrew utils to PATH
+run: |
+  echo "$(brew --prefix)/opt/coreutils/libexec/gnubin" >> $GITHUB_PATH
+  echo "$(brew --prefix)/opt/gnu-sed/libexec/gnubin" >> $GITHUB_PATH
+  echo "$(brew --prefix)/opt/openssl@3/bin" >> $GITHUB_PATH
+  - name: add homebrew utils to ENV
+run: |
+  echo 'LDFLAGS="-L'"$(brew --prefix)/opt/openssl@3/lib ${LDFLAGS}"'"' 
>> $GITHUB_ENV
+  echo 'CPPFLAGS="-I'"$(brew --prefix)/opt/openssl@3/include 
${CPPFLAGS}"'"' >> $GITHUB_ENV
+  echo 'PKG_CONFIG_PATH="'"$(brew 
--prefix)/opt/openssl@3/lib/pkgconfig:${PKG_CONFIG_PATH}"'"' >> $GITHUB_ENV
+  echo 'LDFLAGS="-L'"$(brew --prefix)/opt/b2sum/lib ${LDFLAGS}"'"' >> 
$GITHUB_ENV
+  echo 'CPPFLAGS="-I'"$(brew --prefix)/opt/b2sum/include 
${CPPFLAGS}"'"' >> $GITHUB_ENV
   - uses: actions/checkout@v2
   - name: configure
 run: ./configure --disable-maintainer-mode --disable-openmp



[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-02-06 Thread Fabian Groffen
commit: 42a04c468aff667e0dbaf69aef07c9f679176470
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 14:51:14 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 14:51:14 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=42a04c46

libq/tree: plug leak in tree_match_atom

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/tree.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libq/tree.c b/libq/tree.c
index 7285cd7..1e0e623 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -1778,6 +1778,7 @@ tree_match_atom(tree_ctx *ctx, const depend_atom *query, 
int flags)
sizeof(*cat_ctx->pkg_ctxs), 
tree_pkg_compar);
}
}
+   xarrayfree_int(cats);
}
 
/* activate cache for future lookups, tree_match_atom relies on



[gentoo-commits] proj/portage-utils:master commit in: /

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

qmerge: plug leak in pkg_merge

Signed-off-by: Fabian Groffen  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   */
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);
 



[gentoo-commits] proj/portage-utils:master commit in: .github/workflows/

2022-02-06 Thread Fabian Groffen
commit: d89fc5c0d2aabe66f2ccf3214d6ed3ad429a021f
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 14:31:22 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 14:31:22 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d89fc5c0

.github: try to fix macOS build

Signed-off-by: Fabian Groffen  gentoo.org>

 .github/workflows/build-test-ci.yml | 1 +
 1 file changed, 1 insertion(+)

diff --git a/.github/workflows/build-test-ci.yml 
b/.github/workflows/build-test-ci.yml
index e211b89..7f3a262 100644
--- a/.github/workflows/build-test-ci.yml
+++ b/.github/workflows/build-test-ci.yml
@@ -57,6 +57,7 @@ jobs:
 runs-on: ${{ matrix.os }}
 env:
   CC: ${{ matrix.cc }}
+  PATH: "$(brew --prefix)/opt/coreutils/libexec/gnubin:$PATH"
 steps:
   - name: install deps
 run: brew install gpgme gnupg gnu-sed coreutils bash openssl



[gentoo-commits] proj/portage-utils:master commit in: /

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

qmerge: free up some resources

Signed-off-by: Fabian Groffen  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, , 
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;
 }



[gentoo-commits] proj/portage-utils:master commit in: /

2022-02-06 Thread Fabian Groffen
commit: d2c96a1459ce9603e4a538492a43accca376617e
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 14:21:38 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 14:21:38 2022 +
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  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- 
@@ -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(, "%s/%s", binhost, src);
-
/* wget -c -q -P   */
-   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(, "%s/%s", binhost, src);
 
-   waitpid(p, , 0);
-#if 0
-   if (WIFEXITED(status) && WEXITSTATUS(status) == 0)
-   return;
-#endif
+   if (!pretend && (force_download || install))
+   xsystemv([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__)



[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-02-06 Thread Fabian Groffen
commit: 43ad7423ae06e9bcad672a21131f14e3ce790204
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 14:20:35 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 14:20:35 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=43ad7423

libq/xsystem: cleanup/reuse same codepath, allow passing vector

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/xsystem.c | 96 --
 libq/xsystem.h |  8 +++--
 2 files changed, 65 insertions(+), 39 deletions(-)

diff --git a/libq/xsystem.c b/libq/xsystem.c
index e2dbc5e..05743ce 100644
--- a/libq/xsystem.c
+++ b/libq/xsystem.c
@@ -17,49 +17,73 @@
 #include "xasprintf.h"
 #include "xsystem.h"
 
-void xsystem(const char *command)
-{
-   if (unlikely(system(command)))
-   errp("system(%s) failed", command);
-}
-
-void xsystembash(const char *command, int cwd)
+void xsystembash(const char *command, const char **argv, int cwd)
 {
pid_t p = fork();
int status;
 
switch (p) {
-   case 0: /* child */
-   if (cwd != AT_FDCWD)
-   if (fchdir(cwd)) {
-   /* fchdir works with O_PATH starting 
w/linux-3.5 */
-   if (errno == EBADF) {
-   char *path;
-   xasprintf(, "/proc/self/fd/%i", 
cwd);
-   if (chdir(path))
-   errp("chdir(%s) failed", path);
-   } else
-   errp("fchdir(%i) failed", cwd);
+   case 0: /* child */
+   if (cwd != AT_FDCWD) {
+   if (fchdir(cwd)) {
+   /* fchdir works with O_PATH starting 
w/linux-3.5 */
+   if (errno == EBADF) {
+   char *path;
+   xasprintf(, 
"/proc/self/fd/%i", cwd);
+   if (chdir(path))
+   errp("chdir(%s) 
failed", path);
+   } else {
+   errp("fchdir(%i) failed", cwd);
+   }
+   }
+   }
+   if (argv == NULL) {
+   execl(CONFIG_EPREFIX "bin/bash", "bash",
+ "--norc", "--noprofile", "-c", 
command, (char *)NULL);
+   /* Hrm, still here ?  Maybe no bash ... */
+   _exit(execl("/bin/sh", "sh", "-c", command, 
(char *)NULL));
+   } else {
+   int  argc = 0;
+   const char  *a;
+   const char **newargv;
+
+   /* count existing args */
+   for (a = argv[0]; a != NULL; a++, argc++)
+   ;
+   argc += 1 + 1 + 1 + 1;
+   newargv = xmalloc(sizeof(newargv[0]) * (argc + 
1));
+   argc = 0;
+   newargv[argc++] = "bash";
+   newargv[argc++] = "--norc";
+   newargv[argc++] = "--noprofile";
+   newargv[argc++] = "-c";
+   for (a = argv[0]; a != NULL; a++)
+   newargv[argc++] = a;
+   newargv[argc] = NULL;
+
+   execv(CONFIG_EPREFIX "bin/bash", (char *const 
*)newargv);
+
+   /* Hrm, still here ?  Maybe no bash ... */
+   newargv = [2];  /* shift, two args less 
*/
+   argc = 0;
+   newargv[argc++] = "sh";
+   _exit(execv("/bin/sh", (char *const *)newargv));
}
-   execl(CONFIG_EPREFIX "bin/bash", "bash",
-   "--norc", "--noprofile", "-c", command, (char 
*)NULL);
-   /* Hrm, still here ?  Maybe no bash ... */
-   _exit(execl("/bin/sh", "sh", "-c", command, (char *)NULL));
 
-   default: /* parent */
-   waitpid(p, , 0);
-   if (WIFSIGNALED(status)) {
-   err("phase crashed with signal %i: %s", 
WTERMSIG(status),
-   strsignal(WTERMSIG(status)));
-   } else if (WIFEXITED(status)) {
-   if (WEXITSTATUS(status) == 0)
-   return;

[gentoo-commits] proj/portage-utils:master commit in: .github/workflows/

2022-02-06 Thread Fabian Groffen
commit: 6c33449f9142125bd166c174560798dd426f1755
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 13:28:51 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 13:28:51 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=6c33449f

.github: coverity also needs builddeps

Signed-off-by: Fabian Groffen  gentoo.org>

 .github/workflows/build-test-ci.yml | 4 
 1 file changed, 4 insertions(+)

diff --git a/.github/workflows/build-test-ci.yml 
b/.github/workflows/build-test-ci.yml
index 00a93fc..e211b89 100644
--- a/.github/workflows/build-test-ci.yml
+++ b/.github/workflows/build-test-ci.yml
@@ -69,6 +69,10 @@ jobs:
   coverity:
 runs-on: ubuntu-latest
 steps:
+  - name: install deps
+run: >
+  sudo apt-get install -y
+  libgpgme-dev gnupg2 liblz4-tool lzop zstd lzip brotli libb2-dev
   - uses: actions/checkout@v2
   - name: configure
 run: >



[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-02-06 Thread Fabian Groffen
commit: d0767ea8eab387c65a90445bfd5d8e6e196c30d6
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 13:24:54 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 13:24:54 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=d0767ea8

libq/tree: ensure we free cache.store (for Packages file)

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/tree.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libq/tree.c b/libq/tree.c
index 114541d..db0d2d2 100644
--- a/libq/tree.c
+++ b/libq/tree.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- 
@@ -194,6 +194,8 @@ tree_close(tree_ctx *ctx)
 
xarrayfree_int(t);
}
+   if (ctx->cache.store != NULL)
+   free(ctx->cache.store);
 
closedir(ctx->dir);
/* closedir() above does this for us: */



[gentoo-commits] proj/portage-utils:master commit in: .github/workflows/

2022-02-06 Thread Fabian Groffen
commit: 55ffda741879894c683899eed37347ff3b0b39a3
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 13:02:31 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 13:02:31 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=55ffda74

.github: enable coverity, we setup the secrets

Signed-off-by: Fabian Groffen  gentoo.org>

 .github/workflows/build-test-ci.yml | 27 +--
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/.github/workflows/build-test-ci.yml 
b/.github/workflows/build-test-ci.yml
index 94262b6..00a93fc 100644
--- a/.github/workflows/build-test-ci.yml
+++ b/.github/workflows/build-test-ci.yml
@@ -66,20 +66,19 @@ jobs:
   - name: make
 run: make CFLAGS="-O3 -Wall -Wshadow -pipe" V=1 check
 
-# until we are able to set token on Github :(
-#  coverity:
-#runs-on: ubuntu-latest
-#steps:
-#  - uses: actions/checkout@v2
-#  - name: configure
-#run: >
-#  ./configure
-#  --disable-maintainer-mode --disable-openmp
-#  --enable-qmanifest --enable-qtegrity
-#  - uses: vapier/coverity-scan-action@v1
-#with:
-#  email: ${{ secrets.COVERITY_SCAN_EMAIL }}
-#  token: ${{ secrets.COVERITY_SCAN_TOKEN }}
+  coverity:
+runs-on: ubuntu-latest
+steps:
+  - uses: actions/checkout@v2
+  - name: configure
+run: >
+  ./configure
+  --disable-maintainer-mode --disable-openmp
+  --enable-qmanifest --enable-qtegrity
+  - uses: vapier/coverity-scan-action@v1
+with:
+  email: ${{ secrets.COVERITY_SCAN_EMAIL }}
+  token: ${{ secrets.COVERITY_SCAN_TOKEN }}
 
   valgrind:
 runs-on: ubuntu-latest



[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-02-06 Thread Fabian Groffen
commit: 0541387d790d9e9c0e0033492bdbdb5c6d6d2f59
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 13:27:22 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 13:27:22 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=0541387d

libq/tree: allocate enough space in tree_clone_meta

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/tree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libq/tree.c b/libq/tree.c
index db0d2d2..7285cd7 100644
--- a/libq/tree.c
+++ b/libq/tree.c
@@ -1135,7 +1135,7 @@ tree_clone_meta(tree_pkg_meta *m)
len = sizeof(*ret);
for (ptr = >Q__data; ptr <= >Q__last; ptr++)
if (*ptr != NULL)
-   len += strlen(*ptr);
+   len += strlen(*ptr) + 1;
 
/* malloc and copy */
ret = xzalloc(len);



[gentoo-commits] proj/portage-utils:master commit in: tests/valgrind-wrapper/, travis/, /

2022-02-06 Thread Fabian Groffen
commit: e106383b82df59b81bf1a5a862f893717547fd6d
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 12:31:15 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 12:31:15 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=e106383b

travis: remove

Signed-off-by: Fabian Groffen  gentoo.org>

 .travis.yml  | 67 
 tests/valgrind-wrapper/qvalgrind |  2 +-
 travis/install-blake2.sh | 33 
 travis/lib.sh| 38 ---
 travis/main.sh   | 37 --
 5 files changed, 1 insertion(+), 176 deletions(-)

diff --git a/.travis.yml b/.travis.yml
deleted file mode 100644
index af1504c..000
--- a/.travis.yml
+++ /dev/null
@@ -1,67 +0,0 @@
-# Travis build integration.
-# https://docs.travis-ci.com/
-
-language: c
-dist: focal
-os: linux
-osx_image: xcode11.3.1
-
-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="grob...@gentoo.org"
-- COVERITY_SCAN_BUILD_COMMAND="make"
-- compiler: valgrind
-  arch: amd64
-  env:
-- CFLAGS="-g"
-- Q_RUN_WITH_VALGRIND=1
-- 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"
-
-env:
-  global:
-- secure: 
"qF/ueXvm1uawirfQL+jK5LSJW1P+ZVXDx5t9HljFP1jC45D/1aqEs1ffaNkvBJohUJy6mABnXN5+ZP0PoQ+ZA01t+6NDc/LrowGP87T02KGwjBukQ9tQK8zVutsT+0CY3qUPhRcaLH5Gt3c+uPDKlLndg/bXWS6cRpMt6tC3VTy+WpAlvHHfZJjSZVYp8qhCattnaZ7GvzqGqbjBZ6X7TrQnwIDdGAyg5r4xnViDxu9lO4ZH4zS6Rc7DxesrqC3zxwPRw5HLNsGbJiGQF3meXH6rVNt1uxKwwOQoDcL0NKiyAMpXwu5iGeuMILoy3KMpFwZFnhyXqMGRORakDuDNB9oMgzp+PB3Zb7TICXbhxbrQ46lSlv0VWkwn3bcJ0lek53NzDUmM2uywvCUYybPgn3xCqY9jG0zwO2ZIACc1ekGh7y0gFXfBoSZGhl1VthV5hWMJ01p/n5jK7XdDmK4G/+0wN2WlHhyvjoF6XyJ+SRC85l6VhpBNbFJA2bGT2Y4+p/CzF7M8DVYR3o+OfCWxsiZyE+Vnmpdg4U829oy97obIuBeCvBd1Vp0hoB+RpzaeqzS69N+S4tgCIXvIdu168HltFaTUPtvIGoDtIAPCaUZC8jVO22cA6RpNkac3HjpLSceYYtdkiph4VuBMwHZj6/N2+m46Y9Uxrh01KzLy/GY="
-
-addons:
-  apt:
-packages:
-- libgpgme11-dev
-- gnupg2
-- valgrind
-- liblz4-tool
-- lzop
-- zstd
-- lzip
-- brotli
-  homebrew:
-packages:
-- gpgme
-- gnupg
-- gnu-sed
-- coreutils
-- bash
-- libressl
-
-before_install:
-  - ./travis/install-blake2.sh
-script: ./travis/main.sh

diff --git a/tests/valgrind-wrapper/qvalgrind b/tests/valgrind-wrapper/qvalgrind
index 7240e98..5286cf6 100755
--- a/tests/valgrind-wrapper/qvalgrind
+++ b/tests/valgrind-wrapper/qvalgrind
@@ -16,7 +16,7 @@ if [[ ${ret} == 234 ]] ; then
mv q-valgrind.log q-valgrind.$$.log
echo "valgrind log can be found at ${PWD}/q-valgrind.$$.log" > 
/dev/stderr
# dump complaints in Travis' log, as we cannot retrieve them lateron
-   [[ -n ${TRAVIS_OS_NAME} ]] && cat q-valgrind.$$.log > /dev/stderr
+   [[ -n ${RUNNER_OS} ]] && cat q-valgrind.$$.log > /dev/stderr
 else
rm q-valgrind.log
 fi

diff --git a/travis/install-blake2.sh b/travis/install-blake2.sh
deleted file mode 100755
index 92e58ff..000
--- a/travis/install-blake2.sh
+++ /dev/null
@@ -1,33 +0,0 @@
-#!/bin/bash -e
-
-. "${0%/*}"/lib.sh
-
-main() {
-   local pv="0.98.1"
-   local S="libb2-${pv}"
-   travis_fold start dep-blake2
-   rm -rf libb2*
-   v mkdir -p ../sysroot
-   v wget 
https://github.com/BLAKE2/libb2/releases/download/v${pv}/libb2-${pv}.tar.gz
-   v tar xf libb2-${pv}.tar.gz
-   (
-   cd "${S}"
-   ./configure \
-   --enable-static \
-   --disable-shared \
-   --disable-openmp \
-   --prefix=/ \
-   --libdir=/ \
-   --includedir=/
-   m
-   m DESTDIR="${PWD}/../../sysroot" install
-   )
-   v rm -f ../sysroot/*.la
-   v rm -rf libb2*
-   travis_fold end dep-blake2
-}
-
-if [[ ${CC} == valgrind || ${CC} == coverity ]] ; then
-   export CC=gcc
-fi
-main "$@"

diff --git a/travis/lib.sh b/travis/lib.sh
deleted file mode 100644
index 687ed41..000
--- a/travis/lib.sh
+++ /dev/null
@@ -1,38 +0,0 @@
-#!/bin/bash
-# Common funcs for working w/Travis.
-
-travis_fold() {
-   if [[ -n ${TRAVIS_OS_NAME} ]] ; then
-   printf 'travis_fold:%s:%s\r\n' "$@" | sed 's: :_:g'
-   fi
-}

[gentoo-commits] proj/portage-utils:master commit in: .github/workflows/

2022-02-06 Thread Fabian Groffen
commit: 40a20be491c2247388f210807e38433c33861a86
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 12:27:04 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 12:27:04 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=40a20be4

.github: have to deal with Werror=unknown-pragmas

Signed-off-by: Fabian Groffen  gentoo.org>

 .github/workflows/build-test-ci.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build-test-ci.yml 
b/.github/workflows/build-test-ci.yml
index 228a9da..94262b6 100644
--- a/.github/workflows/build-test-ci.yml
+++ b/.github/workflows/build-test-ci.yml
@@ -45,7 +45,7 @@ jobs:
   --disable-maintainer-mode --disable-openmp
   ${{ matrix.features }}
   - name: make variant ${{ matrix.features }}
-run: make CFLAGS="-O3 -Wall -Werror -Wshadow -pipe" V=1 check
+run: make CFLAGS="-O3 -Wall -Wshadow -pipe" V=1 check
 
   make-check-macos-x64:
 strategy:
@@ -64,7 +64,7 @@ jobs:
   - name: configure
 run: ./configure --disable-maintainer-mode --disable-openmp
   - name: make
-run: make CFLAGS="-O3 -Wall -Werror -Wshadow -pipe" V=1 check
+run: make CFLAGS="-O3 -Wall -Wshadow -pipe" V=1 check
 
 # until we are able to set token on Github :(
 #  coverity:



[gentoo-commits] proj/portage-utils:master commit in: .github/workflows/

2022-02-06 Thread Fabian Groffen
commit: da7641278eb4633f66ceca9c94c14056dfe5792f
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 12:24:02 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 12:24:02 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=da764127

.github: fix yaml syntax

Signed-off-by: Fabian Groffen  gentoo.org>

 .github/workflows/build-test-ci.yml | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/.github/workflows/build-test-ci.yml 
b/.github/workflows/build-test-ci.yml
index 641a5ec..228a9da 100644
--- a/.github/workflows/build-test-ci.yml
+++ b/.github/workflows/build-test-ci.yml
@@ -37,13 +37,13 @@ jobs:
   - name: install deps
 run: >
   sudo apt-get install -y
-libgpgme-dev gnupg2 liblz4-tool lzop zstd lzip brotli libb2-dev
+  libgpgme-dev gnupg2 liblz4-tool lzop zstd lzip brotli libb2-dev
   - uses: actions/checkout@v2
   - name: configure variant ${{ matrix.features }}
 run: >
   ./configure
---disable-maintainer-mode --disable-openmp
-${{ matrix.features }}
+  --disable-maintainer-mode --disable-openmp
+  ${{ matrix.features }}
   - name: make variant ${{ matrix.features }}
 run: make CFLAGS="-O3 -Wall -Werror -Wshadow -pipe" V=1 check
 
@@ -74,8 +74,8 @@ jobs:
 #  - name: configure
 #run: >
 #  ./configure
-#--disable-maintainer-mode --disable-openmp
-#--enable-qmanifest --enable-qtegrity
+#  --disable-maintainer-mode --disable-openmp
+#  --enable-qmanifest --enable-qtegrity
 #  - uses: vapier/coverity-scan-action@v1
 #with:
 #  email: ${{ secrets.COVERITY_SCAN_EMAIL }}
@@ -87,13 +87,13 @@ jobs:
   - name: install deps
 run: >
   sudo apt-get install -y
-libgpgme-dev gnupg2 liblz4-tool lzop zstd lzip brotli libb2-dev
-valgrind
+  libgpgme-dev gnupg2 liblz4-tool lzop zstd lzip brotli libb2-dev
+  valgrind
   - uses: actions/checkout@v2
   - name: configure
 run: >
   ./configure
---disable-maintainer-mode --disable-openmp
---enable-qmanifest --enable-qtegrity
+  --disable-maintainer-mode --disable-openmp
+  --enable-qmanifest --enable-qtegrity
   - name: make
 run: make CFLAGS="-g -pipe" Q_RUN_WITH_VALGRIND=1 V=1 check



[gentoo-commits] proj/portage-utils:master commit in: .github/workflows/

2022-02-06 Thread Fabian Groffen
commit: 146d1bdf696c23084a7951696a992ef73766e01c
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 12:22:50 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 12:22:50 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=146d1bdf

.github: try libgpgme-dev iso numbered variant

Signed-off-by: Fabian Groffen  gentoo.org>

 .github/workflows/build-test-ci.yml | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/.github/workflows/build-test-ci.yml 
b/.github/workflows/build-test-ci.yml
index 272eff8..641a5ec 100644
--- a/.github/workflows/build-test-ci.yml
+++ b/.github/workflows/build-test-ci.yml
@@ -37,7 +37,7 @@ jobs:
   - name: install deps
 run: >
   sudo apt-get install -y
-libgpgme11-dev gnupg2 liblz4-tool lzop zstd lzip brotli libb2-dev
+libgpgme-dev gnupg2 liblz4-tool lzop zstd lzip brotli libb2-dev
   - uses: actions/checkout@v2
   - name: configure variant ${{ matrix.features }}
 run: >
@@ -87,7 +87,7 @@ jobs:
   - name: install deps
 run: >
   sudo apt-get install -y
-libgpgme11-dev gnupg2 liblz4-tool lzop zstd lzip brotli libb2-dev
+libgpgme-dev gnupg2 liblz4-tool lzop zstd lzip brotli libb2-dev
 valgrind
   - uses: actions/checkout@v2
   - name: configure



[gentoo-commits] proj/portage-utils:master commit in: libq/

2022-02-06 Thread Fabian Groffen
commit: 8468afb97a92adb0c49aaff461bafc7fc0f72992
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 12:21:53 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 12:21:53 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=8468afb9

libq/xsystem: avoid using obsolete vfork()

Signed-off-by: Fabian Groffen  gentoo.org>

 libq/xsystem.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/libq/xsystem.c b/libq/xsystem.c
index e11172e..e2dbc5e 100644
--- a/libq/xsystem.c
+++ b/libq/xsystem.c
@@ -1,8 +1,9 @@
 /*
- * Copyright 2010-2019 Gentoo Foundation
+ * Copyright 2010-2022 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2010-2016 Mike Frysinger  - 
+ * Copyright 2022- Fabian Groffen  - 
  */
 
 #include "main.h"
@@ -24,7 +25,7 @@ void xsystem(const char *command)
 
 void xsystembash(const char *command, int cwd)
 {
-   pid_t p = vfork();
+   pid_t p = fork();
int status;
 
switch (p) {



[gentoo-commits] proj/portage-utils:master commit in: .github/workflows/

2022-02-06 Thread Fabian Groffen
commit: 7f952b13493b2177ca2bc4bc68f9d9ba39c9d40c
Author: Fabian Groffen  gentoo  org>
AuthorDate: Sun Feb  6 12:02:23 2022 +
Commit: Fabian Groffen  gentoo  org>
CommitDate: Sun Feb  6 12:02:23 2022 +
URL:https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=7f952b13

.github: first attempt at build/test automation to replace Travis

The Coverity task is disabled for I don't have access to the Github
project to add the necessary secrets :(

Signed-off-by: Fabian Groffen  gentoo.org>

 .github/workflows/build-test-ci.yml | 99 +
 1 file changed, 99 insertions(+)

diff --git a/.github/workflows/build-test-ci.yml 
b/.github/workflows/build-test-ci.yml
new file mode 100644
index 000..272eff8
--- /dev/null
+++ b/.github/workflows/build-test-ci.yml
@@ -0,0 +1,99 @@
+# GitHub actions workflow.
+# 
https://docs.github.com/en/actions/learn-github-actions/workflow-syntax-for-github-actions
+
+name: Build+Test CI
+
+on:
+  push:
+branches:
+  - master
+tags:
+  - v*
+  pull_request:
+types:
+  - opened
+branches:
+  - master
+
+jobs:
+  make-check-ubuntu-x64:
+strategy:
+  matrix:
+os:
+  - ubuntu-latest
+cc:
+  - gcc
+  - clang
+features:
+  - --enable-qmanifest --enable-qtegrity
+  - --disable-qmanifest --enable-qtegrity
+  - --enable-qmanifest --disable-qtegrity
+  - --disable-qmanifest --disable-qtegrity
+  - ""
+runs-on: ${{ matrix.os }}
+env:
+  CC: ${{ matrix.cc }}
+steps:
+  - name: install deps
+run: >
+  sudo apt-get install -y
+libgpgme11-dev gnupg2 liblz4-tool lzop zstd lzip brotli libb2-dev
+  - uses: actions/checkout@v2
+  - name: configure variant ${{ matrix.features }}
+run: >
+  ./configure
+--disable-maintainer-mode --disable-openmp
+${{ matrix.features }}
+  - name: make variant ${{ matrix.features }}
+run: make CFLAGS="-O3 -Wall -Werror -Wshadow -pipe" V=1 check
+
+  make-check-macos-x64:
+strategy:
+  matrix:
+os:
+  - macos-latest
+cc:
+  - clang
+runs-on: ${{ matrix.os }}
+env:
+  CC: ${{ matrix.cc }}
+steps:
+  - name: install deps
+run: brew install gpgme gnupg gnu-sed coreutils bash openssl
+  - uses: actions/checkout@v2
+  - name: configure
+run: ./configure --disable-maintainer-mode --disable-openmp
+  - name: make
+run: make CFLAGS="-O3 -Wall -Werror -Wshadow -pipe" V=1 check
+
+# until we are able to set token on Github :(
+#  coverity:
+#runs-on: ubuntu-latest
+#steps:
+#  - uses: actions/checkout@v2
+#  - name: configure
+#run: >
+#  ./configure
+#--disable-maintainer-mode --disable-openmp
+#--enable-qmanifest --enable-qtegrity
+#  - uses: vapier/coverity-scan-action@v1
+#with:
+#  email: ${{ secrets.COVERITY_SCAN_EMAIL }}
+#  token: ${{ secrets.COVERITY_SCAN_TOKEN }}
+
+  valgrind:
+runs-on: ubuntu-latest
+steps:
+  - name: install deps
+run: >
+  sudo apt-get install -y
+libgpgme11-dev gnupg2 liblz4-tool lzop zstd lzip brotli libb2-dev
+valgrind
+  - uses: actions/checkout@v2
+  - name: configure
+run: >
+  ./configure
+--disable-maintainer-mode --disable-openmp
+--enable-qmanifest --enable-qtegrity
+  - name: make
+run: make CFLAGS="-g -pipe" Q_RUN_WITH_VALGRIND=1 V=1 check



  1   2   3   4   5   6   7   8   9   10   >