Skip to content

Commit

Permalink
Add disabling source inclusion
Browse files Browse the repository at this point in the history
Not all users care about source packages, so let's make life easier for
them. With the new option, the tool will not do anything about source
rpms, including not printing a warning for each RPM.
  • Loading branch information
lubomir committed Dec 2, 2024
1 parent 4973d9e commit 8c677e9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 9 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## Unreleased

### Added

- Inclusion of source packages in the final manifest can now be disabled with a
toplevel config option `noSources: true`. This is mostly useful for cases
where there are no source repos available to silence the many warnings.

## [0.11.0] - 2024-11-20

### Added
Expand Down
24 changes: 15 additions & 9 deletions rpm_lockfile/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ def resolver(
reinstall_packages: set[str],
module_enable: set[str],
module_disable: set[str],
no_sources: bool,
):
packages = set()
sources = set()
Expand Down Expand Up @@ -180,15 +181,16 @@ def resolver(
modular_repos.add(pkg.repoid)
packages.add(PackageItem.from_dnf(pkg))
# Find the corresponding source package
n, v, r = strip_suffix(pkg.sourcerpm, ".src.rpm").rsplit("-", 2)
results = base.sack.query().filter(
name=n, version=v, release=r, arch="src"
)
if len(results) == 0:
logging.warning("No sources found for %s", pkg)
else:
src = results[0]
sources.add(PackageItem.from_dnf(src))
if not no_sources:
n, v, r = strip_suffix(pkg.sourcerpm, ".src.rpm").rsplit("-", 2)
results = base.sack.query().filter(
name=n, version=v, release=r, arch="src"
)
if len(results) == 0:
logging.warning("No sources found for %s", pkg)
else:
src = results[0]
sources.add(PackageItem.from_dnf(src))

for repoid in modular_repos:
repo = base.repos[repoid]
Expand Down Expand Up @@ -245,6 +247,7 @@ def process_arch(
reinstall_packages: set[str],
module_enable: set[str],
module_disable: set[str],
no_sources: bool,
):
logging.info("Running solver for %s", arch)

Expand All @@ -258,6 +261,7 @@ def process_arch(
reinstall_packages,
module_enable,
module_disable,
no_sources,
)

return {
Expand Down Expand Up @@ -404,6 +408,7 @@ def main():

context = config.get("context", {})
allowerasing = args.allowerasing or config.get("allowerasing", False)
no_sources = config.get("noSources", False)

local = args.local_system or context.get("localSystem")
if local and arches != [platform.machine()]:
Expand Down Expand Up @@ -459,6 +464,7 @@ def main():
module_disable=set(
filter_for_arch(arch, config.get("moduleDisable", []))
),
no_sources=no_sources,
)
)

Expand Down
1 change: 1 addition & 0 deletions rpm_lockfile/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ def get_schema():
],
},
"allowerasing": {"type": "boolean"},
"noSources": {"type": "boolean"},
},
"required": ["contentOrigin"],
"additionalProperties": False,
Expand Down

0 comments on commit 8c677e9

Please sign in to comment.