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

@ -1 +1 @@
3138648e26b680c38a2ddfcc54bf8a939e3c6065
19d6de3e1210c7f1c033d46d4178694d263cf0c1

View File

@ -1,21 +1,24 @@
LICENSE := BSD
VERSION := git
DOWNLOADS := rump.git backport.svn libc_aarch64.svn libc_riscv.svn
DOWNLOADS := rump.git backport.sparse-git libc_aarch64.sparse-git libc_riscv.sparse-git
URL(rump) := https://github.com/ssumpf/rump.git
DIR(rump) := src/lib/dde_rump
REV(rump) := 28945d1af5f66c98a3884453adf84ede4ca1b702
URL(backport) := https://github.com/justincormack/netbsd-src/trunk/src/sys/arch
URL(backport) := https://github.com/justincormack/netbsd-src
REV(backport) := HEAD
DIR(backport) := src/lib/dde_rump_backport
SPARSE_PATH(backport) := src/sys/arch
URL(libc_aarch64) := https://github.com/justincormack/netbsd-src/trunk/src/common/lib/libc/arch/aarch64/atomic
URL(libc_aarch64) := https://github.com/justincormack/netbsd-src
REV(libc_aarch64) := HEAD
DIR(libc_aarch64) := src/lib/libc/aarch64/atomic
SPARSE_PATH(libc_aarch64) := src/common/lib/libc/arch/aarch64/atomic
URL(libc_riscv) := https://github.com/justincormack/netbsd-src/trunk/src/common/lib/libc/arch/riscv/atomic
URL(libc_riscv) := https://github.com/justincormack/netbsd-src
REV(libc_riscv) := HEAD
DIR(libc_riscv) := src/lib/libc/riscv/atomic
SPARSE_PATH(libc_riscv) := src/common/lib/libc/arch/riscv/atomic
PATCHES := patches/rump.patch patches/aarch64.patch patches/riscv.patch patches/sync.patch

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
##