vendor/jets-gems/lib/jets/gems/extract/ruby.rb in jets-1.2.1 vs vendor/jets-gems/lib/jets/gems/extract/ruby.rb in jets-1.3.0

- old
+ new

@@ -1,8 +1,8 @@ # Usage: # -# Jets::Gems::Extract::Ruby.new("2.5.0", +# Jets::Gems::Extract::Ruby.new("2.5.3", # downloads_root: cache_area, # defaults to /tmp/lambdagem # dest: cache_area, # defaults to . (project_root) # ).run # module Jets::Gems::Extract @@ -10,28 +10,37 @@ class NotFound < RuntimeError; end def run say "Looking for #{full_ruby_name}" clean_downloads(:rubies) if @options[:clean] - tarball_path = download_ruby - unpack_tarball(tarball_path) - say("Ruby #{full_ruby_name} unpacked at #{project_root}", :debug) + zip_path = download_ruby + unzip(zip_path) end + def unzip(path) + dest = "#{Jets.build_root}/stage/code/opt" + say "Unpacking into #{dest}" + FileUtils.mkdir_p(dest) + # cd-ing dest unzips the files into that folder + sh("cd #{dest} && unzip -qo #{path}") + say("Ruby #{full_ruby_name} unziped at #{dest}", :debug) + end + def download_ruby url = ruby_url + puts "download ruby url #{url}" tarball_dest = download_file(url, download_path(File.basename(url))) unless tarball_dest message = "Url: #{url} not found" if @options[:exit_on_error] say message exit else raise NotFound.new(message) end end - say "Tarball downloaded to: #{tarball_dest}" + say "Downloaded to: #{tarball_dest}" tarball_dest end def download_path(filename) "#{@downloads_root}/downloads/rubies/#{filename}" @@ -40,19 +49,19 @@ # If only the ruby version is given, then append ruby- in front. Otherwise # leave alone. # # Example: # - # 2.5.0 -> ruby-2.5.0-linux-x86_64.tgz - # ruby-2.5.0 -> ruby-2.5.0-linux-x86_64.tgz - # test-ruby-2.5.0 -> test-ruby-2.5.0-linux-x86_64.tgz + # 2.5.3 -> ruby-2.5.3.zip + # ruby-2.5.3 -> ruby-2.5.3.zip + # test-ruby-2.5.3 -> test-ruby-2.5.3.zip def full_ruby_name md = @name.match(/^(\d+\.\d+\.\d+)$/) if md ruby_version = md[1] - "ruby-#{ruby_version}-linux-x86_64.tgz" + "ruby-#{ruby_version}.zip" else - "#{@name}-linux-x86_64.tgz" + "#{@name}.zip" end end def ruby_url "#{source_url}/rubies/#{full_ruby_name}"