Class: RPM::Spec

Inherits:
Object
  • Object
show all
Defined in:
lib/rake/rpmtask.rb

Overview

RPM::init_macros *%W

/usr/lib/rpm/macros
/usr/lib/rpm/i686-linux/macros
/etc/rpm/macros.*
/etc/rpm/macros
/etc/rpm/i686-linux/macros
~/.rpmmacros

#{ File.join( File.dirname(__FILE__), '../rpmmacros' ) }

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



27
28
29
# File 'lib/rake/rpmtask.rb', line 27

def name
  @name
end

#pathObject (readonly)

Returns the value of attribute path.



27
28
29
# File 'lib/rake/rpmtask.rb', line 27

def path
  @path
end

Class Method Details

._spec_openObject



30
# File 'lib/rake/rpmtask.rb', line 30

alias _spec_open open

.open(spec_path) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/rake/rpmtask.rb', line 31

def open( spec_path )
  # need to be in directory of spec file for %{srcdir} to work properly
  Dir.chdir File.dirname(spec_path)  do
    spec = _spec_open spec_path
    spec.instance_eval {  @path = spec_path }

    if spec.packages.empty?
      # some specs (i.e. kernel modules) need their sources installed before their specs will properly parse
      raise "Spec file #{spec_path} has no packages"  if spec.install_sources.zero?
      spec = _spec_open spec_path
      spec.instance_eval {  @path = spec_path }
    end

    spec
  end
end

Instance Method Details

#install_sourcesObject



53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/rake/rpmtask.rb', line 53

def install_sources
  self.sources.select  do |src|
    src_path = File.join File.dirname(@path), src.filename
    dest_path = File.join RPM::SourceDir, src.filename
    next  unless File.exists? src_path

    file dest_path => src_path  do |t|
      puts "#{src_path} -> #{File.dirname dest_path}"
      FileUtils.cp src_path, dest_path
    end.invoke
    true
  end.size
end

#releaseObject



51
# File 'lib/rake/rpmtask.rb', line 51

def release()  @release ||= packages.first.version.r  ; end

#sh_build(flags) ⇒ Object Also known as: build



67
68
69
70
71
# File 'lib/rake/rpmtask.rb', line 67

def sh_build( flags )
  rpm_opts = "--define='srcdir #{File.dirname @path}'"
  cmd = "rpmbuild #{rpm_opts} -b" + (flags == RPM::BUILD__ALL_PACKAGE ? 'a' : 'b') + " #{@path}"
  system(cmd) ? $?.exitstatus : -1
end

#versionObject



50
# File 'lib/rake/rpmtask.rb', line 50

def version()  @version ||= packages.first.version.v  ; end