<commit_before>#
# Cookbook Name:: windev
# Recipe:: packages
#
# Copyright (c) 2014-2016 Zühlke, All Rights Reserved.

include_recipe 'windev::depot'

::Chef::Recipe.send(:include, Windows::Helper)

node.fetch('installer_packages',[]).each do |pkg|
  unless is_package_installed?(pkg['name']) && installed_packages[pkg['name']][:version] == pkg['version']
    if pkg["source"]
      windev_cache_package pkg["save_as"] do
        source pkg["source"]
        depot node['software_depot']
      end
      if pkg["unpack"]
        unpackPath = File.join(node["software_depot"],pkg['unpack'])
        directory unpackPath do
          action :delete
          recursive true
        end
        windows_zipfile unpackPath do
          source ::File.join(node["software_depot"],pkg['save_as'])
          action :unzip
        end
      end
    end
    if pkg["installer"]
      installer= ::File.join(node["software_depot"],pkg['installer'])
    else
      installer= ::File.join(node["software_depot"],pkg['save_as'])
    end

    ruby_block "installer_exists" do
      block do
        raise "Installer #{File.expand_path(installer)} not found" unless File.exist?(File.expand_path(installer))
      end
      action :run
    end

    package pkg['name'] do # ~FC009
      provider Chef::Provider::Package::Windows
      source File.expand_path(installer)
      installer_type pkg['type'].to_sym if pkg['type']
      options pkg['options']
      version pkg['version']
      timeout pkg.fetch('timeout',600)
      returns [0,3010] + pkg.fetch('exit_codes', [])
      action :install
    end
  end
end

node.fetch('zip_packages',[]).each do |pkg|
  version=::File.expand_path("#{pkg['unpack']}/#{pkg['version']}.version")
  unless ::File.exists?(version)
    if pkg["source"]
      windev_cache_package pkg["save_as"] do
        source pkg["source"]
        depot node['software_depot']<commit_msg>use unique resource name to get rid of resource cloning deprecation warnings (see https://docs.chef.io/deprecations_resource_cloning.html)<commit_after>#
# Cookbook Name:: windev
# Recipe:: packages
#
# Copyright (c) 2014-2016 Zühlke, All Rights Reserved.

include_recipe 'windev::depot'

::Chef::Recipe.send(:include, Windows::Helper)

node.fetch('installer_packages',[]).each do |pkg|
  unless is_package_installed?(pkg['name']) && installed_packages[pkg['name']][:version] == pkg['version']
    if pkg["source"]
      windev_cache_package pkg["save_as"] do
        source pkg["source"]
        depot node['software_depot']
      end
      if pkg["unpack"]
        unpackPath = File.join(node["software_depot"],pkg['unpack'])
        directory unpackPath do
          action :delete
          recursive true
        end
        windows_zipfile unpackPath do
          source ::File.join(node["software_depot"],pkg['save_as'])
          action :unzip
        end
      end
    end
    if pkg["installer"]
      installer= ::File.join(node["software_depot"],pkg['installer'])
    else
      installer= ::File.join(node["software_depot"],pkg['save_as'])
    end

    ruby_block "#{installer} exists" do
      block do
        raise "Installer #{File.expand_path(installer)} not found" unless File.exist?(File.expand_path(installer))
      end
      action :run
    end

    package pkg['name'] do # ~FC009
      provider Chef::Provider::Package::Windows
      source File.expand_path(installer)
      installer_type pkg['type'].to_sym if pkg['type']
      options pkg['options']
      version pkg['version']
      timeout pkg.fetch('timeout',600)
      returns [0,3010] + pkg.fetch('exit_codes', [])
      action :install
    end
  end
end

node.fetch('zip_packages',[]).each do |pkg|
  version=::File.expand_path("#{pkg['unpack']}/#{pkg['version']}.version")
  unless ::File.exists?(version)
    if pkg["source"]
      windev_cache_package pkg["save_as"] do
        source pkg["source"]
        depot node['software_depot']
{'fraction_non_alphanumeric': 0.1439509954058193, 'fraction_numerical': 0.009698825931597753, 'mean_word_length': 3.408323959505062, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, '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': '468104', 'n_tokens_mistral': 1284, 'n_tokens_neox': 1204, 'n_words': 255}