On apk-based distro (Alpine etc.):
( APK_NAME="hello" APK_RELDIR="repository/testdata" && apk index -o TMP.tar.gz \
${APK_RELDIR}/*.apk &>/dev/null && tar xf TMP.tar.gz -O APKINDEX | \
grep -e ^C: -e ^P: | grep -B1 P:${APK_NAME} | head -1 | \
cut -d: -f2 && rm -f TMP.tar.gz )
Using Docker (via distroless.dev/alpine-base
):