-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·50 lines (42 loc) · 1.37 KB
/
run.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/usr/bin/env bash
set -euxo pipefail
SCRIPT_DIR="$(cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
OUT_DIR="${SCRIPT_DIR}/out"
REVISION=$(git --work-tree="${SCRIPT_DIR}"/../ --git-dir="${SCRIPT_DIR}"/../.git \
rev-parse HEAD)
BUILDER_TAG_NAME="rust-overlay_builder:$REVISION"
#########################################
# Self test
#########################################
err() {
echo -e "$*"
exit 1
}
self_test() {
# Check sha256sum
command -v sha256sum &>/dev/null || \
err "sha256sum not found. Please install coreutils first"
# Check docker
docker info &>/dev/null || \
err "Make sure docker daemon is running"
}
# Let's go
self_test
echo "Creating builder container image..."
# Need to run docker build in script's parent directory
cd "${SCRIPT_DIR}/.."
docker build --platform linux/amd64 -f "${SCRIPT_DIR}/Dockerfile" -t "${BUILDER_TAG_NAME}" .
docker images "${BUILDER_TAG_NAME}"
rm -rf "${OUT_DIR}"
mkdir -p "${OUT_DIR}"
echo "Cross building started..."
docker run --platform linux/amd64 -v "${OUT_DIR}":/tmp/out_rust-overlay --rm -i "${BUILDER_TAG_NAME}" << CMD
mkdir -p /tmp/out_rust-overlay && \
cp -r /build/rust-cross-build-nix/out/* /tmp/out_rust-overlay/
CMD
echo
echo "============ HELLO-RANDOM ARTIFACTS INFO ============"
echo "Artifacts created in ${OUT_DIR}/"
echo "sha256sums:"
sha256sum "${OUT_DIR}"/hello-random* | sort -k2
echo