public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] proj/portage-utils:master commit in: man/include/, /, man/
@ 2021-02-20 12:23 Fabian Groffen
  0 siblings, 0 replies; 6+ messages in thread
From: Fabian Groffen @ 2021-02-20 12:23 UTC (permalink / raw
  To: gentoo-commits

commit:     08cdb5f41aa73580067e8668bc02c8e4be431a65
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Sat Feb 20 12:23:26 2021 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Sat Feb 20 12:23:26 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=08cdb5f4

man: regen with new qwhich manpage

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

 applets.h               |  2 +-
 man/include/qwhich.desc | 15 +++++++++++++++
 man/q.1                 |  4 +++-
 man/qatom.1             |  3 ++-
 man/qcheck.1            |  3 ++-
 man/qdepends.1          |  3 ++-
 man/qfile.1             |  3 ++-
 man/qgrep.1             |  3 ++-
 man/qkeyword.1          |  3 ++-
 man/qlist.1             |  3 ++-
 man/qlop.1              |  3 ++-
 man/qmanifest.1         |  3 ++-
 man/qmerge.1            |  3 ++-
 man/qpkg.1              |  3 ++-
 man/qsearch.1           |  3 ++-
 man/qsize.1             |  3 ++-
 man/qtbz2.1             |  3 ++-
 man/qtegrity.1          |  3 ++-
 man/quse.1              |  3 ++-
 man/qwhich.1            | 32 +++++++++++++++++++++++++++++---
 man/qxpak.1             |  5 +++--
 21 files changed, 83 insertions(+), 23 deletions(-)

diff --git a/applets.h b/applets.h
index f37cb63..956ab67 100644
--- a/applets.h
+++ b/applets.h
@@ -91,7 +91,7 @@ static const struct applet_t {
 	{"qtegrity",  qtegrity_main,  "<misc args>",     "verify files with IMA"},
 #endif
 	{"quse",      quse_main,      "<useflag>",       "find pkgs using useflags"},
-	{"qwhich",    qwhich_main,    "<useflag>",       "find path to pkg"},
+	{"qwhich",    qwhich_main,    "<pkg ...>",       "find path to pkg"},
 	{"qxpak",     qxpak_main,     "<misc args>",     "manipulate xpak archives"},
 
 	/* aliases for equery compatibility */

diff --git a/man/include/qwhich.desc b/man/include/qwhich.desc
new file mode 100644
index 0000000..abef4e2
--- /dev/null
+++ b/man/include/qwhich.desc
@@ -0,0 +1,15 @@
+.I qwhich
+returns the paths to the ebuilds matching the given atoms.  Searching is
+done by default over the main ebuild repository and all configured
+overlays.  When requested, a search can be made over the repository of
+installed packages (VDB) or binpkg repos.
+.P
+The default action is to print the full path to the latest ebuild for
+each package.  This can be changed using \fB-d\fR to print the directory
+the ebuild is in instead.  E.g\. one could \fBcd\fR(1) to this
+directory.  Alternatively, one can request to stop searching after the
+first match using \fB-f\fR, which means at most one match per repo is
+returned.
+.P
+\fIqwhich\fR accepts atoms to search for, which can be any valid atom,
+including e.g\. version specifications to narrow the search.

diff --git a/man/q.1 b/man/q.1
index d98c3c3..2979cab 100644
--- a/man/q.1
+++ b/man/q.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH q "1" "Nov 2020" "Gentoo Foundation" "q"
+.TH q "1" "Feb 2021" "Gentoo Foundation" "q"
 .SH NAME
 q \- invoke a portage utility applet
 .SH SYNOPSIS
@@ -75,6 +75,7 @@ Print version and exit.
      qtbz2 <misc args>     : manipulate tbz2 packages
   qtegrity <misc args>     : verify files with IMA
       quse <useflag>       : find pkgs using useflags
+    qwhich <pkg ...>       : find path to pkg
      qxpak <misc args>     : manipulate xpak archives
 .fi
 .SH "REPORTING BUGS"
@@ -104,4 +105,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qatom.1 b/man/qatom.1
index d8c7cd6..99bf67a 100644
--- a/man/qatom.1
+++ b/man/qatom.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qatom "1" "Nov 2020" "Gentoo Foundation" "qatom"
+.TH qatom "1" "Feb 2021" "Gentoo Foundation" "qatom"
 .SH NAME
 qatom \- split atom strings
 .SH SYNOPSIS
@@ -157,4 +157,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qcheck.1 b/man/qcheck.1
index 2473513..2d98408 100644
--- a/man/qcheck.1
+++ b/man/qcheck.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qcheck "1" "Nov 2020" "Gentoo Foundation" "qcheck"
+.TH qcheck "1" "Feb 2021" "Gentoo Foundation" "qcheck"
 .SH NAME
 qcheck \- verify integrity of installed packages
 .SH SYNOPSIS
@@ -81,4 +81,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qdepends.1 b/man/qdepends.1
index 0eb7ba3..0690f16 100644
--- a/man/qdepends.1
+++ b/man/qdepends.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qdepends "1" "Nov 2020" "Gentoo Foundation" "qdepends"
+.TH qdepends "1" "Feb 2021" "Gentoo Foundation" "qdepends"
 .SH NAME
 qdepends \- show dependency info
 .SH SYNOPSIS
@@ -165,4 +165,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qfile.1 b/man/qfile.1
index ffe0968..1f261d4 100644
--- a/man/qfile.1
+++ b/man/qfile.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qfile "1" "Nov 2020" "Gentoo Foundation" "qfile"
+.TH qfile "1" "Feb 2021" "Gentoo Foundation" "qfile"
 .SH NAME
 qfile \- list all pkgs owning files
 .SH SYNOPSIS
@@ -256,4 +256,5 @@ TGL <degrenier[at]easyconnect.fr>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qgrep.1 b/man/qgrep.1
index 70d7eba..196a741 100644
--- a/man/qgrep.1
+++ b/man/qgrep.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qgrep "1" "Nov 2020" "Gentoo Foundation" "qgrep"
+.TH qgrep "1" "Feb 2021" "Gentoo Foundation" "qgrep"
 .SH NAME
 qgrep \- grep in ebuilds
 .SH SYNOPSIS
@@ -105,4 +105,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qkeyword.1 b/man/qkeyword.1
index d18bea6..2c7eaf5 100644
--- a/man/qkeyword.1
+++ b/man/qkeyword.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qkeyword "1" "Nov 2020" "Gentoo Foundation" "qkeyword"
+.TH qkeyword "1" "Feb 2021" "Gentoo Foundation" "qkeyword"
 .SH NAME
 qkeyword \- list packages based on keywords
 .SH SYNOPSIS
@@ -131,4 +131,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qlist.1 b/man/qlist.1
index ed1d784..cfd25be 100644
--- a/man/qlist.1
+++ b/man/qlist.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qlist "1" "Nov 2020" "Gentoo Foundation" "qlist"
+.TH qlist "1" "Feb 2021" "Gentoo Foundation" "qlist"
 .SH NAME
 qlist \- list files owned by pkgname
 .SH SYNOPSIS
@@ -112,4 +112,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qlop.1 b/man/qlop.1
index a175332..7a3f2fe 100644
--- a/man/qlop.1
+++ b/man/qlop.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qlop "1" "Jan 2021" "Gentoo Foundation" "qlop"
+.TH qlop "1" "Feb 2021" "Gentoo Foundation" "qlop"
 .SH NAME
 qlop \- emerge log analyzer
 .SH SYNOPSIS
@@ -174,4 +174,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qmanifest.1 b/man/qmanifest.1
index 21f90c5..2ba3d64 100644
--- a/man/qmanifest.1
+++ b/man/qmanifest.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qmanifest "1" "Nov 2020" "Gentoo Foundation" "qmanifest"
+.TH qmanifest "1" "Feb 2021" "Gentoo Foundation" "qmanifest"
 .SH NAME
 qmanifest \- verify or generate thick Manifest files
 .SH SYNOPSIS
@@ -117,4 +117,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qmerge.1 b/man/qmerge.1
index 0fb67e0..870238b 100644
--- a/man/qmerge.1
+++ b/man/qmerge.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qmerge "1" "Nov 2020" "Gentoo Foundation" "qmerge"
+.TH qmerge "1" "Feb 2021" "Gentoo Foundation" "qmerge"
 .SH NAME
 qmerge \- fetch and merge binary package
 .SH SYNOPSIS
@@ -89,4 +89,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qpkg.1 b/man/qpkg.1
index 29e989d..c5c045c 100644
--- a/man/qpkg.1
+++ b/man/qpkg.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qpkg "1" "Nov 2020" "Gentoo Foundation" "qpkg"
+.TH qpkg "1" "Feb 2021" "Gentoo Foundation" "qpkg"
 .SH NAME
 qpkg \- create or manipulate Gentoo binpkgs
 .SH SYNOPSIS
@@ -69,4 +69,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qsearch.1 b/man/qsearch.1
index c24c17c..f38572c 100644
--- a/man/qsearch.1
+++ b/man/qsearch.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qsearch "1" "Nov 2020" "Gentoo Foundation" "qsearch"
+.TH qsearch "1" "Feb 2021" "Gentoo Foundation" "qsearch"
 .SH NAME
 qsearch \- search pkgname/desc
 .SH SYNOPSIS
@@ -77,4 +77,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qsize.1 b/man/qsize.1
index bcdfcbe..538cade 100644
--- a/man/qsize.1
+++ b/man/qsize.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qsize "1" "Nov 2020" "Gentoo Foundation" "qsize"
+.TH qsize "1" "Feb 2021" "Gentoo Foundation" "qsize"
 .SH NAME
 qsize \- calculate size usage
 .SH SYNOPSIS
@@ -81,4 +81,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qtbz2 (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qtbz2.1 b/man/qtbz2.1
index 1d8d6f7..17c30e9 100644
--- a/man/qtbz2.1
+++ b/man/qtbz2.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qtbz2 "1" "Nov 2020" "Gentoo Foundation" "qtbz2"
+.TH qtbz2 "1" "Feb 2021" "Gentoo Foundation" "qtbz2"
 .SH NAME
 qtbz2 \- manipulate tbz2 packages
 .SH SYNOPSIS
@@ -73,4 +73,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qsize (1),
 .BR qtegrity (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qtegrity.1 b/man/qtegrity.1
index afba135..2b37579 100644
--- a/man/qtegrity.1
+++ b/man/qtegrity.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qtegrity "1" "Nov 2020" "Gentoo Foundation" "qtegrity"
+.TH qtegrity "1" "Feb 2021" "Gentoo Foundation" "qtegrity"
 .SH NAME
 qtegrity \- verify files with IMA
 .SH SYNOPSIS
@@ -79,4 +79,5 @@ Sam Besselink
 .BR qsize (1),
 .BR qtbz2 (1),
 .BR quse (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/quse.1 b/man/quse.1
index 8b1d21b..fe46d83 100644
--- a/man/quse.1
+++ b/man/quse.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH quse "1" "Nov 2020" "Gentoo Foundation" "quse"
+.TH quse "1" "Feb 2021" "Gentoo Foundation" "quse"
 .SH NAME
 quse \- find pkgs using useflags
 .SH SYNOPSIS
@@ -84,4 +84,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qsize (1),
 .BR qtbz2 (1),
 .BR qtegrity (1),
+.BR qwhich (1),
 .BR qxpak (1)

diff --git a/man/qwhich.1 b/man/qwhich.1
index dce52c2..66c30a4 100644
--- a/man/qwhich.1
+++ b/man/qwhich.1
@@ -4,9 +4,23 @@
 qwhich \- find path to pkg
 .SH SYNOPSIS
 .B qwhich
-\fI[opts] <useflag>\fR
+\fI[opts] <pkg ...>\fR
 .SH DESCRIPTION
-
+.I qwhich
+returns the paths to the ebuilds matching the given atoms.  Searching is
+done by default over the main ebuild repository and all configured
+overlays.  When requested, a search can be made over the repository of
+installed packages (VDB) or binpkg repos.
+.P
+The default action is to print the full path to the latest ebuild for
+each package.  This can be changed using \fB-d\fR to print the directory
+the ebuild is in instead.  E.g\. one could \fBcd\fR(1) to this
+directory.  Alternatively, one can request to stop searching after the
+first match using \fB-f\fR, which means at most one match per repo is
+returned.
+.P
+\fIqwhich\fR accepts atoms to search for, which can be any valid atom,
+including e.g\. version specifications to narrow the search.
 .SH OPTIONS
 .TP
 \fB\-I\fR, \fB\-\-vdb\fR
@@ -24,8 +38,20 @@ Print (pretty) atom instead of path for use with -F.
 \fB\-d\fR, \fB\-\-dir\fR
 Print directory instead of path.
 .TP
+\fB\-R\fR, \fB\-\-repo\fR
+Print repository name instead of path for tree/overlay matches.
+.TP
 \fB\-f\fR, \fB\-\-first\fR
-Stop searching after first match.
+Stop searching after first match (implies -l).
+.TP
+\fB\-l\fR, \fB\-\-latest\fR
+Only return latest version for each match.
+.TP
+\fB\-T\fR, \fB\-\-novirtual\fR
+Skip virtual category.
+.TP
+\fB\-A\fR, \fB\-\-noacct\fR
+Skip acct-user and acct-group categories.
 .TP
 \fB\-F\fR \fI<arg>\fR, \fB\-\-format\fR \fI<arg>\fR
 Print matched using given format string.

diff --git a/man/qxpak.1 b/man/qxpak.1
index 5947e70..01902aa 100644
--- a/man/qxpak.1
+++ b/man/qxpak.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qxpak "1" "Nov 2020" "Gentoo Foundation" "qxpak"
+.TH qxpak "1" "Feb 2021" "Gentoo Foundation" "qxpak"
 .SH NAME
 qxpak \- manipulate xpak archives
 .SH SYNOPSIS
@@ -69,4 +69,5 @@ Fabian Groffen <grobian@gentoo.org>
 .BR qsize (1),
 .BR qtbz2 (1),
 .BR qtegrity (1),
-.BR quse (1)
+.BR quse (1),
+.BR qwhich (1)


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: man/include/, /, man/
@ 2019-12-27 16:57 Fabian Groffen
  0 siblings, 0 replies; 6+ messages in thread
From: Fabian Groffen @ 2019-12-27 16:57 UTC (permalink / raw
  To: gentoo-commits

commit:     032bd7e9200d1071b79f3a5d33906020fc805048
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Dec 27 16:55:58 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Dec 27 16:55:58 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=032bd7e9

main: add masks support

Expose masks via q -m, store masks in preparation for applying masks
when listing available ebuilds.

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

 main.c             | 221 +++++++++++++++++++++++++++++++++--------------------
 main.h             |   2 +
 man/include/q.desc |   2 +
 man/q.1            |  13 +++-
 q.c                |  56 +++++++++++++-
 5 files changed, 209 insertions(+), 85 deletions(-)

diff --git a/main.c b/main.c
index 869bf31..b5404cb 100644
--- a/main.c
+++ b/main.c
@@ -22,6 +22,7 @@
 #include "eat_file.h"
 #include "rmspace.h"
 #include "scandirat.h"
+#include "set.h"
 #include "xasprintf.h"
 
 /* variables to control runtime behavior */
@@ -354,10 +355,12 @@ set_portage_env_var(env_vars *var, const char *value, const char *src)
 	}
 }
 
-/* Helper to read a portage env file (e.g. make.conf), or recursively if
- * it points to a directory */
+/* Helper to read a portage file (e.g. make.conf, package.mask), or
+ * recursively if it points to a directory (we don't care about EAPI for
+ * dirs, basically PMS 5.2.5 EAPI restriction is ignored) */
+enum portage_file_type { ENV_FILE, PMASK_FILE };
 static void
-read_portage_env_file(const char *file, env_vars vars[])
+read_portage_file(const char *file, enum portage_file_type type, void *data)
 {
 	FILE *fp;
 	struct dirent **dents;
@@ -368,6 +371,8 @@ read_portage_env_file(const char *file, env_vars vars[])
 	size_t buflen = 0;
 	size_t line;
 	int i;
+	env_vars *vars = data;
+	set *masks = data;
 
 	if (getenv("DEBUG"))
 		fprintf(stderr, "profile %s\n", file);
@@ -384,7 +389,7 @@ read_portage_env_file(const char *file, env_vars vars[])
 					d->d_name[strlen(d->d_name) - 1] == '~')
 				continue;
 			snprintf(npath, sizeof(npath), "%s/%s", file, d->d_name);
-			read_portage_env_file(npath, vars);
+			read_portage_file(npath, type, data);
 		}
 		scandir_free(dents, dentslen);
 		goto done;
@@ -402,84 +407,107 @@ read_portage_env_file(const char *file, env_vars vars[])
 			continue;
 
 		/* Handle "source" keyword */
-		if (strncmp(buf, "source ", 7) == 0) {
-			const char *sfile = buf + 7;
-			char npath[_Q_PATH_MAX * 2];
+		if (type == ENV_FILE) {
+			if (strncmp(buf, "source ", 7) == 0) {
+				const char *sfile = buf + 7;
+				char npath[_Q_PATH_MAX * 2];
 
-			if (sfile[0] != '/') {
-				/* handle relative paths */
-				size_t file_path_len;
+				if (sfile[0] != '/') {
+					/* handle relative paths */
+					size_t file_path_len;
 
-				s = strrchr(file, '/');
-				file_path_len = s - file + 1;
+					s = strrchr(file, '/');
+					file_path_len = s - file + 1;
 
-				snprintf(npath, sizeof(npath), "%.*s/%s",
-						(int)file_path_len, file, sfile);
-				sfile = npath;
-			}
-
-			read_portage_env_file(sfile, vars);
-			continue;
-		}
+					snprintf(npath, sizeof(npath), "%.*s/%s",
+							(int)file_path_len, file, sfile);
+					sfile = npath;
+				}
 
-		/* look for our desired variables and grab their value */
-		for (i = 0; vars[i].name; ++i) {
-			if (buf[vars[i].name_len] != '=' && buf[vars[i].name_len] != ' ')
-				continue;
-			if (strncmp(buf, vars[i].name, vars[i].name_len))
+				read_portage_file(sfile, type, data);
 				continue;
+			}
 
-			/* make sure we handle spaces between the varname, the =,
-			 * and the value:
-			 * VAR=val   VAR = val   VAR="val"
-			 */
-			s = buf + vars[i].name_len;
-			if ((p = strchr(s, '=')) != NULL)
-				s = p + 1;
-			while (isspace(*s))
-				++s;
-			if (*s == '"' || *s == '\'') {
-				char *endq;
-				char q = *s;
-
-				/* make sure we handle spacing/comments after the quote */
-				endq = strchr(s + 1, q);
-				if (!endq) {
-					/* If the last char is not a quote, then we span lines */
-					size_t abuflen;
-					char *abuf;
-
-					abuf = NULL;
-					while (getline(&abuf, &abuflen, fp) != -1) {
-						buf = xrealloc(buf, buflen + abuflen);
-						endq = strchr(abuf, q);
-						if (endq)
-							*endq = '\0';
-
-						strcat(buf, abuf);
-						buflen += abuflen;
-
-						if (endq)
-							break;
-					}
-					free(abuf);
-
-					if (!endq)
-						warn("%s:%zu: %s: quote mismatch",
-								file, line, vars[i].name);
+			/* look for our desired variables and grab their value */
+			for (i = 0; vars[i].name; i++) {
+				if (buf[vars[i].name_len] != '=' &&
+						buf[vars[i].name_len] != ' ')
+					continue;
+				if (strncmp(buf, vars[i].name, vars[i].name_len))
+					continue;
 
-					s = buf + vars[i].name_len + 2;
+				/* make sure we handle spaces between the varname, the =,
+				 * and the value:
+				 * VAR=val   VAR = val   VAR="val"
+				 */
+				s = buf + vars[i].name_len;
+				if ((p = strchr(s, '=')) != NULL)
+					s = p + 1;
+				while (isspace(*s))
+					s++;
+				if (*s == '"' || *s == '\'') {
+					char *endq;
+					char q = *s;
+
+					/* make sure we handle spacing/comments after the quote */
+					endq = strchr(s + 1, q);
+					if (!endq) {
+						/* if the last char is not a quote,
+						 * then we span lines */
+						size_t abuflen;
+						char *abuf;
+
+						abuf = NULL;
+						while (getline(&abuf, &abuflen, fp) != -1) {
+							buf = xrealloc(buf, buflen + abuflen);
+							endq = strchr(abuf, q);
+							if (endq)
+								*endq = '\0';
+
+							strcat(buf, abuf);
+							buflen += abuflen;
+
+							if (endq)
+								break;
+						}
+						free(abuf);
+
+						if (!endq)
+							warn("%s:%zu: %s: quote mismatch",
+									file, line, vars[i].name);
+
+						s = buf + vars[i].name_len + 2;
+					} else {
+						*endq = '\0';
+						s++;
+					}
 				} else {
-					*endq = '\0';
-					++s;
+					/* no quotes, so chop the spacing/comments ourselves */
+					size_t off = strcspn(s, "# \t\n");
+					s[off] = '\0';
 				}
+
+				set_portage_env_var(&vars[i], s, file);
+			}
+		} else if (type == PMASK_FILE) {
+			/* trim leading space */
+			for (s = buf; isspace((int)*s); s++)
+				;
+			if (*s == '\0')
+				continue;
+			if (*s == '-') {
+				/* negation/removal, lookup and drop mask if it exists;
+				 * note that this only supports exact matches (PMS
+				 * 5.2.5) so we don't even have to parse and use
+				 * atom-compare here */
+				s++;
+				if ((p = del_set(s, masks, NULL)) != NULL)
+					free(p);
 			} else {
-				/* no quotes, so chop the spacing/comments ourselves */
-				size_t off = strcspn(s, "# \t\n");
-				s[off] = '\0';
+				p = xstrdup(file);
+				if (add_set_value(s, p, masks) != NULL)
+					free(p);
 			}
-
-			set_portage_env_var(&vars[i], s, file);
 		}
 	}
 
@@ -490,9 +518,10 @@ read_portage_env_file(const char *file, env_vars vars[])
 
 /* Helper to recursively read stacked make.defaults in profiles */
 static void
-read_portage_profile(const char *profile, env_vars vars[])
+read_portage_profile(const char *profile, env_vars vars[], set *masks)
 {
 	char profile_file[_Q_PATH_MAX * 3];
+	char rpath[_Q_PATH_MAX];
 	size_t profile_len;
 	char *s;
 	char *p;
@@ -548,7 +577,9 @@ read_portage_profile(const char *profile, env_vars vars[])
 			snprintf(profile_file + profile_len,
 					sizeof(profile_file) - profile_len, "%s", s);
 		}
-		read_portage_profile(profile_file, vars);
+		read_portage_profile(
+				realpath(profile_file, rpath) == NULL ? profile_file : rpath,
+				vars, masks);
 		/* restore original path in case we were repointed by profile */
 		if (p != NULL)
 			snprintf(profile_file, sizeof(profile_file), "%s/", profile);
@@ -557,9 +588,11 @@ read_portage_profile(const char *profile, env_vars vars[])
 
 	free(buf);
 
-	/* now consume *this* profile's make.defaults */
+	/* now consume *this* profile's make.defaults and package.mask */
 	strcpy(profile_file + profile_len, "make.defaults");
-	read_portage_env_file(profile_file, vars);
+	read_portage_file(profile_file, ENV_FILE, vars);
+	strcpy(profile_file + profile_len, "package.mask");
+	read_portage_file(profile_file, PMASK_FILE, masks);
 }
 
 static bool nocolor = 0;
@@ -598,6 +631,7 @@ env_vars vars_to_read[] = {
 
 #undef _Q_EV
 };
+set *package_masks = NULL;
 
 /* Handle a single file in the repos.conf format. */
 static void
@@ -716,10 +750,11 @@ initialize_portage_env(void)
 	const char *s;
 	env_vars *var;
 	char pathbuf[_Q_PATH_MAX];
+	char rpathbuf[_Q_PATH_MAX];
 	const char *configroot = getenv("PORTAGE_CONFIGROOT");
 	char *primary_overlay = NULL;
 
-	/* initialize all the strings with their default value */
+	/* initialize all the properties with their default value */
 	for (i = 0; vars_to_read[i].name; ++i) {
 		var = &vars_to_read[i];
 		if (var->type != _Q_BOOL)
@@ -727,6 +762,8 @@ initialize_portage_env(void)
 		var->src = xstrdup(STR_DEFAULT);
 	}
 
+	package_masks = create_set();
+
 	/* figure out where to find our config files */
 	if (!configroot)
 		configroot = CONFIG_EPREFIX;
@@ -737,7 +774,7 @@ initialize_portage_env(void)
 		i--;
 
 	/* read overlays first so we can resolve repo references in profile
-	 * parent files */
+	 * parent files (non PMS feature?) */
 	snprintf(pathbuf, sizeof(pathbuf), "%.*s", (int)i, configroot);
 	read_repos_conf(pathbuf, "/usr/share/portage/config/repos.conf",
 			&primary_overlay);
@@ -747,23 +784,41 @@ initialize_portage_env(void)
 	snprintf(pathbuf, sizeof(pathbuf),
 			"%.*s/usr/share/portage/config/make.globals",
 			(int)i, configroot);
-	read_portage_env_file(pathbuf, vars_to_read);
+	read_portage_file(pathbuf, ENV_FILE, vars_to_read);
+
+	/* start with base masks, Portage behaviour PMS 5.2.8 */
+	if (primary_overlay != NULL) {
+		char *overlay;
+		size_t n;
+		array_for_each(overlay_names, n, overlay) {
+			if (overlay == primary_overlay) {
+				snprintf(pathbuf, sizeof(pathbuf), "%s/profiles/package.mask",
+						(char *)array_get_elem(overlays, n));
+				read_portage_file(pathbuf, PMASK_FILE, package_masks);
+				break;
+			}
+		}
+	}
 
 	/* walk all the stacked profiles */
 	snprintf(pathbuf, sizeof(pathbuf), "%.*s/etc/make.profile",
 			(int)i, configroot);
-	read_portage_profile(pathbuf, vars_to_read);
+	read_portage_profile(
+			realpath(pathbuf, rpathbuf) == NULL ? pathbuf : rpathbuf,
+			vars_to_read, package_masks);
 	snprintf(pathbuf, sizeof(pathbuf), "%.*s/etc/portage/make.profile",
 			(int)i, configroot);
-	read_portage_profile(pathbuf, vars_to_read);
+	read_portage_profile(
+			realpath(pathbuf, rpathbuf) == NULL ? pathbuf : rpathbuf,
+			vars_to_read, package_masks);
 
-	/* now read all the config files */
+	/* now read all Portage's config files */
 	snprintf(pathbuf, sizeof(pathbuf), "%.*s/etc/make.conf",
 			(int)i, configroot);
-	read_portage_env_file(pathbuf, vars_to_read);
+	read_portage_file(pathbuf, ENV_FILE, vars_to_read);
 	snprintf(pathbuf, sizeof(pathbuf), "%.*s/etc/portage/make.conf",
 			(int)i, configroot);
-	read_portage_env_file(pathbuf, vars_to_read);
+	read_portage_file(pathbuf, ENV_FILE, vars_to_read);
 
 	/* finally, check the env */
 	for (i = 0; vars_to_read[i].name; i++) {

diff --git a/main.h b/main.h
index 98e5cbb..68b9795 100644
--- a/main.h
+++ b/main.h
@@ -24,6 +24,7 @@
 
 #include "colors.h"
 #include "i18n.h"
+#include "set.h"
 
 extern const char *argv0;
 
@@ -152,5 +153,6 @@ typedef struct {
 	char *src;
 } env_vars;
 extern env_vars vars_to_read[];
+extern set *package_masks;
 
 #endif

diff --git a/man/include/q.desc b/man/include/q.desc
index 7109c46..7d38ba2 100644
--- a/man/include/q.desc
+++ b/man/include/q.desc
@@ -6,3 +6,5 @@ After version 0.74 of portage-utils, the cache functionality was removed
 in favour of using various trees directly, and optionally the caches
 therein.  As such the \fB-r\fR and \fB-m\fR options were removed.  It is
 no longer necessary to initialise the cache at any time.
+.P
+After version 0.82, the \fB-m\fR flag got repurposed for listing masks.

diff --git a/man/q.1 b/man/q.1
index 886b00f..21a09b3 100644
--- a/man/q.1
+++ b/man/q.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH q "1" "Nov 2019" "Gentoo Foundation" "q"
+.TH q "1" "Dec 2019" "Gentoo Foundation" "q"
 .SH NAME
 q \- invoke a portage utility applet
 .SH SYNOPSIS
@@ -14,6 +14,8 @@ After version 0.74 of portage-utils, the cache functionality was removed
 in favour of using various trees directly, and optionally the caches
 therein.  As such the \fB-r\fR and \fB-m\fR options were removed.  It is
 no longer necessary to initialise the cache at any time.
+.P
+After version 0.82, the \fB-m\fR flag got repurposed for listing masks.
 .SH OPTIONS
 .TP
 \fB\-i\fR, \fB\-\-install\fR
@@ -26,6 +28,15 @@ see the source (file) where the overlay was declared.
 \fB\-e\fR, \fB\-\-envvar\fR
 Print used environment variables and found values.  Use \fI-v\fR to
 see the source (file, environment) where the variable was declared.
+Additional arguments are treated as variable names to print the
+values for.  If just one name is given, only the value is printed if
+matched.  When no arguments or more than one argument is given, the
+variable name and the value is printed as a shell-style declaration.
+.TP
+\fB\-m\fR, \fB\-\-masks\fR
+Print the masks from package.mask files found.  Use \fI-v\fR to see
+the source (file) where the mask was declared.  Additional arguments
+are treated as atom selectors which must match the masks.
 .TP
 \fB\-\-root\fR \fI<arg>\fR
 Set the ROOT env var.

diff --git a/q.c b/q.c
index f137b04..4a2fd62 100644
--- a/q.c
+++ b/q.c
@@ -19,21 +19,24 @@
 #include <libproc.h>
 #endif
 
+#include "atom.h"
 #include "basename.h"
 #include "eat_file.h"
 #include "rmspace.h"
 
-#define Q_FLAGS "ioe" COMMON_FLAGS
+#define Q_FLAGS "ioem" COMMON_FLAGS
 static struct option const q_long_opts[] = {
 	{"install",       no_argument, NULL, 'i'},
 	{"overlays",      no_argument, NULL, 'o'},
 	{"envvar",        no_argument, NULL, 'e'},
+	{"masks",         no_argument, NULL, 'm'},
 	COMMON_LONG_OPTS
 };
 static const char * const q_opts_help[] = {
 	"Install symlinks for applets",
 	"Print available overlays (read from repos.conf)",
 	"Print used variables and their found values",
+	"Print (package.)masks for the current profile",
 	COMMON_OPTS_HELP
 };
 #define q_usage(ret) usage(ret, Q_FLAGS, q_long_opts, q_opts_help, NULL, lookup_applet_idx("q"))
@@ -81,6 +84,7 @@ int q_main(int argc, char **argv)
 	bool install;
 	bool print_overlays;
 	bool print_vars;
+	bool print_masks;
 	const char *p;
 	APPLET func;
 
@@ -100,12 +104,14 @@ int q_main(int argc, char **argv)
 	install = false;
 	print_overlays = false;
 	print_vars = false;
+	print_masks = false;
 	while ((i = GETOPT_LONG(Q, q, "+")) != -1) {
 		switch (i) {
 		COMMON_GETOPTS_CASES(q)
 		case 'i': install = true;        break;
 		case 'o': print_overlays = true; break;
 		case 'e': print_vars = true;     break;
+		case 'm': print_masks = true;    break;
 		}
 	}
 
@@ -258,6 +264,54 @@ int q_main(int argc, char **argv)
 		return 0;
 	}
 
+	if (print_masks) {
+		DECLARE_ARRAY(masks);
+		DECLARE_ARRAY(files);
+		char *mask;
+		size_t n;
+		int j;
+		bool match;
+		depend_atom *atom;
+		depend_atom *qatom;
+
+		array_set(package_masks, masks);
+		values_set(package_masks, files);
+
+		array_for_each(masks, n, mask) {
+			if ((atom = atom_explode(mask)) == NULL)
+				continue;
+
+			match = true;
+			if (argc > optind) {
+				match = false;
+				for (j = optind; j < argc; j++) {
+					qatom = atom_explode(argv[j]);
+					if (qatom != NULL && atom_compare(atom, qatom) == EQUAL)
+						match = true;
+					atom_implode(qatom);
+					if (match)
+						break;
+				}
+			}
+			if (!match)
+				continue;
+
+			printf("%s", atom_format(
+						"%[pfx]%[CAT]%[PF]%[SLOT]%[SUBSLOT]%[sfx]%[USE]%[REPO]",
+						atom));
+			if (verbose)
+				printf(" [%s]\n", (char *)array_get_elem(files, n));
+			else
+				printf("\n");
+			atom_implode(atom);
+		}
+
+		xarrayfree_int(masks);
+		xarrayfree_int(files);
+
+		return 0;
+	}
+
 	if (argc == optind)
 		q_usage(EXIT_FAILURE);
 	if ((func = lookup_applet(argv[optind])) == NULL)


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

commit:     057ffaead77a168f14861b0cce51c69332ab4ae1
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Wed Jun 19 07:30:44 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Wed Jun 19 07:30:44 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=057ffaea

qdepends: make -qq with -Q just print list of packages

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

 man/include/qdepends-05-examples.include | 17 +++++++++++++++++
 man/include/qdepends.optdesc.yaml        |  3 ++-
 man/qdepends.1                           | 19 ++++++++++++++++++-
 qdepends.c                               |  6 ++++--
 4 files changed, 41 insertions(+), 4 deletions(-)

diff --git a/man/include/qdepends-05-examples.include b/man/include/qdepends-05-examples.include
index d3eac01..98ceb3a 100644
--- a/man/include/qdepends-05-examples.include
+++ b/man/include/qdepends-05-examples.include
@@ -17,3 +17,20 @@ can quickly see what specific dependency is expressed here.  If
 the above had used \fI<logrotate-3\fR, for example, no matches would be
 returned.  Not using any specifiers allows to reveal in what way a
 dependency is expressed.
+.P
+Producing a list of packages that need rebuilding after a Perl upgrade:
+.nf
+	$ \fIqdepends -Qqq -F '%[CATEGORY]%[PN]%[SLOT]' ^perl:0/5.30\fR
+	dev-vcs/git:0
+	perl-core/File-Temp:0
+	dev-perl/Text-CSV_XS:0
+	...
+.fi
+With the double \fB-q\fR flag, just the matching packages are returned,
+allowing to use the list for instance as arguments to \fBemerge\fR(1).
+The custom formatter in this case ensures all selected packages will be
+the best matching for the currently installed SLOT.  Finally, the use of
+the antislot matching (\fI^\fR) is returning all packages that depend on
+perl in SLOT \fB0\fR, but in a different SUBSLOT than \fB5.30\fR,
+effectively requesting the list of packages that need rebuilding to use
+the newly installed version of Perl.

diff --git a/man/include/qdepends.optdesc.yaml b/man/include/qdepends.optdesc.yaml
index dc4ce91..f49461c 100644
--- a/man/include/qdepends.optdesc.yaml
+++ b/man/include/qdepends.optdesc.yaml
@@ -32,4 +32,5 @@ verbose: |
     matches.  When used with \fB-t\fR, the atom highlighting matches
     what is used by the installed package, if available.
 quiet: Suppress DEPEND= output for \fB\-f\fR.  Only print the matching
-    atom for \fB\-Q\fR.
+    atom for \fB\-Q\fR.  When given two or more times, suppresses the
+    matching atom for \fB\-Q\fR, e.g.\ producing just a list of packages.

diff --git a/man/qdepends.1 b/man/qdepends.1
index d7c8957..7898e3d 100644
--- a/man/qdepends.1
+++ b/man/qdepends.1
@@ -92,7 +92,7 @@ matches.  When used with \fB-t\fR, the atom highlighting matches
 what is used by the installed package, if available.
 .TP
 \fB\-q\fR, \fB\-\-quiet\fR
-Suppress DEPEND= output for \fB\-f\fR.  Only print the matching atom for \fB\-Q\fR.
+Suppress DEPEND= output for \fB\-f\fR.  Only print the matching atom for \fB\-Q\fR.  When given two or more times, suppresses the matching atom for \fB\-Q\fR, e.g.\ producing just a list of packages.
 .TP
 \fB\-C\fR, \fB\-\-nocolor\fR
 Don't output color.
@@ -121,6 +121,23 @@ can quickly see what specific dependency is expressed here.  If
 the above had used \fI<logrotate-3\fR, for example, no matches would be
 returned.  Not using any specifiers allows to reveal in what way a
 dependency is expressed.
+.P
+Producing a list of packages that need rebuilding after a Perl upgrade:
+.nf
+	$ \fIqdepends -Qqq -F '%[CATEGORY]%[PN]%[SLOT]' ^perl:0/5.30\fR
+	dev-vcs/git:0
+	perl-core/File-Temp:0
+	dev-perl/Text-CSV_XS:0
+	...
+.fi
+With the double \fB-q\fR flag, just the matching packages are returned,
+allowing to use the list for instance as arguments to \fBemerge\fR(1).
+The custom formatter in this case ensures all selected packages will be
+the best matching for the currently installed SLOT.  Finally, the use of
+the antislot matching (\fI^\fR) is returning all packages that depend on
+perl in SLOT \fB0\fR, but in a different SUBSLOT than \fB5.30\fR,
+effectively requesting the list of packages that need rebuilding to use
+the newly installed version of Perl.
 .SH "REPORTING BUGS"
 Please report bugs via http://bugs.gentoo.org/
 .br

diff --git a/qdepends.c b/qdepends.c
index f5aa5a5..b5e8993 100644
--- a/qdepends.c
+++ b/qdepends.c
@@ -251,13 +251,15 @@ qdepends_results_cb(tree_pkg_ctx *pkg_ctx, void *priv)
 
 						if (!firstmatch) {
 							datom = tree_get_atom(pkg_ctx, true);
-							printf("%s:", atom_format(state->format, datom));
+							printf("%s%s", atom_format(state->format, datom),
+									quiet < 2 ? ":" : "");
 						}
 						firstmatch = true;
 
 						snprintf(buf, sizeof(buf), "%s%s%s",
 								RED, atom_to_string(atom), NORM);
-						add_set_unique(buf, state->udeps, NULL);
+						if (quiet < 2)
+							add_set_unique(buf, state->udeps, NULL);
 					} else if (!quiet) {
 						add_set_unique(atom_to_string(atom),
 								state->udeps, NULL);


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: man/include/, /, man/
@ 2019-04-12 18:50 Fabian Groffen
  0 siblings, 0 replies; 6+ messages in thread
From: Fabian Groffen @ 2019-04-12 18:50 UTC (permalink / raw
  To: gentoo-commits

commit:     26397171ecf098661502d86f9c6cde45ec70d180
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Fri Apr 12 18:48:17 2019 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Fri Apr 12 18:48:17 2019 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=26397171

qlist: change behaviour to use colours and no parenthesis

- in list mode, show colours by default (can be disabled in the
  normal way using -C)
- in USE-flag mode, don't output ( ) so the output is compatible with
  e.g. package.use

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

 man/include/qlist.optdesc.yaml |  9 +++------
 man/qlist.1                    | 11 +++++------
 qlist.c                        | 31 ++++++++++++++++---------------
 3 files changed, 24 insertions(+), 27 deletions(-)

diff --git a/man/include/qlist.optdesc.yaml b/man/include/qlist.optdesc.yaml
index 2b9299c..5fff904 100644
--- a/man/include/qlist.optdesc.yaml
+++ b/man/include/qlist.optdesc.yaml
@@ -16,9 +16,6 @@ columns: |
     space-separated columns.
 verbose: |
     When used with \fB\-I\fR, print the package version next to name.
-    When listing the package contents, a single \fB\-v\fR displays
-    symlinks with an arrow (\->) to their target.  Two or more \fB\-v\fR
-    adds colour to the entries and prints like \fB\-I\fR before the
-    listing.  Shows disabled USE-flags when used with \fB\-U\fR.
-quiet: |
-    Suppresses the parenthesis around the USE-flags when used with \fB\-U\fR.
+    When listing the package contents, \fB\-v\fR displays symlinks with
+    an arrow (\->) to their target.  Shows disabled USE-flags when used
+    with \fB\-U\fR.

diff --git a/man/qlist.1 b/man/qlist.1
index 4df7dab..0b16318 100644
--- a/man/qlist.1
+++ b/man/qlist.1
@@ -1,5 +1,5 @@
 .\" generated by mkman.py, please do NOT edit!
-.TH qlist "1" "Mar 2019" "Gentoo Foundation" "qlist"
+.TH qlist "1" "Apr 2019" "Gentoo Foundation" "qlist"
 .SH NAME
 qlist \- list files owned by pkgname
 .SH SYNOPSIS
@@ -57,13 +57,12 @@ Set the ROOT env var.
 .TP
 \fB\-v\fR, \fB\-\-verbose\fR
 When used with \fB\-I\fR, print the package version next to name.
-When listing the package contents, a single \fB\-v\fR displays
-symlinks with an arrow (\->) to their target.  Two or more \fB\-v\fR
-adds colour to the entries and prints like \fB\-I\fR before the
-listing.  Shows disabled USE-flags when used with \fB\-U\fR.
+When listing the package contents, \fB\-v\fR displays symlinks with
+an arrow (\->) to their target.  Shows disabled USE-flags when used
+with \fB\-U\fR.
 .TP
 \fB\-q\fR, \fB\-\-quiet\fR
-Suppresses the parenthesis around the USE-flags when used with \fB\-U\fR.
+Tighter output; suppress warnings.
 .TP
 \fB\-C\fR, \fB\-\-nocolor\fR
 Don't output color.

diff --git a/qlist.c b/qlist.c
index d46e0a6..313ff56 100644
--- a/qlist.c
+++ b/qlist.c
@@ -88,11 +88,11 @@ cmpstringp(const void *p1, const void *p2)
  * -redis -sasl (-selinux) -sqlite -srs -syslog" 0 KiB
  *
  * % qlist -IUv exim
- * mail-mta/exim-4.92 (-arc -dane -dcc dkim -dlfunc dmarc dnsdb -doc
+ * mail-mta/exim-4.92 -arc -dane -dcc dkim -dlfunc dmarc dnsdb -doc
  * -dovecot-sasl -dsn exiscan-acl -gnutls -idn ipv6 -ldap -libressl lmtp
  * maildir -mbx -mysql -nis pam -perl -pkcs11 -postgres prdr -proxy
  * -radius -redis -sasl -selinux spf -sqlite -srs ssl -syslog tcpd tpda
- * -X)
+ * -X
  */
 static char _umapstr_buf[BUFSIZ];
 static const char *
@@ -134,8 +134,7 @@ umapstr(char display, q_vdb_pkg_ctx *pkg_ctx)
 
 #define add_to_buf(fmt, Cb, use, Ce) \
 	bufp += snprintf(bufp, sizeof(_umapstr_buf) - (bufp - _umapstr_buf), \
-			" %s%s" fmt "%s", \
-			bufp == _umapstr_buf && !quiet ? "(" : "", Cb, use, Ce);
+			" %s" fmt "%s", Cb, use, Ce);
 
 	/* merge join, ensure inputs are sorted (Portage does this, but just
 	 * to be sure) */
@@ -163,9 +162,6 @@ umapstr(char display, q_vdb_pkg_ctx *pkg_ctx)
 		}
 	}
 
-	bufp += snprintf(bufp, sizeof(_umapstr_buf) - (bufp - _umapstr_buf),
-			"%s", bufp == _umapstr_buf || quiet ? "" : ")");
-
 	freeargv(iuse_argc, iuse_argv);
 	freeargv(use_argc, use_argv);
 	free(iuse);
@@ -352,7 +348,8 @@ qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 
 	/* see if this cat/pkg is requested */
 	for (i = optind; i < state->argc; ++i)
-		if (qlist_match(pkg_ctx, state->argv[i], &state->atoms[i - optind], state->exact))
+		if (qlist_match(pkg_ctx, state->argv[i],
+					&state->atoms[i - optind], state->exact))
 			break;
 	if ((i == state->argc) && (state->argc != optind))
 		return 0;
@@ -362,7 +359,8 @@ qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 		atom = (verbose ? NULL : atom_explode(pkgname));
 		if ((state->all + state->just_pkgname) < 2) {
 			if (state->show_slots && !pkg_ctx->slot) {
-				q_vdb_pkg_eat(pkg_ctx, "SLOT", &pkg_ctx->slot, &pkg_ctx->slot_len);
+				q_vdb_pkg_eat(pkg_ctx, "SLOT",
+						&pkg_ctx->slot, &pkg_ctx->slot_len);
 				/* chop off the subslot if desired */
 				if (state->show_slots == 1) {
 					char *s = strchr(pkg_ctx->slot, '/');
@@ -396,8 +394,9 @@ qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 			return 1;
 	}
 
-	if (verbose > 1)
-		printf("%s%s/%s%s%s\n%sCONTENTS%s:\n", BOLD, catname, BLUE, pkgname, NORM, DKBLUE, NORM);
+	if (verbose)
+		printf("%s%s/%s%s%s %sCONTENTS%s:\n",
+				BOLD, catname, BLUE, pkgname, NORM, DKBLUE, NORM);
 
 	fp = q_vdb_pkg_fopenat_ro(pkg_ctx, "CONTENTS");
 	if (fp == NULL)
@@ -420,18 +419,20 @@ qlist_cb(q_vdb_pkg_ctx *pkg_ctx, void *priv)
 		switch (e->type) {
 			case CONTENTS_DIR:
 				if (state->show_dir)
-					printf("%s%s%s/\n", verbose > 1 ? YELLOW : "" , e->name, verbose > 1 ? NORM : "");
+					printf("%s%s%s/\n", YELLOW, e->name, NORM);
 				break;
 			case CONTENTS_OBJ:
 				if (state->show_obj)
-					printf("%s%s%s\n", verbose > 1 ? WHITE : "" , e->name, verbose > 1 ? NORM : "");
+					printf("%s%s%s\n", WHITE, e->name, NORM);
 				break;
 			case CONTENTS_SYM:
 				if (state->show_sym) {
 					if (verbose)
-						printf("%s%s -> %s%s\n", verbose > 1 ? CYAN : "", e->name, e->sym_target, NORM);
+						printf("%s%s%s -> %s%s%s\n",
+								CYAN, e->name, NORM,
+								CYAN, e->sym_target, NORM);
 					else
-						printf("%s\n", e->name);
+						printf("%s%s%s\n", CYAN, e->name, NORM);
 				}
 				break;
 		}


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

commit:     b5cc7d87b7adf46c2444c68537d8fcfb73ae0060
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Thu Apr 12 19:32:37 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Thu Apr 12 19:32:37 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=b5cc7d87

qlop: accept "today" and "yesterday" for parse_date

Bug: https://bugs.gentoo.org/652312

 man/include/qlop.optdesc.yaml |  4 ++++
 man/qlop.1                    |  4 ++++
 qlop.c                        | 13 +++++++++++--
 3 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/man/include/qlop.optdesc.yaml b/man/include/qlop.optdesc.yaml
index fad1670..3ff62c3 100644
--- a/man/include/qlop.optdesc.yaml
+++ b/man/include/qlop.optdesc.yaml
@@ -6,6 +6,10 @@ date: |
     .IP "NUMBER <day|week|month|year>[s] [ago]"
     Relative time, specifying \fINUMBER\fR \fIdays\fR, \fIweeks\fR,
     \fImonths\fR or \fIyears\fR, for example \fI3 days ago\fR.
+    .IP today
+    Alias for \fI0 days ago\fR.
+    .IP yesterday
+    Alias for \fI1 day ago\fR.
     .IP YYYY-MM-DD
     Big-endian date, with components separated by hyphens, starting with
     year, followed by month and day of month.

diff --git a/man/qlop.1 b/man/qlop.1
index 9c449a9..18c05fb 100644
--- a/man/qlop.1
+++ b/man/qlop.1
@@ -46,6 +46,10 @@ can take a few forms.
 .IP "NUMBER <day|week|month|year>[s] [ago]"
 Relative time, specifying \fINUMBER\fR \fIdays\fR, \fIweeks\fR,
 \fImonths\fR or \fIyears\fR, for example \fI3 days ago\fR.
+.IP today
+Alias for \fI0 days ago\fR.
+.IP yesterday
+Alias for \fI1 day ago\fR.
 .IP YYYY-MM-DD
 Big-endian date, with components separated by hyphens, starting with
 year, followed by month and day of month.

diff --git a/qlop.c b/qlop.c
index 1d4e0d9..7bac8c2 100644
--- a/qlop.c
+++ b/qlop.c
@@ -758,8 +758,17 @@ parse_date(const char *sdate, time_t *t)
 			char ago[len];
 			int ret = sscanf(sdate, "%lu %s %s", &num, dur, ago);
 
-			if (ret < 2)
-				return false;
+			if (ret < 2) {
+				if (strcmp(sdate, "today") == 0) {
+					num = 0;
+					snprintf(dur, len, "%s", "day");
+				} else if (strcmp(sdate, "yesterday") == 0) {
+					num = 1;
+					snprintf(dur, len, "%s", "day");
+				} else {
+					return false;
+				}
+			}
 			if (ret == 3 && strcmp(ago, "ago") != 0)
 				return false;
 


^ permalink raw reply related	[flat|nested] 6+ messages in thread
* [gentoo-commits] proj/portage-utils:master commit in: man/include/, /, man/
@ 2018-04-03 15:21 Fabian Groffen
  0 siblings, 0 replies; 6+ messages in thread
From: Fabian Groffen @ 2018-04-03 15:21 UTC (permalink / raw
  To: gentoo-commits

commit:     454020200171d3d921b0f7e2229d4e527e1e6b2a
Author:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
AuthorDate: Tue Apr  3 15:19:43 2018 +0000
Commit:     Fabian Groffen <grobian <AT> gentoo <DOT> org>
CommitDate: Tue Apr  3 15:19:43 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage-utils.git/commit/?id=45402020

quse: improve documentation

Bug: https://bugs.gentoo.org/645554

 man/include/quse.desc         |  2 ++
 man/include/quse.optdesc.yaml | 11 +++++++++++
 man/quse.1                    | 40 ++++++++++++++++++++++++----------------
 quse.c                        |  4 ++--
 4 files changed, 39 insertions(+), 18 deletions(-)

diff --git a/man/include/quse.desc b/man/include/quse.desc
new file mode 100644
index 0000000..7492774
--- /dev/null
+++ b/man/include/quse.desc
@@ -0,0 +1,2 @@
+\fIquse\fR searches in ebuilds for a match in IUSE, KEYWORDS or LICENSE.
+It can also search for USE-flags and show their descriptions.

diff --git a/man/include/quse.optdesc.yaml b/man/include/quse.optdesc.yaml
new file mode 100644
index 0000000..2a3675d
--- /dev/null
+++ b/man/include/quse.optdesc.yaml
@@ -0,0 +1,11 @@
+exact: Search for exact string, e.g.\ do not use regular expression matching.
+format: |
+    Advanced option to manually override the variable searched for in
+    ebuilds.  By default, the search is \fIIUSE=\fR, the \fB\-K\fR and
+    \fB\-L\fR override that to \fIKEYWORDS=\fR and \fILICENSE=\fR
+    respectively.  This option, sets the search to any variable.  Note
+    that the equals sign is part of the search, and needs to be set.
+verbose: |
+    Show problems encountered during parsing.  These are mostly
+    diagnostic and indicate possible incorrectness in the results.
+quiet: Ignored for compatibility with other qapplets.

diff --git a/man/quse.1 b/man/quse.1
index e1e6db9..9b632b7 100644
--- a/man/quse.1
+++ b/man/quse.1
@@ -1,56 +1,64 @@
-.TH quse "1" "Mar 2016" "Gentoo Foundation" "quse"
+.\" generated by mkman.py, please do NOT edit!
+.TH quse "1" "Apr 2018" "Gentoo Foundation" "quse"
 .SH NAME
 quse \- find pkgs using useflags
 .SH SYNOPSIS
 .B quse
 \fI[opts] <useflag>\fR
 .SH DESCRIPTION
-
+\fIquse\fR searches in ebuilds for a match in IUSE, KEYWORDS or LICENSE.
+It can also search for USE-flags and show their descriptions.
 .SH OPTIONS
 .TP
 \fB\-e\fR, \fB\-\-exact\fR
-Show exact non regexp matching using strcmp
+Search for exact string, e.g.\ do not use regular expression matching.
 .TP
 \fB\-a\fR, \fB\-\-all\fR
-Show annoying things in IUSE
+List all ebuilds, don't match anything.
 .TP
 \fB\-K\fR, \fB\-\-keywords\fR
-Use the KEYWORDS vs IUSE
+Use the KEYWORDS vs IUSE.
 .TP
 \fB\-L\fR, \fB\-\-license\fR
-Use the LICENSE vs IUSE
+Use the LICENSE vs IUSE.
 .TP
 \fB\-D\fR, \fB\-\-describe\fR
-Describe the USE flag
+Describe the USE flag.
 .TP
 \fB\-F\fR \fI<arg>\fR, \fB\-\-format\fR \fI<arg>\fR
-Use your own variable formats. -F NAME=
+Advanced option to manually override the variable searched for in
+ebuilds.  By default, the search is \fIIUSE=\fR, the \fB\-K\fR and
+\fB\-L\fR override that to \fIKEYWORDS=\fR and \fILICENSE=\fR
+respectively.  This option, sets the search to any variable.  Note
+that the equals sign is part of the search, and needs to be set.
 .TP
 \fB\-N\fR, \fB\-\-name\-only\fR
-Only show package name
+Only show package name.
 .TP
 \fB\-\-root\fR \fI<arg>\fR
-Set the ROOT env var
+Set the ROOT env var.
 .TP
 \fB\-v\fR, \fB\-\-verbose\fR
-Make a lot of noise
+Show problems encountered during parsing.  These are mostly
+diagnostic and indicate possible incorrectness in the results.
 .TP
 \fB\-q\fR, \fB\-\-quiet\fR
-Tighter output; suppress warnings
+Ignored for compatibility with other qapplets.
 .TP
 \fB\-C\fR, \fB\-\-nocolor\fR
-Don't output color
+Don't output color.
 .TP
 \fB\-h\fR, \fB\-\-help\fR
-Print this help and exit
+Print this help and exit.
 .TP
 \fB\-V\fR, \fB\-\-version\fR
-Print version and exit
+Print version and exit.
 
 .SH "REPORTING BUGS"
 Please report bugs via http://bugs.gentoo.org/
 .br
-Product: Portage Development; Component: Tools
+Product: Portage Development; Component: Tools, Assignee:
+portage-utils@gentoo.org
 .SH AUTHORS
 .nf
 Ned Ludd <solar@gentoo.org>

diff --git a/quse.c b/quse.c
index ea8a326..05ba2f4 100644
--- a/quse.c
+++ b/quse.c
@@ -1,5 +1,5 @@
 /*
- * Copyright 2005-2014 Gentoo Foundation
+ * Copyright 2005-2018 Gentoo Foundation
  * Distributed under the terms of the GNU General Public License v2
  *
  * Copyright 2005-2010 Ned Ludd        - <solar@gentoo.org>
@@ -26,7 +26,7 @@ static struct option const quse_long_opts[] = {
 };
 static const char * const quse_opts_help[] = {
 	"Show exact non regexp matching using strcmp",
-	"Show annoying things in IUSE",
+	"List all ebuilds, don't match anything",
 	"Use the KEYWORDS vs IUSE",
 	"Use the LICENSE vs IUSE",
 	"Describe the USE flag",


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-02-20 12:23 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-02-20 12:23 [gentoo-commits] proj/portage-utils:master commit in: man/include/, /, man/ Fabian Groffen
  -- strict thread matches above, loose matches on Subject: below --
2019-12-27 16:57 Fabian Groffen
2019-06-19  7:31 Fabian Groffen
2019-04-12 18:50 Fabian Groffen
2018-04-12 19:33 Fabian Groffen
2018-04-03 15:21 Fabian Groffen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox