Hello community, here is the log from the commit of package rubygem-mixlib-shellout for openSUSE:Factory checked in at 2015-02-11 16:46:08 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-mixlib-shellout (Old) and /work/SRC/openSUSE:Factory/.rubygem-mixlib-shellout.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-mixlib-shellout" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-mixlib-shellout/rubygem-mixlib-shellout.changes 2014-10-23 14:20:46.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-mixlib-shellout.new/rubygem-mixlib-shellout.changes 2015-02-11 16:46:11.000000000 +0100 @@ -1,0 +2,5 @@ +Mon Feb 9 10:04:38 UTC 2015 - coolo@suse.com + +- updated to version 2.0.1 + +------------------------------------------------------------------- Old: ---- mixlib-shellout-1.4.0.gem New: ---- gem2rpm.yml mixlib-shellout-2.0.1.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-mixlib-shellout.spec ++++++ --- /var/tmp/diff_new_pack.EYLVT7/_old 2015-02-11 16:46:12.000000000 +0100 +++ /var/tmp/diff_new_pack.EYLVT7/_new 2015-02-11 16:46:12.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package rubygem-mixlib-shellout # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -16,17 +16,25 @@ # +# +# This file was generated with a gem2rpm.yml and not just plain gem2rpm. +# All sections marked as MANUAL, license headers, summaries and descriptions +# can be maintained in that file. Please consult this file before editing any +# of those fields +# + Name: rubygem-mixlib-shellout -Version: 1.4.0 +Version: 2.0.1 Release: 0 %define mod_name mixlib-shellout %define mod_full_name %{mod_name}-%{version} BuildRoot: %{_tmppath}/%{name}-%{version}-build +BuildRequires: %{ruby >= 1.9.3} BuildRequires: %{rubygem gem2rpm} -BuildRequires: %{ruby} BuildRequires: ruby-macros >= 5 Url: http://wiki.opscode.com/ Source: http://rubygems.org/gems/%{mod_full_name}.gem +Source1: gem2rpm.yml Summary: Run external commands on Unix or Windows License: Apache-2.0 Group: Development/Languages/Ruby ++++++ gem2rpm.yml ++++++ # --- # ## used by gem2rpm # :summary: this is a custom summary # ## used by gem2rpm # :description: |- # this is a custom description # # it can be multiline # ## used by gem2rpm # :license: MIT or Ruby # ## used by gem2rpm and gem_packages # :version_suffix: -x_y # ## used by gem2rpm and gem_packages # :disable_docs: true # ## used by gem2rpm # :disable_automatic_rdoc_dep: true # ## used by gem2rpm # :preamble: |- # BuildRequires: foobar # Requires: foobar # ## used by gem2rpm # :patches: # foo.patch: -p1 # bar.patch: # ## used by gem2rpm :sources: # - foo.desktop # - bar.desktop # :gem_install_args: '....' # ## used by gem2rpm # :pre_install: |- # %if 0%{?use_system_libev} # export USE_VENDORED_LIBEV="no" # %endif # ## used by gem2rpm # :post_install: |- # # delete custom files here or do other fancy stuff # install -D -m 0644 %{S:1} %{buildroot}%{_bindir}/gem2rpm-opensuse # ## used by gem2rpm # :testsuite_command: |- # (pushd %{buildroot}%{gem_base}/gems/%{mod_full_name} && rake test) # ## used by gem2rpm # :filelist: |- # /usr/bin/gem2rpm-opensuse # ## used by gem2rpm # :scripts: # :post: |- # /bin/echo foo # ## used by gem_packages # :main: # :preamble: |- # Requires: util-linux # Recommends: pwgen # :filelist: |- # /usr/bin/gem2rpm-opensuse # ## used by gem_packages # :custom: # apache: # :preamble: |- # Requires: ..... # :filelist: |- # /etc/apache2/conf.d/passenger.conf # :summary: Custom summary is optional # :description: |- # Custom description is optional # # bar # :post: |- # /bin/echo foo # ++++++ mixlib-shellout-1.4.0.gem -> mixlib-shellout-2.0.1.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2014-04-08 21:06:11.000000000 +0200 +++ new/README.md 2014-12-19 19:44:46.000000000 +0100 @@ -37,7 +37,7 @@ crontab.run_command ## Windows Impersonation Example -Invoke crontab to edit user cron: +Invoke "whoami.exe" to demonstrate running a command as another user: whomai = Mixlib::ShellOut.new("whoami.exe", :user => "username", :domain => "DOMAIN", :password => "password") whoami.run_command @@ -51,4 +51,4 @@ ## See Also * `Process.spawn` in Ruby 1.9 -* [https://github.com/rtomayko/posix-spawn](posix-spawn) +* [https://github.com/rtomayko/posix-spawn](https://github.com/rtomayko/posix-spawn) Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mixlib/shellout/unix.rb new/lib/mixlib/shellout/unix.rb --- old/lib/mixlib/shellout/unix.rb 2014-04-08 21:06:11.000000000 +0200 +++ new/lib/mixlib/shellout/unix.rb 2014-12-19 19:44:46.000000000 +0100 @@ -115,14 +115,14 @@ # If the child dies very quickly, @child_pid may be a zombie, so handle # ESRCH here. @child_pgid = -Process.getpgid(@child_pid) - rescue Errno::ESRCH + rescue Errno::ESRCH, Errno::EPERM @child_pgid = nil end def set_user if user - Process.euid = uid Process.uid = uid + Process.euid = uid end end @@ -211,31 +211,6 @@ STDIN.sync = true if input end - # When a new process is started with chef, it shares the file - # descriptors of the parent. We clean the file descriptors - # coming from the parent to prevent unintended locking if parent - # is killed. - # NOTE: After some discussions we've decided to iterate on file - # descriptors upto 256. We believe this is a reasonable upper - # limit in a chef environment. If we have issues in the future this - # number could be made to be configurable or updated based on - # the ulimit based on platform. - def clean_parent_file_descriptors - # Don't clean $stdin, $stdout, $stderr, process_status_pipe. - 3.upto(256) do |n| - # We are checking the fd for error pipe before attempting to - # create a file because error pipe will auto close when we - # try to create a file since it's set to CLOEXEC. - if n != @process_status_pipe.last.to_i - begin - fd = File.for_fd(n) - fd.close if fd - rescue - end - end - end - end - def configure_parent_process_file_descriptors # Close the sides of the pipes we don't care about stdin_pipe.first.close @@ -254,7 +229,7 @@ # Some patch levels of ruby in wide use (in particular the ruby 1.8.6 on OSX) # segfault when you IO.select a pipe that's reached eof. Weak sauce. def open_pipes - @open_pipes ||= [child_stdout, child_stderr] + @open_pipes ||= [child_stdout, child_stderr, child_process_status] end # Keep this unbuffered for now @@ -266,11 +241,10 @@ def attempt_buffer_read ready = IO.select(open_pipes, nil, nil, READ_WAIT_TIME) - if ready && ready.first.include?(child_stdout) - read_stdout_to_buffer - end - if ready && ready.first.include?(child_stderr) - read_stderr_to_buffer + if ready + read_stdout_to_buffer if ready.first.include?(child_stdout) + read_stderr_to_buffer if ready.first.include?(child_stderr) + read_process_status_to_buffer if ready.first.include?(child_process_status) end ready end @@ -278,7 +252,7 @@ def read_stdout_to_buffer while chunk = child_stdout.read_nonblock(READ_SIZE) @stdout << chunk - @live_stream << chunk if @live_stream + @live_stdout << chunk if @live_stdout end rescue Errno::EAGAIN rescue EOFError @@ -288,12 +262,22 @@ def read_stderr_to_buffer while chunk = child_stderr.read_nonblock(READ_SIZE) @stderr << chunk + @live_stderr << chunk if @live_stderr end rescue Errno::EAGAIN rescue EOFError open_pipes.delete(child_stderr) end + def read_process_status_to_buffer + while chunk = child_process_status.read_nonblock(READ_SIZE) + @process_status << chunk + end + rescue Errno::EAGAIN + rescue EOFError + open_pipes.delete(child_process_status) + end + def fork_subprocess initialize_ipc @@ -304,12 +288,13 @@ # support the "ONESHOT" optimization (where sh -c does exec without # forking). To support cleaning up all the children, we need to # ensure they're in a unique process group. - Process.setsid + # We cannot use setsid here since getpgid fails on AIX with EPERM + # when parent and child have different sessions and the parent tries to get the process group, + # hence we just create a new process group, and have the same session. + Process.setpgrp configure_subprocess_file_descriptors - clean_parent_file_descriptors - set_group set_user set_environment @@ -317,7 +302,7 @@ set_cwd begin - command.kind_of?(Array) ? exec(*command) : exec(command) + command.kind_of?(Array) ? exec(*command, :close_others=>true) : exec(command, :close_others=>true) raise 'forty-two' # Should never get here rescue Exception => e @@ -334,23 +319,25 @@ # assume everything went well. def propagate_pre_exec_failure begin - e = Marshal.load child_process_status + attempt_buffer_read until child_process_status.eof? + e = Marshal.load(@process_status) raise(Exception === e ? e : "unknown failure: #{e.inspect}") - rescue EOFError # If we get an EOF error, then the exec was successful + rescue ArgumentError # If we get an ArgumentError error, then the exec was successful true ensure child_process_status.close + open_pipes.delete(child_process_status) end end def reap_errant_child return if attempt_reap - @terminate_reason = "Command execeded allowed execution time, process terminated" - logger.error("Command execeded allowed execution time, sending TERM") if logger + @terminate_reason = "Command exceeded allowed execution time, process terminated" + logger.error("Command exceeded allowed execution time, sending TERM") if logger Process.kill(:TERM, child_pgid) sleep 3 attempt_reap - logger.error("Command execeded allowed execution time, sending KILL") if logger + logger.error("Command exceeded allowed execution time, sending KILL") if logger Process.kill(:KILL, child_pgid) reap diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mixlib/shellout/version.rb new/lib/mixlib/shellout/version.rb --- old/lib/mixlib/shellout/version.rb 2014-04-08 21:06:11.000000000 +0200 +++ new/lib/mixlib/shellout/version.rb 2014-12-19 19:44:46.000000000 +0100 @@ -1,5 +1,5 @@ module Mixlib class ShellOut - VERSION = "1.4.0" + VERSION = "2.0.1" end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mixlib/shellout/windows.rb new/lib/mixlib/shellout/windows.rb --- old/lib/mixlib/shellout/windows.rb 2014-04-08 21:06:11.000000000 +0200 +++ new/lib/mixlib/shellout/windows.rb 2014-12-19 19:44:46.000000000 +0100 @@ -111,6 +111,12 @@ when WAIT_TIMEOUT # Kill the process if (Time.now - start_wait) > timeout + begin + Process.kill(:KILL, process.process_id) + rescue Errno::EIO + logger.warn("Failed to kill timed out process #{process.process_id}") if logger + end + raise Mixlib::ShellOut::CommandTimeout, "command timed out:\n#{format_for_exception}" end @@ -156,7 +162,7 @@ begin next_chunk = stdout_read.readpartial(READ_SIZE) @stdout << next_chunk - @live_stream << next_chunk if @live_stream + @live_stdout << next_chunk if @live_stdout rescue EOFError stdout_read.close open_streams.delete(stdout_read) @@ -165,7 +171,9 @@ if ready.first.include?(stderr_read) begin - @stderr << stderr_read.readpartial(READ_SIZE) + next_chunk = stderr_read.readpartial(READ_SIZE) + @stderr << next_chunk + @live_stderr << next_chunk if @live_stderr rescue EOFError stderr_read.close open_streams.delete(stderr_read) @@ -198,7 +206,6 @@ end end - # cmd does not parse multiple quotes well unless the whole thing is wrapped up in quotes. # https://github.com/opscode/mixlib-shellout/pull/2#issuecomment-4837859 # http://ss64.com/nt/syntax-esc.html diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mixlib/shellout.rb new/lib/mixlib/shellout.rb --- old/lib/mixlib/shellout.rb 2014-04-08 21:06:11.000000000 +0200 +++ new/lib/mixlib/shellout.rb 2014-12-19 19:44:46.000000000 +0100 @@ -27,7 +27,6 @@ READ_WAIT_TIME = 0.01 READ_SIZE = 4096 DEFAULT_READ_TIMEOUT = 600 - DEFAULT_ENVIRONMENT = {'LC_ALL' => 'C'} if RUBY_PLATFORM =~ /mswin|mingw32|windows/ require 'mixlib/shellout/windows' @@ -53,10 +52,13 @@ # to determine if the command was successful. Normally set via options to new attr_accessor :valid_exit_codes - # When live_stream is set, stdout of the subprocess will be copied to it as - # the subprocess is running. For example, if live_stream is set to STDOUT, - # the command's output will be echoed to STDOUT. - attr_accessor :live_stream + # When live_stdout is set, the stdout of the subprocess will be copied to it + # as the subprocess is running. + attr_accessor :live_stdout + + # When live_stderr is set, the stderr of the subprocess will be copied to it + # as the subprocess is running. + attr_accessor :live_stderr # ShellOut will push data from :input down the stdin of the subprocss. # Normally set via options passed to new. @@ -81,7 +83,7 @@ # Environment variables that will be set for the subcommand. Refer to the # documentation of new to understand how ShellOut interprets this. - attr_reader :environment + attr_accessor :environment # The maximum time this command is allowed to run. Usually set via options # to new @@ -122,16 +124,23 @@ # subprocess. This only has an effect if you call +error!+ after # +run_command+. # * +environment+: a Hash of environment variables to set before the command - # is run. By default, the environment will *always* be set to 'LC_ALL' => 'C' - # to prevent issues with multibyte characters in Ruby 1.8. To avoid this, - # use :environment => nil for *no* extra environment settings, or - # :environment => {'LC_ALL'=>nil, ...} to set other environment settings - # without changing the locale. + # is run. # * +timeout+: a Numeric value for the number of seconds to wait on the # child process before raising an Exception. This is calculated as the # total amount of time that ShellOut waited on the child process without # receiving any output (i.e., IO.select returned nil). Default is 60 # seconds. Note: the stdlib Timeout library is not used. + # * +input+: A String of data to be passed to the subcommand. This is + # written to the child process' stdin stream before the process is + # launched. The child's stdin stream will be a pipe, so the size of input + # data should not exceed the system's default pipe capacity (4096 bytes + # is a safe value, though on newer Linux systems the capacity is 64k by + # default). + # * +live_stream+: An IO or Logger-like object (must respond to the append + # operator +<<+) that will receive data as ShellOut reads it from the + # child process. Generally this is used to copy data from the child to + # the parent's stdout so that users may observe the progress of + # long-running commands. # === Examples: # Invoke find(1) to search for .rb files: # find = Mixlib::ShellOut.new("find . -name '*.rb'") @@ -146,12 +155,12 @@ # cmd = Mixlib::ShellOut.new("apachectl", "start", :user => 'www', :env => nil, :cwd => '/tmp') # cmd.run_command # etc. def initialize(*command_args) - @stdout, @stderr = '', '' - @live_stream = nil + @stdout, @stderr, @process_status = '', '', '' + @live_stdout = @live_stderr = nil @input = nil @log_level = :debug @log_tag = nil - @environment = DEFAULT_ENVIRONMENT + @environment = {} @cwd = nil @valid_exit_codes = [0] @terminate_reason = nil @@ -163,6 +172,18 @@ @command = command_args.size == 1 ? command_args.first : command_args end + # Returns the stream that both is being used by both live_stdout and live_stderr, or nil + def live_stream + live_stdout == live_stderr ? live_stdout : nil + end + + # A shortcut for setting both live_stdout and live_stderr, so that both the + # stdout and stderr from the subprocess will be copied to the same stream as + # the subprocess is running. + def live_stream=(stream) + @live_stdout = @live_stderr = stream + end + # Set the umask that the subprocess will have. If given as a string, it # will be converted to an integer by String#oct. def umask=(new_umask) @@ -286,7 +307,11 @@ when 'returns' self.valid_exit_codes = Array(setting) when 'live_stream' - self.live_stream = setting + self.live_stdout = self.live_stderr = setting + when 'live_stdout' + self.live_stdout = setting + when 'live_stderr' + self.live_stderr = setting when 'input' self.input = setting when 'logger' @@ -296,13 +321,7 @@ when 'log_tag' self.log_tag = setting when 'environment', 'env' - # Set the LC_ALL from the parent process if the user wanted - # to use the default. - if setting && setting.has_key?("LC_ALL") && setting['LC_ALL'].nil? - setting['LC_ALL'] = ENV['LC_ALL'] - end - # passing :environment => nil means don't set any new ENV vars - @environment = setting.nil? ? {} : @environment.dup.merge!(setting) + self.environment = setting || {} else raise InvalidCommandOption, "option '#{option.inspect}' is not a valid option for #{self.class.name}" diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2014-04-08 21:06:11.000000000 +0200 +++ new/metadata 2014-12-19 19:44:46.000000000 +0100 @@ -1,27 +1,27 @@ --- !ruby/object:Gem::Specification name: mixlib-shellout version: !ruby/object:Gem::Version - version: 1.4.0 + version: 2.0.1 platform: ruby authors: - Opscode autorequire: bindir: bin cert_chain: [] -date: 2014-04-08 00:00:00.000000000 Z +date: 2014-12-19 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rspec requirement: !ruby/object:Gem::Requirement requirements: - - - "~>" + - - ~> - !ruby/object:Gem::Version version: '2.0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - "~>" + - - ~> - !ruby/object:Gem::Version version: '2.0' description: Run external commands on Unix or Windows @@ -49,17 +49,17 @@ - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - ! '>=' - !ruby/object:Gem::Version - version: '0' + version: 1.9.3 required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - - ">=" + - - ! '>=' - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.2.2 +rubygems_version: 2.4.1 signing_key: specification_version: 4 summary: Run external commands on Unix or Windows -- To unsubscribe, e-mail: opensuse-commit+unsubscribe@opensuse.org For additional commands, e-mail: opensuse-commit+help@opensuse.org