From 341036a31e02d1f3edae152ac919d8b953980e6f Mon Sep 17 00:00:00 2001 From: Michael Klement Date: Fri, 26 Jun 2015 00:12:00 -0400 Subject: [PATCH 1/3] * [robustness] If `make` is found not to be _GNU_ `make`, an attempt is made to use `gmake` instead. --- CHANGELOG.md | 3 +++ bin/n-install | 20 +++++++++++++++++--- bin/n-uninstall | 2 +- bin/n-update | 2 +- package.json | 2 +- 5 files changed, 23 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ebdd191..3358c96 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,9 @@ Versioning complies with [semantic versioning (semver)](http://semver.org/). +* **[v0.1.3-0](https://github.com/mklement0/n-install/compare/v0.1.2...v0.1.3-0)** (2015-06-26): + * [robustness] If `make` is found not to be _GNU_ `make`, an attempt is made to use `gmake` instead. + * **[v0.1.2](https://github.com/mklement0/n-install/compare/v0.1.1...v0.1.2)** (2015-06-21): * [doc] Examples revised. diff --git a/bin/n-install b/bin/n-install index 627a8bf..f7cd703 100755 --- a/bin/n-install +++ b/bin/n-install @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# !! CAVEAT (hypothetical, for now, because n as of 1.3.0 doesn't support FreeBSD, given that binary Node.js packages aren't available for it): +# !! On FreeBSD, process substitution (<(...)) is by default NOT ENABLED- AVOID PROCESS SUBSTITUTIONS. + # # Script-global constants # @@ -381,7 +384,7 @@ unset CDPATH # to prevent unpredictable `cd` behavior [[ -t 1 ]] || kNO_COLOR=1 # turn off colored output if stdout is not connected to a terminal # Output version number and exit, if requested. Note that the `ver='...'` statement is automatically updated by `make version VER=` - DO keep the 'v' suffix in the variable _definition_. -[[ $1 == '--version' ]] && { ver='v0.1.2'; echo "$kTHIS_NAME ${ver#v}"; exit 0; } +[[ $1 == '--version' ]] && { ver='v0.1.3-0'; echo "$kTHIS_NAME ${ver#v}"; exit 0; } # !! AS OF n 1.3.0, n ITSELF ONLY WORKS WITH curl, NOT ALSO WITH wget. # !! Once n also supports wget, mention wget as an alternative in the help text. @@ -461,11 +464,22 @@ preReqMsg= # !! AS OF n 1.3.0, n ITSELF ONLY WORKS WITH curl, NOT ALSO WITH wget. # !! Once n also supports wget, remove 'curl' from this `for` loop and activate # !! the curl-OR-wget command below. -for exe in curl git make; do +for exe in curl git; do [[ -n $(command -v "$exe") ]] || preReqMsg+="${preReqMsg:+$'\n'}\`$exe\` not found, which is required for operation." done +# # !! ACTIVATE THE FOLLOWING ONCE n ITSELF SUPPORTS wget. # [[ -n $(command -v curl) || -n $(command -v wget) ]] || preReqMsg+="${preReqMsg:+$'\n'}Neither \`curl\` nor \`wget\` found; one of them is required for operation." +# +# !! n's own installation procedure, `make install`, unfortunately currently (1.3.0) requires GNU make (due to use of conditional assignment `?=`), even though it would be simple to make it +# !! POSIX-compliant; for now, we therefore explicitly require GNU make. +# !! However, this is a hypothetical concern, because, as of n 1.3.0, n only works with *prebuilt* binaries downloadable from https://nodejs.org/dist/, and, as of Node.js v0.12.4, +# !! prebuilt binaries only exist for Linux, Darwin (OSX) (and Windows) - if building Node.js from source were supported, however, GNU make would be required for that, too. +for makeExe in make gmake; do + "$makeExe" --version 2>/dev/null | grep -Fq "GNU Make" && break + [[ $makeExe == 'make' ]] && continue + preReqMsg+="${preReqMsg:+$'\n'}GNU Make not found, which is required for operation."$'\n'"On FreeBSD and PC-BSD, for instance, you can download it with \`sudo pkg install gmake\`." +done [[ -z $preReqMsg ]] || die - <<<"$preReqMsg" # Parse options. @@ -641,7 +655,7 @@ echo "-- Cloning $kN_REPO_URL to '$nRepoDir'..." git clone -q "$kN_REPO_URL" "$nRepoDir/" >/dev/null || die "Aborting, because cloning n's GitHub repository into '$nRepoDir' failed." echo "-- Running local n installation to '$nBinDir'..." -(cd "$nRepoDir" && PREFIX="$N_PREFIX" make install >/dev/null) || die "Aborting, because n's own installation procedure failed." +(cd "$nRepoDir" && PREFIX="$N_PREFIX" "$makeExe" install >/dev/null) || die "Aborting, because n's own installation procedure failed." # Modify the relevant shell initialization file. initFile=$(modifyShellInitFile) || die diff --git a/bin/n-uninstall b/bin/n-uninstall index b729727..22ae38d 100755 --- a/bin/n-uninstall +++ b/bin/n-uninstall @@ -208,7 +208,7 @@ unset CDPATH # to prevent unpredictable `cd` behavior [[ -t 1 ]] || kNO_COLOR=1 # turn off colored output if stdout is not connected to a terminal # Output version number and exit, if requested. Note that the `ver='...'` statement is automatically updated by `make version VER=` - DO keep the 'v' suffix in the variable _definition_. -[ "$1" = '--version' ] && { ver='v0.1.2'; echo "$kTHIS_NAME ${ver#v}"; exit 0; } +[ "$1" = '--version' ] && { ver='v0.1.3-0'; echo "$kTHIS_NAME ${ver#v}"; exit 0; } # Command-line help. if [ "$1" = '--help' ] || [ "$1" = '-h' ]; then diff --git a/bin/n-update b/bin/n-update index cbe6c32..329386a 100755 --- a/bin/n-update +++ b/bin/n-update @@ -124,7 +124,7 @@ unset CDPATH # to prevent unpredictable `cd` behavior [[ -t 1 ]] || kNO_COLOR=1 # turn off colored output if stdout is not connected to a terminal # Output version number and exit, if requested. Note that the `ver='...'` statement is automatically updated by `make version VER=` - DO keep the 'v' suffix in the variable _definition_. -[ "$1" = '--version' ] && { ver='v0.1.2'; echo "$kTHIS_NAME ${ver#v}"; exit 0; } +[ "$1" = '--version' ] && { ver='v0.1.3-0'; echo "$kTHIS_NAME ${ver#v}"; exit 0; } # Command-line help. if [ "$1" = '--help' ] || [ "$1" = '-h' ]; then diff --git a/package.json b/package.json index 76a4546..6a3f98e 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "n-install", "description": "installs n, the Node.js version manager, without needing to install Node.js first", "private": true, - "version": "0.1.2", + "version": "0.1.3-0", "os": [ "darwin", "linux" From 41dfeaeeddff89ce515417aa8813bf8d3a982d79 Mon Sep 17 00:00:00 2001 From: Michael Klement Date: Sat, 4 Jul 2015 19:31:28 -0400 Subject: [PATCH 2/3] * n-update now also looks for 'gmake' as an alternative, if make isn't GNU make. --- bin/n-install | 2 +- bin/n-update | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/bin/n-install b/bin/n-install index f7cd703..aa9cedb 100755 --- a/bin/n-install +++ b/bin/n-install @@ -477,7 +477,7 @@ done # !! prebuilt binaries only exist for Linux, Darwin (OSX) (and Windows) - if building Node.js from source were supported, however, GNU make would be required for that, too. for makeExe in make gmake; do "$makeExe" --version 2>/dev/null | grep -Fq "GNU Make" && break - [[ $makeExe == 'make' ]] && continue + [[ $makeExe == 'make' ]] && continue # if 'make' isn't GNU Make, try again with 'gmake'. preReqMsg+="${preReqMsg:+$'\n'}GNU Make not found, which is required for operation."$'\n'"On FreeBSD and PC-BSD, for instance, you can download it with \`sudo pkg install gmake\`." done [[ -z $preReqMsg ]] || die - <<<"$preReqMsg" diff --git a/bin/n-update b/bin/n-update index 329386a..5d653d2 100755 --- a/bin/n-update +++ b/bin/n-update @@ -174,9 +174,21 @@ shift $((OPTIND - 1)) # Skip the already-processed arguments (options). [[ -n $N_PREFIX ]] || die "Cannot locate n, because environment variable N_PREFIX is not defined." # Check for prerequisites. -for exe in git make; do - [[ -n $(command -v "$exe") ]] || die "Required binary \`$exe\` not found." +preReqMsg= +for exe in git; do + [[ -n $(command -v "$exe") ]] || preReqMsg+="Required binary \`$exe\` not found." done +# !! n's own installation procedure, `make install`, unfortunately currently (1.3.0) requires GNU make (due to use of conditional assignment `?=`), even though it would be simple to make it +# !! POSIX-compliant; for now, we therefore explicitly require GNU make. +# !! However, this is a hypothetical concern, because, as of n 1.3.0, n only works with *prebuilt* binaries downloadable from https://nodejs.org/dist/, and, as of Node.js v0.12.4, +# !! prebuilt binaries only exist for Linux, Darwin (OSX) (and Windows) - if building Node.js from source were supported, however, GNU make would be required for that, too. +for makeExe in make gmake; do + "$makeExe" --version 2>/dev/null | grep -Fq "GNU Make" && break + [[ $makeExe == 'make' ]] && continue # if 'make' isn't GNU Make, try again with 'gmake'. + preReqMsg+="${preReqMsg:+$'\n'}GNU Make not found, which is required for operation."$'\n'"On FreeBSD and PC-BSD, for instance, you can download it with \`sudo pkg install gmake\`." +done +[[ -z $preReqMsg ]] || die - <<<"$preReqMsg" + nDir="$N_PREFIX/n" @@ -207,6 +219,6 @@ target="$nExe" diff "$src" "$target" >/dev/null && { echo "(Installed version $("$nExe" --version) is up-to-date.)"; exit 0; } # Invoke the Makefile installation task, which simply copies bin/n to ${N_PREFIX}/bin. -PREFIX="$N_PREFIX" make install || die +PREFIX="$N_PREFIX" "$makeExe" install || die echo "-- n successfully updated to version $("$nExe" --version)." From 1947427901faac9a0d48e756e12e3250d8389084 Mon Sep 17 00:00:00 2001 From: Michael Klement Date: Sat, 4 Jul 2015 23:06:19 -0400 Subject: [PATCH 3/3] v0.1.3 --- CHANGELOG.md | 3 ++- README.md | 25 ++++++++++++++++--------- bin/n-install | 2 +- bin/n-uninstall | 2 +- bin/n-update | 2 +- package.json | 2 +- 6 files changed, 22 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3358c96..daa5bca 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,8 +4,9 @@ Versioning complies with [semantic versioning (semver)](http://semver.org/). -* **[v0.1.3-0](https://github.com/mklement0/n-install/compare/v0.1.2...v0.1.3-0)** (2015-06-26): +* **[v0.1.3](https://github.com/mklement0/n-install/compare/v0.1.2...v0.1.3)** (2015-07-04): * [robustness] If `make` is found not to be _GNU_ `make`, an attempt is made to use `gmake` instead. + * [doc] `--version` now also outputs the project's home URL; read-me improvements. * **[v0.1.2](https://github.com/mklement0/n-install/compare/v0.1.1...v0.1.2)** (2015-06-21): * [doc] Examples revised. diff --git a/README.md b/README.md index 9e40a5e..22a43c9 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,14 @@ **Installs [`n`](https://github.com/tj/n)**, the **[Node.js](https://nodejs.org/) and [io.js](https://iojs.org/) version manager**, on Unix-like platforms, **without needing to install Node.js or io.js first**. Additionally, installs scripts `n-update` for later on-demand updating of `n`, and `n-uninstall` for uninstalling. +The simplest case is **installation of `n` with confirmation prompt**, with subsequent **installation of the latest stable Node.js version**: + +```shell +curl -L http://git.io/n-install | bash +``` + +This is by far **the simplest way to get started with both `n` and Node.js** - even if you're looking to install only the latest stable Node.js version, with no (immediate) plans to install _multiple_ versions. + `n` is installed as follows: * The installation target is a **dedicated directory**, which **defaults to `~/n`** and can be overridden with environment variable `N_PREFIX`; n itself as well as the active Node.js/io.js version are placed there. @@ -39,12 +47,6 @@ Additionally, installs scripts `n-update` for later on-demand updating of `n`, a * For other shells, these modification must be performed manually; instructions are provided during installation. * By default, the latest stable Node.js version is installed; you can suppress that or even specify multiple Node.js/io.js versions to install. -The simplest case is **installation of `n` with confirmation prompt**, with subsequent **installation of the latest stable Node.js version**: - -```shell -curl -L http://git.io/n-install | bash -``` - +* **[v0.1.3](https://github.com/mklement0/n-install/compare/v0.1.2...v0.1.3)** (2015-07-04): + * [robustness] If `make` is found not to be _GNU_ `make`, an attempt is made to use `gmake` instead. + * [doc] `--version` now also outputs the project's home URL; read-me improvements. + * **[v0.1.2](https://github.com/mklement0/n-install/compare/v0.1.1...v0.1.2)** (2015-06-21): * [doc] Examples revised. diff --git a/bin/n-install b/bin/n-install index aa9cedb..b0bc736 100755 --- a/bin/n-install +++ b/bin/n-install @@ -384,7 +384,7 @@ unset CDPATH # to prevent unpredictable `cd` behavior [[ -t 1 ]] || kNO_COLOR=1 # turn off colored output if stdout is not connected to a terminal # Output version number and exit, if requested. Note that the `ver='...'` statement is automatically updated by `make version VER=` - DO keep the 'v' suffix in the variable _definition_. -[[ $1 == '--version' ]] && { ver='v0.1.3-0'; echo "$kTHIS_NAME ${ver#v}"; exit 0; } +[[ $1 == '--version' ]] && { ver='v0.1.3'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } # !! AS OF n 1.3.0, n ITSELF ONLY WORKS WITH curl, NOT ALSO WITH wget. # !! Once n also supports wget, mention wget as an alternative in the help text. diff --git a/bin/n-uninstall b/bin/n-uninstall index 22ae38d..dd40ab2 100755 --- a/bin/n-uninstall +++ b/bin/n-uninstall @@ -208,7 +208,7 @@ unset CDPATH # to prevent unpredictable `cd` behavior [[ -t 1 ]] || kNO_COLOR=1 # turn off colored output if stdout is not connected to a terminal # Output version number and exit, if requested. Note that the `ver='...'` statement is automatically updated by `make version VER=` - DO keep the 'v' suffix in the variable _definition_. -[ "$1" = '--version' ] && { ver='v0.1.3-0'; echo "$kTHIS_NAME ${ver#v}"; exit 0; } +[ "$1" = '--version' ] && { ver='v0.1.3'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } # Command-line help. if [ "$1" = '--help' ] || [ "$1" = '-h' ]; then diff --git a/bin/n-update b/bin/n-update index 5d653d2..ec28fac 100755 --- a/bin/n-update +++ b/bin/n-update @@ -124,7 +124,7 @@ unset CDPATH # to prevent unpredictable `cd` behavior [[ -t 1 ]] || kNO_COLOR=1 # turn off colored output if stdout is not connected to a terminal # Output version number and exit, if requested. Note that the `ver='...'` statement is automatically updated by `make version VER=` - DO keep the 'v' suffix in the variable _definition_. -[ "$1" = '--version' ] && { ver='v0.1.3-0'; echo "$kTHIS_NAME ${ver#v}"; exit 0; } +[ "$1" = '--version' ] && { ver='v0.1.3'; echo "$kTHIS_NAME ${ver#v}"$'\nFor license information and more, visit https://git.io/n-install-repo'; exit 0; } # Command-line help. if [ "$1" = '--help' ] || [ "$1" = '-h' ]; then diff --git a/package.json b/package.json index 6a3f98e..80873ef 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "n-install", "description": "installs n, the Node.js version manager, without needing to install Node.js first", "private": true, - "version": "0.1.3-0", + "version": "0.1.3", "os": [ "darwin", "linux"