From f84c79523d0a7788d4770e0558e6948d36efb03d Mon Sep 17 00:00:00 2001 From: aszlig Date: Sun, 31 Aug 2014 20:06:10 +0200 Subject: [PATCH] nix/install: Don't rely on tar for decompression. 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 --- nix/install | 25 +++++++++++-------------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/nix/install b/nix/install index 342aa0daf1..023a5ac202 100644 --- a/nix/install +++ b/nix/install @@ -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 } @@ -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"