24837601 facter, hiera,et al should use ruby-version-specific scripts
authorApril Chin <april.chin@oracle.com>
Tue, 18 Oct 2016 15:03:44 -0700
changeset 7130 73b1ef197337
parent 7129 6587d6b48782
child 7133 cabdc0719c92
24837601 facter, hiera,et al should use ruby-version-specific scripts
make-rules/puppetmodule.mk
make-rules/ruby.mk
make-rules/shared-macros.mk
--- a/make-rules/puppetmodule.mk	Tue Oct 04 14:04:16 2016 +0200
+++ b/make-rules/puppetmodule.mk	Tue Oct 18 15:03:44 2016 -0700
@@ -20,7 +20,7 @@
 #
 
 #
-# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
 #
 
 # Puppet modules do not have any concept of 'build' so make this a no-op
@@ -30,6 +30,15 @@
 	$(COMPONENT_POST_BUILD_ACTION)
 	$(TOUCH) [email protected]
 
+# Modify ruby scripts containing "#!/usr/bin/env ruby" to
+# use the version-specific ruby path, defined by the $(RUBY_VERSION) macro.
+# Without this change, the mediated ruby version in /usr/bin/ruby
+# will probably be used, which may not match the ruby
+# version supported by the puppet module.
+COMPONENT_POST_INSTALL_ACTION += \
+    cd $(PROTO_DIR); \
+    $(RUBY_SCRIPT_FIX_FUNC);
+
 # install the source into the proto directory
 $(BUILD_DIR)/%/.installed:      $(BUILD_DIR)/%/.built
 	$(COMPONENT_PRE_INSTALL_ACTION)
--- a/make-rules/ruby.mk	Tue Oct 04 14:04:16 2016 +0200
+++ b/make-rules/ruby.mk	Tue Oct 18 15:03:44 2016 -0700
@@ -31,3 +31,13 @@
 PKG_MACROS += RUBYV=$(subst .,,$(RUBY_VERSION))
 VENDOR_RUBY = /usr/ruby/$(RUBY_VERSION)/lib/ruby/vendor_ruby/$(RUBY_LIB_VERSION)
 VENDOR_RUBY_ARCH = /usr/ruby/$(RUBY_VERSION)/lib/ruby/vendor_ruby/$(RUBY_LIB_VERSION)/$(MACH64)-solaris$(SOLARIS_VERSION)
+
+# Modify ruby scripts in the ruby-version-specific path of the proto area,
+# under usr/ruby/$(RUBY_VERSION), containing "#!/usr/bin/env ruby" to
+# use the version-specific ruby path, defined by the $(RUBY_VERSION) macro.
+# Without this change, the mediated ruby version in /usr/bin/ruby
+# will probably be used, which may not match the ruby
+# version supported by the component.
+COMPONENT_POST_INSTALL_ACTION += \
+    cd $(PROTO_DIR)/usr/ruby/$(RUBY_VERSION); \
+    $(RUBY_SCRIPT_FIX_FUNC);
--- a/make-rules/shared-macros.mk	Tue Oct 04 14:04:16 2016 +0200
+++ b/make-rules/shared-macros.mk	Tue Oct 18 15:03:44 2016 -0700
@@ -514,6 +514,14 @@
 # both the ruby version and the ruby library version are needed. 
 RUBY_VERSIONS = $(RUBY_LIB_VERSION)
 
+# Transform Ruby scripts to call the supported
+# version-specific ruby; used in multiple *.mk files
+RUBY_SCRIPT_FIX_FUNC = \
+    $(GNU_GREP) -Rl '^\#! */usr/bin/env ruby' | \
+        /usr/bin/xargs -I\{\} $(GSED) -i -e \
+        '1s%^\#! */usr/bin/env ruby%\#!/usr/ruby/$(RUBY_VERSION)/bin/ruby%' \
+        \{\}
+
 PYTHON.2.7.VENDOR_PACKAGES.32 = /usr/lib/python2.7/vendor-packages
 PYTHON.2.7.VENDOR_PACKAGES.64 = /usr/lib/python2.7/vendor-packages/64
 PYTHON.2.7.VENDOR_PACKAGES = $(PYTHON.2.7.VENDOR_PACKAGES.$(BITS))