mirror of
https://github.com/Llewellynvdm/exa.git
synced 2024-11-05 20:37:52 +00:00
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.
This commit is contained in:
parent
02403c7cc5
commit
173e9b2345
22
Vagrantfile
vendored
22
Vagrantfile
vendored
@ -78,27 +78,7 @@ Vagrant.configure(2) do |config|
|
||||
echo -e "#!/bin/sh\nbuild-exa && test-exa && run-xtests" > /usr/bin/compile-exa
|
||||
ln -sf /usr/bin/compile-exa /usr/bin/c
|
||||
|
||||
echo "#!/bin/bash" > /usr/bin/package-exa
|
||||
echo "set -e" >> /usr/bin/package-exa
|
||||
|
||||
echo 'echo -e "\nCompiling release version of exa..."' >> /usr/bin/package-exa
|
||||
echo "cargo build --release --manifest-path /vagrant/Cargo.toml" >> /usr/bin/package-exa
|
||||
echo "cargo test --release --manifest-path /vagrant/Cargo.toml --lib" >> /usr/bin/package-exa
|
||||
echo "/vagrant/xtests/run.sh --release" >> /usr/bin/package-exa
|
||||
echo "cp /home/ubuntu/target/release/exa /vagrant/exa-linux-x86_64" >> /usr/bin/package-exa
|
||||
|
||||
echo 'echo -e "\nStripping binary..."' >> /usr/bin/package-exa
|
||||
echo "strip /vagrant/exa-linux-x86_64" >> /usr/bin/package-exa
|
||||
|
||||
echo 'echo -e "\nZipping binary..."' >> /usr/bin/package-exa
|
||||
echo "rm -f /vagrant/exa-linux-x86_64.zip" >> /usr/bin/package-exa
|
||||
echo "zip -j /vagrant/exa-linux-x86_64.zip /vagrant/exa-linux-x86_64" >> /usr/bin/package-exa
|
||||
|
||||
echo 'echo -e "\nLibraries linked:"' >> /usr/bin/package-exa
|
||||
echo "ldd /vagrant/exa-linux-x86_64" >> /usr/bin/package-exa
|
||||
|
||||
echo 'echo -e "\nAll done!"' >> /usr/bin/package-exa
|
||||
echo '/vagrant/exa-linux-x86_64 /vagrant/exa-linux-x86_64* -lB' >> /usr/bin/package-exa
|
||||
echo -e "#!/bin/sh\nbash /vagrant/devtools/dev-package-for-linux.sh" > /usr/bin/package-exa
|
||||
|
||||
chmod +x /usr/bin/{exa,rexa,b,t,x,c,build-exa,test-exa,run-xtests,compile-exa,package-exa}
|
||||
EOF
|
||||
|
58
devtools/dev-package-for-linux.sh
Normal file
58
devtools/dev-package-for-linux.sh
Normal file
@ -0,0 +1,58 @@
|
||||
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 it’s
|
||||
# accessible from the host machine.
|
||||
#
|
||||
# If you’re 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, it’s 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 it’s 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
|
@ -4,7 +4,7 @@ set +xe
|
||||
|
||||
# Release mode
|
||||
case "$1" in
|
||||
"--release") echo "Testing release exa..."; exa_binary="$HOME/target/release/exa" ;;
|
||||
"--release") exa_binary="$HOME/target/release/exa" ;;
|
||||
*) exa_binary="$HOME/target/debug/exa" ;;
|
||||
esac
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user