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 pkgstats
The 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-json
You can search for a package to see its popularity:
pkgstats search <package-name>
Example:
pkgstats search firefox
You can compare the popularity of multiple packages:
pkgstats show <package1> <package2> ...
Example:
pkgstats show firefox chromium
This project uses just
as a command runner. To see all available commands, run:
just
To 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
pkgstats
binary 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 lint
To run the unit tests, run:
just test
This will run all tests in the tests/
directory.
To generate a test coverage report, run:
just coverage
The 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-integration
To run all available tests, including static analysis, unit tests, and integration tests, run:
just test-all
The justfile
setup is modular to support different CPU architectures.
- The main
justfile
importsjust/dev.just
, which contains the main development tasks. just/dev.just
includesjust
files for each supported architecture (aarch64
,arm
,i686
,loongarch64
,riscv64
,x86_64
) using themod
keyword.- Each architecture-specific
just
file defines how to run tests and builds for that architecture usingqemu
. - The cross-platform testing tasks in
just/dev.just
iterate through all supported architectures and execute the corresponding tasks from the architecture-specificjust
files.
The pkgstats
project is structured as follows:
cmd/
: Contains the command-line interface logic, using thecobra
library. 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 thejust
commands for development and testing.tests/
: Contains the unit and integration tests.