Rakefile in spqr-0.2.0 vs Rakefile in spqr-0.2.2

- old
+ new

@@ -21,17 +21,73 @@ def pkg_version version = File.exist?('VERSION') ? File.read('VERSION') : "" return version.chomp end +def name + return "spqr" +end + +def pkg_name + return "ruby-" + name() +end + +def pkg_spec + return pkg_name() + ".spec" +end + +def pkg_rel + return `grep -i 'define rel' #{pkg_spec} | awk '{print $3}'`.chomp() +end + +def pkg_source + return pkg_name() + "-" + pkg_version() + "-" + pkg_rel() + ".tar.gz" +end + +def pkg_dir + return pkg_name() + "-" + pkg_version() +end + +def rpm_dirs + return %w{BUILD BUILDROOT RPMS SOURCES SPECS SRPMS} +end + desc "create an RPM spec file" task :rpmspec => :build do sh "gem2rpm -t spqr.spec.in -o spqr.spec pkg/spqr-#{pkg_version}.gem" end -desc "create a source RPM" -task :srpm => :build do - sh "gem2rpm -t spqr.spec.in -s pkg/spqr-#{pkg_version}.gem" +desc "create RPMs" +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/SPQR_VERSION/#{pkg_version}/' > #{pkg_spec}" +end + +desc "Create a tarball" +task :tarball => [:make_rpmdirs, :gen_spec] do + FileUtils.cp_r 'bin', pkg_dir() + FileUtils.cp_r 'lib', pkg_dir() + FileUtils.cp_r 'examples', 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 => :clean do + FileUtils.mkdir pkg_dir() + FileUtils.mkdir rpm_dirs() +end + +desc "Cleanup after an RPM build" +task :clean do + require 'fileutils' + 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'