1 #!/bin/sh2 # 06_build: every process bind in the deploy file has a binary that exists.3 #4 # A container bind is built into its own image and checked by the container5 # gate; 06_build only requires that it names an image. The bind names a plugin6 # id; section 17 rule 9 turns a process bind into a binary name.7 set -eu8 9 root=$(cd "$(dirname "$0")/../../.." && pwd)10 target=${CARGO_TARGET_DIR:-$root/target}11 case "$target" in12 /*) ;;13 *) target=$root/$target ;;14 esac15 export CARGO_TARGET_DIR=$target16 17 "$root/ops/build.sh" release18 19 # One tab-separated row per bind: id, runtime (default process), image.20 bindings() {21 awk '22 function value(line) {23 sub(/^[^=]*=[[:space:]]*"/, "", line)24 sub(/".*$/, "", line)25 return line26 }27 function flush() {28 if (id != "") {29 print id "\t" (runtime == "" ? "process" : runtime) "\t" image30 }31 id = ""; runtime = ""; image = ""32 }33 /^[[:space:]]*\[\[node\.bind\]\]/ { flush(); next }34 /^[[:space:]]*bundle[[:space:]]*=/ { id = value($0); next }35 /^[[:space:]]*runtime[[:space:]]*=/ { runtime = value($0); next }36 /^[[:space:]]*image[[:space:]]*=/ { image = value($0); next }37 END { flush() }38 ' "$1"39 }40 41 check_deploy() {42 deploy=$143 tab=$(printf '\t')44 bindings "$deploy" >"$target/bindings.$$"45 while IFS=$tab read -r id runtime image; do46 [ -n "$id" ] || continue47 case $runtime in48 process)49 name=$(printf '%s' "$id" | tr '/' '-')50 binary="$target/release/inf3r-$name"51 [ -x "$binary" ] || {52 echo "06_build: bind $id has no binary at $binary" >&253 rm -f "$target/bindings.$$"54 exit 155 }56 ;;57 container)58 [ -n "$image" ] || {59 echo "06_build: container bind $id has no image" >&260 rm -f "$target/bindings.$$"61 exit 162 }63 ;;64 *)65 echo "06_build: bind $id has runtime $runtime, not process or container" >&266 rm -f "$target/bindings.$$"67 exit 168 ;;69 esac70 done <"$target/bindings.$$"71 rm -f "$target/bindings.$$"72 }73 74 check_deploy "$root/deploy.toml"75 check_deploy "$root/.f0rge/ci/fixtures/deploy-mixed.toml"