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