#!/bin/sh

set -ex

REPO=https://github.com/mozilla/sccache
VERSION=v0.2.15
TARFILENAME="sccache-$VERSION-x86_64-unknown-linux-musl"
TARFILEPATH="$HOME/.cache/$TARFILENAME.tar.gz"
BINDIR="$HOME/.local/bin"

test -f "$TARFILEPATH" ||
    wget -qO "$TARFILEPATH" "$REPO/releases/download/$VERSION/$TARFILENAME.tar.gz"

tar -xf "$TARFILEPATH" -C "$BINDIR" --wildcards "*/sccache" --strip-components=1
chmod u+x "$BINDIR/sccache"
