Skip to content
Closed
3 changes: 2 additions & 1 deletion bin/quickpkg
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ def quickpkg_atom(options, infos, arg, eout):
eout.eerror(f"Invalid atom: {arg}")
infos["missing"].append(arg)
return 1
if atom[:1] == "=" and arg[:1] != "=":
# Check if dep_expand added an operator that wasn't in the original arg
if atom.operator == "=" and not str(arg).startswith("="):
# dep_expand() allows missing '=' but it's really invalid
eout.eerror(f"Invalid atom: {arg}")
infos["missing"].append(arg)
Expand Down
5 changes: 3 additions & 2 deletions lib/_emerge/BlockerCache.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Distributed under the terms of the GNU General Public License v2

import errno
from portage.dep import Atom
from portage.util import writemsg
from portage.data import secpass
import portage
Expand Down Expand Up @@ -99,10 +100,10 @@ def _load(self):
continue
invalid_atom = False
for atom in atoms:
if not isinstance(atom, str):
if not isinstance(atom, (str, Atom)):
invalid_atom = True
break
if atom[:1] != "!" or not portage.isvalidatom(
if str(atom)[:1] != "!" or not portage.isvalidatom(
atom, allow_blockers=True
):
invalid_atom = True
Expand Down
8 changes: 4 additions & 4 deletions lib/_emerge/BlockerDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def findInstalledBlockers(self, new_pkg):
)
continue

blocker_atoms = [atom for atom in atoms if atom.startswith("!")]
blocker_atoms.sort()
blocker_atoms = [atom for atom in atoms if atom.blocker]
blocker_atoms.sort(key=str)
blocker_cache[inst_pkg.cpv] = blocker_cache.BlockerData(
inst_pkg.counter, blocker_atoms
)
Expand All @@ -89,7 +89,7 @@ def findInstalledBlockers(self, new_pkg):
blocker_atoms = []
for pkg in installed_pkgs:
for blocker_atom in blocker_cache[pkg.cpv].atoms:
blocker_atom = blocker_atom.lstrip("!")
blocker_atom = str(blocker_atom).lstrip("!")
blocker_atoms.append(blocker_atom)
blocker_parents.add(blocker_atom, pkg)

Expand All @@ -113,7 +113,7 @@ def findInstalledBlockers(self, new_pkg):
show_invalid_depstring_notice(new_pkg, atoms)
assert False

blocker_atoms = [atom.lstrip("!") for atom in atoms if atom[:1] == "!"]
blocker_atoms = [str(atom).lstrip("!") for atom in atoms if atom.blocker]
if blocker_atoms:
blocker_atoms = InternalPackageSet(initial_atoms=blocker_atoms)
for inst_pkg in installed_pkgs:
Expand Down
70 changes: 37 additions & 33 deletions lib/_emerge/actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -1183,17 +1183,11 @@ def unresolved_deps():
# visible in the unevaluated form of the atom. In this
# case, we must display the unevaluated atom, so that
# the user can see the conditional USE deps that would
# otherwise be invisible. Use Atom(str(atom)) to
# test for a package where this case would matter. This
# is not necessarily the same as atom.without_use,
# since Atom(str(atom)) may still contain some
# USE dependencies that remain after evaluation of
# otherwise be invisible. This is not necessarily the same as
# atom.without_use, since the evaluated atom may still contain
# some USE dependencies that remain after evaluation of
# conditionals.
if (
atom.package
and atom != atom.unevaluated_atom
and vardb.match(Atom(str(atom)))
):
if atom.package and atom != atom.unevaluated_atom and vardb.match(atom):
msg.append(f" {atom.unevaluated_atom} ({atom}) pulled in by:")
else:
msg.append(f" {atom} pulled in by:")
Expand Down Expand Up @@ -1758,16 +1752,16 @@ def action_deselect(settings, trees, opts, atoms):
expanded_atoms = set(atoms)

for atom in atoms:
if not atom.startswith(SETPREFIX):
if atom.cp.startswith("null/"):
if not str(atom).startswith(SETPREFIX):
if atom.category == "null":
# try to expand category from world set
null_cat, pn = portage.catsplit(atom.cp)
for world_atom in world_atoms:
cat, world_pn = portage.catsplit(world_atom.cp)
if pn == world_pn:
expanded_atoms.add(
Atom(
atom.replace("null", cat, 1),
str(atom).replace("null", cat, 1),
allow_repo=True,
allow_wildcard=True,
)
Expand All @@ -1780,27 +1774,27 @@ def action_deselect(settings, trees, opts, atoms):
discard_atoms = set()
for atom in world_set:
for arg_atom in expanded_atoms:
if arg_atom.startswith(SETPREFIX):
if atom.startswith(SETPREFIX) and arg_atom == atom:
if str(arg_atom).startswith(SETPREFIX):
if str(atom).startswith(SETPREFIX) and arg_atom == atom:
discard_atoms.add(atom)
break
else:
if (
not atom.startswith(SETPREFIX)
not str(atom).startswith(SETPREFIX)
and arg_atom.intersects(atom)
and not (arg_atom.slot and not atom.slot)
and not (arg_atom.repo and not atom.repo)
):
discard_atoms.add(atom)
break
if discard_atoms:
for atom in sorted(discard_atoms):
for atom in sorted(discard_atoms, key=str):
if pretend:
action_desc = "Would remove"
else:
action_desc = "Removing"

if atom.startswith(SETPREFIX):
if str(atom).startswith(SETPREFIX):
filename = "world_sets"
else:
filename = "world"
Expand Down Expand Up @@ -2103,7 +2097,7 @@ def action_info(settings, trees, myopts, myfiles):
if not atom.blocker:
atoms.append((x, atom))

myvars = sorted(set(atoms))
myvars = sorted(set(atoms), key=lambda t: str(t[0]))

cp_map = {}
cp_max_len = 0
Expand Down Expand Up @@ -2835,7 +2829,7 @@ def binpkg_selection_config(opts, settings):
writemsg(
"\n!!! The following atoms appear in both the --usepkg-exclude "
"and --usepkg-include command line arguments:\n"
"\n %s\n" % ("\n ".join(conflicted_atoms))
"\n %s\n" % ("\n ".join(str(a) for a in conflicted_atoms))
)
for a in conflicted_atoms:
usepkg_exclude.remove(a)
Expand All @@ -2847,14 +2841,16 @@ def binpkg_selection_config(opts, settings):
writemsg(
"\n!!! The following --usepkg-exclude atoms are ignored due "
"to use of --nobindeps:\n"
"\n %s\n" % ("\n ".join(usepkg_exclude.getAtoms()))
"\n %s\n"
% ("\n ".join(str(a) for a in usepkg_exclude.getAtoms()))
)
usepkg_exclude.clear()
if not usepkg_include.isEmpty():
writemsg(
"\n!!! The following --usepkg-include atoms are ignored due "
"to use of --nobindeps:\n"
"\n %s\n" % ("\n ".join(usepkg_include.getAtoms()))
"\n %s\n"
% ("\n ".join(str(a) for a in usepkg_include.getAtoms()))
)
usepkg_include.clear()
for repo in settings.repositories:
Expand All @@ -2863,15 +2859,21 @@ def binpkg_selection_config(opts, settings):
"\n!!! The following usepkg-exclude atoms for [%s] are "
"ignored due to use of --nobindeps:\n"
"\n %s\n"
% (repo.name, "\n ".join(repo.usepkg_exclude.getAtoms()))
% (
repo.name,
"\n ".join(str(a) for a in repo.usepkg_exclude.getAtoms()),
)
)
repo.usepkg_exclude.clear()
if not repo.usepkg_include.isEmpty():
writemsg(
"\n!!! The following usepkg-include atoms for [%s] are "
"ignored due to use of --nobindeps:\n"
"\n %s\n"
% (repo.name, "\n ".join(repo.usepkg_include.getAtoms()))
% (
repo.name,
"\n ".join(str(a) for a in repo.usepkg_include.getAtoms()),
)
)
repo.usepkg_include.clear()

Expand All @@ -2884,7 +2886,8 @@ def binpkg_selection_config(opts, settings):
writemsg(
"\n!!! The following usepkg-exclude atoms for [%s] have "
"been overridden by the --usepkg-include option:\n"
"\n %s\n" % (repo.name, "\n ".join(conflicted_exclude))
"\n %s\n"
% (repo.name, "\n ".join(str(a) for a in conflicted_exclude))
)
for a in conflicted_exclude:
repo.usepkg_exclude.remove(a)
Expand All @@ -2895,7 +2898,8 @@ def binpkg_selection_config(opts, settings):
writemsg(
"\n!!! The following usepkg-include atoms for [%s] have "
"been overridden by the --usepkg-exclude option:\n"
"\n %s\n" % (repo.name, "\n ".join(conflicted_include))
"\n %s\n"
% (repo.name, "\n ".join(str(a) for a in conflicted_include))
)
for a in conflicted_include:
repo.usepkg_include.remove(a)
Expand All @@ -2908,20 +2912,20 @@ def binpkg_selection_config(opts, settings):
writemsg(
"\n!!! The following atoms appear in both the --getbinpkg-exclude "
"and --getbinpkg-include command line arguments:\n"
"\n %s\n" % ("\n ".join(conflicted_atoms))
"\n %s\n" % ("\n ".join(str(a) for a in conflicted_atoms))
)
for a in conflicted_atoms:
getbinpkg_exclude.remove(a)
getbinpkg_include.remove(a)

if not getbinpkg_exclude.isEmpty():
opts["--getbinpkg-exclude"] = list(getbinpkg_exclude)
opts["--getbinpkg-exclude"] = [str(a) for a in getbinpkg_exclude]
if not getbinpkg_include.isEmpty():
opts["--getbinpkg-include"] = list(getbinpkg_include)
opts["--getbinpkg-include"] = [str(a) for a in getbinpkg_include]
if not usepkg_exclude.isEmpty():
opts["--usepkg-exclude"] = list(usepkg_exclude)
opts["--usepkg-exclude"] = [str(a) for a in usepkg_exclude]
if not usepkg_include.isEmpty():
opts["--usepkg-include"] = list(usepkg_include)
opts["--usepkg-include"] = [str(a) for a in usepkg_include]


def display_missing_pkg_set(root_config, set_name):
Expand Down Expand Up @@ -4161,11 +4165,11 @@ def emergeexitsig(signum, frame):
# look at the ebuilds, since EAPI 4 allows running pkg_info
# on non-installed packages
valid_atom = dep_expand(x, mydb=vardb)
if valid_atom.cp.split("/")[0] == "null":
if valid_atom.category == "null":
valid_atom = dep_expand(x, mydb=portdb)

if (
valid_atom.cp.split("/")[0] == "null"
valid_atom.category == "null"
and emerge_config.opts.get("--usepkg") is True
):
valid_atom = dep_expand(x, mydb=bindb)
Expand Down
2 changes: 1 addition & 1 deletion lib/_emerge/create_world_atom.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def create_world_atom(pkg, args_set, root_config, before_install=False):
# gcc for example.
system_atom = sets["system"].findAtomForPackage(pkg)
if system_atom:
if not system_atom.cp.startswith("virtual/"):
if system_atom.category != "virtual":
return None
# System virtuals aren't safe to exclude from world since they can
# match multiple old-style virtuals but only one of them will be
Expand Down
Loading
Loading