From c66ec8776ec6f467937918a114bdefa28ac036a9 Mon Sep 17 00:00:00 2001 From: Luca Fancellu Date: Wed, 18 Oct 2023 12:20:59 +0100 Subject: linuxptp: Use templates for the systemd services Use templates for the systemd services so that sbindir and sysconfdir can be written into them, improving portability. Pass sbindir with EXTRA_OEMAKE and remove 'prefix' which is redundant since we pass sbindir and mandir already. Signed-off-by: Luca Fancellu Signed-off-by: Khem Raj --- .../linuxptp/linuxptp/systemd/phc2sys@.service | 13 ------------- .../linuxptp/linuxptp/systemd/phc2sys@.service.in | 13 +++++++++++++ .../linuxptp/linuxptp/systemd/ptp4l@.service | 11 ----------- .../linuxptp/linuxptp/systemd/ptp4l@.service.in | 11 +++++++++++ meta-oe/recipes-connectivity/linuxptp/linuxptp_4.1.bb | 15 ++++++++++----- 5 files changed, 34 insertions(+), 29 deletions(-) delete mode 100644 meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/phc2sys@.service create mode 100644 meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/phc2sys@.service.in delete mode 100644 meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/ptp4l@.service create mode 100644 meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/ptp4l@.service.in diff --git a/meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/phc2sys@.service b/meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/phc2sys@.service deleted file mode 100644 index dd2512bdca..0000000000 --- a/meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/phc2sys@.service +++ /dev/null @@ -1,13 +0,0 @@ -[Unit] -Description=Synchronize system clock or PTP hardware clock (PHC) -Documentation=man:phc2sys -Requires=ptp4l.service -After=ptp4l.service -Before=time-sync.target - -[Service] -Type=simple -ExecStart=/usr/sbin/phc2sys -w -s %I - -[Install] -WantedBy=multi-user.target diff --git a/meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/phc2sys@.service.in b/meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/phc2sys@.service.in new file mode 100644 index 0000000000..f66dd2d010 --- /dev/null +++ b/meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/phc2sys@.service.in @@ -0,0 +1,13 @@ +[Unit] +Description=Synchronize system clock or PTP hardware clock (PHC) +Documentation=man:phc2sys +Requires=ptp4l.service +After=ptp4l.service +Before=time-sync.target + +[Service] +Type=simple +ExecStart=@SBINDIR@/phc2sys -w -s %I + +[Install] +WantedBy=multi-user.target diff --git a/meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/ptp4l@.service b/meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/ptp4l@.service deleted file mode 100644 index 1bad2d72df..0000000000 --- a/meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/ptp4l@.service +++ /dev/null @@ -1,11 +0,0 @@ -[Unit] -Description=Precision Time Protocol (PTP) service for %I -Documentation=man:ptp4l -After=sys-subsystem-net-devices-%i.device - -[Service] -Type=simple -ExecStart=/usr/sbin/ptp4l -f /etc/linuxptp/ptp4l.conf -i %I - -[Install] -WantedBy=multi-user.target diff --git a/meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/ptp4l@.service.in b/meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/ptp4l@.service.in new file mode 100644 index 0000000000..2502181412 --- /dev/null +++ b/meta-oe/recipes-connectivity/linuxptp/linuxptp/systemd/ptp4l@.service.in @@ -0,0 +1,11 @@ +[Unit] +Description=Precision Time Protocol (PTP) service for %I +Documentation=man:ptp4l +After=sys-subsystem-net-devices-%i.device + +[Service] +Type=simple +ExecStart=@SBINDIR@/ptp4l -f @SYSCONFDIR@/linuxptp/ptp4l.conf -i %I + +[Install] +WantedBy=multi-user.target diff --git a/meta-oe/recipes-connectivity/linuxptp/linuxptp_4.1.bb b/meta-oe/recipes-connectivity/linuxptp/linuxptp_4.1.bb index a92434385d..9a5c9b5204 100644 --- a/meta-oe/recipes-connectivity/linuxptp/linuxptp_4.1.bb +++ b/meta-oe/recipes-connectivity/linuxptp/linuxptp_4.1.bb @@ -10,8 +10,8 @@ LINUXPTP_SRC_URI = "http://sourceforge.net/projects/linuxptp" SRC_URI = "${LINUXPTP_SRC_URI}/files/v4.1/linuxptp-${PV}.tgz \ file://0001-include-string.h-for-strncpy.patch \ file://0002-linuxptp-Use-CC-in-incdefs.sh.patch \ - file://systemd/phc2sys@.service \ - file://systemd/ptp4l@.service \ + file://systemd/phc2sys@.service.in \ + file://systemd/ptp4l@.service.in \ " SRC_URI[md5sum] = "1db8699fc155965341759be5e5aad938" @@ -22,14 +22,15 @@ inherit systemd UPSTREAM_CHECK_URI = "${LINUXPTP_SRC_URI}/files/" UPSTREAM_CHECK_REGEX = "(?P\d+(\.\d+)+)/" -EXTRA_OEMAKE = "CC='${CC}' EXTRA_CFLAGS='${CFLAGS}' mandir='${mandir}'" +EXTRA_OEMAKE = "CC='${CC}' EXTRA_CFLAGS='${CFLAGS}' mandir='${mandir}' \ + sbindir='${sbindir}'" export KBUILD_OUTPUT="${RECIPE_SYSROOT}" LINUXPTP_SYSTEMD_SERVICES = "phc2sys@.service ptp4l@.service" do_install() { - oe_runmake install DESTDIR=${D} prefix=${prefix} + oe_runmake install DESTDIR=${D} # Install example configs from source tree install -d ${D}${docdir}/${PN} @@ -44,7 +45,11 @@ do_install() { # Install systemd services install -d ${D}/${systemd_unitdir}/system/ for service in ${LINUXPTP_SYSTEMD_SERVICES}; do - install -m 644 ${WORKDIR}/systemd/$service \ + sed -i -e 's,@SBINDIR@,${sbindir},g' \ + ${WORKDIR}/systemd/$service.in + sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \ + ${WORKDIR}/systemd/$service.in + install -m 644 ${WORKDIR}/systemd/$service.in \ ${D}/${systemd_unitdir}/system/$service done } -- cgit v1.2.3-54-g00ecf