<commit_before># Copyright (c) 2015 SwiftStack, Inc.
#
# 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.


execute "clean-up" do
  command "rm /home/vagrant/postinstall.sh || true"
end

if node['extra_key'] then
  keys_file = "~vagrant/.ssh/authorized_keys"
  execute "add_extra_key" do
    command "echo '#{node['extra_key']}' >> #{keys_file}"
    not_if "grep -q '#{node['extra_key']}' #{keys_file}"
  end
end

# deadsnakes for py2.6
execute "deadsnakes key" do
  command "sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <KEY>"
  action :run
  not_if "sudo apt-key list | grep 'Launchpad Old Python Versions'"
end

cookbook_file "/etc/apt/sources.list.d/fkrull-deadsnakes-trusty.list" do
  source "etc/apt/sources.list.d/fkrull-deadsnakes-trusty.list"
  mode 0644
end

execute "enable backports" do
  command "sudo sed -ie 's/# deb http:\\/\\/archive.ubuntu.com\\/ubuntu trusty-backports/deb http:\\/\\/archive.ubuntu.com\\/ubuntu trusty-backports/' /etc/apt/sources.list"
  action :run
  not_if "sudo grep -q '^deb .* trusty-backports' /etc/apt/sources.list"
end

execute "apt-get-update" do
  command "apt-get update && touch /tmp/.apt-get-update"
  if not node['full_reprovision']
    creates "/tmp/.apt-get-update"
  end
  action :run
end

# packages
required_packages = [
  "libjerasure-dev",  # required for the EC biz
  "curl", "gcc", "memcached", "rsync", "sqlite3", "xfsprogs", "git-core",
  "build-essential", "python-dev", "libffi-dev", "python-dev", "python3.3",
  "python3.3-dev", "python3.4", "python3.4-dev", "python2.6", "python2.6-dev",
  "libxml2-dev", "libxml2", "libxslt1-dev",
]
extra_packages = node['extra_packages']
(required_packages + extra_packages).each do |pkg|
  package pkg do
    action :install
  end
end

# it's a brave new world
execute "install pip" do
  command "curl https://bootstrap.pypa.io/get-pip.py | python"
  not_if "which pip"
end<commit_msg>just clean up packages and test<commit_after># Copyright (c) 2015 SwiftStack, Inc.
#
# 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.


execute "clean-up" do
  command "rm /home/vagrant/postinstall.sh || true"
end

if node['extra_key'] then
  keys_file = "~vagrant/.ssh/authorized_keys"
  execute "add_extra_key" do
    command "echo '#{node['extra_key']}' >> #{keys_file}"
    not_if "grep -q '#{node['extra_key']}' #{keys_file}"
  end
end

# deadsnakes for py2.6
execute "deadsnakes key" do
  command "sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys <KEY>"
  action :run
  not_if "sudo apt-key list | grep 'Launchpad Old Python Versions'"
end

cookbook_file "/etc/apt/sources.list.d/fkrull-deadsnakes-trusty.list" do
  source "etc/apt/sources.list.d/fkrull-deadsnakes-trusty.list"
  mode 0644
end

execute "enable backports" do
  command "sudo sed -ie 's/# deb http:\\/\\/archive.ubuntu.com\\/ubuntu trusty-backports/deb http:\\/\\/archive.ubuntu.com\\/ubuntu trusty-backports/' /etc/apt/sources.list"
  action :run
  not_if "sudo grep -q '^deb .* trusty-backports' /etc/apt/sources.list"
end

execute "apt-get-update" do
  command "apt-get update && touch /tmp/.apt-get-update"
  if not node['full_reprovision']
    creates "/tmp/.apt-get-update"
  end
  action :run
end

# packages
required_packages = [
  "libjerasure-dev",  # required for the EC biz
  "curl", "gcc", "memcached", "rsync", "sqlite3", "xfsprogs", "git-core",
  "build-essential", "python-dev", "libffi-dev", "python3.3", "python3.3-dev",
  "python3.4", "python3.4-dev", "python2.6", "python2.6-dev", "libxml2-dev",
  "libxml2", "libxslt1-dev",
]
extra_packages = node['extra_packages']
(required_packages + extra_packages).each do |pkg|
  package pkg do
    action :install
  end
end

# it's a brave new world
execute "install pip" do
  command "curl https://bootstrap.pypa.io/get-pip.py | python"
  not_if "which pip"
end
{'fraction_non_alphanumeric': 0.1403581840899625, 'fraction_numerical': 0.012494793835901708, 'mean_word_length': 3.992723492723493, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 4}, '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': '4869842', 'n_tokens_mistral': 1723, 'n_tokens_neox': 1650, 'n_words': 495}