different ways of updating the apt package index #4
Labels
No labels
bugfix
cleanup
discussion
documentation
doing
done
feature
improvement
packaging
Stale
testing
TODO
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
ungleich-public/cdist#4
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
There are multiple types that update the apt package index as I rediscovered them where I wanted to fix them cause of an interactive prompt that the suite changes and aborts when called non-interactive (see #861). Previous it was also noted by Ander at an other fix for
__package_update_index.It's a bit difficult because each type updates the package to an other point of time:
__package_update_indexjust updates the index like you would when you executeapt-get updatewith the addition to not run the update if the index is younger than$x__apt_update_indexupdates the index only if an element in/etc/apt/is newer than the index__apt_sourceupdates the index if itself changes (correct speaking if the modifing source file changes)__package_aptupdates the index before the package install if it's too oldMoving everything to a single type is a bit difficult to do, but better for maintainability (1 instead of 4 MR's). Having one singleton type isn't a problem if you only depend on it, but get's bigger when the index update depends on something else (like changed sources files). Funny things starts and probably end like
__uci_commitended. It's also the question if we need multiple index updates in one cdist run (What if__apt_keyneeds to installcurlbut the index update should happen after the__apt_sourcerun? Assuming we want to update the package index before any package installation because it could be too old.) and so on. But also, we don't want to run the index update a useless second round.As my first thoughts about this aren't that pretty, this issue should group the whole thread at one place in the hope we find a solution for this code duplication. Maybe with a layer outside the types? A library?
ping @ander and @ssrq
so, perhaps something like this:
https://code.ungleich.ch/ungleich-public/cdist/-/compare/master...ander%2F__package_apt_update_index
mentioned in merge request !1028
Good cents.
Sure there is: install something, change APT's conf (add keys, sources, whatnot) and then again install something. Then there's this magical question if
__apt_keyand__apt_sourceshould also automatically update index onchange (sounds familiar? 😄)? I think not, because if you call__package_aptafter them, index gets updated, because there have been change in/etc/apt/. So, automatically updating index is only important for__package_apt? If__apt_update_indexis singleton, I'm not sure what's going to happen in this kind of situations, when there's actual need to run__apt_update_indexmultiple times in one configuration run. So, instead, we only need to implement Very Smart Index Updating (tm) for__package_aptand deprecate everything else?🤷
First of all: yes, the current situation is a mess and it should be solved!
JM2C:
__*_update_indexbe singletons? Are there any cases where one would need to update the index multiple times during a single cdist run?__package_update_index? What would be the use case?Are there any other use cases other than
__package_update_index --force?https://github.com/ungleich/cdist/pull/780
PR in GitHub reminded me this issue.
While sitting in the garden and enjoying nice autumn weather, I did some thinking.
I'll start with following proposal and then try to shoot holes into it:
__package_*types should only deal with installing (and potentially upgrading) packages.__*_update_indexshould only update index based on some parameters with sane defaults. For example: always update if something in/etc/aptis newer than/var/lib/apt/listsor if latter is missing. Or update cache if it's older than X hours or cache files are missing.__package_update_indexshould behave similarly as__package- calls correct os-specific type according to information given by explorer(s).__package_*then should call__*_update_indexin type manifest. In theory, if first instance of__package_*updates index and type itself is non-parallel, then other instances shouldn't retry it.Now shooting some holes.
Currently
__apt_update_indexand__package_update_indexare singletons. This must be changed then? Same time calling singleton type multiple times don't raise error...If
__package_*can handle index update anyway, then why splitting this functionality into separate type(s)? Right, do one thing and do it well.Some users might prefer to explicitly call something like
__*_update_index --forceor__package_update_index --forceon every configuration run before doing anything else.Is there something I forgot or don't see?
changed title from diffrent ways of updating the apt package index to diff{+e+}rent ways of updating the apt package index