#
# Copyright 2014 Chef Software, Inc.
#
# All Rights Reserved.
#

name "pushy-server-cookbooks"

dependency 'berkshelf2'

cookbook_name = "opscode-pushy-server"
cookbook_dir = "#{install_dir}/embedded/cookbooks"

source path: "#{project.files_path}/pushy-server-cookbooks"

build do
  mkdir "#{cookbook_dir}"
  command "cd #{cookbook_name} && #{install_dir}/embedded/bin/berks install" \
          " --path=#{cookbook_dir}"
  block do
    File.open("#{cookbook_dir}/dna.json", "w") do |f|
      f.write JSON.fast_generate(
        run_list: [
          'recipe[opscode-pushy-server::default]',
        ]
      )
    end
    File.open("#{cookbook_dir}/show-config.json", "w") do |f|
      f.write JSON.fast_generate(
        run_list: [
          'recipe[opscode-pushy-server::show_config]',
        ]
      )
    end
    File.open("#{cookbook_dir}/solo.rb", "w") do |f|
      f.write <<-EOH.gsub(/^ {8}/, '')
        cookbook_path   "#{install_dir}/embedded/cookbooks"
        file_cache_path "#{install_dir}/embedded/cookbooks/cache"
        verbose_logging true
      EOH
    end
  end
end

#
# Copyright 2014 Chef Software, Inc.
#
# All Rights Reserved.
#

name "pushy-server-cookbooks"

source path: "#{project.files_path}/pushy-server-cookbooks"

dependency 'berkshelf2'

build do
  env = with_standard_compiler_flags(with_embedded_path)
  command "berks install" \
        " --path=#{install_dir}/embedded/cookbooks", env: env, cwd: "#{project_dir}/opscode-pushy-server"
  block do
    File.open("#{install_dir}/embedded/cookbooks/dna.json", "w") do |f|
      f.write JSON.fast_generate(
        run_list: [
          'recipe[opscode-pushy-server::default]',
        ]
      )
    end
    File.open("#{install_dir}/embedded/cookbooks/show-config.json", "w") do |f|
      f.write JSON.fast_generate(
        run_list: [
          'recipe[opscode-pushy-server::show_config]',
        ]
      )
    end
    File.open("#{install_dir}/embedded/cookbooks/solo.rb", "w") do |f|
      f.write <<-EOH.gsub(/^ {8}/, '')
        cookbook_path   "#{install_dir}/embedded/cookbooks"
        file_cache_path "#{install_dir}/embedded/cookbooks/cache"
        verbose_logging true
      EOH
    end
  end
end

Make cookbooks software definition consistent with other projects.
Make cookbooks software definition consistent with other projects.
