mirror of
https://github.com/fish-shell/fish-shell.git
synced 2024-11-22 12:04:39 +08:00
62 lines
1.8 KiB
Bash
Executable File
62 lines
1.8 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
# Script to generate a tarball of vendored (downloaded) Rust dependencies
|
|
# and the cargo configuration to ensure they are used
|
|
# This tarball should be unpacked into a fish source directory
|
|
# Outputs to $FISH_ARTEFACT_PATH or ~/fish_built by default
|
|
|
|
# Exit on error
|
|
set -e
|
|
|
|
# We need GNU tar as that supports the --mtime and --transform options
|
|
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
|
|
|
|
# Get the current directory, which we'll use for telling Cargo where to find the sources
|
|
wd="$PWD"
|
|
|
|
# Get the version from git-describe
|
|
VERSION=$(git describe --dirty 2>/dev/null)
|
|
|
|
# The name of the prefix, which is the directory that you get when you untar
|
|
prefix="fish-$VERSION"
|
|
|
|
# The path where we will output the tar file
|
|
# Defaults to ~/fish_built
|
|
path=${FISH_ARTEFACT_PATH:-~/fish_built}/$prefix-vendor.tar
|
|
|
|
# Clean up stuff we've written before
|
|
rm -f "$path" "$path".xz
|
|
|
|
# Work in a temporary directory to avoid clobbering the source directory
|
|
PREFIX_TMPDIR=$(mktemp -d)
|
|
cd "$PREFIX_TMPDIR"
|
|
|
|
mkdir .cargo
|
|
cargo vendor --manifest-path "$wd/Cargo.toml" > .cargo/config
|
|
|
|
# vendoring drags in a lot of Windows dependencies, which makes the resulting tarball enormous
|
|
# cargo can't be told only to support a particular platform
|
|
# see https://github.com/rust-lang/cargo/issues/7058
|
|
# workaround below from https://github.com/rust-lang/cargo/issues/7058#issuecomment-751856262
|
|
rm -r vendor/winapi*/lib/*.a
|
|
|
|
tar cfvJ $path.xz vendor .cargo
|
|
|
|
cd -
|
|
rm -r "$PREFIX_TMPDIR"
|
|
|
|
# Output what we did, and the sha256 hash
|
|
echo "Tarball written to $path".xz
|
|
openssl dgst -sha256 "$path".xz
|