Debian Codegraph @

devtools/source-dist.sh

raw
1 #!/bin/bash
2
3 set -ev
4 # GNU tar is `gtar` on macOS (where this is usually run by hand) and `tar` on
5 # Linux (e.g. in CI); both support --transform/--exclude, BSD tar does not. Pick
6 # the first GNU tar found, and fail with an actionable message rather than
7 # falling back to BSD tar and erroring later on an unknown --transform option.
8 TAR=$(command -v gtar || command -v tar)
9 if ! "${TAR}" --version 2>/dev/null | grep -q "GNU tar"; then
10 echo "error: GNU tar is required (it provides --transform/--exclude)." >&2
11 echo "Install it and re-run: 'brew install gnu-tar' on macOS, or" >&2
12 echo "'apt-get install tar' on Debian/Ubuntu." >&2
13 exit 1
14 fi
15 VERSION=$(git describe --tags --dirty=.dirty)
16 VERSION_FILE=cmake/libMBDVersionTag.cmake
17 SLUG=libmbd-${VERSION}
18 echo "set(VERSION_TAG ${VERSION})">${VERSION_FILE}
19 mkdir -p dist
20 ARCHIVE=dist/${SLUG}.tar.gz
21 "${TAR}" -vcz -f ${ARCHIVE} \
22 --exclude "*pymbd*" --exclude "__pycache__" --exclude "conftest.py" --exclude ".*" \
23 --transform "s,^,${SLUG}/," CMakeLists.txt cmake src tests LICENSE README.md
24 rm ${VERSION_FILE}
25 echo ${ARCHIVE}