endef
# Only intends to be called as a submethod from other DownloadMethod
+#
+# We first clone, checkout and then we generate a tar using the
+# git archive command to apply any rules of .gitattributes
+# To keep consistency with github generated tar archive, we default
+# the short hash to 8 (default is 7). (for git log related usage)
define DownloadMethod/rawgit
echo "Checking out files from the git repository..."; \
mkdir -p $(TMP_DIR)/dl && \
rm -rf $(SUBDIR) && \
[ \! -d $(SUBDIR) ] && \
git clone $(OPTS) $(URL) $(SUBDIR) && \
- (cd $(SUBDIR) && git checkout $(VERSION) && \
- $(if $(filter skip,$(SUBMODULES)),true,git submodule update --init --recursive -- $(SUBMODULES))) && \
- echo "Packing checkout..." && \
+ (cd $(SUBDIR) && git checkout $(VERSION)) && \
export TAR_TIMESTAMP=`cd $(SUBDIR) && git log -1 --format='@%ct'` && \
- rm -rf $(SUBDIR)/.git && \
+ echo "Generating formal git archive (apply .gitattributes rules)" && \
+ (cd $(SUBDIR) && git config core.abbrev 8 && \
+ git archive --format=tar HEAD --output=../$(SUBDIR).tar.git) && \
+ $(if $(filter skip,$(SUBMODULES)),true,$(TAR) --ignore-failed-read -C $(SUBDIR) -f $(SUBDIR).tar.git -r .git .gitmodules 2>/dev/null) && \
+ rm -rf $(SUBDIR) && mkdir $(SUBDIR) && \
+ $(TAR) -C $(SUBDIR) -xf $(SUBDIR).tar.git && \
+ (cd $(SUBDIR) && $(if $(filter skip,$(SUBMODULES)),true,git submodule update --init --recursive -- $(SUBMODULES) && \
+ rm -rf .git .gitmodules)) && \
+ echo "Packing checkout..." && \
$(call dl_tar_pack,$(TMP_DIR)/dl/$(FILE),$(SUBDIR)) && \
mv $(TMP_DIR)/dl/$(FILE) $(DL_DIR)/ && \
rm -rf $(SUBDIR);