Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #136 from nareshov/rpmbuild-define

Add new option to pass --define arguments to rpmbuild.
  • Loading branch information...
commit a44e6753b865d7db9dc2adc8b09ece2622120279 2 parents d6504e1 + 6c76ecb
@jordansissel jordansissel authored
Showing with 23 additions and 6 deletions.
  1. +1 −0  lib/fpm/program.rb
  2. +22 −6 lib/fpm/target/rpm.rb
View
1  lib/fpm/program.rb
@@ -99,6 +99,7 @@ def options(args)
FPM::Source::Python.flags(FPM::Flags.new(opts, "python", "python source only"),
@settings)
FPM::Target::Deb.flags(FPM::Flags.new(opts, "deb", "deb target only"), @settings)
+ FPM::Target::Rpm.flags(FPM::Flags.new(opts, "rpm", "rpm target only"), @settings)
# Process fpmrc first
fpmrc(opts)
View
28 lib/fpm/target/rpm.rb
@@ -2,6 +2,14 @@
require "fpm/util"
class FPM::Target::Rpm < FPM::Package
+ def self.flags(opts, settings)
+ settings.target[:rpm] = "rpm"
+
+ opts.on("--rpmbuild-define DEFINITION", "Pass a --define argument to rpmbuild.") do |define|
+ (settings.target[:rpmbuild_define] ||= []) << define
+ end
+ end
+
def architecture
case @architecture
when nil
@@ -73,12 +81,20 @@ def build!(params)
# TODO(sissel): Abort if 'rpmbuild' tool not found.
%w(BUILD RPMS SRPMS SOURCES SPECS).each { |d| Dir.mkdir(d) }
- args = ["rpmbuild", "-ba",
- "--define", "buildroot #{Dir.pwd}/BUILD",
- "--define", "_topdir #{Dir.pwd}",
- "--define", "_sourcedir #{Dir.pwd}",
- "--define", "_rpmdir #{Dir.pwd}/RPMS",
- "#{name}.spec"]
+ prefixargs = ["rpmbuild", "-ba",
+ "--define", "buildroot #{Dir.pwd}/BUILD",
+ "--define", "_topdir #{Dir.pwd}",
+ "--define", "_sourcedir #{Dir.pwd}",
+ "--define", "_rpmdir #{Dir.pwd}/RPMS"]
+
+ spec = ["#{name}.spec"]
+
+ if defines.empty?
+ args = prefixargs + spec
+ else
+ args = prefixargs + defines.collect{ |define| ["--define", define] }.flatten + spec
+ end
+
safesystem(*args)
Dir["#{Dir.pwd}/RPMS/**/*.rpm"].each do |path|
Please sign in to comment.
Something went wrong with that request. Please try again.