Date: Sun, 30 May 2021 11:31:46 GMT From: Serhii (Sergey) Kozlov <skozlov@FreeBSD.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org Subject: git: 3fc479f35f65 - main - www/pydio-cells: Fix build and overhaul Message-ID: <202105301131.14UBVk3u096657@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch main has been updated by skozlov: URL: https://cgit.FreeBSD.org/ports/commit/?id=3fc479f35f65392937dabe00b94b2ef4d8bec74d commit 3fc479f35f65392937dabe00b94b2ef4d8bec74d Author: Serhii (Sergey) Kozlov <skozlov@FreeBSD.org> AuthorDate: 2021-05-17 21:27:39 +0000 Commit: Serhii (Sergey) Kozlov <skozlov@FreeBSD.org> CommitDate: 2021-05-30 11:27:16 +0000 www/pydio-cells: Fix build and overhaul Summary: Pydio cells uses a custom version of packr to embed the static resources into the `cells` binary. Previously, the embedding process was not peformed, resulting in a non-functional binary. When trying to use the app, user will just get "404 Not Found" error instead of a web page. To fix this - before the build `gmake generate` has to be performed in the WRKSRC, and a special custom version of packr v1 (devel/pydio-packr) has to be used. Other changes: - DOCS option was removed, as the README.md file didn't really provide any useful information for the port's users - Generation of bash and zsh completion files was added - App version is now provided during the build process (previously 0.1.0 would be indicated instead of the real version) - Indicate failure to build on i386 - Create separate user/group for running the daemon, as recommended by the administrator's manual - Add rc script - Add pkg-message with configuration instructions - Add more patches fixing bugs and adapting the code for FreeBSD No UPDATING is required, as the port was not functional previously Reviewed by: koobs MFH: No (port isn't in any of the quarterly branches yet) Differential Revision: https://reviews.freebsd.org/D30323 --- GIDs | 2 +- UIDs | 2 +- www/pydio-cells/Makefile | 56 ++++++++++++--- www/pydio-cells/files/cells.in | 85 +++++++++++++++++++++++ www/pydio-cells/files/patch-cmd_start.go | 15 ++++ www/pydio-cells/files/patch-common_config_dirs.go | 19 +++++ www/pydio-cells/pkg-message | 24 +++++++ 7 files changed, 192 insertions(+), 11 deletions(-) diff --git a/GIDs b/GIDs index 58146b04c480..c88db791479c 100644 --- a/GIDs +++ b/GIDs @@ -230,7 +230,7 @@ webdis:*:287: ntopng:*:288: victoria-metrics:*:289: _gmid:*:290: -# free: 291 +pydio:*:291: # free: 292 # free: 293 # free: 294 diff --git a/UIDs b/UIDs index 47fca7e85caf..8a16d44b933c 100644 --- a/UIDs +++ b/UIDs @@ -235,7 +235,7 @@ webdis:*:287:287::0:0:webdis daemon user:/nonexistent:/usr/sbin/nologin ntopng:*:288:288::0:0:ntopng daemon user:/nonexistent:/usr/sbin/nologin victoria-metrics:*:289:289::0:0:VictoriaMetrics user:/nonexistent:/usr/sbin/nologin _gmid:*:290:290::0:0:gmid daemon user:/var/empty:/usr/sbin/nologin -# free: 291 +pydio:*:291:291::0:0:pydio cells user:/var/pydio:/bin/sh # free: 292 # free: 293 # free: 294 diff --git a/www/pydio-cells/Makefile b/www/pydio-cells/Makefile index 4c75e55d52b2..caa8ef3bae4b 100644 --- a/www/pydio-cells/Makefile +++ b/www/pydio-cells/Makefile @@ -1,6 +1,7 @@ PORTNAME= cells -PORTVERSION= 2.2.7 DISTVERSIONPREFIX= v +DISTVERSION= 2.2.7 +PORTREVISION= 1 CATEGORIES= www PKGNAMEPREFIX= pydio- @@ -10,20 +11,57 @@ COMMENT= Nextgen file sharing platform for organizations LICENSE= AGPLv3 LICENSE_FILE= ${WRKSRC}/LICENSE -USES= go +NOT_FOR_ARCHS= i386 +NOT_FOR_ARCHS_REASON= Not supported on i386 -GO_PKGNAME= github.com/pydio/cells +BUILD_DEPENDS= pydio-packr:devel/pydio-packr + +USES= go gmake +USE_RC_SUBR= ${PORTNAME} USE_GITHUB= yes GH_ACCOUNT= pydio +GO_PKGNAME= github.com/pydio/cells +GO_BUILDFLAGS= -ldflags "-X github.com/pydio/cells/common.version=${DISTVERSION}" + +USERS= pydio +GROUPS= pydio PLIST_FILES= bin/cells -PORTDOCS= README.md -OPTIONS_DEFINE= DOCS -DOCS_DESC= Install pydio-cells README file +OPTIONS_DEFINE= BASH ZSH +OPTIONS_DEFAULT= BASH ZSH + +BASH_PLIST_FILES= etc/bash_completion.d/${PORTNAME} +ZSH_PLIST_FILES= share/zsh/site-functions/_${PORTNAME} + +post-patch: + ${REINPLACE_CMD} -e "s|\$${GOPATH}/bin/packr|${LOCALBASE}/bin/pydio-packr|g" \ + ${WRKSRC}/Makefile + +pre-build: + @cd ${WRKSRC} && \ + ${MAKE_CMD} generate + +post-build-BASH-on: + ${SETENV} CELLS_WORKING_DIR=${WRKDIR}/wrkdir \ + ${GO_WRKDIR_BIN}/${PORTNAME} tools completion bash \ + > ${WRKDIR}/bash_completions + @${REINPLACE_CMD} -e 's|${GO_WRKDIR_BIN}/||g' ${WRKDIR}/bash_completions + +post-build-ZSH-on: + ${SETENV} CELLS_WORKING_DIR=${WRKDIR}/wrkdir \ + ${GO_WRKDIR_BIN}/${PORTNAME} tools completion zsh \ + > ${WRKDIR}/zsh_completions + @${REINPLACE_CMD} -e 's|${GO_WRKDIR_BIN}/||g' ${WRKDIR}/zsh_completions + +post-install-BASH-on: + @${MKDIR} ${STAGEDIR}${PREFIX}/etc/bash_completion.d + ${INSTALL_DATA} ${WRKDIR}/bash_completions \ + ${STAGEDIR}${PREFIX}/etc/bash_completion.d/${PORTNAME} -do-install-DOCS-on: - ${MKDIR} ${STAGEDIR}${DOCSDIR} - ${INSTALL_DATA} ${WRKSRC}/${PORTDOCS} ${STAGEDIR}${DOCSDIR} +post-install-ZSH-on: + @${MKDIR} ${STAGEDIR}${PREFIX}/share/zsh/site-functions + ${INSTALL_DATA} ${WRKDIR}/zsh_completions \ + ${STAGEDIR}${PREFIX}/share/zsh/site-functions/_${PORTNAME} .include <bsd.port.mk> diff --git a/www/pydio-cells/files/cells.in b/www/pydio-cells/files/cells.in new file mode 100644 index 000000000000..b90b2995024e --- /dev/null +++ b/www/pydio-cells/files/cells.in @@ -0,0 +1,85 @@ +#!/bin/sh + +# PROVIDE: cells +# REQUIRE: LOGIN +# KEYWORD: shutdown +# +# Add the following line to /etc/rc.conf to enable Pydio Cells: +# +# cells_enable (bool): Set to "NO" by default. +# Set to "YES" to enable Pydio Cells. +# cells_user (str): Default to "pydio". +# cells_group (str): Default to "pydio". +# User and group to run Pydio Cells with. +# cells_flags (str): Additional flags to append to "cells start" command. +# Read `cells help start` for more information. +# cells_workingdir (str): Default to "/var/pydio/.config/pydio/cells". +# Application directory. +# cells_logdir (str): Default to "${cells_workingdir}/logs". +# Directory for application logs. + +. /etc/rc.subr + +name=cells +rcvar=cells_enable +desc="Pydio Cells" + +load_rc_config cells + +: ${cells_enable:=NO} +: ${cells_user:=pydio} +: ${cells_group:=pydio} +: ${cells_workingdir=/var/pydio/.config/pydio/cells} +: ${cells_logdir="${cells_workingdir}/logs"} + +_envvars="CELLS_WORKING_DIR=${cells_workingdir} CELLS_LOG_DIR=${cells_logdir}" +_sucmd=/usr/bin/su + +extra_commands=cli +pidfile=/var/run/${name}/${name}.pid +cli_precmd=cells_precmd +cli_cmd="cells_cli $@" +start_precmd=cells_precmd +stop_cmd=cells_stop +procname="%%PREFIX%%/bin/cells" +command=/usr/sbin/daemon +command_args="-p ${pidfile} -o ${cells_logdir}/cells.log env ${_envvars} ${procname} start ${cells_flags}" + +cells_precmd() +{ + # Create PID file directory + install -d -o ${cells_user} -g ${cells_group} -m 0755 "$(dirname ${pidfile})" + + # Remove default flags, they're added in `command_args` manually + rc_flags="" +} + +cells_cli() +{ + shift 1 + ${_sucmd} -l ${cells_user} -c "exec env ${_envvars} ${procname} $*" +} + +cells_stop() +{ + # Copy-paste from rc.subr + if [ -z "${rc_pid}" ]; then + [ -n "${rc_fast}" ] && return 0 + _run_rc_notrunning + return 1 + fi + _children_pids=$(pgrep -P ${rc_pid}) + + echo "Stopping ${name}." + _run_rc_doit "kill -TERM ${rc_pid}" || return 1 + + # Stopping children is unreliable, so re-send TERM to them + # and wait for both the parent and the children + for _pid in ${_children_pids}; do + kill -TERM ${_pid} + done + + wait_for_pids ${rc_pid} ${children_pids} +} + +run_rc_command "$1" diff --git a/www/pydio-cells/files/patch-cmd_start.go b/www/pydio-cells/files/patch-cmd_start.go new file mode 100644 index 000000000000..70beb4144f5e --- /dev/null +++ b/www/pydio-cells/files/patch-cmd_start.go @@ -0,0 +1,15 @@ +--- cmd/start.go.orig 2021-05-06 12:02:02 UTC ++++ cmd/start.go +@@ -289,7 +289,11 @@ ENVIRONMENT + if (process == nil || len(process.Services) == 0) && len(childrenProcesses) == 0 { + return nil + } +- log.Info("Services are still running ", zap.Any("services", process.Services)) ++ // Already fixed upstream, should be in the next version after 2.2.7: ++ // https://github.com/pydio/cells/issues/325 ++ if (process != nil) { ++ log.Info("Services are still running ", zap.Any("services", process.Services)) ++ } + continue + case <-timeout: + return nil diff --git a/www/pydio-cells/files/patch-common_config_dirs.go b/www/pydio-cells/files/patch-common_config_dirs.go new file mode 100644 index 000000000000..3f72940370be --- /dev/null +++ b/www/pydio-cells/files/patch-common_config_dirs.go @@ -0,0 +1,19 @@ +--- common/config/dirs.go.orig 2021-05-06 12:02:02 UTC ++++ common/config/dirs.go +@@ -54,9 +54,14 @@ func ApplicationWorkingDir(dirType ...ApplicationDirTy + } else if d == ApplicationDirServices && os.Getenv("CELLS_SERVICES_DIR") != "" { + f = os.Getenv("CELLS_SERVICES_DIR") + } else { +- vendor := "Pydio" +- if runtime.GOOS == "linux" { ++ // Pull request upstream: ++ // https://github.com/pydio/cells/pull/326 ++ var vendor string ++ switch runtime.GOOS { ++ case "linux", "freebsd": + vendor = "pydio" ++ default: ++ vendor = "Pydio" + } + appName := "cells" + configDirs := configdir.New(vendor, appName) diff --git a/www/pydio-cells/pkg-message b/www/pydio-cells/pkg-message new file mode 100644 index 000000000000..bc70d7cedc82 --- /dev/null +++ b/www/pydio-cells/pkg-message @@ -0,0 +1,24 @@ +[ +{ type: install + message: <<EOM +To configure and start Pydio Cells: + +1. Enable cells in rc.conf: + # sysrc cells_enable=YES + +2. (optional) Set the custom working and log directories: + # sysrc cells_workingdir=<working_dir> + # sysrc cells_logdir=<log_dir> + +3. Run the configuration + # service cells cli configure --exit_after_install + +4. When the configuration master finishes - start the cells + # service cells start + +To control your installation you can use cells CLI +with workingdir and logdir set by running: +# service cells cli ... +EOM +} +]
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202105301131.14UBVk3u096657>