Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fetch from array of URLs, remove src dir on fail #30

Closed
wants to merge 8 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
64 changes: 32 additions & 32 deletions nave.sh
Expand Up @@ -127,19 +127,35 @@ nave_fetch () {
remove_dir "$src"
ensure_dir "$src"

# fixme: use array here.
local url="http://nodejs.org/dist/node-v$version.tar.gz"
local url2="http://nodejs.org/dist/v$version/node-v$version.tar.gz"
local url3="http://nodejs.org/dist/node-$version.tar.gz"
curl -# -L "$url" \
| $tar xzf - -C "$src" --strip-components=1 \
|| curl -# -L "$url2" \
| $tar xzf - -C "$src" --strip-components=1 \
|| curl -# -L "$url3" \
| $tar xzf - -C "$src" --strip-components=1 \
|| fail "Couldn't fetch $version"
declare -a urls=(
"http://nodejs.org/dist/v$version/node-v$version.tar.gz"
"http://nodejs.org/dist/node-v$version.tar.gz"
"http://nodejs.org/dist/node-$version.tar.gz"
)
for url in "${urls[@]}"; do
curl -#Lf "$url" \
| $tar xzf - -C "$src" --strip-components=1
if [ $? -eq 0 ]; then
return 0
fi
done

return 0
remove_dir "$src"
fail "Couldn't fetch $version"
}

build () {
local version="$1"
nave_fetch "$version"
local src="$NAVE_SRC/$version"

( cd -- "$src"
JOBS=${JOBS:-2} ./configure --debug --prefix="$2" \
|| fail "Failed to configure $version"
JOBS=${JOBS:-2} make \
|| fail "Failed to make $version"
make install || fail "Failed to install $version"
) || fail "fail"
}

nave_usemain () {
Expand All @@ -161,16 +177,8 @@ nave_usemain () {
echo "$version already installed"
return 0
fi
nave_fetch "$version"
src="$NAVE_SRC/$version"

( cd -- "$src"
JOBS=${JOBS:-2} ./configure --debug --prefix $prefix \
|| fail "Failed to configure $version"
JOBS=${JOBS:-2} make \
|| fail "Failed to make $version in main env"
make install || fail "Failed to install $version in main env"
) || fail "fail"
build "$version in main env" "$prefix"
}

nave_install () {
Expand All @@ -179,19 +187,11 @@ nave_install () {
echo "Already installed: $version" >&2
return 0
fi
nave_fetch "$version"

local src="$NAVE_SRC/$version"
local install="$NAVE_ROOT/$version"
remove_dir "$install"
ensure_dir "$install"
( cd -- "$src"
JOBS=${JOBS:-8} ./configure --debug --prefix="$install" \
|| fail "Failed to configure $version"
JOBS=${JOBS:-8} make \
|| fail "Failed to make $version"
make install || fail "Failed to install $version"
) || fail "fail"

build "$version" "$install"
}

nave_test () {
Expand Down Expand Up @@ -350,7 +350,7 @@ nave_use () {
npm_config_binroot="$bin" npm_config_root="$lib" \
npm_config_manroot="$man" \
NODE_PATH="$lib" \
"$SHELL" -c "$(enquote_all node "$@")"
"$SHELL" -c "$(enquote_all "$@")"
hash -r
else
hash -r
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{ "name" : "nave"
, "author" : "Isaac Z. Schlueter <i@izs.me>"
, "description" : "Virtual Environments for Node"
, "version" : "0.2.0"
, "version" : "0.2.3"
, "preferGlobal" : true
, "bin" : { "nave" : "./nave.sh" }
}