Class: Gaffer::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gaffer/base.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Base

Returns a new instance of Base.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/gaffer/base.rb', line 5

def initialize(options)
  @dir     = options[:dir] || Dir.pwd
  @git     = Git.open(@dir)
  @version = options[:version]
  @project = options[:project] || File.basename(File.dirname(@git.repo.path))
  @maintainer = "#{@git.config["user.name"]} <#{@git.config["user.email"]}>"
  @prefix  = options[:prefix] || "opt/#{@project}"

  @git.chdir do
    @readme = File.read("README") rescue "no README file"
    @depends = File.read("DEPENDS").chomp rescue "libc6 (>= 2.10)"
    @version ||= File.read("VERSION").chomp
  end

  puts "======> #{@version.inspect}"
  build_id = @git.tags.map { |a| a.name =~ /^#{@version}-(.+)/; $1.to_i }.sort.last.to_i + 1
  @build = "#{@version}-#{build_id}"

  raise "Bad version #{@version}" unless @version =~ /^\d+[.]\d+[.]\d+$/
end

Instance Attribute Details

#buildObject

Returns the value of attribute build.



3
4
5
# File 'lib/gaffer/base.rb', line 3

def build
  @build
end

#dependsObject

Returns the value of attribute depends.



3
4
5
# File 'lib/gaffer/base.rb', line 3

def depends
  @depends
end

#dirObject

Returns the value of attribute dir.



3
4
5
# File 'lib/gaffer/base.rb', line 3

def dir
  @dir
end

#gitObject

Returns the value of attribute git.



3
4
5
# File 'lib/gaffer/base.rb', line 3

def git
  @git
end

#maintainerObject

Returns the value of attribute maintainer.



3
4
5
# File 'lib/gaffer/base.rb', line 3

def maintainer
  @maintainer
end

#prefixObject

Returns the value of attribute prefix.



3
4
5
# File 'lib/gaffer/base.rb', line 3

def prefix
  @prefix
end

#projectObject

Returns the value of attribute project.



3
4
5
# File 'lib/gaffer/base.rb', line 3

def project
  @project
end

#readmeObject

Returns the value of attribute readme.



3
4
5
# File 'lib/gaffer/base.rb', line 3

def readme
  @readme
end

#versionObject

Returns the value of attribute version.



3
4
5
# File 'lib/gaffer/base.rb', line 3

def version
  @version
end

Instance Method Details

#compileObject



26
27
28
29
30
31
32
33
# File 'lib/gaffer/base.rb', line 26

def compile
  @git.add_tag(@build)
  ## check version - tag repo
  [ "i386", "amd64" ].each do |arch|
    Gaffer::Deb.new(self, arch, project,          depends).compile
    Gaffer::Deb.new(self, arch, "#{project}-dev", "#{project} (>= #{@version})").compile
  end
end