Feature/apk software inventory - #1217
Open
Megachip wants to merge 5 commits into
Open
Conversation
Added support for software inventory using Alpine Package Keeper.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add software inventory support for Alpine Package Keeper (apk)
Closes the request in discussion #901.
Why
Alpine Linux is the default distribution for a large share of Docker base
images, but glpi-agent had no software-inventory support for its package
manager
apk. Installed apk packages were therefore missing from theinventory entirely.
What
New module
GLPI::Agent::Task::Inventory::Generic::Softwares::APK.It reads the apk installed packages database (
/lib/apk/db/installed)directly rather than forking the
apkbinary. This was chosen over parsingapk list --installedoutput because it is:apk, which parses thatvery same file itself;
fields (
P:/V:), so there is no fragilename-versiontoken splitting(apk names may contain digits, e.g.
libcrypto3, which makes heuristicsplitting error-prone). This also sidesteps the apk v2/v3
listoutputdifferences raised in the discussion;
The database describes each package as a block of
key:valuelines separatedby a blank line. The module extracts:
PNAMEVVERSIONAARCHIFILESIZE(installed size, in bytes)TCOMMENTS(description)mPUBLISHER(maintainer, when present)FROM => 'apk'isEnabled()requires bothcanRun('apk')and the database file to be present.Maintainer names are UTF-8 decoded (like the RPM module).
INSTALLDATEisdeliberately not set: the database only stores the package build time (
t:),not a per-host installation date (the Deb module omits it for the same reason).
Tests
resources/linux/packaging/apk(a realisticinstalleddatabase, incl. a multi-hyphen name, a digit-suffixed name
libcrypto3, anoarchpackage and one package without a maintainer field).t/tasks/inventory/linux/softwares.twith apk parsing andregistration checks. Full file passes (27/27).
use utf8was added so theaccented maintainer names in the expectations compare correctly.
Notes
opkgis intentionally out of scope here and can follow in a separate PR.reaches stable Alpine, the parser will need a format check. All currently
deployed Alpine releases use the text format handled here.