git: 2faca847a9b8 - main - net/teddycloud: alternative to the public toniebox server

From: Matthias Fechner <mfechner_at_FreeBSD.org>
Date: Sat, 02 Nov 2024 06:55:09 UTC
The branch main has been updated by mfechner:

URL: https://cgit.FreeBSD.org/ports/commit/?id=2faca847a9b81becdab7355228ed5949002de067

commit 2faca847a9b81becdab7355228ed5949002de067
Author:     Michael Pape <freebsd@pe82.de>
AuthorDate: 2024-11-02 06:06:39 +0000
Commit:     Matthias Fechner <mfechner@FreeBSD.org>
CommitDate: 2024-11-02 06:52:58 +0000

    net/teddycloud: alternative to the public toniebox server
    
    Small fixes applied to build successfully.
    
    PR:             276541
---
 net/Makefile                                       |  1 +
 net/teddycloud/Makefile                            | 67 ++++++++++++++++++++++
 net/teddycloud/distinfo                            | 23 ++++++++
 net/teddycloud/files/patch-Makefile                | 19 ++++++
 .../files/patch-cyclone_common_compiler__port.h    | 11 ++++
 net/teddycloud/files/teddycloudd.in                | 20 +++++++
 net/teddycloud/pkg-descr                           |  5 ++
 net/teddycloud/pkg-plist                           | 30 ++++++++++
 8 files changed, 176 insertions(+)

diff --git a/net/Makefile b/net/Makefile
index 3b34aac78cfb..df46c484b725 100644
--- a/net/Makefile
+++ b/net/Makefile
@@ -1567,6 +1567,7 @@
     SUBDIR += tcpxtract
     SUBDIR += td-system-tools
     SUBDIR += tdetect
+    SUBDIR += teddycloud
     SUBDIR += termshark
     SUBDIR += tftpgrab
     SUBDIR += throttled
