Rakefile in rhubarb-0.2.1 vs Rakefile in rhubarb-0.2.2
- old
+ new
@@ -39,17 +39,16 @@
def pkg_version
version = File.exist?('VERSION') ? File.read('VERSION') : ""
return version.chomp
end
-def pkg_version
- version = File.exist?('VERSION') ? File.read('VERSION') : ""
- return version.chomp
+def name
+ return 'rhubarb'
end
def pkg_name
- return 'ruby-rhubarb'
+ return "ruby-" + name()
end
def pkg_spec
return pkg_name() + ".spec"
end
@@ -69,36 +68,37 @@
def rpm_dirs
return %w{BUILD BUILDROOT RPMS SOURCES SPECS SRPMS}
end
desc "create RPMs"
-task :rpms => [:build, :tarball] do
- require 'fileutils'
+task :rpms => [:build, :tarball, :gen_spec] do
FileUtils.cp pkg_spec(), 'SPECS'
sh "rpmbuild --define=\"_topdir \${PWD}\" -ba SPECS/#{pkg_spec}"
end
+desc "Generate the specfile"
+task :gen_spec do
+ sh "cat #{pkg_spec}" + ".in" + "| sed 's/RHUBARB_VERSION/#{pkg_version}/' > #{pkg_spec}"
+end
+
desc "Create a tarball"
-task :tarball => :make_rpmdirs do
- require 'fileutils'
+task :tarball => [:make_rpmdirs, :gen_spec] do
FileUtils.cp_r 'lib', pkg_dir()
FileUtils.cp ['LICENSE', 'README.rdoc', 'CHANGES', 'TODO', 'VERSION'], pkg_dir()
sh "tar -cf #{pkg_source} #{pkg_dir}"
FileUtils.mv pkg_source(), 'SOURCES'
end
desc "Make dirs for building RPM"
-task :make_rpmdirs => :rpm_clean do
- require 'fileutils'
+task :make_rpmdirs => :clean do
FileUtils.mkdir pkg_dir()
FileUtils.mkdir rpm_dirs()
end
desc "Cleanup after an RPM build"
-task :rpm_clean do
+task :clean do
require 'fileutils'
- FileUtils.rm_r pkg_dir(), :force => true
- FileUtils.rm_r rpm_dirs(), :force => true
+ FileUtils.rm_r [pkg_dir(), rpm_dirs(), pkg_spec(), 'pkg', name() + ".gemspec"], :force => true
end
require 'spec/rake/spectask'
Spec::Rake::SpecTask.new(:spec) do |spec|
spec.libs << 'lib' << 'spec'