maketarball.sh 551 Bytes
Newer Older
Jakub Sztandera's avatar
Jakub Sztandera committed
1 2 3 4 5 6 7
#!/usr/bin/env bash
# vim: set expandtab sw=2 ts=2:

# bash safe mode
set -euo pipefail
IFS=$'\n\t'

8 9 10
# readlink doesn't work on macos
OUTPUT="${1:-go-ipfs-source.tar.gz}"
if ! [[ "$OUTPUT" = /* ]]; then
11
  OUTPUT="$PWD/$OUTPUT"
12
fi
Jakub Sztandera's avatar
Jakub Sztandera committed
13

14 15
GOCC=${GOCC=go}

Jakub Sztandera's avatar
Jakub Sztandera committed
16
TMPDIR="$(mktemp -d)"
17 18 19
cp -r . "$TMPDIR"
( cd "$TMPDIR" &&
  echo $PWD &&
20
  $GOCC mod vendor &&
21 22 23 24
  (git describe --always --match=NeVeRmAtCh --dirty 2>/dev/null || true) > .tarball &&
  chmod -R u=rwX,go=rX "$TMPDIR" # normalize permissions
  tar -czf "$OUTPUT" --exclude="./.git" .
  )
Jakub Sztandera's avatar
Jakub Sztandera committed
25 26

rm -rf "$TMPDIR"