[vagrant] Remove conflict between the location of plugins.json and plugin gem's directories.
Vít Ondruch
vondruch at fedoraproject.org
Wed Jan 21 13:38:39 UTC 2015
commit a0e92dcbae8c3c541204c6b8512a346ee676c522
Author: Vít Ondruch <vondruch at redhat.com>
Date: Wed Nov 26 12:35:24 2014 +0100
Remove conflict between the location of plugins.json and plugin gem's directories.
macros.vagrant | 40 +++++++++++++++++++++++-----------------
vagrant.spec | 11 +++++++----
2 files changed, 30 insertions(+), 21 deletions(-)
---
diff --git a/macros.vagrant b/macros.vagrant
index 6636aba..0868b11 100644
--- a/macros.vagrant
+++ b/macros.vagrant
@@ -1,41 +1,47 @@
-# Common gem locations and files for Vagrant plugin
-%gem_dir /usr/share/vagrant/gems
-%gem_instdir %{gem_dir}/gems/%{gem_name}-%{version}
-%gem_extdir_mri %{_libdir}/gems/ruby/%{gem_name}-%{version}
-%gem_libdir %{gem_instdir}/lib
-%gem_cache %{gem_dir}/cache/%{gem_name}-%{version}.gem
-%gem_spec %{gem_dir}/specifications/%{gem_name}-%{version}.gemspec
-%gem_docdir %{gem_dir}/doc/%{gem_name}-%{version}
+%vagrant_dir %{_datadir}/%{name}
+
+%vagrant_plugin_conf_dir %{_sharedstatedir}/%{name}
+%vagrant_plugin_conf %{vagrant_plugin_conf_dir}/plugins.json
+
+# Common locations for Vagrant plugin gems
+%vagrant_plugin_dir %{vagrant_dir}/gems
+%vagrant_plugin_instdir %{vagrant_plugin_dir}/gems/%{vagrant_plugin_name}-%{version}
+# We are not prepared for paltfor dependent vagrant plugins yet.
+# %%vagrant_plugin_extdir %%{_libdir}/%%{name}/gems/ruby/%%{vagrant_plugin_name}-%%{version}
+%vagrant_plugin_libdir %{vagrant_plugin_instdir}/lib
+%vagrant_plugin_cache %{vagrant_plugin_dir}/cache/%{vagrant_plugin_name}-%{version}.gem
+%vagrant_plugin_spec %{vagrant_plugin_dir}/specifications/%{vagrant_plugin_name}-%{version}.gemspec
+%vagrant_plugin_docdir %{vagrant_plugin_dir}/doc/%{vagrant_plugin_name}-%{version}
# Install gem into appropriate directory.
-# -n<gem_file> Overrides gem file name for installation.
+# -n<vagrant_plugin_file> Overrides gem file name for installation.
# -d<install_dir> Set installation directory.
-%gem_install(d:n:) \
-mkdir -p %{-d*}%{!?-d:.%{gem_dir}} \
+%vagrant_plugin_install(d:n:) \
+mkdir -p %{-d*}%{!?-d:.%{vagrant_plugin_dir}} \
\
CONFIGURE_ARGS="--with-cflags='%{optflags}' $CONFIGURE_ARGS" \\\
gem install \\\
-V \\\
--local \\\
- --install-dir %{-d*}%{!?-d:.%{gem_dir}} \\\
+ --install-dir %{-d*}%{!?-d:.%{vagrant_plugin_dir}} \\\
--bindir .%{_bindir} \\\
--force \\\
--document=ri,rdoc \\\
--backtrace \\\
- %{-n*}%{!?-n:%{gem_name}-%{version}.gem} \
+ %{-n*}%{!?-n:%{vagrant_plugin_name}-%{version}.gem} \
%{nil}
# Macros to (un)register Vagrant gem
%vagrant_plugin_register() \
%{_bindir}/ruby -e ' \\\
-$LOAD_PATH.unshift "%{_datadir}/vagrant/lib"; \\\
+$LOAD_PATH.unshift "%{vagrant_dir}/lib"; \\\
require "vagrant/plugin/manager"; \\\
-Vagrant::Plugin::StateFile.new(Pathname.new(File.expand_path "/var/lib/vagrant/plugins.json")).add_plugin "%1";' \
+Vagrant::Plugin::StateFile.new(Pathname.new(File.expand_path "%{vagrant_plugin_conf}")).add_plugin "%1";' \
%{nil}
%vagrant_plugin_unregister() \
%{_bindir}/ruby -e ' \\\
-$LOAD_PATH.unshift "%{_datadir}/vagrant/lib"; \\\
+$LOAD_PATH.unshift "%{vagrant_dir}/lib"; \\\
require "vagrant/plugin/manager"; \\\
-Vagrant::Plugin::StateFile.new(Pathname.new(File.expand_path "/var/lib/vagrant/plugins.json")).remove_plugin "%1";' \
+Vagrant::Plugin::StateFile.new(Pathname.new(File.expand_path "%{vagrant_plugin_conf}")).remove_plugin "%1";' \
%{nil}
diff --git a/vagrant.spec b/vagrant.spec
index f1ae6cf..825f7f6 100644
--- a/vagrant.spec
+++ b/vagrant.spec
@@ -1,6 +1,4 @@
%global bashcompletion_dir %(pkg-config --variable=completionsdir bash-completion 2> /dev/null || :)
-%global vagrant_dir %{_datadir}/%{name}
-%global vagrant_plugin_dir %{_sharedstatedir}/%{name}
%global vagrant_spec_commit c0dafc996165bf1628b672dd533f1858ff66fe4a
@@ -26,6 +24,10 @@ Source3: patches.rb
Source4: macros.vagrant
+# The load directive is supported since RPM 4.12, i.e. F21+. The build process
+# fails on older Fedoras.
+%{?load:%{SOURCE4}}
+
Patch0: vagrant-1.6.5-fix-dependencies.patch
Requires: ruby(release)
@@ -110,14 +112,14 @@ rm %{buildroot}%{vagrant_dir}/LICENSE
# https://github.com/mitchellh/vagrant-installers/blob/master/substrate/modules/vagrant_installer/templates/vagrant.erb
install -D -m 755 %{SOURCE1} %{buildroot}%{_bindir}/vagrant
sed -i 's|@vagrant_dir@|%{vagrant_dir}|' %{buildroot}%{_bindir}/vagrant
-sed -i 's|@vagrant_plugin_dir@|%{vagrant_plugin_dir}|' %{buildroot}%{_bindir}/vagrant
+sed -i 's|@vagrant_plugin_conf_dir@|%{vagrant_plugin_conf_dir}|' %{buildroot}%{_bindir}/vagrant
# auto-completion
install -D -m 0644 %{buildroot}%{vagrant_dir}/contrib/bash/completion.sh \
%{buildroot}%{bashcompletion_dir}/%{name}
# create the global home dir
-install -d -m 755 %{buildroot}%{vagrant_plugin_dir}
+install -d -m 755 %{buildroot}%{vagrant_plugin_conf_dir}
# Install the monkey-patch file and load it from Vagrant after loading RubyGems
cp %{SOURCE3} %{buildroot}%{vagrant_dir}/lib/vagrant
@@ -126,6 +128,7 @@ sed -i -e "11irequire 'vagrant/patches'" %{buildroot}%{vagrant_dir}/lib/vagrant.
# Install Vagrant macros
mkdir -p %{buildroot}%{_rpmconfigdir}/macros.d/
cp %{SOURCE4} %{buildroot}%{_rpmconfigdir}/macros.d/
+sed -i "s/%%{name}/%{name}/" %{buildroot}%{_rpmconfigdir}/macros.d/macros.%{name}
%check
More information about the scm-commits
mailing list