diff --git a/recipes-bsp/early-date/early-date_1.bb b/recipes-bsp/early-date/early-date_1.bb new file mode 100644 index 0000000..a1b22d8 --- /dev/null +++ b/recipes-bsp/early-date/early-date_1.bb @@ -0,0 +1,23 @@ +DESCRIPTION = "Set an early date on RTC less systems" +LICENSE = "MIT" +LIC_FILES_CHKSUM = "file://${COREBASE}/LICENSE;md5=3f40d7994397109285ec7b81fdeb3b58" + +SRC_URI = "\ + file://early-date \ + file://early-date.service" + +FILES_${PN} = "${systemd_unitdir}/system /sbin" +RDPEPENDS_${PN} = "systemd" + +do_install() { + install -d ${D}/sbin + install -d ${D}${systemd_unitdir}/system/basic.target.wants + + # Copy the service file and link it + install -m 0644 ${WORKDIR}/early-date.service ${D}${systemd_unitdir}/system + ln -sf ../early-date.service ${D}${systemd_unitdir}/system/basic.target.wants/ + + # Hardcode to /sbin + # TODO: Set the date as of the build time.. + install -m 0755 ${WORKDIR}/early-date ${D}/sbin +} diff --git a/recipes-bsp/early-date/files/early-date b/recipes-bsp/early-date/files/early-date new file mode 100755 index 0000000..15a7bbb --- /dev/null +++ b/recipes-bsp/early-date/files/early-date @@ -0,0 +1,10 @@ +#!/bin/sh + +# Check if the year is lower than the lowest configured and then +# set a default date +YEAR=`date +%Y` + +if [ $YEAR -lt 2014 ]; then + date -s 2014.07.18-10:00:00 + hwclock -w +fi diff --git a/recipes-bsp/early-date/files/early-date.service b/recipes-bsp/early-date/files/early-date.service new file mode 100644 index 0000000..9e2bf87 --- /dev/null +++ b/recipes-bsp/early-date/files/early-date.service @@ -0,0 +1,14 @@ +[Unit] +Description=Early boot time for RTC less systems +DefaultDependencies=no +After=systemd-remount-fs.service +Before=sysinit.target + +[Service] +ExecStart=/sbin/early-date +RemainAfterExit=No +Type=oneshot +StandardOutput=syslog + +[Install] +WantedBy=basic.target