Permalink
Browse files

Extract .exe files via 7zip, DRY up some common code. Add git recipe.

  • Loading branch information...
1 parent 592d0eb commit c26946908cee7fddf9f3a0ae23e5d5ac73976e98 @ender672 committed Apr 2, 2009
View
@@ -35,8 +35,9 @@ class << task ; def needed?() ; true ; end ; end
else
# Download to a file task instead
fail unless args.keys.size == 1
+ target = args.keys.first.to_s
uri = URI.parse(args.values.first.to_s)
- file_create(args.keys.first) do |task|
+ file_create(target) do |task|
task.sources << uri
task.enhance { uri.download(task.name, options) }
end
View
@@ -18,7 +18,7 @@ def extract(file, target, options = {})
when /(^.+)\.tgz$/
seven_zip tmpdir, file
seven_zip target, File.join(tmpdir, "#{File.basename($1)}.tar")
- when /(^.+\.zip$)/
+ when /(^.+\.zip$)/, /(^.+\.exe$)/
seven_zip(target, $1)
else
raise "Unknown file extension! (for file #{file})"
View
@@ -1,10 +1,45 @@
require 'rake'
require 'rake/clean'
+sandbox = File.join RubyInstaller::ROOT, 'sandbox'
+downloads = File.join RubyInstaller::ROOT, 'downloads'
+
# default cleanup
-CLOBBER.include("sandbox")
-CLOBBER.include("downloads")
+CLOBBER.include sandbox
+CLOBBER.include downloads
# define common tasks
-directory "downloads"
-directory "sandbox"
+directory downloads
+directory sandbox
+
+def standard_download_and_extract(package)
+ target = File.join RubyInstaller::ROOT, package.target
+ directory target
+ CLEAN.include target
+
+ standard_download package
+ standard_extract package
+end
+
+def file_paths(package)
+ package.files.map{|f| File.join RubyInstaller::DOWNLOADS, f}
+end
+
+def standard_download(package)
+ package_file_uris = package.files.map{|f| URI.parse "#{package.url}/#{f}"}
+ file_paths(package).each_with_index do |f, i|
+ uri = package_file_uris[i]
+ file_create(f){p "downloading #{uri} to #{f}"; uri.download(f, {:verbose => true})}
+ file f => RubyInstaller::DOWNLOADS
+ task :download => f
+ end
+end
+
+def standard_extract(package)
+ target = File.join RubyInstaller::ROOT, package.target
+ # Prepare the :sandbox, it requires the :download task
+ task :extract => [:extract_utils, :download, target] do
+ p "extracting #{package}"
+ file_paths(package).each{|f| extract f, target}
+ end
+end
@@ -1,35 +1,10 @@
require 'rake'
require 'rake/clean'
-namespace(:compiler) do
- namespace(:mingw) do
- # mingw needs downloads, sandbox and sandbox/mingw
+namespace :compiler do
+ namespace :mingw do
package = RubyInstaller::MinGW
- directory package.target
- CLEAN.include(package.target)
-
- # Put files for the :download task
- package.files.each do |f|
- file_source = "#{package.url}/#{f}"
- file_target = "downloads/#{f}"
- download file_target => file_source
-
- # depend on downloads directory
- file file_target => "downloads"
-
- # download task need these files as pre-requisites
- task :download => file_target
- end
-
- # Prepare the :sandbox, it requires the :download task
- task :extract => [:extract_utils, :download, package.target] do
- # grab the files from the download task
- files = Rake::Task['compiler:mingw:download'].prerequisites
-
- files.each { |f|
- extract(File.join(RubyInstaller::ROOT, f), package.target)
- }
- end
+ standard_download_and_extract package
end
end
View
@@ -3,33 +3,9 @@ require 'rake/clean'
namespace(:compiler) do
namespace(:msys) do
- # mingw needs downloads, sandbox and sandbox/mingw
package = RubyInstaller::MSYS
- directory package.target
- CLEAN.include(package.target)
-
- # Put files for the :download task
- package.files.each do |f|
- file_source = "#{package.url}/#{f}"
- file_target = "downloads/#{f}"
- download file_target => file_source
-
- # depend on downloads directory
- file file_target => "downloads"
-
- # download task need these files as pre-requisites
- task :download => file_target
- end
-
- # Prepare the :sandbox, it requires the :download task
- task :extract => [:extract_utils, :download, package.target] do
- # grab the files from the download task
- files = Rake::Task['compiler:msys:download'].prerequisites
-
- files.each { |f|
- extract(File.join(RubyInstaller::ROOT, f), package.target)
- }
- end
+ target = File.join RubyInstaller::ROOT, package.target
+ standard_download_and_extract package
# prepares the msys environment to be used
task :prepare do
@@ -46,12 +22,12 @@ namespace(:compiler) do
# create the fstab file, mount /mingw to sandbox/mingw
# mount also /usr/local to sandbox/msys/usr
- File.open(File.join(package.target, "etc", "fstab"), 'w') do |f|
- f.puts "#{File.join(RubyInstaller::ROOT, RubyInstaller::MinGW.target)} /mingw"
+ File.open(File.join(target, "etc", "fstab"), 'w') do |f|
+ f.puts "#{File.join RubyInstaller::ROOT, RubyInstaller::MinGW.target} /mingw"
end
#remove the chdir to $HOME in the /etc/profile
- profile = File.join(package.target, "etc", "profile")
+ profile = File.join(target, "etc", "profile")
contents = File.read(profile).gsub(/cd \"\$HOME\"/) do |match|
"# commented to allow calling from current directory\n##{match}"
@@ -0,0 +1,11 @@
+require 'rake'
+require 'rake/clean'
+
+namespace(:dependencies) do
+ namespace(:cairo) do
+ standard_download_and_extract RubyInstaller::Cairo
+ end
+end
+
+task :download => ['dependencies:cairo:download']
+task :extract => ['dependencies:cairo:extract']
@@ -4,31 +4,7 @@ require 'rake/clean'
namespace(:dependencies) do
namespace(:gdbm) do
package = RubyInstaller::Gdbm
- directory package.target
- CLEAN.include(package.target)
-
- # Put files for the :download task
- package.files.each do |f|
- file_source = "#{package.url}/#{f}"
- file_target = "downloads/#{f}"
- download file_target => file_source
-
- # depend on downloads directory
- file file_target => "downloads"
-
- # download task need these files as pre-requisites
- task :download => file_target
- end
-
- # Prepare the :sandbox, it requires the :download task
- task :extract => [:extract_utils, :download, package.target] do
- # grab the files from the download task
- files = Rake::Task['dependencies:gdbm:download'].prerequisites
-
- files.each { |f|
- extract(File.join(RubyInstaller::ROOT, f), package.target)
- }
- end
+ standard_download_and_extract package
task :prepare => [package.target] do
# gdbm needs some adjustments.
@@ -0,0 +1,12 @@
+require 'rake'
+require 'rake/clean'
+
+namespace(:dependencies) do
+ namespace(:git) do
+ package = RubyInstaller::Git
+ standard_download_and_extract package
+ end
+end
+
+task :download => ['dependencies:git:download']
+task :extract => ['dependencies:git:extract']
@@ -3,32 +3,7 @@ require 'rake/clean'
namespace(:dependencies) do
namespace(:glib) do
- package = RubyInstaller::Glib
- directory package.target
- CLEAN.include(package.target)
-
- # Put files for the :download task
- package.files.each do |f|
- file_source = "#{package.url}/#{f}"
- file_target = "downloads/#{f}"
- download file_target => file_source
-
- # depend on downloads directory
- file file_target => "downloads"
-
- # download task need these files as pre-requisites
- task :download => file_target
- end
-
- # Prepare the :sandbox, it requires the :download task
- task :extract => [:extract_utils, :download, package.target] do
- # grab the files from the download task
- files = Rake::Task['dependencies:glib:download'].prerequisites
-
- files.each { |f|
- extract(File.join(RubyInstaller::ROOT, f), package.target)
- }
- end
+ standard_download_and_extract RubyInstaller::Glib
end
end
@@ -3,33 +3,8 @@ require 'rake/clean'
namespace(:dependencies) do
namespace(:iconv) do
- # zlib needs mingw and downloads
package = RubyInstaller::Iconv
- directory package.target
- CLEAN.include(package.target)
-
- # Put files for the :download task
- package.files.each do |f|
- file_source = "#{package.url}/#{f}"
- file_target = "downloads/#{f}"
- download file_target => file_source
-
- # depend on downloads directory
- file file_target => "downloads"
-
- # download task need these files as pre-requisites
- task :download => file_target
- end
-
- # Prepare the :sandbox, it requires the :download task
- task :extract => [:extract_utils, :download, package.target] do
- # grab the files from the download task
- files = Rake::Task['dependencies:iconv:download'].prerequisites
-
- files.each { |f|
- extract(File.join(RubyInstaller::ROOT, f), package.target)
- }
- end
+ standard_download_and_extract RubyInstaller::Gdbm
task :prepare => [package.target] do
# win_iconv needs some adjustments.
@@ -3,32 +3,7 @@ require 'rake/clean'
namespace(:dependencies) do
namespace(:libjpeg) do
- package = RubyInstaller::LibJpeg
- directory package.target
- CLEAN.include(package.target)
-
- # Put files for the :download task
- package.files.each do |f|
- file_source = "#{package.url}/#{f}"
- file_target = "downloads/#{f}"
- download file_target => file_source
-
- # depend on downloads directory
- file file_target => "downloads"
-
- # download task need these files as pre-requisites
- task :download => file_target
- end
-
- # Prepare the :sandbox, it requires the :download task
- task :extract => [:extract_utils, :download, package.target] do
- # grab the files from the download task
- files = Rake::Task['dependencies:libjpeg:download'].prerequisites
-
- files.each { |f|
- extract(File.join(RubyInstaller::ROOT, f), package.target)
- }
- end
+ standard_download_and_extract RubyInstaller::LibJpeg
end
end
@@ -3,32 +3,7 @@ require 'rake/clean'
namespace(:dependencies) do
namespace(:libpng) do
- package = RubyInstaller::LibPng
- directory package.target
- CLEAN.include(package.target)
-
- # Put files for the :download task
- package.files.each do |f|
- file_source = "#{package.url}/#{f}"
- file_target = "downloads/#{f}"
- download file_target => file_source
-
- # depend on downloads directory
- file file_target => "downloads"
-
- # download task need these files as pre-requisites
- task :download => file_target
- end
-
- # Prepare the :sandbox, it requires the :download task
- task :extract => [:extract_utils, :download, package.target] do
- # grab the files from the download task
- files = Rake::Task['dependencies:libpng:download'].prerequisites
-
- files.each { |f|
- extract(File.join(RubyInstaller::ROOT, f), package.target)
- }
- end
+ standard_download_and_extract RubyInstaller::LibPng
end
end
@@ -3,32 +3,7 @@ require 'rake/clean'
namespace(:dependencies) do
namespace(:libungif) do
- package = RubyInstaller::LibUnGif
- directory package.target
- CLEAN.include(package.target)
-
- # Put files for the :download task
- package.files.each do |f|
- file_source = "#{package.url}/#{f}"
- file_target = "downloads/#{f}"
- download file_target => file_source
-
- # depend on downloads directory
- file file_target => "downloads"
-
- # download task need these files as pre-requisites
- task :download => file_target
- end
-
- # Prepare the :sandbox, it requires the :download task
- task :extract => [:extract_utils, :download, package.target] do
- # grab the files from the download task
- files = Rake::Task['dependencies:libungif:download'].prerequisites
-
- files.each { |f|
- extract(File.join(RubyInstaller::ROOT, f), package.target)
- }
- end
+ standard_download_and_extract RubyInstaller::LibUnGif
end
end
Oops, something went wrong.

0 comments on commit c269469

Please sign in to comment.