jenkins-bot has submitted this change and it was merged. ( 
https://gerrit.wikimedia.org/r/383034 )

Change subject: Simplify setup.{bat,sh}
......................................................................


Simplify setup.{bat,sh}

The complexity of finding the Vagrant ruby interpreter and running
custom ruby code is unnecessary since we switched from full plugin
install to sideloading in c8ca590 and stopped installing external
plugins. Instead we can just call `vagrant config --required`.

This change was prompted by a report on irc that the
"..\..\embedded\bin\ruby.exe" path is invalid with the latest version of
Vagrant for windows.

Bug: T171380
Change-Id: I161be221ff1c51eae029c0897d20de7a3271b7ad
---
M .rubocop_todo.yml
D lib/mediawiki-vagrant/setup.rb
M setup.bat
M setup.sh
D support/setup.rb
5 files changed, 8 insertions(+), 132 deletions(-)

Approvals:
  Brion VIBBER: Looks good to me, but someone else must approve
  BryanDavis: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml
index ec446ba..87348c8 100644
--- a/.rubocop_todo.yml
+++ b/.rubocop_todo.yml
@@ -62,7 +62,6 @@
   Exclude:
     - 'lib/mediawiki-vagrant/environment.rb'
     - 'lib/mediawiki-vagrant/roles/list.rb'
-    - 'lib/mediawiki-vagrant/setup.rb'
 
 # Offense count: 1
 # Configuration parameters: Methods.
diff --git a/lib/mediawiki-vagrant/setup.rb b/lib/mediawiki-vagrant/setup.rb
deleted file mode 100644
index 9592279..0000000
--- a/lib/mediawiki-vagrant/setup.rb
+++ /dev/null
@@ -1,89 +0,0 @@
-require 'English'
-require 'optparse'
-require 'rubygems'
-
-module MediaWikiVagrant
-  # Assists with the setup of MediaWiki-Vagrant.
-  #
-  # Provides an interactive set of prompts for configuration of required
-  # settings.
-  #
-  class Setup
-    class ExecutionError < RuntimeError
-      attr_reader :command, :status
-
-      def initialize(command, status)
-        @command = command
-        @status = status
-      end
-
-      def to_s
-        "Failed to execute command `#{command}` (#{status})"
-      end
-    end
-
-    attr_reader :directory, :options
-
-    # Creates a new setup runner from the given command-line invocation.
-    #
-    def initialize(invocation)
-      @silent = false
-      @directory = File.expand_path('..', invocation)
-
-      @options = OptionParser.new do |parser|
-        parser.banner = "Usage: #{invocation}"
-
-        parser.on('-s', '--silent', 'Run silently with no prompts or output') 
do
-          @silent = true
-        end
-
-        parser.on_tail('-h', '--help', 'Show this help message.') do
-          puts parser
-          exit
-        end
-      end
-    end
-
-    # Prompt the user to configure any required settings.
-    #
-    def run
-      @options.parse!
-
-      # Configure required settings
-      configure_settings unless @silent
-
-      notify "\nYou're all set! Simply run `vagrant up` to boot your new 
environment."
-      notify "\n(Or try `vagrant config --list` to see what else you can 
tweak.)"
-    end
-
-    private
-
-    # Prompts the user to configure required settings.
-    #
-    def configure_settings
-      vagrant('config', '--required') { |pipe| pipe.each_char { |c| print c } }
-    end
-
-    # Outputs the given message at the given indentation level unless we're
-    # operating in silent mode.
-    #
-    def notify(message_or_io, level = 0)
-      unless @silent
-        prefix = ('-' * level) + (level > 0 ? ' ' : '')
-        message_or_io.each_line { |line| puts "#{prefix}#{line}" }
-      end
-    end
-
-    # Executes the vagrant commands with the given arguments.
-    #
-    def vagrant(*args, &blk)
-      command = ['vagrant'] + args
-      blk ||= proc { |pipe| notify pipe, 1 }
-
-      result = IO.popen(command, err: [:child, :out], &blk)
-      raise ExecutionError.new(command.join(' '), $CHILD_STATUS) unless 
$CHILD_STATUS.success?
-
-      result
-    end
-  end
-end
diff --git a/setup.bat b/setup.bat
index a921499..272ed88 100644
--- a/setup.bat
+++ b/setup.bat
@@ -1,7 +1,5 @@
 @echo off
 
