star-build

Automation tool for project installation
git clone git://git.meso-star.fr/star-build.git
Log | Files | Refs | README | LICENSE

commit d2fcd2db3aa21a47ad6b16d1a4d732bf23bac0bd
parent 2e4abc28ae2c06be1848ef9b068cfa7b7650c684
Author: Vincent Forest <vincent.forest@meso-star.com>
Date:   Wed, 17 Jul 2024 17:22:42 +0200

Start of support for offline builds

Offline building allows you to rely on the star-build infrastructure
even if access to the network is not possible, as may be the case, for
example, behind a VPN or a router that is too strict.

Addition of the NETWORK macro, which can be used to configure whether
the build should be done online or offline. If the build is offline, the
new MIRROR macro defines the local directory where precompiled binaries
and source repositories are retrieved. This directory must first be
populated with the resources required by the BUILD in question, by
invoking the new 'mirror' Makefile target.

Not all projects yet support offline building. Currently only spkg, git,
Random123, libcyaml and clipper2 have been updated to support it.

Diffstat:
MMakefile | 5+++++
Mconfig.mk | 32++++++++++++++++++++++++++++----
Msrc/clipper2.mk.in | 11++++++++++-
Msrc/git.mk.in | 7+++++++
Msrc/libcyaml.mk.in | 11++++++++++-
Msrc/random123.mk.in | 11++++++++++-
Msrc/spkg.mk.in | 7+++++--
7 files changed, 75 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile @@ -39,11 +39,16 @@ distclean: makefile uninstall: makefile @$(MAKE) -f $(MK) -f Makefile uninstall_all +mirror: makefile + mkdir -p "$(MIRROR)" + @$(MAKE) -f $(MK) -f Makefile mirror_all + # Generate the Makefile of the build makefile: cache @echo "Setup $(MK)" @{ \ printf 'CACHE = %s\n' "$(CACHE)"; \ + printf 'MIRROR = %s\n' "$(MIRROR)"; \ PATH="src:$${PATH}" USE_SIMD=$(USE_SIMD) \ $(SHELL) "$(BUILD)"; \ } > "$(MK)" diff --git a/config.mk b/config.mk @@ -39,7 +39,31 @@ CACHE = ./cache # download archives of precompiled binaries. CURL_OPT = --fail --retry 3 -# List of repositories -REPO = https://gitlab.com/meso-star -REPO_BIN = https://www.meso-star.com/packages/v0.4/ -REPO_VAPLV = https://gitlab.com/vaplv +# Define the state of the network, either ONLINE or OFFLINE. +# If the network is OFFLINE, the sources and precompiled binaries are +# retrieved from the local MIRROR directory, which must therefore +# contain the expected data. To do this, simply run the 'mirror' target +# to download the source repositories and binary packages locally: +# +# make NETWORK=ONLINE mirror +# +NETWORK = ONLINE + +# Directory in which to download the data required for offline +# build of the project (see the NETWORK macro) +MIRROR = ./mirror + +# URLs for online repositories +REPO_ONLINE = https://gitlab.com/meso-star +REPO_BIN_ONLINE = https://www.meso-star.com/packages/v0.4/ +REPO_VAPLV_ONLINE = https://gitlab.com/vaplv + +# URLs for offline repositories +REPO_OFFLINE = $(MIRROR) +REPO_BIN_OFFLINE = $(MIRROR) +REPO_VAPLV_OFFLINE = $(MIRROR) + +# List of repositories to use depending on the state of the network +REPO = $(REPO_$(NETWORK)) +REPO_BIN = "file://$$(pwd)/$(REPO_BIN_$(NETWORK))" +REPO_VAPLV = $(REPO_VAPLV_$(NETWORK)) diff --git a/src/clipper2.mk.in b/src/clipper2.mk.in @@ -15,7 +15,9 @@ # Configuration macros CLIPPER2_TAG=@TAG@ -CLIPPER2_URL=https://github.com/AngusJohnson/Clipper2 +CLIPPER2_URL_ONLINE = https://github.com/AngusJohnson/Clipper2 +CLIPPER2_URL_OFFLINE = $(MIRROR)/Clipper2 +CLIPPER2_URL = $(CLIPPER2_URL_$(NETWORK)) # Helper macros CLIPPER2_DIR=$(CACHE)/clipper2/$(CLIPPER2_TAG) @@ -71,7 +73,14 @@ uninstall_clipper2: distclean_clipper2: rm -rf "$(CLIPPER2_DIR)" +mirror_clipper2: + @repo="$$(echo "$(CLIPPER2_URL)" | sed 's/[\/]\{0,\}$$//g')" && \ + repo="$(MIRROR)/$${repo##*/}" && \ + rm -rf "$${repo}" && \ + git clone --mirror $(CLIPPER2_URL) "$${repo}" + clean_all: clean_clipper2 distclean_all: distclean_clipper2 install_all: clipper2 uninstall_all: uninstall_clipper2 +mirror_all: mirror_clipper2 diff --git a/src/git.mk.in b/src/git.mk.in @@ -33,7 +33,14 @@ uninstall_@NAME@: fetch_@NAME@ prefix distclean_@NAME@: rm -rf "$(CACHE)/@NAME@/@TAG@" +mirror_@NAME@: + @repo="$$(echo "@URL@" | sed 's/[\/]\{0,\}$$//g')" && \ + repo="$(MIRROR)/$${repo##*/}" && \ + rm -rf "$${repo}" && \ + git clone --mirror @URL@ "$${repo}" + clean_all: clean_@NAME@ distclean_all: distclean_@NAME@ install_all: @NAME@ uninstall_all: uninstall_@NAME@ +mirror_all: mirror_@NAME@ diff --git a/src/libcyaml.mk.in b/src/libcyaml.mk.in @@ -15,7 +15,9 @@ # Configuration macros LIBCYAML_TAG=@TAG@ -LIBCYAML_URL=https://github.com/tlsa/libcyaml +LIBCYAML_URL_ONLINE = https://github.com/tlsa/libcyaml +LIBCYAML_URL_OFFLINE = $(MIRROR)/libcyaml +LIBCYAML_URL = $(LIBCYAML_URL_$(NETWORK)) # Helper macros LIBCYAML_DIR=$(CACHE)/libcyaml/$(LIBCYAML_TAG) @@ -47,7 +49,14 @@ uninstall_libcyaml: distclean_libcyaml: rm -rf "$(LIBCYAML_DIR)" +mirror_libcyaml: + @repo="$$(echo "$(LIBCYAML_URL)" | sed 's/[\/]\{0,\}$$//g')" && \ + repo="$(MIRROR)/$${repo##*/}" && \ + rm -rf "$${repo}" && \ + git clone --mirror $(LIBCYAML_URL) "$${repo}" + clean_all: clean_libcyaml distclean_all: distclean_libcyaml install_all: libcyaml uninstall_all: uninstall_libcyaml +mirror_all: mirror_libcyaml diff --git a/src/random123.mk.in b/src/random123.mk.in @@ -16,7 +16,9 @@ # Configuration macros RANDOM123_VERSION=@VERSION@ RANDOM123_TAG=@TAG@ -RANDOM123_URL=https://github.com/DEShawResearch/random123 +RANDOM123_URL_ONLINE=https://github.com/DEShawResearch/random123 +RANDOM123_URL_OFFLINE=$(MIRROR)/random123 +RANDOM123_URL = $(RANDOM123_URL_$(NETWORK)) # Helper macros RANDOM123_DIR=$(CACHE)/random123/$(RANDOM123_TAG) @@ -79,6 +81,13 @@ uninstall_random123: prefix distclean_random123: rm -rf "$(RANDOM123_DIR)" +mirror_random123: + @repo="$$(echo "$(RANDOM123_URL)" | sed 's/[\/]\{0,\}$$//g')" && \ + repo="$(MIRROR)/$${repo##*/}" && \ + rm -rf "$${repo}" && \ + git clone --mirror $(RANDOM123_URL) "$${repo}" + distclean_all: distclean_random123 install_all: random123 uninstall_all: uninstall_random123 +mirror_all: mirror_random123 diff --git a/src/spkg.mk.in b/src/spkg.mk.in @@ -15,10 +15,10 @@ cp "@ARCH@.sha512sum" "$${prefix}/share/spkg/"; \ fi -$(CACHE)/@ARCH@.tgz: +$(CACHE)/@ARCH@.tgz $(MIRROR)/@ARCH@.tgz: curl $(CURL_OPT) -o $@ "@PATH@/@ARCH@.tgz" -$(CACHE)/@ARCH@.sha512sum: +$(CACHE)/@ARCH@.sha512sum $(MIRROR)/@ARCH@.sha512sum: curl $(CURL_OPT) -o $@ "@PATH@/@ARCH@.sha512sum" uninstall_@NAME@: prefix @@ -30,6 +30,9 @@ uninstall_@NAME@: prefix distclean_@NAME@: rm -rf "$(CACHE)/@ARCH@.tgz" "$(CACHE)/@ARCH@.sha512sum" +mirror_@NAME@: $(MIRROR)/@ARCH@.tgz $(MIRROR)/@ARCH@.sha512sum + distclean_all: distclean_@NAME@ install_all: @NAME@ uninstall_all: uninstall_@NAME@ +mirror_all: mirror_@NAME@