Skip to content

Commit 9cf5487

Browse files
committed
Support debian make
Make profile for debian. Issues exist when compared to 2.9 with permissions: To help with an expectation that configuration will be written to usr/lib/riak - a system of links is used instead - with the links configured through the riakpre script. Care needs to be taken with the merging of extended_start_script_hooks across profiles - this may not yield the expected results. Hence each profile has a dedicated configurtaion and a single profile is used for make rel-deb. The pid_dir is defined in multiple places (debian/vars.config, rebar.config, riak.riak.service). These need to align.
1 parent 7a47a9b commit 9cf5487

File tree

20 files changed

+514
-32
lines changed

20 files changed

+514
-32
lines changed

Makefile

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ rel: locked-deps compile
8282
rel-rpm: locked-deps compile
8383
$(REBAR) as rel,rpm release
8484

85+
rel-deb: locked-deps compile
86+
$(REBAR) as deb release
87+
cp -a _build/deb/rel/riak rel/
88+
8589
relclean:
8690
rm -rf $(REL_DIR)
8791
rm -rf rel/riak
@@ -303,8 +307,9 @@ pkgclean: ballclean
303307
PKG_VERSION = $(shell echo $(PKG_ID) | sed -e 's/^$(REPO)-//')
304308

305309
package:
310+
mkdir rel/pkg/out/riak-$(PKG_ID)
306311
git archive --format=tar HEAD | gzip >rel/pkg/out/riak-$(PKG_ID).tar.gz
307-
$(MAKE) -C rel/pkg/ -f Makefile
312+
$(MAKE) -f rel/pkg/Makefile
308313

