From 414b347ae54e9469dff4d942319ca99d21344f20 Mon Sep 17 00:00:00 2001 From: Benjamin Sago Date: Sun, 20 Aug 2017 18:19:58 +0100 Subject: [PATCH] Formalise exa-packaging script MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Every time I had to build exa, I copied the files manually and checked to make sure they all had the same name. There’s now a script that does all that stuff for me, so I don’t need to remember to do it anymore. It also does some things that weren’t being done before, including stripping the binary and listing its linked dependencies to we can tell if something like libhttp_parser has slipped in there (see #194) --- .gitignore | 2 ++ Vagrantfile | 26 ++++++++++++++++++++++++-- xtests/run.sh | 12 ++++++++---- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 817a47b..3eda9b6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,6 @@ target +/exa-linux-x86_64 +/exa-linux-x86_64.zip .vagrant ubuntu-xenial-16.04-cloudimg-console.log diff --git a/Vagrantfile b/Vagrantfile index 8e364b7..4598f1d 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -21,7 +21,7 @@ Vagrant.configure(2) do |config| config.vm.provision :shell, privileged: true, inline: <<-EOF set -xe apt-get install -qq -o=Dpkg::Use-Pty=0 -y \ - git cmake curl attr libgit2-dev \ + git cmake curl attr libgit2-dev zip \ fish zsh bash bash-completion EOF @@ -68,8 +68,30 @@ 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 - chmod +x /usr/bin/{exa,rexa,b,t,x,c,build-exa,test-exa,run-xtests,compile-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 /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 + + chmod +x /usr/bin/{exa,rexa,b,t,x,c,build-exa,test-exa,run-xtests,compile-exa,package-exa} EOF diff --git a/xtests/run.sh b/xtests/run.sh index f3f0015..3062b0f 100755 --- a/xtests/run.sh +++ b/xtests/run.sh @@ -2,12 +2,15 @@ set +xe -# The exa binary -exa_binary="$HOME/target/debug/exa" +# Release mode +case "$1" in + "--release") echo "Testing release exa..."; exa_binary="$HOME/target/release/exa" ;; + *) exa_binary="$HOME/target/debug/exa" ;; +esac if [ ! -f "$exa_binary" ]; then echo "exa binary ($exa_binary) does not exist" - echo -e "create it first with \033[1;32mbuild-exa\033[0m or \033[1;32mb\033[0m" + if [ "$1" != "--release" ]; then echo -e "create it first with \033[1;32mbuild-exa\033[0m or \033[1;32mb\033[0m"; fi exit 1 fi @@ -150,7 +153,8 @@ env LANG=ja_JP.UTF-8 $exa $testcases/dates -l | diff -q - $results/dates_jp || # Paths and directories # These directories are created in the VM user’s home directory (the default # location) when a Cargo build is done. -(cd; $exa -1d target target/debug target/debug/build | diff -q - $results/dir_paths) || exit 1 +(cd; mkdir -p target/debug/build + $exa -1d target target/debug target/debug/build | diff -q - $results/dir_paths) || exit 1 $exa -1d . .. / | diff -q - $results/dirs || exit 1