Revert "scripts/vagrant: Remove inline shell scripts"

This reverts commit 436b9be9d0.

Reason:
these change makes Vagrantfile rely on env variables (eg. spdk_dir),
which are only set when running scripts/vagrant/create_vbox.sh script.
After create_vbox.sh has finished env variables are not accessible,
but still needed to work with Vagrantfile using Vagrant commands
like 'vagrant ssh' or 'vagrant reload', etc. This results in
configuration errors from Vagrant and scripts being unusable.

Signed-off-by: Karol Latecki <karol.latecki@intel.com>
Change-Id: I135c42d248c13dfa93c2210dabce49df8116e8f0
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/3055
Reviewed-by: Maciej Wawryk <maciejx.wawryk@intel.com>
Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Mellanox Build Bot
This commit is contained in:
Karol Latecki 2020-06-25 13:18:24 +02:00 committed by Tomasz Zawadzki
parent cb98b2ab3e
commit afa0404c4b
5 changed files with 32 additions and 48 deletions

View File

@ -74,11 +74,14 @@ Vagrant.configure(2) do |config|
# Copy the tsocks configuration file for use when installing some spdk test pool dependencies # Copy the tsocks configuration file for use when installing some spdk test pool dependencies
if File.file?("/etc/tsocks.conf") if File.file?("/etc/tsocks.conf")
$tsocks_copy = <<-SCRIPT
sudo -s
mv -f tsocks.conf /etc/tsocks.conf
chown root /etc/tsocks.conf
chmod 644 /etc/tsocks.conf
SCRIPT
config.vm.provision "file", source: "/etc/tsocks.conf", destination: "tsocks.conf" config.vm.provision "file", source: "/etc/tsocks.conf", destination: "tsocks.conf"
config.vm.provision "shell" do |setup| config.vm.provision "shell", inline: $tsocks_copy
setup.path = "#{spdk_dir}/scripts/vagrant/vagrantfiles/tsocks_setup.sh"
setup.privileged = true
end
end end
# vagrant-cachier caches apt/yum etc to speed subsequent # vagrant-cachier caches apt/yum etc to speed subsequent
@ -102,11 +105,15 @@ Vagrant.configure(2) do |config|
# Proxyconf does not seem to support FreeBSD boxes or at least it's # Proxyconf does not seem to support FreeBSD boxes or at least it's
# docs do not mention that. Set up proxy configuration manually. # docs do not mention that. Set up proxy configuration manually.
if distro.include?("freebsd") if distro.include?("freebsd")
config.vm.provision "shell" do |setup| $freebsd_proxy = <<-SCRIPT
setup.path = "#{spdk_dir}/scripts/vagrant/vagrantfiles/freebsd_proxy.sh" sudo -s
setup.privileged = true echo "export http_proxy=#{ENV['http_proxy']}" >> /etc/profile
setup.args = ["#{ENV['http_proxy']}"] echo "export https_proxy=#{ENV['http_proxy']}" >> /etc/profile
end echo "pkg_env: {http_proxy: #{ENV['http_proxy']}}" > /usr/local/etc/pkg.conf
chown root:wheel /usr/local/etc/pkg.conf
chmod 644 /usr/local/etc/pkg.conf
SCRIPT
config.vm.provision "shell", inline: $freebsd_proxy
end end
end end
@ -115,10 +122,14 @@ Vagrant.configure(2) do |config|
# To make sources usable in the guest VM we need to unmount them and use # To make sources usable in the guest VM we need to unmount them and use
# local copy. # local copy.
if distro.include?("freebsd") if distro.include?("freebsd")
config.vm.provision "shell" do |setup| $freebsd_spdk_repo = <<-SCRIPT
setup.path = "#{spdk_dir}/scripts/vagrant/vagrantfiles/freebsd_spdk_repo.sh" sudo -s
setup.privileged = true cp -R /home/vagrant/spdk_repo/spdk /tmp/spdk
end umount /home/vagrant/spdk_repo/spdk && rm -rf /home/vagrant/spdk_repo/spdk
mv /tmp/spdk /home/vagrant/spdk_repo/spdk
chown -R vagrant:vagrant /home/vagrant/spdk_repo/spdk
SCRIPT
config.vm.provision "shell", inline: $freebsd_spdk_repo
end end
config.ssh.forward_agent = true config.ssh.forward_agent = true
@ -241,10 +252,14 @@ Vagrant.configure(2) do |config|
# Clear CFLAGS in clear linux # Clear CFLAGS in clear linux
if distro == "clearlinux" if distro == "clearlinux"
config.vm.provision "shell" do |setup| $clearcflags = <<-SCRIPT
setup.path = "#{spdk_dir}/scripts/vagrant/vagrantfiles/clearlinux_cflags.sh" echo "export CFLAGS=" >> /etc/profile.d/clearcflags.sh
setup.privileged = false echo "export CFFLAGS=" >> /etc/profile.d/clearcflags.sh
end echo "export CXXFLAGS=" >> /etc/profile.d/clearcflags.sh
echo "export FFLAGS=" >> /etc/profile.d/clearcflags.sh
echo "export THEANO_FLAGS=" >> /etc/profile.d/clearcflags.sh
SCRIPT
config.vm.provision "shell", inline: $clearcflags, run: "always"
end end
# Copy in the user's tools if they exists # Copy in the user's tools if they exists

View File

@ -1,9 +0,0 @@
#!/usr/bin/env bash
cat <<- FLAGS >> /etc/profile.d/clearcflags.sh
export CFLAGS=
export CFFLAGS=
export CXXFLAGS=
export FFLAGS=
export THEANO_FLAGS=
FLAGS

View File

@ -1,11 +0,0 @@
#!/usr/bin/env bash
http_proxy=$1
cat <<- PROXY >> /etc/profile
export http_proxy=${http_proxy}
export https_proxy=${http_proxy}
PROXY
echo "pkg_env: {http_proxy: ${http_proxy}" > /usr/local/etc/pkg.conf
chown root:wheel /usr/local/etc/pkg.conf
chmod 644 /usr/local/etc/pkg.conf

View File

@ -1,6 +0,0 @@
#!/usr/bin/env bash
cp -R /home/vagrant/spdk_repo/spdk /tmp/spdk
umount /home/vagrant/spdk_repo/spdk && rm -rf /home/vagrant/spdk_repo/spdk
mv /tmp/spdk /home/vagrant/spdk_repo/spdk
chown -R vagrant:vagrant /home/vagrant/spdk_repo/spdk

View File

@ -1,5 +0,0 @@
#!/usr/bin/env bash
mv -f tsocks.conf /etc/tsocks.conf
chown root /etc/tsocks.conf
chmod 644 /etc/tsocks.conf