Skip to content

Commit

Permalink
bin/n: Option to download xz-compressed tarball
Browse files Browse the repository at this point in the history
To download an xz-compressed tarball, set the environment variable
"N_USE_XZ" to be non-empty before running n.
  • Loading branch information
DeeDeeG committed Jun 23, 2019
1 parent 13562ee commit 41400d6
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions bin/n
Original file line number Diff line number Diff line change
Expand Up @@ -406,6 +406,7 @@ tarball_url() {
local uname="$(uname -a)"
local arch=x86
local os=
local ext=gz

# from nave(1)
case "$uname" in
Expand All @@ -431,7 +432,9 @@ tarball_url() {

[ -n "$ARCH" ] && arch="$ARCH"

echo "${MIRROR[$DEFAULT]}v${version}/${BIN_NAME[$DEFAULT]}-v${version}-${os}-${arch}.tar.gz"
[ -n "$N_USE_XZ" ] && ext="xz"

echo "${MIRROR[$DEFAULT]}v${version}/${BIN_NAME[$DEFAULT]}-v${version}-${os}-${arch}.tar.${ext}"

}

Expand Down Expand Up @@ -541,6 +544,12 @@ install() {

local dir="${VERSIONS_DIR[$DEFAULT]}/$version"

if test -n "$N_USE_XZ"; then
local tarflag="-Jx"
else
local tarflag="-zx"
fi

if test -d "$dir"; then
if [[ ! -e "$dir/n.lock" ]] ; then
if "$ACTIVATE" ; then
Expand All @@ -566,7 +575,7 @@ install() {
cd "$dir"

log fetch "$url"
$GET "$url" | tar -zx --strip-components=1
$GET "$url" | tar "$tarflag" --strip-components=1
[ "$QUIET" == false ] && erase_line
rm -f "$dir/n.lock"

Expand Down

0 comments on commit 41400d6

Please sign in to comment.