pkgstats is the command-line client for the Arch Linux package statistics project. It allows users to submit a list of their installed packages, helping Arch Linux developers understand package usage and prioritize their efforts.
The tool also provides functionality to search for packages and compare their popularity based on the collected data.
You can install pkgstats from the official Arch Linux repositories:
sudo pacman -Syu pkgstatsThe package will collect the list of your installed packages, your system's architecture, and the mirror you are using, and submit it to the pkgstats project. The data is sent anonymously.
You can also view the data that would be sent without actually submitting it:
pkgstats submit --dump-jsonYou can search for a package to see its popularity:
pkgstats search <package-name>Example:
pkgstats search firefoxYou can compare the popularity of multiple packages:
pkgstats show <package1> <package2> ...Example:
pkgstats show firefox chromiumYou can create a configuration file at /etc/pkgstats.yaml to filter packages and mirrors from being submitted.
Example configuration:
blocklist:
packages:
- "secret-*"
- "*-debug"
mirrors:
- "private.mirror.com"
- "*.internal.net"The packages and mirrors fields support glob patterns. For mirrors, the pattern is matched against the hostname of the mirror URL.
This project uses just as a command runner. To see all available commands, run:
justTo build pkgstats from source, you need to have go and just installed.
-
Clone the repository:
git clone https://github.com/pkgstats/pkgstats-cli.git cd pkgstats-cli -
Build the project:
just build
This will create a
pkgstatsbinary in the root directory.
The project has a comprehensive test suite that includes unit tests, integration tests, and static code analysis.
To run all static analysis checks, including formatting, vetting, and linting, run:
just lintTo run the unit tests, run:
just testThis will run all tests in the tests/ directory.
To generate a test coverage report, run:
just coverageThe project includes tests for different CPU architectures. To run them, you need to have docker and qemu installed.
just test-cross-platform: Runs unit tests on different CPU architectures.just test-build: Builds the project for different CPU architectures.just test-cpu-detection: Tests CPU architecture detection on different CPUs.just test-os-detection: Tests OS architecture detection on different CPUs.
To run the integration tests, you need to have docker installed. The integration tests run with a mocked API server.
just test-integrationTo run all available tests, including static analysis, unit tests, and integration tests, run:
just test-allThe justfile setup is modular to support different CPU architectures.
- The main
justfileimportsjust/dev.just, which contains the main development tasks. just/dev.justincludesjustfiles for each supported architecture (aarch64,arm,i686,loongarch64,riscv64,x86_64) using themodkeyword.- Each architecture-specific
justfile defines how to run tests and builds for that architecture usingqemu. - The cross-platform testing tasks in
just/dev.justiterate through all supported architectures and execute the corresponding tasks from the architecture-specificjustfiles.
The pkgstats project is structured as follows:
cmd/: Contains the command-line interface logic, using thecobralibrary. Each command has its own file.internal/: Contains the core logic of the application.api/: Handles communication with the pkgstats API.pacman/: Interacts with the pacman configuration to gather package information.system/: Gathers system information like CPU architecture.
main.go: The main entry point of the application.justfile: Contains thejustcommands for development and testing.tests/: Contains the unit and integration tests.