Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gotify/server #5126

Merged
merged 6 commits into from
Feb 19, 2022
Merged

Add gotify/server #5126

merged 6 commits into from
Feb 19, 2022

Conversation

thorpelawrence
Copy link
Contributor

@thorpelawrence thorpelawrence commented Feb 9, 2022

Description

Add new package https://github.com/gotify/server. Based roughly on its build instructions

Checklist

  • Build rule all-supported completed successfully
  • New installation of package completed successfully
  • Package upgrade completed successfully (Manually install the package again)
  • Package functionality was tested
  • Any needed documentation is updated/created

Type of change

  • Bug fix
  • New Package
  • Package update
  • Includes small framework changes
  • This change requires a documentation update (e.g. Wiki)

@thorpelawrence
Copy link
Contributor Author

thorpelawrence commented Feb 9, 2022

Planned to test on armv7-6.2.4, was able to build gotify/server with GOARCH=arm GOARM=7 go build (on my local machine) but seems like it's not working with this version of gcc, any ideas on how I might be able to fix it? So far haven't been able to build an spk because of this as the toolchain wasn't working with it

arm-unknown-linux-gnueabi-gcc: error: unrecognized command line option '-m64'
...
/spksrc/native/go/work-native/go/pkg/tool/linux_amd64/link: running /spksrc/toolchain/syno-armv7-6.2.4/work/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc failed: exit status 1
/spksrc/toolchain/syno-armv7-6.2.4/work/arm-unknown-linux-gnueabi/bin/../lib/gcc/arm-unknown-linux-gnueabi/4.9.3/../../../../arm-unknown-linux-gnueabi/bin/ld.gold: -plugin: unknown option
/spksrc/toolchain/syno-armv7-6.2.4/work/arm-unknown-linux-gnueabi/bin/../lib/gcc/arm-unknown-linux-gnueabi/4.9.3/../../../../arm-unknown-linux-gnueabi/bin/ld.gold: use the --help option for usage information

@hgy59
Copy link
Contributor

hgy59 commented Feb 10, 2022

@thorpelawrence as x64 successfully builds, I tried to run in under DSM 7 on DS218+.
The server cannot create a data directory in the bin folder and therefore does not run (and there is no way to configure a different data folder).

@thorpelawrence
Copy link
Contributor Author

Thanks for testing, I didn't have an x64 Synology to test. Will see if I can create a patch or upstream change to configure data directory

- adjust icon (make it square)
- add gotify-cli to package
- fix service setup to create pid file
- avoid creation of target/bin/data folder by environment variable
- introduce environment-variables file for custom service configuration
- remove obsolete config.yml
@hgy59
Copy link
Contributor

hgy59 commented Feb 10, 2022

@thorpelawrence I did some redesign and now it works on my DS218+ (x86_64) with DSM 7.0.1.

  • rename package to gotify
  • adjust icon (make it square)
  • add gotify-cli to package
  • fix service setup to create pid file
  • avoid creation of target/bin/data folder by environment variables
  • introduce environment-variables file for custom service configuration
  • remove obsolete config.yml

grafik

@thorpelawrence
Copy link
Contributor Author

Thanks for all the help on this @hgy59, unfortunately I haven't been able to get it to compile with make arch-armv7-6.2.4, do you know if there's a way to cross-compile with a different toolchain that works with it?

@hgy59
Copy link
Contributor

hgy59 commented Feb 10, 2022

Yes, we still have a cross compilation issue. Only x64 builds are succeeding yet.

  • one issue is with go run hack/packr/packr.go as packr must be built for the host but the resulting files must be for the target arch.
  • when I (temp.) skipped the packr part I got errors in the next step (go build) like:
    /spksrc/native/go/work-native/go/pkg/tool/linux_amd64/link: running /spksrc/toolchain/syno-aarch64-6.1/work/aarch64-unknown-linux-gnueabi/bin/aarch64-unknown-linux-gnueabi-gcc failed: exit status 1
    /spksrc/toolchain/syno-aarch64-6.1/work/aarch64-unknown-linux-gnueabi/bin/../lib/gcc/aarch64-unknown-linux-gnueabi/4.9.4/../../../../aarch64-unknown-linux-gnueabi/bin/ld.gold: -plugin: unknown option
    /spksrc/toolchain/syno-aarch64-6.1/work/aarch64-unknown-linux-gnueabi/bin/../lib/gcc/aarch64-unknown-linux-gnueabi/4.9.4/../../../../aarch64-unknown-linux-gnueabi/bin/ld.gold: use the --help option for usage information
    collect2: error: ld returned 1 exit status
    

@hgy59
Copy link
Contributor

hgy59 commented Feb 10, 2022

As another approach we could try to use the prebuilt binaries of gotify-server and gotify-cli.

@thorpelawrence
Copy link
Contributor Author

  • one issue is with go run hack/packr/packr.go as packr must be built for the host but the resulting files must be for the target arch.

Interesting, as far as I could see it was just generating Go code (no CGO dependency) so didn't think packr would generate anything platform specific.

@hgy59
Copy link
Contributor

hgy59 commented Feb 10, 2022

Interesting, as far as I could see it was just generating Go code (no CGO dependency) so didn't think packr would generate anything platform specific.

Sorry this was just a guess. The "-m64" errors are a hint that the options are for the host but the gcc used is for the target arch.

