From 1bd15efef1dfe0fff29a448fb719b5dfc2a0e861 Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz Date: Jan 22 2021 14:19:49 +0000 Subject: Implements ${{DEFAULT,PKG,...}_MIRRORS}. build.sh:build(): define and zero-initialise ${DEFAULT_MIRRORS}. etc/README.md: updated. midipix.env: adds ${DEFAULT_MIRRORS} (https://midipix.org/mirror/ https://midipix.lucioillanes.de/archives/). subr.rtl/rtl_fetch.subr:rtl_fetch_url_wget(): receive and operate on target name and optional list of mirrors. subr/pkg_fetch_download.subr: additionally pass ${PKG_NAME} and ${PKG_MIRRORS} to rtl_fetch_url_wget(). --- diff --git a/build.sh b/build.sh index c089ad6..5797ccd 100755 --- a/build.sh +++ b/build.sh @@ -117,7 +117,7 @@ build() { BUILD_NFAIL=0 BUILD_NFINI=0 BUILD_NSKIP=0 BUILD_PKGS_FAILED="" BUILD_TARGET="" BUILD_USER="" \ DEFAULT_BUILD_CPUS=1 DEFAULT_BUILD_LAST_FAILED_PKG_FNAME="" DEFAULT_BUILD_LOG_FNAME="" \ DEFAULT_BUILD_STEPS="" DEFAULT_BUILD_VARS="" DEFAULT_CLEAR_PREFIX_PATHS="" DEFAULT_GIT_ARGS="" \ - DEFAULT_GITROOT_HEAD DEFAULT_LOG_ENV_VARS="" DEFAULT_TARGET="" DEFAULT_WGET_ARGS="" \ + DEFAULT_GITROOT_HEAD DEFAULT_LOG_ENV_VARS="" DEFAULT_MIRRORS="" DEFAULT_TARGET="" DEFAULT_WGET_ARGS="" \ MIDIPIX_BUILD_PWD=""; DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME=""; EX_PKG_DISPATCH_WAIT=""; if ! . "${0%/*}/subr/build_init.subr"; then _rc=1; printf "Error: failed to source \`${0%/*}/subr/build_init.subr'." >&2; diff --git a/etc/README.md b/etc/README.md index 3ec8522..5e17115 100644 --- a/etc/README.md +++ b/etc/README.md @@ -580,6 +580,7 @@ VERSION`` and/or ``URLS_GIT``, respectively. | MAKEFLAGS_INSTALL_EXTRA | Additional list of ``make(1)`` flags during package ``make(1)`` installation | | MAKEFLAGS_VERBOSITY | Variable-value pair to pass to ``make(1)`` in order to force echo-back of command lines prior to execution | | MAKE_INSTALL_VNAME | Variable name of ``make(1)`` installation destination directory variable during package ``make(1)`` installation | +| MIRRORS | List of package archive mirror base URLs to attempt downloading from; archive files are expected to reside within ``${PKG_NAME}`` subdirs | | NO_CLEAN | Inhibit cleaning of package build directory beneath ``${PKG_BASE_DIR}`` pre-finish | | NO_CLEAN_BASE_DIR | Inhibit cleaning of package build root directory beneath ``${BUILD_WORKDIR}`` | | NO_LOG_VARS | Inhibit logging of build & package variables pre-package build | diff --git a/midipix.env b/midipix.env index c078915..bf26893 100644 --- a/midipix.env +++ b/midipix.env @@ -26,7 +26,7 @@ DEFAULT_BUILD_VARS=" LDFLAGS_CONFIGURE LDFLAGS_CONFIGURE_EXTRA LIBTOOL MAKE \ MAKE_INSTALL_VNAME MAKE_SUBDIRS MAKEFLAGS_BUILD MAKEFLAGS_BUILD_EXTRA \ MAKEFLAGS_INSTALL MAKEFLAGS_INSTALL_EXTRA MAKEFLAGS_VERBOSITY \ - NO_CLEAN NO_CLEAN_BASE_DIR NO_LOG_VARS PYTHON PATCHES_EXTRA \ + MIRRORS NO_CLEAN NO_CLEAN_BASE_DIR NO_LOG_VARS PYTHON PATCHES_EXTRA \ PKG_CONFIG PKG_CONFIG_LIBDIR PKGLIST_DISABLE PREFIX RANLIB \ RPM_DISABLE SHA256SUM SUBDIR TARGET URL URLS_GIT VERSION"; @@ -65,6 +65,10 @@ DEFAULT_BUILD_VARS=" ARCH BUILD_KIND BUILD_DLCACHEDIR BUILD_WORKDIR DEFAULT_GITROOT HOME PATH PREFIX PREFIX_CROSS PREFIX_MINGW32 PREFIX_MINIPIX PREFIX_NATIVE PREFIX_RPM USER"}; +: ${DEFAULT_MIRRORS:=" +https://midipix.org/mirror/ +https://midipix.lucioillanes.de/archives/ +"}; # Default flags & variables : ${DEFAULT_BUILD_CPUS:=}; diff --git a/subr.rtl/rtl_fetch.subr b/subr.rtl/rtl_fetch.subr index d0ad54b..64eac92 100644 --- a/subr.rtl/rtl_fetch.subr +++ b/subr.rtl/rtl_fetch.subr @@ -53,12 +53,16 @@ rtl_fetch_urls_git() { # N.B. URLs ($1) may contain `?' or '&' characters. rtl_fetch_url_wget() { - local _urls="${1}" _sha256sum_src="${2}" _target_fname="${3}" _rc=0 _target_fname_full=""\ - _url="" _urls_count=0; + local _urls="${1}" _sha256sum_src="${2}" _target_fname="${3}" _target_name="${4}" _mirrors="${5:-}" \ + _rc=0 _target_fname_full="" _url="" _url_base="" _urls_count=0 _urls_full=""; if [ "${ARG_FETCH_FORCE}" = "offline" ]; then return 0; - else _urls_count="$(rtl_llength "${_urls}")"; - for _url in ${_urls}; do + else _urls_full="${_urls}"; + for _url_base in ${_mirrors}; do + _urls_full="$(rtl_lconcat "${_urls_full}" "${_url_base%/}/${_target_name}/${_target_fname}")"; + done; + _urls_count="$(rtl_llength "${_urls_full}")"; + for _url in ${_urls_full}; do if [ -z "${_target_fname}" ]; then _target_fname="$(rtl_basename "${_url}")"; fi; diff --git a/subr/pkg_fetch_download.subr b/subr/pkg_fetch_download.subr index 57cad8b..bfe358f 100644 --- a/subr/pkg_fetch_download.subr +++ b/subr/pkg_fetch_download.subr @@ -4,7 +4,7 @@ pkg_fetch_download() { if [ -n "${PKG_URL:-}" ]; then - if ! rtl_fetch_url_wget "${PKG_URL}" "${PKG_SHA256SUM}" "${PKG_FNAME}"; then + if ! rtl_fetch_url_wget "${PKG_URL}" "${PKG_SHA256SUM}" "${PKG_FNAME}" "${PKG_NAME}" "${PKG_MIRRORS}"; then return 1; fi; fi;