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

Improve package status consistency on Debian #303

Merged
merged 1 commit into from
Apr 18, 2023

Conversation

smortex
Copy link
Contributor

@smortex smortex commented Apr 11, 2023

In dpkg-query(1), the Status field is composed of 3 values [source]:

  1. the package wanted status (e.g. install, unknown),
  2. the package status error flag (e.g. ok),
  3. the package status word (e.g. installed, not-installed).

When requesting the status of a package, we have this kind of response:

  {
    "status": "install ok installed",
    "version": "7.24.0-1bullseye"
  }

A similar command targeting a CentOS node return a more consise status:

  {
    "status": "installed",
    "version": "7.24.0-1.el7"
  }

Hardcode the status value of installed packages to installed to match
other operating systems.

@smortex smortex requested a review from a team as a code owner April 11, 2023 18:26
bastelfreak
bastelfreak previously approved these changes Apr 14, 2023
files/apt.sh Outdated
@@ -18,9 +18,9 @@ apt_check_latest() {
candidate="${candidate#*: }"

if [[ $installed != $candidate ]]; then
cmd_status="$(apt_status "{ \"status\":\"\${Status}\", \"version\":\"${installed}\", \"latest\":\"${candidate}\" }")"
cmd_status="$(apt_status "{ \"status\":\"\${db:Status-Status}\", \"version\":\"${installed}\", \"latest\":\"${candidate}\" }")"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can also hardcode installed here and bellow if you prefer, because it is what we are going to get all the times here and it makes the code slightly more explicit.

Copy link
Collaborator

@bastelfreak bastelfreak Apr 17, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh good idea, I like that.

In `dpkg-query(1)`, the `Status` field is composed of 3 values [source]:

1. the package wanted status (e.g. `install`, `unknown`),
2. the package status error flag (e.g. `ok`),
3. the package status word (e.g. `installed`, `not-installed`).

When requesting the status of a package, we have this kind of response:

```json
  {
    "status": "install ok installed",
    "version": "7.24.0-1bullseye"
  }
```

A similar command targeting a CentOS node return a more consise status:

```json
  {
    "status": "installed",
    "version": "7.24.0-1.el7"
  }
```

Hardcode the status value of installed packages to `installed` to match
other operating systems.

[source]:https://manpages.debian.org/bullseye/dpkg/dpkg-query.1.en.html
@donoghuc donoghuc merged commit 13b2930 into puppetlabs:main Apr 18, 2023
@smortex smortex deleted the status-consistency branch April 19, 2023 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants