Skip to content

Commit

Permalink
fix(package): use correct version parameter with packages
Browse files Browse the repository at this point in the history
* 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 node version

BREAKING CHANGE: `node:pkg:version` needs to be specified as the
full version number (ie, 17.0.1) instead of just the major number
in order to be able to properly install using packages and pin the
desired version.
  • Loading branch information
javierbertoli committed Nov 10, 2021
1 parent eddad91 commit a5cdd41
Show file tree
Hide file tree
Showing 10 changed files with 39 additions and 25 deletions.
1 change: 1 addition & 0 deletions .yamllint
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ ignore: |
.git/
node_modules/
test/**/states/**/*.sls
test/salt/pillar/repo.sls
.kitchen/
kitchen.vagrant.yml
node/osfamilymap.yaml
Expand Down
9 changes: 5 additions & 4 deletions node/defaults.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# vim: ft=yaml
---
node:
version: 13.12.0
version: 17.0.1
config_file: /etc/npmrc
config: {}
environ_file: /etc/default/node.sh
Expand All @@ -19,7 +19,7 @@ node:
source: /usr/local/src
pkg:
name: nodejs
version: '14'
# version: 17.0.1
use_upstream_repo: false
use_upstream_archive: false
use_upstream_source: false
Expand All @@ -34,13 +34,14 @@ node:
suffix: tar.gz
archive:
uri: https://nodejs.org/dist
source_hash: 3e66b14bbeb9ea1ba129fae7c65374844f4ddaf1e48e2bc19b3b2570e158e362
# node-v17.0.1.tar.gz
source_hash: 6ec480f872cb7c34877044985e3d7bd89329ace5b8e2ad90b57980601786341c
enforce_toplevel: false
trim_output: true
options: '--strip-components=1'
source:
uri: https://github.com/nodejs/node/archive
source_hash: 37aff6cc2f451d1dbe693d18ad87fad352ed4f74f7b8e232590dd7f2f6b5d525
source_hash: ef8544d55b9f514a30824e8c59cb25349a00d7a9ea325ed5c6f2e366f99cfc1a
trim_output: true
enforce_toplevel: false
options: '--strip-components=1'
Expand Down
3 changes: 2 additions & 1 deletion node/map.jinja
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
'source': '%s/v%s/%s.%s'|format(node.pkg.archive.uri, node.version, dirname, node.pkg.suffix)}) %}
{%- endif %}
{%- if node.pkg.use_upstream_repo -%}
{%- set full_repo_name = 'deb %s/node_%s.x %s'|format(node.pkg.repo.url, node.pkg.version, node.pkg.repo.dist) -%}
{%- set repo_version = node.version.split('.')[0] | default('') %}
{%- set full_repo_name = 'deb %s/node_%s.x %s'|format(node.pkg.repo.url, repo_version, node.pkg.repo.dist) -%}
{%- do node.pkg.repo.update({
'name': full_repo_name}) -%}
{%- endif -%}
17 changes: 10 additions & 7 deletions node/osfamilymap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@
{%- set macos_rootgroup = salt['cmd.run']("stat -f '%Sg' /dev/console") %}
{%- endif %}

# Source hashes taken from https://nodejs.org/dist/vnode.version/SHASUMS256.txt

Debian:
pkg:
version: 17.0.1-deb-1nodesource1
deps:
- pkg-config
- build-essential
Expand Down Expand Up @@ -65,23 +68,23 @@ FreeBSD:
pkg:
name: node
source:
# node-v13.12.0.tar.gz ????
source_hash: 1b74d624493f17210b96dbd925066034e2d540090a36a99d5c50155cd6726a38
# node-v17.0.1.tar.gz ????
source_hash: f06242a7958b89f1bc3c7070af1ff5e477a9d3b76d2348456617f87e8f4f6988

OpenBSD:
pkg:
name: node
source:
# node-v13.12.0.tar.gz ????
source_hash: 1b74d624493f17210b96dbd925066034e2d540090a36a99d5c50155cd6726a38
# node-v17.0.1.tar.gz ????
source_hash: f06242a7958b89f1bc3c7070af1ff5e477a9d3b76d2348456617f87e8f4f6988

Solaris: {}

Windows:
pkg:
source:
# win-x64/node.exe
source_hash: a5c49d8053f399bf8eb3de86426b2274982ddceaeade7fb2f3446b4ebc7cd2e4
source_hash: 9f85861d85abeeb5fbd1ef6cea6bc7b672bc66aa13643e609941ee84b9402596
archive_suffix: exe

MacOS:
Expand All @@ -90,5 +93,5 @@ MacOS:
pkg:
name: node # homebrew; macports: nodejs7
source:
# darwin amd64 tarball, node-v13.12.0-darwin-x64.tar.gz
source_hash: 1fe3103610e8eb66ae71872ea1b4e868a638292a4e7ad0e41976a9fe417a09c7
# darwin amd64 tarball, node-v17.0.1-darwin-x64.tar.gz
source_hash: 0dfe6f904f3f20652e3d34c60885b790603f120d5d51a53031355827a4eaf6a9
5 changes: 2 additions & 3 deletions node/package/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ node-package-install-pkg-installed:
pkg.installed:
- name: {{ node.pkg.name }}
- reload_modules: true
{%- if salt['pillar.get']('node:pkg:version', '') %}
{# use pkg:version for pinning #}
- version: {{ salt['pillar.get']('node:pkg:version', '') }}
{%- if node.pkg.version is defined %}
- version: {{ node.pkg.version }}
{%- endif %}
12 changes: 9 additions & 3 deletions pillar.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@
# vim: ft=yaml
---
node:
version: 13.12.0
# This version is used in archive/source installations, and it's major number
# is used in to build the upstream's repo URL when using package installations
# (the default) and `use_upstream_repo: true`
version: 17.0.1
config:
prefix: '/home/vagrant/.npm-packages'
environ:
a: b
pkg:
# This version is used only in `package` based installations, to pin to
# specific package version, specially if the repo has more than one available
# version: 17.0.1
use_upstream_repo: false
use_upstream_archive: false
use_upstream_source: false
archive:
uri: https://nodejs.org/dist
source_hash: 3e66b14bbeb9ea1ba129fae7c65374844f4ddaf1e48e2bc19b3b2570e158e362
source_hash: 6ec480f872cb7c34877044985e3d7bd89329ace5b8e2ad90b57980601786341c
source:
uri: https://github.com/nodejs/node/archive
source_hash: 37aff6cc2f451d1dbe693d18ad87fad352ed4f74f7b8e232590dd7f2f6b5d525
source_hash: ef8544d55b9f514a30824e8c59cb25349a00d7a9ea325ed5c6f2e366f99cfc1a
4 changes: 2 additions & 2 deletions test/salt/pillar/archive.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# vim: ft=yaml
---
node:
version: 13.12.0
version: 17.0.1
pkg:
use_upstream_archive: true # from NodeSource
archive:
uri: https://nodejs.org/dist
source_hash: 3e66b14bbeb9ea1ba129fae7c65374844f4ddaf1e48e2bc19b3b2570e158e362
source_hash: 6ec480f872cb7c34877044985e3d7bd89329ace5b8e2ad90b57980601786341c

config:
prefix: '/home/vagrant/.npm-packages'
Expand Down
6 changes: 3 additions & 3 deletions test/salt/pillar/default.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# vim: ft=yaml
---
node:
version: 13.12.0
version: 17.0.1
config:
prefix: '/home/vagrant/.npm-packages'
environ:
Expand All @@ -13,7 +13,7 @@ node:
use_upstream_source: false
archive:
uri: https://nodejs.org/dist
source_hash: 3e66b14bbeb9ea1ba129fae7c65374844f4ddaf1e48e2bc19b3b2570e158e362
source_hash: 6ec480f872cb7c34877044985e3d7bd89329ace5b8e2ad90b57980601786341c
source:
uri: https://github.com/nodejs/node/archive
source_hash: 37aff6cc2f451d1dbe693d18ad87fad352ed4f74f7b8e232590dd7f2f6b5d525
source_hash: ef8544d55b9f514a30824e8c59cb25349a00d7a9ea325ed5c6f2e366f99cfc1a
3 changes: 3 additions & 0 deletions test/salt/pillar/repo.sls
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
node:
pkg:
use_upstream_repo: true # Debian family only
{%- if salt['grains.get']('osfinger') in ['Debian-9','Ubuntu-18.04'] %}
version: 17.0.1-1nodesource1
{%- endif %}
config:
prefix: /home/vagrant/.npm-packages
environ:
Expand Down
4 changes: 2 additions & 2 deletions test/salt/pillar/source.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# vim: ft=yaml
---
node:
version: 13.12.0
version: 17.0.1
pkg:
use_upstream_source: true
source:
uri: https://github.com/nodejs/node/archive
source_hash: 37aff6cc2f451d1dbe693d18ad87fad352ed4f74f7b8e232590dd7f2f6b5d525
source_hash: ef8544d55b9f514a30824e8c59cb25349a00d7a9ea325ed5c6f2e366f99cfc1a

config:
prefix: '/home/vagrant/.npm-packages'
Expand Down

0 comments on commit a5cdd41

Please sign in to comment.