Skip to content

Commit 9a7c963

Browse files
authored
Merge pull request #43 from criteo-cookbooks/bump_chef_dependency
Bump chef to 15+ and remove dependency to windows cookbook
2 parents 2632bad + 592c27e commit 9a7c963

File tree

4 files changed

+35
-18
lines changed

4 files changed

+35
-18
lines changed

CHANGELOG.md

+5
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# NSSM CHANGELOG
22

3+
## 5.0.0 2021-10-28
4+
5+
- Depends on Chef 15+
6+
- Remove dependency on Windows cookbook
7+
38
## 4.0.1 2018-07-25
49

510
- Remote file is now before notification friendly (fixes #33)

metadata.rb

+4-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
# frozen_string_literal: true
22

33
name 'nssm'
4-
maintainer 'Dennis Hoer'
5-
maintainer_email 'dennis.hoer@gmail.com'
4+
maintainer 'Criteo'
5+
maintainer_email 'systems-services-team@criteo.com'
66
license 'MIT'
77
description 'Installs/Configures NSSM'
88
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
99
source_url 'https://github.com/criteo-cookbooks/nssm'
1010
issues_url 'https://github.com/criteo-cookbooks/nssm/issues'
11-
version '4.0.1'
11+
version '5.0.0'
1212

13-
chef_version '>= 12.7'
13+
chef_version '>= 15.0'
1414

1515
supports 'windows'
16-
depends 'windows'

resources/install.rb

+19-7
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,29 @@
88
action :install do
99
src = new_resource.source
1010
basename = src.slice(src.rindex('/') + 1, src.rindex('.') - src.rindex('/') - 1)
11+
download_path = "#{Chef::Config[:file_cache_path]}/#{basename}.zip"
12+
extract_path = "#{Chef::Config[:file_cache_path]}/#{basename}"
1113
system = node['kernel']['machine'] == 'x86_64' ? 'win64' : 'win32'
12-
system_file = "#{Chef::Config[:file_cache_path]}/#{basename}/#{system}/nssm.exe"
14+
system_file = "#{extract_path}/#{basename}/#{system}/nssm.exe"
1315

14-
windows_zipfile 'download nssm' do
15-
path Chef::Config[:file_cache_path]
16-
source src
17-
overwrite true
16+
remote_file 'download nssm' do
1817
checksum new_resource.sha256
19-
action :unzip
18+
path download_path
19+
source src
2020
notifies :create, 'remote_file[install nssm]', :immediately
21-
not_if { Digest::SHA256.file("#{Chef::Config[:file_cache_path]}/#{basename}.zip").hexdigest == new_resource.sha256 } if ::File.exist?("#{Chef::Config[:file_cache_path]}/#{basename}.zip")
21+
end
22+
23+
directory extract_path do
24+
action :nothing
25+
recursive true
26+
subscribes :delete, 'remote_file[download nssm]', :before
27+
end
28+
29+
archive_file 'extract nssm' do
30+
action :extract
31+
destination extract_path
32+
overwrite false
33+
path download_path
2234
end
2335

2436
remote_file 'install nssm' do

spec/unit/default_spec.rb

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,19 +19,20 @@
1919
)
2020
end
2121

22-
it 'download nssm' do
23-
expect(chef_run).to unzip_windows_zipfile('download nssm').with(
24-
path: CACHE,
22+
it 'downloads nssm' do
23+
expect(chef_run).to create_remote_file('download nssm').with(
24+
path: "#{CACHE}/nssm-#{VERSION}.zip",
2525
source: "https://nssm.cc/ci/nssm-#{VERSION}.zip"
2626
)
2727
end
2828

29-
it 'install nssm' do
29+
it 'installs nssm' do
3030
allow(::File).to receive(:exist?).and_call_original
31-
expect(::File).to receive(:exist?).with("#{CACHE}/nssm-2.24-94-g9c88bc1/win64/nssm.exe").and_return true
31+
expect(::File).to receive(:exist?).with("#{CACHE}/nssm-#{VERSION}/nssm-#{VERSION}/win64/nssm.exe").and_return true
32+
3233
expect(chef_run).to create_remote_file('install nssm').with(
3334
path: "C:\\tmp\\nssm-#{VERSION}.exe",
34-
source: "file:///#{CACHE}/nssm-2.24-94-g9c88bc1/win64/nssm.exe"
35+
source: "file:///#{CACHE}/nssm-#{VERSION}/nssm-#{VERSION}/win64/nssm.exe"
3536
)
3637
end
3738
end

0 commit comments

Comments
 (0)