Class: Cpio
Instance Attribute Summary collapse
-
#cpio_data ⇒ Object
Returns the value of attribute cpio_data.
-
#data_dir ⇒ Object
readonly
Returns the value of attribute data_dir.
-
#extract_dir ⇒ Object
Returns the value of attribute extract_dir.
-
#rpm_file ⇒ Object
Returns the value of attribute rpm_file.
Attributes inherited from CliFuncs
#base_dir, #flags_all, #ignore_bad_exit, #output
Instance Method Summary collapse
- #cpio ⇒ Object
- #flags_extract_files ⇒ Object
-
#initialize ⇒ Cpio
constructor
A new instance of Cpio.
- #set_extract_flags ⇒ Object
Methods inherited from CliFuncs
#clear_values, #flag_add, #flags_run, #run_and_capture, #set_dirs
Constructor Details
#initialize ⇒ Cpio
Returns a new instance of Cpio.
8 9 10 11 12 13 14 15 |
# File 'lib/cli_funcs_cpio.rb', line 8 def initialize super @cpio_data @utility = CliUtils.new("cpio").utility_path @data_dir = SYSTEM_CONFIG["data_dir"] @extract_dir = "" set_extract_flags end |
Instance Attribute Details
#cpio_data ⇒ Object
Returns the value of attribute cpio_data.
5 6 7 |
# File 'lib/cli_funcs_cpio.rb', line 5 def cpio_data @cpio_data end |
#data_dir ⇒ Object (readonly)
Returns the value of attribute data_dir.
6 7 8 |
# File 'lib/cli_funcs_cpio.rb', line 6 def data_dir @data_dir end |
#extract_dir ⇒ Object
Returns the value of attribute extract_dir.
5 6 7 |
# File 'lib/cli_funcs_cpio.rb', line 5 def extract_dir @extract_dir end |
#rpm_file ⇒ Object
Returns the value of attribute rpm_file.
5 6 7 |
# File 'lib/cli_funcs_cpio.rb', line 5 def rpm_file @rpm_file end |
Instance Method Details
#cpio ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/cli_funcs_cpio.rb', line 17 def cpio begin FileUtils.mkdir_p @extract_dir unless Dir.exists? @extract_dir opts = { :chdir => @extract_dir, :err => "/dev/null" } io = IO.popen([@utility, flags_run].flatten, mode='r+', opts) io.puts @cpio_data io.close raise "Cpio data was zero in size, nothing extracted." if @cpio_data.length == 0 puts [@utility, flags_run, opts].flatten.inspect if DEBUG rescue Exception => e puts "Tried to run #{@utility} #{@rpm_file} #{opts.inspect} during Cpio.cpio, received exception: #{e}" end end |
#flags_extract_files ⇒ Object
35 36 37 |
# File 'lib/cli_funcs_cpio.rb', line 35 def flags_extract_files flag_add("-idm") end |
#set_extract_flags ⇒ Object
31 32 33 |
# File 'lib/cli_funcs_cpio.rb', line 31 def set_extract_flags flags_extract_files end |