2017-04-28 18:36:42 +00:00
|
|
|
|
Vagrant.configure(2) do |config|
|
2017-09-30 13:23:55 +00:00
|
|
|
|
|
|
|
|
|
# We use Ubuntu instead of Debian because the image comes with two-way
|
|
|
|
|
# shared folder support by default.
|
2020-10-09 23:21:20 +00:00
|
|
|
|
UBUNTU = 'hashicorp/bionic64'
|
2017-09-30 13:23:55 +00:00
|
|
|
|
|
2020-10-09 23:21:20 +00:00
|
|
|
|
config.vm.define(:exa) do |config|
|
2017-04-28 18:36:42 +00:00
|
|
|
|
config.vm.provider :virtualbox do |v|
|
2017-09-30 13:23:55 +00:00
|
|
|
|
v.name = 'exa'
|
2020-01-19 00:37:24 +00:00
|
|
|
|
v.memory = 2048
|
2020-10-09 23:21:20 +00:00
|
|
|
|
v.cpus = `nproc`.chomp.to_i
|
2020-01-19 00:37:24 +00:00
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
config.vm.provider :vmware_desktop do |v|
|
|
|
|
|
v.vmx['memsize'] = '2048'
|
2020-10-09 23:21:20 +00:00
|
|
|
|
v.vmx['numvcpus'] = `nproc`.chomp
|
2016-10-07 18:31:03 +00:00
|
|
|
|
end
|
|
|
|
|
|
2017-09-30 13:23:55 +00:00
|
|
|
|
config.vm.box = UBUNTU
|
|
|
|
|
config.vm.hostname = 'exa'
|
2017-05-06 18:38:34 +00:00
|
|
|
|
|
2017-04-28 18:36:42 +00:00
|
|
|
|
|
2017-09-30 13:23:55 +00:00
|
|
|
|
# Make sure we know the VM image’s default user name. The ‘cassowary’ user
|
|
|
|
|
# (specified later) is used for most of the test *output*, but we still
|
|
|
|
|
# need to know where the ‘target’ and ‘.cargo’ directories go.
|
2018-09-26 20:25:50 +00:00
|
|
|
|
developer = 'vagrant'
|
2016-10-07 18:31:03 +00:00
|
|
|
|
|
2017-04-28 18:34:23 +00:00
|
|
|
|
|
2017-04-30 10:06:52 +00:00
|
|
|
|
# Install the dependencies needed for exa to build, as quietly as
|
|
|
|
|
# apt can do.
|
2017-05-06 19:34:59 +00:00
|
|
|
|
config.vm.provision :shell, privileged: true, inline: <<-EOF
|
2020-10-18 00:12:27 +00:00
|
|
|
|
if hash fish &>/dev/null; then
|
|
|
|
|
echo "Tools are already installed"
|
|
|
|
|
else
|
|
|
|
|
trap 'exit' ERR
|
|
|
|
|
echo "Installing tools"
|
|
|
|
|
apt-get update -qq
|
|
|
|
|
apt-get install -qq -o=Dpkg::Use-Pty=0 \
|
|
|
|
|
git gcc curl attr libgit2-dev zip \
|
|
|
|
|
fish zsh bash bash-completion
|
|
|
|
|
fi
|
2017-05-06 19:34:59 +00:00
|
|
|
|
EOF
|
2017-04-28 18:34:23 +00:00
|
|
|
|
|
2016-10-07 18:31:03 +00:00
|
|
|
|
|
|
|
|
|
# Install Rust.
|
|
|
|
|
# This is done as vagrant, not root, because it’s vagrant
|
|
|
|
|
# who actually uses it. Sent to /dev/null because the progress
|
2017-04-28 18:34:23 +00:00
|
|
|
|
# bar produces a ton of output.
|
2019-07-13 19:15:44 +00:00
|
|
|
|
config.vm.provision :shell, privileged: false, inline: <<-EOF
|
|
|
|
|
if hash rustc &>/dev/null; then
|
|
|
|
|
echo "Rust is already installed"
|
|
|
|
|
else
|
2020-10-16 22:41:25 +00:00
|
|
|
|
trap 'exit' ERR
|
2020-10-18 00:12:27 +00:00
|
|
|
|
echo "Installing Rust"
|
2021-01-08 16:45:59 +00:00
|
|
|
|
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- --profile minimal --component rustc,rust-std,cargo,clippy -y > /dev/null
|
2020-10-16 22:41:25 +00:00
|
|
|
|
source $HOME/.cargo/env
|
2021-01-08 16:45:59 +00:00
|
|
|
|
echo "Installing cargo-hack"
|
2020-10-18 00:12:27 +00:00
|
|
|
|
cargo install -q cargo-hack
|
2021-01-08 16:45:59 +00:00
|
|
|
|
echo "Installing specsheet"
|
|
|
|
|
cargo install -q --git https://github.com/ogham/specsheet
|
2019-07-13 19:15:44 +00:00
|
|
|
|
fi
|
|
|
|
|
EOF
|
2016-10-07 18:31:03 +00:00
|
|
|
|
|
2017-04-28 18:34:23 +00:00
|
|
|
|
|
2020-10-18 00:12:27 +00:00
|
|
|
|
# Privileged installation and setup scripts.
|
Replace Makefile with a developmental Justfile
This commit deletes the Makefile, which contained targets to build exa and install it on the local machine, and replaces it with a Justfile, which only contains command to build and test exa.
My reasoning for doing this is as follows:
• exa is increasingly being installed through package managers, rather than built and tested locally, so users are avoiding using the Makefile at all.
• It was a pain to keep up with the correct paths for installing the binary, man pages, and completions, which can vary between OSes. By removing them, the code in this repository need only concern itself with building exa and putting its files in the 'target' directory, simplifying things.
• just is much simpler than make conceptually, which is why I prefer it. It just runs commands, rather than being a complete build system, which we already use Cargo for.
• just has features built-in, such as listing tasks, that we've had to create make targets for.
• exa only needed a Makefile at all because it pre-dates Cargo!
• Other Rust projects seem to be getting along perfectly fine without one.
If I've missed some important reason that makes it worth keeping the Makefile around then please let me know.
2020-10-09 23:47:17 +00:00
|
|
|
|
config.vm.provision :shell, privileged: true, inline: <<-EOF
|
2020-10-18 00:12:27 +00:00
|
|
|
|
|
|
|
|
|
# Install Just, the command runner.
|
Replace Makefile with a developmental Justfile
This commit deletes the Makefile, which contained targets to build exa and install it on the local machine, and replaces it with a Justfile, which only contains command to build and test exa.
My reasoning for doing this is as follows:
• exa is increasingly being installed through package managers, rather than built and tested locally, so users are avoiding using the Makefile at all.
• It was a pain to keep up with the correct paths for installing the binary, man pages, and completions, which can vary between OSes. By removing them, the code in this repository need only concern itself with building exa and putting its files in the 'target' directory, simplifying things.
• just is much simpler than make conceptually, which is why I prefer it. It just runs commands, rather than being a complete build system, which we already use Cargo for.
• just has features built-in, such as listing tasks, that we've had to create make targets for.
• exa only needed a Makefile at all because it pre-dates Cargo!
• Other Rust projects seem to be getting along perfectly fine without one.
If I've missed some important reason that makes it worth keeping the Makefile around then please let me know.
2020-10-09 23:47:17 +00:00
|
|
|
|
if hash just &>/dev/null; then
|
|
|
|
|
echo "just is already installed"
|
|
|
|
|
else
|
2020-10-18 00:12:27 +00:00
|
|
|
|
trap 'exit' ERR
|
|
|
|
|
echo "Installing just"
|
2021-01-08 16:45:59 +00:00
|
|
|
|
wget -q "https://github.com/casey/just/releases/download/v0.8.3/just-v0.8.3-x86_64-unknown-linux-musl.tar.gz"
|
|
|
|
|
tar -xf "just-v0.8.3-x86_64-unknown-linux-musl.tar.gz"
|
Replace Makefile with a developmental Justfile
This commit deletes the Makefile, which contained targets to build exa and install it on the local machine, and replaces it with a Justfile, which only contains command to build and test exa.
My reasoning for doing this is as follows:
• exa is increasingly being installed through package managers, rather than built and tested locally, so users are avoiding using the Makefile at all.
• It was a pain to keep up with the correct paths for installing the binary, man pages, and completions, which can vary between OSes. By removing them, the code in this repository need only concern itself with building exa and putting its files in the 'target' directory, simplifying things.
• just is much simpler than make conceptually, which is why I prefer it. It just runs commands, rather than being a complete build system, which we already use Cargo for.
• just has features built-in, such as listing tasks, that we've had to create make targets for.
• exa only needed a Makefile at all because it pre-dates Cargo!
• Other Rust projects seem to be getting along perfectly fine without one.
If I've missed some important reason that makes it worth keeping the Makefile around then please let me know.
2020-10-09 23:47:17 +00:00
|
|
|
|
cp just /usr/local/bin
|
|
|
|
|
fi
|
|
|
|
|
|
2020-10-18 00:12:27 +00:00
|
|
|
|
# Guarantee that the timezone is UTC — some of the tests
|
|
|
|
|
# depend on this (for now).
|
|
|
|
|
timedatectl set-timezone UTC
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Use a different ‘target’ directory on the VM than on the host.
|
|
|
|
|
# By default it just uses the one in /vagrant/target, which can
|
|
|
|
|
# cause problems if it has different permissions than the other
|
|
|
|
|
# directories, or contains object files compiled for the host.
|
2017-09-30 13:23:55 +00:00
|
|
|
|
echo 'PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/home/#{developer}/.cargo/bin"' > /etc/environment
|
|
|
|
|
echo 'CARGO_TARGET_DIR="/home/#{developer}/target"' >> /etc/environment
|
2017-05-06 19:34:59 +00:00
|
|
|
|
|
|
|
|
|
|
2020-10-18 00:12:27 +00:00
|
|
|
|
# Create a variety of misc scripts.
|
2017-05-07 19:25:53 +00:00
|
|
|
|
|
2017-10-02 08:22:50 +00:00
|
|
|
|
ln -sf /vagrant/devtools/dev-run-debug.sh /usr/bin/exa
|
|
|
|
|
ln -sf /vagrant/devtools/dev-run-release.sh /usr/bin/rexa
|
2017-08-26 14:13:19 +00:00
|
|
|
|
|
2017-10-02 08:22:50 +00:00
|
|
|
|
echo -e "#!/bin/sh\ncargo build --manifest-path /vagrant/Cargo.toml \\$@" > /usr/bin/build-exa
|
2017-09-30 13:23:55 +00:00
|
|
|
|
ln -sf /usr/bin/build-exa /usr/bin/b
|
2017-08-26 14:13:19 +00:00
|
|
|
|
|
Inline the library into the binary
This commit removes the library portion of exa. Cargo now only builds a binary.
The original intent was for exa to have its own internal library, and have the binary just call the library. This is usually done for code cleanliness reasons: it separates the code that implements the purpose of the program (the "plumbing") from the code that the user interacts with (the "porcelain"), ensuring a well-defined interface between the two.
However, in exa, this split was in completely the wrong place. Logging was handled in the binary, but option parsing was handled in the library. The library could theoretically print to any Writer ("for testing", it said), but it's far easier to run integration tests by executing the binary than to change the code to handle unit tests, so this abstraction isn't gaining us anything.
I've also had several people ask me if exa should be packaged for Linux distributions as a library, or just a binary. Clearly, this is confusing!
In several of my other Rust projects, I've done this better, with the command-line option parsing and log printing done on the binary side. It also turns out that you don't need to have a [lib] section in the Cargo.toml, so that's gone too.
2020-10-10 00:43:42 +00:00
|
|
|
|
echo -e "#!/bin/sh\ncargo test --manifest-path /vagrant/Cargo.toml \\$@ -- --quiet" > /usr/bin/test-exa
|
2017-09-30 13:23:55 +00:00
|
|
|
|
ln -sf /usr/bin/test-exa /usr/bin/t
|
2017-08-26 14:13:19 +00:00
|
|
|
|
|
2017-09-30 13:23:55 +00:00
|
|
|
|
echo -e "#!/bin/sh\n/vagrant/xtests/run.sh" > /usr/bin/run-xtests
|
|
|
|
|
ln -sf /usr/bin/run-xtests /usr/bin/x
|
2017-08-19 16:59:52 +00:00
|
|
|
|
|
2017-09-30 13:23:55 +00:00
|
|
|
|
echo -e "#!/bin/sh\nbuild-exa && test-exa && run-xtests" > /usr/bin/compile-exa
|
|
|
|
|
ln -sf /usr/bin/compile-exa /usr/bin/c
|
2017-08-20 17:19:58 +00:00
|
|
|
|
|
2017-10-08 19:44:34 +00:00
|
|
|
|
echo -e "#!/bin/sh\nbash /vagrant/devtools/dev-package-for-linux.sh \\$@" > /usr/bin/package-exa
|
|
|
|
|
echo -e "#!/bin/sh\ncat /etc/motd" > /usr/bin/halp
|
2017-08-26 14:13:19 +00:00
|
|
|
|
|
2017-10-02 08:26:39 +00:00
|
|
|
|
chmod +x /usr/bin/{exa,rexa,b,t,x,c,build-exa,test-exa,run-xtests,compile-exa,package-exa,halp}
|
2017-08-26 14:13:19 +00:00
|
|
|
|
|
2020-10-16 22:41:25 +00:00
|
|
|
|
|
2020-10-18 00:12:27 +00:00
|
|
|
|
# Configure the welcoming text that gets shown:
|
2017-09-30 13:23:55 +00:00
|
|
|
|
|
2017-10-01 07:49:45 +00:00
|
|
|
|
# Capture the help text so it gets displayed first
|
2020-10-18 00:12:27 +00:00
|
|
|
|
rm -f /etc/update-motd.d/*
|
2017-10-01 07:49:45 +00:00
|
|
|
|
bash /vagrant/devtools/dev-help.sh > /etc/motd
|
|
|
|
|
|
|
|
|
|
# Tell bash to execute a bunch of stuff when a session starts
|
2018-09-26 20:25:50 +00:00
|
|
|
|
echo "source /vagrant/devtools/dev-bash.sh" > /home/#{developer}/.bash_profile
|
2019-07-13 19:15:44 +00:00
|
|
|
|
chown #{developer} /home/#{developer}/.bash_profile
|
2017-09-30 13:23:55 +00:00
|
|
|
|
|
|
|
|
|
# Disable last login date in sshd
|
|
|
|
|
sed -i '/PrintLastLog yes/c\PrintLastLog no' /etc/ssh/sshd_config
|
|
|
|
|
systemctl restart sshd
|
2017-04-28 18:34:23 +00:00
|
|
|
|
|
|
|
|
|
|
2020-10-18 00:12:27 +00:00
|
|
|
|
# Link the completion files so they’re “installed”:
|
2017-05-07 19:25:53 +00:00
|
|
|
|
|
2020-10-18 00:12:27 +00:00
|
|
|
|
# bash
|
2017-09-30 13:23:55 +00:00
|
|
|
|
test -h /etc/bash_completion.d/exa \
|
|
|
|
|
|| ln -s /vagrant/contrib/completions.bash /etc/bash_completion.d/exa
|
2017-05-06 20:56:40 +00:00
|
|
|
|
|
2020-10-18 00:12:27 +00:00
|
|
|
|
# zsh
|
2017-09-30 13:23:55 +00:00
|
|
|
|
test -h /usr/share/zsh/vendor-completions/_exa \
|
|
|
|
|
|| ln -s /vagrant/contrib/completions.zsh /usr/share/zsh/vendor-completions/_exa
|
2017-05-06 19:50:24 +00:00
|
|
|
|
|
2020-10-18 00:12:27 +00:00
|
|
|
|
# fish
|
2017-09-30 13:23:55 +00:00
|
|
|
|
test -h /usr/share/fish/completions/exa.fish \
|
|
|
|
|
|| ln -s /vagrant/contrib/completions.fish /usr/share/fish/completions/exa.fish
|
2017-05-06 19:34:59 +00:00
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
2017-05-07 19:25:53 +00:00
|
|
|
|
# Install kcov for test coverage
|
|
|
|
|
# This doesn’t run coverage over the xtests so it’s less useful for now
|
|
|
|
|
if ENV.key?('INSTALL_KCOV')
|
2017-09-30 13:23:55 +00:00
|
|
|
|
config.vm.provision :shell, privileged: false, inline: <<-EOF
|
2020-10-16 22:41:25 +00:00
|
|
|
|
trap 'exit' ERR
|
2017-09-30 13:23:55 +00:00
|
|
|
|
|
|
|
|
|
test -e ~/.cargo/bin/cargo-kcov \
|
|
|
|
|
|| cargo install cargo-kcov
|
|
|
|
|
|
|
|
|
|
sudo apt-get install -qq -o=Dpkg::Use-Pty=0 -y \
|
|
|
|
|
cmake g++ pkg-config \
|
|
|
|
|
libcurl4-openssl-dev libdw-dev binutils-dev libiberty-dev
|
|
|
|
|
|
|
|
|
|
cargo kcov --print-install-kcov-sh | sudo sh
|
|
|
|
|
EOF
|
|
|
|
|
end
|
2020-10-16 22:41:25 +00:00
|
|
|
|
|
|
|
|
|
config.vm.provision :shell, privileged: true, path: 'devtools/dev-set-up-environment.sh'
|
|
|
|
|
config.vm.provision :shell, privileged: false, path: 'devtools/dev-create-test-filesystem.sh'
|
2017-09-30 13:23:55 +00:00
|
|
|
|
end
|
2016-10-07 18:31:03 +00:00
|
|
|
|
end
|