pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

smocker: Add static files



Module Name:	pkgsrc-wip
Committed By:	Leonardo Taccari <leot%NetBSD.org@localhost>
Pushed By:	leot
Date:		Sun Jan 1 02:44:52 2023 +0100
Changeset:	035eb8ac494d1f7531547780a974977de7db5673

Modified Files:
	smocker/Makefile
	smocker/PLIST
	smocker/distinfo
Added Files:
	smocker/patches/patch-main.go
Removed Files:
	smocker/TODO

Log Message:
smocker: Add static files

Use release distfile to add all static files (HTML, JavaScript and CSS)
needed by the UI.

Adjust hardcoded paths so invoking smocker without any further
arguments just works.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=035eb8ac494d1f7531547780a974977de7db5673

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 smocker/Makefile              | 26 ++++++++++++++++++++++++++
 smocker/PLIST                 |  9 +++++++++
 smocker/TODO                  |  4 ----
 smocker/distinfo              |  4 ++++
 smocker/patches/patch-main.go | 22 ++++++++++++++++++++++
 5 files changed, 61 insertions(+), 4 deletions(-)

diffs:
diff --git a/smocker/Makefile b/smocker/Makefile
index 928d461c3b..198d52b239 100644
--- a/smocker/Makefile
+++ b/smocker/Makefile
@@ -4,6 +4,14 @@ DISTNAME=	smocker-0.18.2
 CATEGORIES=	www
 MASTER_SITES=	${MASTER_SITE_GITHUB:=Thiht/}
 
+# XXX: Release distfile is actually just a tar, not a tar.gz (probably
+# XXX: accidentally).
+RELEASE_DIST=		${DISTNAME}-release.tar
+SITES.${RELEASE_DIST}=	-https://github.com/Thiht/smocker/releases/download/${PKGVERSION_NOREV}/smocker.tar.gz
+DISTFILES=		${DEFAULT_DISTFILES} ${RELEASE_DIST}
+
+EXTRACT_DIR.${RELEASE_DIST}=	${WRKSRC}/release
+
 MAINTAINER=	pkgsrc-users%NetBSD.org@localhost
 HOMEPAGE=	https://smocker.dev/
 COMMENT=	Simple and efficient HTTP mock server and proxy
@@ -15,7 +23,25 @@ GO_BUILD_PATTERN+=	-ldflags ' \
 			-X main.buildCommit= \
 			-X main.buildDate='
 
+PKG_SYSCONFSUBDIR=	smocker
+
+SUBST_CLASSES+=		paths
+SUBST_STAGE.paths=	pre-configure
+SUBST_MESSAGE.paths=	Adjust hardcoded paths
+SUBST_FILES.paths+=	main.go
+SUBST_VARS.paths=	PKG_SYSCONFDIR PREFIX
+
 .include "go-modules.mk"
 
