From 6ce8259a4ec8ba715cf4fb2923f7bfc3b5a02ebc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javier=20B=C3=A9rtoli?= Date: Fri, 5 Nov 2021 21:19:44 -0300 Subject: [PATCH] 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. --- .yamllint | 1 + node/defaults.yaml | 10 ++++++---- node/map.jinja | 3 ++- node/osfamilymap.yaml | 17 ++++++++++------- node/package/install.sls | 5 ++--- pillar.example | 12 +++++++++--- test/salt/pillar/archive.sls | 4 ++-- test/salt/pillar/default.sls | 6 +++--- test/salt/pillar/repo.sls | 3 +++ test/salt/pillar/source.sls | 4 ++-- 10 files changed, 40 insertions(+), 25 deletions(-) diff --git a/.yamllint b/.yamllint index bbcdef3..602a009 100644 --- a/.yamllint +++ b/.yamllint @@ -18,6 +18,7 @@ ignore: | .git/ node_modules/ test/**/states/**/*.sls + test/salt/pillar/repo.sls .kitchen/ kitchen.vagrant.yml node/osfamilymap.yaml diff --git a/node/defaults.yaml b/node/defaults.yaml index 19e95d4..3b7673d 100644 --- a/node/defaults.yaml +++ b/node/defaults.yaml @@ -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 @@ -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 @@ -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' diff --git a/node/map.jinja b/node/map.jinja index f7f4657..4eb5ffc 100644 --- a/node/map.jinja +++ b/node/map.jinja @@ -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 -%} diff --git a/node/osfamilymap.yaml b/node/osfamilymap.yaml index b9b1b49..e605bb7 100644 --- a/node/osfamilymap.yaml +++ b/node/osfamilymap.yaml @@ -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 @@ -65,15 +68,15 @@ 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: {} @@ -81,7 +84,7 @@ Windows: pkg: source: # win-x64/node.exe - source_hash: a5c49d8053f399bf8eb3de86426b2274982ddceaeade7fb2f3446b4ebc7cd2e4 + source_hash: 7fca04f83b0e2169e41b2e1845e8da0f07d66cf9c3a1b4150767bf3ffddccf62 archive_suffix: exe MacOS: @@ -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 diff --git a/node/package/install.sls b/node/package/install.sls index 22cefdb..2606676 100644 --- a/node/package/install.sls +++ b/node/package/install.sls @@ -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 %} diff --git a/pillar.example b/pillar.example index 79cb109..f2a1f15 100644 --- a/pillar.example +++ b/pillar.example @@ -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 diff --git a/test/salt/pillar/archive.sls b/test/salt/pillar/archive.sls index 125d567..cdeee2e 100644 --- a/test/salt/pillar/archive.sls +++ b/test/salt/pillar/archive.sls @@ -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' diff --git a/test/salt/pillar/default.sls b/test/salt/pillar/default.sls index 79cb109..1e28549 100644 --- a/test/salt/pillar/default.sls +++ b/test/salt/pillar/default.sls @@ -2,7 +2,7 @@ # vim: ft=yaml --- node: - version: 13.12.0 + version: 16.13.0 config: prefix: '/home/vagrant/.npm-packages' environ: @@ -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 diff --git a/test/salt/pillar/repo.sls b/test/salt/pillar/repo.sls index 230e1a0..36547fb 100644 --- a/test/salt/pillar/repo.sls +++ b/test/salt/pillar/repo.sls @@ -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: diff --git a/test/salt/pillar/source.sls b/test/salt/pillar/source.sls index a66cb04..d8ea126 100644 --- a/test/salt/pillar/source.sls +++ b/test/salt/pillar/source.sls @@ -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'