deviceinfo: add and require _codename (!1732)

deviceinfo_codneame holds the device's code name, so we can easily look
it up in the finished postmarketOS installation by reading
/etc/deviceinfo.

Related: postmarketOS/pmaports#157
This commit is contained in:
Luca Weiss 2018-12-25 17:59:18 +01:00 committed by Oliver Smith
parent 23df933db4
commit 747ccfdd75
No known key found for this signature in database
GPG Key ID: 5AE7F5513E0885CB
3 changed files with 9 additions and 0 deletions

View File

@ -127,6 +127,7 @@ def generate_deviceinfo_fastboot_content(args, bootimg=None):
def generate_deviceinfo(args, pkgname, name, manufacturer, arch, has_keyboard,
has_external_storage, flash_method, bootimg=None):
codename = "-".join(pkgname.split("-")[1:])
# Note: New variables must be added to pmb/config/__init__.py as well
content = """\
# Reference: <https://postmarketos.org/deviceinfo>
@ -135,6 +136,7 @@ def generate_deviceinfo(args, pkgname, name, manufacturer, arch, has_keyboard,
deviceinfo_format_version="0"
deviceinfo_name=\"""" + name + """\"
deviceinfo_manufacturer=\"""" + manufacturer + """\"
deviceinfo_codename=\"""" + codename + """\"
deviceinfo_date=""
deviceinfo_dtb=""
deviceinfo_modules_initfs=""

View File

@ -225,6 +225,7 @@ deviceinfo_attributes = [
"format_version",
"name",
"manufacturer",
"codename",
"date",
"dtb",
"modules_initfs",

View File

@ -42,6 +42,12 @@ def sanity_check(info, path):
" delete the deviceinfo_msm_refresher line in: " +
path)
# "codename" is required
codename = os.path.basename(os.path.dirname(path)).replace("device-", "")
if "codename" not in info or info["codename"] != codename:
raise RuntimeError("Please add 'deviceinfo_codename=\"" + codename +
"\"' to: " + path)
def deviceinfo(args, device=None):
"""