├── test ├── package │ ├── README.md │ ├── package.json │ ├── server.js │ └── test.js ├── README.md ├── test-docker.sh └── test ├── deb ├── README.md ├── setup └── setup_dev ├── LICENSE.md ├── rpm ├── test.sh └── setup └── README.md /test/package/README.md: -------------------------------------------------------------------------------- 1 | This is the package embedded in the test script, changes made here should be copied back into test.sh manually. -------------------------------------------------------------------------------- /deb/README.md: -------------------------------------------------------------------------------- 1 | **setup** is deployed to 2 | 3 | **setup_dev** is deployed to 4 | -------------------------------------------------------------------------------- /test/package/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "test", 3 | "version": "1.0.0", 4 | "main": "server.js", 5 | "dependencies": { 6 | "bl": "~0.9.1", 7 | "buffertools": "~2.1.2", 8 | "hyperquest": "~0.3.0" 9 | }, 10 | "scripts": { 11 | "test": "npm start; node test.js", 12 | "start": "node server.js &" 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | **test** is deployed to 2 | 3 | It can be executed with: 4 | 5 | ```text 6 | $ curl -sL https://deb.nodesource.com/test | bash - 7 | ``` 8 | 9 | The test script will clean up after itself and report a `0` or `1` exit code on success or failure respectively. The output is verbose and should show any problems along the way. -------------------------------------------------------------------------------- /test/package/server.js: -------------------------------------------------------------------------------- 1 | const http = require('http') 2 | , bl = require('bl') 3 | , bt = require('buffertools') 4 | 5 | http.createServer(function (req, res) { 6 | req.pipe(bl(function (err, data) { 7 | res.setHeader('content-type', 'text/plain') 8 | if (err) { 9 | res.statusCode = 500 10 | res.end(err.stack) 11 | } else { 12 | res.statusCode = 200 13 | res.end(bt.reverse(data.slice())) 14 | } 15 | setTimeout(function () { 16 | process.exit(0) 17 | }, 200) 18 | })) 19 | }).listen(3456) 20 | -------------------------------------------------------------------------------- /test/package/test.js: -------------------------------------------------------------------------------- 1 | const hyperquest = require('hyperquest') 2 | , crypto = require('crypto') 3 | , bl = require('bl') 4 | , assert = require('assert') 5 | , rnd = [ crypto.randomBytes(32), crypto.randomBytes(32) ] 6 | 7 | function run () { 8 | var req = hyperquest.post('http://localhost:3456') 9 | 10 | req.pipe(bl(function (err, data) { 11 | assert.ifError(err) 12 | 13 | var rev = data.toString('hex') 14 | , orig = Buffer.concat(rnd) 15 | , i = orig.length - 1 16 | , origRev = new Buffer(orig.length) 17 | 18 | for (; i >= 0; i--) 19 | origRev[orig.length - i - 1] = orig[i] 20 | 21 | assert.equal(rev, origRev.toString('hex')) 22 | 23 | console.log('SUCCESS') 24 | })) 25 | 26 | req.write(rnd[0]) 27 | req.end(rnd[1]) 28 | } 29 | 30 | setTimeout(run, 500) -------------------------------------------------------------------------------- /test/test-docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | TARGETS=" \ 4 | ubuntu:10.04 \ 5 | ubuntu:12.04 \ 6 | ubuntu:14.04 \ 7 | debian:stable \ 8 | debian:testing \ 9 | debian:unstable \ 10 | " 11 | 12 | CMD=" \ 13 | apt-get update && apt-get install curl -y \ 14 | && curl -sL https://deb.nodesource.com/setup | bash - \ 15 | && apt-get install nodejs build-essential python -y \ 16 | && curl -sL https://deb.nodesource.com/test | bash - \ 17 | " 18 | 19 | for target in $TARGETS; do 20 | 21 | outfile="/tmp/node-dist-test-docker-${target}.out" 22 | 23 | echo -e "\033[1m\033[33m## Testing ${target}, writing output to ${outfile} ...\033[39m\033[22m" 24 | 25 | docker run -t --rm $target /bin/bash -c "$CMD" > $outfile 26 | 27 | if [ $? == 0 ]; then 28 | echo -e "\033[1m\033[32m## Test of ${target} SUCCESSFUL\033[39m\033[22m" 29 | else 30 | echo -e "\033[1m\033[31m## Test of ${target} FAILED\033[39m\033[22m" 31 | fi 32 | 33 | echo "" 34 | 35 | done -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | ===================== 3 | 4 | Copyright (c) 2014 NodeSource LLC 5 | --------------------------------- 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 8 | 9 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 12 | -------------------------------------------------------------------------------- /test/test: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | NPM_CACHE=".npm-test-cache" 4 | TEST_DIR="_test-node-install" 5 | OWD=$(pwd) 6 | 7 | print_status() { 8 | echo 9 | echo "## $1" 10 | echo 11 | } 12 | 13 | cleanup() { 14 | print_status "Cleaning up ..." 15 | cd $OWD 16 | exec_cmd "rm -rf ${TEST_DIR}" 17 | } 18 | 19 | bail() { 20 | echo 'Error executing command' 21 | cleanup 22 | exit 1 23 | } 24 | 25 | exec_cmd_nobail() { 26 | echo "+ $1" 27 | bash -c "$1" 28 | } 29 | 30 | exec_cmd() { 31 | exec_cmd_nobail "$1" || bail 32 | } 33 | 34 | print_status "Testing Node.js and npm installation ..." 35 | 36 | exec_cmd "mkdir ${TEST_DIR} && cd ${TEST_DIR}" 37 | 38 | # because the previous cd was in a subshell and only for show 39 | cd $TEST_DIR 40 | 41 | print_status "Creating test package ..." 42 | 43 | cat > server.js << EOF 44 | const http = require('http') 45 | , bl = require('bl') 46 | , bt = require('buffertools') 47 | 48 | http.createServer(function (req, res) { 49 | req.pipe(bl(function (err, data) { 50 | res.setHeader('content-type', 'text/plain') 51 | if (err) { 52 | res.statusCode = 500 53 | res.end(err.stack) 54 | } else { 55 | res.statusCode = 200 56 | res.end(bt.reverse(data.slice())) 57 | } 58 | setTimeout(function () { 59 | process.exit(0) 60 | }, 200) 61 | })) 62 | }).listen(3456) 63 | EOF 64 | 65 | cat > test.js << EOF 66 | const hyperquest = require('hyperquest') 67 | , crypto = require('crypto') 68 | , bl = require('bl') 69 | , assert = require('assert') 70 | , rnd = [ crypto.randomBytes(32), crypto.randomBytes(32) ] 71 | 72 | function run () { 73 | var req = hyperquest.post('http://localhost:3456') 74 | 75 | req.pipe(bl(function (err, data) { 76 | assert.ifError(err) 77 | 78 | var rev = data.toString('hex') 79 | , orig = Buffer.concat(rnd) 80 | , i = orig.length - 1 81 | , origRev = new Buffer(orig.length) 82 | 83 | for (; i >= 0; i--) 84 | origRev[orig.length - i - 1] = orig[i] 85 | 86 | assert.equal(rev, origRev.toString('hex')) 87 | 88 | console.log('SUCCESS') 89 | })) 90 | 91 | req.write(rnd[0]) 92 | req.end(rnd[1]) 93 | } 94 | 95 | setTimeout(run, 500) 96 | EOF 97 | 98 | cat > package.json << EOF 99 | { 100 | "name": "test", 101 | "version": "1.0.0", 102 | "main": "server.js", 103 | "dependencies": { 104 | "bl": "~0.9.1", 105 | "buffertools": "~2.1.2", 106 | "hyperquest": "~0.3.0" 107 | }, 108 | "scripts": { 109 | "test": "npm start; node test.js", 110 | "start": "node server.js &" 111 | } 112 | } 113 | EOF 114 | 115 | print_status "Installing dependencies ..." 116 | 117 | exec_cmd "npm install --spin=false --loglevel=info --cache=${NPM_CACHE}" 118 | 119 | print_status "Running test ..." 120 | 121 | exec_cmd "npm test" 122 | 123 | cleanup -------------------------------------------------------------------------------- /rpm/test.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | clean () { 4 | rm -f _test_check_distro.sh 5 | rm -rf _test_bin/ 6 | } 7 | 8 | mkdir -p _test_bin 9 | 10 | cat > _test_check_distro.sh << EOF 11 | #!/bin/bash 12 | print_status() { 13 | echo \$1 14 | } 15 | $(sed -n '/#-check-distro-#/,/#-check-distro-#/p' setup) 16 | echo type=\$DIST_TYPE version=\$DIST_VERSION arch=\$DIST_ARCH url=\$RELEASE_URL 17 | EOF 18 | 19 | chmod 744 _test_check_distro.sh 20 | 21 | testCheckDistro () { 22 | local release=$1 23 | local uname=$2 24 | local exptype=$3 25 | local expversion=$4 26 | local exparch=$5 27 | local relurl=$6 28 | 29 | echo "echo '${release}'" > _test_bin/rpm 30 | chmod 755 _test_bin/rpm 31 | echo "echo ${uname}" > _test_bin/uname 32 | chmod 755 _test_bin/uname 33 | 34 | _result=$(PATH=_test_bin/:${PATH} ./_test_check_distro.sh | sed '/^\+.*$/d') 35 | local result=$_result 36 | 37 | if [[ $? -ne 0 ]]; then 38 | echo -e "\033[1m\033[31mFAIL\033[39m\033[22m: $release $uname (exec)" 39 | return 40 | fi 41 | 42 | local expected="type=${exptype} version=${expversion} arch=${exparch} url=${relurl}" 43 | 44 | if [ "X${result}" != "X${expected}" ]; then 45 | echo -e "\033[1m\033[31mFAIL\033[39m\033[22m: $release $uname (match)" 46 | echo -e " ${result}" 47 | echo -e "!= ${expected}" 48 | return 49 | else 50 | echo -e "\033[1m\033[32mPASS\033[39m\033[22m: $release $uname" 51 | fi 52 | 53 | } 54 | 55 | 56 | ## release uname exptype expversion exparch relurl 57 | testCheckDistro fedora-release-19-8.noarch i686 fc 19 i386 https://rpm.nodesource.com/pub/fc/19/i386/nodesource-release-fc19-1.noarch.rpm 58 | testCheckDistro fedora-release-19-8.noarch x86_64 fc 19 x86_64 https://rpm.nodesource.com/pub/fc/19/x86_64/nodesource-release-fc19-1.noarch.rpm 59 | testCheckDistro fedora-release-20-3.noarch i686 fc 20 i386 https://rpm.nodesource.com/pub/fc/20/i386/nodesource-release-fc20-1.noarch.rpm 60 | testCheckDistro fedora-release-20-3.noarch x86_64 fc 20 x86_64 https://rpm.nodesource.com/pub/fc/20/x86_64/nodesource-release-fc20-1.noarch.rpm 61 | 62 | testCheckDistro centos-release-5-8.el5.centos i686 el 5 i386 https://rpm.nodesource.com/pub/el/5/i386/nodesource-release-el5-1.noarch.rpm 63 | testCheckDistro centos-release-5-10.el5.centos x86_64 el 5 x86_64 https://rpm.nodesource.com/pub/el/5/x86_64/nodesource-release-el5-1.noarch.rpm 64 | testCheckDistro centos-release-6-5.el6.centos.11.2.i686 i686 el 6 i386 https://rpm.nodesource.com/pub/el/6/i386/nodesource-release-el6-1.noarch.rpm 65 | testCheckDistro centos-release-6-5.el6.centos.11.2.x86_64 x86_64 el 6 x86_64 https://rpm.nodesource.com/pub/el/6/x86_64/nodesource-release-el6-1.noarch.rpm 66 | testCheckDistro centos-release-7-0.1406.el7.centos.2.5.x86_64 x86_64 el 7 x86_64 https://rpm.nodesource.com/pub/el/7/x86_64/nodesource-release-el7-1.noarch.rpm 67 | 68 | testCheckDistro redhat-release-5Server-5.10.0.4 x86_64 el 5 x86_64 https://rpm.nodesource.com/pub/el/5/x86_64/nodesource-release-el5-1.noarch.rpm 69 | testCheckDistro redhat-release-server-6Server-6.5.0.1.el6.x86_64 x86_64 el 6 x86_64 https://rpm.nodesource.com/pub/el/6/x86_64/nodesource-release-el6-1.noarch.rpm 70 | testCheckDistro redhat-release-server-7.0-1.el7.x86_64 x86_64 el 7 x86_64 https://rpm.nodesource.com/pub/el/7/x86_64/nodesource-release-el7-1.noarch.rpm 71 | testCheckDistro redhat-release-workstation-6Workstation-6.5.0.2.el6.x86_64 x86_64 el 6 x86_64 https://rpm.nodesource.com/pub/el/6/x86_64/nodesource-release-el6-1.noarch.rpm 72 | 73 | clean 74 | 75 | exit 0 76 | -------------------------------------------------------------------------------- /deb/setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Discussion, issues and change requests at: 4 | # https://github.com/nodesource/distributions 5 | # 6 | # Script to install NodeSource repo onto a Debian or Ubuntu system. 7 | # 8 | # Run as root or insert `sudo` before `bash`: 9 | # 10 | # curl -sL https://deb.nodesource.com/setup | bash - 11 | # or 12 | # wget -qO- https://deb.nodesource.com/setup | bash - 13 | # 14 | 15 | export DEBIAN_FRONTEND=noninteractive 16 | 17 | print_status() { 18 | echo 19 | echo "## $1" 20 | echo 21 | } 22 | 23 | bail() { 24 | echo 'Error executing command, exiting' 25 | exit 1 26 | } 27 | 28 | exec_cmd_nobail() { 29 | echo "+ $1" 30 | bash -c "$1" 31 | } 32 | 33 | exec_cmd() { 34 | exec_cmd_nobail "$1" || bail 35 | } 36 | 37 | PRE_INSTALL_PKGS="" 38 | 39 | # Check that HTTPS transport is available to APT 40 | # (Check snaked from: https://get.docker.io/ubuntu/) 41 | 42 | if [ ! -e /usr/lib/apt/methods/https ]; then 43 | PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} apt-transport-https" 44 | fi 45 | 46 | if [ ! -x /usr/bin/lsb_release ]; then 47 | PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} lsb-release" 48 | fi 49 | 50 | if [ ! -x /usr/bin/curl ] && [ ! -x /usr/bin/wget ]; then 51 | PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} curl" 52 | fi 53 | 54 | # Populating Cache 55 | print_status "Populating apt-get cache..." 56 | exec_cmd 'apt-get update' 57 | 58 | if [ "X${PRE_INSTALL_PKGS}" != "X" ]; then 59 | print_status "Installing packages required for setup:${PRE_INSTALL_PKGS}..." 60 | # This next command needs to be redirected to /dev/null or the script will bork 61 | # in some environments 62 | exec_cmd "apt-get install -y${PRE_INSTALL_PKGS} 2>&1 > /dev/null" 63 | fi 64 | 65 | DISTRO=$(lsb_release -c -s) 66 | 67 | check_alt() { 68 | if [ "X${DISTRO}" == "X${2}" ]; then 69 | echo 70 | echo "## You seem to be using ${1} version ${DISTRO}." 71 | echo "## This maps to ${3} \"${4}\"... Adjusting for you..." 72 | DISTRO="${4}" 73 | fi 74 | } 75 | 76 | check_alt "Linux Mint" "rebecca" "Ubuntu" "trusty" 77 | check_alt "Linux Mint" "qiana" "Ubuntu" "trusty" 78 | check_alt "Linux Mint" "maya" "Ubuntu" "precise" 79 | check_alt "elementaryOS" "luna" "Ubuntu" "precise" 80 | check_alt "elementaryOS" "freya" "Ubuntu" "trusty" 81 | check_alt "Trisquel" "toutatis" "Ubuntu" "precise" 82 | check_alt "Trisquel" "belenos" "Ubuntu" "trusty" 83 | 84 | if [ "X${DISTRO}" == "Xdebian" ]; then 85 | print_status "Unknown Debian-based distribution, checking /etc/debian_version..." 86 | NEWDISTRO=$([[ -e /etc/debian_version ]] && cat /etc/debian_version | cut -d/ -f1) 87 | if [ "X${DISTRO}" == "X" ]; then 88 | print_status "Could not determine distribution from /etc/debian_version..." 89 | else 90 | DISTRO=$NEWDISTRO 91 | print_status "Found \"${DISTRO}\" in /etc/debian_version..." 92 | fi 93 | fi 94 | 95 | print_status "Confirming \"${DISTRO}\" is supported..." 96 | 97 | if [ -x /usr/bin/curl ]; then 98 | exec_cmd_nobail "curl -sLf -o /dev/null 'https://deb.nodesource.com/node/dists/${DISTRO}/Release'" 99 | RC=$? 100 | else 101 | exec_cmd_nobail "wget -qO /dev/null -o /dev/null 'https://deb.nodesource.com/node/dists/${DISTRO}/Release'" 102 | RC=$? 103 | fi 104 | 105 | if [[ $RC != 0 ]]; then 106 | print_status "Your distribution, identified as \"${DISTRO}\", is not currently supported, please contact NodeSource at https://github.com/nodesource/distributions/issues if you think this is incorrect or would like your distribution to be considered for support" 107 | exit 1 108 | fi 109 | 110 | if [ -f "/etc/apt/sources.list.d/chris-lea-node_js-$DISTRO.list" ]; then 111 | print_status 'Removing Launchpad PPA Repository for NodeJS...' 112 | 113 | exec_cmd 'add-apt-repository -y -r ppa:chris-lea/node.js' 114 | exec_cmd "rm -f /etc/apt/sources.list.d/chris-lea-node_js-${DISTRO}.list" 115 | fi 116 | 117 | print_status 'Adding the NodeSource signing key to your keyring...' 118 | 119 | if [ -x /usr/bin/curl ]; then 120 | exec_cmd 'curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -' 121 | else 122 | exec_cmd 'wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -' 123 | fi 124 | 125 | print_status 'Creating apt sources list file for the NodeSource repo...' 126 | 127 | exec_cmd "echo 'deb https://deb.nodesource.com/node ${DISTRO} main' > /etc/apt/sources.list.d/nodesource.list" 128 | exec_cmd "echo 'deb-src https://deb.nodesource.com/node ${DISTRO} main' >> /etc/apt/sources.list.d/nodesource.list" 129 | 130 | print_status 'Running `apt-get update` for you...' 131 | 132 | exec_cmd 'apt-get update' 133 | 134 | print_status 'Run `apt-get install nodejs` (as root) to install Node.js and npm' 135 | -------------------------------------------------------------------------------- /deb/setup_dev: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Discussion, issues and change requests at: 4 | # https://github.com/nodesource/distributions 5 | # 6 | # Script to install NodeSource repo onto a Debian or Ubuntu system. 7 | # 8 | # Run as root or insert `sudo` before `bash`: 9 | # 10 | # curl -sL https://deb.nodesource.com/setup_dev | bash - 11 | # or 12 | # wget -qO- https://deb.nodesource.com/setup_dev | bash - 13 | # 14 | 15 | export DEBIAN_FRONTEND=noninteractive 16 | 17 | print_status() { 18 | echo 19 | echo "## $1" 20 | echo 21 | } 22 | 23 | bail() { 24 | echo 'Error executing command, exiting' 25 | exit 1 26 | } 27 | 28 | exec_cmd_nobail() { 29 | echo "+ $1" 30 | bash -c "$1" 31 | } 32 | 33 | exec_cmd() { 34 | exec_cmd_nobail "$1" || bail 35 | } 36 | 37 | PRE_INSTALL_PKGS="" 38 | 39 | # Check that HTTPS transport is available to APT 40 | # (Check snaked from: https://get.docker.io/ubuntu/) 41 | 42 | if [ ! -e /usr/lib/apt/methods/https ]; then 43 | PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} apt-transport-https" 44 | fi 45 | 46 | if [ ! -x /usr/bin/lsb_release ]; then 47 | PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} lsb-release" 48 | fi 49 | 50 | if [ ! -x /usr/bin/curl ] && [ ! -x /usr/bin/wget ]; then 51 | PRE_INSTALL_PKGS="${PRE_INSTALL_PKGS} curl" 52 | fi 53 | 54 | # Populating Cache 55 | print_status "Populating apt-get cache..." 56 | exec_cmd 'apt-get update' 57 | 58 | if [ "X${PRE_INSTALL_PKGS}" != "X" ]; then 59 | print_status "Installing packages required for setup:${PRE_INSTALL_PKGS}..." 60 | # This next command needs to be redirected to /dev/null or the script will bork 61 | # in some environments 62 | exec_cmd "apt-get install -y${PRE_INSTALL_PKGS} 2>&1 > /dev/null" 63 | fi 64 | 65 | DISTRO=$(lsb_release -c -s) 66 | 67 | check_alt() { 68 | if [ "X${DISTRO}" == "X${2}" ]; then 69 | echo 70 | echo "## You seem to be using ${1} version ${DISTRO}." 71 | echo "## This maps to ${3} \"${4}\"... Adjusting for you..." 72 | DISTRO="${4}" 73 | fi 74 | } 75 | 76 | check_alt "Linux Mint" "rebecca" "Ubuntu" "trusty" 77 | check_alt "Linux Mint" "qiana" "Ubuntu" "trusty" 78 | check_alt "Linux Mint" "maya" "Ubuntu" "precise" 79 | check_alt "elementaryOS" "luna" "Ubuntu" "precise" 80 | check_alt "elementaryOS" "freya" "Ubuntu" "trusty" 81 | check_alt "Trisquel" "toutatis" "Ubuntu" "precise" 82 | check_alt "Trisquel" "belenos" "Ubuntu" "trusty" 83 | 84 | if [ "X${DISTRO}" == "Xdebian" ]; then 85 | print_status "Unknown Debian-based distribution, checking /etc/debian_version..." 86 | NEWDISTRO=$([[ -e /etc/debian_version ]] && cat /etc/debian_version | cut -d/ -f1) 87 | if [ "X${DISTRO}" == "X" ]; then 88 | print_status "Could not determine distribution from /etc/debian_version..." 89 | else 90 | DISTRO=$NEWDISTRO 91 | print_status "Found \"${DISTRO}\" in /etc/debian_version..." 92 | fi 93 | fi 94 | 95 | print_status "Confirming \"${DISTRO}\" is supported..." 96 | 97 | if [ -x /usr/bin/curl ]; then 98 | exec_cmd_nobail "curl -sLf -o /dev/null 'https://deb.nodesource.com/node-devel/dists/${DISTRO}/Release'" 99 | RC=$? 100 | else 101 | exec_cmd_nobail "wget -qO /dev/null -o /dev/null 'https://deb.nodesource.com/node-devel/dists/${DISTRO}/Release'" 102 | RC=$? 103 | fi 104 | 105 | if [[ $RC != 0 ]]; then 106 | print_status "Your distribution, identified as \"${DISTRO}\", is not currently supported, please contact NodeSource at https://github.com/nodesource/distributions/issues if you think this is incorrect or would like your distribution to be considered for support" 107 | exit 1 108 | fi 109 | 110 | if [ -f "/etc/apt/sources.list.d/chris-lea-node_js-$DISTRO.list" ]; then 111 | print_status 'Removing Launchpad PPA Repository for NodeJS...' 112 | 113 | exec_cmd 'add-apt-repository -y -r ppa:chris-lea/node.js' 114 | exec_cmd "rm -f /etc/apt/sources.list.d/chris-lea-node_js-${DISTRO}.list" 115 | fi 116 | 117 | print_status 'Adding the NodeSource signing key to your keyring...' 118 | 119 | if [ -x /usr/bin/curl ]; then 120 | exec_cmd 'curl -s https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -' 121 | else 122 | exec_cmd 'wget -qO- https://deb.nodesource.com/gpgkey/nodesource.gpg.key | apt-key add -' 123 | fi 124 | 125 | print_status 'Creating apt sources list file for the NodeSource repo...' 126 | 127 | exec_cmd "echo 'deb https://deb.nodesource.com/node-devel ${DISTRO} main' > /etc/apt/sources.list.d/nodesource-devel.list" 128 | exec_cmd "echo 'deb-src https://deb.nodesource.com/node-devel ${DISTRO} main' >> /etc/apt/sources.list.d/nodesource-devel.list" 129 | 130 | print_status 'Running `apt-get update` for you...' 131 | 132 | exec_cmd 'apt-get update' 133 | 134 | print_status 'Run `apt-get install nodejs` (as root) to install Node.js and npm' 135 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # [NodeSource](https://nodesource.com/) Node.js Binary Distributions 2 | 3 | ![Linux Distributions](https://nodesource.com/assets/external/linux-distributions.svg) 4 | 5 | This repository contains the source of the **[NodeSource](https://nodesource.com)** **[Node.js](http://nodejs.org)** Binary Distributions setup and support scripts. 6 | 7 | For **Debian / Ubuntu** based distributions, see the **[deb](./deb)** directory for the source of the two setup scripts located at and . 8 | 9 | For **Enterprise Linux** based distributions (Red Hat® Enterprise Linux® / RHEL, CentOS, Fedora), see the **[rpm](./rpm)** directory for the source of setup script located at . 10 | 11 | Please file an issue if you are experiencing a problem or would like to discuss something related to the distributions. 12 | 13 | Pull requests are encouraged if you have changes you believe would improve the setup process or increase compatibility across Linux distributions. 14 | 15 | * **[Debian and Ubuntu based distributions](#deb)** (deb) 16 | * **[Enterprise Linux based distributions](#rpm)** (rpm) 17 | * **[Tests](#tests)** 18 | 19 | 20 | ## Debian and Ubuntu based distributions 21 | 22 | **Available architectures:** 23 | 24 | NodeSource will continue to maintain the following architectures and may add additional ones in the future. 25 | 26 | * **i386** (32-bit) 27 | * **amd64** (64-bit) 28 | * **armhf** (ARM 32-bit hard-float, ARMv7 and up: _arm-linux-gnueabihf_) 29 | 30 | **Supported Ubuntu versions:** 31 | 32 | NodeSource will maintain Ubuntu distributions in active support by Canonical, including LTS and the intermediate releases. 33 | 34 | * **Ubuntu 10.04 LTS** (Lucid Lynx, *armhf build not available*) 35 | * **Ubuntu 12.04 LTS** (Precise Pangolin) 36 | * **Ubuntu 14.04 LTS** (Trusty Tahr) 37 | * **Ubuntu 14.10** (Utopic Unicorn) 38 | 39 | **Supported Debian versions:** 40 | 41 | NodeSource will maintain support for stable, testing and unstable releases of Debian, due to the long release cycle a considerable number of users are running unstable. 42 | 43 | * **Debian 7 / stable** (wheezy) 44 | * **Debian testing** (jessie) 45 | * **Debian unstable** (sid) 46 | 47 | **Supported Linux Mint versions:** 48 | 49 | * **Linux Mint 13 "Maya"** (via Ubuntu 12.04 LTS) 50 | * **Linux Mint 17 "Qiana"** (via Ubuntu 14.04 LTS) 51 | * **Linux Mint Debian Edition (LMDE) stable** (via Debian stable) 52 | * **Linux Mint Debian Edition (LMDE) testing** (via Debian testing) 53 | * **Linux Mint Debian Edition (LMDE) unstable** (via Debian unstable) 54 | 55 | **Supported elementary OS versions:** 56 | 57 | * **elementary OS Luna** (via Ubuntu 12.04 LTS) 58 | * **elementary OS Freya** (via Ubuntu 14.04 LTS) 59 | 60 | **Supported Trisquel versions:** 61 | 62 | * **Trisquel 6 "Toutatis"** (via Ubuntu 12.04 LTS) 63 | * **Trisquel 7 "Belenos"** (via Ubuntu 14.04 LTS) 64 | 65 | 66 | ### Usage instructions 67 | 68 | Current instructions for installing, as listed on the [Node.js Wiki](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager): 69 | 70 | Setup with **Ubuntu**: 71 | 72 | ```text 73 | curl -sL https://deb.nodesource.com/setup | sudo bash - 74 | ``` 75 | 76 | Then install with **Ubuntu**: 77 | 78 | ```text 79 | sudo apt-get install -y nodejs 80 | ``` 81 | 82 | Setup with **Debian** (as root): 83 | 84 | ```text 85 | curl -sL https://deb.nodesource.com/setup | bash - 86 | ``` 87 | 88 | Then install with **Debian** (as root): 89 | 90 | ```text 91 | apt-get install -y nodejs nodejs-legacy 92 | ``` 93 | 94 | ***Optional***: install build tools 95 | 96 | To compile and install native addons from npm you may also need to install build tools: 97 | 98 | ```text 99 | apt-get install -y build-essential 100 | ``` 101 | 102 | 103 | ## Enterprise Linux based distributions 104 | 105 | **Available architectures:** 106 | 107 | NodeSource will continue to maintain the following architectures and may add additional ones in the future. 108 | 109 | * **i386** (32-bit, not available for EL7) 110 | * **x86_64** (64-bit) 111 | 112 | **Supported Red Hat® Enterprise Linux® versions:** 113 | 114 | * **RHEL 5** (32-bit and 64-bit) 115 | * **RHEL 6** (32-bit and 64-bit) 116 | * **RHEL 7** (64-bit) 117 | 118 | **Supported CentOS versions:** 119 | 120 | * **CentOS 5** (32-bit and 64-bit) 121 | * **CentOS 6** (32-bit and 64-bit) 122 | * **CentOS 7** (64-bit) 123 | 124 | **Supported Fedora versions:** 125 | 126 | * **Fedora 20 (Heisenbug)** (32-bit and 64-bit) 127 | * **Fedora 19 (Schrödinger's Cat)** (32-bit and 64-bit) 128 | 129 | 130 | ### Usage instructions 131 | 132 | Current instructions for installing, as listed on the [Node.js Wiki](https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager): 133 | 134 | Note that the Node.js packages for EL 5 (RHEL5 and CentOS 5) depend on the [EPEL](https://fedoraproject.org/wiki/EPEL) repository being available. The setup script will check and provide instructions if it is not installed. 135 | 136 | Run as root on RHEL, CentOS or Fedora: 137 | 138 | ```text 139 | curl -sL https://rpm.nodesource.com/setup | bash - 140 | ``` 141 | 142 | Then install, as root: 143 | 144 | ```text 145 | yum install -y nodejs 146 | ``` 147 | 148 | ***Optional***: install build tools 149 | 150 | To compile and install native addons from npm you may also need to install build tools: 151 | 152 | ```text 153 | yum install gcc-c++ make 154 | # or: yum groupinstall 'Development Tools' 155 | ``` 156 | 157 | 158 | ## Tests 159 | 160 | To test an installation is working (and that the setup scripts are working!) use: 161 | 162 | ```text 163 | curl -sL https://deb.nodesource.com/test | bash - 164 | ``` 165 | 166 | ## License 167 | 168 | This material is Copyright (c) 2014 NodeSource LLC and licenced under the MIT licence. All rights not explicitly granted in the MIT license are reserved. See the included LICENSE.md file for more details. 169 | 170 | ------------------------------------------------------------------ 171 | 172 | *Supported with love by by [Chris Lea](https://github.com/chrislea), [Rod Vagg](https://github.com/rvagg) and the [NodeSource](https://nodesource.com) team* 173 | 174 | *This project is not affiliated with Debian, Ubuntu, Red Hat, CentOS or Fedora.*
175 | *Ubuntu is a registered trademark of Canonical Ltd.*
176 | *Debian is a registered trademark owned by Software in the Public Interest, Inc.*
177 | *Red Hat, CentOS and Fedora are trademarks of Red Hat, Inc.* 178 | -------------------------------------------------------------------------------- /rpm/setup: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Discussion, issues and change requests at: 4 | # https://github.com/nodesource/distributions 5 | # 6 | # Script to install NodeSource repo onto a Enterprise Linux or 7 | # Fedora Core based system. 8 | # 9 | # Run as root or insert `sudo` before `bash`: 10 | # 11 | # curl -sL https://rpm.nodesource.com/setup | bash - 12 | # or 13 | # wget -qO- https://rpm.nodesource.com/setup | bash - 14 | # 15 | 16 | print_status() { 17 | local outp=$(echo "$1" | sed -r 's/\\n/\\n## /mg') 18 | echo 19 | echo -e "## ${outp}" 20 | echo 21 | } 22 | 23 | bail() { 24 | echo 'Error executing command, exiting' 25 | exit 1 26 | } 27 | 28 | exec_cmd_nobail() { 29 | echo "+ $1" 30 | bash -c "$1" 31 | } 32 | 33 | exec_cmd() { 34 | exec_cmd_nobail "$1" || bail 35 | } 36 | 37 | 38 | print_status "Inspecting system..." 39 | 40 | if [ ! -x /bin/rpm ]; then 41 | print_status "\ 42 | You don't appear to be running an Enterprise Linux based \ 43 | system, please contact NodeSource at \ 44 | https://github.com/nodesource/distributions/issues if you think this \ 45 | is incorrect or would like your distribution to be considered for \ 46 | support.\ 47 | " 48 | exit 1 49 | fi 50 | 51 | ## Annotated section for auto extraction in test.sh 52 | #-check-distro-# 53 | 54 | ## Check distro and arch 55 | echo "+ rpm -q --whatprovides redhat-release" 56 | DISTRO_PKG=$(rpm -q --whatprovides redhat-release) 57 | echo "+ uname -m" 58 | UNAME_ARCH=$(uname -m) 59 | 60 | if [ "X${UNAME_ARCH}" == "Xi686" ]; then 61 | DIST_ARCH=i386 62 | elif [ "X${UNAME_ARCH}" == "Xx86_64" ]; then 63 | DIST_ARCH=x86_64 64 | else 65 | 66 | print_status "\ 67 | You don't appear to be running a supported machine architecture: ${UNAME_ARCH}. \ 68 | Please contact NodeSource at \ 69 | https://github.com/nodesource/distributions/issues if you think this is \ 70 | incorrect or would like your architecture to be considered for support. \ 71 | " 72 | exit 1 73 | 74 | fi 75 | 76 | if [[ $DISTRO_PKG =~ ^redhat- ]] || [[ $DISTRO_PKG =~ ^centos- ]]; then 77 | DIST_TYPE=el 78 | elif [[ $DISTRO_PKG =~ ^system-release- ]]; then # Amazon Linux 79 | DIST_TYPE=el 80 | elif [[ $DISTRO_PKG =~ ^fedora- ]]; then 81 | DIST_TYPE=fc 82 | else 83 | 84 | print_status "\ 85 | You don't appear to be running a supported version of Enterprise Linux. \ 86 | Please contact NodeSource at \ 87 | https://github.com/nodesource/distributions/issues if you think this is \ 88 | incorrect or would like your architecture to be considered for support. \ 89 | Include your 'distribution package' name: ${DISTRO_PKG}. \ 90 | " 91 | exit 1 92 | 93 | fi 94 | 95 | if [[ $DISTRO_PKG =~ ^system-release-201[4-9]\. ]]; then #NOTE: not really future-proof 96 | 97 | # Amazon Linux, for 2014.* use el7, older versions are unknown, perhaps el6 98 | DIST_VERSION=7 99 | 100 | else 101 | 102 | ## Using the redhat-release-server-X, centos-release-X, etc. pattern 103 | ## extract the major version number of the distro 104 | DIST_VERSION=$(echo $DISTRO_PKG | sed -r 's/^[a-z]+-release(-server|-workstation)?-([0-9]+).*$/\2/') 105 | 106 | if ! [[ $DIST_VERSION =~ ^[0-9][0-9]?$ ]]; then 107 | 108 | print_status "\ 109 | Could not determine your distribution version, you may not be running a \ 110 | supported version of Enterprise Linux. \ 111 | Please contact NodeSource at \ 112 | https://github.com/nodesource/distributions/issues if you think this is \ 113 | incorrect. Include your 'distribution package' name: ${DISTRO_PKG}. \ 114 | " 115 | exit 1 116 | 117 | fi 118 | 119 | fi 120 | 121 | 122 | ## Given the distro, version and arch, construct the url for 123 | ## the appropriate nodesource-release package (it's noarch but 124 | ## we include the arch in the directory tree anyway) 125 | RELEASE_URL_VERSION_STRING="${DIST_TYPE}${DIST_VERSION}" 126 | RELEASE_URL="\ 127 | https://rpm.nodesource.com/pub/\ 128 | ${DIST_TYPE}/\ 129 | ${DIST_VERSION}/\ 130 | ${DIST_ARCH}/\ 131 | nodesource-release-${RELEASE_URL_VERSION_STRING}-1.noarch.rpm" 132 | 133 | #-check-distro-# 134 | 135 | print_status "Confirming \"${DIST_TYPE}${DIST_VERSION}-${DIST_ARCH}\" is supported..." 136 | 137 | ## Simple fetch & fast-fail to see if the nodesource-release 138 | ## file exists for this distro/version/arch 139 | exec_cmd_nobail "curl -sLf -o /dev/null '${RELEASE_URL}'" 140 | RC=$? 141 | 142 | if [[ $RC != 0 ]]; then 143 | print_status "\ 144 | Your distribution, identified as \"${DISTRO_PKG}\", \ 145 | is not currently supported, please contact NodeSource at \ 146 | https://github.com/nodesource/distributions/issues \ 147 | if you think this is incorrect or would like your distribution to be considered for support" 148 | exit 1 149 | fi 150 | 151 | ## EPEL is needed for EL5, we don't install it if it's missing but 152 | ## we can give guidance 153 | if [ "$DIST_TYPE" == "el" ] && [ "$DIST_VERSION" == "5" ]; then 154 | 155 | print_status "Checking if EPEL is enabled..." 156 | 157 | echo "+ yum repolist enabled 2> /dev/null | grep epel" 158 | repolist=$(yum repolist enabled 2> /dev/null | grep epel) 159 | 160 | if [ "X${repolist}" == "X" ]; then 161 | print_status "Finding current EPEL release RPM..." 162 | 163 | ## We can scrape the html to find the latest epel-release (likely 5.4) 164 | epel_url="http://dl.fedoraproject.org/pub/epel/5/${DIST_ARCH}/" 165 | epel_release_view="${epel_url}repoview/epel-release.html" 166 | echo "+ curl -s $epel_release_view | grep -oE 'epel-release-[0-9\-]+\.noarch\.rpm'" 167 | epel=$(curl -s $epel_release_view | grep -oE 'epel-release-[0-9\-]+\.noarch\.rpm') 168 | if [ "X${epel}" = "X" ]; then 169 | print_status "Error: Could not find current EPEL release RPM!" 170 | exit 1 171 | fi 172 | 173 | print_status "\ 174 | The EPEL (Extra Packages for Enterprise Linux) repository is a\n\ 175 | prerequisite for installing Node.js on your operating system. Please\n\ 176 | add it and re-run this setup script.\n\ 177 | \n\ 178 | The EPEL repository RPM is available at:\n\ 179 | ${epel_url}${epel}\n\ 180 | You can try installing with: \`rpm -ivh \`\ 181 | " 182 | 183 | exit 1 184 | fi 185 | 186 | fi 187 | 188 | print_status "Downloading release setup RPM..." 189 | 190 | ## Two-step process to install the nodesource-release RPM, 191 | ## Download to a tmp file then install it directly with `rpm`. 192 | ## We don't rely on RPM's ability to fetch from HTTPS directly 193 | echo "+ mktemp" 194 | RPM_TMP=$(mktemp || bail) 195 | 196 | exec_cmd "curl -sL -o '${RPM_TMP}' '${RELEASE_URL}'" 197 | 198 | print_status "Installing release setup RPM..." 199 | 200 | ## --nosignature because nodesource-release contains the signature! 201 | exec_cmd "rpm -i --nosignature --force '${RPM_TMP}'" 202 | 203 | print_status "Cleaning up..." 204 | 205 | exec_cmd "rm -f '${RPM_TMP}'" 206 | 207 | print_status "Checking for existing installations..." 208 | 209 | ## Nasty consequences if you have an existing Node or npm package 210 | ## installed, need to inform if they are there 211 | echo "+ rpm -qa 'node|npm' | grep -v nodesource" 212 | EXISTING_NODE=$(rpm -qa 'node|npm' | grep -v nodesource) 213 | 214 | if [ "X${EXISTING_NODE}" != "X" ]; then 215 | 216 | print_status "\ 217 | Your system appears to already have Node.js installed from an alternative source.\n\ 218 | Run \`\033[1myum remove -y nodejs npm\033[22m\` (as root) to remove these first.\ 219 | " 220 | 221 | fi 222 | 223 | print_status "\ 224 | Run \`\033[1myum install -y nodejs\033[22m\` (as root) to install Node.js and npm.\n\ 225 | You may also need development tools to build native addons:\n\ 226 | \`yum install -y gcc-c++ make\`\ 227 | " 228 | 229 | ## Alternative to install dev tools: `yum groupinstall 'Development Tools' 230 | 231 | exit 0 232 | --------------------------------------------------------------------------------