Skip to content

Commit 6ce8259

Browse files
committed
fix(package): use correct version parameter with packages
* fix(package): remove double colon preventing correct version usage * feat(package): when `use_upstream_repo: true`, guess URL's version from `node:version`'s major value, to be consistent where the major version is obtained from. This also allows to pick a minor version from the repo (if available), using `node:pkg:version` * feat(version): update to latest LTS node version (16.13.0) BREAKING CHANGE: `node:pkg:version` needs to be specified as the full version number (ie, 16.13.0) instead of just the major number in order to be able to properly install using packages and pin the desired version.
1 parent eddad91 commit 6ce8259

10 files changed

+40
-25
lines changed

.yamllint

+1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ ignore: |
1818
.git/
1919
node_modules/
2020
test/**/states/**/*.sls
21+
test/salt/pillar/repo.sls
2122
.kitchen/
2223
kitchen.vagrant.yml
2324
node/osfamilymap.yaml

node/defaults.yaml

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# vim: ft=yaml
33
---
44
node:
5-
version: 13.12.0
5+
version: 16.13.0
66
config_file: /etc/npmrc
77
config: {}
88
environ_file: /etc/default/node.sh
@@ -19,7 +19,7 @@ node:
1919
source: /usr/local/src
2020
pkg:
2121
name: nodejs
22-
version: '14'
22+
# version: 16.13.0
2323
use_upstream_repo: false
2424
use_upstream_archive: false
2525
use_upstream_source: false
@@ -34,13 +34,15 @@ node:
3434
suffix: tar.gz
3535
archive:
3636
uri: https://nodejs.org/dist
37-
source_hash: 3e66b14bbeb9ea1ba129fae7c65374844f4ddaf1e48e2bc19b3b2570e158e362
37+
# node-v16.13.0.tar.gz
38+
source_hash: 9c00e5b6024cfcbc9105f9c58cf160762e78659a345d100c5bd80a7fb38c684f
3839
enforce_toplevel: false
3940
trim_output: true
4041
options: '--strip-components=1'
4142
source:
4243
uri: https://github.com/nodejs/node/archive
43-
source_hash: 37aff6cc2f451d1dbe693d18ad87fad352ed4f74f7b8e232590dd7f2f6b5d525
44+
# https://github.com/nodejs/node/archive/refs/tags/v16.13.0.tar.gz
45+
source_hash: f0327e99f730bf2506a1f13dbd452ec80b33667a7ce1c77a2dacd6babc8643c7
4446
trim_output: true
4547
enforce_toplevel: false
4648
options: '--strip-components=1'

node/map.jinja

+2-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535
'source': '%s/v%s/%s.%s'|format(node.pkg.archive.uri, node.version, dirname, node.pkg.suffix)}) %}
3636
{%- endif %}
3737
{%- if node.pkg.use_upstream_repo -%}
38-
{%- set full_repo_name = 'deb %s/node_%s.x %s'|format(node.pkg.repo.url, node.pkg.version, node.pkg.repo.dist) -%}
38+
{%- set repo_version = node.version.split('.')[0] | default('') %}
39+
{%- set full_repo_name = 'deb %s/node_%s.x %s'|format(node.pkg.repo.url, repo_version, node.pkg.repo.dist) -%}
3940
{%- do node.pkg.repo.update({
4041
'name': full_repo_name}) -%}
4142
{%- endif -%}

node/osfamilymap.yaml

