Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Apt: Only update package lists if packages need to be installed #1102

Open
matthijskooijman opened this issue May 12, 2024 · 0 comments
Open

Comments

@matthijskooijman
Copy link
Contributor

Is your feature request related to a problem? Please describe

I'm using this to install packages:

      apt.packages(
          name="Install packages",
          packages=('vim', 'avahi-daemon'),
          update=True,
          cache_time=3600,
      )

This runs an apt update if needed, to ensure that the install actually works (it can fail if the lists are outdated).

However, currently this runs the apt update every hour, even if the specified packages are already installed and no further action is needed (and because upgrade=False and latest=False, which are the defaults, there is AFAICS also no way that running the update could cause a package to be installed/upgraded that would not be without running the update). In practice, this means every pyinfra run takes quite long, even when just making a small other change...

Describe the solution you'd like

When update is specified, but not upgrade or latest, only run the apt update when any packages are missing. If latest and/or upgrade are specified, then the behavior must remain as now, since the update needs to be run to decide whether any packages can be upgraded.

This is a change in behavior, but the documentation says "update: run apt update before installing packages", so the proposed behavior would (IMHO) better implement the documentation - run update only before/when actually installing packages.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant