Skip to content
Browse files

Changes to build behavior in rpmtask.rb, Rakefile

Source a .spec.in file and output .spec.
Determine whether to include extra_release based on setting of Release in .spec.in
Make Version a constant in Rakefile.
  • Loading branch information...
1 parent d030803 commit 17b704a45ebd01c1e73ab6d3ad7c493a82b5c81a @eggmaster eggmaster committed Dec 21, 2011
Showing with 22 additions and 11 deletions.
  1. +2 −1 Rakefile
  2. +1 −1 contrib/{aeolus-configure.spec → aeolus-configure.spec.in}
  3. +19 −9 rake/rpmtask.rb
View
3 Rakefile
@@ -28,10 +28,11 @@ CLEAN.include('pkg', 'repo')
CLOBBER.include('aeolus')
PKG_NAME = "aeolus-configure"
RPM_SPEC = "contrib/aeolus-configure.spec"
+PKG_VERSION = "2.5.0"
# Build the rpm
rpm_task =
-Rake::RpmTask.new(RPM_SPEC) do |rpm|
+Rake::RpmTask.new(RPM_SPEC, {:suffix => '.in', :pkg_version => PKG_VERSION}) do |rpm|
rpm.need_tar = true
rpm.package_files.include("COPYING", "bin/*", "recipes/**/*", "conf/*")
rpm.topdir = "#{RPMBUILD_DIR}"
View
2 contrib/aeolus-configure.spec → contrib/aeolus-configure.spec.in
@@ -3,7 +3,7 @@
Summary: Aeolus Configure Puppet Recipe
Name: aeolus-configure
-Version: 2.5.0
+Version: @VERSION@
Release: 0%{?extra_release}%{?dist}
Group: Applications/Internet
View
28 rake/rpmtask.rb
@@ -26,7 +26,7 @@ module Rake
# Create a package based upon a RPM spec.
# RPM packages, can be produced by this task.
class RpmTask < PackageTask
- # RPM spec containing the metadata for this package
+ # filename for output RPM spec
attr_accessor :rpm_spec
# RPM build dir
@@ -35,15 +35,29 @@ class RpmTask < PackageTask
# Include extra_release information in the rpm
attr_accessor :include_extra_release
- def initialize(rpm_spec)
- init(rpm_spec)
+ def initialize(rpm_spec, args = {})
+ init(rpm_spec,args)
yield self if block_given?
define if block_given?
end
- def init(rpm_spec)
- @include_extra_release = true
+ def init(rpm_spec,args)
@rpm_spec = rpm_spec
+
+ if args[:suffix]
+ rpm_spec_in = @rpm_spec + args[:suffix]
+ @include_extra_release = eval `grep -q '^[[:space:]]*Release:[[:space:]]*0' #{rpm_spec_in} && echo true || echo false`
+
+ git_head = `git log -1 --pretty=format:%h`
+ extra_release = @include_extra_release ? ("." + Time.now.strftime("%Y%m%d%H%M%S").gsub(/\s/, '') + "git" + "#{git_head}") : ''
+
+ if args[:pkg_version]
+ pkg_version = args[:pkg_version]
+ `sed -e "s|@VERSION@|#{pkg_version}|;s|^\\(Release:[^%]*\\)|\\1#{extra_release}|" #{rpm_spec_in} > #{@rpm_spec}`
+ else
+ `sed -e "s|^\\(Release:[^%]*\\)|\\1#{extra_release}|" #{rpm_spec_in} > #{@rpm_spec}`
+ end
+ end
# parse this out of the rpmbuild macros,
# not ideal but better than hardcoding this
@@ -85,14 +99,10 @@ def define
# FIXME properly determine :package build artifact(s) to copy to sources dir
file rpm_file, [:include_extra_release] => [:package, "#{@topdir}/SOURCES", "#{@topdir}/SPECS"] do |t,args|
- @include_extra_release = args.include_extra_release != "false"
- git_head = `git log -1 --pretty=format:%h`
- extra_release = "." + Time.now.strftime("%Y%m%d%H%M%S").gsub(/\s/, '') + "git" + "#{git_head}"
cp "#{package_dir}/#{@name}-#{@version}.tgz", "#{@topdir}/SOURCES/"
cp @rpm_spec, "#{@topdir}/SPECS"
sh "#{@rpmbuild_cmd} " +
"--define '_topdir #{@topdir}' " +
- "--define 'extra_release #{@include_extra_release ? extra_release : ''}' " +
"-ba #{@rpm_spec}"
end
end

0 comments on commit 17b704a

Please sign in to comment.
Something went wrong with that request. Please try again.