Closed Gobidev closed 5 months ago
How does the installed
file look like? I presume that this method works and it's so odd that it does.
The file contains information about the installed packages, where the individual packages are separated by blank lines.
This is an example from one of my testing VMs: installed
I have tested this method with various amounts of packages installed and so far it was accurate without the need to correct for off-by-one errors.
Great, thanks for the attachment! Let's merge it.
On Alpine Linux, packages can be counted by counting the amount of empty lines in
/lib/apk/db/installed
. On my test VM, this takes about 5ms compared to 80ms with the previous method with 82 packages installed.I left the previous counting method as fallback, in case there are systems that use
apk
where the new one does not work.Related to https://github.com/Gobidev/pfetch-rs/issues/48