Skip to content

Commit

Permalink
devel/soft-serve: Update to 0.5.4
Browse files Browse the repository at this point in the history
- Update rc.d script to include migrate target
- Add an UPDATING note for upgrade
- Add a pkg-message for upgrade
  • Loading branch information
wahjava committed Jun 18, 2023
1 parent fc569d6 commit 25000d4
Show file tree
Hide file tree
Showing 5 changed files with 121 additions and 21 deletions.
37 changes: 37 additions & 0 deletions UPDATING
Expand Up @@ -5,6 +5,43 @@ they are unavoidable.
You should get into the habit of checking this file for changes each time
you update your ports collection, before attempting any port upgrades.

20230618
AFFECTS: users of devel/soft-serve
AUTHOR: ashish@FreeBSD.org

soft-serve no longer uses config repository for configuration. To migrate
configuration from 0.4.x to 0.5.x, please review the upgrade documentation at:

https://github.com/charmbracelet/soft-serve/releases/tag/v0.5.0

The migration process has been incorporated in rc.d script's migrate command,
and can be performed using following instructions:

0. Please make sure to backup repository data

1. Stop existing process:

# /usr/local/etc/rc.d/soft-serve stop

2. Run the rc.d script to migrate, e.g.

# /usr/local/etc/rc.d/soft-serve migrate
INFO Setting SSH listen address...
INFO Copying SSH host key...
INFO Reading config repository...
INFO Setting server settings...
INFO Copying repos...
INFO Copying repo ports
INFO Copying readme from "config" to ".soft-serve"
INFO Setting repos metadata & collabs...
INFO Creating users & collabs...
INFO Creating user "ashish"
INFO Writing config...
INFO Done!

Another variable is introduced in rc.d script, soft_serve_data_path,
indicating the path to data directory used by soft-serve.

20230609:
AFFECTS: users of security/sequoia
AUTHOR: vishwin@FreeBSD.org
Expand Down
6 changes: 4 additions & 2 deletions devel/soft-serve/Makefile
@@ -1,7 +1,6 @@
PORTNAME= soft-serve
DISTVERSIONPREFIX= v
DISTVERSION= 0.4.7
PORTREVISION= 1
DISTVERSION= 0.5.4
CATEGORIES= devel

MAINTAINER= ashish@FreeBSD.org
Expand All @@ -19,16 +18,19 @@ GH_ACCOUNT= charmbracelet
GO_MODULE= github.com/charmbracelet/soft-serve
GO_TARGET= ./cmd/soft
USE_RC_SUBR= soft-serve
SUB_FILES= pkg-message
SUB_LIST+= CHOWN="${CHOWN}" \
CUT="${CUT}" \
DEFAULTHOST=0.0.0.0 \
DEFAULTKEY=.ssh/soft_serve_server_ed25519 \
DEFAULTPORT=23231 \
DEFAULTREPO=.repos \
DEFAULTDATA=data \
DIRNAME="${DIRNAME}" \
GITUSER="${USERS}" \
MKDIR="${MKDIR}" \
PW="${PW}" \
SU="${SU_CMD:[1]}" \
SETENV="${SETENV}"
USERS= git
GROUPS= git
Expand Down
14 changes: 7 additions & 7 deletions devel/soft-serve/distinfo
@@ -1,7 +1,7 @@
TIMESTAMP = 1680139619
SHA256 (go/devel_soft-serve/charmbracelet-soft-serve-v0.4.7_GH0/v0.4.7.mod) = ef1fbfc5c6935a714359db87e5334032a3dc178ce33122ad8b81dd42fa31e594
SIZE (go/devel_soft-serve/charmbracelet-soft-serve-v0.4.7_GH0/v0.4.7.mod) = 3393
SHA256 (go/devel_soft-serve/charmbracelet-soft-serve-v0.4.7_GH0/v0.4.7.zip) = 3b31183de65758c7c2a1b1066449227039b2d238cd728d7f51d8b962a5e8f733
SIZE (go/devel_soft-serve/charmbracelet-soft-serve-v0.4.7_GH0/v0.4.7.zip) = 98820
SHA256 (go/devel_soft-serve/charmbracelet-soft-serve-v0.4.7_GH0/charmbracelet-soft-serve-v0.4.7_GH0.tar.gz) = d850f3560584a206bbe1d88ec2f92622743a216e6f1cde868a606acdcd4e1de9
SIZE (go/devel_soft-serve/charmbracelet-soft-serve-v0.4.7_GH0/charmbracelet-soft-serve-v0.4.7_GH0.tar.gz) = 67151
TIMESTAMP = 1687104983
SHA256 (go/devel_soft-serve/charmbracelet-soft-serve-v0.5.4_GH0/v0.5.4.mod) = 4f88d2ffd3eefb6df2f5e48f6d37ae880811701fc42fcdc71f3563ddeec5c1b7
SIZE (go/devel_soft-serve/charmbracelet-soft-serve-v0.5.4_GH0/v0.5.4.mod) = 3922
SHA256 (go/devel_soft-serve/charmbracelet-soft-serve-v0.5.4_GH0/v0.5.4.zip) = cf4439453eaa997928f35007377caa57e8e755f0ac776050458b1b0d307019d2
SIZE (go/devel_soft-serve/charmbracelet-soft-serve-v0.5.4_GH0/v0.5.4.zip) = 160514
SHA256 (go/devel_soft-serve/charmbracelet-soft-serve-v0.5.4_GH0/charmbracelet-soft-serve-v0.5.4_GH0.tar.gz) = ac9365cfc171a09e68875503ad0518c7461f900d7267dbe92e3e686dcd985356
SIZE (go/devel_soft-serve/charmbracelet-soft-serve-v0.5.4_GH0/charmbracelet-soft-serve-v0.5.4_GH0.tar.gz) = 103793
39 changes: 39 additions & 0 deletions devel/soft-serve/files/pkg-message.in
@@ -0,0 +1,39 @@
[
{ type: upgrade
maximum_version: 0.5.0
message: <<EOM
soft-serve no longer uses config repository for configuration. To migrate
configuration from 0.4.x to 0.5.x, please review the upgrade documentation at:

https://github.com/charmbracelet/soft-serve/releases/tag/v0.5.0

The migration process has been incorporated in rc.d script's migrate command,
and can be performed using following instructions:

0. Please make sure to backup repository data

1. Stop existing process:

# %%PREFIX%%/etc/rc.d/soft-serve stop

2. Run the rc.d script to migrate, e.g.

# %%PREFIX%%/etc/rc.d/soft-serve migrate
INFO Setting SSH listen address...
INFO Copying SSH host key...
INFO Reading config repository...
INFO Setting server settings...
INFO Copying repos...
INFO Copying repo ports
INFO Copying readme from "config" to ".soft-serve"
INFO Setting repos metadata & collabs...
INFO Creating users & collabs...
INFO Creating user "ashish"
INFO Writing config...
INFO Done!

Another variable is introduced in rc.d script, soft_serve_data_path,
indicating the path to data directory used by soft-serve.
EOM
}
]
46 changes: 34 additions & 12 deletions devel/soft-serve/files/soft-serve.in
Expand Up @@ -18,8 +18,10 @@
# Set to %%DEFAULTHOST%% by default.
# soft_serve_key_path (path): Path to host key.
# Set to ~%%GITUSER%%/%%DEFAULTKEY%% by default.
# soft_serve_repo_path (path): Path to repositories root.
# soft_serve_repo_path (path): Path to repositories root (old)
# Set to ~%%GITUSER%%/%%DEFAULTREPO%% by default.
# soft_serve_data_path (path): Path to repositories data.
# Set to ~%%GITUSER%%/%%DEFAULTDATA%% by default.
# soft_serve_initial_admin_key (ssh public key): SSH public key for initial
# access to repositories (required)

