Fix `check_remote_jdk_configs.sh` for archives with nested layouts

Instead of looking at just the top level directory, we find the first '/bin' directory (or symlink).

Context from https://github.com/bazelbuild/rules_java/pull/370

`Note that Azul changed the layout of the macOS tar.gz archives after 21.0.9: they now contain a macOS application bundle with the JDK under Contents/Home instead of a flat JDK image (the Zulu 25 macOS archives are still flat). The strip_prefix of the two macOS entries therefore descends into Contents/Home.`

(ignore-relnotes)

PiperOrigin-RevId: 960249078
Change-Id: I7b4e93dfc395985a672795204cad10fba20fcf93
diff --git a/test/check_remote_jdk_configs.sh b/test/check_remote_jdk_configs.sh
index b1c509f..09930be 100755
--- a/test/check_remote_jdk_configs.sh
+++ b/test/check_remote_jdk_configs.sh
@@ -27,15 +27,16 @@
       exit 1
     fi
     if [[ -z "${url##*.tar.gz}" ]]; then
-      root_dir=$(tar ztf ${TMP_FILE} --exclude='*/*')
+      bin_dir=$(tar ztf ${TMP_FILE} | egrep '/bin(|/)$' | sort | head -n1)
     elif [[ -z "${url##*.zip}" ]]; then
-      root_dir=$(unzip -Z1 ${TMP_FILE} | head -n1)
+      bin_dir=$(unzip -Z1 ${TMP_FILE} | egrep '/bin(|/)/$' | sort | head -n1)
     else
       echo "ERROR: unexpected archive type for ${name}"
       exit 1
     fi
-    if [ "${root_dir}" != "${strip_prefix}/" ]; then
-      echo "ERROR: bad strip_prefix for ${name}, wanted: ${strip_prefix}/, got: ${root_dir}"
+    root_dir="${bin_dir%/bin*}"
+    if [ "${root_dir}" != "${strip_prefix}" ]; then
+      echo "ERROR: bad strip_prefix for ${name}, wanted: ${strip_prefix}, got: ${root_dir}"
       exit 1
     fi
     if [[ -n "${mirror_url}" ]]; then