From 74abf8132e26f3ec1193c565a8c0e7e6c276f401 Mon Sep 17 00:00:00 2001 From: Alice Domage Date: Tue, 5 Dec 2023 16:25:48 +0100 Subject: [PATCH] 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 Issue genodelabs#5072 Issue genodelabs/goa#28 --- repos/dde_rump/ports/dde_rump.hash | 2 +- repos/dde_rump/ports/dde_rump.port | 11 +++++++---- tool/ports/mk/check.mk | 6 ++++++ tool/ports/mk/install.mk | 22 ++++++++++++++++++++++ 4 files changed, 36 insertions(+), 5 deletions(-) diff --git a/repos/dde_rump/ports/dde_rump.hash b/repos/dde_rump/ports/dde_rump.hash index fcabb717d9..ee15a3e2ae 100644 --- a/repos/dde_rump/ports/dde_rump.hash +++ b/repos/dde_rump/ports/dde_rump.hash @@ -1 +1 @@ -3138648e26b680c38a2ddfcc54bf8a939e3c6065 +19d6de3e1210c7f1c033d46d4178694d263cf0c1 diff --git a/repos/dde_rump/ports/dde_rump.port b/repos/dde_rump/ports/dde_rump.port index 17b3ee9e13..17dd137828 100644 --- a/repos/dde_rump/ports/dde_rump.port +++ b/repos/dde_rump/ports/dde_rump.port @@ -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 diff --git a/tool/ports/mk/check.mk b/tool/ports/mk/check.mk index 63afaeb289..159c839339 100644 --- a/tool/ports/mk/check.mk +++ b/tool/ports/mk/check.mk @@ -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 # diff --git a/tool/ports/mk/install.mk b/tool/ports/mk/install.mk index 77d9e24fe5..d02743b3f3 100644 --- a/tool/ports/mk/install.mk +++ b/tool/ports/mk/install.mk @@ -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 ##