<commit_before>include_recipe 'chef-sugar'
include_recipe 'build-essential'

if debian?
  prereqs = %w(automake pkg-config zlib1g-dev libpcre3-dev liblzma-dev)
elsif rhel? || fedora?
  prereqs = %w(automake pkgconfig zlib zlib-devel pcre pcre-devel xz xz-devel)
else
  log "Don't know prereqs for #{node.platform_family}; proceeding anyway"
  prereqs = []
end

prereqs.each do |pkg|
  package pkg do
    action :install
  end
end

cache = "the_silver_searcher-#{node.the_silver_searcher.version}"

remote_file "#{Chef::Config['file_cache_path']}/#{cache}.tar.gz" do
  source node.the_silver_searcher.url
  checksum node.the_silver_searcher.checksum
  notifies :run, 'bash[install ag]', :immediately
end

bash 'install ag' do
  user 'root'
  cwd Chef::Config['file_cache_path']
  code <<-EOH
    tar -zxf #{cache}.tar.gz
    (cd #{cache} && ./build.sh #{node.the_silver_searcher.build_opt} && make install)
  EOH
  action :nothing
end
<commit_msg>add debug log<commit_after>include_recipe 'chef-sugar'
include_recipe 'build-essential'

if debian?
  prereqs = %w(automake pkg-config zlib1g-dev libpcre3-dev liblzma-dev)
elsif rhel? || fedora?
  prereqs = %w(automake pkgconfig zlib zlib-devel pcre pcre-devel xz xz-devel)
else
  log "Don't know prereqs for #{node.platform_family}; proceeding anyway"
  prereqs = []
end

prereqs.each do |pkg|
  package pkg do
    action :install
  end
end

cache = "the_silver_searcher-#{node.the_silver_searcher.version}"

remote_file "#{Chef::Config['file_cache_path']}/#{cache}.tar.gz" do
  source node.the_silver_searcher.url
  checksum node.the_silver_searcher.checksum
  notifies :run, 'bash[install ag]', :immediately
end

bash 'install ag' do
  user 'root'
  cwd Chef::Config['file_cache_path']
  code <<-EOH
    echo build opt: #{node.the_silver_searcher.build_opt}
    tar -zxf #{cache}.tar.gz
    (cd #{cache} && ./build.sh #{node.the_silver_searcher.build_opt} && make install)
  EOH
  action :nothing
end

{'fraction_non_alphanumeric': 0.12512820512820513, 'fraction_numerical': 0.0020512820512820513, 'mean_word_length': 4.655072463768116, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '67426', 'n_tokens_mistral': 774, 'n_tokens_neox': 756, 'n_words': 172}