I got curious how much code Purism has developed for the Librem 5, so I wrote a little Python script to download the source code from the projects that Purism has created and run it through cloc
and then sum the total.
So here is what I get:
$ python3 locPurism.py
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. We also have to take into account the code that Purism has contributed to other projects (Linux kernel, wlroots, GTK and roughly 20 GTK/GNOME apps).
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 nearly every major distro family except Gentoo, Purism is making a huge 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 the major distros, because it was designed as a thin overlay on top of a desktop stack, so it is easier to integrate in the desktop distros. Even people who use desktop GTK/GNOME are seeing the benefits of libhandy/libadwaita. 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 this forum 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 locPurism.py -d
# locPurism.py counts lines of code developed by Purism for the Librem 5
#
# Author: Amos Batto <amosbatto@yahoo.com>
# 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" : "https://gitlab.gnome.org/GNOME/libhandy/-/archive/master/libhandy-master.tar.bz2",
"libadwaita" : "https://gitlab.gnome.org/GNOME/libadwaita/-/archive/main/libadwaita-main.tar.bz2",
"calls" : "https://gitlab.gnome.org/GNOME/calls/-/archive/master/calls-master.tar.bz2",
"chatty" : "https://source.puri.sm/Librem5/chatty/-/archive/master/chatty-master.tar.bz2",
"squeekboard": "https://gitlab.gnome.org/World/Phosh/squeekboard/-/archive/master/squeekboard-master.tar.bz2",
"libcall-ui" : "https://gitlab.gnome.org/World/Phosh/libcall-ui/-/archive/main/libcall-ui-main.tar.bz2",
"phoc" : "https://gitlab.gnome.org/World/Phosh/phoc/-/archive/master/phoc-master.tar.bz2",
"phosh" : "https://gitlab.gnome.org/World/Phosh/phosh/-/archive/main/phosh-main.tar.bz2",
"feedbackd" : "https://source.puri.sm/Librem5/feedbackd/-/archive/master/feedbackd-master.tar.bz2",
"feedbackd-device-themes": "https://source.puri.sm/Librem5/feedbackd-device-themes/-/archive/master/feedbackd-device-themes-master.tar.bz2",
"gtherm" : "https://source.puri.sm/Librem5/gtherm/-/archive/master/gtherm-master.tar.bz2",
"haegtesse" : "https://source.puri.sm/Librem5/haegtesse/-/archive/master/haegtesse-master.tar.bz2",
"wys" : "https://source.puri.sm/Librem5/wys/-/archive/master/wys-master.tar.bz2"
}
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 = re.search( r'^SUM:.*?\s+(\d+)$', output.decode('utf-8'), re.M)
if found:
loc = int(found.group(1))
totalLoc += loc
else:
print(f"Error: no SUM of the lines of code in {projName}.")
sys.exit();
if "-d" in sys.argv[1:] :
print(projName)
os.system("cloc --exclude-lang='PO File,Markdown' " + fileName);
print('');
else:
print(f"\t{projName}: {loc}")
shutil.rmtree(tmpDir)
print("Total lines of code: " + str(totalLoc));
if __name__ == "__main__":
main()