Hello,

I think I've been staring at this too long...

grafana is proving to be a special case unless I'm missing something
obvious. The project seems to follow the pkg[0] layout pattern. It
uses a build.go which imports from the module in pkg/ to generate
the final build files. From there, the problem seems to be with the
vendoring. When Go runs build.go, it expects to find the grafana
module (in pkg/) in vendor/github.com/grafana/grafana.

I've tried naively copying the contents of pkg into
vendors/github.com/grafana/grafana. This starts the build, but
quickly (and unsurprisingly) fails with more "cannot find package..."
errors. Looking in go.port.mk, I've tried manipulating MODGO_WORKSPACE
and MODGO_GOPATH to mirror what a $HOME install would look like
(~/go/pkg/...) to no avail.

When built and run locally from $HOME, it works just fine from the
initial testing. I must be missing the right incantation of MODGO
vars, but I'm at a loss what I'm doing incorrectly and/or missing.
I've attached the WIP diff. Feel free to ignore the notes about
building the {front,back}end, they're not relevant here and
incorporated into the vendored DISTFILES. You should be able to
take the DISTFILES though and build locally, `go run build.go setup`
, `go run build.go build`, and then `./bin/openbsd-amd64/grafana-server`.
If that doesn't work, well, I must be a fool...

Best,
Lucas

[0] https://github.com/golang-standards/project-layout#pkg
https://github.com/grafana/grafana/tree/v8.5.0
diff refs/heads/master refs/heads/grafana
blob - b50ead16349c7d4375f0ebd4e3cbfcc5fd469fe7
blob + f1ecc30cb4abab11953bcf20773edd756f06dc22
--- sysutils/grafana/Makefile
+++ sysutils/grafana/Makefile
@@ -1,26 +1,38 @@
+# grafana requires a vendored build in two stages, frontend and backend
+# To build the backend, run `gmake gen-go`, `go mod tidy`, and then
+# `go mod vendor`
+# To build the frontend:
+# 1. Run `yarn install --immutable`. yarn will fail to build the
+#    cypress module, but this doesn't matter. It is only used for e2e
+#    tests
+# 2. Run `NODE_ENV=production NODE_OPTIONS="--max-old-space-size=6144" \
+#    yarn run build`
+# Tidy up a bit by grabbing the BUILD_ID from the generated JS files
+# and removing these directories:
+# * rm -R .yarn/{.cache,cache,install-state.gz,unplugged}
+# * rm -R node_modules
+# Compress the grafana directory
 COMMENT =      monitoring and metric analytics dashboards
 
-V =            7.5.11
+V =            8.5.0
 DISTNAME =     grafana+vendor-$V
 WRKDIST =      ${WRKDIR}/grafana-$V
-EXTRACT_SUFX = .tar.zstd
+EXTRACT_SUFX = .tar.zst
 PKGNAME =      grafana-$V
-BUILD_ID =     0cd8deb042c68e8113e4
+BUILD_ID =     da4d1dde3251d06d1d4a
 
 CATEGORIES =   sysutils
 
 HOMEPAGE =     https://grafana.com
 
-DISTFILES =    ${DISTNAME}${EXTRACT_SUFX} \
-               grafana-$V.linux-amd64.tar.gz{grafana-$V.linux-amd64.tar.gz?1}:0
+DISTFILES =    ${DISTNAME}${EXTRACT_SUFX}
 # force CDN refresh; upstream rerolled but some CDN nodes have the old version
 # normally     grafana-$V.linux-amd64.tar.gz:0
 
 # grafana+vendor distfile generated by fetching archive from
 # https://github.com/grafana/grafana/archive/v$V/grafana-$V.tar.gz
 # and running "go mod tidy" + "go mod vendor"
-MASTER_SITES = https://rhaalovely.net/~landry/stuff/
-MASTER_SITES0 =        https://dl.grafana.com/oss/release/
+MASTER_SITES = https://ports.lucasraab.me/
 
 # Apache 2.0 (bundles roboto and opensans fonts)
 PERMIT_PACKAGE =       Yes
@@ -31,10 +43,6 @@ SUBST_VARS +=        BUILD_ID
 
 MODGO_FLAGS += -ldflags="-w -X main.version=$V"
 