+INSTALLATION_DIRS+=	share/smocker
+
+# Remove binary to preserve only static files needed by -static-files option
+post-extract:
+	${RM} ${WRKSRC}/release/smocker
+
+# Install also static files needed by -static-files option
+post-install:
+	${INSTALL_DATA} ${WRKSRC}/release/* ${DESTDIR}${PREFIX}/share/smocker
+
 .include "../../lang/go/go-module.mk"
 .include "../../mk/bsd.pkg.mk"
diff --git a/smocker/PLIST b/smocker/PLIST
index 4a1d83a890..18d14d7a65 100644
--- a/smocker/PLIST
+++ b/smocker/PLIST
@@ -1,2 +1,11 @@
 @comment $NetBSD$
 bin/smocker
+share/smocker/favicon.faca1f95.ico
+share/smocker/index.127cffb2.js
+share/smocker/index.127cffb2.js.map
+share/smocker/index.cea503c2.js
+share/smocker/index.cea503c2.js.map
+share/smocker/index.f126532d.css
+share/smocker/index.f126532d.css.map
+share/smocker/index.html
+share/smocker/logo180.16b61295.png
diff --git a/smocker/TODO b/smocker/TODO
deleted file mode 100644
index a04048a1d4..0000000000
--- a/smocker/TODO
+++ /dev/null
@@ -1,4 +0,0 @@
-- Not really tested, beware!
-- frontend currently broken, probably needs yarn-fu and distributing build
-  artifacts locally similar to e.g. databases/prometheus or fetching them
-  from official release
diff --git a/smocker/distinfo b/smocker/distinfo
index af618e904b..3c64ed36dc 100644
--- a/smocker/distinfo
+++ b/smocker/distinfo
@@ -441,6 +441,10 @@ Size (layeh.com_gopher-luar_@v_v1.0.7.mod) = 109 bytes
 BLAKE2s (layeh.com_gopher-luar_@v_v1.0.7.zip) = 5ce141415ec65fa2513fce6fc906ec372fadf3ed2c52654058475d27f7bbf75c
 SHA512 (layeh.com_gopher-luar_@v_v1.0.7.zip) = 94b70a83a31acde7232223ca82d6588716b39d6463baf5f15d921a5bc24a7d9b98307b8d44d3bbc9a5a82f6e4111b2b9ba1c15ee313a3784a30d63fe5d198bd3
 Size (layeh.com_gopher-luar_@v_v1.0.7.zip) = 36857 bytes
+BLAKE2s (smocker-0.18.2-release.tar) = c0f21fa2e5f9e611c2f6c92195335dc44305d1a306f259cfb5d97604d582ca8c
+SHA512 (smocker-0.18.2-release.tar) = be0a0e8e0fbca3d87021dda2928c1ac7123e094ed516ef2fa55858bb65a99efdcaa7669d9b5c8fa94d94388ca7d74f16e068cd5635f3440b9ba69ca751b52c81
+Size (smocker-0.18.2-release.tar) = 33863680 bytes
 BLAKE2s (smocker-0.18.2.tar.gz) = 13202d32b4973e19fcf484bc65cc20511b970610122caaff4ac2e91d2df5024c
 SHA512 (smocker-0.18.2.tar.gz) = e5b74bc8e1a7f378b37bbf17352f2f05637eebf5f879296e9b66bbfd55b1911fd08321c8f592230f6d29cc4bafd526e6d2f51bc44f25709be42b66c0c95958e2
 Size (smocker-0.18.2.tar.gz) = 1130662 bytes
+SHA1 (patch-main.go) = 812440dbd382c8428c7f50263bb715188b202fa6
diff --git a/smocker/patches/patch-main.go b/smocker/patches/patch-main.go
new file mode 100644
index 0000000000..15765eecbc
--- /dev/null
+++ b/smocker/patches/patch-main.go
@@ -0,0 +1,22 @@
+$NetBSD$
+
+Adjust paths to pkgsrc.
+
+--- main.go.orig	2022-04-27 09:42:26.000000000 +0000
++++ main.go
+@@ -28,12 +28,12 @@ func parseConfig() (c config.Config) {
+ 	flag.StringVar(&c.ConfigBasePath, "config-base-path", "/", "Base path applied to Smocker UI")
+ 	flag.IntVar(&c.ConfigListenPort, "config-listen-port", 8081, "Listening port of Smocker administration server")
+ 	flag.IntVar(&c.MockServerListenPort, "mock-server-listen-port", 8080, "Listening port of Smocker mock server")
+-	flag.StringVar(&c.StaticFiles, "static-files", ".", "Location of the static files to serve (index.html, etc.)")
++	flag.StringVar(&c.StaticFiles, "static-files", "@PREFIX@/share/smocker", "Location of the static files to serve (index.html, etc.)")
+ 	flag.IntVar(&c.HistoryMaxRetention, "history-retention", 0, "Maximum number of calls to keep in the history per session (0 = no limit)")
+ 	flag.StringVar(&c.PersistenceDirectory, "persistence-directory", "", "If defined, the directory where the sessions will be synchronized")
+ 	flag.BoolVar(&c.TLSEnable, "tls-enable", false, "Enable TLS using the provided certificate")
+-	flag.StringVar(&c.TLSCertFile, "tls-cert-file", "/etc/smocker/tls/certs/cert.pem", "Path to TLS certificate file ")
+-	flag.StringVar(&c.TLSKeyFile, "tls-private-key-file", "/etc/smocker/tls/private/key.pem", "Path to TLS key file")
++	flag.StringVar(&c.TLSCertFile, "tls-cert-file", "@PKG_SYSCONFDIR@/tls/certs/cert.pem", "Path to TLS certificate file ")
++	flag.StringVar(&c.TLSKeyFile, "tls-private-key-file", "@PKG_SYSCONFDIR@/tls/private/key.pem", "Path to TLS key file")
+ 	flag.Parse()
+ 	return
+ }


Home | Main Index | Thread Index | Old Index