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 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.
  • Loading branch information
javierbertoli committed Nov 10, 2021
1 parent eddad91 commit 6ce8259
Show file tree
Hide file tree
Showing 10 changed files with 40 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
10 changes: 6 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: 16.13.0
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: 16.13.0
use_upstream_repo: false
use_upstream_archive: false
use_upstream_source: false
Expand All @@ -34,13 +34,15 @@ node:
suffix: tar.gz
archive:
uri: https://nodejs.org/dist
source_hash: 3e66b14bbeb9ea1ba129fae7c65374844f4ddaf1e48e2bc19b3b2570e158e362
# node-v16.13.0.tar.gz
source_hash: 9c00e5b6024cfcbc9105f9c58cf160762e78659a345d100c5bd80a7fb38c684f
enforce_toplevel: false
trim_output: true
options: '--strip-components=1'
source:
uri: https://github.com/nodejs/node/archive
source_hash: 37aff6cc2f451d1dbe693d18ad87fad352ed4f74f7b8e232590dd7f2f6b5d525
# https://github.com/nodejs/node/archive/refs/tags/v16.13.0.tar.gz
source_hash: f0327e99f730bf2506a1f13dbd452ec80b33667a7ce1c77a2dacd6babc8643c7
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/v node.version /SHASUMS256.txt

Debian:
pkg:
version: 16.13.0-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-v16.13.0.tar.gz ????
source_hash: 9c00e5b6024cfcbc9105f9c58cf160762e78659a345d100c5bd80a7fb38c684f

OpenBSD:
pkg:
name: node
source:
# node-v13.12.0.tar.gz ????
source_hash: 1b74d624493f17210b96dbd925066034e2d540090a36a99d5c50155cd6726a38
# node-v16.13.0.tar.gz ????
source_hash: 9c00e5b6024cfcbc9105f9c58cf160762e78659a345d100c5bd80a7fb38c684f

Solaris: {}

Windows:
pkg:
source:
# win-x64/node.exe
source_hash: a5c49d8053f399bf8eb3de86426b2274982ddceaeade7fb2f3446b4ebc7cd2e4
source_hash: 7fca04f83b0e2169e41b2e1845e8da0f07d66cf9c3a1b4150767bf3ffddccf62
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-v16.13.0-darwin-x64.tar.gz
source_hash: 37e09a8cf2352f340d1204c6154058d81362fef4ec488b0197b2ce36b3f0367a
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: 16.13.0
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: 16.13.0
use_upstream_repo: false
use_upstream_archive: false
use_upstream_source: false
archive:
uri: https://nodejs.org/dist
source_hash: 3e66b14bbeb9ea1ba129fae7c65374844f4ddaf1e48e2bc19b3b2570e158e362
source_hash: 9c00e5b6024cfcbc9105f9c58cf160762e78659a345d100c5bd80a7fb38c684f
source:
uri: https://github.com/nodejs/node/archive
source_hash: 37aff6cc2f451d1dbe693d18ad87fad352ed4f74f7b8e232590dd7f2f6b5d525
source_hash: f0327e99f730bf2506a1f13dbd452ec80b33667a7ce1c77a2dacd6babc8643c7
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: 16.13.0
pkg:
use_upstream_archive: true # from NodeSource
archive:
uri: https://nodejs.org/dist
source_hash: 3e66b14bbeb9ea1ba129fae7c65374844f4ddaf1e48e2bc19b3b2570e158e362
source_hash: 9c00e5b6024cfcbc9105f9c58cf160762e78659a345d100c5bd80a7fb38c684f

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: 16.13.0
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: 9c00e5b6024cfcbc9105f9c58cf160762e78659a345d100c5bd80a7fb38c684f
source:
uri: https://github.com/nodejs/node/archive
source_hash: 37aff6cc2f451d1dbe693d18ad87fad352ed4f74f7b8e232590dd7f2f6b5d525
source_hash: f0327e99f730bf2506a1f13dbd452ec80b33667a7ce1c77a2dacd6babc8643c7
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: 16.13.0-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: 16.13.0
pkg:
use_upstream_source: true
source:
uri: https://github.com/nodejs/node/archive
source_hash: 37aff6cc2f451d1dbe693d18ad87fad352ed4f74f7b8e232590dd7f2f6b5d525
source_hash: f0327e99f730bf2506a1f13dbd452ec80b33667a7ce1c77a2dacd6babc8643c7

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

0 comments on commit 6ce8259

Please sign in to comment.