summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--data/lineageos_wiki/Makefile53
-rwxr-xr-xdata/lineageos_wiki/find_lineageos_devices.py122
-rwxr-xr-xdata/parse-partition-tables/parse_partition_tables.py3
-rw-r--r--patches/Makefile8
-rw-r--r--patches/README4
-rwxr-xr-xpatches/replicant_prepare_patch.py2
6 files changed, 160 insertions, 32 deletions
diff --git a/data/lineageos_wiki/Makefile b/data/lineageos_wiki/Makefile
new file mode 100644
index 0000000..5120e89
--- /dev/null
+++ b/data/lineageos_wiki/Makefile
@@ -0,0 +1,53 @@
+.PHONY: all check check-all check-replicant help clean
+
+PYTHON ?= python3
+LINEAGE_WIKI_PATH ?= lineage_wiki
+LINEAGE_WIKI_REV ?= 36f4ed8f3ead74e74f7b3740bd755cf43ae379c4
+
+all: help
+
+help:
+ @echo "Available targets:"
+ @echo "check # Run automatic tests."
+ @echo "replicant-devices # Print potential Replicant targets"
+ @echo "all-devices # Print all devices"
+
+all-devices: lineage_wiki_revision.txt
+ $(PYTHON) find_lineageos_devices.py lineage_wiki all
+
+replicant-devices: lineage_wiki_revision.txt
+ $(PYTHON) find_lineageos_devices.py lineage_wiki replicant
+
+clean:
+ rm -rf lineage_wiki
+
+$(LINEAGE_WIKI_PATH):
+ git clone https://github.com/LineageOS/lineage_wiki $(LINEAGE_WIKI_PATH)
+
+lineage_wiki_revision.txt: $(LINEAGE_WIKI_PATH) Makefile
+ if [ ! -f $@ ] || [ "`cat $@`" != "$(LINEAGE_WIKI_REV)" ] ; then \
+ rm -f lineage_wiki_revision.txt ; \
+ git -C $(LINEAGE_WIKI_PATH) fetch origin ; \
+ git -C $(LINEAGE_WIKI_PATH) checkout -f $(LINEAGE_WIKI_REV) ; \
+ git -C $(LINEAGE_WIKI_PATH) reset --hard ; \
+ git -C $(LINEAGE_WIKI_PATH) clean -dfx ; \
+ echo $(LINEAGE_WIKI_REV) > $@ ; \
+ fi
+
+check-replicant: lineage_wiki_revision.txt
+ @if $(PYTHON) find_lineageos_devices.py lineage_wiki \
+ >/dev/null; then \
+ echo "[ OK ] lineageos_devices.py lineage_wiki" ; \
+ else \
+ echo "[ !! ] lineageos_devices.py lineage_wiki" ; \
+ fi
+
+check-all: lineage_wiki_revision.txt
+ @if $(PYTHON) find_lineageos_devices.py lineage_wiki all \
+ >/dev/null; then \
+ echo "[ OK ] lineageos_devices.py lineage_wiki all" ; \
+ else \
+ echo "[ !! ] lineageos_devices.py lineage_wiki all" ; \
+ fi
+
+check: check-replicant check-all
diff --git a/data/lineageos_wiki/find_lineageos_devices.py b/data/lineageos_wiki/find_lineageos_devices.py
index 1e0509a..9fe0bd6 100755
--- a/data/lineageos_wiki/find_lineageos_devices.py
+++ b/data/lineageos_wiki/find_lineageos_devices.py
@@ -16,6 +16,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
+import copy
import os
import re
import sys
@@ -23,14 +24,40 @@ import yaml
basedir = '_data' + os.sep + 'devices'
results = {}
-last_lineageos_version = 17.1
+# Reference: https://en.wikipedia.org/wiki/LineageOS#Version_history
+last_lineageos_version = 21
+
+def get_devices(document):
+ if type(document['soc']) == str:
+ return [document]
+ # find7_variant{1,2}.yml and Z00{A,B}.yml have 2 SOCs (and
+ # variants) so we need to treat them as 2 devices.
+ elif type(document['soc']) == list:
+ devices = []
+ for soc in document['soc']:
+ device = copy.copy(document)
+ for key in ['codename', 'name']:
+ if key in document.keys():
+ device[key] = document[key] + ' (' + soc + ')'
+ if 'soc' in document.keys():
+ device['soc'] = soc
+ devices.append(device)
+ return devices
+ else:
+ assert(False)
+
+def protocol_supported(document, protocol):
+ if protocol in document['network']:
+ return True
+ else:
+ return False
-def still_supported(document):
- if not last_lineageos_version in document['versions']:
+def still_supported(device):
+ if not last_lineageos_version in device['versions']:
return False
- if 'channels' in document.keys() and 'discontinued' in document['channels']:
+ if 'channels' in device.keys() and 'discontinued' in device['channels']:
return False
- if 'maintainers' in document.keys() and len(document['maintainers']) == 0:
+ if 'maintainers' in device.keys() and len(device['maintainers']) == 0:
return False
return True
@@ -69,10 +96,32 @@ def device_has_shared_memory_between_modem_and_soc(vendor, product):
return None
def soc_has_modem(vendor, product):
- if vendor == 'HiSilicon':
+ if vendor == 'Amlogic' and product in ['S905x2', 'S905y2']:
+ # Reference:
+ # https://en.wikipedia.org/wiki/Amlogic#Media_player_SoCs_(S9_family_gen_2)
+ # doesn't says that S905y2 or S905x2 have modems and they are
+ # "Media player" SOCs anyway.
+ return False
+ elif vendor == 'Amlogic' and product in ['S905y3']:
+ # While at the time of writing, this SOC is not present in
+ # https://en.wikipedia.org/wiki/Amlogic#Media_player_SoCs_(S9_family_gen_2)
+ # , given the SOC namings, it's likely to also be a media
+ # player SOC and so to not contain a modem.
+ return False
+ elif vendor == 'Google' and product in ['Tensor GS101',
+ 'Tensor GS201',
+ 'Tensor G3']:
+ # Reference:
+ # https://en.wikipedia.org/wiki/Google_Tensor#Models says that
+ # the GS101 and GS201 have an Exynos modem inside.
+ return True
+ elif vendor == 'HiSilicon':
pass
elif vendor == 'Intel':
pass
+ elif vendor == 'Mediatek' and product in ['MT6768 Helio G85', 'MT6785 Helio G95']:
+ # Reference: https://en.wikipedia.org/wiki/List_of_MediaTek_systems_on_chips#Helio_G_Series_(2019%E2%80%93present)
+ return True
elif vendor in ['Nvidia', 'NVIDIA'] and re.search("^Tegra 4", product):
# The modem could be implemented in software
pass
@@ -80,6 +129,8 @@ def soc_has_modem(vendor, product):
pass
elif vendor in ['Nvidia', 'NVIDIA'] and re.search("^Tegra X1", product):
pass
+ elif vendor in ['Nvidia', 'NVIDIA'] and re.search("^Tegra X2", product):
+ pass
elif vendor == 'Qualcomm' and re.search("^MSM", product):
return True
elif vendor == 'Qualcomm' and re.search("^APQ", product) or re.search("^Snapdragon 600", product):
@@ -110,8 +161,11 @@ def soc_has_modem(vendor, product):
def parse_soc(soc):
soc_vendors = [
+ "Amlogic",
+ "Google",
"HiSilicon",
"Intel",
+ "Mediatek",
"NVIDIA",
"Nvidia",
"Qualcomm",
@@ -168,15 +222,15 @@ def battery_is_removable(battery):
print("TODO: Handle batteries where removable is \"{}\": {}".format(removable, battery))
sys.exit(1)
-def has_removable_battery(document):
+def has_removable_battery(device):
removable_battery = None
- if 'battery' not in document:
+ if 'battery' not in device:
# We don't know the policies reguarding incomplete data so the data
# may either be incomplete or the device may not have a battery.
print("TODO: Add support for devices lacking a battery")
sys.exit(1)
else:
- battery = document.get('battery')
+ battery = device.get('battery')
if type(battery) is not list:
return battery_is_removable(battery)
else:
@@ -209,7 +263,7 @@ def has_removable_battery(document):
print(" Add support for it in the parsing code")
sys.exit(1)
-def interesting_for_replicant(document):
+def interesting_for_replicant(device):
# For smartphones or tablets with a modem, since the modem is in
# the same SOC, we would need to do some extensive review of the SOC
# architecture to understand if the modem can be isolated with an IOMMU
@@ -218,12 +272,21 @@ def interesting_for_replicant(document):
# For devices without a modem, we would still need to make sure that the
# sound card and the microphone is completely under the control of free
# software and that there aren't too much proprietary libraries to replace
- soc = parse_soc(document['soc'])
+ soc = parse_soc(device['soc'])
if soc_has_modem(soc['vendor'], soc['product']) == True:
return False
- if device_has_shared_memory_between_modem_and_soc(document['vendor'],
- document['name']):
+ if device_has_shared_memory_between_modem_and_soc(device['vendor'],
+ device['name']):
+ return False
+
+ # The 2G and 3G procol families are being removed. Given how long
+ # it takes to add support for a device, it's not worth investing
+ # too much time in supporting devices without support for these
+ # protocols. Note that 4G LTE isn't telling if voice will work on
+ # 4G networks as this requires VoLTE.
+ if not protocol_supported(device, '4G LTE') and \
+ not protocol_supported(device, '5G NR'):
return False
# Non replaceable batteries causes too much issues for both users
@@ -245,21 +308,21 @@ def interesting_for_replicant(document):
#
# So for now we aproximate non-removable batteries to non-replaceable
# batteries until we find a way to deal with it.
- if document['type'] != 'Set top box' and not has_removable_battery(document):
+ if device['type'] != 'Set top box' and not has_removable_battery(device):
return False
return True
-def store_infos(results, document):
+def store_infos(results, device):
fields = ['vendor', 'name', 'type']
device_dict = {}
for field in fields:
- device_dict[field] = document[field]
+ device_dict[field] = device[field]
- device_dict['removable_battery'] = has_removable_battery(document)
+ device_dict['removable_battery'] = has_removable_battery(device)
- soc = document['soc']
+ soc = device['soc']
soc_data = parse_soc(soc)
soc_vendor = None
soc_product = None
@@ -285,23 +348,30 @@ def print_results(results):
print(" * {0}: {1} ({2})".format(
device['vendor'], device['name'], device['type']))
-def find_devices(path):
+def find_devices(path, device_types):
for filename in os.listdir(path + os.sep + basedir):
filepath = path + os.sep + basedir + os.sep + filename
if re.search("\.yml$", filepath):
yaml_file = open(filepath, 'r')
document = yaml.safe_load(yaml_file)
- if still_supported(document) and interesting_for_replicant(document):
- store_infos(results, document)
+ for device in get_devices(document):
+ if device_types == 'replicant':
+ if still_supported(device) and \
+ interesting_for_replicant(device):
+ store_infos(results, device)
+ elif device_types == 'all':
+ store_infos(results, device)
+
print_results(results)
def usage(argv0):
progname = os.path.basename(argv0)
- print("{} [path/to/lineage_wiki]".format(progname))
+ print("{} [path/to/lineage_wiki] [all|replicant]".format(progname))
sys.exit(1)
-if len(sys.argv) != 2:
+if len(sys.argv) not in [2, 3]:
usage(sys.argv[0])
-
-find_devices(sys.argv[1])
-
+elif len(sys.argv) == 2:
+ find_devices(sys.argv[1], 'replicant')
+elif len(sys.argv) == 3:
+ find_devices(sys.argv[1], sys.argv[2])
diff --git a/data/parse-partition-tables/parse_partition_tables.py b/data/parse-partition-tables/parse_partition_tables.py
index 784cfc5..3781562 100755
--- a/data/parse-partition-tables/parse_partition_tables.py
+++ b/data/parse-partition-tables/parse_partition_tables.py
@@ -29,7 +29,8 @@ def usage(progname):
def get_human_size(size):
size_names = {
- 1024*1024 : 'GiB',
+ 1024*1024*1024 : 'GiB',
+ 1024*1024 : 'MiB',
1024 : 'KiB',
}
diff --git a/patches/Makefile b/patches/Makefile
index 64a3f64..30c88ce 100644
--- a/patches/Makefile
+++ b/patches/Makefile
@@ -1,6 +1,10 @@
-DESTDIR ?= /usr/local/bin
+DESTDIR ?= /usr/local
INSTALL ?= install
.PHONY: install
install:
- $(INSTALL) -m 755 replicant_prepare_patch.py -t $(DESTDIR)
+ $(INSTALL) -D $(DESTDIR)/bin replicant_prepare_patch.py
+ $(INSTALL) -D $(DESTDIR)/share/doc/vendor_replicant-scripts/ COPYING
+ $(INSTALL) -D $(DESTDIR)/share/doc/vendor_replicant-scripts/ README
+ $(INSTALL) -D $(DESTDIR)/share/doc/vendor_replicant-scripts/ \
+ replicant_prepare_patch.conf
diff --git a/patches/README b/patches/README
index 5ccf0c4..7da120a 100644
--- a/patches/README
+++ b/patches/README
@@ -44,7 +44,7 @@ you want to contribute to, in your namespace on the Replicant git server.
For example I use GNUtoo as remote for the GNUtoo namespace:
$ git remote get-url GNUtoo
- ssh://git@git.replicant.us/GNUtoo/vendor_replicant-scripts.git
+ ssh://git@git.replicant.us/contrib/GNUtoo/vendor_replicant-scripts.git
Unfortunately, at this time it's not possible to configure the name of
that namespace for each individual repositories, as the code assume that
@@ -79,7 +79,7 @@ starting from the current HEAD we can use this command:
https://git.replicant.us/contrib/GNUtoo/vendor_replicant-scripts/commit/?id=5b6757fc6c6f852a4176bb7fc8f32e05c21f703f
And here's how to get it in a git repository:
- git clone https://git.replicant.us/GNUtoo/vendor_replicant-scripts
+ git clone https://git.replicant.us/contrib/GNUtoo/vendor_replicant-scripts
cd vendor_replicant-scripts
git show 5b6757fc6c6f852a4176bb7fc8f32e05c21f703f
diff --git a/patches/replicant_prepare_patch.py b/patches/replicant_prepare_patch.py
index f75b1ec..9e7f883 100755
--- a/patches/replicant_prepare_patch.py
+++ b/patches/replicant_prepare_patch.py
@@ -1,4 +1,4 @@
-#!/bin/env python
+#!/bin/env python3
# Copyright (C) 2020 Denis 'GNUtoo' Carikli <GNUtoo@cyberdimension.org>
#
# This program is free software: you can redistribute it and/or modify