-rem Finds the Ruby embedded with Vagrant and executes setup.rb
-
 where /q vagrant.exe
 
 if errorlevel 1 (
@@ -12,6 +10,8 @@
     exit /b 1
 )
 
-for /f "tokens=*" %%F in ('where vagrant.exe') do set vagrant=%%F
+vagrant config --required
 
-"%vagrant%\..\..\embedded\bin\ruby.exe" "%~dp0\support\setup.rb" "%0" %*
+echo.
+echo "You're all set! Simply run `vagrant up` to boot your new environment."
+echo "(Or try `vagrant config --list` to see what else you can tweak.)"
diff --git a/setup.sh b/setup.sh
index 2a09f6a..7cd91a6 100755
--- a/setup.sh
+++ b/setup.sh
@@ -1,7 +1,4 @@
 #!/usr/bin/env bash
-#
-# Executes setup.rb using the Ruby bundled with Vagrant.
-#
 
 if ! which vagrant > /dev/null; then
     echo "Vagrant doesn't seem to be installed. Please download and install it"
@@ -9,22 +6,8 @@
     exit 1
 fi
 
-# These paths assume Vagrant was installed from the vendor-supplied packages
-if [ "$(uname)" == "Darwin" ]; then
-    ruby=/Applications/Vagrant/embedded/bin/ruby
-else
-    ruby=/opt/vagrant/embedded/bin/ruby
-fi
+vagrant config --required
 
-# Try to fallback on a system-installed ruby (as long as it's 1.9 or above)
-if [ ! -x "$ruby" ]; then
-    ruby="$(which ruby2.1 ruby2.0 ruby1.9.3 ruby1.9.1 ruby1.9 ruby | head -n 
1)"
-
-    if [ $? -gt 0 ] || "$ruby" -e 'exit RUBY_VERSION < "1.9"'; then
-        echo "A version of Ruby >= 1.9 isn't installed on your system and the"
-        echo "version bundled with Vagrant couldn't be found."
-        exit 2
-    fi
-fi
-
-"$ruby" "$(dirname "$0")/support/setup.rb" "$0" "$@"
+echo
+echo "You're all set! Simply run \`vagrant up\` to boot your new environment."
+echo "(Or try \`vagrant config --list\` to see what else you can tweak.)"
diff --git a/support/setup.rb b/support/setup.rb
deleted file mode 100644
index afda41b..0000000
--- a/support/setup.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# Cross-platform setup script for MediaWiki-Vagrant.
-#
-
-$LOAD_PATH << File.expand_path('../../lib', __FILE__)
-
-require 'mediawiki-vagrant/setup'
-
-begin
-  setup = MediaWikiVagrant::Setup.new(ARGV.shift)
-  setup.run
-rescue OptionParser::InvalidOption => e
-  STDERR.puts e
-  STDERR.puts setup.options
-rescue MediaWikiVagrant::Setup::ExecutionError => e
-  STDERR.puts e
-  exit e.status.exitstatus
-end

-- 
To view, visit https://gerrit.wikimedia.org/r/383034
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I161be221ff1c51eae029c0897d20de7a3271b7ad
Gerrit-PatchSet: 3
Gerrit-Project: mediawiki/vagrant
Gerrit-Branch: master
Gerrit-Owner: BryanDavis <bda...@wikimedia.org>
Gerrit-Reviewer: Brion VIBBER <br...@wikimedia.org>
Gerrit-Reviewer: BryanDavis <bda...@wikimedia.org>
Gerrit-Reviewer: Dduvall <dduv...@wikimedia.org>
Gerrit-Reviewer: Gergő Tisza <gti...@wikimedia.org>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to