42 lines
938 B
Bash
Executable File
42 lines
938 B
Bash
Executable File
#! /bin/bash
|
|
|
|
set -ex
|
|
|
|
BUILD_START=$SECONDS
|
|
|
|
format_duration() {
|
|
local total="$1"
|
|
printf '%02d:%02d:%02d' "$((total / 3600))" "$(((total % 3600) / 60))" "$((total % 60))"
|
|
}
|
|
|
|
run_phase() {
|
|
local name="$1"
|
|
shift
|
|
local start=$SECONDS
|
|
local status=0
|
|
|
|
printf '====> starting %s\n' "$name"
|
|
if "$@"; then
|
|
status=0
|
|
else
|
|
status=$?
|
|
fi
|
|
printf '====> finished %s in %s\n' "$name" "$(format_duration "$((SECONDS - start))")"
|
|
return "$status"
|
|
}
|
|
|
|
finish() {
|
|
local status=$?
|
|
run_phase cleanup scripts/cleanup.sh || true
|
|
printf '====> total build.sh time: %s\n' "$(format_duration "$((SECONDS - BUILD_START))")"
|
|
exit "$status"
|
|
}
|
|
trap finish EXIT
|
|
|
|
run_phase check-qemu scripts/check-qemu.sh
|
|
run_phase download-base scripts/download-base.sh
|
|
run_phase setup-mount scripts/setup-mount.sh
|
|
run_phase copy-files scripts/copy-files.sh
|
|
run_phase update-configtxt scripts/update-configtxt.sh
|
|
run_phase build-in-chroot scripts/build-in-chroot.sh
|