Skip to content

Commit

Permalink
no-up-no-halt
Browse files Browse the repository at this point in the history
  • Loading branch information
toy committed May 4, 2024
1 parent 522f7d3 commit 6d29b7d
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 43 deletions.
2 changes: 2 additions & 0 deletions README.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,8 @@ Mac OS X binaries and libraries are built on host, others using containers.

```sh
script/run # Build and test all for all oses and architectures
script/run NO_HALT=1 # Don't halt VMs after building
script/run NO_UP=1 # Don't start VMs before building (will fail if not already running)
script/run darwin 64 # Build only platforms matching darwin or 64

make # Build all tools and copy them to vendor/OS-ARCH for current OS and ARCH, then test
Expand Down
89 changes: 46 additions & 43 deletions script/run
Original file line number Diff line number Diff line change
Expand Up @@ -68,54 +68,57 @@ container_build() {

container_name="image_optim_pack-build-$vm"
workdir=/pack
status=$("$container_tool" inspect --format '{{.State.Status}}' "$container_name" 2>/dev/null || true)

if [[ "$status" == "" ]]; then
mount="./_path_:$workdir/_path_"

"$container_tool" \
container create \
--quiet \
--name="$container_name" \
--stop-signal SIGHUP \
-it \
-v "${mount//_path_/Makefile}":ro \
-v "${mount//_path_/checksums.mk}":ro \
-v "${mount//_path_/download}":ro \
-v "${mount//_path_/patches}":ro \
-v "${mount//_path_/build/$vm}" \
-v "${mount//_path_/vendor/$vm}" \
--workdir "$workdir" \
"$image"

"$container_tool" container start "$container_name"

"$container_tool" exec -it "$container_name" bash -ec "
apt update
apt -y install make gcc g++ chrpath perl pkg-config autoconf automake libtool nasm cmake cargo patch
"
fi

if [[ "$status" = @(created|exited) ]]; then
"$container_tool" container start "$container_name"
fi

if [[ "$status" = @(created|exited|running) ]]; then
"$container_tool" exec -it "$container_name" bash -ec "
apt update
apt -y dist-upgrade
rustup update
"
fi

if ! [[ "$status" = @(|created|exited|running) ]]; then
echo "unexpected status $status"
exit 1
if [[ -z "$NO_UP" ]]; then
status=$("$container_tool" inspect --format '{{.State.Status}}' "$container_name" 2>/dev/null || true)

if [[ "$status" == "" ]]; then
mount="./_path_:$workdir/_path_"

"$container_tool" \
container create \
--quiet \
--name="$container_name" \
--stop-signal SIGHUP \
-it \
-v "${mount//_path_/Makefile}":ro \
-v "${mount//_path_/checksums.mk}":ro \
-v "${mount//_path_/download}":ro \
-v "${mount//_path_/patches}":ro \
-v "${mount//_path_/build/$vm}" \
-v "${mount//_path_/vendor/$vm}" \
--workdir "$workdir" \
"$image"

"$container_tool" container start "$container_name"

"$container_tool" exec -it "$container_name" bash -ec "
apt update
apt -y install make gcc g++ chrpath perl pkg-config autoconf automake libtool nasm cmake cargo patch
"
fi

if [[ "$status" = @(created|exited) ]]; then
"$container_tool" container start "$container_name"
fi

if [[ "$status" = @(created|exited|running) ]]; then
"$container_tool" exec -it "$container_name" bash -ec "
apt update
apt -y dist-upgrade
rustup update
"
fi

if ! [[ "$status" = @(|created|exited|running) ]]; then
echo "unexpected status $status"
exit 1
fi
fi

"$container_tool" exec -it "$container_name" make $MAKE_TASK

"$container_tool" container stop "$container_name"
[[ -n "$NO_HALT" ]] || "$container_tool" container stop "$container_name"
}

container_build linux-x86_64 rust

0 comments on commit 6d29b7d

Please sign in to comment.