Class: Simp::Rake::Build::Tar
- Inherits:
-
Rake::TaskLib
- Object
- Rake::TaskLib
- Simp::Rake::Build::Tar
- Includes:
- Constants
- Defined in:
- lib/simp/rake/build/tar.rb
Instance Method Summary collapse
-
#define_tasks ⇒ Object
define rake tasks.
-
#initialize(base_dir) ⇒ Tar
constructor
A new instance of Tar.
Methods included from Constants
#init_member_vars, #os_build_metadata
Constructor Details
#initialize(base_dir) ⇒ Tar
Returns a new instance of Tar.
12 13 14 15 16 |
# File 'lib/simp/rake/build/tar.rb', line 12 def initialize( base_dir ) init_member_vars( base_dir ) define_tasks end |
Instance Method Details
#define_tasks ⇒ Object
define rake tasks
19 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 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/simp/rake/build/tar.rb', line 19 def define_tasks namespace :tar do task :prep do if $simp6 @build_dir = $simp6_build_dir @dvd_src = File.join(@build_dir, File.basename(@dvd_src)) end if $tarball_tgt @dvd_dir = File.dirname($tarball_tgt) end end def get_simp_version simp_rpm = Dir.glob("#{@build_dir}/SIMP/RPMS/*/simp-[0-9]*.rpm").max_by {|f| File.mtime(f)} fail("Could not find simp main RPM in output directory!") unless simp_rpm simp_version = File.basename(simp_rpm).gsub(".noarch.rpm","").gsub("simp-","") # For picking up the correct RPM template ENV['SIMP_BUILD_version'] ||= simp_version return simp_version end ############################################################################## # Main tasks ############################################################################## task :validate => [:prep] do |t,args| rpm_dir = File.join(@build_dir,'SIMP','RPMS') fail("Could not find output dir: '#{rpm_dir}'") unless File.directory?(rpm_dir) required_rpms = { 'noarch' => [ 'rubygem-simp-cli', 'simp', 'simp-gpgkeys', 'simp-rsync', 'simp-utils' ] } Dir.chdir(rpm_dir) do failures = [] required_rpms.keys.each do |dir| fail("Could not find directory '#{File.join(rpm_dir,dir)}'") unless File.directory?(dir) Dir.chdir(dir) do required_rpms[dir].each do |pkg| if Dir.glob("#{pkg}-[0-9]*.rpm").empty? failures << " * #{pkg}" end end # Special case for the switch from 'simp-bootstrap' to 'simp-environment' if Dir.glob('simp-bootstrap-[0-9]*.rpm').empty? && Dir.glob('simp-environment-[0-9]*.rpm').empty? failures << ' * simp-bootstrap and simp-environment' end end end unless failures.empty? msg = ['Error: Could not find the following packages:'] fail((msg + failures).join("\n")) end end end desc <<-EOM Build the DVD tarball(s). * :chroot - The mock chroot to use for pkg:build * :key - What key to use for signing the RPMs * :docs - Whether or not to build the documentation * :snapshot_release - Append the timestamp to the SIMP tarball(s) EOM task :build,[:chroot,:key,:docs,:snapshot_release] => ['pkg:build','pkg:checksig','tar:validate'] do |t,args| args.with_defaults(:docs => 'true') validate_in_mock_group? if $tarball_tgt target_dists = ['simp6'] else target_dists = @target_dists end Parallel.map( target_dists, :in_processes => get_cpu_limit, :process => t.name ) do |dist| if $tarball_tgt base_dir = "#{@dvd_dir}/staging" else base_dir = "#{@dvd_dir}/#{dist}/staging" end destdir = "#{base_dir}/SIMP" # Build the staging area remove_entry_secure(destdir) if File.exist?(destdir) mkdir_p(destdir) Simp::RPM.copy_wo_vcs(@dvd_src,".",base_dir) # Copy in the GPG Public Keys mkdir_p("#{destdir}/GPGKEYS") ln(Dir.glob("#{@build_dir}/GPGKEYS/RPM-GPG-KEY*"), "#{destdir}/GPGKEYS", { :force => true }) # Copy in the auto-build RPMs Dir.chdir("#{@build_dir}/SIMP/RPMS") do Dir.glob('*').each do |type| dest_type = type if File.directory?(type) if type =~ /i.*86/ dest_type = 'i386' end mkdir_p("#{destdir}/#{dest_type}") Dir.chdir(type) do ln(Dir.glob("*.#{type}.rpm"), "#{destdir}/#{dest_type}", { :force => true }) end end end end if args.docs.casecmp('true') == 0 # Finally, the PDF docs if they exist. pdfs = Dir.glob("#{@src_dir}/doc/pdf/*") unless pdfs.empty? pdfs.each do |pdf| cp(pdf,base_dir) end else # If we don't have PDFs in the directory, yank them out of the # RPM itself! simp_doc_rpm = Dir.glob("#{@build_dir}/SIMP/RPMS/*/simp-doc*.rpm").last unless simp_doc_rpm raise(StandardError,"Error: Could not find simp-doc*.rpm in the build, something went very wrong") end Dir.mktmpdir { |dir| Dir.chdir(dir) do %x{rpm2cpio #{simp_doc_rpm} | cpio -u --quiet --warning none -ivd ./usr/share/doc/simp-*/pdf/SIMP*.pdf 2>&1 > /dev/null} pdf_docs = Dir.glob("usr/share/doc/simp-*/pdf/*.pdf") if pdf_docs.empty? raise(StandardError,"Error: Could not find any PDFs in the simp-doc RPM, aborting.") end pdf_docs.each do |pdf| cp(pdf,base_dir) end end } end end end # FIXME: this is a horribad way of sharing with `build:auto` $simp_tarballs = {} if $tarball_tgt target_dists = ['simp6'] else target_dists = @target_dists end target_dists.each do |dist| if $tarball_tgt dvd_tarball = File.basename($tarball_tgt) base_dir = "#{@dvd_dir}/staging" else base_dir = "#{@dvd_dir}/#{dist}/staging" dvd_name = [ 'SIMP', 'DVD', dist, get_simp_version ] dvd_tarball = "#{dvd_name.join('-')}.tar.gz" end mkdir_p(base_dir) Dir.chdir(base_dir) do sh %{tar --owner 0 --group 0 --exclude-vcs --mode=u=rwX,g=rX,o=rX -cpzf "../#{dvd_tarball}" ./*} unless $tarball_tgt mv("../#{dvd_tarball}",@dvd_dir) end end puts "Package DVD: #{@dvd_dir}/#{dvd_tarball}" $simp_tarballs[dist] = "#{@dvd_dir}/#{dvd_tarball}" rm_rf(base_dir) end end end end |