diff --git a/net/teddycloud/Makefile b/net/teddycloud/Makefile
new file mode 100644
index 000000000000..f10e5cd2e34b
--- /dev/null
+++ b/net/teddycloud/Makefile
@@ -0,0 +1,67 @@
+PORTNAME=	teddycloud
+DISTVERSIONPREFIX=	tc_v
+DISTVERSION=	0.3.5
+CATEGORIES=	net
+# Get the latest commit hashes here: https://github.com/toniebox-reverse-engineering/tonies-json/commits/release/
+# NOTE: remove the existing tonies.json and tonieboxes.json from DISTDIR before you do a `make makesum`
+MASTER_SITES=	https://raw.githubusercontent.com/toniebox-reverse-engineering/tonies-json/d3bde1c301cc509ffced79bb08b40ec769029bbe/:toniesjson
+DISTFILES=	tonies.json:toniesjson \
+		tonieboxes.json:toniesjson
+EXTRACT_ONLY=	${DISTFILES:N*\:toniesjson:C/\:.*//}
+
+MAINTAINER=	freebsd@pe82.de
+COMMENT=	Alternative cloud server for the Toniebox
+WWW=		https://tonies-wiki.revvox.de/docs/tools/teddycloud/
+
+LICENSE=	GPLv2+
+
+BUILD_DEPENDS+= curl:ftp/curl \
+		protoc-c:devel/protobuf-c
+
+USES= 		gmake
+USE_GCC=	yes
+USE_GITHUB=	yes
+GH_ACCOUNT=	toniebox-reverse-engineering:DEFAULT,teddycloud_web \
+			DaveGamble:cJSON \
+			xiph:ogg,opus \
+			Oryx-Embedded:cyclone_common,cyclone_crypto,cyclone_ssl,cyclone_tcp
+GH_PROJECT=	cJSON:cJSON ogg:ogg opus:opus teddycloud_web:teddycloud_web \
+			Common:cyclone_common CycloneCRYPTO:cyclone_crypto \
+			CycloneSSL:cyclone_ssl CycloneTCP:cyclone_tcp
+GH_SUBDIR=	cJSON:cJSON ogg:ogg opus:opus teddycloud_web:teddycloud_web \
+			cyclone/common:cyclone_common cyclone/cyclone_crypto:cyclone_crypto \
+			cyclone/cyclone_ssl:cyclone_ssl cyclone/cyclone_tcp:cyclone_tcp
+# find versions here clone the repository and switch to tag
+# git submodule update
+# git submodule
+GH_TAGNAME=	v1.7.17:cJSON \
+		v1.3.5:ogg \
+		v1.4:opus \
+		ad73bfa:teddycloud_web \
+		v2.3.2:cyclone_common,cyclone_crypto,cyclone_ssl,cyclone_tcp
+
+USE_RC_SUBR=	teddycloudd
+MAKE_ENV+=	CONFIG_RUNTIME_BASE_PATH=${PREFIX}/etc/teddycloud \
+		RUNTIME_BASE_PATH=${PREFIX}/share/teddycloud
+# This did reliably fail due to some unknown deps when using parallel build
+MAKE_JOBS_UNSAFE=	yes
+ALL_TARGET=	preinstall
+
+post-extract:
+
+pre-install:
+	@${CP} ${DISTFILES:M*\:toniesjson:C/\:.*//:S,^,${_DISTDIR},} ${WRKSRC}/install/pre/config/
+
+do-install:
+	${INSTALL_PROGRAM} ${WRKSRC}/install/pre/teddycloud ${STAGEDIR}${PREFIX}/bin
+	${INSTALL_PROGRAM} ${WRKSRC}/install/pre/teddycloud ${STAGEDIR}${PREFIX}/bin
+	@${MKDIR} ${STAGEDIR}${DATADIR}/certs
+	@(cd ${WRKSRC}/install/pre/certs && ${COPYTREE_SHARE} . ${STAGEDIR}${DATADIR}/certs)
+	@${MKDIR} ${STAGEDIR}${DATADIR}/data
+	@(cd ${WRKSRC}/install/pre/data && ${COPYTREE_SHARE} . ${STAGEDIR}${DATADIR}/data)
+	@${MKDIR} ${STAGEDIR}${DATADIR}/certs
+	@(cd ${WRKSRC}/install/pre/certs && ${COPYTREE_SHARE} . ${STAGEDIR}${DATADIR}/certs)
+	@${MKDIR} ${STAGEDIR}${PREFIX}/etc/teddycloud
+	@(cd ${WRKSRC}/install/pre/config && ${COPYTREE_SHARE} . ${STAGEDIR}${PREFIX}/etc/teddycloud)
+
+.include <bsd.port.mk>
diff --git a/net/teddycloud/distinfo b/net/teddycloud/distinfo
new file mode 100644
index 000000000000..fd6908c8e56e
--- /dev/null
+++ b/net/teddycloud/distinfo
@@ -0,0 +1,23 @@
+TIMESTAMP = 1730528281
+SHA256 (tonies.json) = 1316eb7076dc49fe49fd51b8843cb29285090c574201714bf97898955c2cb243
+SIZE (tonies.json) = 5006642
+SHA256 (tonieboxes.json) = de50e30f844dcf743617337ba158b67498117f9c459b9ca4d26097aa3cb6b36f
+SIZE (tonieboxes.json) = 2736
+SHA256 (toniebox-reverse-engineering-teddycloud-tc_v0.3.5_GH0.tar.gz) = eeec26b7375e4ed4a496564930b382be659f117bdf1a0de2146650dec3b35517
+SIZE (toniebox-reverse-engineering-teddycloud-tc_v0.3.5_GH0.tar.gz) = 4758871
+SHA256 (toniebox-reverse-engineering-teddycloud_web-ad73bfa_GH0.tar.gz) = b9cc6afeca96da521a0014135de87a427cfaed13f55c77acef7b75483a5039fa
+SIZE (toniebox-reverse-engineering-teddycloud_web-ad73bfa_GH0.tar.gz) = 386567
+SHA256 (DaveGamble-cJSON-v1.7.17_GH0.tar.gz) = c91d1eeb7175c50d49f6ba2a25e69b46bd05cffb798382c19bfb202e467ec51c
+SIZE (DaveGamble-cJSON-v1.7.17_GH0.tar.gz) = 353748
+SHA256 (xiph-ogg-v1.3.5_GH0.tar.gz) = f6f1b04cfa4e98b70ffe775d5e302d9c6b98541f05159af6de2d6617817ed7d6
+SIZE (xiph-ogg-v1.3.5_GH0.tar.gz) = 251765
+SHA256 (xiph-opus-v1.4_GH0.tar.gz) = 659e6b223e42a51b0a898632b9a5f406ccd5c2e00aa526ddd1264789774b94e5
+SIZE (xiph-opus-v1.4_GH0.tar.gz) = 851780
+SHA256 (Oryx-Embedded-Common-v2.3.2_GH0.tar.gz) = 0a251e8a3674f777e33f01a825be0f55b2092bedbedd058b579b0e00d1b0119d
+SIZE (Oryx-Embedded-Common-v2.3.2_GH0.tar.gz) = 45692
+SHA256 (Oryx-Embedded-CycloneCRYPTO-v2.3.2_GH0.tar.gz) = a37d72648d3e551a9d02106ed42fca5622a3b27d3f7f8540117fe1eb9bfde3cf
+SIZE (Oryx-Embedded-CycloneCRYPTO-v2.3.2_GH0.tar.gz) = 886577
+SHA256 (Oryx-Embedded-CycloneSSL-v2.3.2_GH0.tar.gz) = 6a9aabf7a50e5546eeab94bd70e10ba908c68dff4ebf993013dc05f36eb1acbe
+SIZE (Oryx-Embedded-CycloneSSL-v2.3.2_GH0.tar.gz) = 226189
+SHA256 (Oryx-Embedded-CycloneTCP-v2.3.2_GH0.tar.gz) = 30755eba3b96518e325c19b23279560572c7a55135af4378146ac762212a158c
+SIZE (Oryx-Embedded-CycloneTCP-v2.3.2_GH0.tar.gz) = 2149879
diff --git a/net/teddycloud/files/patch-Makefile b/net/teddycloud/files/patch-Makefile
new file mode 100644
index 000000000000..97473952121d
--- /dev/null
+++ b/net/teddycloud/files/patch-Makefile
@@ -0,0 +1,19 @@
+--- Makefile.orig	2024-01-22 13:39:05 UTC
++++ Makefile
+@@ -40,11 +40,11 @@ else
+ build_rawDateTime:="${shell date "+%Y-%m-%d %H:%M:%S %z"}"
+ endif
+ 
+-build_gitDirty:=${shell git diff --quiet && echo '0' || echo '1'}
+-build_gitDateTime:="${shell git log -1 --format=%ai}"
+-build_gitShortSha:=${shell git rev-parse --short HEAD}
+-build_gitSha:=${shell git rev-parse HEAD}
+-build_gitTag:=${shell git name-rev --tags --name-only $(build_gitSha)}
++build_gitDirty:=0
++build_gitDateTime:="2024-01-22 13:39:05 +0000"
++build_gitShortSha:=8602da9
++build_gitSha:=8602da92d1080e67c678f476d4cf4de008aa857e
++build_gitTag:=tc_v0.3.5
+ build_platform:=$(PLATFORM)
+ build_os:="$(OS)"
+ 
diff --git a/net/teddycloud/files/patch-cyclone_common_compiler__port.h b/net/teddycloud/files/patch-cyclone_common_compiler__port.h
new file mode 100644
index 000000000000..2868f1fe464e
--- /dev/null
+++ b/net/teddycloud/files/patch-cyclone_common_compiler__port.h
@@ -0,0 +1,11 @@
+--- cyclone/common/compiler_port.h.orig	2024-01-17 21:26:40 UTC
++++ cyclone/common/compiler_port.h
+@@ -106,7 +106,7 @@ typedef unsigned int uint_t;
+    #define PRIXSIZE "X"
+    #define PRIuTIME "lu"
+ //Linux GCC compiler
+-#elif defined(__linux__)
++#elif defined(__linux__) || defined(__unix__)
+    #define PRIuSIZE "zu"
+    #define PRIXSIZE "zX"
+    #define PRIuTIME "lu"
diff --git a/net/teddycloud/files/teddycloudd.in b/net/teddycloud/files/teddycloudd.in
new file mode 100644
index 000000000000..a82bb641de82
--- /dev/null
+++ b/net/teddycloud/files/teddycloudd.in
@@ -0,0 +1,20 @@
+#!/bin/sh
+
+# PROVIDE: teddycloudd
+# REQUIRE: DAEMON
+# BEFORE:  LOGIN
+# KEYWORD: shutdown
+
+. /etc/rc.subr
+
+name=teddycloudd
+rcvar=teddycloudd_enable
+
+pidfile="/var/run/${name}.pid"
+
+procname="%%PREFIX%%/bin/teddycloud"
+command="/usr/sbin/daemon"
+command_args="-p ${pidfile} -t ${name} -o /var/log/teddycloud.log ${procname}"
+
+load_rc_config $name
+run_rc_command "$1"
diff --git a/net/teddycloud/pkg-descr b/net/teddycloud/pkg-descr
new file mode 100644
index 000000000000..0a35904a9240
--- /dev/null
+++ b/net/teddycloud/pkg-descr
@@ -0,0 +1,5 @@
+teddycloud is an alternative to the public toniebox server.
+It is designed to be used in a local network and does not provide
+means of authentication. In order to use this server, certificates
+have to be read out of a toniebox, which requires UART access to
+the boxes internal processor.
diff --git a/net/teddycloud/pkg-plist b/net/teddycloud/pkg-plist
new file mode 100644
index 000000000000..3948fc8ce1bc
--- /dev/null
+++ b/net/teddycloud/pkg-plist
@@ -0,0 +1,30 @@
+bin/teddycloud
+%%ETCDIR%%/tonies.custom.json
+%%ETCDIR%%/tonies.json
+%%ETCDIR%%/tonieboxes.json
+%%DATADIR%%/data/www/404.html
+%%DATADIR%%/data/www/encode_test.html
+%%DATADIR%%/data/www/favicon.ico
+%%DATADIR%%/data/www/img_custom.png
+%%DATADIR%%/data/www/img_empty.png
+%%DATADIR%%/data/www/img_unknown.png
+%%DATADIR%%/data/www/index.html
+%%DATADIR%%/data/www/library/esptool.js
+%%DATADIR%%/data/www/web/asset-manifest.json
+%%DATADIR%%/data/www/web/favicon.ico
+%%DATADIR%%/data/www/web/index.html
+%%DATADIR%%/data/www/web/manifest.json
+%%DATADIR%%/data/www/web/robots.txt
+%%DATADIR%%/data/www/web/static/css/main.e6c13ad2.css
+%%DATADIR%%/data/www/web/static/css/main.e6c13ad2.css.map
+%%DATADIR%%/data/www/web/static/js/main.3c1d6764.js
+%%DATADIR%%/data/www/web/static/js/main.3c1d6764.js.LICENSE.txt
+%%DATADIR%%/data/www/web/static/js/main.3c1d6764.js.map
+%%DATADIR%%/data/www/web/static/media/getFetch.40f37ddea2378391108f.cjs
+%%DATADIR%%/data/www/web/static/media/logo.2f09160138082fd1c6f8.png
+%%DATADIR%%/data/www/web/translations/de.json
+%%DATADIR%%/data/www/web/translations/en.json
+@dir %%DATADIR%%/certs/client
+@dir %%DATADIR%%/certs/server
+@dir %%DATADIR%%/data/content/default
+@dir %%DATADIR%%/data/library