On 12/22/2010 02:59 PM, Mohammed Morsi wrote:
> - decouple yum create_repo task from rpms task and just
> have it depend on the rpm file existance
> - parse dist out from rpm macros config instead of hard coding it
> ---
> Rakefile | 3 ++-
> rake/rpmtask.rb | 20 +++++++++++++++-----
> rake/yumtask.rb | 3 +--
> 3 files changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/Rakefile b/Rakefile
> index e5722c0..cd96a85 100644
> --- a/Rakefile
> +++ b/Rakefile
> @@ -14,6 +14,7 @@ PKG_NAME = "deltacloud_recipe"
> RPM_SPEC = "contrib/deltacloud_recipe.spec"
>
> # Build the rpm
> +rpm_task =
> Rake::RpmTask.new(RPM_SPEC) do |rpm|
> rpm.need_tar = true
> rpm.package_files.include("bin/*", "#{PKG_NAME}/**/*")
> @@ -22,5 +23,5 @@ end
>
> # Construct yum repo
> Rake::YumTask.new(YUM_REPO) do |repo|
> - repo.rpms<< "#{RPMBUILD_DIR}/RPMS/noarch/#{PKG_NAME}*.rpm"
> + repo.rpms<< rpm_task.rpm_file
> end
> diff --git a/rake/rpmtask.rb b/rake/rpmtask.rb
> index c836ce9..ff2ee66 100644
> --- a/rake/rpmtask.rb
> +++ b/rake/rpmtask.rb
> @@ -27,6 +27,13 @@ module Rake
> def init(rpm_spec)
> @rpm_spec = rpm_spec
>
> + # parse this out of the rpmbuild macros,
> + # not ideal but better than hardcoding this
> + File.open('/etc/rpm/macros.dist', "r") { |f|
> + f.read.scan(/%dist\s*\.(.*)\n/)
> + @distro = $1
> + }
> +
> # Parse rpm name / version out of spec
> # FIXME hacky way to do this for now
> # (would be nice to implement a full blown rpm spec parser for ruby)
> @@ -35,14 +42,14 @@ module Rake
> @name = contents.scan(/\nName: .*\n/).first.split.last
> @version = contents.scan(/\nVersion: .*\n/).first.split.last
> @release = contents.scan(/\nRelease: .*\n/).first.split.last
> - @arch = contents.scan(/\nBuildArch: .*\n/)
> + @release.gsub!("%{?dist}", "....@distro}")
> + @arch = contents.scan(/\nBuildArch: .*\n/) # TODO grab local
> arch if not defined
> if @arch.nil?
> @arch = Config::CONFIG["target_cpu"] # hoping this will work for
> all cases,
> # can just run the 'arch'
> cmd if we want
> else
> @arch = @arch.first.split.last
> end
> - @distro = 'fc13' # FIXME shouldn't be hardcoded
> }
> super(@name, @version)
>
> @@ -55,17 +62,20 @@ module Rake
> directory "#...@topdir}/SOURCES"
> directory "#...@topdir}/SPECS"
>
> - # FIXME support all a spec's subpackages as well
> - rpm_file =
> "#...@topdir}/RPMS/#...@arch}/#...@name}-#{@version}...@release}.#{@distro}...@arch}.rpm"
> desc "Build the rpms"
> task :rpms => [rpm_file]
>
> - # FIXME properly determine :package build artifact(s) to copy to
> sources dir, allow users to specify others
> + # FIXME properly determine :package build artifact(s) to copy to
> sources dir
> file rpm_file => [:package, "#...@topdir}/SOURCES",
> "#...@topdir}/SPECS"] do
> cp "#{package_dir}/#...@name}-#{@version}.tgz",
> "#...@topdir}/SOURCES/"
> cp @rpm_spec, "#...@topdir}/SPECS"
> sh "#...@rpmbuild_cmd} --define '_topdir #...@topdir}' -ba
> #...@rpm_spec}"
> end
> end
> +
> + def rpm_file
> + # FIXME support all a spec's subpackages as well
> +
> "#...@topdir}/RPMS/#...@arch}/#...@name}-#{@version}...@release}.#{@arch}.rpm"
> + end
> end
> end
> diff --git a/rake/yumtask.rb b/rake/yumtask.rb
> index aebecab..9b713ea 100644
> --- a/rake/yumtask.rb
> +++ b/rake/yumtask.rb
> @@ -28,9 +28,8 @@ module Rake
>
> def define
> desc "Build the yum repo"
> - task :create_repo => :rpms do
> + task :create_repo => @rpms do
> @rpms.each { |rpm|
> - rpm = Dir.glob(rpm).first
> rpmc = rpm.split('.')
> arch = rpmc[rpmc.size-2]
> arch_dir = @yum_repo + "/" + arch
ACK
_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel