Skip to content

Commit 06d74ea

Browse files
author
Martin Cox
authored
3.0 packaging - RPM (#1000)
Port files over from node_package for building packages (RPM & DEB).
1 parent dcde1be commit 06d74ea

21 files changed

+765
-13
lines changed

Makefile

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ test : test-deps
8181
rel: locked-deps compile
8282
$(REBAR) as rel release
8383

84+
rel-rpm: locked-deps compile
85+
$(REBAR) as rpm release
86+
8487
relclean:
8588
rm -rf $(REL_DIR)
8689
rm -rf rel/riak
@@ -256,11 +259,7 @@ get_dist_deps = mkdir distdir && \
256259
# This enables the toplevel repository package to change names
257260
# when underlying dependencies change.
258261
NAME_HASH = $(shell git hash-object distdir/$(CLONEDIR)/$(MANIFEST_FILE) 2>/dev/null | cut -c 1-8)
259-
ifeq ($(REVISION), $(MAJOR_VERSION))
260262
PKG_ID := $(REPO_TAG)
261-
else
262-
PKG_ID = $(REPO)-$(MAJOR_VERSION)-$(NAME_HASH)
263-
endif
264263

265264
# To ensure a clean build, copy the CLONEDIR at a specific tag to a new directory
266265
# which will be the basis of the src tar file (and packages)
@@ -305,9 +304,13 @@ pkgclean: ballclean
305304
# which differs from $REVISION that is repo-<commitcount>-<commitsha>
306305
PKG_VERSION = $(shell echo $(PKG_ID) | sed -e 's/^$(REPO)-//')
307306

308-
package: distdir/$(PKG_ID).tar.gz
309-
ln -s distdir package
310-
$(MAKE) -C package -f $(PKG_ID)/deps/node_package/Makefile
307+
package:
308+
git archive --format=tar HEAD | gzip >rel/pkg/out/riak-3.0.tar.gz
309+
$(MAKE) -C rel/pkg/ -f Makefile
310+
311+
packageclean:
312+
rm -rf rel/pkg/out/*
313+
311314

312315
.PHONY: package
313316
export PKG_VERSION PKG_ID PKG_BUILD BASE_DIR ERLANG_BIN REBAR OVERLAY_VARS RELEASE

rebar.config

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
]}.
2121

2222
{project_plugins, [
23-
{rebar3_cuttlefish, {git, "https://github.com/martincox/rebar3_cuttlefish", {branch, "fix/output-dir-awareness"}}}
23+
{rebar3_cuttlefish, {git, "https://github.com/martincox/rebar3_cuttlefish", {branch, "fix/runner_dirs"}}}
2424
]}.
2525

2626
{cuttlefish, [
@@ -69,11 +69,13 @@
6969
yokozuna,
7070
riak_auth_mods]},
7171

72+
{overlay_vars, "rel/vars.config"},
7273
{dev_mode, false},
7374
{include_erts, true},
7475

7576
{overlay, [
76-
{mkdir, "lib/riak-patches"},
77+
{mkdir, "lib/patches"},
78+
{mkdir, "data/ring"},
7779

7880
{template, "rel/files/advanced.config", "etc/advanced.config"},
7981

@@ -111,14 +113,22 @@
111113
{dialyzer, [{plt_apps, all_deps}]}.
112114

113115
{profiles, [
114-
{rel, [
116+
{dev, [
115117
{relx, [
116-
{overlay_vars, "rel/vars.config"}
118+
{dev_mode, true}
117119
]}
118120
]},
119-
{dev, [
121+
{rpm, [
120122
{relx, [
121-
{dev_mode, true}
123+
{overlay_vars, "rpm.vars.config"},
124+
{overlay, [
125+
{template, "rel/pkg/rpm/riak", "usr/bin/riak"}
126+
]}
127+
]}
128+
]},
129+
{deb, [
130+
{relx, [
131+
{overlay_vars, "deb.vars.config"}
122132
]}
123133
]}
124134
]}.

rel/pkg/Makefile

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
##
2+
## Export all variables to sub-invocation
3+
##
4+
export
5+
6+
OS = $(shell uname -s)
7+
ERLANG_BIN ?= $(shell dirname $(shell which erl))
8+
DEPS_DIR ?= deps
9+
10+
##
11+
## Support RPM and Debian based linux systems
12+
##
13+
ifeq ($(OS),Linux)
14+
ARCH = $(shell uname -m)
15+
ISRPM = $(shell cat /etc/redhat-release 2> /dev/null)
16+
ISDEB = $(shell cat /etc/debian_version 2> /dev/null)
17+
ISSLES = $(shell cat /etc/SuSE-release 2> /dev/null)
18+
ifneq ($(ISRPM),)
19+
OSNAME = RedHat
20+
PKGERDIR = rpm
21+
BUILDDIR = rpmbuild
22+
else
23+
ifneq ($(ISDEB),)
24+
OSNAME = Debian
25+
PKGERDIR = deb
26+
BUILDDIR = debuild
27+
else
28+
ifneq ($(ISSLES),)
29+
OSNAME = SLES
30+
PKGERDIR = rpm
31+
BUILDDIR = rpmbuild
32+
endif # SLES
33+
endif # deb
34+
endif # rpm
35+
endif # linux
36+
37+
ifeq ($(OS),Darwin) # OSX
38+
OSNAME = OSX
39+
ARCH = $(shell file `which erlc` | grep -c x86_64 2> /dev/null | awk \
40+
'{if ($$1 == "0") {print "i386"} else {print "x86_64"}}')
41+
PKGERDIR = osx
42+
BUILDDIR = osxbuild
43+
endif
44+
45+
ifeq ($(OS),FreeBSD)
46+
OSNAME = FreeBSD
47+
ARCH = $(shell uname -m)
48+
BUILDDIR = fbsdbuild
49+
PKGNG = $(shell uname -r | awk -F. '{ print ($$1 > 9) ? "true" : "false" }')
50+
ifeq ($(PKGNG),true) # FreeBSD 10.0 or greater
51+
PKGERDIR = fbsdng
52+
else # Older FreeBSD pkg_add
53+
PKGERDIR = fbsd
54+
endif
55+
endif
56+
57+
ifeq ($(OS),SunOS) # Solaris flavors
58+
KERNELVER = $(shell uname -v | grep -c joyent 2> /dev/null)
59+
ARCH = $(shell file `which erlc` | grep -c 64-bit 2> /dev/null | awk \
60+
'{if ($$1 == "0") {print "i386"} else {print "x86_64"}}')
61+
62+
ifneq ($(KERNELVER),0) # SmartOS
63+
OSNAME = SmartOS
64+
PKGERDIR = smartos
65+
BUILDDIR = smartosbuild
66+
else # Solaris / OmniOS
67+
DISTRO = $(shell head -1 /etc/release|awk \
68+
'{if ($$1 == "OmniOS") {print $$1} else {print "Solaris"}}')
69+
OSNAME = ${DISTRO}
70+
PKGERDIR = solaris
71+
BUILDDIR = solarisbuild
72+
endif
73+
74+
endif
75+
76+
DATE = $(shell date +%Y-%m-%d)
77+
78+
# Default the package build version to 1 if not already set
79+
PKG_BUILD ?= 1
80+
81+
.PHONY: ostype varcheck
82+
83+
## Call platform dependent makefile
84+
ostype: varcheck
85+
$(if $(PKGERDIR),,$(error "Operating system '$(OS)' not supported by node_package"))
86+
$(MAKE) -C $(PKGERDIR) -f Makefile
87+
88+
## Check required settings before continuing
89+
varcheck:
90+
$(if $(PKG_VERSION),,$(error "Variable PKG_VERSION must be set and exported, see basho/node_package readme"))
91+
$(if $(PKG_ID),,$(error "Variable PKG_ID must be set and exported, see basho/node_package readme"))

rel/pkg/deb/Makefile

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
2+
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)";\
8+
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+
for debfile in *.deb; do \
18+
sha256sum $${debfile} > $${debfile}.sha \
19+
; done

rel/pkg/deb/compat

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

rel/pkg/deb/control

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
Source: {{package_name}}
2+
Section: net
3+
Priority: extra
4+
Maintainer: {{vendor_contact_name}} <{{vendor_contact_email}}>
5+
Build-Depends: debhelper (>= 7)
6+
Standards-Version: 3.9.3
7+
Homepage: {{vendor_url}}
8+
9+
Package: {{package_name}}
10+
Architecture: any
11+
Depends: ${misc:Depends}, ${shlibs:Depends}, adduser, logrotate, sudo, {{deb_depends}}
12+
Homepage: {{vendor_url}}
13+
Description: {{package_shortdesc}}
14+
{{package_desc}}
15+
{{package_replacement_line}}
16+
{{package_conflicts_line}}

rel/pkg/deb/copyright

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
Format: http://dep.debian.net/deps/dep5
2+
Upstream-Name: {{package_name}}
3+
Upstream-Contact: {{vendor_contact_name}} <{{vendor_contact_email}}>
4+
5+
Files: *
6+
Copyright: {{copyright}}
7+
License: {{license_type}}
8+
{{license_full_text}}

rel/pkg/deb/deb.template

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
2+
%%
3+
{variables, [
4+
{package_name, "package_name"},
5+
{package_install_name, "package_install_name"},
6+
{package_install_user, "package_install_user"},
7+
{package_install_user_desc, "package_install_user_desc"},
8+
{package_install_group, "package_install_group"},
9+
{package_replacement_line, "{{package_replacement_line_debian}}"},
10+
{package_conflicts_line, "{{package_conflicts_line_debian}}"},
11+
{vendor_name, "vendor_name"},
12+
{vendor_url, "vendor_url"},
13+
{vendor_contact_name, "vendor_contact_name"},
14+
{vendor_contact_email, "vendor_contact_email"},
15+
{copyright, "copyright"},
16+
{license_type, "license_type"},
17+
{license_full_text, ""},
18+
{bin_or_sbin, "bin"},
19+
20+
%% Platform Specific Settings
21+
{platform_bin_dir, "/usr/{{bin_or_sbin}}"},
22+
{platform_data_dir, "/var/lib/{{package_install_name}}"},
23+
{platform_etc_dir, "/etc/{{package_install_name}}"},
24+
{platform_base_dir, "/usr/lib/{{package_install_name}}"},
25+
{platform_lib_dir, "/usr/lib/{{package_install_name}}/lib"},
26+
{platform_log_dir, "/var/log/{{package_install_name}}"}
27+
]
28+
}.
29+
{template, "Makefile", "Makefile"}.
30+
{template, "compat", "compat"}.
31+
{template, "control", "control"}.
32+
{template, "copyright", "copyright"}.
33+
{template, "dirs", "dirs"}.
34+
{template, "install", "install"}.
35+
{template, "postinst", "postinst"}.
36+
{template, "postrm", "postrm"}.
37+
{template, "rules", "rules"}.
38+
{template, "vars.config", "vars.config"}.
39+
{template, "init.script", "{{package_name}}.{{package_install_name}}.init"}.
40+
{template, "package.service", "{{package_name}}.{{package_install_name}}.service"}.
41+
{template, "package.manpages", "{{package_name}}.manpages"}.

rel/pkg/deb/dirs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
etc/logrotate.d
2+
var/log/{{package_install_name}}

0 commit comments

Comments
 (0)