class Object
Constants
- AGENT_PACKAGES
- EQUIFAX_CA
- GEOTRUST_GLOBAL_CA
- GitHubSig
- GitURI
- InstallOptions
- MASTER_PACKAGES
- PREREQS
- RbConfig
- SourcePath
On Windows, '/' leads to a different path for Cygwin utils vs Git. Explicitly use the root drive.
- USERTRUST_NETWORK_CA
- Version
- WINDOWS
Public Instance Methods
build_rdoc(files)
click to toggle source
Build the rdoc documentation.
# File install.rb 260 def build_rdoc(files) 261 return unless $haverdoc 262 begin 263 r = RDoc::RDoc.new 264 r.document(["--main", "MCollective", "--line-numbers"] + files) 265 rescue RDoc::RDocError => e 266 $stderr.puts e.message 267 rescue Exception => e 268 $stderr.puts "Couldn't build RDoc documentation\n#{e.message}" 269 end 270 end
check_prereqs()
click to toggle source
# File install.rb 66 def check_prereqs 67 PREREQS.each do |pre| 68 begin 69 require pre 70 rescue LoadError 71 puts "Could not load #{pre} Ruby library; cannot install" 72 exit(-1) 73 end 74 end 75 end
do_bins(bins, target, strip = 's?bin/')
click to toggle source
# File install.rb 87 def do_bins(bins, target, strip = 's?bin/') 88 Dir.mkdir(target) unless File.directory? target 89 bins.each do |bf| 90 obf = bf.gsub(/#{strip}/, '') 91 install_binfile(bf, obf, target) 92 end 93 end
do_configs(configs, target, strip = 'etc/')
click to toggle source
# File install.rb 77 def do_configs(configs, target, strip = 'etc/') 78 Dir.mkdir(target) unless File.directory? target 79 configs.each do |cf| 80 ocf = File.join(target, cf.gsub(Regexp.new(strip), '')) 81 oc = File.dirname(ocf) 82 makedirs(oc, {:mode => 0755, :verbose => true}) 83 install(cf, ocf, {:mode => 0644, :preserve => true, :verbose => true}) 84 end 85 end
do_libs(libs, target, strip = 'lib/')
click to toggle source
# File install.rb 95 def do_libs(libs, target, strip = 'lib/') 96 libs.each do |lf| 97 olf = File.join(target, lf.sub(/^#{strip}/, '')) 98 op = File.dirname(olf) 99 if File.directory?(lf) 100 makedirs(olf, {:mode => 0755, :verbose => true}) 101 else 102 makedirs(op, {:mode => 0755, :verbose => true}) 103 install(lf, olf, {:mode => 0644, :preserve => true, :verbose => true}) 104 end 105 end 106 end
glob(list)
click to toggle source
# File install.rb 58 def glob(list) 59 g = list.map { |i| Dir.glob(i) } 60 g.flatten! 61 g.compact! 62 g.uniq! 63 g 64 end
install_binfile(from, op_file, target)
click to toggle source
Install file(s) from ./bin to RbConfig::CONFIG. Patch it on the way to insert a #! line; on a Unix install, the command is named as expected
# File install.rb 275 def install_binfile(from, op_file, target) 276 tmp_file = Tempfile.new('mcollective-binfile') 277 278 if InstallOptions.ruby 279 ruby = InstallOptions.ruby 280 else 281 ruby = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name']) 282 end 283 284 File.open(from) do |ip| 285 File.open(tmp_file.path, "w") do |op| 286 op.puts "#!#{ruby}" unless WINDOWS 287 contents = ip.readlines 288 contents.shift if contents[0] =~ /^#!/ 289 op.write contents.join 290 end 291 end 292 293 install(tmp_file.path, File.join(target, op_file), :mode => 0755, :preserve => true, :verbose => true) 294 tmp_file.unlink 295 end
last_run_report(h)
click to toggle source
# File acceptance/tests/mco_puppet_exec.rb 42 def last_run_report(h) 43 if h['platform'] =~ /windows/ 44 'C:/ProgramData/PuppetLabs/puppet/cache' 45 else 46 '/opt/puppetlabs/puppet/cache' 47 end + '/state/last_run_report.yaml' 48 end
prepare_installation()
click to toggle source
Prepare the file installation.
# File install.rb 111 def prepare_installation 112 InstallOptions.configs = true 113 InstallOptions.batch_files = true 114 # Only try to do docs if we're sure they have rdoc 115 if $haverdoc 116 InstallOptions.rdoc = true 117 else 118 InstallOptions.rdoc = false 119 end 120 121 122 ARGV.options do |opts| 123 opts.banner = "Usage: #{File.basename($0)} [options]" 124 opts.separator "" 125 opts.on('--[no-]rdoc', 'Creation of RDoc output.', 'Default is create rdoc.') do |onrdoc| 126 InstallOptions.rdoc = onrdoc 127 end 128 opts.on('--[no-]configs', 'Installation of config files', 'Default is install configs.') do |onconfigs| 129 InstallOptions.configs = onconfigs 130 end 131 opts.on('--destdir[=OPTIONAL]', 'Installation prefix for all targets', 'Default essentially /') do |destdir| 132 InstallOptions.destdir = destdir 133 end 134 opts.on('--configdir[=OPTIONAL]', 'Installation directory for config files', 'Default /etc/mcollective') do |configdir| 135 InstallOptions.configdir = configdir 136 end 137 opts.on('--bindir[=OPTIONAL]', 'Installation directory for binaries', 'overrides RbConfig::CONFIG["bindir"]') do |bindir| 138 InstallOptions.bindir = bindir 139 end 140 opts.on('--sbindir[=OPTIONAL]', 'Installation directory for system binaries', 'overrides RbConfig::CONFIG["sbindir"]') do |sbindir| 141 InstallOptions.sbindir = sbindir 142 end 143 opts.on('--ruby[=OPTIONAL]', 'Ruby interpreter to use with installation', 'overrides ruby used to call install.rb') do |ruby| 144 InstallOptions.ruby = ruby 145 end 146 opts.on('--sitelibdir[=OPTIONAL]', 'Installation directory for libraries', 'overrides RbConfig::CONFIG["sitelibdir"]') do |sitelibdir| 147 InstallOptions.sitelibdir = sitelibdir 148 end 149 opts.on('--plugindir[=OPTIONAL]', 'Installation directory for plugins', 'Default /usr/libexec/mcollective') do |plugindir| 150 InstallOptions.plugindir = plugindir 151 end 152 opts.on('--no-batch-files', 'Prevents installation of batch files for windows', 'Default off') do |batch_files| 153 InstallOptions.batch_files = false 154 end 155 opts.on('--quick', 'Performs a quick installation. Only the', 'installation is done.') do |quick| 156 InstallOptions.rdoc = false 157 InstallOptions.ri = false 158 InstallOptions.configs = true 159 end 160 opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full| 161 InstallOptions.rdoc = true 162 InstallOptions.ri = true 163 InstallOptions.configs = true 164 end 165 if WINDOWS 166 InstallOptions.service_files = true 167 opts.on('--[no-]service-files', 'Installation of windows service files', 'Default is to install the windows service files') do |service_files| 168 InstallOptions.service_files = service_files 169 end 170 end 171 opts.separator("") 172 opts.on_tail('--help', "Shows this help text.") do 173 $stderr.puts opts 174 exit 175 end 176 177 opts.parse! 178 end 179 180 version = [RbConfig::CONFIG["MAJOR"], RbConfig::CONFIG["MINOR"]].join(".") 181 libdir = File.join(RbConfig::CONFIG["libdir"], "ruby", version) 182 183 # Mac OS X 10.5 and higher declare bindir 184 # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin 185 # which is not generally where people expect executables to be installed 186 # These settings are appropriate defaults for all OS X versions. 187 if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/ 188 RbConfig::CONFIG['bindir'] = "/usr/bin" 189 RbConfig::CONFIG['sbindir'] = "/usr/sbin" 190 end 191 192 if InstallOptions.configdir 193 configdir = InstallOptions.configdir 194 else 195 configdir = "/etc/mcollective" 196 end 197 198 if InstallOptions.bindir 199 bindir = InstallOptions.bindir 200 else 201 bindir = RbConfig::CONFIG['bindir'] 202 end 203 204 if InstallOptions.sbindir 205 sbindir = InstallOptions.sbindir 206 else 207 sbindir = RbConfig::CONFIG['sbindir'] 208 end 209 210 if InstallOptions.sitelibdir 211 sitelibdir = InstallOptions.sitelibdir 212 else 213 sitelibdir = RbConfig::CONFIG["sitelibdir"] 214 if sitelibdir.nil? 215 sitelibdir = $LOAD_PATH.find { |x| x =~ /site_ruby/ } 216 if sitelibdir.nil? 217 sitelibdir = File.join(libdir, "site_ruby") 218 elsif sitelibdir !~ Regexp.quote(version) 219 sitelibdir = File.join(sitelibdir, version) 220 end 221 end 222 end 223 224 if InstallOptions.plugindir 225 plugindir = InstallOptions.plugindir 226 else 227 plugindir = "/usr/libexec/mcollective" 228 end 229 230 if InstallOptions.destdir 231 destdir = InstallOptions.destdir 232 else 233 destdir = '' 234 end 235 236 unless destdir.empty? 237 configdir = File.join(destdir, configdir) 238 bindir = File.join(destdir, bindir) 239 sbindir = File.join(destdir, sbindir) 240 sitelibdir = File.join(destdir, sitelibdir) 241 plugindir = File.join(destdir, plugindir) 242 end 243 244 makedirs(configdir) if InstallOptions.configs 245 makedirs(bindir) 246 makedirs(sbindir) 247 makedirs(sitelibdir) 248 makedirs(plugindir) 249 250 InstallOptions.sitelibdir = sitelibdir 251 InstallOptions.configdir = configdir 252 InstallOptions.bindir = bindir 253 InstallOptions.sbindir = sbindir 254 InstallOptions.plugindir = plugindir 255 end
testfile(h)
click to toggle source
# File acceptance/tests/mco_puppet_runonce.rb 6 def testfile(h) 7 if /windows/ =~ h[:platform] 8 "C:/#{@testfilename}" 9 else 10 "/tmp/#{@testfilename}" 11 end 12 end