Add --force-elevated option to updater test script to force the updater to request admin privileges.

This is useful when testing the application in cases where elevation
is required and in cases where it is not.
This commit is contained in:
Robert Knight 2011-09-14 10:06:01 +01:00
parent aa3282b582
commit 4258ab452d

View file

@ -2,6 +2,7 @@
require 'fileutils.rb'
require 'rbconfig'
require 'optparse'
# Install directory - this contains a space to check
# for correct escaping of paths when passing comamnd
@ -45,6 +46,14 @@ def zip_supports_bzip2(zip_tool)
return `#{zip_tool} -Z bzip2 testing-bzip2-support.zip`.strip.include?("Nothing to do")
end
force_elevation = false
OptionParser.new do |parser|
parser.on("-f","--force-elevated","Force the updater to elevate itself") do
force_elevation = true
end
end.parse!
BZIP2_AVAILABLE = zip_supports_bzip2(ZIP_TOOL)
if (BZIP2_AVAILABLE)
ZIP_FLAGS = "-Z bzip2"
@ -92,7 +101,8 @@ FileUtils.cp("../#{UPDATER_NAME}","#{PACKAGE_DIR}/#{UPDATER_NAME}")
#
install_path = File.expand_path(INSTALL_DIR)
Dir.chdir(INSTALL_DIR) do
cmd = "#{PACKAGE_DIR}/#{UPDATER_NAME} --install-dir \"#{install_path}\" --package-dir \"#{PACKAGE_DIR}\" --script file_list.xml"
flags = "--force-elevated" if force_elevation
cmd = "#{PACKAGE_DIR}/#{UPDATER_NAME} #{flags} --install-dir \"#{install_path}\" --package-dir \"#{PACKAGE_DIR}\" --script file_list.xml"
puts "Running '#{cmd}'"
system(cmd)
end