309314
packageclean:
310315
rm -rf rel/pkg/out/*

rebar.config

Lines changed: 46 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
]}.
1919

2020
{project_plugins, [
21-
{rebar3_cuttlefish, {git, "https://github.com/basho/rebar3_cuttlefish", {branch, "develop-3.0"}}}
21+
{rebar3_cuttlefish, {git, "https://github.com/basho/rebar3_cuttlefish", {branch, "develop-3.0-debpkg"}}}
2222
]}.
2323

2424
{cuttlefish, [
@@ -91,50 +91,80 @@
9191

9292
]},
9393

94+
{overlay_vars, "rel/vars.config"},
95+
9496
{generate_start_script, true},
9597
{extended_start_script, true},
9698
{extended_start_script_extensions, [
9799
{admin, "riak-admin"},
98100
{debug, "riak-debug"},
99101
{repl, "riak-repl"},
100102
{chkconfig, "riak-chkconfig"}
101-
]},
102-
103+
]}
103104

104-
{extended_start_script_hooks,
105-
[ {pre_start,
106-
[{custom, "hooks/riak_not_running"},
107-
{custom, "hooks/check_ulimit"}]},
108-
{post_start,
109-
[{wait_for_process, riak_core_node_watcher}
110-
]}
111-
]}
112105
]}.
113106

114107
{dialyzer, [{plt_apps, all_deps}]}.
115108

116109
{profiles, [
117110
{rel, [
118111
{relx, [
119-
{overlay_vars, "rel/vars.config"}
112+
{extended_start_script_hooks,
113+
[{pre_start,
114+
[{custom, "hooks/riak_not_running"},
115+
{custom, "hooks/check_ulimit"}]},
116+
{post_start,
117+
[{wait_for_process, riak_core_node_watcher}]}
118+
]}
120119
]}
121120
]},
122121
{dev, [
123122
{relx, [
124-
{dev_mode, true}
123+
{dev_mode, true},
124+
{extended_start_script_hooks,
125+
[{pre_start,
126+
[{custom, "hooks/riak_not_running"},
127+
{custom, "hooks/check_ulimit"}]},
128+
{post_start,
129+
[{wait_for_process, riak_core_node_watcher}]}
130+
]}
125131
]}
126132
]},
127133
{rpm, [
128134
{relx, [
129135
{overlay_vars, "rpm.vars.config"},
130136
{overlay, [
131-
{template, "rel/pkg/rpm/riak", "usr/bin/riak"}
132-
]}
137+
{template, "rel/files/riak", "usr/bin/riak"},
138+
{template, "rel/files/riakpre", "usr/bin/riakpre"},
139+
{template, "rel/files/riakrun", "usr/bin/riakrun"}
140+
]},
141+
{extended_start_script_hooks,
142+
[{pre_start,
143+
[{custom, "hooks/riak_not_running"},
144+
{custom, "hooks/check_ulimit"}]},
145+
{post_start,
146+
[{pid, "/run/riak/riak.pid"},
147+
{wait_for_process, riak_core_node_watcher}]}
148+
]}
133149
]}
134150
]},
135151
{deb, [
136152
{relx, [
137-
{overlay_vars, "deb.vars.config"}
153+
{overlay_vars, "debian/vars.config"},
154+
{overlay, [
155+
{template, "rel/files/riak", "usr/bin/riak"},
156+
{template, "rel/files/riakpre", "usr/bin/riakpre"},
157+
{template, "rel/files/riakrun", "usr/bin/riakrun"}
158+
]},
159+
{extended_start_script_hooks,
160+
[{pre_start,
161+
[{custom, "hooks/riak_not_running"},
162+
{custom, "hooks/check_ulimit"}]},
163+
{post_start,
164+
[wait_for_vm_start,
165+
{pid, "/run/riak/riak.pid"},
166+
{wait_for_process, riak_core_node_watcher}]}
167+
]}
138168
]}
139169
]}
140170
]}.

rel/files/advanced.config

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,5 +100,9 @@
100100
]
101101
}
102102
]
103-
}
103+
},
104+
{setup,
105+
[
106+
{home, "{{platform_data_dir}}/setup"}
107+
]}
104108
].

rel/files/riak

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/bin/bash
2+
3+
source riakpre
4+
5+
su - riak -c "riakrun ${*}"
6+

rel/files/riakpre

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/bin/bash
2+
3+
RUNNER_GEN_DIR="${RUNNER_GEN_DIR:-{{ platform_gen_dir }}}"
4+
RELEASE_ROOT_DIR="${RELEASE_ROOT_DIR:-{{ runner_base_dir }}}"
5+
PID_DIR={{pid_dir}}
6+
7+
8+
# Switch (+) required on systemd to ensure this is run as root
9+
# as ExecStartPre
10+
if [[ $EUID -ne 0 ]]; then
11+
echo "You need to be root or use sudo to run this command."
12+
exit 1
13+
fi
14+
15+
# If calling ping, admin, stop etc - this has been started and so
16+
# these files should have been created by cf_config
17+
if [ -e "$RUNNER_GEN_DIR/vm.args" ]; then
18+
ln -sf $RUNNER_GEN_DIR/vm.args $RELEASE_ROOT_DIR/vm.args
19+
fi
20+
21+
if [ -e "$RUNNER_GEN_DIR/sys.config" ]; then
22+
ln -sf $RUNNER_GEN_DIR/sys.config $RELEASE_ROOT_DIR/sys.config
23+
fi
24+
25+
# Expect this to have been created by systemd, unless
26+
# user has called sudo /usr/sbin/riak directly
27+
if [ ! -d $PID_DIR ]; then
28+
mkdir $PID_DIR
29+
chown riak:riak $PID_DIR
30+
fi

rel/files/riakrun

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
COMMAND={{platform_bin_dir}}/riak
4+
RUNNER_LOG_DIR={{platform_log_dir}}
5+
6+
case "$1" in
7+
start|console|foreground)
8+
RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*} -pa {{platform_lib_dir}}/patches
9+
;;
10+
*)
11+
RUNNER_LOG_DIR=${RUNNER_LOG_DIR} PIPE_DIR=${PIPE_DIR} ${COMMAND} ${*}
12+
;;
13+
esac

rel/pkg/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ PKG_BUILD ?= 1
8383
## Call platform dependent makefile
8484
ostype: varcheck
8585
$(if $(PKGERDIR),,$(error "Operating system '$(OS)' not supported by node_package"))
86-
$(MAKE) -C $(PKGERDIR) -f Makefile
86+
$(MAKE) -C $(BASE_DIR)/rel/pkg/out/riak-$(PKG_ID) -f $(BASE_DIR)/rel/pkg/$(PKGERDIR)/Makefile
8787

8888
## Check required settings before continuing
8989
varcheck:

rel/pkg/deb/Makefile

Lines changed: 21 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,27 @@
1+
export
2+
3+
TAR_VERSION = $(shell git describe --tags | sed -e 's/\([0-9.]*\-[0-9]*\)-.*/\1/')
14

