ops/control-manifests.sh 1.4 KiB 45 lines Raw
1 #!/bin/sh2 # Stage the manifests of one or more bundles for a control container.3 #4 # A control image already carries the mock manifests. A host that serves other5 # bundles mounts a manifest-only tree over /opt/inf3r/plugins-extra; this script6 # creates that tree without copying a plugin binary, an engine library, an7 # engine tree, or a weight.8 set -eu9 10 root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)11 target=${CARGO_TARGET_DIR:-$root/target}12 case "$target" in13     /*) ;;14     *) target=$root/$target ;;15 esac16 out=$target/control-manifests17 18 usage() {19     printf 'usage: ops/control-manifests.sh <bundle-id> [...]\n' >&220     exit 221 }22 die() {23     printf 'control-manifests: %s\n' "$*" >&224     exit 125 }26 27 [ "$#" -gt 0 ] || usage28 rm -rf "$out"29 mkdir -p "$out"30 for bundle in "$@"; do31     dir=$root/plugins/$bundle32     [ -f "$dir/bundle.toml" ] || die "$bundle has no bundle.toml"33     [ -f "$dir/target.toml" ] || die "$bundle has no target.toml"34     install -d "$out/$bundle"35     install -m 0644 "$dir/bundle.toml" "$dir/target.toml" "$out/$bundle/"36     [ ! -f "$dir/BUNDLE.md" ] || install -m 0644 "$dir/BUNDLE.md" "$out/$bundle/"37     if [ -d "$dir/models" ]; then38         install -d "$out/$bundle/models"39         for file in "$dir"/models/*.toml; do40             [ -f "$file" ] || continue41             install -m 0644 "$file" "$out/$bundle/models/"42         done43     fi44 done45 printf 'manifests %s\n' "$out"