Hi Martin, ports,

Here's an update to start shipping ntfy's web UI in ports. I decided to
bundle it as an additional tarball, as otherwise it requires npm which
assumes an online build. The dist target takes care of creating the
bundle. It was modelled after sthen's great work at comms/zigbee2mqtt.

There are 2 small "hacks" of sorts in the dist target:

- Ignoring vite's requirement and setting the version of esbuild to
  >=0.24.0, which was the newest available at the time I started working
  on this.
- Setting ESBUILD_BINARY_PATH in the environment to use our own esbuild
  instead of whatever npm installed.

To try it out, after restarting the newly built ntfy, the web UI is
accessible at http://<your-instance>/app. I've been running it for quite
some months already and I'm pretty happy with it.

OK?

        Lucas


diff refs/heads/master 91b9037ef3274d092fe3030b40dc03fe7859c428
commit - 9f6dbfb894195edc2a536ad158f7bfede9f44d22
commit + 91b9037ef3274d092fe3030b40dc03fe7859c428
blob - f136e7292df56104b6a1e8021c5ce6b4f5ec6aa3
blob + 9a248184e5ab6967b99d69b365db516a74a66aa0
--- net/ntfy/Makefile
+++ net/ntfy/Makefile
@@ -2,9 +2,14 @@ COMMENT =      send push notifications to your phone or des
 
 MODGO_MODNAME =        heckel.io/ntfy/v2
 MODGO_VERSION =        v2.11.0
+REVISION =     0
 
 DISTNAME =     ntfy-${MODGO_VERSION}
 
+SITES.ui =     https://openbsd.ports.builders/distfiles/net/ntfy/
+DISTFILES.ui = ntfy-${MODGO_VERSION}-ui.tar.gz
+EXTRACT_ONLY +=        ntfy-${MODGO_VERSION}-ui.tar.gz
+
 CATEGORIES =   net
 
 HOMEPAGE =     https://ntfy.sh
@@ -19,12 +24,11 @@ MODULES =   lang/go
 WANTLIB +=     c pthread
 WRKDIST =      ${WRKSRC}
 
-# Stub docs and app HTML files; build fails because of failure to embed them.
-# Building the app fails because esbuild SIGILLs. Building the docs requires
-# mkdocs, not currently ported.
+# Stub docs files; build fails because of failure to embed them. App is
+# provided as an additional distfile as it requires npm, which assumes online
+# builds. Building the docs requires Python mkdocs, not currently ported.
 post-extract:
-       mkdir -p ${WRKSRC}/server/site
-       ${INSTALL_DATA} ${FILESDIR}/app.html ${WRKSRC}/server/site
+       mv ${WRKDIR}/build ${WRKDIST}/server/site
        mkdir -p ${WRKSRC}/server/docs
        ${INSTALL_DATA} ${FILESDIR}/index.html ${WRKSRC}/server/docs
 
@@ -37,5 +41,30 @@ post-install:
        ${INSTALL_DATA} ${WRKSRC}/examples/$i/* ${PREFIX}/share/examples/ntfy/
 .endfor
 
+# Maintainer convenience target for building the UI. Requires jq and esbuild.
+# index.html rename and config.js removal taken from upstream's Makefile.
+dist: ${FULLDISTDIR}/${DISTNAME_ESC}${EXTRACT_SUFX}
+       @set -x; \
+       t=`mktemp -d /tmp/ntfy.XXXXXXXXXX`; \
+       f=$$t/ntfy-${MODGO_VERSION}-ui.tar.gz; \
+       export HOME=$$t LC_CTYPE=C ESBUILD_BINARY_PATH=/usr/local/bin/esbuild; \
+       cd $$t; \
+       unzip ${FULLDISTDIR}/${DISTNAME_ESC}${EXTRACT_SUFX}; \
+       cd ${MODGO_MODNAME_ESC}@${MODGO_VERSION}/web; \
+       jq '.packages["node_modules/vite"].dependencies.esbuild |= ">=0.24.0"' \
+           package-lock.json >package-lock.json.tmp; \
+       mv package-lock.json.tmp package-lock.json; \
+       npm install -dd --include=dev --cache=$$t/npm-cache; \
+       old_ulimit_d=$$(ulimit -Sd); \
+       ulimit -Sd $$((3 * 1024 * 1024)); \
+       npm run build -dd --cache=$$t/npm-cache; \
+       ulimit -Sd "$$old_ulimit_d"; \
+       mv build/index.html build/app.html; \
+       rm build/config.js; \
+       pax -wzf $$f build/; \
+       rsync $$f distfiles@openbsd.ports.builders:/distfiles/net/ntfy/; \
+       cd -; \
+       rm -rf $$t
+
 .include "modules.inc"
 .include <bsd.port.mk>
blob - 7073a0098b01e3bee863ee976cd4608ad1a9e978
blob + 998ce3a64d17c50cc638f726da85221990e4b426
--- net/ntfy/distinfo
+++ net/ntfy/distinfo
@@ -659,6 +659,7 @@ SHA256 (go_modules/gopkg.in/yaml.v3/@v/v3.0.1.zip) = q
 SHA256 
(go_modules/honnef.co/go/tools/@v/v0.0.0-20190102054323-c2f93a96b099.mod) = 
scYIN+phM18U32TzGUw82S4PYo9gZIBnGJUPDXodvp4=
 SHA256 
(go_modules/honnef.co/go/tools/@v/v0.0.0-20190523083050-ea95bdfd59fc.mod) = 
scYIN+phM18U32TzGUw82S4PYo9gZIBnGJUPDXodvp4=
 SHA256 
(go_modules/honnef.co/go/tools/@v/v0.0.0-20190523083050-ea95bdfd59fc.zip) = 
7qqCcA6WrF6APXqcMjYzMlBL7/j7sSAkkrTUPVpec2A=
+SHA256 (ntfy-v2.11.0-ui.tar.gz) = M9lJDZUv7FJit5skvlYqzKeVxBv6vh5+9hUflrRDqf4=
 SHA256 (ntfy-v2.11.0.zip) = IzkLWMTFT4SJnTkqoLamT5BlEmz7lKWMjeQWG7s14A0=
 SIZE (go_modules/cloud.google.com/go/@v/v0.112.1.mod) = 1812
 SIZE (go_modules/cloud.google.com/go/@v/v0.112.2.mod) = 1812
@@ -1321,4 +1322,5 @@ SIZE (go_modules/gopkg.in/yaml.v3/@v/v3.0.1.zip) = 104
 SIZE (go_modules/honnef.co/go/tools/@v/v0.0.0-20190102054323-c2f93a96b099.mod) 
= 26
 SIZE (go_modules/honnef.co/go/tools/@v/v0.0.0-20190523083050-ea95bdfd59fc.mod) 
= 26
 SIZE (go_modules/honnef.co/go/tools/@v/v0.0.0-20190523083050-ea95bdfd59fc.zip) 
= 449180
+SIZE (ntfy-v2.11.0-ui.tar.gz) = 2149674
 SIZE (ntfy-v2.11.0.zip) = 13725478
blob - 859b19451c486080f8b2b6f47bd66aabe777e63c (mode 644)
blob + /dev/null
--- net/ntfy/files/app.html
+++ /dev/null
@@ -1,6 +0,0 @@
-<!DOCTYPE html>
-<title>ntfy</title>
-<p>
-ntfy web UI isn't supported on OpenBSD.
-You can visit the upstream web UI at
-<a href="https://ntfy.sh/app";>https://ntfy.sh/app</a>.

Reply via email to