bin/tpkg in tpkg-1.22.1 vs bin/tpkg in tpkg-1.23.2

- old
+ new

@@ -237,14 +237,18 @@ @other_options[:force_replace] = opt end opts.on('--force', 'Force the execution of a given task') do |opt| @force = opt end -opts.on('--use-ssh-key', 'Use ssh key for deploying instead of password') do |opt| - @deploy_options["use-ssh-key"] = opt - @deploy_params = @deploy_params - ['--use-ssh-key'] +opts.on('-o', '--out', '=DIR', 'Output directory for the -m option') do |opt| + @other_options[:out] = opt end +opts.on('--use-ssh-key [FILE]', 'Use ssh key for deploying instead of password') do |opt| + @deploy_options["use-ssh-key"] = true + @deploy_options["ssh-key"] = opt + @deploy_params = @deploy_params - ['--use-ssh-key', opt, "--use-ssh-key=#{opt}"] +end opts.on('--deploy-as', '=USERNAME', 'What username to use for deploying to remote server') do |opt| @deploy_options["deploy-as"] = opt @deploy_params = @deploy_params - ['--deploy-as'] end opts.on('--compress', '=[TYPE]', 'Compress files when making packages') do |opt| @@ -339,22 +343,41 @@ # if @deploy # puts "Creating deployer with #{@worker_count} number of worker" @deploy_options["max-worker"] = @worker_count @deploy_options["abort-on-fail"] = false + + # check to see if ssh-key is accessible + ssh_key = @deploy_options["use-ssh-key"] + if ssh_key && ssh_key.is_a?(String) + if !File.readable?(ssh_key) && Process.euid == 0 + raise "Unable to read ssh key from #{ssh_key}" + elsif !File.readable?(ssh_key) + warn "Warning: Unable to read ssh key from #{ssh_key}. Attempting to rerun tpkg with sudo." + rerun_with_sudo_if_necessary + end + end + Tpkg::deploy(@deploy_params, @deploy_options, @servers) exit end if @action_value.is_a?(Array) @action_value.uniq! end +# tell tpkg not to prompt if stdin is not tty +if !$stdin.tty? + Tpkg::set_prompt(false) +end + ret_val = 0 case @action when :make - pkgfile = Tpkg::make_package(@action_value, passphrase_callback, {:force => @force, :compress => @compress}) + @other_options[:force] = @force + @other_options[:compress] = @compress + pkgfile = Tpkg::make_package(@action_value, passphrase_callback, @other_options) if pkgfile puts "Package is #{pkgfile}" else puts "Package build aborted or failed" end @@ -491,10 +514,10 @@ end when :query_who_owns_file tpkg = instantiate_tpkg(@tpkg_options) tpkg.files_for_installed_packages.each do |pkgfile, fip| fip[:normalized].each do |file| - if file == @action_value + if file == File.expand_path(@action_value) puts "#{file}: #{pkgfile}" end end end when :query_available