Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Moved Packaging code to Packager gem

  • Loading branch information...
commit b716f6fb7f1b3804a9f8cae88c2dbca8989a5e5e 1 parent 954f34c
@wagenet wagenet authored
Showing with 11 additions and 153 deletions.
  1. +1 −0  Gemfile
  2. +10 −126 Rakefile
  3. +0 −23 build/Distribution.erb
  4. +0 −4 build/PackageInfo.erb
View
1  Gemfile
@@ -5,4 +5,5 @@ gemspec
group :development do
gem "rspec", "~> 2.0"
gem "faraday", "~> 0.5.0"
+ gem "packager"
end
View
136 Rakefile
@@ -1,130 +1,14 @@
-require "bundler/setup"
-require "guides/version"
-require "erb"
+require File.expand_path('../lib/guides/version', __FILE__)
-file "Guides/local/guides/bundle" => "Gemfile" do
- require "rbconfig"
+begin
+ require 'packager/rake_task'
- unless Config::CONFIG["target_cpu"] == "universal"
- puts "Please use a universal binary copy of ruby"
- exit 1
- end
-
- unless RUBY_VERSION == "1.9.2"
- puts "Please use Ruby 1.9.2"
- exit 1
- end
-
- puts "Regenerating the bundle."
-
- sh "rm -rf bundle"
- sh "rm -rf .bundle"
- sh "rm -rf guides-pkg"
- sh "rm -f Guides.pkg"
- Bundler.with_clean_env do
- sh "bundle --standalone --without development"
- end
- sh "mkdir -p Guides/local/guides"
- sh "cp -R bundle Guides/local/guides/"
-
- verbose(false) do
- Dir.chdir("Guides/local/guides/bundle/ruby/1.9.1") do
- Dir["{bin,cache,doc,specifications}"].each { |f| rm_rf f }
- Dir["**/{ext,docs,test,spec}"].each { |f| rm_rf(f) if File.directory?(f) && f !~ /maruku/i }
- Dir["**/erubis-*/doc-api"].each {|f| rm_rf(f) }
- end
- end
-end
-
-file "Guides/local/guides/lib"
-
-`git ls-files -- lib`.split("\n").each do |file|
- dest = "Guides/local/guides/#{file}"
- file dest => file do
- verbose(false) { mkdir_p File.dirname(dest) }
- cp_r file, dest
- end
- task "Guides/local/guides/lib" => dest
-end
-
-file "Guides/bin/guides" => "bin/guides" do
- guides = File.read("bin/guides").sub(/\A#.*/, "#!/usr/local/ruby1.9/bin/ruby -I /usr/local/guides/bundle -r bundler/setup")
-
- sh "mkdir -p Guides/bin"
- File.open("Guides/bin/guides", "w") { |file| file.puts guides }
- File.chmod 0755, "Guides/bin/guides"
-end
-
-desc "Prep the release for PackageMaker"
-task :make_pkg => ["Guides/local/guides/bundle", "Guides/local/guides/lib", "Guides/bin/guides"]
-
-task :rm do
- rm_rf "Guides"
-end
-
-directory "guides-pkg/Resources"
-directory "guides-pkg/guides.pkg"
-
-pkg_dependencies = [:make_pkg, "guides-pkg/Resources", "guides-pkg/guides.pkg",
- "guides-pkg/Distribution", "guides-pkg/guides.pkg/Bom",
- "guides-pkg/guides.pkg/PackageInfo", "guides-pkg/guides.pkg/Payload"]
-
-def details
- @details ||= begin
- total_size, files = 0, 0
-
- Dir["Guides/**/*"].each do |file|
- files += 1
-
- next if File.directory?(file)
-
- total_size += File.size(file)
- end
-
- [total_size, files]
- end
-end
-
-file "guides-pkg/Distribution" do
- src = File.read File.expand_path("../build/Distribution.erb", __FILE__)
- erb = ERB.new(src)
-
- total_size, files = details
-
- kbytes = total_size / 1024
- version = Guides::VERSION
-
- File.open("guides-pkg/Distribution", "w") do |file|
- file.puts erb.result(binding)
+ Packager::RakeTask.new(:pkg) do |t|
+ t.version = Guides::VERSION
+ t.domain = "strobecorp.com"
+ t.package_name = "Guides"
+ t.bin_files = ['guides']
end
+rescue LoadError
+ puts "`gem install packager` for packaging tasks"
end
-
-file "guides-pkg/guides.pkg/PackageInfo" do
- src = File.read File.expand_path("../build/PackageInfo.erb", __FILE__)
- erb = ERB.new(src)
-
- total_size, num_files = details
-
- kbytes = total_size / 1024
- version = Guides::VERSION
-
- File.open("guides-pkg/guides.pkg/PackageInfo", "w") do |file|
- file.puts erb.result(binding)
- end
-end
-
-file "guides-pkg/guides.pkg/Bom" do
- sh "mkbom -s Guides guides-pkg/guides.pkg/Bom"
-end
-
-file "guides-pkg/guides.pkg/Payload" do
- sh "cd Guides && pax -wz -x cpio . > ../guides-pkg/guides.pkg/Payload"
-end
-
-file "Guides.pkg" => pkg_dependencies do
- sh "pkgutil --flatten guides-pkg Guides.pkg"
-end
-
-task :pkg => "Guides.pkg"
-
-task :clean => [:rm, :pkg]
View
23 build/Distribution.erb
@@ -1,23 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<installer-script minSpecVersion="1.000000" authoringTool="org.ruby-lang.rake" authoringToolVersion="0.8.7">
- <title>Guides</title>
- <options customize="never" allow-external-scripts="no"/>
- <domains enable_localSystem="true"/>
- <script>
- function ruby19p136_installed() {
- return !(system.files.fileExistsAtPath('/usr/local/ruby1.9') == true);
- }
- </script>
- <choices-outline>
- <line choice="ruby19p136"/>
- <line choice="guides"/>
- </choices-outline>
- <choice id="ruby19p136" title="ruby" start_selected="false" start_enabled="false" selected="ruby19p136_installed()" enabled="ruby19p136_installed()">
- <pkg-ref id="com.strobecorp.ruby19"/>
- </choice>
- <choice id="guides" title="Guides">
- <pkg-ref id="com.strobecorp.guides"/>
- </choice>
- <pkg-ref id="com.strobecorp.ruby19" installKBytes="26156" archiveKBytes="7353" hash-sha256="7b9507f7a9178c0eaafd3ffcfd2e246400e82899e6f29df2f7c4fcec6ec04ac5" version="1.9.2p136" auth="Root">http://ruby-pkg.strobeapp.com/Ruby-1.9.2p136.pkg</pkg-ref>
- <pkg-ref id="com.strobecorp.guides" installKBytes="<%= kbytes %>" version="<%= version %>" auth="Root">#guides.pkg</pkg-ref>
-</installer-script>
View
4 build/PackageInfo.erb
@@ -1,4 +0,0 @@
-<pkg-info format-version="2" identifier="com.strobecorp.guides" version="<%= version %>" install-location="/usr" auth="root">
- <payload installKBytes="<%= kbytes %>" numberOfFiles="<%= num_files %>"/>
-</pkg-info>
-
Please sign in to comment.
Something went wrong with that request. Please try again.