Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,9 @@ test : test-deps
rel: locked-deps compile
$(REBAR) as rel release

rel-rpm: locked-deps compile
$(REBAR) as rpm release

relclean:
rm -rf $(REL_DIR)
rm -rf rel/riak
Expand Down Expand Up @@ -256,11 +259,7 @@ get_dist_deps = mkdir distdir && \
# This enables the toplevel repository package to change names
# when underlying dependencies change.
NAME_HASH = $(shell git hash-object distdir/$(CLONEDIR)/$(MANIFEST_FILE) 2>/dev/null | cut -c 1-8)
ifeq ($(REVISION), $(MAJOR_VERSION))
PKG_ID := $(REPO_TAG)
else
PKG_ID = $(REPO)-$(MAJOR_VERSION)-$(NAME_HASH)
endif

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

package: distdir/$(PKG_ID).tar.gz
ln -s distdir package
$(MAKE) -C package -f $(PKG_ID)/deps/node_package/Makefile
package:
git archive --format=tar HEAD | gzip >rel/pkg/out/riak-3.0.tar.gz
$(MAKE) -C rel/pkg/ -f Makefile

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


.PHONY: package
export PKG_VERSION PKG_ID PKG_BUILD BASE_DIR ERLANG_BIN REBAR OVERLAY_VARS RELEASE
Expand Down
22 changes: 16 additions & 6 deletions rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
]}.

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

{cuttlefish, [
Expand Down Expand Up @@ -69,11 +69,13 @@
yokozuna,
riak_auth_mods]},

{overlay_vars, "rel/vars.config"},
{dev_mode, false},
{include_erts, true},

