cmds.pkg.CmdVerify: Add command #142
Loading…
Reference in a new issue
No description provided.
Delete branch "jan/feature/20261016-cmds-pkg-cmdverify-add-command"
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?
This PR brings package integrity verification to
jw-pkgas a distribution-independentDistrocapability, exposed to users as thepackages verifycommand.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 samelist[str] | Noneinterface that the newDistro.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-hocjw-base verifypipe that grepsrpm -qVoutput 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 - passNoneto 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 tolist_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-baseverify pipes the output ofrpm -qVfor all janware packages into a grep for md5 mismatches and missing files. The same capability, distribution-independent, belongs in theDistroabstraction so that tools likejw-nettoolscan check the integrity of the packages they install on a fleet of hosts.Distro.verify(), which verifies the given package names, or all packages selected by the package filter when none are given, and returns the flagged filesDistro._verify()as the distribution hookFlaggedFile, 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 startpm/rpm.py:parse_verify_output()parses the output ofrpm -qVand 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()runsrpm -qVper package and collects the findingspm/dpkg.py:parse_verify_output()parses the output ofdpkg -Vand reports md5sum (P) mismatches and missing files (M);verify_packages()runsdpkg -Vper packageSUSE, Red Hat, and Debian Distro classes implement_verify()with the respective pm helpers; the Arch Distro raisesNotImplementedError, like its other package manager hookscmds.pkg.CmdVerify: Add command
Add the
packages verifycommand: it runsDistro.verify()with the app's package filter and prints one line per flagged file.