diff --git a/classes/systimemgrconfig.bbclass b/classes/systimemgrconfig.bbclass new file mode 100644 index 00000000..1cb70d11 --- /dev/null +++ b/classes/systimemgrconfig.bbclass @@ -0,0 +1,61 @@ +# Generates /etc/systimemgr.conf based on active override. +# +# Supported overrides: +# - ntp-dtt-rdkdefault +# - ntp-dtt-drm-tee + +python create_systimemgrconfig() { + import os + + overrides = (d.getVar("OVERRIDES", True) or "").split(":") + rootfs_dir = d.getVar("IMAGE_ROOTFS", True) + + content = None + remove_secure_conf = False + + if "ntp-dtt-drm-tee" in overrides: + content = """timesrc ntp /ntp +timesrc dtt /dtt +timesrc drm /drm +timesync tee /tee +""" + remove_secure_conf = True + elif "ntp-dtt-rdkdefault" in overrides: + content = """timesrc ntp /ntp +timesrc dtt /dtt +timesync rdkdefault /clock_time +""" + + if content is None: + bb.note("No supported systimemgr override active; skipping systimemgr.conf generation") + return + + dest_dir = os.path.join(rootfs_dir, "etc") + os.makedirs(dest_dir, exist_ok=True) + + dest_path = os.path.join(dest_dir, "systimemgr.conf") + with open(dest_path, "w", encoding="utf-8") as f: + f.write(content) + + os.chmod(dest_path, 0o644) + + if remove_secure_conf: + secure_conf = os.path.join( + rootfs_dir, + "lib", + "systemd", + "system", + "systimemgr.service.d", + "secure.conf" + ) + + if os.path.exists(secure_conf): + os.remove(secure_conf) + + service_dir = os.path.dirname(secure_conf) + if os.path.isdir(service_dir) and not os.listdir(service_dir): + os.rmdir(service_dir) +} + +create_systimemgrconfig[vardepsexclude] += "DATETIME" +ROOTFS_POSTPROCESS_COMMAND += 'create_systimemgrconfig; ' diff --git a/conf/include/image-classes.inc b/conf/include/image-classes.inc index 99f81836..1bb354ed 100644 --- a/conf/include/image-classes.inc +++ b/conf/include/image-classes.inc @@ -25,3 +25,6 @@ IMAGE_CLASSES += "mediariteproductconfig" # /etc/rfcdefaults/socprovisioning.ini IMAGE_CLASSES += "socprovisioning-config" + +#/etc/systimemgr.conf +IMAGE_CLASSES += "systimemgrconfig"