Class: Rake::RPMTask

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

Overview

Create a build task that will generate an RPM package from a .spec file.

Author

Steve Sloan ([email protected])

Copyright

Copyright © 2006-2009 Steve Sloan

License

MIT

Direct Known Subclasses

AutoToolsRPMTask

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(args) {|_self| ... } ⇒ RPMTask

Returns a new instance of RPMTask.

Yields:

  • (_self)

Yield Parameters:

  • _self (Rake::RPMTask)

    the object that the method was called on



108
109
110
111
112
113
114
115
116
117
# File 'lib/rake/rpmtask.rb', line 108

def initialize( args, &blk )
  @name, @prereqs = args.keys.first, args.values.first
  @spec_path = @prereqs.find { |t|  File.extname(t.to_s) == '.spec' }
  @build_srpm = false

  yield self  if block_given?

  raise "Unable to find spec file for \"#{@name}\""  unless @spec_path
  define_tasks
end

Instance Attribute Details

#build_srpmsObject

Returns the value of attribute build_srpms.



106
107
108
# File 'lib/rake/rpmtask.rb', line 106

def build_srpms
  @build_srpms
end

#nameObject

Returns the value of attribute name.



106
107
108
# File 'lib/rake/rpmtask.rb', line 106

def name
  @name
end

#spec_pathObject

Returns the value of attribute spec_path.



106
107
108
# File 'lib/rake/rpmtask.rb', line 106

def spec_path
  @spec_path
end

Instance Method Details

#define_tasksObject



127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/rake/rpmtask.rb', line 127

def define_tasks
  task @name => @prereqs  do |t|
    for rpm in spec.packages
      spec.install_sources

      file rpm.path => spec.path  do |t|
        rpm_names = spec.packages.map { |p|  p.name }.join(', ')
        puts '', '-' * 80,
            "Building #{rpm_names} ...",
            '-' * 80

       flags = @build_srpms ? RPM::BUILD__ALL_PACKAGE : RPM::BUILD__BINARY_PACKAGE
       raise "RPM Build failed"  unless spec.build(flags).zero?
      end.invoke

#          CLOBBER.include pkg.path
    end
#        CLEAN.include File.join( RPM::BuildDir, "#{spec.name}-#{spec.version}" )

#        CLOBBER.include @spec.sources.map { |s|  File.join RPM::SRPMDir, s.filename }
  end
end

#specObject



119
120
121
122
123
124
125
# File 'lib/rake/rpmtask.rb', line 119

def spec
  unless @spec
    @spec = RPM::Spec.open @spec_path
    raise "Unable to parse #{spec_path}"  unless @spec
  end
  @spec
end