Amount of code developed by Purism for the Librem 5 phone

I was curious how much code Purism has developed for the Librem 5 phone, so I wrote a little Python script that downloads the source code from the projects that Purism started, runs the code through cloc to count lines of code, and then sums the total.

Here is what I get:

$ python3
Lines of code in Purism projects for the Librem 5:
	libhandy: 47730
	libadwaita: 51270
	calls: 20745
	chatty: 49661
	squeekboard: 17993
	libcall-ui: 4426
	phoc: 15277
	phosh: 48301
	feedbackd: 5970
	feedbackd-device-themes: 603
	gtherm: 1734
	haegtesse: 2105
	wys: 2442
Total lines of code: 268257

This excludes PO translation files and Markdown documentation files. Of course, a number of people outside of Purism have contributed to these projects, such as the GNOME community, Mobian, postmarketOS, etc., but I would guesstimate that to only be about 10% of the total. This only includes the projects that Purism created (although phoc and squeekboard did inherit some code from rootston and eekboard, respectively*). If we include all the code that Purism has contributed to other projects (such as the Linux kernel, wlroots, ModemManager, GeoClue, GTK, and roughly 20 GTK/GNOME apps), the total lines of code would be significantly higher.

Over a quarter of a million lines of code is a pretty big contribution to the Linux ecosystem. When we consider that Purism is providing a way for the GTK/GNOME ecosystem to run on mobile devices and Phosh is now packaged in most of the major distro families except Gentoo, Purism is making a significant contribution to Linux as a whole. Because of Purism’s dev work, Debian->Ubuntu->Mint, Fedora, openSUSE and Arch->Manjaro will be able to run on mobile devices that are supported by the Linux kernel.

Of course, KDE Plasma Mobile and Lomiri are working on the same goal, but Phosh got packaged faster in many of the major distros, because it was designed as a thin overlay on top of a desktop stack, so it is easier to integrate into the desktop distros. Even people who use desktop GTK/GNOME are seeing the benefits of libhandy/libadwaita since it makes their software more adaptive and touch-friendly. Calls and Chats/Chatty are also going to be useful for many desktop users as well.

I thought I would mention this, because I see a lot of people bashing Purism on the Purism forum and r/Purism lately, so it is important to keep in mind the positives, and not only focus on the negatives.

Below is the script, just in case anyone wants to run it in the future to see how much code has been added. If you want all the gory details, run it as:
python3 -d

# counts lines of code developed by Purism for the Librem 5
# Shows details from cloc with the "-d" option: python3 -d
# Author: Amos Batto <>
# License: public domain 
# Requires Python 3.6 or later. Needs the "cloc" package installed. In Debian family: sudo apt install cloc

import shutil, subprocess, tempfile, re, os, os.path, sys
from urllib.request import urlretrieve
from urllib.parse import urlparse

projectUrls = {
	"libhandy"   : "",
	"libadwaita" : "",
	"calls"      : "",
	"chatty"     : "",
	"squeekboard": "",
	"libcall-ui" : "",
	"phoc"       : "",
	"phosh"      : "",
	"feedbackd"  : "",
	"feedbackd-device-themes": "",
	"gtherm"     : "",
	"haegtesse"  : "",
	"wys"        : "" 

def main():
	print("Lines of code in Purism's projects for the Librem 5:")
	totalLoc = 0; #running total of lines of code
	for projName, projUrl in projectUrls.items():
		tmpDir = tempfile.mkdtemp(prefix="loc-")
		a = urlparse(projUrl) 
		compressedFilename = os.path.basename(a.path)
		pathToFileName = os.path.join(tmpDir, compressedFilename)  
		fileName, headers = urlretrieve(projUrl, filename = pathToFileName)
		#Get the LOC sum:
		output = subprocess.check_output(["cloc", "--exclude-lang=Markdown,PO File", fileName])
		found = r'^SUM:.*?\s+(\d+)$', output.decode('utf-8'), re.M)
		if found:
			loc = int(
			totalLoc += loc
			print(f"Error: no SUM of the lines of code in {projName}.")
		if "-d" in sys.argv[1:] :
			os.system("cloc --exclude-lang='PO File,Markdown' " + fileName); 
			print(f"\t{projName}: {loc}")
	print("Total lines of code: " + str(totalLoc));
if __name__ == "__main__":

* The Purism devs posted graphs of when lines of code were added to phoc and to squeekboard. Eyeballing those two graphs, it looks like roughly 25% (4.5/18) of phoc’s code comes from rootston and 9% (1/11) of squeekboard’s code comes from eekboard.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s