ptp4l: new package
PATCH 1/1 ptp4l: new package
Add the Linux PTP Project package, aka ptp4l.
http://linuxptp.sourceforge.net/
The sysV and systemd init scripts start the daemon in automatic mode on eth0.
--- package/Config.in | 1 + package/ptp4l/Config.in | 13 +++++++++++++ package/ptp4l/S65ptp4l | 29 +++++++++++++++++++++++++++++ package/ptp4l/ptp4l.hash | 2 ++ package/ptp4l/ptp4l.mk | 37 +++++++++++++++++++++++++++++++++++++ package/ptp4l/ptp4l.service | 10 ++++++++++ 6 files changed, 92 insertions(+) create mode 100644 package/ptp4l/Config.in create mode 100755 package/ptp4l/S65ptp4l create mode 100644 package/ptp4l/ptp4l.hash create mode 100644 package/ptp4l/ptp4l.mk create mode 100644 package/ptp4l/ptp4l.service
package/Config.in +1 -0
@@ -1660,6 +1660,7 @@ endif source "package/proxychains-ng/Config.in" source "package/ptpd/Config.in" source "package/ptpd2/Config.in" + source "package/ptp4l/Config.in" source "package/pure-ftpd/Config.in" source "package/putty/Config.in" source "package/quagga/Config.in"
package/ptp4l/Config.in new file +13 -0
@@ -0,0 +1,13 @@ +config BR2_PACKAGE_PTP4L + bool "ptp4l / Linux PTP" + help + The Linux PTP Project is the Precision Time Protocol implementation + according to IEEE standard 1588 for Linux. + + The dual design goals are to provide a robust implementation of the + standard and to use the most relevant and modern Application + Programming Interfaces (API) offered by the Linux kernel. Supporting + legacy APIs and other platforms is not a goal. + + http://linuxptp.sourceforge.net/ +
package/ptp4l/S65ptp4l new file +29 -0
@@ -0,0 +1,29 @@ +#!/bin/sh +# +# Start ptp4l +# + +case "$1" in + start) + printf "Starting ptp4l: " + start-stop-daemon -S -b -q -x /usr/sbin/ptp4l -- -A -i eth0 + if [ $? != 0 ]; then + echo "FAILED" + exit 1 + else + echo "OK" + fi + ;; + stop) + printf "Stopping ptp4l: " + start-stop-daemon -K -q -x /usr/sbin/ptp4l + echo "OK" + ;; + restart|reload) + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 +esac + +exit $?
package/ptp4l/ptp4l.hash new file +2 -0
@@ -0,0 +1,2 @@ +# Locally computed: +sha256 fa8e00f6ec73cefa7bb313dce7f60dfe5eb9e2bde3353594e9ac18edc93e5165 linuxptp-1.8.tgz
package/ptp4l/ptp4l.mk new file +37 -0
@@ -0,0 +1,37 @@ +################################################################################ +# +# ptp4l +# +################################################################################ + +PTP4L_VERSION = 1.8 +PTP4L_SOURCE = linuxptp-$(PTP4L_VERSION).tgz +PTP4L_SITE = http://sourceforge.net/projects/linuxptp/files/v$(PTP4L_VERSION) +PTP4L_LICENSE = GPLv2 +PTP4L_LICENSE_FILES = COPYING +PTP4L_CFLAGS = $(TARGET_CFLAGS) + + +define PTP4L_BUILD_CMDS + $(TARGET_MAKE_ENV) $(MAKE) KBUILD_OUTPUT=$(TARGET_DIR) CC=$(TARGET_CC) EXTRA_CFLAGS="$(PTP4L_CFLAGS)" -C $(@D) all +endef + +define PTP4L_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) prefix=$(TARGET_DIR)/usr $(TARGET_CONFIGURE_OPTS) -C $(@D) install +endef + +define PTP4L_INSTALL_INIT_SYSV + $(INSTALL) -m 755 -D $(@D)/package/ptp4l/S65ptp4l \ + $(TARGET_DIR)/etc/init.d/S65ptp4l +endef + +define PTP4L_INSTALL_INIT_SYSTEMD + $(INSTALL) -D -m 644 $(PTP4L_PKGDIR)/ptp4l.service \ + $(TARGET_DIR)/usr/lib/systemd/system/ptp4l.service + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + ln -sf ../../../../usr/lib/systemd/system/ptp4l.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/ptp4l.service +endef + +$(eval $(generic-package)) +
package/ptp4l/ptp4l.service new file +10 -0
@@ -0,0 +1,10 @@ +[Unit] +Description=Precision Time Protocol daemon +After=syslog.target network.target + +[Service] +ExecStart=/usr/sbin/ptp4l -A -i eth0 +Restart=always + +[Install] +WantedBy=multi-user.target
Signature · 1 line
2.7.4
PATCH 1/1 ptp4l: new package
Hello Petr,
Thanks for this contribution! Looks mostly good, just a few comments, see below.
Quoted 6 lines · Petr Kulhavy
package/Config.in | 1 + package/ptp4l/Config.in | 13 +++++++++++++ package/ptp4l/S65ptp4l | 29 +++++++++++++++++++++++++++++ package/ptp4l/ptp4l.hash | 2 ++ package/ptp4l/ptp4l.mk | 37 +++++++++++++++++++++++++++++++++++++ package/ptp4l/ptp4l.service | 10 ++++++++++
Could you add yourself to the DEVELOPERS file for this package?
package/ptp4l/Config.in line 2
Quoted 8 lines
package/ptp4l/Config.in new file +2
-0@@ -0,0 +1,13 @@ +config BR2_PACKAGE_PTP4L + bool "ptp4l / Linux PTP"
Just:
bool "ptp4l"
package/ptp4l/Config.in line 13
Quoted 11 lines
package/ptp4l/Config.in new file +11
-0+ help + The Linux PTP Project is the Precision Time Protocol implementation + according to IEEE standard 1588 for Linux. + + The dual design goals are to provide a robust implementation of the + standard and to use the most relevant and modern Application + Programming Interfaces (API) offered by the Linux kernel. Supporting + legacy APIs and other platforms is not a goal. + + http://linuxptp.sourceforge.net/ +
Unneeded empty new line.
package/ptp4l/Config.in
Quoted 10 lines
package/ptp4l/Config.in new file +10
-0+case "$1" in + start) + printf "Starting ptp4l: " + start-stop-daemon -S -b -q -x /usr/sbin/ptp4l -- -A -i eth0 + if [ $? != 0 ]; then + echo "FAILED" + exit 1 + else + echo "OK" + fi
Use:
[ $? = 0 ] && echo "OK" || echo "FAIL"
Also, please specify a PID file using:
-p /var/run/ptp4l.pid
package/ptp4l/Config.in
Quoted 3 lines
package/ptp4l/Config.in new file +3
-0+ stop) + printf "Stopping ptp4l: " + start-stop-daemon -K -q -x /usr/sbin/ptp4l
And use the PID file here as well.
package/ptp4l/Config.in
Quoted 2 lines
package/ptp4l/Config.in new file +2
-0+ restart|reload) + ;;
Nothing?
package/ptp4l/Config.in
Quoted 4 lines
package/ptp4l/Config.in new file +4
-0+PTP4L_VERSION = 1.8 +PTP4L_SOURCE = linuxptp-$(PTP4L_VERSION).tgz +PTP4L_SITE = http://sourceforge.net/projects/linuxptp/files/v$(PTP4L_VERSION) +PTP4L_LICENSE = GPLv2
You should use SPDX license code, so instead of GPLv2 it should be GPL-2.0.
However, after checking the actual tarball, it seems like the license is GPL-2.0+ (i.e GPLv2 or later).
package/ptp4l/Config.in
Quoted 2 lines
package/ptp4l/Config.in new file +2
-0+PTP4L_LICENSE_FILES = COPYING +PTP4L_CFLAGS = $(TARGET_CFLAGS)
Why is this variable useful?
package/ptp4l/Config.in
Quoted 2 lines
package/ptp4l/Config.in new file +2
-0+ +
One too many empty new line.
package/ptp4l/Config.in
Quoted 2 lines
package/ptp4l/Config.in new file +2
-0+define PTP4L_BUILD_CMDS + $(TARGET_MAKE_ENV) $(MAKE) KBUILD_OUTPUT=$(TARGET_DIR) CC=$(TARGET_CC) EXTRA_CFLAGS="$(PTP4L_CFLAGS)" -C $(@D) all
Just use TARGET_CFLAGS instead of PTP4L_CFLAGS.
Also, split this line that is a bit too long.
What is KBUILD_OUTPUT used for ?
package/ptp4l/Config.in
Quoted 4 lines
package/ptp4l/Config.in new file +4
-0+endef + +define PTP4L_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) prefix=$(TARGET_DIR)/usr $(TARGET_CONFIGURE_OPTS) -C $(@D) install
Please use instead:
prefix=/usr DESTDIR=$(TARGET_DIR)
Why are you passing TARGET_CONFIGURE_OPTS at install time and not build time ?
Quoted 7 lines
package/ptp4l/Config.in new file +7
-0+endef + +define PTP4L_INSTALL_INIT_SYSV + $(INSTALL) -m 755 -D $(@D)/package/ptp4l/S65ptp4l \ + $(TARGET_DIR)/etc/init.d/S65ptp4l +endef +
package/ptp4l/Config.in
Quoted 10 lines
package/ptp4l/Config.in new file +10
-0+define PTP4L_INSTALL_INIT_SYSTEMD + $(INSTALL) -D -m 644 $(PTP4L_PKGDIR)/ptp4l.service \ + $(TARGET_DIR)/usr/lib/systemd/system/ptp4l.service + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + ln -sf ../../../../usr/lib/systemd/system/ptp4l.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/ptp4l.service +endef + +$(eval $(generic-package)) +
Useless empty new line.
Final questions/comments:
- Why is your package named ptp4l and not linuxptp like the upstream tarball/project ?
- Make sure to run support/scripts/check-package (to verify that there are no coding style issues in your package) and support/scripts/test-pkg (to make sure your package builds fine with all toolchains).
Thanks a lot!
Thomas
Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons Embedded Linux and Kernel engineering http://free-electrons.com
PATCH 1/1 ptp4l: new package
Hi Thomas,
thank you for your review, I will do the corrections as per your suggestions and submit a new version of the patch.
Regarding the name you are correctly pointing out that the official web is called "Linux PTP Package".
However there are several other PTP implementations for Linux (ptpd, ptpd2) and in this context I find the name a bit too generic. So I named the package after the "ptp4l" daemon, which is also the name used by few others to refer this package (e.g. Redhat or some conferences about PTP).
I'm however a bit undecided which name is better...
Quoted 14 lines · Thomas Petazzoni
package/ptp4l/ptp4l.mk line 12
Quoted 2 lines · Petr Kulhavy
package/ptp4l/ptp4l.mk new file +2
-0+PTP4L_LICENSE_FILES = COPYING +PTP4L_CFLAGS = $(TARGET_CFLAGS)Why is this variable useful?
What is
KBUILD_OUTPUTused for ?package/ptp4l/ptp4l.mk line 20
Quoted 4 lines
package/ptp4l/ptp4l.mk new file +4
-0+endef + +define PTP4L_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) prefix=$(TARGET_DIR)/usr $(TARGET_CONFIGURE_OPTS) -C $(@D) installPlease use instead:
Quoted 4 lines
prefix=/usr DESTDIR=$(TARGET_DIR)Why are you passing
TARGET_CONFIGURE_OPTSat install time and not build time ?
This is due to the unfortunate way the package's makefile is build:
The makefile calls the script incdefs.sh to detect some features and set the corresponding -Dxxxx flags in CFLAGS .
Unless KBUILD_OUTPUT is set the script searches in /usr/include, i.e. on host machine.
The makefile constructs its own CFLAGS based on the above and the environment CFLAGS are expected to be in EXTRA_CFLAGS.
So if CFLAGS are set on the make's command-line make doesn't call the incdefs.sh script and the detection and possibly the compilation fails.
That's why I couldn't use the TARGET_CONFIGURE_OPTS for the build phase. However I left it as standard for the install phase.
I'm not sure if what I did is 100% clean, but it seems to work :-)
Petr
PATCH 1/1 ptp4l: new package
In reply to Petr KulhavyPetr,
On Tue, May 9, 2017 at 5:42 AM, Petr Kulhavy <[email protected]> wrote:
<snip>
package/ptp4l/ptp4l.mk line 17
Quoted 6 lines
package/ptp4l/ptp4l.mk new file +6
-0+PTP4L_CFLAGS = $(TARGET_CFLAGS) + + +define PTP4L_BUILD_CMDS + $(TARGET_MAKE_ENV) $(MAKE) KBUILD_OUTPUT=$(TARGET_DIR) CC=$(TARGET_CC) EXTRA_CFLAGS="$(PTP4L_CFLAGS)" -C $(@D) all +endef
Perhaps you should add EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" as well. (In addition to eliminating PTP4L_CFLAGS and using EXTRA_CFLAGS="$(TARGET_CFLAGS)" instead,)
FWIW: changing the name to linuxptp: +1
Danomi -
Quoted 43 lines
package/ptp4l/ptp4l.mk new file +20
-0+ +define PTP4L_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) prefix=$(TARGET_DIR)/usr $(TARGET_CONFIGURE_OPTS) -C $(@D) install +endef + +define PTP4L_INSTALL_INIT_SYSV + $(INSTALL) -m 755 -D $(@D)/package/ptp4l/S65ptp4l \ + $(TARGET_DIR)/etc/init.d/S65ptp4l +endef + +define PTP4L_INSTALL_INIT_SYSTEMD + $(INSTALL) -D -m 644 $(PTP4L_PKGDIR)/ptp4l.service \ + $(TARGET_DIR)/usr/lib/systemd/system/ptp4l.service + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + ln -sf ../../../../usr/lib/systemd/system/ptp4l.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/ptp4l.service +endef + +$(eval $(generic-package)) +package/ptp4l/ptp4l.service new file +10
-1@@ -0,0 +1,10 @@ +[Unit] +Description=Precision Time Protocol daemon +After=syslog.target network.target + +[Service] +ExecStart=/usr/sbin/ptp4l -A -i eth0 +Restart=always + +[Install] +WantedBy=multi-user.target --2.7.4
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot
PATCH 1/1 ptp4l: new package
Thanks, Danomi!
Petr
Quoted 62 lines · Danomi Manchego
Petr,
On Tue, May 9, 2017 at 5:42 AM, Petr Kulhavy <[email protected]> wrote:
<snip>package/ptp4l/ptp4l.mk line 17
Quoted 6 lines
package/ptp4l/ptp4l.mk new file +6
-0+PTP4L_CFLAGS = $(TARGET_CFLAGS) + + +define PTP4L_BUILD_CMDS + $(TARGET_MAKE_ENV) $(MAKE) KBUILD_OUTPUT=$(TARGET_DIR) CC=$(TARGET_CC) EXTRA_CFLAGS="$(PTP4L_CFLAGS)" -C $(@D) all +endefPerhaps you should add EXTRA_LDFLAGS="$(TARGET_LDFLAGS)" as well. (In addition to eliminating
PTP4L_CFLAGSand using EXTRA_CFLAGS="$(TARGET_CFLAGS)" instead,)FWIW: changing the name to linuxptp: +1
Danomi -
Quoted 43 lines
package/ptp4l/ptp4l.mk new file +20
-0+ +define PTP4L_INSTALL_TARGET_CMDS + $(TARGET_MAKE_ENV) $(MAKE) prefix=$(TARGET_DIR)/usr $(TARGET_CONFIGURE_OPTS) -C $(@D) install +endef + +define PTP4L_INSTALL_INIT_SYSV + $(INSTALL) -m 755 -D $(@D)/package/ptp4l/S65ptp4l \ + $(TARGET_DIR)/etc/init.d/S65ptp4l +endef + +define PTP4L_INSTALL_INIT_SYSTEMD + $(INSTALL) -D -m 644 $(PTP4L_PKGDIR)/ptp4l.service \ + $(TARGET_DIR)/usr/lib/systemd/system/ptp4l.service + mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants + ln -sf ../../../../usr/lib/systemd/system/ptp4l.service \ + $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/ptp4l.service +endef + +$(eval $(generic-package)) +package/ptp4l/ptp4l.service new file +10
-1@@ -0,0 +1,10 @@ +[Unit] +Description=Precision Time Protocol daemon +After=syslog.target network.target + +[Service] +ExecStart=/usr/sbin/ptp4l -A -i eth0 +Restart=always + +[Install] +WantedBy=multi-user.target --2.7.4
_______________________________________________
buildroot mailing list
buildroot at busybox.net
http://lists.busybox.net/mailman/listinfo/buildroot