[packages/vagrant] add vagrant wrapper to setup gem env properly

glen glen at pld-linux.org
Wed Dec 17 15:14:33 CET 2014


commit 2fe4e4ef869e0f0255cf2e24cf392bc228625b32
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Wed Dec 17 16:12:38 2014 +0200

    add vagrant wrapper to setup gem env properly

 vagrant.sh   | 41 +++++++++++++++++++++++++++++++++++++++++
 vagrant.spec |  8 ++++----
 2 files changed, 45 insertions(+), 4 deletions(-)
---
diff --git a/vagrant.spec b/vagrant.spec
index a86c65e..70b1938 100644
--- a/vagrant.spec
+++ b/vagrant.spec
@@ -4,12 +4,12 @@ Summary:	Provisioning and deployment of virtual instances
 Name:		vagrant
 Version:	1.7.1
 # NOTE: test that it actually works before doing rel "1"
-Release:	0.3
+Release:	0.7
 License:	MIT
 Group:		Applications/Emulators
 Source0:	https://github.com/mitchellh/vagrant/archive/v%{version}/%{name}-%{version}.tar.gz
 # Source0-md5:	6bfb1440145f943e7b683ac99d06adec
-#Source100:	runtime-broken
+Source1:	%{name}.sh
 Patch0:		source_root.patch
 Patch1:		rubygems.patch
 Patch2:		no-warning.patch
@@ -114,7 +114,7 @@ Ruby documentation for %{gem_name}
 
 %prep
 %setup -q
-%patch0 -p1
+#%patch0 -p1
 %patch1 -p1
 %patch2 -p1
 %patch3 -p1
@@ -139,7 +139,7 @@ rm -rf $RPM_BUILD_ROOT
 install -d $RPM_BUILD_ROOT{%{ruby_gemdir}/gems/%{name}-%{version},%{ruby_specdir},%{_bindir}}
 cp -a lib bin keys plugins templates $RPM_BUILD_ROOT%{ruby_gemdir}/gems/%{name}-%{version}
 cp -p %{name}-%{version}.gemspec $RPM_BUILD_ROOT%{ruby_specdir}
-ln -s %{ruby_gemdir}/gems/%{name}-%{version}/bin/%{name} $RPM_BUILD_ROOT%{_bindir}
+install -p %{SOURCE1} $RPM_BUILD_ROOT%{_bindir}/%{name}
 
 install -d $RPM_BUILD_ROOT%{bash_compdir}
 cp -p contrib/bash/completion.sh $RPM_BUILD_ROOT%{bash_compdir}/%{name}
diff --git a/vagrant.sh b/vagrant.sh
new file mode 100755
index 0000000..839de53
--- /dev/null
+++ b/vagrant.sh
@@ -0,0 +1,41 @@
+#!/bin/sh
+#
+# This is a wrapper to properly execute Vagrant so that it sees system gems and
+# merges with it's own gems.
+#
+# This sets up proper environmental variables so that everything loads and
+# compiles to proper directories.
+
+# Set the path to the Ruby executable
+RUBY_EXECUTABLE="/usr/bin/ruby"
+
+GEM_PATH=$($RUBY_EXECUTABLE -r rubygems -e 'puts Gem.respond_to?(:default_dirs) ? Gem.default_dirs[:system][:gem_dir] : Gem.path.first')
+export GEM_PATH
+
+# Export gem paths so it can find vagrant own gem
+export GEM_HOME="${GEM_PATH}"
+
+# Export an enviromental variable to say we're in a Vagrant
+# installer created environment.
+export VAGRANT_INSTALLER_ENV=1
+
+# Unset any RUBYOPT and RUBYLIB, we don't want these bleeding into our
+# runtime.
+unset RUBYOPT
+unset RUBYLIB
+
+# Find the Vagrant executable
+for needle in "${GEM_PATH}/gems/vagrant-"*; do
+	if [ -f "${needle}/lib/vagrant/pre-rubygems.rb" ]; then
+		VAGRANT_GEM_PATH="${needle}"
+	fi
+done
+
+VAGRANT_EXECUTABLE="${VAGRANT_GEM_PATH}/bin/vagrant"
+VAGRANT_LAUNCHER="${VAGRANT_GEM_PATH}/lib/vagrant/pre-rubygems.rb"
+
+# Export the VAGRANT_EXECUTABLE so that pre-rubygems can optimize a bit
+export VAGRANT_EXECUTABLE
+
+# Call the actual Vagrant bin with our arguments
+exec "${RUBY_EXECUTABLE}" "${VAGRANT_LAUNCHER}" "$@"
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/vagrant.git/commitdiff/31d12dba9eb6742fc24b6aac0309639a5bf99d36



More information about the pld-cvs-commit mailing list