@thorpelawrence
Copy link
Contributor Author

Interesting, as far as I could see it was just generating Go code (no CGO dependency) so didn't think packr would generate anything platform specific.

Sorry this was just a guess. The "-m64" errors are a hint that the options are for the host but the gcc used is for the target arch.

I saw the -m64 somewhere in I think the CGO code for ARM builds, so seems like it might be an option that's applied that just doesn't seem to be working with this specific toolchain.

I'd be happy to use the pre built versions, seems like there's an armv7 version - I guess would be OK to just use that for platforms that don't compile?
I was trying to use make all-supported but seems like that doesn't exist anymore?

@thorpelawrence
Copy link
Contributor Author

Was able to get it working using the gotify-linux-arm-7 build from GitHub releases, but wasn't completely sure how to get this to work with other platforms properly

image

@thorpelawrence
Copy link
Contributor Author

In fact, didn't even notice but gotify-cli was compiled fine, just the issue with gotify/server which is what I replaced with the download instead of build. (Makes sense though as it's only Go code in cli, but there's some C code for sqlite inside gotify/server)

@thorpelawrence
Copy link
Contributor Author

Was able to get it working with this (quickly hacked together) change, but obviously only for armv7

diff --git a/cross/gotify-server/Makefile b/cross/gotify-server/Makefile
index fc46a0e1..7351618c 100644
--- a/cross/gotify-server/Makefile
+++ b/cross/gotify-server/Makefile
@@ -15,8 +15,8 @@ LICENSE  = MIT
 GO_SRC_DIR = $(WORK_DIR)/$(PKG_DIR)
 GO_BIN_DIR = $(GO_SRC_DIR)/$(PKG_NAME)
 
-
-PRE_COMPILE_TARGET = gotify_pre_compile
+COMPILE_TARGET = gotify_compile
+# PRE_COMPILE_TARGET = gotify_pre_compile
 
 CGO_ENABLED = 1
 GO_BUILD_ARGS += -ldflags "-w -s -X main.Version=$(PKG_VERS) -X main.BuildDate=$(shell date "+%F-%T") -X main.Commit=$(PKG_VERS) -X main.Mode=prod"
@@ -26,7 +26,12 @@ include ../../mk/spksrc.cross-go.mk
 ENV += NPM_CONFIG_USER=root
 PATH := $(WORK_DIR)/../../../native/nodejs/work-native/node/bin:$(PATH)
 
-.PHONY: gotify_pre_compile
+.PHONY: gotify_pre_compile gotify_compile
 gotify_pre_compile:
-	cd $(GO_SRC_DIR)/ui && npm install && npm run build
-	cd $(GO_SRC_DIR) && env $(filter-out GOARCH=%, $(ENV)) go run hack/packr/packr.go
+	# cd $(GO_SRC_DIR)/ui && npm install && npm run build
+	# cd $(GO_SRC_DIR) && env $(filter-out GOARCH=%, $(ENV)) go run hack/packr/packr.go
+
+gotify_compile:
+	curl -Lo $(WORK_DIR)/tmp.zip https://github.com/gotify/server/releases/download/v2.1.4/gotify-linux-arm-7.zip
+	unzip -o $(WORK_DIR)/tmp.zip gotify-linux-arm-7
+	mv gotify-linux-arm-7 $(GO_BIN_DIR)

@hgy59
Copy link
Contributor

hgy59 commented Feb 11, 2022

@thorpelawrence I have now rewritten the package to use prebuilt binaries only.
Have to make gotify-cli executable...

@thorpelawrence
Copy link
Contributor Author

Awesome, thanks for the help @hgy59!

Any reason we couldn't just keep the compile for gotify-cli if that works? Or did it not work for all?

@hgy59
Copy link
Contributor

hgy59 commented Feb 11, 2022

Any reason we couldn't just keep the compile for gotify-cli if that works? Or did it not work for all?

We save some build resources (cpu, power) when just using the prebuilt binaries and not depend on native/go anymore.
That's why I prefere to use prebuilt binaries of gotify-server for x64 archs too.

@thorpelawrence
Copy link
Contributor Author

Any reason we couldn't just keep the compile for gotify-cli if that works? Or did it not work for all?

We save some build resources (cpu, power) when just using the prebuilt binaries and not depend on native/go anymore. That's why I prefere to use prebuilt binaries of gotify-server for x64 archs too.

Makes sense, happy to use the prebuilt, thought you weren't able to get the executable bit setup but missed that commit.

Is this ready to be merged in that case?

@thorpelawrence
Copy link
Contributor Author

thorpelawrence commented Feb 19, 2022

Hey, sorry to follow up but any updates on this please?

@hgy59 hgy59 merged commit 5a93f45 into SynoCommunity:master Feb 19, 2022
@hgy59 hgy59 added the status/published Published and activated (may take up to 48h until visible in DSM package manager) label Feb 19, 2022
@thorpelawrence
Copy link
Contributor Author

Thanks for all the help again @hgy59, do you know roughly when I can expect it to start showing up in my package manager? I'm on a DS218j with DSM 6.2.4

@thorpelawrence
Copy link
Contributor Author

Never mind, my synology network settings weren't working properly and only just figured out why, it's working now. Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/published Published and activated (may take up to 48h until visible in DSM package manager)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants