Skip to content

Commit 231d6f1

Browse files
author
Andrei Zavada
committed
Merge branch 'hmmr/develop-3.0/fbsdng-support' into hmmr/develop-3.0/upgrade-to-rebar3.17
2 parents 323453d + 9149d75 commit 231d6f1

File tree

7 files changed

+242
-5
lines changed

7 files changed

+242
-5
lines changed

Makefile

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ test : testclean eunit test-deps
7575
##
7676
rel: compile
7777
@$(REBAR) as rel release
78-
# freebsd tar won't write to stdout, so
79-
@tar -c -f rel.tar --exclude-vcs -C _build/rel/rel riak && tar -x -f rel.tar -C rel && rm rel.tar
78+
# freebsd tar won't write to stdout, so:
79+
@tar -c -f rel.tar --exclude '*/.git/*' -C _build/rel/rel riak && tar -x -f rel.tar -C rel && rm rel.tar
8080

8181
rel-rpm: compile
8282
@$(REBAR) as rpm release
@@ -96,6 +96,10 @@ rel-alpine: compile
9696
@(cd _build/alpine/rel/riak/usr/bin && mv riak-nosu riak)
9797
@tar --exclude=vcs -c -C _build/alpine/rel riak | tar -x -C rel
9898

99+
rel-fbsdng: compile
100+
@$(REBAR) as fbsdng release
101+
@tar -c -f rel.tar --exclude '*/.git/*' -C _build/fbsdng/rel riak && tar -x -f rel.tar -C rel && rm rel.tar
102+
99103
relclean:
100104
@rm -rf $(REL_DIR)
101105
@rm -rf rel/riak rel/.libs rel/.deps

rebar.config

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,5 +211,22 @@
211211
[{relx,
212212
[{overlay_vars, "rel/pkg/osx/vars.config"}
213213
]}
214+
]},
215+
216+
{fbsdng,
217+
[{relx,
218+
[{overlay_vars, "rel/pkg/fbsdng/vars.config"},
219+
{extended_start_script_hooks,
220+
[{pre_start,
221+
[{custom, "hooks/riak_not_running"},
222+
{custom, "hooks/check_ulimit"},
223+
{custom, "hooks/erl_maxlogsize"},
224+
{custom, "hooks/erl_codeloadingmode"}]},
225+
{post_start,
226+
[wait_for_vm_start,
227+
{pid, "/var/run/riak/riak.pid"},
228+
{wait_for_process, riak_core_node_watcher}]}
229+
]}
230+
]}
214231
]}
215232
]}.

rel/files/riak

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,20 @@ function maybe_su {
2828
# (previously implicitly done by su -, which option we have
2929
# removed in order to allow any env vars to be available for
3030
# the ultimate invocation of riak/riak-cs/stanchion)
31-
cd {{platform_base_dir}}
32-
$SU riak -c "$*"
33-
fi
31+
cd "{{platform_base_dir}}"
32+
# freebsd su is fairly limited, so:
33+
mkdir -p "$RUNNER_GEN_DIR"
34+
chown riak:riak "$RUNNER_GEN_DIR"
35+
f=`mktemp "$RUNNER_GEN_DIR"/su_piggy-XXXXXXX`
36+
cat >"$f" <<EOF
37+
#!/bin/sh
38+
$*
39+
EOF
40+
chmod +x "$f"
41+
chown riak:riak "$f"
42+
$SU riak -c "$f"
43+
rm -f "$f"
44+
fi
3445
}
3546

3647
case "$1" in

rel/pkg/fbsdng/+MANIFEST

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: "riak"
2+
origin: "databases"
3+
comment: "Riak"
4+
licenses: ["Apache 2"]
5+
licenselogic: "single"
6+
arch: "freebsd:13:x86:64"
7+
www: "tiot.jp"
8+
maintainer: "[email protected]"
9+
users: ["riak"]
10+
groups: ["riak"]
11+
prefix: "/usr/local"
12+
categories: ["databases"]
13+
desc: "Riak is a distributed data store"
14+
scripts: {
15+
pre-install: "if ! pw groupshow riak 2>/dev/null; then pw groupadd riak; fi \n if ! pw usershow riak 2>/dev/null; then pw useradd riak -g riak -h - -d /usr/local/var/lib/riak -s /bin/sh -c \"Riak user\"; fi \n if [ ! -d /var/log/riak ]; then mkdir /var/log/riak && chown riak:riak /var/log/riak; fi"
16+
post-install: "chown riak:riak /usr/local/etc/riak /usr/local/var/lib/riak; (cd /usr/local/lib/riak; ln -s erts-* erts)"
17+
pre-deinstall: "rm -f /usr/local/lib/riak/erts"
18+
}

