Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move away from buildcurl and pull from artifactory #3

Open
wants to merge 17 commits into
base: build_curl-libyaml-0.1.7-node-official
Choose a base branch
from
Open
24 changes: 20 additions & 4 deletions lib/language_pack/fetcher.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,20 @@ def fetch(path)

def fetch_untar(path, files_to_extract = nil)
curl = curl_command("#{@host_url.join(path)} -s -o")
run!("#{curl} - | tar zxf - #{files_to_extract}", error_class: FetchError)
run!("#{curl} | tar zxf - #{files_to_extract}", error_class: FetchError)
print 'done - fetch_untar'
end

def fetch_bunzip2(path, files_to_extract = nil)
curl = curl_command("#{@host_url.join(path)} -s -o")
run!("#{curl} - | tar jxf - #{files_to_extract}", error_class: FetchError)
run!("#{curl} | tar jxf - #{files_to_extract}", error_class: FetchError)
print 'done - fetch_bunzip2'
end

def fetch_xz(path, files_to_extract = nil)
curl = curl_command("#{@host_url.join(path)} -s -o")
run!("#{curl} | tar Jxf - #{files_to_extract}", error_class: FetchError)
print 'done - fetch_xz'
end

private
Expand All @@ -35,16 +43,24 @@ def curl_command(command)
buildcurl_mapping = {
"ruby" => /^ruby-(.+)$/,
"rubygem-bundler" => /^bundler-(.+)$/,
"libyaml" => /^libyaml-(.+)$/
"libyaml" => /^libyaml-(.+)$/,
"node" => /^node-(.+)$/
}
buildcurl_mapping.each do |k,v|
if File.basename(binary, ".tgz") =~ v
return "set -o pipefail; curl -L --get --fail --retry 3 #{buildcurl_url} -d recipe=#{k} -d version=#{$1} -d target=$TARGET #{rest.join(" ")}"
filename = File.basename(binary)
print "build location and file = #{build_dep_loc}/#{filename}\n"
return "set -o pipefail; cat #{build_dep_loc}/#{filename}"
#return "set -o pipefail; curl -L --get --fail --retry 3 #{buildcurl_url} -d recipe=#{k} -d version=#{$1} -d target=$TARGET #{rest.join(" ")}"
end
end
"set -o pipefail; curl -L --fail --retry 3 --retry-delay 1 --connect-timeout #{curl_connect_timeout_in_seconds} --max-time #{curl_timeout_in_seconds} #{command}"
end

def build_dep_loc
ENV['BUILD_DEP_LOC']
end

def buildcurl_url
ENV['BUILDCURL_URL'] || "buildcurl.com"
end
Expand Down
4 changes: 2 additions & 2 deletions lib/language_pack/helpers/node_installer.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class LanguagePack::NodeInstaller
MODERN_NODE_VERSION = "0.10.30"
MODERN_NODE_VERSION = "18.19.0"
MODERN_BINARY_PATH = "node-v#{MODERN_NODE_VERSION}-linux-x64"

LEGACY_NODE_VERSION = "0.4.7"
Expand Down Expand Up @@ -37,7 +37,7 @@ def install
@fetchers[:legacy].fetch_untar("#{LEGACY_BINARY_PATH}.tgz")
else
node_bin = "#{MODERN_BINARY_PATH}/bin/node"
@fetchers[:modern].fetch_untar("#{MODERN_BINARY_PATH}.tar.gz", "#{MODERN_BINARY_PATH}/bin/node")
@fetchers[:modern].fetch_xz("#{MODERN_BINARY_PATH}.tar.xz", "#{MODERN_BINARY_PATH}/bin/node")
FileUtils.mv(node_bin, ".")
FileUtils.rm_rf(MODERN_BINARY_PATH)
end
Expand Down
18 changes: 16 additions & 2 deletions lib/language_pack/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# base Ruby Language Pack. This is for any base ruby app.
class LanguagePack::Ruby < LanguagePack::Base
NAME = "ruby"
LIBYAML_VERSION = "0.1.7"
LIBYAML_VERSION = "0.2.5"
LIBYAML_PATH = "libyaml-#{LIBYAML_VERSION}"
BUNDLER_VERSION = "1.11.2"
BUNDLER_GEM_PATH = "bundler-#{BUNDLER_VERSION}"
Expand Down Expand Up @@ -460,6 +460,7 @@ def install_bundler_in_app
# default set of binaries to install
# @return [Array] resulting list
def binaries
print "add_node_js_binary #{add_node_js_binary}\n"
add_node_js_binary
end

Expand Down Expand Up @@ -544,7 +545,7 @@ def build_bundler
instrument 'ruby.build_bundler' do
log("bundle") do
bundle_without = env("BUNDLE_WITHOUT") || "development:test"
bundle_bin = "bundle"
bundle_bin = "bundle config --global ssl_verify_mode 0 && bundle"
bundle_command = "#{bundle_bin} install --without #{bundle_without} --path vendor/bundle --binstubs #{bundler_binstubs_path}"
bundle_command << " -j4"

Expand Down Expand Up @@ -795,9 +796,22 @@ def node_preinstall_bin_path
else
@node_preinstall_bin_path = false
end
# on alma container, `which` binary is present and it will find `node`
# from `/usr/local/bin/node` as a result of which node is considered
# `preinstalled` and the real node is not installed in the right place.
# lets ignore this path in this branch.
# HACK ALERT
if force_node_install?
print "forcing node install\n"
@node_preinstall_bin_path = false
end
end
alias :node_js_installed? :node_preinstall_bin_path

def force_node_install?
ENV["FORCE_NODE_INSTALL"].to_s.downcase == "true" || false
end

def node_not_preinstalled?
!node_js_installed?
end
Expand Down