* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/
@ 2025-01-15 20:02 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2025-01-15 20:02 UTC (permalink / raw
To: gentoo-commits
commit: c4598e95a81b98bba9373b5f91ff53bcac304efa
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 15 19:59:58 2025 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed Jan 15 19:59:58 2025 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=c4598e95
patom: support input from stdin when "-" is passed as an argument
Resolves: https://github.com/pkgcore/pkgcore/issues/226
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/scripts/patom.py | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/src/pkgcore/scripts/patom.py b/src/pkgcore/scripts/patom.py
index ac7a2ef2..113bd853 100644
--- a/src/pkgcore/scripts/patom.py
+++ b/src/pkgcore/scripts/patom.py
@@ -1,6 +1,7 @@
"""atom parsing utility"""
import re
+import sys
from functools import partial
from ..ebuild.atom import atom as atom_cls
@@ -90,6 +91,14 @@ def _transform_format(atom: atom_cls, match: re.Match):
def main(options, out, err):
if options.format:
fmt, *atoms = options.format
+
+ if "-" in atoms:
+ atoms = [atom for atom in atoms if atom != "-"]
+ if not sys.stdin.isatty():
+ atoms += [x.strip() for x in sys.stdin.readlines()]
+ else:
+ argparser.error("reading from stdin is only valid when piping data in")
+
VAR_REGEX = re.compile(r"%\[.+?\]|%\{.+?\}")
for value in atoms:
try:
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/
@ 2025-01-20 17:17 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2025-01-20 17:17 UTC (permalink / raw
To: gentoo-commits
commit: 8eaae2bcf639d58ed1c6864ae83ab5ef7f3bd8db
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Jan 20 17:17:18 2025 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Jan 20 17:17:18 2025 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=8eaae2bc
pquery: fix docs for --one-attr
Reported-by: Eli Schwartz <eschwartz <AT> gentoo.org>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/scripts/pquery.py | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/src/pkgcore/scripts/pquery.py b/src/pkgcore/scripts/pquery.py
index bae4ca36..46311121 100644
--- a/src/pkgcore/scripts/pquery.py
+++ b/src/pkgcore/scripts/pquery.py
@@ -1136,8 +1136,7 @@ one_attr_mux.add_argument(
help="print one attribute, suppresses other output",
docs=f"""
Print the given attribute's value, while suppressing all other output.
- This option can be specified multiple times. All attributes of ``--attr``
- are accepted.
+ All attributes of ``--attr`` are accepted.
""",
)
one_attr_mux.add_argument(
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/
@ 2025-01-18 17:21 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2025-01-18 17:21 UTC (permalink / raw
To: gentoo-commits
commit: 288b3b03f7c53777d6e08d5dec29c91cddd91d77
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Jan 18 17:18:07 2025 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Jan 18 17:18:07 2025 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=288b3b03
pquery: improve documentation of `--attr`
Resolves: https://github.com/pkgcore/pkgcore/issues/423
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/scripts/pquery.py | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/src/pkgcore/scripts/pquery.py b/src/pkgcore/scripts/pquery.py
index ea20c2eb..bae4ca36 100644
--- a/src/pkgcore/scripts/pquery.py
+++ b/src/pkgcore/scripts/pquery.py
@@ -1116,7 +1116,7 @@ output.add_argument(
Print the given attribute's value. This option can be specified
multiple times.
- Valid attributes: {', '.join(printable_attrs)}
+ Valid attributes: {', '.join(f'``{x}``' for x in printable_attrs)}
""",
)
output.add_argument(
@@ -1125,9 +1125,8 @@ output.add_argument(
dest="attr",
metavar="attribute",
default=[],
- help="like --attr but accepts any string as "
- "attribute name instead of only explicitly "
- "supported names",
+ help="""Like --attr but accepts any string as attribute name instead
+ of only explicitly supported names.""",
)
one_attr_mux = output.add_mutually_exclusive_group()
one_attr_mux.add_argument(
@@ -1135,6 +1134,11 @@ one_attr_mux.add_argument(
choices=printable_attrs,
metavar="attribute",
help="print one attribute, suppresses other output",
+ docs=f"""
+ Print the given attribute's value, while suppressing all other output.
+ This option can be specified multiple times. All attributes of ``--attr``
+ are accepted.
+ """,
)
one_attr_mux.add_argument(
"--force-one-attr",
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/
@ 2025-01-15 20:02 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2025-01-15 20:02 UTC (permalink / raw
To: gentoo-commits
commit: 6a98a8395bf825870fcb0514c61e8b26b97d2fe1
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Wed Jan 15 20:01:56 2025 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Wed Jan 15 20:01:56 2025 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=6a98a839
pquery: support input from stdin when "-" is passed as an argument
Resolves: https://github.com/pkgcore/pkgcore/issues/226
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/scripts/pquery.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/pkgcore/scripts/pquery.py b/src/pkgcore/scripts/pquery.py
index 7211441f..6ab6a79f 100644
--- a/src/pkgcore/scripts/pquery.py
+++ b/src/pkgcore/scripts/pquery.py
@@ -15,8 +15,9 @@ running them on source repos makes no sense.
import errno
import os
-from functools import partial
+import sys
import typing
+from functools import partial
from snakeoil.cli import arghparse
from snakeoil.formatters import decorate_forced_wrapping
@@ -705,9 +706,17 @@ def bind_add_query(*args, **kwds):
type=None,
help="extended atom matching of pkgs",
)
-def matches_finalize(targets, namespace):
+def matches_finalize(targets: list[str], namespace):
repos = multiplex.tree(*namespace.repos)
+ if "-" in targets:
+ if not sys.stdin.isatty():
+ idx = targets.index("-")
+ in_targets = [x.strip() for x in sys.stdin.readlines()]
+ targets = targets[:idx] + in_targets + targets[idx + 1 :]
+ else:
+ argparser.error("reading from stdin is only valid when piping data in")
+
# If current working dir is in a repo, build a path restriction; otherwise
# match everything.
if not targets:
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/
@ 2023-11-24 15:17 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2023-11-24 15:17 UTC (permalink / raw
To: gentoo-commits
commit: a65cbd1bbf283e22c908136ca79b8e52cb69a593
Author: Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Nov 21 00:33:39 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Nov 24 15:17:21 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=a65cbd1b
pquery: correct minor english typo in comments
Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/scripts/pquery.py | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/pkgcore/scripts/pquery.py b/src/pkgcore/scripts/pquery.py
index 7a8922bad..0a01702fd 100644
--- a/src/pkgcore/scripts/pquery.py
+++ b/src/pkgcore/scripts/pquery.py
@@ -871,7 +871,7 @@ def parse_ownsre(value):
@bind_add_query("--maintainer", action="append", help="regex to search for maintainers")
def parse_maintainer(value):
"""
- Case insensitive Regex match on the combined 'name <email>' bit of
+ Case-insensitive Regex match on the combined 'name <email>' bit of
metadata.xml's maintainer data.
"""
if value and value != "maintainer-needed":
@@ -895,7 +895,7 @@ def parse_maintainer(value):
)
def parse_maintainer_name(value):
"""
- Case insensitive Regex match on the name bit of metadata.xml's
+ Case-insensitive Regex match on the name bit of metadata.xml's
maintainer data.
"""
return packages.PackageRestriction(
@@ -915,7 +915,7 @@ def parse_maintainer_name(value):
)
def parse_maintainer_email(value):
"""
- Case insensitive Regex match on the email bit of metadata.xml's
+ Case-insensitive Regex match on the email bit of metadata.xml's
maintainer data.
"""
return packages.PackageRestriction(
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/
@ 2023-11-24 15:17 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2023-11-24 15:17 UTC (permalink / raw
To: gentoo-commits
commit: e3276db7fd78c3d7514d97aae24eabbb924a1ff1
Author: Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Tue Nov 21 01:00:53 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Fri Nov 24 15:17:21 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=e3276db7
pquery: Fix --environment-re support .
This has been broken for a long while, thus I'm renaming
it to `--environment-re` (from `--environment`) in the
process.
Tests will follow in a later PR (pquery test infra needs some
work).
Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
Closes: https://github.com/pkgcore/pkgcore/pull/415
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/scripts/pquery.py | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/src/pkgcore/scripts/pquery.py b/src/pkgcore/scripts/pquery.py
index 0a01702fd..7211441fc 100644
--- a/src/pkgcore/scripts/pquery.py
+++ b/src/pkgcore/scripts/pquery.py
@@ -16,6 +16,7 @@ running them on source repos makes no sense.
import errno
import os
from functools import partial
+import typing
from snakeoil.cli import arghparse
from snakeoil.formatters import decorate_forced_wrapping
@@ -35,9 +36,17 @@ from ..util import parserestrict
class DataSourceRestriction(values.base):
"""Turn a data_source into a line iterator and apply a restriction."""
- def __init__(self, childrestriction, **kwargs):
+ __slots__ = ("negate", "restriction")
+
+ def __init__(
+ self,
+ childrestriction: typing.Union[values.base, values.AnyMatch],
+ negate=False,
+ **kwargs,
+ ):
super().__init__(**kwargs)
- self.restriction = childrestriction
+ object.__setattr__(self, "restriction", childrestriction)
+ object.__setattr__(self, "negate", negate)
def __str__(self):
return f"DataSourceRestriction: {self.restriction} negate={self.negate}"
@@ -929,9 +938,11 @@ def parse_maintainer_email(value):
@bind_add_query(
- "--environment", action="append", help="regexp search in environment.bz2"
+ "--environment-re",
+ action="append",
+ help="regexp search of lines in environment.bz2",
)
-def parse_envmatch(value):
+def parse_environment_re(value):
"""Apply a regexp to the environment."""
return packages.PackageRestriction(
"environment", DataSourceRestriction(values.AnyMatch(values.StrRegex(value)))
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/
@ 2023-10-23 17:35 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2023-10-23 17:35 UTC (permalink / raw
To: gentoo-commits
commit: 590658425abffe0253602adc30f7c22172f92b13
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Mon Oct 23 17:03:30 2023 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Mon Oct 23 17:03:30 2023 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=59065842
pmaint eclass: add better invocation with output filename format
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/scripts/pmaint.py | 26 +++++++++++++++++++++++---
1 file changed, 23 insertions(+), 3 deletions(-)
diff --git a/src/pkgcore/scripts/pmaint.py b/src/pkgcore/scripts/pmaint.py
index 008de533f..c148454a7 100644
--- a/src/pkgcore/scripts/pmaint.py
+++ b/src/pkgcore/scripts/pmaint.py
@@ -496,6 +496,19 @@ eclass_opts = eclass.add_argument_group("subcommand options")
eclass_opts.add_argument(
"--dir", dest="output_dir", type=arghparse.create_dir, help="output directory"
)
+eclass_opts.add_argument(
+ "-o",
+ "--output",
+ dest="output_format",
+ default="{eclass}.eclass.{format}",
+ help="output file name format",
+ docs="""
+ Output file name format. Defaults to ``{eclass}.eclass.{format}``. You
+ can use ``{eclass}`` and ``{format}`` placeholders to customize the
+ output file name. The filename can have path separator, for example:
+ ``{eclass}/{eclass}.eclass.{format}``.
+ """,
+)
eclass_opts.add_argument(
"-f",
"--format",
@@ -541,9 +554,16 @@ def _eclass_main(options, out, err):
for path in options.eclasses:
try:
- with open(
- pjoin(options.output_dir, f"{os.path.basename(path)}.{ext}"), "wt"
- ) as f:
+ filename = pjoin(
+ options.output_dir,
+ options.output_format.format(
+ eclass=os.path.basename(path).removesuffix(".eclass"),
+ format=ext,
+ ),
+ )
+ out.write("Compiling: ", path)
+ os.makedirs(os.path.dirname(filename), exist_ok=True)
+ with open(filename, "wt") as f:
obj = EclassDoc(path, sourced=True)
convert_func = getattr(obj, f"to_{options.format}")
f.write(convert_func())
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/
@ 2022-12-22 7:11 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2022-12-22 7:11 UTC (permalink / raw
To: gentoo-commits
commit: 322a5f0b4f92731d36bb1922697a59472e20eace
Author: Brian Harring <ferringb <AT> gmail <DOT> com>
AuthorDate: Wed Dec 21 23:26:15 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Thu Dec 22 03:10:33 2022 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=322a5f0b
pmerge: sort target processing to stabilize the graph.
The current resolver is effectively brute force graph exploration,
iteratively adding results to the graph changing previously decisions
based on new requests. This means that the resolver *can* produce
different solutions if the order of constraints added to it differ.
It's desirable the resolver behaviour be reproducible, thus change the default
behaviour to sort the target list given to the resolver.
As to why we don't force sorting within the resolver itself; for processing
of package dependencies, those are already stably ordered. A future
enhancement would be to modify the resolver to be explicit, but that's for
when the resolver is rewritten.
Currently the source of instability is the atoms fed to the resolver from
pmerge, thus why I'm adding the sorting in pmerge.
Finally: the resolver must always produce a solution, or must always not, irregardless
of the argument ordering it's given. Thus '--disable-resolver-target-sorting' is
added to allow disabling the sorting and doing something of a random entry/walk
into the depgraph. This can produce differing solutions than what a sorted entry
would produce; that is working as intended (there is no global optimizer of solutions,
thus 'first solution' is what pmerge uses).
Basically, these two invocations should agree that a solution exists, or doesn't.
If they disagree this directly shows that the resolver is failing to explore solution
space fully:
* `pmerge <targets> --disable-resolver-target-sorting`
* `pmerge <targets>
Signed-off-by: Brian Harring <ferringb <AT> gmail.com>
src/pkgcore/scripts/pmerge.py | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/src/pkgcore/scripts/pmerge.py b/src/pkgcore/scripts/pmerge.py
index 77046feb1..8ea24c8c6 100644
--- a/src/pkgcore/scripts/pmerge.py
+++ b/src/pkgcore/scripts/pmerge.py
@@ -286,6 +286,23 @@ debug_options.add_argument(
what it has decided and why.
"""
)
+debug_options.add_argument(
+ '--disable-resolver-target-sorting', dest='force_stable_ordering_of_targets',
+ action='store_false', default=True,
+ help='disable stabilization of resolver graph processing',
+ docs="""
+ Resolution of package dependencies can grossly vary depending on which nodes you start from.
+
+ Pmerge by default sorts the targets it's asked to resolve; this in turn stabilizes the resolvers
+ output. This option allows disabling that sort.
+
+ This should be only used if you're debugging the resolver and wish to effectively fuzz the resolvers
+ ability to find solutions; for a properly working resolver if a solution can be found, it *must*
+ be found. If a solution can't be found, then this flag should also result in no solution found.
+
+ Any deviation from this is a bug in the resolver and should be reported.
+ """
+)
class AmbiguousQuery(parserestrict.ParseError):
@@ -640,6 +657,7 @@ def main(options, out, err):
# This mode does not care about sets and packages so bypass all that.
if options.unmerge:
+ # TODO: this logic should be updated to honor self.force_stable_ordering_of_targets
if not options.oneshot:
if world_set is None:
argparser.error("disable world updating via --oneshot, "
@@ -702,6 +720,8 @@ def main(options, out, err):
return 1
atoms = stable_unique(atoms)
+ if options.force_stable_ordering_of_targets:
+ atoms = sorted(atoms)
if options.clean and not options.oneshot:
if world_set is None:
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/
@ 2022-11-12 10:51 Arthur Zamarin
0 siblings, 0 replies; 9+ messages in thread
From: Arthur Zamarin @ 2022-11-12 10:51 UTC (permalink / raw
To: gentoo-commits
commit: fa5153ff81b8159fa59dc2495f5bf9cdf36a99a4
Author: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 12 10:49:25 2022 +0000
Commit: Arthur Zamarin <arthurzam <AT> gentoo <DOT> org>
CommitDate: Sat Nov 12 10:49:25 2022 +0000
URL: https://gitweb.gentoo.org/proj/pkgcore/pkgcore.git/commit/?id=fa5153ff
pquery: fix crash with verbose single uris attr
When the `uris` attribute has only one value, and the `verbose` option
was used, pquery was crashing because `node.uri` isn't subscriptable.
Use more agnostic `next(iter(node.uris))` instead.
Signed-off-by: Arthur Zamarin <arthurzam <AT> gentoo.org>
src/pkgcore/scripts/pquery.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/pkgcore/scripts/pquery.py b/src/pkgcore/scripts/pquery.py
index 6bc04994d..eaba242f3 100644
--- a/src/pkgcore/scripts/pquery.py
+++ b/src/pkgcore/scripts/pquery.py
@@ -269,7 +269,7 @@ def format_attr(config, out, pkg, attr):
if not node.uri:
return False
if len(node.uri) == 1:
- out.write(node.uri[0], autoline=False)
+ out.write(next(iter(node.uri)), autoline=False)
return False
out.write('|| (')
out.first_prefix.append(' ')
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2025-01-20 17:17 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-15 20:02 [gentoo-commits] proj/pkgcore/pkgcore:master commit in: src/pkgcore/scripts/ Arthur Zamarin
-- strict thread matches above, loose matches on Subject: below --
2025-01-20 17:17 Arthur Zamarin
2025-01-18 17:21 Arthur Zamarin
2025-01-15 20:02 Arthur Zamarin
2023-11-24 15:17 Arthur Zamarin
2023-11-24 15:17 Arthur Zamarin
2023-10-23 17:35 Arthur Zamarin
2022-12-22 7:11 Arthur Zamarin
2022-11-12 10:51 Arthur Zamarin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox