Class: Simp::Rake::Build::Upload
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Simp::Rake::Build::Upload
- Includes:
- Constants
- Defined in:
- lib/simp/rake/build/upload.rb
Instance Method Summary collapse
- #define_tasks ⇒ Object
-
#initialize(base_dir) ⇒ Upload
constructor
A new instance of Upload.
Methods included from Constants
#init_member_vars, #os_build_metadata
Constructor Details
#initialize(base_dir) ⇒ Upload
Returns a new instance of Upload.
13 14 15 16 17 18 |
# File 'lib/simp/rake/build/upload.rb', line 13 def initialize( base_dir ) init_member_vars( base_dir ) @mock = ENV['mock'] || '/usr/bin/mock' define_tasks end |
Instance Method Details
#define_tasks ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 |
# File 'lib/simp/rake/build/upload.rb', line 20 def define_tasks namespace :upload do task :prep do if $simp6 @build_dir = $simp6_build_dir end end ############################################################################## # Helper methods ############################################################################## # Get a list of all packages that have been updated since the passed # date or git identifier (tag, branch, or commit). def get_updated_packages(start,script_format) pkg_info = Hash.new printed_info = false to_check = [] # Find all static RPMs and GPGKEYS that we may need to update so # that we can see if we have newer versions to upload! Find.find(@build_dir) do |file| next if file == @build_dir Find.prune if file !~ /^#{@build_dir}\/(Ext.*(\.rpm)?|GPGKEYS)/ to_check << file if File.file?(file) end # Smash in all of the file files! to_check += Dir.glob("#{@spec_dir}/*.spec") to_check += Dir.glob("#{@src_dir}/puppet/modules/*/pkg/*.spec") to_check.each do |file| is_commit = false oldstart = start humanstart = '' # Before changing the directory, see if we've got a commit or a # date. If we've got a tag or branch from the top level, then we # need to get the date from there and use it later. Dir.chdir(@spec_dir) do stdin,stdout,stderr = Open3.popen3('git','rev-list',start) stderr.read !~ /^fatal:/ and is_commit = true if is_commit # Snag the date. start, humanstart = `git log #{start} --pretty=format:"%ct##%cd" --max-count=1`.chomp.split('##') else printed_info = true end end !printed_info and puts "Info: Comparing to '#{humanstart}' based on input of '#{oldstart}'" Dir.chdir(File.dirname(file)) do # Get the file HEAD commit # If we're not in a git repo, this will explode, but that's just # fine. current_head = `git rev-list HEAD --max-count=1`.chomp begin # Convert the spec files to something more human readable... pkg_info[file] = { :is_new => false } pkg_info[file][:alias] = file if file =~ /.spec$/ if script_format pkg_info[file][:alias] = "#{@build_dir}/RPMS/#{Simp::RPM.new(file).name}*.rpm" else pkg_info[file][:alias] = Simp::RPM.new(file).name end end rescue raise "Error: There was an issue getting information from #{file}" end commit_head = nil # It turns out that an invalid date will just return # everything commit_head = `git log --before="#{start}" --pretty=format:%H --max-count=1 #{File.basename(file)}`.chomp # Did we find something different? if commit_head.empty? pkg_info[file][:is_new] = true else pkg_info[file][:is_new] = !system('git','diff','--quiet',commit_head,File.basename(file)) end end end return pkg_info end desc <<-EOM Get a list of modified packages. The package list is created from the given date or git identifier (tag, branch, or hash) EOM task :get_modified,[:start,:script_format] => [:prep] do |t,args| args.with_defaults(:script_format => false) args.start or raise "Error: You must specify a 'start'" updated_pkgs = get_updated_packages(args.start, args.script_format) updated_pkgs.keys.sort.each do |k| updated_pkgs[k][:is_new] and puts "Updated: #{updated_pkgs[k][:alias]}" end end end end |