summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--package/pkg-download.mk13
1 files changed, 10 insertions, 3 deletions
diff --git a/package/pkg-download.mk b/package/pkg-download.mk
index 6c57244ac..ea01b0530 100644
--- a/package/pkg-download.mk
+++ b/package/pkg-download.mk
@@ -74,12 +74,19 @@ domainseparator=$(if $(1),$(1),/)
################################################################################
# Try a shallow clone - but that only works if the version is a ref (tag or
-# branch). Fall back on a full clone if it's a generic sha1.
+# branch). Before trying to do a shallow clone we check if $($(PKG)_DL_VERSION)
+# is in the list provided by git ls-remote. If not we fall back on a full clone.
+#
+# Messages for the type of clone used are provided to ease debugging in case of
+# problems
define DOWNLOAD_GIT
test -e $(DL_DIR)/$($(PKG)_SOURCE) || \
(pushd $(DL_DIR) > /dev/null && \
- ($(GIT) clone --depth 1 -b $($(PKG)_DL_VERSION) --bare $($(PKG)_SITE) $($(PKG)_BASE_NAME) || \
- $(GIT) clone --bare $($(PKG)_SITE) $($(PKG)_BASE_NAME)) && \
+ ((test `git ls-remote $($(PKG)_SITE) | cut -f 2- | grep $($(PKG)_DL_VERSION)` && \
+ echo "Doing shallow clone" && \
+ $(GIT) clone --depth 1 -b $($(PKG)_DL_VERSION) --bare $($(PKG)_SITE) $($(PKG)_BASE_NAME)) || \
+ (echo "Doing full clone" && \
+ $(GIT) clone --bare $($(PKG)_SITE) $($(PKG)_BASE_NAME))) && \
pushd $($(PKG)_BASE_NAME) > /dev/null && \
$(GIT) archive --format=tar --prefix=$($(PKG)_BASE_NAME)/ $($(PKG)_DL_VERSION) | \
gzip -c > $(DL_DIR)/$($(PKG)_SOURCE) && \