e617d8fcfd4f783bfe7e3b569c620532ab43858d
markd
  Wed Jun 10 01:32:09 2026 -0700
fix #37741 Source zip (jksrc.zip) build broken: htslib submodule not included by git archive

diff --git src/submodules/submoduleSetup src/submodules/submoduleSetup
index ee2fe9670f0..68f8e01b849 100755
--- src/submodules/submoduleSetup
+++ src/submodules/submoduleSetup
@@ -1,19 +1,27 @@
 #!/bin/bash
 set -beEu -o pipefail
 
 # Do required submodule setup to support building the browser
 # If need, do the submodule init, also check from having remains of
 # old htslib copy to deal with switch from old version.
 
 if [ -e htslib ] ; then
     echo "*********************************************************************" >&2
     echo "Note: an outdated kent/src/htslib/ exists in the working tree." >&2
     echo "      It is no longer used and can be removed."   >&2
     echo "*********************************************************************" >&2
 fi
 
 if [ !  -e submodules/htslib/.git -o ! -e submodules/htslib/htscodecs/.git ] ; then
+    if git rev-parse --is-inside-work-tree >/dev/null 2>&1 ; then
         echo "Note: initializing git submodules" >&2
         (set -x; git -c protocol.file.allow=always submodule update --init --recursive)
+    elif [ ! -e submodules/htslib/hts.c -o ! -e submodules/htslib/htscodecs/htscodecs/htscodecs.c ] ; then
+        # not a git working tree (e.g. a source release); submodule sources must
+        # already be present since they can not be checked out without git.
+        echo "Error: submodule sources under submodules/htslib are missing and this" >&2
+        echo "       is not a git working tree, so they can not be initialized." >&2
+        exit 1
+    fi
 fi