tool/port: add .sparse-git install rule

Following Github support removal for svn [1], dde_rump port fails to
prepare. This commit introduces a new install rule for ports,
'.sparse-git'. It performs a sparse-checkout on the port repository, only
fetching required files.

[1] https://github.blog/2023-01-20-sunsetting-subversion-support/

Co-authored-by: Benjamin Lamowski <benjamin.lamowski@genode-labs.com>

Issue genodelabs#5072
Issue genodelabs/goa#28
This commit is contained in:
Alice Domage
2023-12-05 16:25:48 +01:00
committed by Norman Feske
parent 636f5dda29
commit 74abf8132e
4 changed files with 36 additions and 5 deletions

View File

@@ -40,6 +40,12 @@ check: $(DOWNLOADS)
%.git:
$(VERBOSE)git ls-remote --exit-code $(URL($*)) >/dev/null 2>&1
#
# Check source codes from a Git repository (sparse-checkout)
#
%.sparse-git:
$(VERBOSE)git ls-remote --exit-code $(URL($*)) >/dev/null 2>&1
#
# Check source codes from Subversion repository
#

View File

@@ -167,6 +167,28 @@ _git_dir = $(call _assert,$(DIR($1)),Missing declaration of DIR($*))
cd $$dir && $(GIT) fetch && $(GIT) reset -q --hard HEAD && $(GIT) checkout -q $(REV($*))
##
## Obtain source codes from a Git repository, subdirectory, using sparse-checkout
##
%.sparse-git:
$(VERBOSE)test -n "$(REV($*))" ||\
($(ECHO) "Error: Undefined revision for $*"; false);
$(VERBOSE)test -n "$(URL($*))" ||\
($(ECHO) "Error: Undefined URL for $*"; false);
$(VERBOSE)test -n "$(SPARSE_PATH($*))" ||\
($(ECHO) "Error: Undefined SPARSE_PATH for $*"; false);
$(VERBOSE)dir=$(call _git_dir,$*);\
sparse_sane=$$(echo $(SPARSE_PATH($*)) | sed -e 's-^/--') ;\
test -d $$dir || ( $(MSG_DOWNLOAD)$(URL($*)); \
tmp=$$(mktemp -d); \
git clone --depth 1 --filter=blob:none --sparse $(URL($*)) $$tmp &> >(sed 's/^/$(MSG_GIT)/'); \
$(GIT) -C $$tmp sparse-checkout set $$sparse_sane && \
$(GIT) -C $$tmp checkout -q $(REV($*)); \
mkdir -p $$dir; \
mv $$tmp/$$sparse_sane/* $$dir; rm -rf $$tmp; )
##
## Obtain source codes from Subversion repository
##