add git archive function

This commit is contained in:
Lance Vick 2023-06-22 02:50:56 -07:00
parent 88527fc427
commit 09c3a79d8c
Signed by: lrvick
GPG Key ID: 8E47A1EC35A1551D
1 changed files with 18 additions and 3 deletions

View File

@ -252,18 +252,33 @@ define fetch_file
" "
endef endef
define git_archive
$(call git_clone,$(CACHE_DIR)/$(notdir $@),$(1),$(2)) \
&& tar \
-C $(CACHE_DIR)/$(notdir $@) \
--sort=name \
--mtime='@0' \
--owner=0 \
--group=0 \
--numeric-owner \
-cvf - \
. \
| gzip -n > $@ \
&& rm -rf $(CACHE_DIR)/$(notdir $@)
endef
define git_clone define git_clone
[ -d $(1) ] || \ [ -d $(1) ] || \
mkdir -p $(FETCH_DIR) && \ mkdir -p $(1).tmp && \
mkdir $(1).tmp && \
git -C $(1).tmp init && \ git -C $(1).tmp init && \
git -C $(1).tmp remote add origin $(2) && \ git -C $(1).tmp remote add origin $(2) && \
git -C $(1).tmp fetch origin $(3) && \ git -C $(1).tmp fetch origin $(3) && \
git -C $(1).tmp -c advice.detachedHead=false checkout $(3) && \ git -C $(1).tmp -c advice.detachedHead=false checkout $(3) && \
git -C $(1).tmp submodule update --init && \
git -C $(1).tmp rev-parse --verify HEAD | grep -q $(3) || { \ git -C $(1).tmp rev-parse --verify HEAD | grep -q $(3) || { \
echo 'Error: Git ref/branch collision.'; exit 1; \ echo 'Error: Git ref/branch collision.'; exit 1; \
} && \ } && \
mv $(1).tmp $(1); mv $(1).tmp $(1)
endef endef
define apply_patches define apply_patches