cmds.pkg.CmdVerify: Add command #142

Merged
Jan Lindemann merged 3 commits from jan/feature/20261016-cmds-pkg-cmdverify-add-command into master 2026-10-16 09:53:58 +02:00 AGit
Owner

This PR brings package integrity verification to jw-pkg as a distribution-independent Distro capability, exposed to users as the packages verify command.

The commits build up to that command: Distro.pkg_files() is generalized first so that a file-list query can target a single package, a list of packages, or all packaged files - the same list[str] | None interface that the new Distro.verify() reuses to select the packages to check. The verification itself is a distribution hook with rpm and dpkg backends, and the final commit wires it up as the command. It replaces the ad-hoc jw-base verify pipe that greps rpm -qV output and makes the capability available to other tools, e.g. jw-nettools, for checking packages installed on a fleet of hosts.

lib.Distro.pkg_files(): Take list[str] | None

Distro.pkg_files() takes a package name and returns a list of files in that package. This commit generalizes that - pass None to it and get the list of all packaged files in the system, and pass a list of strings to retrieve all files belonging to the named packages.

The same arguments are propagated to _pkg_files(), which in turn propagates them to list_files().

This allows faster generation of file lists than before. Having to retrieve a list of matching packages and query each package for its contained files can be collapsed into one or two backend calls.

lib.Distro.verify(): Add method

jw-base verify pipes the output of rpm -qV for all janware packages into a grep for md5 mismatches and missing files. The same capability, distribution-independent, belongs in the Distro abstraction so that tools like jw-nettools can check the integrity of the packages they install on a fleet of hosts.

  • Add Distro.verify(), which verifies the given package names, or all packages selected by the package filter when none are given, and returns the flagged files
  • Add Distro._verify() as the distribution hook
  • Add FlaggedFile, the record for a flagged file: package, file, and the package manager's verify status line - not distribution independent as of today, but it's a start
  • pm/rpm.py: parse_verify_output() parses the output of rpm -qV and reports md5 mismatches and missing files, the latter reported with the literal word "missing" in the flag field; size, mode, mtime, user, and group mismatches are noise on dev machines and are ignored. verify_packages() runs rpm -qV per package and collects the findings
  • pm/dpkg.py: parse_verify_output() parses the output of dpkg -V and reports md5sum (P) mismatches and missing files (M); verify_packages() runs dpkg -V per package
  • The SUSE, Red Hat, and Debian Distro classes implement _verify() with the respective pm helpers; the Arch Distro raises NotImplementedError, like its other package manager hooks

cmds.pkg.CmdVerify: Add command

Add the packages verify command: it runs Distro.verify() with the app's package filter and prints one line per flagged file.