{overlay, [
{mkdir, "lib/riak-patches"},
{mkdir, "lib/patches"},
{mkdir, "data/ring"},

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

Expand Down Expand Up @@ -111,14 +113,22 @@
{dialyzer, [{plt_apps, all_deps}]}.

{profiles, [
{rel, [
{dev, [
{relx, [
{overlay_vars, "rel/vars.config"}
{dev_mode, true}
]}
]},
{dev, [
{rpm, [
{relx, [
{dev_mode, true}
{overlay_vars, "rpm.vars.config"},
{overlay, [
{template, "rel/pkg/rpm/riak", "usr/bin/riak"}
]}
]}
]},
{deb, [
{relx, [
{overlay_vars, "deb.vars.config"}
]}
]}
]}.
91 changes: 91 additions & 0 deletions rel/pkg/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
##
## Export all variables to sub-invocation
##
export

OS = $(shell uname -s)
ERLANG_BIN ?= $(shell dirname $(shell which erl))
DEPS_DIR ?= deps

##
## Support RPM and Debian based linux systems
##
ifeq ($(OS),Linux)
ARCH = $(shell uname -m)
ISRPM = $(shell cat /etc/redhat-release 2> /dev/null)
ISDEB = $(shell cat /etc/debian_version 2> /dev/null)
ISSLES = $(shell cat /etc/SuSE-release 2> /dev/null)
ifneq ($(ISRPM),)
OSNAME = RedHat
PKGERDIR = rpm
BUILDDIR = rpmbuild
else
ifneq ($(ISDEB),)
OSNAME = Debian
PKGERDIR = deb
BUILDDIR = debuild
else
ifneq ($(ISSLES),)
OSNAME = SLES
PKGERDIR = rpm
BUILDDIR = rpmbuild
endif # SLES
endif # deb
endif # rpm
endif # linux

ifeq ($(OS),Darwin) # OSX
OSNAME = OSX
ARCH = $(shell file `which erlc` | grep -c x86_64 2> /dev/null | awk \
'{if ($$1 == "0") {print "i386"} else {print "x86_64"}}')
PKGERDIR = osx
BUILDDIR = osxbuild
endif

ifeq ($(OS),FreeBSD)
OSNAME = FreeBSD
ARCH = $(shell uname -m)
BUILDDIR = fbsdbuild
PKGNG = $(shell uname -r | awk -F. '{ print ($$1 > 9) ? "true" : "false" }')
ifeq ($(PKGNG),true) # FreeBSD 10.0 or greater
PKGERDIR = fbsdng
else # Older FreeBSD pkg_add
PKGERDIR = fbsd
endif
endif

ifeq ($(OS),SunOS) # Solaris flavors
KERNELVER = $(shell uname -v | grep -c joyent 2> /dev/null)
ARCH = $(shell file `which erlc` | grep -c 64-bit 2> /dev/null | awk \
'{if ($$1 == "0") {print "i386"} else {print "x86_64"}}')

ifneq ($(KERNELVER),0) # SmartOS
OSNAME = SmartOS
PKGERDIR = smartos
BUILDDIR = smartosbuild
else # Solaris / OmniOS
DISTRO = $(shell head -1 /etc/release|awk \
'{if ($$1 == "OmniOS") {print $$1} else {print "Solaris"}}')
OSNAME = ${DISTRO}
PKGERDIR = solaris
BUILDDIR = solarisbuild
endif

endif

DATE = $(shell date +%Y-%m-%d)

# Default the package build version to 1 if not already set
PKG_BUILD ?= 1

.PHONY: ostype varcheck

## Call platform dependent makefile
ostype: varcheck
$(if $(PKGERDIR),,$(error "Operating system '$(OS)' not supported by node_package"))
$(MAKE) -C $(PKGERDIR) -f Makefile

## Check required settings before continuing
varcheck:
$(if $(PKG_VERSION),,$(error "Variable PKG_VERSION must be set and exported, see basho/node_package readme"))
$(if $(PKG_ID),,$(error "Variable PKG_ID must be set and exported, see basho/node_package readme"))
19 changes: 19 additions & 0 deletions rel/pkg/deb/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

default:
ln -sf $(PKG_ID).tar.gz ../{{package_name}}_$(PKG_VERSION).orig.tar.gz
export DEBFULLNAME="{{vendor_contact_name}}"; \
export DEBEMAIL="{{vendor_contact_email}}"; \
dch --create --package {{package_name}} -v "$(PKG_VERSION)-$(PKG_BUILD)" \
"Build from $(PKG_VERSION)";\
debuild --prepend-path=$(ERLANG_BIN) \
-e REVISION=$(PKG_VERSION) \
-e RELEASE=$(PKG_BUILD) \
-e REBAR=$(REBAR) \
{{debuild_extra_options}} \
-uc -us
mkdir -p ../packages
cd .. && mv *$(PKG_VERSION)-$(PKG_BUILD)_*.deb packages
cd ../packages && \
for debfile in *.deb; do \
sha256sum $${debfile} > $${debfile}.sha \
; done
1 change: 1 addition & 0 deletions rel/pkg/deb/compat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
7
16 changes: 16 additions & 0 deletions rel/pkg/deb/control
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
Source: {{package_name}}
Section: net
Priority: extra
Maintainer: {{vendor_contact_name}} <{{vendor_contact_email}}>
Build-Depends: debhelper (>= 7)
Standards-Version: 3.9.3
Homepage: {{vendor_url}}

Package: {{package_name}}
Architecture: any
Depends: ${misc:Depends}, ${shlibs:Depends}, adduser, logrotate, sudo, {{deb_depends}}
Homepage: {{vendor_url}}
Description: {{package_shortdesc}}
{{package_desc}}
{{package_replacement_line}}
{{package_conflicts_line}}
8 changes: 8 additions & 0 deletions rel/pkg/deb/copyright
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Format: http://dep.debian.net/deps/dep5
Upstream-Name: {{package_name}}
Upstream-Contact: {{vendor_contact_name}} <{{vendor_contact_email}}>

Files: *
Copyright: {{copyright}}
License: {{license_type}}
{{license_full_text}}
41 changes: 41 additions & 0 deletions rel/pkg/deb/deb.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
%%
{variables, [
{package_name, "package_name"},
{package_install_name, "package_install_name"},
{package_install_user, "package_install_user"},
{package_install_user_desc, "package_install_user_desc"},
{package_install_group, "package_install_group"},
{package_replacement_line, "{{package_replacement_line_debian}}"},
{package_conflicts_line, "{{package_conflicts_line_debian}}"},
{vendor_name, "vendor_name"},
{vendor_url, "vendor_url"},
{vendor_contact_name, "vendor_contact_name"},
{vendor_contact_email, "vendor_contact_email"},
{copyright, "copyright"},
{license_type, "license_type"},
{license_full_text, ""},
{bin_or_sbin, "bin"},

%% Platform Specific Settings
{platform_bin_dir, "/usr/{{bin_or_sbin}}"},
{platform_data_dir, "/var/lib/{{package_install_name}}"},
{platform_etc_dir, "/etc/{{package_install_name}}"},
{platform_base_dir, "/usr/lib/{{package_install_name}}"},
{platform_lib_dir, "/usr/lib/{{package_install_name}}/lib"},
{platform_log_dir, "/var/log/{{package_install_name}}"}
]
}.
{template, "Makefile", "Makefile"}.
{template, "compat", "compat"}.
{template, "control", "control"}.
{template, "copyright", "copyright"}.
{template, "dirs", "dirs"}.
{template, "install", "install"}.
{template, "postinst", "postinst"}.
{template, "postrm", "postrm"}.
{template, "rules", "rules"}.
{template, "vars.config", "vars.config"}.
{template, "init.script", "{{package_name}}.{{package_install_name}}.init"}.
{template, "package.service", "{{package_name}}.{{package_install_name}}.service"}.
{template, "package.manpages", "{{package_name}}.manpages"}.
2 changes: 2 additions & 0 deletions rel/pkg/deb/dirs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
etc/logrotate.d
var/log/{{package_install_name}}
Loading