~nvalcarcel/ubuntu/lucid/puppet/fix-546677

« back to all changes in this revision

Viewing changes to install.rb

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-23 00:48:10 UTC
  • mfrom: (1.1.10 upstream) (3.1.7 squeeze)
  • Revision ID: james.westby@ubuntu.com-20091223004810-3i4oryds922g5n59
Tags: 0.25.1-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/rules:
    + Don't start puppet when first installing puppet.
  - debian/puppet.conf, lib/puppet/defaults.rb:
    + Move templates to /etc/puppet
  - lib/puppet/defaults.rb:
    + Fix /var/lib/puppet/state ownership.
  - man/man8/puppet.conf.8: 
    + Fix broken URL in manpage.
  - debian/control:
    + Update maintainer accordint to spec.
    + Puppetmaster Recommends -> Suggests
    + Created puppet-testsuite as a seperate. Allow the users to run puppet's 
      testsuite.
  - tests/Rakefile: Fix rakefile so that the testsuite can acutally be ran.

Show diffs side-by-side

added added

removed removed

Lines of Context:
35
35
require 'rbconfig'
36
36
require 'find'
37
37
require 'fileutils'
38
 
require 'ftools' # apparently on some system ftools doesn't get loaded
 
38
begin
 
39
  require 'ftools' # apparently on some system ftools doesn't get loaded
 
40
  $haveftools = true
 
41
rescue LoadError
 
42
  puts "ftools not found.  Using FileUtils instead.."
 
43
  $haveftools = false
 
44
end
39
45
require 'optparse'
40
46
require 'ostruct'
41
47
 
92
98
  libs.each do |lf|
