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

« back to all changes in this revision

Viewing changes to Rakefile

  • 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:
1
1
# Rakefile for Puppet -*- ruby -*-
2
2
 
 
3
$: << File.expand_path('lib')
3
4
$LOAD_PATH << File.join(File.dirname(__FILE__), 'tasks')
4
5
 
5
 
$: << File.expand_path(File.join(File.dirname(__FILE__), 'lib'))
6
 
 
7
 
begin
8
 
    require 'rake/reductive'
9
 
rescue LoadError
10
 
    $stderr.puts "You must have the Reductive build library in your RUBYLIB; see http://github.com/lak/reductive-build/tree/master."
11
 
    exit(14)
12
 
end
13
 
 
14
 
TESTHOSTS = %w{rh3a fedora1 centos1 freebsd1 culain}
15
 
 
16
 
project = Rake::RedLabProject.new("puppet") do |p|
17
 
    p.summary = "System Automation and Configuration Management Software"
18
 
    p.description = "Puppet is a declarative language for expressing system
19
 
        configuration, a client and server for distributing it, and a library
20
 
        for realizing the configuration."
21
 
 
22
 
    p.filelist = [
23
 
        'install.rb',
24
 
        '[A-Z]*',
25
 
        'lib/puppet.rb',
26
 
        'lib/puppet/**/*.rb',
27
 
        'lib/puppet/**/*.py',
28
 
        'test/**/*',
29
 
        'spec/**/*',
30
 
        'bin/**/*',
31
 
        'ext/**/*',
32
 
        'examples/**/*',
33
 
        'conf/**/*',
34
 
        'man/**/*'
35
 
    ]
36
 
    p.filelist.exclude("bin/pi")
37
 
 
38
 
    p.add_dependency('facter', '1.1.0')
39
 
end
40
 
 
41
 
if project.has?(:gem)
42
 
    # Make our gem task.  This actually just fills out the spec.
43
 
    project.mkgemtask do |task|
44
 
 
45
 
        task.require_path = 'lib'                         # Use these for libraries.
46
 
 
47
 
        task.bindir = "bin"                               # Use these for applications.
48
 
        task.executables = ["puppet", "puppetd", "puppetmasterd", "puppetdoc",
49
 
                         "puppetca", "puppetrun", "ralsh"]
50
 
        task.default_executable = "puppet"
51
 
 
52
 
        #### Documentation and testing.
53
 
 
54
 
        task.has_rdoc = true
55
 
        #s.extra_rdoc_files = rd.rdoc_files.reject { |fn| fn =~ /\.rb$/ }.to_a
56
 
        task.rdoc_options <<
57
 
            '--title' <<  'Puppet - Configuration Management' <<
58
 
            '--main' << 'README' <<
59
 
            '--line-numbers'
60
 
        task.test_file = "test/Rakefile"
61
 
        task.author = "Luke Kanies"
62
 
    end
63
 
end
64
 
 
65
 
rule(/_is_runnable$/) do |t|
66
 
    available = false
67
 
    executable = t.name.sub(/_is_runnable$/, '')
68
 
    ENV['PATH'].split(':').each do |elem|
69
 
        available = true if File.executable? File.join(elem, executable)
70
 
    end
71
 
    
72
 
    unless available
73
 
        puts "You do not have #{executable} available in your path"
74
 
        exit 1
75
 
    end
76
 
end
77
 
 
78
 
task :check_build_deps => 'dpkg-checkbuilddeps_is_runnable' do
79
 
    system("dpkg-checkbuilddeps") || exit(1)
80
 
end
81
 
 
82
 
task :debian_packages => [ "debian", :check_build_deps, :fakeroot_is_runnable ] do
83
 
    system("fakeroot debian/rules clean") || exit(1)
84
 
    system("fakeroot debian/rules binary") || exit(1)
85
 
end
86
 
 
87
 
 
88
 
def dailyfile(package)
89
 
    "#{downdir}/#{package}/#{package}-daily-#{stamp}.tgz"
90
 
end
91
 
 
92
 
def daily(package)
93
 
    edir = "/tmp/daily-export"
94
 
    Dir.mkdir edir
95
 
    Dir.chdir(edir) do
