Skip to content

Commit

Permalink
nix/install: Don't rely on tar for decompression.
Browse files Browse the repository at this point in the history
Older versions of tar didn't detect the compression type and thus tried
to extract an uncompressed archive and even older versions of tar didn't
even have the -j argument at all, so let's download, decompress and
unpack in one go.

Signed-off-by: aszlig <aszlig@redmoonstudios.org>
  • Loading branch information
aszlig committed Aug 31, 2014
1 parent 18cf43d commit f84c795
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions nix/install
Expand Up @@ -4,16 +4,16 @@
# downloading a binary distribution and running its installer script
# (which in turn creates and populates /nix).

tarball=nix-binary-tarball.tar.bz2
unpack=nix-binary-tarball-unpack

cleanup() {
rm -rf "$unpack" "$tarball"
require_util() {
type "$1" > /dev/null 2>&1 || which "$1" > /dev/null 2>&1 ||
oops "you do not have \`$1' installed, which i need to $2"
}

oops() {
echo "$0: $@" >&2
cleanup
rm -rf "$unpack"
exit 1
}

Expand All @@ -26,19 +26,16 @@ esac

url="https://nixos.org/releases/nix/nix-1.7/nix-1.7-$system.tar.bz2"

type curl > /dev/null 2>&1 || which curl > /dev/null 2>&1 ||
oops "you do not have \`curl' installed," \
"which I need to download the binary tarball"
require_util curl "download the binary tarball"
require_util bzcat "decompress the binary tarball"
require_util tar "unpack the binary tarball"

echo "downloading Nix binary tarball for $system from \`$url'..."
curl -L -o "$tarball" "$url" || oops "failed to download \`$url'"

echo "unpacking binary tarball..."
mkdir "$unpack"
tar xf "$tarball" -C "$unpack"
echo "unpacking Nix binary tarball for $system from \`$url'..."
mkdir "$unpack" || oops "failed to create \`$unpack' directory"
curl -L "$url" | bzcat | tar x -C "$unpack" || oops "failed to unpack \`$url'"

[ -e "$unpack"/*/install ] ||
oops "installation script is missing from the binary tarball!"

"$unpack"/*/install
cleanup
rm -rf "$unpack"

0 comments on commit f84c795

Please sign in to comment.