From b63b9baad8f41274e844c11bceb38efd20dfb3fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Sat, 23 Jan 2021 10:49:42 +0000 Subject: Implements setting up & fetching from mirrors. etc/pkgtool.usage: updated. etc/README.md: updated. pkgtool.sh:pkgtoolp_mirror{,_fetch}(): initial implementation. subr/pkg_fetch_download.subr: default to empty ${PKG_MIRRORS}. subr/pkg_fetch_download.subr: factor out ${ARG_FETCH_FORCE} check and ${BUILD_DLCACHEDIR}. subr/pkgtool_init.subr: updated. subr.rtl/rtl_fetch.subr:rtl_fetch_urls_{git,wget}(): factor out ${ARG_FETCH_FORCE} check and ${BUILD_DLCACHEDIR}; minor cleanup. subr.rtl/rtl_fetch.subr:rtl_fetch_url_wget(): return vs. exit on fatal failure. subr.rtl/rtl_fetch.subr:rtlp_fetch_url_git(): copy only if ${_cache_dname} != ${_tgtdir}. subr.rtl/rtl_fetch.subr:rtlp_fetch_url_git(): return if unable to git-clone(1). subr.rtl/rtl_fetch.subr:{rtlp_fetch_url_git,rtl_fetch_urls_git}(): implement Git repository mirroring. vars/{gcc,python[23]{,_host}}.vars: updated. --- subr/pkg_fetch_download.subr | 16 +++++++++------- subr/pkgtool_init.subr | 14 ++++++++------ 2 files changed, 17 insertions(+), 13 deletions(-) (limited to 'subr') diff --git a/subr/pkg_fetch_download.subr b/subr/pkg_fetch_download.subr index bfe358f6..75d49f50 100644 --- a/subr/pkg_fetch_download.subr +++ b/subr/pkg_fetch_download.subr @@ -3,14 +3,16 @@ # pkg_fetch_download() { - if [ -n "${PKG_URL:-}" ]; then - if ! rtl_fetch_url_wget "${PKG_URL}" "${PKG_SHA256SUM}" "${PKG_FNAME}" "${PKG_NAME}" "${PKG_MIRRORS}"; then - return 1; + if [ "${ARG_FETCH_FORCE:-}" != "offline" ]; then + if [ -n "${PKG_URL:-}" ]; then + if ! rtl_fetch_url_wget "${PKG_URL}" "${PKG_SHA256SUM}" "${BUILD_DLCACHEDIR}" "${PKG_FNAME}" "${PKG_NAME}" "${PKG_MIRRORS:-}"; then + return 1; + fi; fi; - fi; - if [ -n "${PKG_URLS_GIT:-}" ]; then - if ! rtl_fetch_urls_git "${PKG_BASE_DIR}" ${PKG_URLS_GIT}; then - return 1; + if [ -n "${PKG_URLS_GIT:-}" ]; then + if ! rtl_fetch_urls_git "${BUILD_DLCACHEDIR}" "${PKG_BASE_DIR}" "${PKG_MIRRORS:-}" ${PKG_URLS_GIT}; then + return 1; + fi; fi; fi; }; diff --git a/subr/pkgtool_init.subr b/subr/pkgtool_init.subr index 76e1c33b..b33795ee 100644 --- a/subr/pkgtool_init.subr +++ b/subr/pkgtool_init.subr @@ -4,12 +4,12 @@ pkgtoolp_init_args() { local _rc=0; _status=""; - if [ "$((${ARG_INFO:-0} + ${ARG_RDEPENDS:-0} + ${ARG_SHELL:-0} + ${ARG_TARBALL:-0}))" -gt 1 ]; then + if [ "$((${ARG_INFO:-0} + ${ARG_MIRROR:-0} + ${ARG_RDEPENDS:-0} + ${ARG_SHELL:-0} + ${ARG_TARBALL:-0}))" -gt 1 ]; then cat etc/pkgtool.usage; _rc=1; _status="Error: only one of -i, -r, -s, or -t must be specified."; - elif [ "$((${ARG_INFO:-0} + ${ARG_RDEPENDS:-0} + ${ARG_SHELL:-0} + ${ARG_TARBALL:-0}))" -eq 0 ]\ + elif [ "$((${ARG_INFO:-0} + ${ARG_MIRROR:-0} + ${ARG_RDEPENDS:-0} + ${ARG_SHELL:-0} + ${ARG_TARBALL:-0}))" -eq 0 ]\ && [ -z "${ARG_RESTART_AT}" ]\ && [ "${ARG_UPDATE_DIFF:-0}" -eq 0 ]; then - cat etc/pkgtool.usage; _rc=1; _status="Error: one of -i, -r, -s, or -t must be specified."; + cat etc/pkgtool.usage; _rc=1; _status="Error: one of -i, -m, -r, -s, or -t must be specified."; else _rc=0; export TMP="${BUILD_WORKDIR}" TMPDIR="${BUILD_WORKDIR}"; fi; return "${_rc}"; }; @@ -30,7 +30,7 @@ pkgtoolp_init_env() { pkgtoolp_init_getopts() { local _opt="" _shiftfl=0 _rc=0 OPTIND=0; _status=""; : ${ARCH:="nt64"}; : ${BUILD_KIND:="debug"}; - ARG_INFO=0; ARG_RESTART_AT=""; ARG_RDEPENDS=0; ARG_UPDATE_DIFF=0; ARG_SHELL=0; ARG_TARBALL=0; + ARG_INFO=0; ARG_MIRROR=0; ARG_MIRROR_DNAME=""; ARG_RESTART_AT=""; ARG_RDEPENDS=0; ARG_UPDATE_DIFF=0; ARG_SHELL=0; ARG_TARBALL=0; while [ "${#}" -gt 0 ]; do case "${1}" in --update-diff) @@ -48,12 +48,13 @@ pkgtoolp_init_getopts() { break; elif [ "${_shiftfl:-0}" -gt 0 ]; then shift "${_shiftfl}"; continue; - elif getopts a:b:hirst _opt; then + elif getopts a:b:him:rst _opt; then case "${_opt}" in a) ARCH="${OPTARG}"; ;; b) BUILD_KIND="${OPTARG}"; ;; h) cat etc/pkgtool.usage; exit 0; ;; i) ARG_INFO=1; ;; + m) ARG_MIRROR=1; ARG_MIRROR_DNAME="${OPTARG}"; ;; r) ARG_RDEPENDS=1; ;; s) ARG_SHELL=1; ;; t) ARG_TARBALL=1; ;; @@ -66,7 +67,8 @@ pkgtoolp_init_getopts() { fi; done; if [ "${_rc}" -eq 0 ]; then - if [ -z "${PKGTOOL_PKG_NAME:-}" ]; then + if [ -z "${PKGTOOL_PKG_NAME:-}" ]\ + && [ "${ARG_MIRROR:-0}" -eq 0 ]; then _rc=1; _status="Error: missing package name."; else export PKGTOOL_PKG_NAME; fi; -- cgit v1.2.3