Class: Gaffer::Base
- Inherits:
-
Object
- Object
- Gaffer::Base
- Defined in:
- lib/gaffer/base.rb
Instance Attribute Summary collapse
-
#build_name ⇒ Object
Returns the value of attribute build_name.
-
#depends ⇒ Object
Returns the value of attribute depends.
-
#dir ⇒ Object
Returns the value of attribute dir.
-
#git ⇒ Object
Returns the value of attribute git.
-
#maintainer ⇒ Object
Returns the value of attribute maintainer.
-
#prefix ⇒ Object
Returns the value of attribute prefix.
-
#project ⇒ Object
Returns the value of attribute project.
-
#readme ⇒ Object
Returns the value of attribute readme.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #add(file) ⇒ Object
- #build(dir) ⇒ Object
- #git_build_id ⇒ Object
-
#initialize(options) ⇒ Base
constructor
A new instance of Base.
- #next_build_id ⇒ Object
- #push_changed(dir, &blk) ⇒ Object
- #repro ⇒ Object
- #repro_build_id ⇒ Object
- #repro_dir ⇒ Object
- #repro_ready? ⇒ Boolean
Constructor Details
#initialize(options) ⇒ Base
Returns a new instance of Base.
5 6 7 |
# File 'lib/gaffer/base.rb', line 5 def initialize() @force = [:force] end |
Instance Attribute Details
#build_name ⇒ Object
Returns the value of attribute build_name.
3 4 5 |
# File 'lib/gaffer/base.rb', line 3 def build_name @build_name end |
#depends ⇒ Object
Returns the value of attribute depends.
3 4 5 |
# File 'lib/gaffer/base.rb', line 3 def depends @depends end |
#dir ⇒ Object
Returns the value of attribute dir.
3 4 5 |
# File 'lib/gaffer/base.rb', line 3 def dir @dir end |
#git ⇒ Object
Returns the value of attribute git.
3 4 5 |
# File 'lib/gaffer/base.rb', line 3 def git @git end |
#maintainer ⇒ Object
Returns the value of attribute maintainer.
3 4 5 |
# File 'lib/gaffer/base.rb', line 3 def maintainer @maintainer end |
#prefix ⇒ Object
Returns the value of attribute prefix.
3 4 5 |
# File 'lib/gaffer/base.rb', line 3 def prefix @prefix end |
#project ⇒ Object
Returns the value of attribute project.
3 4 5 |
# File 'lib/gaffer/base.rb', line 3 def project @project end |
#readme ⇒ Object
Returns the value of attribute readme.
3 4 5 |
# File 'lib/gaffer/base.rb', line 3 def readme @readme end |
#version ⇒ Object
Returns the value of attribute version.
3 4 5 |
# File 'lib/gaffer/base.rb', line 3 def version @version end |
Instance Method Details
#add(file) ⇒ Object
46 47 48 |
# File 'lib/gaffer/base.rb', line 46 def add(file) repro.include(file) end |
#build(dir) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/gaffer/base.rb', line 9 def build(dir) @dir = dir @git = Git::open(dir) @project = File::basename(File::dirname(@git.repo.path)) @maintainer = "#{@git.config["user.name"]} <#{@git.config["user.email"]}>" @prefix = "opt/#{@project}" @readme = File::read("#{dir}/README") rescue "no README file" @depends = File::read("#{dir}/DEPENDS").chomp rescue "libc6 (>= 2.10)" @version = File::read("#{dir}/VERSION").chomp raise "Bad version #{@version}" unless @version =~ /^\d+[.]\d+[.]\d+$/ @build_name = "#{@version}-#{next_build_id}" puts "======> #{@version.inspect}" @git.add_tag(@build_name) ## check version - tag repo Gaffer::Deb::new(self, project, depends).build # Gaffer::Deb::new(self, "#{project}-dev", "#{project} (>= #{@version})").build end |
#git_build_id ⇒ Object
34 35 36 |
# File 'lib/gaffer/base.rb', line 34 def git_build_id @git..map { |a| a.name =~ /^#{@version}-(.+)/; $1.to_i }.sort.last.to_i end |
#next_build_id ⇒ Object
42 43 44 |
# File 'lib/gaffer/base.rb', line 42 def next_build_id [git_build_id, repro_build_id].max + 1 end |
#push_changed(dir, &blk) ⇒ Object
50 51 52 53 54 55 56 57 58 59 |
# File 'lib/gaffer/base.rb', line 50 def push_changed(dir, &blk) # I can optimze later start = Time::now Dir.chdir(dir) do blk.call Dir["**/*"].select { |file| File::stat(file).mtime >= start }.each do |file| puts "PUSHING: #{f}" end end end |
#repro ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/gaffer/base.rb', line 61 def repro = {} [:aws_key] ||= ENV['AWS_ACCESS_KEY_ID'] [:aws_secret] ||= ENV['AWS_SECRET_ACCESS_KEY'] [:bucket] ||= ENV['GAFFER_BUCKET'] [:email] ||= ENV['GAFFER_EMAIL'] [:maintainer] ||= ENV['GAFFER_MAINTAINER'] [:key] ||= ENV['GAFFER_KEY'] [:key] ||= [:email] [:codename] ||= "maverick" [:components] ||= "main" [:force] ||= !!@force Gaffer::Repro.new(repro_dir, ) end |
#repro_build_id ⇒ Object
38 39 40 |
# File 'lib/gaffer/base.rb', line 38 def repro_build_id repro.packages.map { |p| p =~ /^#{@project}_#{@version}-(\d+)_/; $1 }.reject { |x| x.nil? }.max.to_i rescue 0 end |
#repro_dir ⇒ Object
79 80 81 82 83 84 85 |
# File 'lib/gaffer/base.rb', line 79 def repro_dir if ENV['HOME'] "#{ENV['HOME']}/.gaffer/repo" else "/var/lib/gaffer/repo" end end |
#repro_ready? ⇒ Boolean
87 88 89 |
# File 'lib/gaffer/base.rb', line 87 def repro_ready? File.exists? "#{repro_dir}/ubuntu/conf/distributions" end |