Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #179 from basho/jem-smartos-pkg

SmartOS packaging for Riak
  • Loading branch information...
commit 6b4e9344592bdb08908b702d6769699395ca76ce 2 parents 12e853f + 84948d8
@jaredmorrow jaredmorrow authored
View
29 package/Makefile
@@ -1,31 +1,44 @@
OS = $(shell uname -s)
KERNEL = $(shell uname -r)
ERLANG_BIN = $(shell dirname $(shell which erl))
-ifeq ($(OS),Linux)
+
+ifeq ($(OS),Linux) # Linux
ARCH = $(shell uname -m)
PKGER = $(shell cat /etc/redhat-release 2> /dev/null)
-ifeq ($(PKGER),)
+ifeq ($(PKGER),) # Debian / Ubuntu
OSNAME = Debian
PKGERDIR = deb
-else
+BUILDDIR = debuild
+else # Redhat / Centos
OSNAME = RedHat
PKGERDIR = rpm
+BUILDDIR = rpmbuild
endif
-endif
-ifeq ($(OS),SunOS)
+endif # linux
+
+ifeq ($(OS),SunOS) # Solaris flavors
+KERNELVER = $(shell uname -v | grep -c joyent 2> /dev/null)
ARCH = $(shell uname -p)
+
+ifneq ($(KERNELVER),0) # SmartOS
+OSNAME = SmartOS
+PKGERDIR = smartos
+BUILDDIR = smartosbuild
+else # Solaris / OmniOS
PKGERDIR = solaris
DISTRO = $(shell head -1 /etc/release|awk \
'{if ($$1 == "OmniOS") {print $$1} else {print "Solaris"}}')
OSNAME = ${DISTRO}
endif
-ifeq ($(OS),Darwin)
+endif # solaris
+
+ifeq ($(OS),Darwin) # OSX
OSNAME = OSX
ARCH = $(shell uname -m)
PKGERDIR = osx
BUILDDIR = osxbuild
endif
-ifeq ($(OS),FreeBSD)
+ifeq ($(OS),FreeBSD) # FreeBSD
OSNAME = $(OS)
ARCH = $(shell uname -p)
PKGERDIR = freebsd
@@ -44,7 +57,7 @@ $(APP)-$(PKG_VERSION).tar.gz: ../$(DISTNAME).tar.gz
ln -s $< $@
pkgclean: $(PKGERDIR)/pkgclean
- rm -rf $(APP)-*.tar.gz working rpmbuild debuild packages osxbuild bsdbuild
+ rm -rf $(APP)-*.tar.gz packages $(BUILDDIR)
pkgcheck:
$(if $(DISTNAME),,$(error "You can't generate a release tarball from a non-tagged revision. Run 'git checkout <tag>', then 'make dist'"))
View
7 package/smartos/+BUILD_INFO
@@ -0,0 +1,7 @@
+ABI=64
+MACHINE_ARCH=x86_64
+MACHINE_GNU_ARCH=x86_64
+OBJECT_FMT=ELF
+OPSYS=SunOS
+OS_VERSION=5.11
+PKGTOOLS_VERSION=20091115
View
1  package/smartos/+COMMENT
@@ -0,0 +1 @@
+Distributed, highly available data store
View
17 package/smartos/+DEINSTALL
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+if [ "$2" != "POST-DEINSTALL" ]; then
+ exit 0
+fi
+
+USER=riak
+
+if getent group "${USER}" 2>/dev/null 1>&2; then
+ echo "To delete ${USER} group permanently, use 'groupdel ${USER}'"
+fi
+
+if getent passwd "${USER}" 2>/dev/null 1>&2; then
+ echo "To delete ${USER} user permanently, use 'userdel ${USER}'"
+fi
+
+exit 0
View
10 package/smartos/+DESC
@@ -0,0 +1,10 @@
+Riak is a Dynamo-inspired key/value store with a distributed database
+network platform that makes storing and retrieving data simple, safe
+and low-cost. Riak liberates data from vulnerable centralized databases,
+allowing it to escape catastrophic losses and surges while accelerating
+the speed of applications. Riak has no single point of failure. Its
+multiple nodes create a truly fault-tolerant system for storing any
+type of mission-critical data.
+
+Homepage:
+http://basho.com/products/riak-overview/
View
33 package/smartos/+DISPLAY
@@ -0,0 +1,33 @@
+Thank you for installing Riak.
+
+Riak has been installed in /opt/local owned by user:group riak:riak
+
+The primary directories are:
+
+ {platform_bin_dir, "/opt/local/sbin"}
+ {platform_data_dir, "/var/db/riak"}
+ {platform_etc_dir, "/opt/local/etc/riak"}
+ {platform_lib_dir, "/opt/local/lib/riak"}
+ {platform_log_dir, "/var/log/riak"}
+
+These can be configured and changed in the platform_etc_dir/app.config.
+
+Add /opt/local/sbin to your path to run the riak, riak-admin, and search-cmd
+scripts directly.
+
+Man pages are available for riak(1), riak-admin(1), and search-cmd(1)
+
+//////////////////////////////////////////////////////////////////////////////
+
+This package is SMF enabled, which means you can use SMF to 'enable',
+'disable' or 'restart' the persistent daemon process, e.g.:
+
+ svcadm enable riak
+
+The SMF manifest was automatically imported now.
+
+See the SmartOS wiki on what's SMF and how to use it to your advantage:
+
+ http://wiki.joyent.com/display/smart/About+the+Service+Management+Facility
+
+//////////////////////////////////////////////////////////////////////////////
View
27 package/smartos/+INSTALL
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+if [ "$2" != "PRE-INSTALL" ]; then
+ exit 0
+fi
+
+USER=riak
+RIAK_DATA_DIR=/var/db/riak
+RIAK_LOG_DIR=/var/log/riak
+
+if ! getent group "${USER}" 2>/dev/null 1>&2; then
+ groupadd ${USER}
+fi
+
+if ! getent passwd "${USER}" 2>/dev/null 1>&2; then
+ useradd -g ${USER} -d /opt/local/lib/${USER} -s /bin/sh ${USER}
+fi
+
+# Create var directories outside of +CONTENTS
+mkdir -p ${RIAK_DATA_DIR}
+chown -R ${USER}:${USER} ${RIAK_DATA_DIR}
+chmod 770 ${RIAK_DATA_DIR}
+mkdir -p ${RIAK_LOG_DIR}
+chown -R ${USER}:${USER} ${RIAK_LOG_DIR}
+chmod 770 ${RIAK_LOG_DIR}
+
+exit 0
View
147 package/smartos/Makefile
@@ -0,0 +1,147 @@
+BUILD_RIAK_PATH = $(BUILDDIR)/$(REPO)-$(PKG_VERSION)
+BUILD_STAGE_DIR = $(BUILDDIR)/$(APP)
+
+# Where we install things (based on vars.config)
+# /opt/local based dirs
+PMAN_DIR = $(BUILD_STAGE_DIR)/man
+PBIN_DIR = $(BUILD_STAGE_DIR)/sbin
+PETC_DIR = $(BUILD_STAGE_DIR)/etc/riak
+PLIB_DIR = $(BUILD_STAGE_DIR)/lib/riak
+PSMF_DIR = $(BUILD_STAGE_DIR)/share/smf/riak
+
+# /var based dirs are handled in the +INSTALL file
+
+TARNAME = $(APP)-$(PKG_VERSION)-$(OSNAME)-$(ARCH).tar
+PKGNAME = $(APP)-$(PKG_VERSION)-$(OSNAME)-$(ARCH).tgz
+
+# pkg_add on Smartos requires that the tar file
+# and +CONTENTS files are in the exact same order
+# so we need to pack up the tar in a very
+# particular order to not anger pkg_add.
+# This is done by piping the file listings into tar
+# in the same manner we did with the +CONTENTS file
+build: packing_list_files
+ @echo "Building package $(PKGNAME)"
+ mkdir -p packages
+ cd $(BUILD_STAGE_DIR) && \
+ tar -cf $(TARNAME) +CONTENTS +COMMENT +DESC +INSTALL +DEINSTALL +DISPLAY +BUILD_INFO
+ cd $(BUILD_STAGE_DIR) && \
+ find man -type f | tar -rf $(TARNAME) -T - && \
+ find etc -type f | tar -rf $(TARNAME) -T - && \
+ find lib -type f | tar -rf $(TARNAME) -T - && \
+ find sbin -type f | tar -rf $(TARNAME) -T - && \
+ find share -type f | tar -rf $(TARNAME) -T -
+
+ cd $(BUILD_STAGE_DIR) && \
+ gzip $(TARNAME) && \
+ mv $(TARNAME).gz ../../packages/$(PKGNAME)
+
+ cd packages && \
+ for tarfile in `ls *.tgz`; do \
+ shasum -a 256 $${tarfile} > $${tarfile}.sha \
+ ; done
+
+# Where most of the magic (horror?) happens
+# Create a packing list according to pkg_create(1)
+# Write initial settings to a local file then copy
+# to the destination folder where we use 'find'
+# to populate the files and directories
+packing_list_files: $(BUILD_STAGE_DIR) templates
+ @echo "Adding to packaging list $(APP)-$(PKG_VERSION)"
+ echo "@name $(APP)-$(PKG_VERSION)" >> plist
+ echo "@pkgcfl riak-*" >> plist
+ echo "@pkgdep sudo-[0-9]*" >> plist
+ echo "@pkgdep openssl-0.9.8*" >> plist
+
+ @echo "Copying staging package listing to +CONTENTS"
+ mv plist $(BUILD_STAGE_DIR)/+CONTENTS
+
+ @echo "Packaging /opt/local files"
+ cd $(BUILD_STAGE_DIR) && \
+ echo "@cwd /opt/local" >> +CONTENTS && \
+ echo "@owner root" >> +CONTENTS && \
+ echo "@group root" >> +CONTENTS && \
+ find man -type f >> +CONTENTS
+
+ cd $(BUILD_STAGE_DIR) && \
+ echo "@cwd /opt/local" >> +CONTENTS && \
+ echo "@owner root" >> +CONTENTS && \
+ echo "@group root" >> +CONTENTS && \
+ find etc -type f >> +CONTENTS
+
+ cd $(BUILD_STAGE_DIR) && \
+ echo "@cwd /opt/local" >> +CONTENTS && \
+ echo "@owner riak" >> +CONTENTS && \
+ echo "@group riak" >> +CONTENTS
+ cd $(BUILD_STAGE_DIR) && \
+ find lib -type f >> +CONTENTS && \
+ echo "@exec chown -R riak:riak /opt/local/lib/riak" >> +CONTENTS
+ cd $(BUILD_STAGE_DIR) && \
+ echo "@owner riak" >> +CONTENTS && \
+ echo "@group riak" >> +CONTENTS && \
+ find sbin -type f >> +CONTENTS
+ cd $(BUILD_STAGE_DIR) && \
+ echo "@owner riak" >> +CONTENTS && \
+ echo "@group riak" >> +CONTENTS && \
+ find share -type f >> +CONTENTS
+
+ cd $(BUILD_STAGE_DIR) && \
+ echo "@display +DISPLAY" >> +CONTENTS
+
+
+# These are static files that should not have to change often
+templates: $(BUILD_STAGE_DIR)
+ @echo "Copying metadata files to package"
+ cp $(PKGERDIR)/+DESC $(PKGERDIR)/+COMMENT $(PKGERDIR)/+DEINSTALL \
+ $(PKGERDIR)/+INSTALL $(PKGERDIR)/+BUILD_INFO \
+ $(PKGERDIR)/+DISPLAY $(BUILD_STAGE_DIR)
+ mkdir -p $(PSMF_DIR)
+ cp $(PKGERDIR)/manifest.xml $(PSMF_DIR)
+
+
+# Copy the app rel directory to the staging directory to build our
+# package structure and move the directories into the right place
+# for the package, see the vars.config file for destination
+# directories
+# The data and log directories need to go into /var, but the
+# smartos pkg_add doesn't allow this to be in the +CONTENTS
+# file so the directories are created in the +INSTALL script
+$(BUILD_STAGE_DIR): buildrel
+ @echo "Copying rel directory to staging directory"
+ mkdir -p $@
+ cp -R $(BUILD_RIAK_PATH)/rel/riak $(BUILD_STAGE_DIR)
+ mkdir -p $(PBIN_DIR)
+ cp -R $(BUILD_RIAK_PATH)/rel/riak/bin/* $(PBIN_DIR)
+ mkdir -p $(PETC_DIR)
+ cp -R $(BUILD_RIAK_PATH)/rel/riak/etc/* $(PETC_DIR)
+ mkdir -p $(PLIB_DIR)
+ cp -R $(BUILD_RIAK_PATH)/rel/riak/lib $(PLIB_DIR)
+ cp -R $(BUILD_RIAK_PATH)/rel/riak/erts-* $(PLIB_DIR)
+ cp -R $(BUILD_RIAK_PATH)/rel/riak/releases $(PLIB_DIR)
+ echo "Copying man pages to staging directory"
+ mkdir -p $(PMAN_DIR)
+ cp -R $(BUILD_RIAK_PATH)/doc/man/man1 $(PMAN_DIR)
+
+
+
+# Build the release we need to package
+# * Ensure all binaries are executable
+# * copy the vars.config over for build config
+buildrel: $(BUILD_RIAK_PATH)
+ cp $(BUILD_RIAK_PATH)/rel/files/riak $(BUILD_RIAK_PATH)/rel/files/riak.tmp
+ sed -e "s/^RIAK_VERSION.*$$/RIAK_VERSION=\"${VERSIONSTRING}\"/" < \
+ $(BUILD_RIAK_PATH)/rel/files/riak.tmp > $(BUILD_RIAK_PATH)/rel/files/riak
+ cp -f $(PKGERDIR)/vars.config $(BUILD_RIAK_PATH)/rel/vars.config
+ $(MAKE) -C $(BUILD_RIAK_PATH) deps rel
+ chmod 0755 $(BUILD_RIAK_PATH)/rel/riak/bin/* $(BUILD_RIAK_PATH)/rel/riak/erts-*/bin/*
+
+
+
+$(BUILD_RIAK_PATH): $(BUILDDIR) $(APP)-$(PKG_VERSION).tar.gz
+ tar xz -C $(BUILDDIR) -f $(APP)-$(PKG_VERSION).tar.gz
+
+$(BUILDDIR):
+ mkdir -p $@
+
+$(PKGERDIR)/pkgclean:
+ rm -rf $(BUILD_STAGE_DIR) $(BUILDDIR)
View
37 package/smartos/manifest.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<service_bundle type="manifest" name="riak">
+ <service name="application/riak" type="service" version="1">
+ <create_default_instance enabled="false" />
+ <single_instance />
+ <dependency name="network" grouping="require_all" restart_on="error" type="service">
+ <service_fmri value="svc:/milestone/network:default" />
+ </dependency>
+ <dependency name="filesystem" grouping="require_all" restart_on="error" type="service">
+ <service_fmri value="svc:/system/filesystem/local" />
+ </dependency>
+ <method_context working_directory="/tmp" project="riak">
+ <method_credential user="riak" group="riak" />
+ <method_environment>
+ <envvar name="HOME" value="/opt/local/lib/riak" />
+ <envvar name="LOGNAME" value="riak" />
+ <envvar name="PATH" value="/usr/bin:/bin:/opt/local/bin:/opt/local/sbin" />
+ <envvar name="LD_PRELOAD_32" value="/lib/libumem.so.1" />
+ <envvar name="LD_PRELOAD_64" value="/lib/64/libumem.so.1:/opt/local/lib/amd64/libgcc_s.so.1"/>
+ <envvar name="UMEM_OPTIONS" value="allocator=best" />
+ </method_environment>
+ </method_context>
+ <exec_method type="method" name="start" exec="/opt/local/sbin/riak start" timeout_seconds="60" />
+ <exec_method type="method" name="stop" exec="/opt/local/sbin/riak stop" timeout_seconds="60" />
+ <property_group name="startd" type="framework">
+ <propval name="duration" type="astring" value="contract" />
+ <propval name="ignore_error" type="astring" value="core,signal" />
+ </property_group>
+ <stability value="Evolving" />
+ <template>
+ <common_name>
+ <loctext xml:lang="C">Riak Data Store</loctext>
+ </common_name>
+ </template>
+ </service>
+</service_bundle>
View
49 package/smartos/vars.config
@@ -0,0 +1,49 @@
+%% -*- mode: erlang;erlang-indent-level: 4;indent-tabs-mode: nil -*-
+%% ex: ft=erlang ts=4 sw=4 et
+
+% Platform-specific installation paths
+{platform_bin_dir, "/opt/local/sbin"}.
+{platform_data_dir, "/var/db/riak"}.
+{platform_etc_dir, "/opt/local/etc/riak"}.
+{platform_lib_dir, "/opt/local/lib/riak"}.
+{platform_log_dir, "/var/log/riak"}.
+
+
+%%
+%% etc/app.config
+%%
+{web_ip, "127.0.0.1"}.
+{web_port, 8098}.
+{handoff_port, 8099}.
+{pb_ip, "127.0.0.1"}.
+{pb_port, 8087}.
+{ring_state_dir, "{{platform_data_dir}}/ring"}.
+{bitcask_data_root, "{{platform_data_dir}}/bitcask"}.
+{leveldb_data_root, "{{platform_data_dir}}/leveldb"}.
+{sasl_error_log, "{{platform_log_dir}}/sasl-error.log"}.
+{sasl_log_dir, "{{platform_log_dir}}/sasl"}.
+{mapred_queue_dir, "{{platform_data_dir}}/mr_queue"}.
+
+%% riak_search
+{merge_index_data_root, "{{platform_data_dir}}/merge_index"}.
+
+%% Javascript VMs
+{map_js_vms, 8}.
+{reduce_js_vms, 6}.
+{hook_js_vms, 2}.
+
+%%
+%% etc/vm.args
+%%
+{node, "riak@127.0.0.1"}.
+{crash_dump, "{{platform_log_dir}}/erl_crash.dump"}.
+
+%%
+%% bin/riak
+%%
+{runner_script_dir, "{{platform_bin_dir}}"}.
+{runner_base_dir, "{{platform_lib_dir}}"}.
+{runner_etc_dir, "{{platform_etc_dir}}"}.
+{runner_log_dir, "{{platform_log_dir}}"}.
+{pipe_dir, "/tmp/riak/"}.
+{runner_user, "riak"}.
Please sign in to comment.
Something went wrong with that request. Please try again.