1
0
mirror of https://git.FreeBSD.org/ports.git synced 2024-12-20 04:02:27 +00:00

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
This commit is contained in:
Serhii (Sergey) Kozlov 2021-05-17 21:27:39 +00:00
parent ec71ebb98c
commit 3fc479f35f
7 changed files with 192 additions and 11 deletions

2
GIDs
View File

@ -230,7 +230,7 @@ webdis:*:287:
ntopng:*:288:
victoria-metrics:*:289:
_gmid:*:290:
# free: 291
pydio:*:291:
# free: 292
# free: 293
# free: 294

2
UIDs
View File

@ -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

View File

@ -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
do-install-DOCS-on:
${MKDIR} ${STAGEDIR}${DOCSDIR}
${INSTALL_DATA} ${WRKSRC}/${PORTDOCS} ${STAGEDIR}${DOCSDIR}
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}
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>

View File

@ -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"

View File

@ -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

View File

@ -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)

View File

@ -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
}
]