This PR brings package integrity verification to `jw-pkg` as a distribution-independent `Distro` capability, exposed to users as the `packages verify` command. The commits build up to that command: `Distro.pkg_files()` is generalized first so that a file-list query can target a single package, a list of packages, or all packaged files - the same `list[str] | None` interface that the new `Distro.verify()` reuses to select the packages to check. The verification itself is a distribution hook with rpm and dpkg backends, and the final commit wires it up as the command. It replaces the ad-hoc `jw-base verify` pipe that greps `rpm -qV` output and makes the capability available to other tools, e.g. `jw-nettools`, for checking packages installed on a fleet of hosts. #### lib.Distro.pkg_files(): Take list[str] | None `Distro.pkg_files()` takes a package name and returns a list of files in that package. This commit generalizes that - pass `None` to it and get the list of all packaged files in the system, and pass a list of strings to retrieve all files belonging to the named packages. The same arguments are propagated to `_pkg_files()`, which in turn propagates them to `list_files()`. This allows faster generation of file lists than before. Having to retrieve a list of matching packages and query each package for its contained files can be collapsed into one or two backend calls. #### lib.Distro.verify(): Add method `jw-base` verify pipes the output of `rpm -qV` for all janware packages into a grep for md5 mismatches and missing files. The same capability, distribution-independent, belongs in the `Distro` abstraction so that tools like `jw-nettools` can check the integrity of the packages they install on a fleet of hosts. - Add `Distro.verify()`, which verifies the given package names, or all packages selected by the package filter when none are given, and returns the flagged files - Add `Distro._verify()` as the distribution hook - Add `FlaggedFile`, the record for a flagged file: package, file, and the package manager's verify status line - not distribution independent as of today, but it's a start - `pm/rpm.py`: `parse_verify_output()` parses the output of `rpm -qV` and reports md5 mismatches and missing files, the latter reported with the literal word "missing" in the flag field; size, mode, mtime, user, and group mismatches are noise on dev machines and are ignored. `verify_packages()` runs `rpm -qV` per package and collects the findings - `pm/dpkg.py`: `parse_verify_output()` parses the output of `dpkg -V` and reports md5sum (P) mismatches and missing files (M); `verify_packages()` runs `dpkg -V` per package - The `SUSE`, Red Hat, and Debian Distro classes implement `_verify()` with the respective pm helpers; the Arch Distro raises `NotImplementedError`, like its other package manager hooks #### cmds.pkg.CmdVerify: Add command Add the `packages verify` command: it runs `Distro.verify()` with the app's package filter and prints one line per flagged file.
Distro.pkg_files() takes a package name and returns a list of files in that
package. This commit generalizes that - pass None to it and get the list of
all packaged files in the system, and pass a list of strings to retrieve
all files belonging to the named packages.

The same arguments are propagated to _pkg_files(), which in turn propagates
them to list_files().

This allows faster generation of file lists than before. Having to retrieve
a list of matching packages and query each package for its contained files
can be collapsed into one or two backend calls.

Signed-off-by: Jan Lindemann <jan@janware.com>
jw-base verify pipes the output of rpm -qV for all janware packages
into a grep for md5 mismatches and missing files. The same capability,
distribution-independent, belongs in the Distro abstraction so that tools
like jw-nettools can check the integrity of the packages they install on a
fleet of hosts.

- Add Distro.verify(), which verifies the given package names, or all
  packages selected by the package filter when none are given, and returns
  the flagged files
- Add Distro._verify() as the distribution hook
- Add FlaggedFile, the record for a flagged file: package, file, and the
  package manager's verify status line - not distribution independent as of
  today, but it's a start
- pm/rpm.py: parse_verify_output() parses the output of `rpm -qV` and
  reports md5 mismatches and missing files, the latter reported with the
  literal word "missing" in the flag field; size, mode, mtime, user, and
  group mismatches are noise on dev machines and are ignored.
  verify_packages() runs `rpm -qV` per package and collects the findings
- pm/dpkg.py: parse_verify_output() parses the output of `dpkg -V` and
  reports md5sum (P) mismatches and missing files (M); verify_packages()
  runs `dpkg -V` per package
- The SUSE, Red Hat, and Debian Distro classes implement _verify() with the
  respective pm helpers; the Arch Distro raises NotImplementedError, like
  its other package manager hooks

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.2.0
cmds.pkg.CmdVerify: Add command
All checks were successful
CI / Packaging - Kali Linux (pull_request) Successful in 4m24s
CI / Packaging - OpenSUSE Tumbleweed (pull_request) Successful in 4m43s
CI / Packaging test (pull_request) Successful in 0s
CI / Packaging - Kali Linux (push) Successful in 4m48s
CI / Packaging - OpenSUSE Tumbleweed (push) Successful in 4m38s
CI / Packaging test (push) Successful in 0s
8106d4a7b0
Add the "packages verify" command: it runs Distro.verify() with the app's
package filter and prints one line per flagged file.

Signed-off-by: Jan Lindemann <jan@janware.com>
Assisted-by: unsloth/Qwen3.8-27B-GGUF:Q4_K_M with pi.dev v1.2.0
Jan Lindemann scheduled this pull request to auto merge when all checks succeed 2026-10-16 09:40:24 +02:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
janware/jw-pkg!142
No description provided.