exa/devtools/dev-package-for-linux.sh
Benjamin Sago 173e9b2345 Move the packaging script into its own file
Having it all echo-ed into the file like that made it hard to read *and* hard to maintain. My initial aversion to it was that I didn’t want there to be an executable script in the main repository that only worked when you were in the VM, because people would just run it anyway. But this can be avoided by leaving it non-executable, and having a command in the VM that runs it instead.
2017-10-01 09:48:20 +02:00

59 lines
2.5 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

set -e
# This script builds a publishable release-worthy version of exa.
# It gets the version number, builds exa using cargo, tests it, strips the
# binary, compresses it into a zip, then puts it in /vagrant so its
# accessible from the host machine.
#
# If youre in the VM, you can run it using the package-exa command.
# First, we need to get the version number to figure out what to call the zip.
# We do this by getting the first line from the Cargo.toml that matches
# /version/, removing its whitespace, and building a command out of it, so the
# shell executes something like `exa_version="0.8.0"`, which it understands as
# a variable definition. Hey, its not a hack if it works.
toml_file="/vagrant/Cargo.toml"
eval exa_$(grep version $toml_file | head -n 1 | sed "s/ //g")
if [ -z "$exa_version" ]; then
echo "Failed to parse version number! Can't build exa!"
exit
else
echo "Building exa v$exa_version"
fi
# Compilation is done in --release mode, which takes longer but produces a
# faster binary. This binary gets built to a different place, so the extended
# tests script needs to be told which one to use.
echo -e "\n\033[4mCompiling release version of exa...\033[0m"
exa_linux_binary="/vagrant/exa-linux-x86_64"
rm -vf "$exa_linux_binary"
cargo build --release --manifest-path "$toml_file"
cargo test --release --manifest-path "$toml_file" --lib -- --quiet
/vagrant/xtests/run.sh --release
cp /home/ubuntu/target/release/exa "$exa_linux_binary"
# Stripping the binary before distributing it removes a bunch of debugging
# symbols, saving some space.
echo -e "\n\033[4mStripping binary...\033[0m"
strip -v "$exa_linux_binary"
# Compress the binary for upload. The -j flag is necessary to avoid the
# /vagrant path being in the zip too. Only the zip gets the version number, so
# the binaries can have consistent names, but its still possible to tell
# different *downloads* apart.
echo -e "\n\033[4mZipping binary...\033[0m"
exa_linux_zip="/vagrant/exa-linux-x86_64-${exa_version}.zip"
rm -vf "$exa_linux_zip"
zip -j "$exa_linux_zip" "$exa_linux_binary"
# There was a problem a while back where a library was getting unknowingly
# *dynamically* linked, which broke the whole self-contained binary concept.
# So dump the linker table, in case anything unscrupulous shows up.
echo -e "\n\033[4mLibraries linked:\033[0m"
ldd "$exa_linux_binary" | sed "s/\t//"
# Might as well use it to test itself, right?
echo -e "\n\033[4mAll done! Files produced:\033[0m"
"$exa_linux_binary" "$exa_linux_binary" "$exa_linux_zip" -lB