2012-05-10 09:11:28 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2012-07-10 02:41:51 +00:00
|
|
|
# Script to generate a tarball
|
|
|
|
# We use git to output a tree. But we also want to build the user documentation
|
2019-03-30 20:48:17 +00:00
|
|
|
# and put that in the tarball, so that nobody needs to have sphinx installed
|
2012-07-10 02:41:51 +00:00
|
|
|
# to build it.
|
2016-05-25 16:51:04 +00:00
|
|
|
# Outputs to $FISH_ARTEFACT_PATH or ~/fish_built by default
|
2012-07-10 02:41:51 +00:00
|
|
|
|
|
|
|
# Exit on error
|
|
|
|
set -e
|
|
|
|
|
2016-05-25 16:49:53 +00:00
|
|
|
# We wil generate a tarball with a prefix "fish-VERSION"
|
2012-07-10 02:41:51 +00:00
|
|
|
# git can do that automatically for us via git-archive
|
2016-05-25 16:49:53 +00:00
|
|
|
# but to get the documentation in, we need to make a symlink called "fish-VERSION"
|
2012-07-10 02:41:51 +00:00
|
|
|
# and tar from that, so that the documentation gets the right prefix
|
|
|
|
|
2023-02-22 14:08:19 +00:00
|
|
|
# Use Ninja if available, as it automatically paralellises
|
|
|
|
BUILD_TOOL="make"
|
|
|
|
BUILD_GENERATOR="Unix Makefiles"
|
|
|
|
if command -v ninja >/dev/null; then
|
|
|
|
BUILD_TOOL="ninja"
|
|
|
|
BUILD_GENERATOR="Ninja"
|
|
|
|
fi
|
|
|
|
|
2019-02-12 01:38:04 +00:00
|
|
|
# We need GNU tar as that supports the --mtime and --transform options
|
2016-05-25 16:54:38 +00:00
|
|
|
TAR=notfound
|
|
|
|
for try in tar gtar gnutar; do
|
|
|
|
if $try -Pcf /dev/null --mtime now /dev/null >/dev/null 2>&1; then
|
|
|
|
TAR=$try
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
if [ "$TAR" = "notfound" ]; then
|
|
|
|
echo 'No suitable tar (supporting --mtime) found as tar/gtar/gnutar in PATH'
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2012-07-10 02:41:51 +00:00
|
|
|
# Get the current directory, which we'll use for symlinks
|
|
|
|
wd="$PWD"
|
|
|
|
|
2013-06-24 10:12:09 +00:00
|
|
|
# Get the version from git-describe
|
2019-11-28 01:53:58 +00:00
|
|
|
VERSION=$(git describe --dirty 2>/dev/null)
|
2016-05-25 16:49:53 +00:00
|
|
|
|
|
|
|
# The name of the prefix, which is the directory that you get when you untar
|
|
|
|
prefix="fish-$VERSION"
|
2013-06-24 10:12:09 +00:00
|
|
|
|
2012-07-10 02:41:51 +00:00
|
|
|
# The path where we will output the tar file
|
2016-05-25 16:51:04 +00:00
|
|
|
# Defaults to ~/fish_built
|
|
|
|
path=${FISH_ARTEFACT_PATH:-~/fish_built}/$prefix.tar
|
2012-07-10 02:41:51 +00:00
|
|
|
|
|
|
|
# Clean up stuff we've written before
|
2020-02-14 14:00:00 +00:00
|
|
|
rm -f "$path" "$path".xz
|
2012-07-10 02:41:51 +00:00
|
|
|
|
|
|
|
# git starts the archive
|
2014-09-07 01:37:43 +00:00
|
|
|
git archive --format=tar --prefix="$prefix"/ HEAD > "$path"
|
2012-07-10 02:41:51 +00:00
|
|
|
|
2019-02-12 01:38:04 +00:00
|
|
|
# tarball out the documentation, generate a version file
|
2019-11-28 01:53:58 +00:00
|
|
|
PREFIX_TMPDIR=$(mktemp -d)
|
|
|
|
cd "$PREFIX_TMPDIR"
|
|
|
|
echo "$VERSION" > version
|
2023-02-22 14:08:19 +00:00
|
|
|
cmake -G "$BUILD_GENERATOR" "$wd"
|
|
|
|
$BUILD_TOOL doc
|
2016-05-25 16:55:40 +00:00
|
|
|
|
2019-02-12 01:38:04 +00:00
|
|
|
TAR_APPEND="$TAR --append --file=$path --mtime=now --owner=0 --group=0 \
|
|
|
|
--mode=g+w,a+rX --transform s/^/$prefix\//"
|
|
|
|
$TAR_APPEND --no-recursion user_doc
|
|
|
|
$TAR_APPEND user_doc/html user_doc/man
|
|
|
|
$TAR_APPEND version
|
2016-05-25 16:55:40 +00:00
|
|
|
|
|
|
|
cd -
|
2019-02-12 01:38:04 +00:00
|
|
|
rm -r "$PREFIX_TMPDIR"
|
2012-07-10 02:41:51 +00:00
|
|
|
|
2020-02-14 14:00:00 +00:00
|
|
|
# xz it
|
|
|
|
xz "$path"
|
2012-07-10 02:41:51 +00:00
|
|
|
|
2023-03-30 04:12:09 +00:00
|
|
|
# Output what we did, and the sha256 hash
|
2020-02-14 14:00:00 +00:00
|
|
|
echo "Tarball written to $path".xz
|
|
|
|
openssl dgst -sha256 "$path".xz
|