diff options
Diffstat (limited to 'tasks/rake')
-rw-r--r-- | tasks/rake/gem.rake | 9 | ||||
-rw-r--r-- | tasks/rake/git_workflow.rake | 113 | ||||
-rw-r--r-- | tasks/rake/manpages.rake | 37 |
3 files changed, 104 insertions, 55 deletions
diff --git a/tasks/rake/gem.rake b/tasks/rake/gem.rake index d654886ae..efea73882 100644 --- a/tasks/rake/gem.rake +++ b/tasks/rake/gem.rake @@ -1,4 +1,4 @@ -require 'ftools' +require 'fileutils' GEM_FILES = FileList[ '[A-Z]*', @@ -44,7 +44,7 @@ end desc "Prepare binaries for gem creation" task :prepare_gem do SBIN.each do |f| - File.copy(f,"bin") + FileUtils.copy(f,"bin") end end @@ -52,8 +52,9 @@ desc "Create the gem" task :create_gem => :prepare_gem do Dir.mkdir("pkg") rescue nil Gem::Builder.new(spec).build - File.move("puppet-#{Puppet::PUPPETVERSION}.gem", "pkg") + FileUtils.move("puppet-#{Puppet::PUPPETVERSION}.gem", "pkg") SBIN.each do |f| - File.unlink("bin/" + f.gsub(/sbin\//, '')) + fn = f.gsub(/sbin\/(.*)/, '\1') + FileUtils.rm_r "bin/" + fn end end diff --git a/tasks/rake/git_workflow.rake b/tasks/rake/git_workflow.rake index f2ae7ee69..56a414568 100644 --- a/tasks/rake/git_workflow.rake +++ b/tasks/rake/git_workflow.rake @@ -5,82 +5,82 @@ def find_start(start) # This is a case statement, as we might want to map certain # git tags to starting points that are not currently in git. - case start - when nil?: - when @next_release: return "master" - else return start - end + case start + when nil?; + when @next_release; return "master" + else return start + end end desc "Set up git for working with Puppet" task :git_setup do - # This should be changed as new versions get released - @next_release = '0.26.x' - @remote = {} - default_remote = {} - default_remote[:url] = 'git://github.com/reductivelabs/puppet' - default_remote[:name] = 'origin' - @remote[:name] = %x{git config puppet.defaultremote}.chomp - @remote[:name] = @remote[:name].empty? ? default_remote[:name] : @remote[:name] - @remote[:url] = default_remote[:url] if @remote[:name] == default_remote[:name] - default_fetch = '+refs/heads/*:refs/remotes/puppet/*' - @remote[:fetch] = %x{git config puppet.#{@remote[:name]}.fetch}.chomp - @remote[:fetch] = @remote[:fetch].empty? ? default_fetch : @remote[:fetch] + # This should be changed as new versions get released + @next_release = '0.26.x' + @remote = {} + default_remote = {} + default_remote[:url] = 'git://github.com/reductivelabs/puppet' + default_remote[:name] = 'origin' + @remote[:name] = %x{git config puppet.defaultremote}.chomp + @remote[:name] = @remote[:name].empty? ? default_remote[:name] : @remote[:name] + @remote[:url] = default_remote[:url] if @remote[:name] == default_remote[:name] + default_fetch = '+refs/heads/*:refs/remotes/puppet/*' + @remote[:fetch] = %x{git config puppet.#{@remote[:name]}.fetch}.chomp + @remote[:fetch] = @remote[:fetch].empty? ? default_fetch : @remote[:fetch] end desc "Start work on a feature" task :start_feature, [:feature,:remote,:branch] => :git_setup do |t, args| - args.with_defaults(:remote => @remote[:name]) - args.with_defaults(:branch => @next_release) - start_at = find_start(args.branch) - branch = "feature/#{start_at}/#{args.feature}" - sh "git checkout -b #{branch} #{start_at}" do |ok, res| - if ! ok - raise <<EOS + args.with_defaults(:remote => @remote[:name]) + args.with_defaults(:branch => @next_release) + start_at = find_start(args.branch) + branch = "feature/#{start_at}/#{args.feature}" + sh "git checkout -b #{branch} #{start_at}" do |ok, res| + if ! ok + raise <<EOS Was not able to create branch for #{args.feature} on branch #{args.branch}, starting at #{start_at}: error code was: #{res.exitstatus} EOS - end - end - sh "git config branch.#{branch}.remote #{args.remote}" do |ok, res| - raise "Could not set remote: #{$?}" unless ok - end - - sh "git config branch.#{branch}.merge refs/heads/#{branch}" do |ok, res| - raise "Could not configure merge: #{$?}" unless ok - end + end + end + sh "git config branch.#{branch}.remote #{args.remote}" do |ok, res| + raise "Could not set remote: #{$?}" unless ok + end + + sh "git config branch.#{branch}.merge refs/heads/#{branch}" do |ok, res| + raise "Could not configure merge: #{$?}" unless ok + end end desc "Do git prep to start work on a Redmine ticket" task :start_ticket, [:ticket, :remote, :branch] => :git_setup do |t, args| - args.with_defaults(:remote => @remote[:name]) - args.with_defaults(:branch => @next_release) - start_at = find_start(args.branch) - branch = "tickets/#{start_at}/#{args.ticket}" - sh "git checkout -b #{branch} #{start_at}" do |ok, res| - unless ok - raise <<EOS + args.with_defaults(:remote => @remote[:name]) + args.with_defaults(:branch => @next_release) + start_at = find_start(args.branch) + branch = "tickets/#{start_at}/#{args.ticket}" + sh "git checkout -b #{branch} #{start_at}" do |ok, res| + unless ok + raise <<EOS Was not able to create branch for ticket #{args.ticket} on branch #{args.branch}, starting at #{start_at}: error code was: #{$?} Git command used was: #{command} EOS - end - end + end + end sh "git config branch.#{branch}.remote #{args.remote}" do |ok, res| - raise "Could not set remote: #{$?}" unless ok - end + raise "Could not set remote: #{$?}" unless ok + end sh "git config branch.#{branch}.merge refs/heads/#{branch}" do |ok, res| - raise "Could not configure merge: #{$?}" unless ok - end + raise "Could not configure merge: #{$?}" unless ok + end end # This isn't very useful by itself, but we might enhance it later, or use it # in a dependency for a more complex task. desc "Push out changes" task :push_changes, [:remote] do |t, arg| - branch = %x{git branch | grep "^" | awk '{print $2}'} - sh "git push #{arg.remote} #{branch}" do |ok, res| - raise "Unable to push to #{arg.remote}" unless ok - end + branch = %x{git branch | grep "^" | awk '{print $2}'} + sh "git push #{arg.remote} #{branch}" do |ok, res| + raise "Unable to push to #{arg.remote}" unless ok + end end desc "Send patch information to the puppet-dev list" @@ -103,10 +103,21 @@ task :mail_patches do # Create all of the patches sh "git format-patch -C -M -s -n --subject-prefix='PATCH/puppet' #{parent}..HEAD" + # Add info to the patches + additional_info = "Local-branch: #{branch}\n" + files = Dir.glob("00*.patch") + files.each do |file| + contents = File.read(file) + contents.sub!(/^---\n/, "---\n#{additional_info}") + File.open(file, 'w') do |file_handle| + file_handle.print contents + end + end + # And then mail them out. # If we've got more than one patch, add --compose - if Dir.glob("00*.patch").length > 1 + if files.length > 1 compose = "--compose" subject = "--subject \"#{type} #{name} against #{parent}\"" else diff --git a/tasks/rake/manpages.rake b/tasks/rake/manpages.rake new file mode 100644 index 000000000..f7275e4c3 --- /dev/null +++ b/tasks/rake/manpages.rake @@ -0,0 +1,37 @@ +# require 'fileutils' + +desc "Build Puppet manpages" +task :gen_manpages do + + sbins = Dir.glob(%w{sbin/*}) + bins = Dir.glob(%w{bin/*}) + applications = Dir.glob(%w{lib/puppet/application/*}) + # Locate ronn + ronn = %x{which ronn}.chomp + unless File.executable?(ronn) then fail("Ronn does not appear to be installed.") end + + # Create puppet.conf.5 man page + %x{RUBYLIB=./lib:$RUBYLIB bin/puppetdoc --reference configuration > ./man/man5/puppetconf.5.ronn} + %x{#{ronn} --manual="Puppet manual" --organization="Puppet Labs, LLC" -r ./man/man5/puppetconf.5.ronn} + File.move("./man/man5/puppetconf.5", "./man/man5/puppet.conf.5") + File.unlink("./man/man5/puppetconf.5.ronn") + + # Create LEGACY binary man pages (i.e. delete me for 2.8.0) + binary = bins + sbins + binary.each do |bin| + b = bin.gsub( /^s?bin\//, "") + %x{RUBYLIB=./lib:$RUBYLIB #{bin} --help > ./man/man8/#{b}.8.ronn} + %x{#{ronn} --manual="Puppet manual" --organization="Puppet Labs, LLC" -r ./man/man8/#{b}.8.ronn} + File.unlink("./man/man8/#{b}.8.ronn") + end + + # Create modern binary man pages + applications.each do |app| + app.gsub!( /^lib\/puppet\/application\/(.*?)\.rb/, '\1') + %x{RUBYLIB=./lib:$RUBYLIB bin/puppet #{app} --help > ./man/man8/puppet-#{app}.8.ronn} + %x{#{ronn} --manual="Puppet manual" --organization="Puppet Labs, LLC" -r ./man/man8/puppet-#{app}.8.ronn} + File.unlink("./man/man8/puppet-#{app}.8.ronn") + end + + +end
\ No newline at end of file |