Skip to content

Commit c80a4c6

Browse files
committed
Add install_from_binary to install node.js from the binary distribution
1 parent fe7681b commit c80a4c6

File tree

4 files changed

+57
-8
lines changed

4 files changed

+57
-8
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,24 @@ This formula installs [node.js](https://nodejs.org/en/).
77
An example pillar file looks as follows:
88

99
node:
10-
version: 5.1.0
11-
checksum: 25b2d3b7dd57fe47a483539fea240a3c6bbbdab4d89a45a812134cf1380ecb94
10+
version: 5.4.0
11+
checksum: 1dfe37a00cf0ed62beb73071f571ac56697f544a98cc2ff3318faec6363d72ab
1212
make_jobs: 2
13+
install_from_source: True
1314

1415
Available versions can be found on [nodejs.org/dist/](https://nodejs.org/dist/); the checksums are listed in the
15-
file `SHASUMS256.txt` in the respective version’s directory.
16+
file `SHASUMS256.txt` in the respective version’s directory. The *node-v….tar.gz* checksum is used.
17+
18+
## Installing binary packages
19+
20+
On Linux, the binary node.js distribution can be installed to `/usr/local/share/` with the following pillar file:
21+
22+
node:
23+
version: 5.4.0
24+
checksum: f037e2734f52b9de63e6d4a4e80756477b843e6f106e0be05591a16b71ec2bd0
25+
install_from_binary: True
26+
27+
The checksum for the *node-v…-linux-x64.tar.gz* file has to be provided.
1628

1729
### Older versions
1830

node/binary.sls

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{% set node = pillar.get('node', {}) -%}
2+
{% set version = node.get('version', '5.4.0') -%}
3+
{% set checksum = node.get('checksum', 'f037e2734f52b9de63e6d4a4e80756477b843e6f106e0be05591a16b71ec2bd0') -%}
4+
{% set pkgname = 'node-v' ~ version ~ '-linux-x64' -%}
5+
6+
Get binary package:
7+
file.managed:
8+
- name: /usr/local/src/{{ pkgname }}.tar.gz
9+
- source: https://nodejs.org/dist/v{{ version }}/{{ pkgname }}.tar.gz
10+
- source_hash: sha256={{ checksum }}
11+
12+
Extract binary package:
13+
archive.extracted:
14+
- name: /usr/local/src/
15+
- source: /usr/local/src/{{ pkgname }}.tar.gz
16+
- archive_format: tar
17+
- if_missing: /usr/local/src/{{ pkgname }}
18+
19+
Copy lib:
20+
cmd.run:
21+
- cwd: /usr/local/src/{{ pkgname }}/
22+
- name: cp -r bin/ include/ lib/ share/ /usr/local/
23+
- unless: cmp /usr/local/bin/node /usr/local/src/{{ pkgname }}/bin/node

node/init.sls

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
include:
33
{%- if pillar_get('node:install_from_source') %}
44
- .source
5+
{%- elif pillar_get('node:install_from_binary') %}
6+
- .binary
57
{%- else %}
68
- .pkg
79
{%- endif %}

pillar.example

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
1+
# Install from source:
12
node:
2-
version: 5.1.0
3-
checksum: 25b2d3b7dd57fe47a483539fea240a3c6bbbdab4d89a45a812134cf1380ecb94
3+
version: 5.4.0
4+
install_from_source: True
5+
checksum: 1dfe37a00cf0ed62beb73071f571ac56697f544a98cc2ff3318faec6363d72ab
46
make_jobs: 2
5-
# install_from_ppa: True
6-
# ppa:
7-
# repository_url: https://deb.nodesource.com/node_4.x
7+
8+
# Install from binary:
9+
node:
10+
version: 5.4.0
11+
install_from_binary: True
12+
checksum: f037e2734f52b9de63e6d4a4e80756477b843e6f106e0be05591a16b71ec2bd0
13+
14+
# Install from PPA:
15+
node:
16+
version: 5.4.0
17+
install_from_ppa: True
18+
ppa:
19+
repository_url: https://deb.nodesource.com/node_5.x

0 commit comments

Comments
 (0)