[BUG] aptpkg: Updating held packages via sources does not work
@Akm0d is already working on this.
Since May 8, 2024.
- Dominant language
- Python
- Stars
- 15.7k
- Forks
- 5.6k
- Avg merge
- 2d 44m
- Merged PRs (30d)
- 80
Description
Description
When installing packages via state pkg.installed by using the sources arg updating of held packages does not work.
Setup
common-pkgs:
pkg.installed:
- sources:
- pkg1: salt://common/pkg1_{{ pkg1_version }}.deb
- pkg2: salt://common/pkg2_{{ pkg2_version }}.deb
- hold: True
- update_holds: True
Steps to Reproduce the behavior
# salt-call state.apply common
local:
----------
ID: common-pkgs
Function: pkg.installed
Result: False
Comment: Problem encountered installing package(s). Additional info follows:
errors:
- Running scope as unit: run-rc481e0a775024bad8e2077bd25caa6d3.scope
E: Held packages were changed and -y was used without --allow-change-held-packages.
Started: 11:21:49.207895
Duration: 12991.293 ms
Changes:
Expected behavior
update would be working
Versions Report
3007.0
Additional context
In debug logs I see folloging line:
[DEBUG ] Current version (['1.0.8922-1']) did not match desired version specification (salt://common/pkg1_1.0.9457-1.deb), adding to installation targets
It seems, that all_pkgs in aptpkg.py does contain the path an not the package name
=> pkg1 will not be added to the to_unhold array so it wont be "unholded" before the install is triggered.
I see 2 possible approaches to fix this:
- extend targeted_names with the keys of the
sourcesdict so this package gets addedto_unhold - pass
--allow-change-held-packages(introduced in 1.1 as successor for the--force-yesparam) to apt - e.g. by usingupdate_holdswhich is documented as working for apt, yum and zypper but seems to only be implemented for yum.
The second approach has the charme, that the implementation around to_unhold might be completely be skipped by making this param "responsible" for allowing updates.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.