rel/pkg/fbsdng/Makefile

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
export
2+
3+
BUILDDIR = $(shell pwd)
4+
BUILD_STAGE_DIR = $(BUILDDIR)/riak
5+
6+
# Where we install things (based on vars.config)
7+
# /usr/local based dirs
8+
PMAN_DIR = $(BUILD_STAGE_DIR)/usr/local/man
9+
PBIN_DIR = $(BUILD_STAGE_DIR)/usr/local/lib/riak/bin
10+
PETC_DIR = $(BUILD_STAGE_DIR)/usr/local/etc/riak
11+
PLIB_DIR = $(BUILD_STAGE_DIR)/usr/local/lib/riak
12+
PUSRBIN_DIR = $(BUILD_STAGE_DIR)/usr/local/bin
13+
# /var based dirs
14+
PDATA_DIR = $(BUILD_STAGE_DIR)/usr/local/var/lib/riak
15+
PLOG_DIR = $(BUILD_STAGE_DIR)/var/log/riak
16+
17+
PKGNAME = riak-$(PKG_VERSION)-$(OSNAME)-$(ARCH).tbz
18+
19+
20+
# Recursive assignment of ERTS version
21+
# We will know this after building the rel
22+
ERTS_PATH = $(shell ls $(BUILDDIR)/rel/riak | egrep -o "erts-.*")
23+
24+
build: packing_list_files
25+
@echo "Building package $(PKGNAME)"
26+
27+
cd $(BUILD_STAGE_DIR) && \
28+
mkdir ../../../out/packages && \
29+
pkg create -m . -r . -o ../../../out/packages
30+
31+
cd ../../out/packages && \
32+
for f in *.pkg; do \
33+
shasum -a 256 $${f} > $${f}.sha \
34+
; done
35+
36+
packing_list_files: $(BUILD_STAGE_DIR)
37+
@mv ${BUILDDIR}/rel/pkg/fbsdng/+MANIFEST ${BUILD_STAGE_DIR}
38+
sed -e "s/%ERTS_PATH%/${ERTS_PATH}/" < \
39+
${BUILDDIR}/rel/pkg/fbsdng/rc.d > \
40+
${BUILD_STAGE_DIR}/usr/local/etc/rc.d/riak
41+
chmod -w ${BUILD_STAGE_DIR}/usr/local/etc/rc.d/riak
42+
chmod +x ${BUILD_STAGE_DIR}/usr/local/etc/rc.d/riak
43+
@cd $(BUILD_STAGE_DIR) && \
44+
echo "version: \"${PKG_VERSION}\"" >> +MANIFEST && \
45+
echo "files: {" >> +MANIFEST
46+
47+
@echo "Copying Man pages to staging directory"
48+
@cd $(BUILDDIR) && \
49+
if [ -d doc/man/man1 ]; then \
50+
mkdir -p $(PMAN_DIR) && \
51+
cp -R doc/man/man1 $(PMAN_DIR); fi
52+
53+
@echo "Packaging /usr/local files"
54+
@cd $(BUILD_STAGE_DIR) && \
55+
find usr -type f | while read file ; do \
56+
mode=$$(stat -f%p "$$file" | cut -c 3-) && \
57+
sum=$$(sha256 -q $$file) && \
58+
echo " \"/$$file\": { sum: \"$$sum\", perm: \"$$mode\", uname: \"root\", gname: \"wheel\" }," >> +MANIFEST; done && \
59+
sed -i .bak '$$s/,$$//' +MANIFEST && \
60+
rm -- +MANIFEST.bak && \
61+
echo " }" >> +MANIFEST
62+
63+
@cd $(BUILD_STAGE_DIR) && \
64+
echo "directories: {" >> +MANIFEST && \
65+
echo " /usr/local/lib/riak: \"y\"," >> +MANIFEST && \
66+
echo " /usr/local/var/lib/riak: {uname: \"riak\", gname: \"riak\", perm: \"0700\" }," >> +MANIFEST && \
67+
echo " /usr/local/etc/riak: \"y\"" >> +MANIFEST && \
68+
echo " }" >> +MANIFEST
69+
70+
# Copy the app rel directory to the staging directory to build our
71+
# package structure and move the directories into the right place
72+
# for the package, see the vars.config file for destination
73+
# directories
74+
$(BUILD_STAGE_DIR): buildrel
75+
@echo "Copying rel directory to staging directory"
76+
mkdir -p $@
77+
mkdir -p $(PBIN_DIR) $(PUSRBIN_DIR)
78+
for f in riak-admin riak-debug riak-repl riak-chkconfig; do \
79+
cp -R rel/riak/bin/$$f $(PUSRBIN_DIR); \
80+
done
81+
cp -R rel/riak/usr/bin/riak $(PUSRBIN_DIR)
82+
cp -R rel/riak/bin $(PLIB_DIR);
83+
mkdir -p $(PETC_DIR)
84+
cp -R rel/riak/etc/* $(PETC_DIR)
85+
mkdir -p $(PLIB_DIR)
86+
cp -R rel/riak/lib $(PLIB_DIR)
87+
cp -R rel/riak/share $(PLIB_DIR)
88+
cp -R rel/riak/erts-* $(PLIB_DIR)
89+
(cd $(PLIB_DIR) && ln -s erts-* erts)
90+
cp -R rel/riak/releases $(PLIB_DIR)
91+
mkdir -p $(PDATA_DIR)
92+
cp -R rel/riak/data/* $(PDATA_DIR)
93+
mkdir -p ${BUILD_STAGE_DIR}/usr/local/etc/rc.d
94+
95+
# Build the release we need to package
96+
# * Ensure all binaries are executable
97+
# * copy the vars.config over for build config
98+
buildrel:
99+
tar -xf $(BASE_DIR)/rel/pkg/out/$(PKG_ID).tar.gz -C $(BASE_DIR)/rel/pkg/out/riak-$(PKG_ID)
100+
$(MAKE) -C $(BASE_DIR)/rel/pkg/out/riak-$(PKG_ID) rel-fbsdng
101+
chmod 0755 rel/riak/bin/* rel/riak/erts-*/bin/*
102+
103+
$(BUILDDIR):
104+
mkdir -p $@
105+
106+
$(PKGERDIR)/pkgclean:
107+
rm -rf $(BUILD_STAGE_DIR) $(BUILDDIR)

rel/pkg/fbsdng/rc.d

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/bin/sh
2+
3+
# $FreeBSD$
4+
#
5+
# PROVIDE: riak
6+
# REQUIRE: LOGIN
7+
# KEYWORD: shutdown
8+
9+
. /etc/rc.subr
10+
11+
name=riak
12+
command=/usr/local/lib/riak/%ERTS_PATH%/bin/beam.smp
13+
rcvar=riak_enable
14+
start_cmd="/usr/local/bin/riak start"
15+
stop_cmd="/usr/local/bin/riak stop"
16+
pidfile="/var/run/riak/riak.pid"
17+
18+
load_rc_config $name
19+
run_rc_command "$1"

rel/pkg/fbsdng/vars.config

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
2+
%% ex: ft=erlang ts=4 sw=4 et
3+
4+
{rel_vsn, "{{release_version}}"}.
5+
6+
%% Platform-specific installation paths
7+
{platform_bin_dir, "/usr/local/lib/riak/bin"}.
8+
{platform_data_dir, "/usr/local/var/lib/riak"}.
9+
{platform_etc_dir, "/usr/local/etc/riak"}.
10+
{platform_base_dir, "/usr/local/lib/riak"}.
11+
{platform_lib_dir, "/usr/local/lib/riak/lib"}.
12+
{platform_log_dir, "/var/log/riak"}.
13+
{platform_gen_dir, "{{platform_data_dir}}"}.
14+
{platform_patch_dir, "{{platform_lib_dir}}/patches"}.
15+
16+
%%
17+
%% etc/app.config
18+
%%
19+
{web_ip, "127.0.0.1"}.
20+
{web_port, 8098}.
21+
{cluster_manager_ip, "127.0.0.1"}.
22+
{cluster_manager_port, 9080}.
23+
{handoff_port, 8099}.
24+
{handoff_ip, "0.0.0.0"}.
25+
{pb_ip, "127.0.0.1"}.
26+
{pb_port, 8087}.
27+
{storage_backend, "bitcask"}.
28+
{sasl_error_log, "{{platform_log_dir}}/sasl-error.log"}.
29+
{sasl_log_dir, "{{platform_log_dir}}/sasl"}.
30+
{repl_data_root, "{{platform_data_dir}}/riak_repl/"}.
31+
32+
%% lager
33+
{console_log_default, file}.
34+
35+
%%
36+
%% etc/vm.args
37+
%%
38+
39+
{crash_dump, "{{platform_log_dir}}/erl_crash.dump"}.
40+
41+
%%
42+
%% bin/riak
43+
%%
44+
{runner_script_dir, "{{platform_bin_dir}}"}.
45+
{runner_base_dir, "{{platform_base_dir}}"}.
46+
{runner_etc_dir, "{{platform_etc_dir}}"}.
47+
{runner_log_dir, "{{platform_log_dir}}"}.
48+
{runner_lib_dir, "{{platform_lib_dir}}"}.
49+
{runner_patch_dir, "{{platform_lib_dir}}/patches"}.
50+
51+
{pid_dir, "/var/run/riak"}.
52+
{pipe_dir, "/tmp/riak"}.
53+
54+
%%
55+
%% cuttlefish
56+
%%
57+
{cuttlefish, "on"}.
58+
{cuttlefish_conf, "riak.conf"}.
59+
60+
%% {yz_solr_port, 8093}.
61+
%% {yz_solr_jmx_port, 8985}.

0 commit comments

Comments
 (0)