Expand All @@ -36,6 +38,7 @@ load_rc_config $name
: ${soft_serve_host:="%%DEFAULTHOST%%"}
: ${soft_serve_key_path:="%%DEFAULTKEY%%"}
: ${soft_serve_repo_path:="%%DEFAULTREPO%%"}
: ${soft_serve_data_path:="%%DEFAULTDATA%%"}
: ${soft_serve_initial_admin_key:=""}

command="%%PREFIX%%/bin/soft-serve"
Expand All @@ -44,7 +47,27 @@ githome="$(%%PW%% user show -n ${soft_serve_user} | %%CUT%% -d: -f9)"

pidfile="/var/run/${name}.pid"

extra_commands="migrate"
start_cmd="${name}_start"
migrate_cmd="${name}_migrate"

soft_serve_migrate() {
if echo ${soft_serve_key_path} | grep -q ^/; then
SOFT_SERVE_KEY_PATH=${soft_serve_key_path}
else
SOFT_SERVE_KEY_PATH=$githome/${soft_serve_key_path}
fi
if echo ${soft_serve_repo_path} | grep -q ^/; then
SOFT_SERVE_REPO_PATH=${soft_serve_repo_path}
else
SOFT_SERVE_REPO_PATH=$githome/${soft_serve_repo_path}
fi
%%SU%% -l ${soft_serve_user} -c "\
%%SETENV%% \
\"SOFT_SERVE_KEY_PATH=${SOFT_SERVE_KEY_PATH}\" \
\"SOFT_SERVE_REPO_PATH=${SOFT_SERVE_REPO_PATH}\" \
$command migrate-config"
}

soft_serve_start() {
if [ -z "${soft_serve_initial_admin_key}" ]; then
Expand All @@ -68,23 +91,22 @@ soft_serve_start() {
fi
fi

if [ "${soft_serve_repo_path}" = "%%DEFAULTREPO%%" ]; then
soft_serve_repo_path=${githome}/${soft_serve_repo_path}
if ! [ -d $(%%DIRNAME%% $soft_serve_repo_path) ]; then
echo Creating repositories directory...
%%MKDIR%% $soft_serve_repo_path
%%CHOWN%% $soft_serve_user $soft_serve_repo_path
if [ "${soft_serve_data_path}" = "%%DEFAULTDATA%%" ]; then
soft_serve_data_path=${githome}/${soft_serve_data_path}
if ! [ -d $soft_serve_data_path ]; then
echo Creating data directory...
%%MKDIR%% $soft_serve_data_path
%%CHOWN%% $soft_serve_user $soft_serve_data_path
fi
fi

/usr/sbin/daemon -f \
-u ${soft_serve_user} -p ${pidfile} \
%%SETENV%% -i \
"SOFT_SERVE_PORT=${soft_serve_port}" \
"SOFT_SERVE_HOST=${soft_serve_host}" \
"SOFT_SERVE_KEY_PATH=${soft_serve_key_path}" \
"SOFT_SERVE_REPO_PATH=${soft_serve_repo_path}" \
"SOFT_SERVE_INITIAL_ADMIN_KEY=${soft_serve_initial_admin_key}" \
"SOFT_SERVE_SSH_PUBLIC_URL=ssh://${soft_serve_host}:${soft_serve_port}" \
"SOFT_SERVE_SSH_KEY_PATH=${soft_serve_key_path}" \
"SOFT_SERVE_DATA_PATH=${soft_serve_data_path}" \
"SOFT_SERVE_INITIAL_ADMIN_KEYS=${soft_serve_initial_admin_key}" \
"PATH=%%LOCALBASE%%/bin:${PATH}" \
"USER=${soft_serve_user}" \
$command serve
Expand Down

0 comments on commit 25000d4

Please sign in to comment.