New to Linux and the open source world? We have compiled a huge list of resources to help you go through Linux and its distributions. Visit the full Linux guide page right now.
Whether it was for research purposes, or just general curiosity to know which packages and repositories are more popular than the others on Ubuntu, you may would like to find the download statistics of a certain package from an Ubuntu PPA (personal package archive). Luckily, we have a good way for you to do this in a matter of minutes.
For those who do not know; a PPA is a package repository that is hosted on Launchpad.net, which is an online system built mainly to serve Ubuntu and its infrastructure. Launchpad hosts these repositories and allows anybody to create a free PPA for his own usage any time he wants.
We’ll together learn how to get the download stats of a certain package in a certain PPA we are interested in.
Getting Download Statistics of a PPA
Launchpad provides a public API which allows you (even if you were a non-logged-in user or non-registered) to get the download statistics of any PPA you want from Launchpad. So, if you just write a small script to run the API aganist a specific package from the PPA you want, the task is easily done.
Thankfully, many people have done this in the past. One of the best tools we found was the “PPAstats” tool developed by Jean-Philippe Orsini. It’s a simple tool to generate a full HTML report about a specific PPA showing the download counts per day, per package, per version for any repository you want.
Here’s how a report looks like:
The installation instructions are available in the project’s web page. Sadly, the Ubuntu package is only available up to Ubuntu 16.04, so to install the tool, you’ll need to compile it from the source code on your own distribution.
This isn’t hard, you just need to download he latest source code (since 2016, it’s ppastats-1.3.3.tar.gz) and work on it. The main thing that I found during compilation is that there’s a missing line in the src/pstr.c file, line 21, you need to add this there:
Then, in the main project directory, you should be able to run:
./configure make sudo make install
And debug your way all along and install the needed dependencies yourself. On my Ubuntu 18.04 LTS installation, I found that I needed the following packages: libjson-c-dev libjson-c3:i386 ocaml-base-nox libreact-ocaml libresult-ocaml libev4 liblwt-ocaml libcurl-ocaml libcurlpp0 libcurl3-nss libcurl4-gnutls-dev libcurlpp-dev.
After you install the tool, to generate a report, you should run the following command:
ppastats -o output/ jfi ppastats
Replace output/ with the name of the folder to which the HTML report and its assets should be generated, replace jfi with the owner name of the PPA, and ppastats with the PPA name.
After it’s finished, you should get these files in the output folder, open the main index.html in a browser to see the report. Then you can read the statistics from there.
Important Note: Many developers don’t rebuild packages for different Ubuntu versions, but rather, build it just once for one Ubuntu version (e.g 18.10) and then copy the binaries into the other versions branches. This causes you to be unable to see the number of downloads per different Ubuntu versions, because they all would be the same number (or very similar), so be careful about that.
I asked about it while I was looking for my PPA download statistics and this was the answer:
Launchpad is only able to gather statistics from observing which files apt downloads. This means that if the same binary has been copied between series or architectures it’s not possible for Launchpad to distinguish which series or architecture the download should be attributed to. Internally, each binary file maps to a unique bucket, but many binary_
package_ publishing_ history objects on the API may map to the same bucket if they represent the same file.
So each download counts in exactly one number, but that number may be returned by multiple BPPHs if you’ve copied binaries between series or if the binary is architecture-
So don’t turn mad why sometimes, some numbers may not make sense.
It’s also worth to note that the Launchpad infrastructure is very unstable; Sometimes you would receive a 503 error when you try to use the tool to get your stats aganist big PPAs/daily updated PPAs. This isn’t just about the Launchpad API, but even the website itself usually returns 503 errors when navigating it from time to time.. So you need to be patient and try in times of night when there’s less load.
You may also try to use this small Python script to do the task. First you need to install the launchpadlib package via pip for Python:
pip install launchpadlib
Then, save the Python script into a file called ppa.py, and run the script like this to get the download stats:
mhsabbagh@mysimplepc:~$ python ppa.py -p green-recorder -s bionic -a amd64 fossproject/ppa green-recorder bionic amd64 9465
Of course, the output is just the number of downloads per series and architecture, but you may use it if you just want to get that, or if the PPAstats isn’t working well with you. Replace the given arguments according to your needs.
PPAstats is a very nice tool to get a visualized report about the download statistics you want for any Ubuntu PPA. Apart from the installation method, everything is so easy to get using the tool. You are now able to find the download stats of any PPA you want.
If you have found some interesting results, something like a comparison between Kubuntu & Xubuntu repositories, then share them with us in the comments!