In about two months, that will be the sixth anniversary as Gentoo user for me, but I just realized that I could plot the number of installed packages over time since the first package was installed.

Gentoo Portage maintains /var/log/emerge.log, everything is written in it since Gentoo was first installed, I wrote gentoo-numbers-packages.py to plot the following chart using that log file:

https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsaQjr57SrT0lZzhWImKqMiMk8o9iROlP9vlJiltOWeIXlT0OmyXwGz_FpPodZvcE77tUG0PC5ILrkDjRWrs-Tlh0koNUikHGYIIXI_E9VzsOHZO146k6Y5jakL8ya0hhHtUEno5L7gVQ/s640/gentoo-numbers-packages.png

There is a big issue, there are 31 entries in my log causing KeyError and ValueError. They mean either the package or the version has not been merged before a unmerge success log entry. I don’t know how that happens, but I think they could be installed via the stage tarball, they were copied onto the system, not installed via emerge, therefore the log doesn’t contain any merging logs.

If you know what’s going on and have a correct fix, please do let me know. I might extract the script from the Gist, so you could fork it cleaner.

The other thing is, the numbers since quite different as shown below.

command packages by versions
equery l '*' | wc -l 975  
EIX_LIMIT_COMPACT=1 eix -Ic 960  
gentoo-numbers-packages.py 1016 1226

I am not sure how equery and eix counts the packages, but I believe eix doesn’t count each version into the number of packages. It seems to merge all versions and slots into one count, and maybe also not count the obsolete packages.

If I ran eix -ic, it reported only 12 packages had more than one version installed, I have no idea where the 1226-1016=210 extra versions come from. Anyway, I don’t really mind the issue, all I want to see a graph, even it’s not completely accurate, a line indicating the installed packages, and I do have one now.

The script works on both Python 2 and 3. Beside the counting part, the most interesting is the package Names and Versions specification, I didn’t write the regular expression, I just copied from Package Manager Specification (eapi-5-approved-2012-09-20), and pieced them together with slight modifications.

I wouldn’t know about Package Manager Specification if I didn’t stumble on a forum post, glad I still remember it or I might not ever work out a correct regular expression by myself.