canonical / canonical/cloud-init

[enhancement]: Allow downgrades on package installs

Open
#5,861 2 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Python
Stars
3.8k
Forks
1.1k
Avg merge
2d 23h
Merged PRs (30d)
18

Description

# Enhancement

Hi there! So I'm working with a situation where I'm enabling a PPA, setting pin priority (manually), and attempting to install packages from it. These are seen by apt to be downgrade actions, and as a result, apt functions will fail (`package_upgrade`, `packages`, etc):

```
E: Packages were downgraded and -y was used without --allow-downgrades.
2024-11-08 20:38:41,119 - util.py[WARNING]: Package upgrade failed
```

With apt, as the message states, the `--allow-downgrades` flag needs to be present when `-y` is also used. I believe dnf/yum will just happily proceed with the downgrade if that's what it thinks is best, though I could be wrong there.

It would be nice to have an option to allow this scenario to happen. Maybe something on the same level as `package_upgrade`, like `allow_package_downgrade`? With this bool set to true, it would append that `--allow-downgrades` flag to all apt commands (and an equivalent if necessary for dnf/yum)? Right now I'm working around it by running those commands in `runcmd` statements, but it would be nice to use the more native built-ins for this.

Thank you for your time and consideration!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.