Skip to content

Commit

Permalink
Allow definying classes of equivalence for system tools
Browse files Browse the repository at this point in the history
  • Loading branch information
ktf committed Oct 15, 2024
1 parent d51c1b7 commit 34f10cb
Showing 1 changed file with 25 additions and 21 deletions.
46 changes: 25 additions & 21 deletions alibuild_helpers/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -488,28 +488,32 @@ def getPackageList(packages, specs, configDir, preferSystem, noSystem,
else:
# The check printed the name of a replacement; use it.
key = match.group("key").strip()
try:
replacement = spec["prefer_system_replacement_specs"][key]
except KeyError:
dieOnError(True, "Could not find named replacement spec for "
"%s: %s" % (spec["package"], key))
replacement = None
for replacement_matcher in spec["prefer_system_replacement_specs"]:
if re.match(replacement_matcher, key):
replacement = spec["prefer_system_replacement_specs"][replacement_matcher]
break
dieOnError(replacement is None, "Could not find named replacement spec for "
"%s: %s" % (spec["package"], key))
assert(replacement)
# We must keep the package name the same, since it is used to
# specify dependencies.
replacement["package"] = spec["package"]
# The version is required for all specs. What we put there will
# influence the package's hash, so allow the user to override it.
replacement.setdefault("version", requested_version)
spec = replacement
# Allows generalising the version based on the actual key provided
spec["version"] = spec["version"].replace("%(key)s", key)
recipe = replacement.get("recipe", "")
# If there's an explicitly-specified recipe, we're still building
# the package. If not, aliBuild will still "build" it, but it's
# basically instantaneous, so report to the user that we're taking
# it from the system.
if recipe:
ownPackages.add(spec["package"])
else:
# We must keep the package name the same, since it is used to
# specify dependencies.
replacement["package"] = spec["package"]
# The version is required for all specs. What we put there will
# influence the package's hash, so allow the user to override it.
replacement.setdefault("version", requested_version)
spec = replacement
recipe = replacement.get("recipe", "")
# If there's an explicitly-specified recipe, we're still building
# the package. If not, aliBuild will still "build" it, but it's
# basically instantaneous, so report to the user that we're taking
# it from the system.
if recipe:
ownPackages.add(spec["package"])
else:
systemPackages.add(spec["package"])
systemPackages.add(spec["package"])

dieOnError(("system_requirement" in spec) and recipe.strip("\n\t "),
"System requirements %s cannot have a recipe" % spec["package"])
Expand Down

0 comments on commit 34f10cb

Please sign in to comment.