Module: Simp::Rake
- Includes:
- CommandUtils
- Included in:
- Build, Build::Code, Build::Iso, Build::Pkg
- Defined in:
- lib/simp/rake.rb,
lib/simp/rake/helpers.rb,
lib/simp/rake/build/iso.rb,
lib/simp/rake/build/pkg.rb,
lib/simp/rake/build/tar.rb,
lib/simp/rake/build/auto.rb,
lib/simp/rake/build/code.rb,
lib/simp/rake/build/spec.rb,
lib/simp/rake/build/build.rb,
lib/simp/rake/build/clean.rb,
lib/simp/rake/build/unpack.rb,
lib/simp/rake/build/upload.rb,
lib/simp/rake/build/helpers.rb,
lib/simp/rake/build/rpmdeps.rb,
lib/simp/rake/pupmod/helpers.rb,
lib/simp/rake/build/constants.rb,
lib/simp/rake/helpers/version.rb,
lib/simp/rake/helpers/rpm_spec.rb,
lib/simp/rake/pupmod/module_build.rb,
lib/simp/rake/build/deps.rb
Defined Under Namespace
Modules: Build, Pupmod Classes: Fixtures, Helpers, Pkg, Rubygem
Instance Attribute Summary collapse
-
#module_paths ⇒ Object
readonly
Returns the value of attribute module_paths.
-
#puppetfile ⇒ Object
readonly
Returns the value of attribute puppetfile.
Instance Method Summary collapse
-
#clean_yaml(yaml_input) ⇒ Object
Add a standard method for cleaning up strange YAML transations between versions of Ruby.
-
#encode_line(line) ⇒ Object
Force the encoding to something that Ruby >= 1.9 is happy with.
-
#get_cpu_limit ⇒ Object
by default, we use all processors - 1.
- #help ⇒ Object
- #load_puppetfile(method = 'tracking') ⇒ Object
-
#run_pager ⇒ Object
Snarfed from nex-3.com/posts/73-git-style-automatic-paging-in-ruby.
Methods included from CommandUtils
Instance Attribute Details
#module_paths ⇒ Object (readonly)
Returns the value of attribute module_paths.
21 22 23 |
# File 'lib/simp/rake.rb', line 21 def module_paths @module_paths end |
#puppetfile ⇒ Object (readonly)
Returns the value of attribute puppetfile.
21 22 23 |
# File 'lib/simp/rake.rb', line 21 def puppetfile @puppetfile end |
Instance Method Details
#clean_yaml(yaml_input) ⇒ Object
Add a standard method for cleaning up strange YAML transations between versions of Ruby
Assumes YAML string input
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/simp/rake.rb', line 50 def clean_yaml(yaml_input) yaml_output = yaml_input # Had some issues with different versions of ruby giving different results yaml_output.gsub!(%r{!ruby/sym(bol)? }, ':') # Also, some versions appear to dump out trailing whitespace yaml_output.gsub!(%r{\s+$}, '') yaml_output end |
#encode_line(line) ⇒ Object
Force the encoding to something that Ruby >= 1.9 is happy with
37 38 39 40 41 42 43 44 |
# File 'lib/simp/rake.rb', line 37 def encode_line(line) if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.9') require 'iconv' Iconv.new('ISO-8859-1//IGNORE', 'UTF-8').iconv(line) else line.force_encoding(Encoding::ISO_8859_1).encode(Encoding::UTF_8, :replace => nil, :undef => :replace) end end |
#get_cpu_limit ⇒ Object
by default, we use all processors - 1
63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/simp/rake.rb', line 63 def get_cpu_limit cpus = Parallel.processor_count env_cpus = ENV.fetch('SIMP_RAKE_LIMIT_CPUS', '-1').strip.to_i env_cpus = 1 if env_cpus.zero? env_cpus += cpus if env_cpus.negative? # sanitize huge numbers env_cpus = (cpus - 1) if env_cpus >= cpus env_cpus = 1 if env_cpus.negative? env_cpus end |
#help ⇒ Object
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 |
# File 'lib/simp/rake.rb', line 107 def help run_pager puts <<-EOM = SIMP Build Tasks = Use 'rake' and choose one of the options below that best suits your needs. If you are simply trying to build the SIMP tarball, use the 'rake tar:build[:chroot]' option. NOTE: Any task that requires a :chroot input will require you to be in the 'mock' group and have the 'mock' package installed. == Space Requirements == A full parallel build will take around 500M for each git submodule built. If you are space limited, set SIMP_RAKE_LIMIT_CPUS=1 at build time. == Environment Variables == * SIMP_RAKE_CHOWN_EVERYTHING=(Y|n) - Chown everything to the 'mock' group prior to building * SIMP_RAKE_MOCK_OFFLINE=(y|N) - Mock runs are limited to the local cache * SIMP_RAKE_LIMIT_CPUS=# - Default: Num system CPUs - 1 - An Integer that limits builds to # processors - If set to '1', will only build in a single mock directory * SIMP_GIT_BRANCH=<Branch ID> - If you are working in the supermodule and wish to perform a reset, but retain your working branch at the supermodule level. You can set this to ignore the current supermodule branch value. - This is particularly valuable when using Jenkins. ******************** EOM sh %(rake -D) end |
#load_puppetfile(method = 'tracking') ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/simp/rake.rb', line 23 def load_puppetfile(method = 'tracking') return if @puppetfile # Pull the puppetfile from the top-level @puppetfile = R10KHelper.new("#{@base_dir}/Puppetfile.#{method}") @module_paths = [] @puppetfile.each_module do |mod| path = mod[:path] @module_paths.push(path) end end |
#run_pager ⇒ Object
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 |
# File 'lib/simp/rake.rb', line 77 def run_pager return if RUBY_PLATFORM.include?('win32') return unless $stdout.tty? read, write = IO.pipe unless Kernel.fork # Child process $stdout.reopen(write) $stderr.reopen(write) if $stderr.tty? read.close write.close return end # Parent process, become pager $stdin.reopen(read) read.close write.close ENV['LESS'] = 'FSRX' # Don't page if the input is short enough Kernel.select [$stdin] # Wait until we have input before we start the pager pager = ENV['PAGER'] || 'less' begin exec pager rescue StandardError exec '/bin/sh', '-c', pager end end |