module Megam::Install::ClassMethods
Public Instance Methods
copy(options, birr_opts)
click to toggle source
now run the stuff in parsed block. eg.pull out the directory and copy it.
# File lib/megam/install.rb 72 def copy (options, birr_opts) 73 cmd = Megam::WorkArea.new(options) 74 75 Birr.text.info(Birr.text.color("DUMP :", :green, :bold) + "dumping directory " + "#{cmd.directory}") 76 77 if cmd.directory_avail? 78 from_dir = Megam::Install.workarea_loader[(File.join(options[:method_name],cmd.directory))] 79 to_dir = Megam::TransferArea.convert_to_transferarea_dir(cmd.directory) 80 81 goahead_copy = Birr.text.agree("Do you wish to copy files from #{from_dir}\n to #{to_dir} [y/n]?") 82 83 if Dir.exists?(from_dir) && goahead_copy 84 #formulate the shell cp command, and returns it. now feed it to shelly and execute it. 85 cp_opts = { :from_dir => from_dir, 86 :to_dir => to_dir, 87 :sudo => birr_opts.sudo?, 88 :recursive => true, 89 :copy_on_new => true} 90 birr_opts.command(Megam::CmdVerb.cp(cp_opts)) 91 options[:message] = '' 92 shelly(options,birr_opts) 93 else 94 unless goahead_copy 95 then 96 Birr.text.warn "Skip : OK." 97 else 98 Birr.text.fatal "Skip : You need to specify an existing #{from_dir}\n in the :directory option to dump" 99 100 end 101 end 102 end 103 end
dump(options = {},&block)
click to toggle source
default parms del_if_exists is false message prints a dump directory string
# File lib/megam/install.rb 29 def dump(options = {},&block) 30 if block_given? 31 birr_opts = BirrOptions.new(&block) 32 options[:method_name] = __method__.to_s 33 copy(options,birr_opts) 34 end 35 end
install(options = {},&block)
click to toggle source
# File lib/megam/install.rb 48 def install(options = {},&block) 49 if block_given? 50 birr_opts = BirrOptions.new(&block) 51 cmd = Megam::WorkArea.new(options) 52 options[:method_name] = __method__.to_s 53 shelly(options,birr_opts) 54 end 55 end
script(options = {},&block)
click to toggle source
# File lib/megam/install.rb 37 def script(options = {},&block) 38 if block_given? 39 birr_opts = BirrOptions.new(&block) 40 cmd = Megam::WorkArea.new(options) 41 options[:method_name] = "package" 42 key = Megam::Install.workarea_loader[(File.join(options[:method_name],cmd.directory))] 43 birr_opts.command(cmd.find_package_script(options[:method_name]+'.'+cmd.directory, birr_opts.commands).fetch(key)) 44 shelly(options,birr_opts) 45 end 46 end
shelly(options ={},birr_opts)
click to toggle source
now run the stuff in parsed block. eg.pull out the command and run it.
# File lib/megam/install.rb 107 def shelly (options ={},birr_opts) 108 msg = '' 109 msg = options[:message] if options[:message] 110 Birr.text.info(Birr.text.color("INSTALL :", :green, :bold) + msg.to_s) unless !msg.strip 111 command ||= birr_opts.commands 112 unless !BirrOptions.method_defined?(:command) 113 command.each do |scmd| 114 Birr.text.info(Birr.text.color("SHELL :", :cyan, :bold) + scmd.to_s) 115 find = Mixlib::ShellOut.new(scmd.strip) 116 find.run_command 117 Birr.text.info find.stdout 118 find.error! 119 end 120 end 121 end
tarball(options = {},&block)
click to toggle source
# File lib/megam/install.rb 57 def tarball(options = {},&block) 58 if block_given? 59 birr_opts = BirrOptions.new(&block) 60 cmd = Megam::WorkArea.new(options) 61 options[:method_name] = __method__.to_s 62 tar_dir = Megam::Install.workarea_loader[(File.join(options[:method_name],cmd.directory.gsub(".", File::SEPARATOR)))] 63 64 tmp_opts = {:tar_file => File.join(tar_dir,birr_opts.tarball_file), :to_dir => Megam::TransferArea.convert_to_transferarea_dir(cmd.directory) } 65 birr_opts.command(Megam::CmdVerb.untar(tmp_opts)) 66 shelly(options, birr_opts) 67 end 68 end