Thanks to Joerg for pointing out pkg-nums.

I was pretty sure such a tool already existed but could not find it.

At least, my script (with Thomas’ amendments) allow distinctions between sections (free, contrib, non-free) ;-) And thanks to pkg-nums, I was able to check the results.