-# remove linux binaries from grafana-$V.linux-amd64.tar.gz
-post-extract:
-       rm ${WRKDIST}/bin/*
-
 do-build:
        cd ${WRKSRC} && ${MODGO_CMD} run ${MODGO_FLAGS} build.go setup
        cd ${WRKSRC} && ${MODGO_CMD} run ${MODGO_FLAGS} build.go build
blob - 81e7a9a3d39a828710545471759cc73fea63bc22
blob + ddecead58fa7793ff1cc8cfbb9b0b758672740d9
--- sysutils/grafana/distinfo
+++ sysutils/grafana/distinfo
@@ -1,4 +1,2 @@
-SHA256 (grafana+vendor-7.5.11.tar.zstd) = 
qWIl+v4PaHTkg72OGWISgYbfnPD8v3KzAivCnsJHbm0=
-SHA256 (grafana-7.5.11.linux-amd64.tar.gz) = 
MkTQztSNLelybJo71tXwjBtqCB1CZlQB4DP8SjHFfV0=
-SIZE (grafana+vendor-7.5.11.tar.zstd) = 21207028
-SIZE (grafana-7.5.11.linux-amd64.tar.gz) = 52218943
+SHA256 (grafana+vendor-8.5.0.tar.zst) = 
DMJof60UoaSxwo9ZbEzQQUYu39Yg0xpc776lKtBW0bs=
+SIZE (grafana+vendor-8.5.0.tar.zst) = 58331264
blob - 8c90a0d54c0f1a800a0a12cf4970c14fa733eabf (mode 644)
blob + /dev/null
--- sysutils/grafana/patches/patch-build_go
+++ /dev/null
@@ -1,12 +0,0 @@
-Index: build.go
---- build.go.orig
-+++ build.go
-@@ -343,7 +343,7 @@ func setBuildEnv() {
-               os.Setenv("GOARCH", goarch)
-       }
-       if goarch == "386" {
--              os.Setenv("GO386", "387")
-+              os.Setenv("GO386", "softfloat")
-       }
-       if cgo {
-               os.Setenv("CGO_ENABLED", "1")
blob - b724dd60382b907afc8c6a9425200cd4434c97c3
blob + aeab81e36c2b3a8134ba763ae53ec0e144512b61
--- sysutils/grafana/patches/patch-conf_sample_ini
+++ sysutils/grafana/patches/patch-conf_sample_ini
@@ -25,27 +25,25 @@ Index: conf/sample.ini
  
  #################################### Server 
####################################
  [server]
-@@ -165,8 +165,8 @@
- # Server reporting, sends usage counters to stats.grafana.org every 24 hours.
+@@ -193,7 +193,7 @@
  # No ip addresses are being tracked, only simple counters to track
  # running instances, dashboard and error counts. It is very helpful to us.
--# Change this option to false to disable reporting.
+ # Change this option to false to disable reporting.
 -;reporting_enabled = true
-+# Change this option to true to enable reporting.
 +reporting_enabled = false
  
  # The name of the distributor of the Grafana instance. Ex hosted-grafana, 
grafana-labs
  ;reporting_distributor = grafana-labs
-@@ -176,7 +176,7 @@
- # in some UI views to notify that grafana or plugin update exists
+@@ -203,7 +203,7 @@
+ # in some UI views to notify that a grafana update exists.
  # This option does not cause any auto updates, nor send any information
- # only a GET request to http://grafana.com to get latest versions
+ # only a GET request to 
https://raw.githubusercontent.com/grafana/grafana/main/latest.json to get the 
latest version.
 -;check_for_updates = true
 +check_for_updates = false
  
- # Google Analytics universal tracking code, only enabled if you specify an id 
here
- ;google_analytics_ua_id =
-@@ -520,7 +520,7 @@
+ # Set to false to disable all checks to https://grafana.com
+ # for new versions of plugins. The check is used
+@@ -646,7 +646,7 @@
  [log]
  # Either "console", "file", "syslog". Default is console and  file
  # Use space to separate multiple modes, e.g. "console file"
blob - d83f92d8ac1ccbd93a156ee11100b811656b66cf
blob + fd3e8333888e5420ff21ecd2cdc08e7d4f7802b1
--- sysutils/grafana/patches/patch-pkg_cmd_grafana-cli_commands_commands_go
+++ sysutils/grafana/patches/patch-pkg_cmd_grafana-cli_commands_commands_go
@@ -1,12 +1,12 @@
 Index: pkg/cmd/grafana-cli/commands/commands.go
 --- pkg/cmd/grafana-cli/commands/commands.go.orig
 +++ pkg/cmd/grafana-cli/commands/commands.go
-@@ -57,7 +57,7 @@ func runPluginCommand(command func(commandLine utils.C
+@@ -95,7 +95,7 @@ func runPluginCommand(command func(commandLine utils.C
                        return err
                }
  
--              logger.Info("\nRestart grafana after installing plugins . 
<service grafana-server restart>\n\n")
-+              logger.Info("\nRestart grafana after installing plugins . 
<rcctl restart grafana>\n\n")
+-              logger.Info(color.GreenString("Please restart Grafana after 
installing plugins. Refer to Grafana documentation for instructions if 
necessary.\n\n"))
++              logger.Info(color.GreenString("Please restart Grafana after 
installing plugins. rcctl restart grafana\n\n"))
                return nil
        }
  }

Reply via email to