Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] package/httpdate: new package
@ 2026-11-04 14:09 Angelo Compagnucci
  2026-11-04 14:09 ` [Buildroot] [PATCH 2/2] package/htpdate: remove package Angelo Compagnucci
  2026-11-04 20:52 ` [Buildroot] [PATCH 1/2] package/httpdate: new package Thomas Petazzoni via buildroot
  0 siblings, 2 replies; 4+ messages in thread
From: Angelo Compagnucci @ 2026-11-04 14:09 UTC (permalink / raw)
  To: buildroot; +Cc: Fiona Klute, Thomas Petazzoni, Angelo Compagnucci

httpdate synchronizes the system time using the Date header of HTTP and
HTTPS servers, which is useful on networks where NTP is blocked but web
access is permitted. It is the successor of htpdate, from the same
author: it delegates the network transport (HTTP, HTTPS, HTTP/2,
proxies) to libcurl, and estimates the time from several servers.

Like the htpdate package, add a SysV init script and a systemd unit,
running httpdate with the arguments of HTTPDATE_ARGS, that can be
overridden in /etc/default/httpdate. As httpdate does not write a
pidfile, it runs in the foreground (-F), and start-stop-daemon
backgrounds it and writes the pidfile.

https://github.com/twekkel/httpdate

Signed-off-by: Angelo Compagnucci <angelo.compagnucci@gmail.com>
---
 DEVELOPERS                        |  1 +
 package/Config.in                 |  1 +
 package/httpdate/Config.in        | 11 +++++++
 package/httpdate/S43httpdate      | 55 +++++++++++++++++++++++++++++++
 package/httpdate/httpdate.hash    |  3 ++
 package/httpdate/httpdate.mk      | 33 +++++++++++++++++++
 package/httpdate/httpdate.service | 12 +++++++
 7 files changed, 116 insertions(+)
 create mode 100644 package/httpdate/Config.in
 create mode 100644 package/httpdate/S43httpdate
 create mode 100644 package/httpdate/httpdate.hash
 create mode 100644 package/httpdate/httpdate.mk
 create mode 100644 package/httpdate/httpdate.service

diff --git a/DEVELOPERS b/DEVELOPERS
index 1b9dd41f01..21b5700dc9 100644
--- a/DEVELOPERS
+++ b/DEVELOPERS
@@ -234,6 +234,7 @@ F:	package/fail2ban/
 F:	package/grep/
 F:	package/gtkiostream/
 F:	package/htpdate/
+F:	package/httpdate/
 F:	package/i2c-tools/
 F:	package/jq/
 F:	package/libapparmor/
diff --git a/package/Config.in b/package/Config.in
index 32fc1496c9..089860e7ec 100644
--- a/package/Config.in
+++ b/package/Config.in
@@ -2509,6 +2509,7 @@ endif
 	source "package/hostapd/Config.in"
 	source "package/hplip/Config.in"
 	source "package/htpdate/Config.in"
+	source "package/httpdate/Config.in"
 	source "package/httping/Config.in"
 	source "package/i2pd/Config.in"
 	source "package/iana-assignments/Config.in"
