<commit_before>#
# Cookbook Name:: rvm
# Recipe:: compile_gemset
#
#  Copyright 2011 <NAME>
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

gemset_file = "/tmp/gemset.gems"
gemset_dir = ::File.join(node[:rvm][:install_path], "gems", "#{node[:rvm][:compile_gemset][:ruby]}@compile_me")

include_recipe "rvm::default"

rjg_aws_s3 "Download gemset file" do
  access_key_id node[:aws][:access_key_id]
  secret_access_key node[:aws][:secret_access_key]
  s3_bucket node[:rvm][:compile_gemset][:s3_bucket]
  s3_file node[:rvm][:compile_gemset][:gemset_file]
  file_path gemset_file
  action :get
end

bash "Create and upload gem binaries (i386 arch)" do
  code <<-EOF
rvm_archflags="-arch i386" CFLAGS="-arch i386" LDFLAGS="-arch i386" rvm install #{node[:rvm][:compile_gemset][:ruby]}
rvm --default use #{node[:rvm][:compile_gemset][:ruby]}
rvm --create #{node[:rvm][:compile_gemset][:ruby]}@compile_me
rvm gemset import #{gemset_file}
cd #{gemset_dir}
tar -cf /tmp/#{node[:rvm][:compile_gemset][:gemset_name]}-i386.tar *
gzip /tmp/#{node[:rvm][:compile_gemset][:gemset_name]}-i386.tar
  EOF
end

bash "Create and upload gem binaries (x86_64 arch)" do
  code <<-EOF
rvm remove #{node[:rvm][:compile_gemset][:ruby]}
rm -rf #{gemset_dir}
rvm_archflags="-arch x86_64" CFLAGS="-arch x86_64" LDFLAGS="-arch x86_64" rvm install #{node[:rvm][:compile_gemset][:ruby]}
rvm --default use #{node[:rvm][:compile_gemset][:ruby]}
rvm --create #{node[:rvm][:compile_gemset][:ruby]}@compile_me
rvm gemset import #{gemset_file}
cd #{gemset_dir}<commit_msg>Specify the rvm binary path<commit_after>#
# Cookbook Name:: rvm
# Recipe:: compile_gemset
#
#  Copyright 2011 <NAME>
#  Licensed under the Apache License, Version 2.0 (the "License");
#  you may not use this file except in compliance with the License.
#  You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#  Unless required by applicable law or agreed to in writing, software
#  distributed under the License is distributed on an "AS IS" BASIS,
#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#  See the License for the specific language governing permissions and
#  limitations under the License.

gemset_file = "/tmp/gemset.gems"
gemset_dir = ::File.join(node[:rvm][:install_path], "gems", "#{node[:rvm][:compile_gemset][:ruby]}@compile_me")
rvm_bin = ::File.join(node[:rvm][:install_path], "bin", "rvm")

include_recipe "rvm::default"

rjg_aws_s3 "Download gemset file" do
  access_key_id node[:aws][:access_key_id]
  secret_access_key node[:aws][:secret_access_key]
  s3_bucket node[:rvm][:compile_gemset][:s3_bucket]
  s3_file node[:rvm][:compile_gemset][:gemset_file]
  file_path gemset_file
  action :get
end

bash "Create and upload gem binaries (i386 arch)" do
  code <<-EOF
rvm_archflags="-arch i386" CFLAGS="-arch i386" LDFLAGS="-arch i386" #{rvm_bin} install #{node[:rvm][:compile_gemset][:ruby]}
#{rvm_bin} --default use #{node[:rvm][:compile_gemset][:ruby]}
#{rvm_bin} --create #{node[:rvm][:compile_gemset][:ruby]}@compile_me
#{rvm_bin} gemset import #{gemset_file}
cd #{gemset_dir}
tar -cf /tmp/#{node[:rvm][:compile_gemset][:gemset_name]}-i386.tar *
gzip /tmp/#{node[:rvm][:compile_gemset][:gemset_name]}-i386.tar
  EOF
end

bash "Create and upload gem binaries (x86_64 arch)" do
  code <<-EOF
#{rvm_bin} remove #{node[:rvm][:compile_gemset][:ruby]}
rm -rf #{gemset_dir}
rvm_archflags="-arch x86_64" CFLAGS="-arch x86_64" LDFLAGS="-arch x86_64" #{rvm_bin} install #{node[:rvm][:compile_gemset][:ruby]}
#{rvm_bin} --default use #{node[:rvm][:compile_gemset][:ruby]}
#{rvm_bin} --create #{node[:rvm][:compile_gemset][:ruby]}@compile_me
#{rvm_bin} gemset import #{gemset_file}
cd #{gemset_dir}
{'fraction_non_alphanumeric': 0.15550807217473883, 'fraction_numerical': 0.02184235517568851, 'mean_word_length': 6.276338514680484, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '961556', 'n_tokens_mistral': 1595, 'n_tokens_neox': 1522, 'n_words': 391}