96
 
        sh %{git clone git://reductivelabs.com/#{package} #{package} >/dev/null}
97
 
        sh %{tar cf - #{package} | gzip -c > #{dailyfile(package)}}
98
 
    end
99
 
    FileUtils.rm_rf(edir)
100
 
end
101
 
 
102
 
def downdir
103
 
    ENV['DOWNLOAD_DIR'] || "/opt/rl/docroots/reductivelabs.com/htdocs/downloads"
104
 
end
105
 
 
106
 
def stamp
107
 
    [Time.now.year, Time.now.month, Time.now.day].collect { |i| i.to_s}.join
108
 
end
109
 
 
110
 
pdaily = dailyfile("puppet")
111
 
fdaily = dailyfile("facter")
112
 
 
113
 
file pdaily do
114
 
    daily("puppet")
115
 
end
116
 
 
117
 
file fdaily do
118
 
    daily("facter")
119
 
end
120
 
 
121
 
task :daily => [pdaily, fdaily]
122
 
 
123
 
task :dailyclean do
124
 
    Dir.glob("#{downdir}/*/*daily*.tgz").each do |file|
125
 
        puts "Removing %s" % file
126
 
        File.unlink(file)
127
 
    end
128
 
end
129
 
 
130
 
task :tracdocs do
131
 
    require 'puppet'
132
 
    require 'puppet/util/reference'
133
 
    Puppet::Util::Reference.references.each do |ref| 
134
 
        sh "puppetdoc -m trac -r #{ref.to_s}"
135
 
    end
136
 
end
 
6
require './lib/puppet.rb'
 
7
require 'rake'
 
8
require 'rake/packagetask'
 
9
require 'rake/gempackagetask'
 
10
 
 
11
Dir['tasks/**/*.rake'].each { |t| load t }
 
12
 
 
13
FILES = FileList[
 
14
    '[A-Z]*',
 
15
    'install.rb',
 
16
    'bin/**/*',
 
17
    'sbin/**/*',
 
18
    'lib/**/*',
 
19
    'conf/**/*',
 
20
    'man/**/*',
 
21
    'examples/**/*',
 
22
    'ext/**/*',
 
23
    'test/**/*',
 
24
    'spec/**/*'
 
25
]
 
26
 
 
27
Rake::PackageTask.new("puppet", Puppet::PUPPETVERSION) do |pkg|
 
28
    pkg.package_dir = 'pkg'
 
29
    pkg.need_tar_gz = true
 
30
    pkg.package_files = FILES.to_a
 
31
end
 
32
 
 
33
task :default do
 
34
    sh %{rake -T}
 
35
end
 
36
 
 
37
task :puppetpackages => [:create_gem, :package]
137
38
 
138
39
desc "Run the specs under spec/"
139
40
task :spec do
140
41
    require 'spec'
141
42
    require 'spec/rake/spectask'
142
 
    # require 'rcov'
 
43
    begin
 
44
        require 'rcov'
 
45
    rescue LoadError
 
46
    end
 
47
 
143
48
    Spec::Rake::SpecTask.new do |t|
144
 
         #   t.rcov = true
145
 
         t.spec_opts = ['--format','s', '--loadby','mtime']
146
 
         t.spec_files = FileList['spec/**/*.rb']
147
 
    end
 
49
        t.spec_opts = ['--format','s', '--loadby','mtime']
 
50
        t.spec_files = FileList['spec/**/*.rb']
 
51
        if defined?(Rcov)
 
52
            t.rcov = true
 
53
            t.rcov_opts = ['--exclude', 'spec/*,test/*,results/*,/usr/lib/*,/usr/local/lib/*']
 
54
        end
 
55
     end
148
56
end
149
57
 
150
58
desc "Run the unit tests"
151
59
task :unit do
152
60
    sh "cd test; rake"
153
61
end
154
 
 
155
 
namespace :ci do
156
 
 
157
 
  desc "Run the CI prep tasks"
158
 
  task :prep do
159
 
    require 'rubygems'
160
 
    gem 'ci_reporter'
161
 
    require 'ci/reporter/rake/rspec'
162
 
    require 'ci/reporter/rake/test_unit'
163
 
    ENV['CI_REPORTS'] = 'results'
164
 
  end
165
 
 
166
 
  desc "Run CI Unit tests"
167
 
  task :unit => [:prep, 'ci:setup:testunit'] do
168
 
     sh "cd test; rake test; exit 0"
169
 
  end
170
 
 
171
 
  desc "Run CI RSpec tests"
172
 
  task :spec => [:prep, 'ci:setup:rspec'] do
173
 
     sh "cd spec; rake all; exit 0"
174
 
  end
175
 
 
176
 
end
177
 
 
178
 
desc "Send patch information to the puppet-dev list"
179
 
task :mail_patches do
180
 
    if Dir.glob("00*.patch").length > 0
181
 
        raise "Patches already exist matching '00*.patch'; clean up first"
182
 
    end
183
 
 
184
 
    unless %x{git status} =~ /On branch (.+)/
185
 
        raise "Could not get branch from 'git status'"
186
 
    end
187
 
    branch = $1
188
 
    
189
 
    unless branch =~ %r{^([^\/]+)/([^\/]+)/([^\/]+)$}
190
 
        raise "Branch name does not follow <type>/<parent>/<name> model; cannot autodetect parent branch"
191
 
    end
192
 
 
193
 
    type, parent, name = $1, $2, $3
194
 
 
195
 
    # Create all of the patches
196
 
    sh "git format-patch -C -M -s -n #{parent}..HEAD"
197
 
 
198
 
    # And then mail them out.
199
 
 
200
 
    # If we've got more than one patch, add --compose
201
 
    if Dir.glob("00*.patch").length > 1
202
 
        compose = "--compose"
203
 
    else
204
 
        compose = ""
205
 
    end
206
 
 
207
 
    # Now send the mail.
208
 
    sh "git send-email #{compose} --no-chain-reply-to --no-signed-off-by-cc --suppress-from --no-thread --to puppet-dev@googlegroups.com 00*.patch"
209
 
 
210
 
    # Finally, clean up the patches
211
 
    sh "rm 00*.patch"
212
 
end
213
 
 
214
 
    desc "Create a changelog based on your git commits."
215
 
    task :changelog do
216
 
 
217
 
      CHANGELOG_DIR = "#{Dir.pwd}"
218
 
 
219
 
      mkdir(CHANGELOG_DIR) unless File.directory?(CHANGELOG_DIR)
220
 
 
221
 
      change_body=`git log --pretty=format:'%aD%n%an <%ae>%n%s%n'`
222
 
 
223
 
      File.open(File.join(CHANGELOG_DIR, "CHANGELOG.git"), 'w') do |f|
224
 
        f << change_body 
225
 
      end
226
 
 
227
 
      # Changelog commit
228
 
      `git add #{CHANGELOG_DIR}/CHANGELOG.git`
229
 
      `git commit -m "Update CHANGELOG.git"`
230
 
    end