Skip to content

Commit

Permalink
Merge pull request #65 from basho/jem-smartos-runner-patches
Browse files Browse the repository at this point in the history
Create patches for SmartOS packages to handle differing behavior
  • Loading branch information
jaredmorrow committed Jun 25, 2013
2 parents ff988bf + 69ae305 commit 6fb09aa
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 94 deletions.
16 changes: 13 additions & 3 deletions priv/templates/smartos/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ templates: $(BUILD_STAGE_DIR)
# file so the directories are created in the +INSTALL script
# We copy the data and log directories if they exist to make
# scanning them easier later
$(BUILD_STAGE_DIR): buildrel
$(BUILD_STAGE_DIR): buildrel patch_runner
@echo "Copying rel directory to staging directory"
mkdir -p $@
cp -R $(BUILDDIR)/rel/{{package_install_name}} $(BUILD_STAGE_DIR)
Expand Down Expand Up @@ -235,11 +235,21 @@ smartos_check:
$(if $(NCURSES_DEP),,$(error "Unsupported SmartOS version, please add to github.com/basho/node_package"))
@echo "Building for pkgsrc version $(PKGSRC_VERSION)"

# Patch the runner script with SmartOS modifications
patch_runner: buildrel
cp $(PKGERDIR)/runner.patch $(BUILDDIR)/rel/{{package_install_name}}/bin/
cp $(PKGERDIR)/env.patch $(BUILDDIR)/rel/{{package_install_name}}/lib/
cd $(BUILDDIR)/rel/{{package_install_name}}/bin && \
patch -p0 {{package_install_name}} runner.patch
rm $(BUILDDIR)/rel/{{package_install_name}}/bin/runner.patch
cd $(BUILDDIR)/rel/{{package_install_name}}/lib && \
patch -p0 env.sh env.patch
rm $(BUILDDIR)/rel/{{package_install_name}}/lib/env.patch


# Build the release we need to package
# * Patch rel/files/riak with our version
# * Ensure all binaries are executable
# * copy the vars.config over for build config
# TODO, solve the .patch issue we have in riak
buildrel: $(BUILDDIR) smartos_check
OVERLAY_VARS="overlay_vars=../smartos/vars.config" $(MAKE) deps rel
chmod 0755 $(BUILDDIR)/rel/{{package_install_name}}/bin/* $(BUILDDIR)/rel/{{package_install_name}}/erts-*/bin/*
Expand Down
4 changes: 4 additions & 0 deletions priv/templates/smartos/env.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
169c169
< exec sudo -H -u $RUNNER_USER -i $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
---
> exec sudo -H -u $RUNNER_USER $RUNNER_SCRIPT_DIR/$RUNNER_SCRIPT $@
2 changes: 1 addition & 1 deletion priv/templates/smartos/manifest131.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<envvar name="LOGNAME" value="{{package_install_user}}" />
<envvar name="PATH" value="/opt/local/bin:/opt/local/sbin:/usr/bin:/usr/sbin" />
<envvar name="LD_PRELOAD_32" value="/lib/libumem.so.1" />
<envvar name="LD_PRELOAD_64" value="/lib/amd64/libumem.so.1:/opt/local/gcc47/lib/amd64/libgcc_s.so.1"/>
<envvar name="LD_PRELOAD_64" value="/lib/amd64/libumem.so.1:/opt/local/gcc47/x86_64-sun-solaris2.11/lib/amd64/libgcc_s.so.1"/>
<envvar name="UMEM_OPTIONS" value="allocator=best" />
</method_environment>
</method_context>
Expand Down
89 changes: 0 additions & 89 deletions priv/templates/smartos/patches/rel-files.patch

This file was deleted.

40 changes: 40 additions & 0 deletions priv/templates/smartos/runner.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
54a55
>
57a59,64
> if [ "${SMF_METHOD}" != "start" ]; then
> echo "***"
> echo "Warning: please use 'svcadm enable $SCRIPT' instead"
> echo "***"
> fi
>
68,69c75,81
< # Warn the user if ulimit is too low
< check_ulimit
---
> # Make sure we have access to enough file descriptors
> ULIMIT_S=$(prctl -n process.max-file-descriptor -t basic -P $$ | awk '/max-file-descriptor/ { print $3 }')
> ULIMIT_H=$(prctl -n process.max-file-descriptor -t priv -P $$ | awk '/max-file-descriptor/ { print $3 }')
> if [ ${ULIMIT_S} -lt ${ULIMIT_H} ]; then
> echo "Trying to raise the file descriptor limit to maximum allowed."
> prctl -n process.max-file-descriptor -t basic -v ${ULIMIT_H} $$ || true
> fi
116a129
>
119a133,138
> if [ "${SMF_METHOD}" != "stop" ]; then
> echo "***"
> echo "Warning: please use 'svcadm disable $SCRIPT' instead"
> echo "***"
> fi
>
226,227c245,251
< # Warn the user if ulimit -n is less than the defined threshold
< check_ulimit
---
> # Make sure we have access to enough file descriptors
> ULIMIT_S=$(prctl -n process.max-file-descriptor -t basic -P $$ | awk '/max-file-descriptor/ { print $3 }')
> ULIMIT_H=$(prctl -n process.max-file-descriptor -t priv -P $$ | awk '/max-file-descriptor/ { print $3 }')
> if [ ${ULIMIT_S} -lt ${ULIMIT_H} ]; then
> echo "Trying to raise the file descriptor limit to maximum allowed."
> prctl -n process.max-file-descriptor -t basic -v ${ULIMIT_H} $$ || true
> fi
4 changes: 3 additions & 1 deletion priv/templates/smartos/smartos.template
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@
{template, "+DISPLAY", "+DISPLAY"}.
{template, "+INSTALL", "+INSTALL"}.
{template, "epmd-manifest.xml", "epmd-manifest.xml"}.
{template, "manifest16.xml", "manifest.xml"}.
{template, "manifest16.xml", "manifest16.xml"}.
{template, "manifest18.xml", "manifest18.xml"}.
{template, "manifest131.xml", "manifest131.xml"}.
{template, "epmd", "epmd"}.
{template, "runner.patch", "runner.patch"}.
{template, "env.patch", "env.patch"}.

0 comments on commit 6fb09aa

Please sign in to comment.