diff options
Diffstat (limited to '.extras/test-build')
| -rwxr-xr-x | .extras/test-build | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/.extras/test-build b/.extras/test-build index d830d69..8057683 100755 --- a/.extras/test-build +++ b/.extras/test-build @@ -183,13 +183,33 @@ declare -A _vstate=() declare -A FETCH_DEPS=() # prog -> 1: resolve via sbopkg in-container # Is a prog already present in the container base? Kept as a callback so the -# pure topo logic stays testable. Default: not in base. -# ponytail: stub returns false, so a dep that the full-install image already -# provides currently reads as UNMET and needs a `drop:` override. Real fix -# belongs with the image-builder work: query the image's package db (e.g. -# `docker run --rm $ACTIVE_IMAGE ls /var/log/packages | grep`) once per run -# and consult it here. Deferred until the image exists (Task 10 / image-builder). -installed_in_base() { return 1; } +# pure topo logic stays testable. +# +# Populated lazily from the active image's package db on first call: each entry +# in /var/log/packages is named <name>-<ver>-<arch>-<build>, so strip the last +# three dash-fields to get the bare package name and match the SBo token +# against that. TB_BASE_PKGS can be pre-seeded by tests to bypass docker. +declare -A TB_BASE_PKGS=() +TB_BASE_LOADED="${TB_BASE_LOADED:-0}" + +load_base_pkgs() { + [[ "$TB_BASE_LOADED" == "1" ]] && return 0 + TB_BASE_LOADED=1 + [[ -n "$ACTIVE_IMAGE" ]] || return 0 + local entry name + while IFS= read -r entry; do + [[ -n "$entry" ]] || continue + # strip trailing -<ver>-<arch>-<build> + name="${entry%-*-*-*}" + TB_BASE_PKGS["$name"]=1 + done < <(docker run --rm "$ACTIVE_IMAGE" \ + /bin/sh -c 'ls /var/log/packages' 2>/dev/null) +} + +installed_in_base() { + load_base_pkgs + [[ -n "${TB_BASE_PKGS[$1]:-}" ]] +} _resolve_visit() { local dir="$1" parent="$2" |
