diff --git a/share/shpkg/shpkg.subr b/share/shpkg/shpkg.subr
index 55fcb96..11a984b 100644
--- a/share/shpkg/shpkg.subr
+++ b/share/shpkg/shpkg.subr
@@ -169,6 +169,10 @@ shpkg_checkout () {
if [ "x${SHPKG_REPO_DIR}" = "x" ]; then
err 1 "shpkg_checkout: unknown repo: $SHPKG_REPO"
fi
+ SHPKG_REPO_SRC_DIR="${SHPKG_SRC_DIR}/${SHPKG_REPO_DIR}"
+ if ! [ -d "${SHPKG_REPO_SRC_DIR}" ]; then
+ ( verbose 2 shpkg_clone "${SHPKG_REPO}"; )
+ fi
( verbose 1 cd "${SHPKG_SRC_DIR}/${SHPKG_REPO_DIR}" &&
verbose 1 git fetch origin "$TREE" &&
verbose 1 git checkout "$TREE" &&