diff --git a/package/httpdate/Config.in b/package/httpdate/Config.in
new file mode 100644
index 0000000000..8d3f2c7bef
--- /dev/null
+++ b/package/httpdate/Config.in
@@ -0,0 +1,11 @@
+config BR2_PACKAGE_HTTPDATE
+	bool "httpdate"
+	depends on BR2_USE_MMU # daemon()
+	select BR2_PACKAGE_LIBCURL
+	help
+	  httpdate synchronizes the system time using the Date header
+	  of HTTP and HTTPS servers, which is useful on networks where
+	  NTP is blocked but web access is permitted. It is the
+	  successor of htpdate.
+
+	  https://github.com/twekkel/httpdate
diff --git a/package/httpdate/S43httpdate b/package/httpdate/S43httpdate
new file mode 100644
index 0000000000..aff7a00eb9
--- /dev/null
+++ b/package/httpdate/S43httpdate
@@ -0,0 +1,55 @@
+#!/bin/sh
+
+DAEMON="httpdate"
+PIDFILE="/var/run/$DAEMON.pid"
+
+HTTPDATE_ARGS="-s https://www.google.com"
+
+# shellcheck source=/dev/null
+test -r "/etc/default/$DAEMON" && . "/etc/default/$DAEMON"
+
+start() {
+	printf 'Starting %s: ' "$DAEMON"
+	# httpdate does not write a pidfile, so run it in the foreground
+	# and let start-stop-daemon background it and write it.
+	# shellcheck disable=SC2086 # we need the word splitting
+	start-stop-daemon -S -q -b -m -p "$PIDFILE" -x "/usr/bin/$DAEMON" \
+		-- -F $HTTPDATE_ARGS
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+stop() {
+	printf 'Stopping %s: ' "$DAEMON"
+	start-stop-daemon -K -q -p "$PIDFILE"
+	status=$?
+	if [ "$status" -eq 0 ]; then
+		rm -f "$PIDFILE"
+		echo "OK"
+	else
+		echo "FAIL"
+	fi
+	return "$status"
+}
+
+restart() {
+	stop
+	sleep 1
+	start
+}
+
+case "$1" in
+	start|stop|restart)
+		"$1";;
+	reload)
+		# Restart, since there is no true "reload" feature.
+		restart;;
+	*)
+		echo "Usage: $0 {start|stop|restart|reload}"
+		exit 1
+esac
diff --git a/package/httpdate/httpdate.hash b/package/httpdate/httpdate.hash
new file mode 100644
index 0000000000..31c6d80868
--- /dev/null
+++ b/package/httpdate/httpdate.hash
@@ -0,0 +1,3 @@
+# Locally calculated
+sha256  c7a13e693de32e48fc374f36598390eece04e4c26f21b1e7d67cdc680d60236b  httpdate-1.0.1.tar.gz
+sha256  cb7177d68741cb08ed1fade01b9f9cc7d1c56c0e96f3f6ab86f5b455cf99e44f  LICENSE
diff --git a/package/httpdate/httpdate.mk b/package/httpdate/httpdate.mk
new file mode 100644
index 0000000000..6a21f0fccc
--- /dev/null
+++ b/package/httpdate/httpdate.mk
@@ -0,0 +1,33 @@
+################################################################################
+#
+# httpdate
+#
+################################################################################
+
+HTTPDATE_VERSION = 1.0.1
+HTTPDATE_SITE = $(call github,twekkel,httpdate,v$(HTTPDATE_VERSION))
+HTTPDATE_LICENSE = GPL-2.0+
+HTTPDATE_LICENSE_FILES = LICENSE
+HTTPDATE_DEPENDENCIES = host-pkgconf libcurl
+
+define HTTPDATE_BUILD_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) \
+		LIBS="`$(PKG_CONFIG_HOST_BINARY) --libs libcurl` -lm"
+endef
+
+define HTTPDATE_INSTALL_TARGET_CMDS
+	$(TARGET_MAKE_ENV) $(TARGET_CONFIGURE_OPTS) $(MAKE) -C $(@D) \
+		DESTDIR=$(TARGET_DIR) PREFIX=/usr install
+endef
+
+define HTTPDATE_INSTALL_INIT_SYSV
+	$(INSTALL) -D -m 0755 package/httpdate/S43httpdate \
+		$(TARGET_DIR)/etc/init.d/S43httpdate
+endef
+
+define HTTPDATE_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -D -m 0644 package/httpdate/httpdate.service \
+		$(TARGET_DIR)/usr/lib/systemd/system/httpdate.service
+endef
+
+$(eval $(generic-package))
diff --git a/package/httpdate/httpdate.service b/package/httpdate/httpdate.service
new file mode 100644
index 0000000000..adce46d929
--- /dev/null
+++ b/package/httpdate/httpdate.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=httpdate daemon
+After=network.target
+
+[Service]
+Type=simple
+Environment=HTTPDATE_ARGS="-s https://www.google.com"
+EnvironmentFile=-/etc/default/httpdate
+ExecStart=/usr/bin/httpdate -F $HTTPDATE_ARGS
+
+[Install]
+WantedBy=multi-user.target
-- 
2.34.1

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-04 20:54 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04 14:09 [Buildroot] [PATCH 1/2] package/httpdate: new package Angelo Compagnucci
2026-11-04 14:09 ` [Buildroot] [PATCH 2/2] package/htpdate: remove package Angelo Compagnucci
2026-11-04 20:53   ` Thomas Petazzoni via buildroot
2026-11-04 20:52 ` [Buildroot] [PATCH 1/2] package/httpdate: new package Thomas Petazzoni via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox