mirror of
https://git.freebsd.org/ports.git
synced 2025-04-28 01:26:39 -04:00
www/codeberg-pages-server: New port: "Github Pages"-like pages server for Gitea/Forgejo
Gitea lacks the ability to host static pages from Git. The Codeberg Pages Server addresses this lack by implementing a standalone service that connects to Gitea via API. It is suitable to be deployed by other Gitea instances, too, to offer static pages hosting to their users. https://codeberg.org/Codeberg/pages-server PR: 284267
This commit is contained in:
parent
cd9b50cd39
commit
0397053f21
7 changed files with 191 additions and 0 deletions
|
@ -116,6 +116,7 @@
|
|||
SUBDIR += closure-compiler
|
||||
SUBDIR += cntlm
|
||||
SUBDIR += cobalt
|
||||
SUBDIR += codeberg-pages-server
|
||||
SUBDIR += codeigniter
|
||||
SUBDIR += colly
|
||||
SUBDIR += coppermine
|
||||
|
|
47
www/codeberg-pages-server/Makefile
Normal file
47
www/codeberg-pages-server/Makefile
Normal file
|
@ -0,0 +1,47 @@
|
|||
PORTNAME= codeberg-pages-server
|
||||
DISTVERSIONPREFIX= v
|
||||
DISTVERSION= 6.2.1
|
||||
CATEGORIES= www
|
||||
MASTER_SITES= https://codeberg.org/Codeberg/pages-server/archive/
|
||||
DISTFILES= ${DISTVERSIONFULL}.zip
|
||||
|
||||
MAINTAINER= orville@anislet.dev
|
||||
COMMENT= Codeberg Pages Server
|
||||
WWW= https://codeberg.org/Codeberg/pages-server
|
||||
|
||||
LICENSE= EUPL12
|
||||
LICENSE_FILE= ${WRKSRC}/LICENSE
|
||||
|
||||
USES= cpe go:1.24,modules
|
||||
USE_RC_SUBR= codeberg-pages-server
|
||||
|
||||
GO_MODULE= codeberg.org/codeberg/pages
|
||||
GO_MOD_DIST= https://codeberg.org/Codeberg/pages-server/raw/tag/${DISTVERSIONFULL}/
|
||||
GO_TARGET= codeberg.org/codeberg/pages:codeberg-pages-server
|
||||
GO_BUILDFLAGS+= -ldflags=" \
|
||||
${STRIP} -w \
|
||||
-extldflags '-static' \
|
||||
-X codeberg.org/codeberg/pages/server/version.Version=${DISTVERSIONFULL}"
|
||||
GO_BUILDFLAGS+= -tags=" \
|
||||
sqlite \
|
||||
sqlite_unlock_notify \
|
||||
netgo"
|
||||
|
||||
WRKSRC= ${WRKDIR}/pages-server
|
||||
|
||||
USERS= www
|
||||
GROUPS= www
|
||||
|
||||
post-build:
|
||||
@${WRKDIR}/bin/codeberg-pages-server --help | \
|
||||
${SETENV} XDG_CACHE_HOME=${WRKDIR}/.cache ${GO_ENV} \
|
||||
${GO_CMD} run ${FILESDIR}/config-generater.go > \
|
||||
${WRKSRC}/codeberg-pages-server-config.in
|
||||
|
||||
post-install:
|
||||
${INSTALL} -m0600 ${WRKSRC}/codeberg-pages-server-config.in \
|
||||
${STAGEDIR}${PREFIX}/etc/rc.conf.d/codeberg-pages-server.sample
|
||||
|
||||
@${MKDIR} ${STAGEDIR}/var/db/codeberg-pages-server
|
||||
|
||||
.include <bsd.port.mk>
|
5
www/codeberg-pages-server/distinfo
Normal file
5
www/codeberg-pages-server/distinfo
Normal file
|
@ -0,0 +1,5 @@
|
|||
TIMESTAMP = 1740750130
|
||||
SHA256 (go/www_codeberg-pages-server/codeberg-pages-server-v6.2.1/v6.2.1.zip) = cb501480f938430aee6066faa473660fafde2ea93539e20472c4acf00bd1d112
|
||||
SIZE (go/www_codeberg-pages-server/codeberg-pages-server-v6.2.1/v6.2.1.zip) = 187631
|
||||
SHA256 (go/www_codeberg-pages-server/codeberg-pages-server-v6.2.1/go.mod) = 608493cbe24bb51ace67cba30cb80b811d431d1f0e660f705a641812c61da041
|
||||
SIZE (go/www_codeberg-pages-server/codeberg-pages-server-v6.2.1/go.mod) = 12379
|
46
www/codeberg-pages-server/files/codeberg-pages-server.in
Normal file
46
www/codeberg-pages-server/files/codeberg-pages-server.in
Normal file
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
# PROVIDE: codeberg_pages_server
|
||||
# REQUIRE: LOGIN
|
||||
# KEYWORD: shutdown
|
||||
|
||||
. /etc/rc.subr
|
||||
|
||||
name="codeberg_pages_server"
|
||||
rcvar="${name}_enable"
|
||||
|
||||
load_rc_config codeberg-pages-server
|
||||
|
||||
: ${codeberg_pages_server_enable:="NO"}
|
||||
: ${codeberg_pages_server_user:="www"}
|
||||
: ${codeberg_pages_server_group:="www"}
|
||||
: ${codeberg_pages_server_log:="/var/log/codeberg-pages-server.log"}
|
||||
: ${codeberg_pages_server_chdir:="/var/db/codeberg-pages-server"}
|
||||
|
||||
command="/usr/sbin/daemon"
|
||||
task="/usr/local/bin/codeberg-pages-server"
|
||||
pidfile="/var/run/codeberg-pages-server/codeberg-pages-server.pid"
|
||||
procname="${task}"
|
||||
|
||||
command_args="-p ${pidfile} -o ${codeberg_pages_server_log} ${task}"
|
||||
|
||||
start_precmd="${name}_prestart"
|
||||
|
||||
codeberg_pages_server_prestart() {
|
||||
if [ ! -d "${codeberg_pages_server_chdir}" ]; then
|
||||
mkdir "${codeberg_pages_server_chdir}"
|
||||
chown ${codeberg_pages_server_user} "${codeberg_pages_server_chdir}"
|
||||
fi
|
||||
|
||||
if [ ! -f "${codeberg_pages_server_log}" ]; then
|
||||
touch "${codeberg_pages_server_log}"
|
||||
chown ${codeberg_pages_server_user}:${codeberg_pages_server_group} "${codeberg_pages_server_log}"
|
||||
chmod 640 "${codeberg_pages_server_log}"
|
||||
fi
|
||||
|
||||
if [ ! -d "/var/run/codeberg-pages-server" ] ; then
|
||||
install -d -o ${codeberg_pages_server_user} -g ${codeberg_pages_server_group} "/var/run/codeberg-pages-server"
|
||||
fi
|
||||
}
|
||||
|
||||
run_rc_command "$1"
|
83
www/codeberg-pages-server/files/config-generater.go
Normal file
83
www/codeberg-pages-server/files/config-generater.go
Normal file
|
@ -0,0 +1,83 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var (
|
||||
linePattern = regexp.MustCompile(`^ *--([a-zA-Z0-9_-]+)\ value.*\[\$([A-Z0-9_]+)\]`)
|
||||
descRegexp = regexp.MustCompile(`^.*value\s+(.*)(\(default.*\)|\[.*\]).*$`)
|
||||
defValRegexp = regexp.MustCompile(`\(default: ([^)]+)\)`)
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println("# See https://codeberg.org/Codeberg/pages-server")
|
||||
fmt.Println()
|
||||
|
||||
scanner := bufio.NewScanner(os.Stdin)
|
||||
for scanner.Scan() {
|
||||
line := scanner.Text()
|
||||
matches := linePattern.FindStringSubmatch(line)
|
||||
if matches == nil {
|
||||
continue
|
||||
}
|
||||
|
||||
optionName := matches[2]
|
||||
|
||||
descMatches := descRegexp.FindStringSubmatch(line)
|
||||
var description string
|
||||
if len(descMatches) > 1 {
|
||||
description = descMatches[1]
|
||||
}
|
||||
description = strings.TrimRight(description, " \t")
|
||||
if strings.HasPrefix(description, "]") {
|
||||
description = strings.TrimPrefix(description, "]")
|
||||
description = strings.TrimLeft(description, " ")
|
||||
}
|
||||
|
||||
defValMatches := defValRegexp.FindStringSubmatch(line)
|
||||
var defaultValue string
|
||||
if len(defValMatches) > 1 {
|
||||
defaultValue = defValMatches[1]
|
||||
}
|
||||
|
||||
exportCmd := "export"
|
||||
switch optionName {
|
||||
case "FORBIDDEN_MIME_TYPES",
|
||||
"ALLOWED_CORS_DOMAINS",
|
||||
"BLACKLISTED_PATHS",
|
||||
"CONFIG_FILE",
|
||||
"PROFILING_ADDRESS",
|
||||
"ACME_EAB_KID",
|
||||
"ACME_EAB_HMAC",
|
||||
"DNS_PROVIDER":
|
||||
optionName = "#" + optionName
|
||||
exportCmd = "#" + exportCmd
|
||||
}
|
||||
|
||||
if description != "" {
|
||||
fmt.Printf("# %s\n", description)
|
||||
} else {
|
||||
fmt.Println("#")
|
||||
}
|
||||
|
||||
if defaultValue != "" {
|
||||
fmt.Printf("%s=%s\n", optionName, defaultValue)
|
||||
fmt.Printf("%s %s\n", exportCmd, optionName)
|
||||
} else {
|
||||
fmt.Printf("%s=\"\"\n", optionName)
|
||||
uncommented := strings.TrimPrefix(optionName, "#")
|
||||
fmt.Printf("%s %s\n", exportCmd, uncommented)
|
||||
}
|
||||
fmt.Println()
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "read error: %v\n", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
5
www/codeberg-pages-server/pkg-descr
Normal file
5
www/codeberg-pages-server/pkg-descr
Normal file
|
@ -0,0 +1,5 @@
|
|||
Gitea/Forgejo lacks the ability to host static pages from Git.
|
||||
The Codeberg Pages Server addresses this lack by implementing a
|
||||
standalone service that connects to Gitea/Forgejo via API. It is
|
||||
suitable to be deployed by other Gitea/Forgejo instances, too,
|
||||
to offer static pages hosting to their users.
|
4
www/codeberg-pages-server/pkg-plist
Normal file
4
www/codeberg-pages-server/pkg-plist
Normal file
|
@ -0,0 +1,4 @@
|
|||
bin/codeberg-pages-server
|
||||
@sample etc/rc.conf.d/codeberg-pages-server.sample
|
||||
@dir etc/rc.conf.d
|
||||
@dir(www,www,755) /var/db/codeberg-pages-server
|
Loading…
Add table
Reference in a new issue