+10-7
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,11 @@
1515
{%- set macos_rootgroup = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
1616
{%- endif %}
1717

18+
# Source hashes taken from https://nodejs.org/dist/v node.version /SHASUMS256.txt
19+
1820
Debian:
1921
pkg:
22+
version: 16.13.0-deb-1nodesource1
2023
deps:
2124
- pkg-config
2225
- build-essential
@@ -65,23 +68,23 @@ FreeBSD:
6568
pkg:
6669
name: node
6770
source:
68-
# node-v13.12.0.tar.gz ????
69-
source_hash: 1b74d624493f17210b96dbd925066034e2d540090a36a99d5c50155cd6726a38
71+
# node-v16.13.0.tar.gz ????
72+
source_hash: 9c00e5b6024cfcbc9105f9c58cf160762e78659a345d100c5bd80a7fb38c684f
7073

7174
OpenBSD:
7275
pkg:
7376
name: node
7477
source:
75-
# node-v13.12.0.tar.gz ????
76-
source_hash: 1b74d624493f17210b96dbd925066034e2d540090a36a99d5c50155cd6726a38
78+
# node-v16.13.0.tar.gz ????
79+
source_hash: 9c00e5b6024cfcbc9105f9c58cf160762e78659a345d100c5bd80a7fb38c684f
7780

7881
Solaris: {}
7982

8083
Windows:
8184
pkg:
8285
source:
8386
# win-x64/node.exe
84-
source_hash: a5c49d8053f399bf8eb3de86426b2274982ddceaeade7fb2f3446b4ebc7cd2e4
87+
source_hash: 7fca04f83b0e2169e41b2e1845e8da0f07d66cf9c3a1b4150767bf3ffddccf62
8588
archive_suffix: exe
8689

8790
MacOS:
@@ -90,5 +93,5 @@ MacOS:
9093
pkg:
9194
name: node # homebrew; macports: nodejs7
9295
source:
93-
# darwin amd64 tarball, node-v13.12.0-darwin-x64.tar.gz
94-
source_hash: 1fe3103610e8eb66ae71872ea1b4e868a638292a4e7ad0e41976a9fe417a09c7
96+
# darwin amd64 tarball, node-v16.13.0-darwin-x64.tar.gz
97+
source_hash: 37e09a8cf2352f340d1204c6154058d81362fef4ec488b0197b2ce36b3f0367a

node/package/install.sls

+2-3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ node-package-install-pkg-installed:
1616
pkg.installed:
1717
- name: {{ node.pkg.name }}
1818
- reload_modules: true
19-
{%- if salt['pillar.get']('node:pkg:version', '') %}
20-
{# use pkg:version for pinning #}
21-
- version: {{ salt['pillar.get']('node:pkg:version', '') }}
19+
{%- if node.pkg.version is defined %}
20+
- version: {{ node.pkg.version }}
2221
{%- endif %}

pillar.example

+9-3
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22
# vim: ft=yaml
33
---
44
node:
5-
version: 13.12.0
5+
# This version is used in archive/source installations, and it's major number
6+
# is used in to build the upstream's repo URL when using package installations
7+
# (the default) and `use_upstream_repo: true`
8+
version: 16.13.0
69
config:
710
prefix: '/home/vagrant/.npm-packages'
811
environ:
912
a: b
1013
pkg:
14+
# This version is used only in `package` based installations, to pin to
15+
# specific package version, specially if the repo has more than one available
16+
# version: 16.13.0
1117
use_upstream_repo: false
1218
use_upstream_archive: false
1319
use_upstream_source: false
1420
archive:
1521
uri: https://nodejs.org/dist
16-
source_hash: 3e66b14bbeb9ea1ba129fae7c65374844f4ddaf1e48e2bc19b3b2570e158e362
22+
source_hash: 9c00e5b6024cfcbc9105f9c58cf160762e78659a345d100c5bd80a7fb38c684f
1723
source:
1824
uri: https://github.com/nodejs/node/archive
19-
source_hash: 37aff6cc2f451d1dbe693d18ad87fad352ed4f74f7b8e232590dd7f2f6b5d525
25+
source_hash: f0327e99f730bf2506a1f13dbd452ec80b33667a7ce1c77a2dacd6babc8643c7

test/salt/pillar/archive.sls

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# vim: ft=yaml
33
---
44
node:
5-
version: 13.12.0
5+
version: 16.13.0
66
pkg:
77
use_upstream_archive: true # from NodeSource
88
archive:
99
uri: https://nodejs.org/dist
10-
source_hash: 3e66b14bbeb9ea1ba129fae7c65374844f4ddaf1e48e2bc19b3b2570e158e362
10+
source_hash: 9c00e5b6024cfcbc9105f9c58cf160762e78659a345d100c5bd80a7fb38c684f
1111

1212
config:
1313
prefix: '/home/vagrant/.npm-packages'

test/salt/pillar/default.sls

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# vim: ft=yaml
33
---
44
node:
5-
version: 13.12.0
5+
version: 16.13.0
66
config:
77
prefix: '/home/vagrant/.npm-packages'
88
environ:
@@ -13,7 +13,7 @@ node:
1313
use_upstream_source: false
1414
archive:
1515
uri: https://nodejs.org/dist
16-
source_hash: 3e66b14bbeb9ea1ba129fae7c65374844f4ddaf1e48e2bc19b3b2570e158e362
16+
source_hash: 9c00e5b6024cfcbc9105f9c58cf160762e78659a345d100c5bd80a7fb38c684f
1717
source:
1818
uri: https://github.com/nodejs/node/archive
19-
source_hash: 37aff6cc2f451d1dbe693d18ad87fad352ed4f74f7b8e232590dd7f2f6b5d525
19+
source_hash: f0327e99f730bf2506a1f13dbd452ec80b33667a7ce1c77a2dacd6babc8643c7

test/salt/pillar/repo.sls

+3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44
node:
55
pkg:
66
use_upstream_repo: true # Debian family only
7+
{%- if salt['grains.get']('osfinger') in ['Debian-9','Ubuntu-18.04'] %}
8+
version: 16.13.0-1nodesource1
9+
{%- endif %}
710
config:
811
prefix: /home/vagrant/.npm-packages
912
environ:

test/salt/pillar/source.sls

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,12 @@
22
# vim: ft=yaml
33
---
44
node:
5-
version: 13.12.0
5+
version: 16.13.0
66
pkg:
77
use_upstream_source: true
88
source:
99
uri: https://github.com/nodejs/node/archive
10-
source_hash: 37aff6cc2f451d1dbe693d18ad87fad352ed4f74f7b8e232590dd7f2f6b5d525
10+
source_hash: f0327e99f730bf2506a1f13dbd452ec80b33667a7ce1c77a2dacd6babc8643c7
1111

1212
config:
1313
prefix: '/home/vagrant/.npm-packages'

0 commit comments

Comments
 (0)