93
99
    olf = File.join(InstallOptions.site_dir, lf.gsub(/#{strip}/, ''))
94
100
    op = File.dirname(olf)
95
 
    File.makedirs(op, true)
96
 
    File.chmod(0644, op)
97
 
    File.install(lf, olf, 0755, true)
 
101
    if $haveftools
 
102
      File.makedirs(op, true)
 
103
      File.chmod(0755, op)
 
104
      File.install(lf, olf, 0644, true)
 
105
    else
 
106
      FileUtils.makedirs(op, {:mode => 0755, :verbose => true})
 
107
      FileUtils.chmod(0755, op)
 
108
      FileUtils.install(lf, olf, {:mode => 0644, :verbose => true})
 
109
    end
98
110
  end
99
111
end
100
112
 
102
114
  man.each do |mf|
103
115
    omf = File.join(InstallOptions.man_dir, mf.gsub(/#{strip}/, ''))
104
116
    om = File.dirname(omf)
105
 
    File.makedirs(om, true)
106
 
    File.chmod(0755, om)
107
 
    File.install(mf, omf, 0644, true)
 
117
    if $haveftools
 
118
      File.makedirs(om, true)
 
119
      File.chmod(0755, om)
 
120
      File.install(mf, omf, 0644, true)
 
121
    else
 
122
      FileUtils.makedirs(om, {:mode => 0755, :verbose => true})
 
123
      FileUtils.chmod(0755, om)
 
124
      FileUtils.install(mf, omf, {:mode => 0644, :verbose => true})
 
125
    end
108
126
    gzip = %x{which gzip}
109
127
    gzip.chomp!
110
128
    %x{#{gzip} -f #{omf}}
161
179
 
162
180
  InstallOptions.tests = true
163
181
 
 
182
  if $haveman
 
183
      InstallOptions.man = true
 
184
      if RUBY_PLATFORM == "i386-mswin32"
 
185
        InstallOptions.man  = false
 
186
      end
 
187
  else
 
188
      InstallOptions.man = false
 
189
  end
 
190
 
164
191
  ARGV.options do |opts|
165
192
    opts.banner = "Usage: #{File.basename($0)} [options]"
166
193
    opts.separator ""
198
225
    end
199
226
    opts.on('--full', 'Performs a full installation. All', 'optional installation steps are run.') do |full|
200
227
      InstallOptions.rdoc   = true
 
228
      InstallOptions.man    = true
201
229
      InstallOptions.ri     = true
202
230
      InstallOptions.tests  = true
203
231
    end
215
243
  version = [Config::CONFIG["MAJOR"], Config::CONFIG["MINOR"]].join(".")
216
244
  libdir = File.join(Config::CONFIG["libdir"], "ruby", version)
217
245
 
218
 
  # Mac OS X 10.5 declares bindir and sbindir as
 
246
  # Mac OS X 10.5 and higher declare bindir and sbindir as
219
247
  # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin
220
248
  # /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/sbin
221
249
  # which is not generally where people expect executables to be installed
222
 
  if RUBY_PLATFORM == "universal-darwin9.0"
 
250
  # These settings are appropriate defaults for all OS X versions.
 
251
  if RUBY_PLATFORM =~ /^universal-darwin[\d\.]+$/
223
252
    Config::CONFIG['bindir'] = "/usr/bin"
224
253
    Config::CONFIG['sbindir'] = "/usr/sbin"
225
254
  end
226
 
  
 
255
 
227
256
  if not InstallOptions.bindir.nil?
228
257
    bindir = InstallOptions.bindir
229
258
  else
230
259
    bindir = Config::CONFIG['bindir']
231
260
  end
232
 
  
 
261
 
233
262
  if not InstallOptions.sbindir.nil?
234
263
    sbindir = InstallOptions.sbindir
235
264
  else
236
265
    sbindir = Config::CONFIG['sbindir']
237
266
  end
238
 
  
 
267
 
239
268
  if not InstallOptions.sitelibdir.nil?
240
269
    sitelibdir = InstallOptions.sitelibdir
241
270
  else
249
278
      end
250
279
    end
251
280
  end
252
 
  
 
281
 
253
282
  if not InstallOptions.mandir.nil?
254
283
    mandir = InstallOptions.mandir
255
284
  else
256
 
    mandir = Config::CONFIG['mandir'] 
 
285
    mandir = Config::CONFIG['mandir']
257
286
  end
258
287
 
259
288
  # To be deprecated once people move over to using --destdir option
345
374
end
346
375
 
347
376
def run_tests(test_list)
348
 
        begin
349
 
                require 'test/unit/ui/console/testrunner'
350
 
                $:.unshift "lib"
351
 
                test_list.each do |test|
352
 
                next if File.directory?(test)
353
 
                require test
354
 
                end
355
 
 
356
 
                tests = []
357
 
                ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) } 
358
 
                tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) }
359
 
                tests.delete_if { |o| o == Test::Unit::TestCase }
360
 
 
361
 
                tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
362
 
                $:.shift
363
 
        rescue LoadError
364
 
                puts "Missing testrunner library; skipping tests"
365
 
        end
 
377
    begin
 
378
        require 'test/unit/ui/console/testrunner'
 
379
        $:.unshift "lib"
 
380
        test_list.each do |test|
 
381
            next if File.directory?(test)
 
382
            require test
 
383
        end
 
384
 
 
385
        tests = []
 
386
        ObjectSpace.each_object { |o| tests << o if o.kind_of?(Class) }
 
387
        tests.delete_if { |o| !o.ancestors.include?(Test::Unit::TestCase) }
 
388
        tests.delete_if { |o| o == Test::Unit::TestCase }
 
389
 
 
390
        tests.each { |test| Test::Unit::UI::Console::TestRunner.run(test) }
 
391
        $:.shift
 
392
    rescue LoadError
 
393
        puts "Missing testrunner library; skipping tests"
 
394
    end
366
395
end
367
396
 
368
397
##
378
407
      break
379
408
    end
380
409
  end
381
 
  
 
410
 
382
411
  fail "Cannot find a temporary directory" unless tmp_dir
383
412
  tmp_file = File.join(tmp_dir, '_tmp')
384
413
  ruby = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])