25
default:
3-
ln -sf $(PKG_ID).tar.gz ../{{package_name}}_$(PKG_VERSION).orig.tar.gz
4-
export DEBFULLNAME="{{vendor_contact_name}}"; \
5-
export DEBEMAIL="{{vendor_contact_email}}"; \
6-
dch --create --package {{package_name}} -v "$(PKG_VERSION)-$(PKG_BUILD)" \
7-
"Build from $(PKG_VERSION)";\
6+
mkdir -p $(BASE_DIR)/rel/pkg/out/riak-$(PKG_ID)/debian
7+
cp -R $(BASE_DIR)/rel/pkg/deb/debian/* $(BASE_DIR)/rel/pkg/out/riak-$(PKG_ID)/debian
8+
9+
tar -xf $(BASE_DIR)/rel/pkg/out/riak-$(PKG_ID).tar.gz -C $(BASE_DIR)/rel/pkg/out/riak-$(PKG_ID)/
10+
ln -sf $(BASE_DIR)/rel/pkg/out/riak-$(PKG_ID).tar.gz $(BASE_DIR)/rel/pkg/out/riak_$(TAR_VERSION).orig.tar.gz
11+
12+
cd $(BASE_DIR)/rel/pkg/out/riak-$(PKG_ID)/; \
13+
echo $(shell pwd); \
14+
dch --create --package riak -v "$(PKG_ID)" \
15+
"Build from $(PKG_ID)";\
816
debuild --prepend-path=$(ERLANG_BIN) \
9-
-e REVISION=$(PKG_VERSION) \
10-
-e RELEASE=$(PKG_BUILD) \
11-
-e REBAR=$(REBAR) \
12-
{{debuild_extra_options}} \
13-
-uc -us
14-
mkdir -p ../packages
15-
cd .. && mv *$(PKG_VERSION)-$(PKG_BUILD)_*.deb packages
16-
cd ../packages && \
17+
-e REVISION=$(PKG_VERSION) \
18+
-e RELEASE=$(PKG_BUILD) \
19+
-e REBAR=$(REBAR) \
20+
-i -uc -us -b
21+
22+
mkdir -p $(BASE_DIR)/rel/pkg/packages
23+
cd $(BASE_DIR)/rel/pkg/out && mv riak_*.deb ../packages
24+
cd $(BASE_DIR)/rel/pkg/packages && \
1725
for debfile in *.deb; do \
1826
sha256sum $${debfile} > $${debfile}.sha \
1927
; done

rel/pkg/deb/debian/compat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7

rel/pkg/deb/debian/control

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Source: riak
2+
Section: net
3+
Priority: extra
4+
Maintainer: packaging <[email protected]>
5+
Build-Depends: debhelper (>= 7)
6+
Standards-Version: 3.9.3
7+
Homepage: riak.com
8+
9+
Package: riak
10+
Architecture: any
11+
Depends: ${misc:Depends}, ${shlibs:Depends}, adduser, logrotate, sudo
12+
Homepage: riak.com
13+
Description: Riak KV Database

0 commit comments

Comments
 (0)