2016-04-17 11:41:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# Make bash fail much more aggressively on errors.
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
|
# Make sure we can build our main container.
|
|
|
|
docker build -t ekidd/rust-musl-builder .
|
|
|
|
|
|
|
|
# Make sure we can build our example derived container.
|
2017-10-24 12:40:12 +00:00
|
|
|
docker build -t rust-musl-zlib examples/adding-a-library
|
2016-04-17 11:41:55 +00:00
|
|
|
|
2017-10-13 11:13:10 +00:00
|
|
|
# Make sure we can build a multi-stage container.
|
2017-10-24 12:40:12 +00:00
|
|
|
docker build -t rust-musl-builder-using-diesel examples/using-diesel
|
|
|
|
docker run --rm rust-musl-builder-using-diesel
|
2017-10-13 11:13:10 +00:00
|
|
|
|
2016-04-17 11:41:55 +00:00
|
|
|
# Make sure we can build a static executable.
|
|
|
|
docker run --rm ekidd/rust-musl-builder bash -c "
|
|
|
|
set -euo pipefail
|
|
|
|
export USER=rust
|
2016-09-12 10:43:11 +00:00
|
|
|
cargo new --vcs none --bin testme
|
|
|
|
cd testme
|
2018-03-26 06:47:01 +00:00
|
|
|
# depending on git2 (and using it) makes the test much better, because git2 links against openssl and libz-sys among others
|
|
|
|
sed -i 's/\[dependencies\]/\[dependencies\]\ngit2 = \"0.6\"/' Cargo.toml
|
|
|
|
echo '
|
|
|
|
extern crate git2;
|
|
|
|
use git2::Repository;
|
|
|
|
fn main() {
|
|
|
|
let _local = Repository::init(\"fkbr\");
|
|
|
|
println!(\"Hello, world!\");
|
|
|
|
}' > src/main.rs
|
2016-04-17 11:41:55 +00:00
|
|
|
cargo build
|
2018-03-26 06:47:01 +00:00
|
|
|
|
|
|
|
# ldd will not die if the file does not exist, we need to check that too
|
|
|
|
if [ ! -f target/x86_64-unknown-linux-musl/debug/testme ]; then
|
|
|
|
echo 'binary was not created by cargo build or has unexpected name. Heres whats in target:' 1>&2
|
|
|
|
# no tree in image, but this also works
|
|
|
|
set -x
|
|
|
|
ls -l target && ls -l target/x86_64-unknown-linux-musl && ls -l target/x86_64-unknown-linux-musl/debug
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2016-04-17 11:41:55 +00:00
|
|
|
echo 'Checking to make sure it is not a dynamic executable'
|
2016-09-12 10:43:11 +00:00
|
|
|
if ldd target/x86_64-unknown-linux-musl/debug/testme; then
|
2016-04-17 11:41:55 +00:00
|
|
|
echo 'Executable is not static!' 1>&2
|
|
|
|
echo 'FAIL.' 1>&2
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
"
|
|
|
|
|
|
|
|
# We're good.
|
|
|
|
echo 'OK. Tests passed.' 1>&2
|