Display package names with the number of files associated with them for a given Debian mirror and architecture.
This command line tool downloads and parses the Debian Contents file to calculate the package statistics.
- Python 3.x
Before installing the CLI, you will need poetry or you can call the package_statistics/main.py
file directly.
To install it, enter the repository and run poetry install
.
After that, you can call the CLI with poetry run package_statistics
or run poetry shell
and then package statistics
.
usage: package_statistics [-h] [-u] [-m MIRROR] [-n NUMBER_OF_PACKAGES] arch
positional arguments:
arch The binary architecture or the pseudo-architecture of the Debian system (e.g. amd64, arm64, mips).
optional arguments:
-h, --help show this help message and exit
-u, --udeb To search for udeb instead of normal Contents file.
-m MIRROR, --mirror MIRROR
The mirror to search for the Contents file. Default is http://ftp.uk.debian.org/debian/dists/stable/main.
-n NUMBER_OF_PACKAGES, --number-of-packages NUMBER_OF_PACKAGES
The number of packages to display. Default is 10.
package_statistics amd64
or
python package_statistics/main.py amd64
Results:
package name number of files
devel/piglit 51784
science/esys-particle 18015
libdevel/libboost1.74-dev 14332
math/acl2-books 12668
golang/golang-1.15-src 9015
libdevel/liboce-modeling-dev 7457
net/zoneminder 7002
libdevel/paraview-dev 6178
kernel/linux-headers-5.10.0-20-amd64 6162
kernel/linux-headers-5.10.0-18-amd64 6156
It took me approximetly 5 hours to deliver this project.
My approach to the problem was:
- Read about the format of a Contents file.
- Created a base project with poetry and static code linter.
- Created the base structure of a command-line program that was able to receive arguments, download a file, extract that file, and print the result.
- Implemented the download file method and the Gz extract file methods.
- Implemented the Contents file parser method and the function to sort and print the packages with most files associated with.
- Added the command-line arguments and construct the URL of the Contents file based on the architecture and the Debian mirror.
- Added new arguments to allow the user to specify a different Debian mirror or different number of packages to display.
- Added unit tests for the core methods.
- Read about the format of a Contents file again to guarantee that everything is right.
- Created this README.
To run the tests, simply run the command:
make tests
To run the code linter, simply run the command:
make code_review