From fe9c032aace3b32baedff9c44a0d048f26f5414f Mon Sep 17 00:00:00 2001 From: RadxaYuntian <95260730+RadxaYuntian@users.noreply.github.com> Date: Wed, 8 Dec 2021 23:15:26 +0800 Subject: [PATCH] Add new options to handle mirror selection better (#3325) * Add new option UBOOT_MIRROR to select mainline U-Boot mirror - set to `github` to use mirror provided by GitHub, the same as `USE_GITHUB_UBOOT_MIRROR=yes`. - set to `gitee` to use mirror provided by Gitee, a Chinese git service. - leave it unset to use offical `source.denx.de`. * Add GITHUB_MIRROR option Usage similar to UBOOT_MIRROR. * Add REGIONAL_MIRROR option Chinese users (the main user of mirror options) can have use this one instead of configure many different options. --- lib/configuration.sh | 48 +++++++++++++++++++++++++++++++++++++++----- lib/general.sh | 3 +++ 2 files changed, 46 insertions(+), 5 deletions(-) diff --git a/lib/configuration.sh b/lib/configuration.sh index 7e95aedf30..032e5dc30f 100644 --- a/lib/configuration.sh +++ b/lib/configuration.sh @@ -67,6 +67,20 @@ fi # small SD card with kernel, boot script and .dtb/.bin files [[ $ROOTFS_TYPE == nfs ]] && FIXED_IMAGE_SIZE=64 +# Since we are having too many options for mirror management, +# then here is yet another mirror related option. +# Respecting user's override in case a mirror is unreachable. +case $REGIONAL_MIRROR in + china) + [[ -z $USE_MAINLINE_GOOGLE_MIRROR ]] && [[ -z $MAINLINE_MIRROR ]] && MAINLINE_MIRROR=tuna + [[ -z $USE_GITHUB_UBOOT_MIRROR ]] && [[ -z $UBOOT_MIRROR ]] && UBOOT_MIRROR=gitee + [[ -z $GITHUB_MIRROR ]] && GITHUB_MIRROR=fastgit + [[ -z $DOWNLOAD_MIRROR ]] && DOWNLOAD_MIRROR=china + ;; + *) + ;; +esac + # used by multiple sources - reduce code duplication [[ $USE_MAINLINE_GOOGLE_MIRROR == yes ]] && MAINLINE_MIRROR=google @@ -91,13 +105,37 @@ esac MAINLINE_KERNEL_DIR='linux-mainline' -if [[ $USE_GITHUB_UBOOT_MIRROR == yes ]]; then - MAINLINE_UBOOT_SOURCE='https://github.com/u-boot/u-boot' -else - MAINLINE_UBOOT_SOURCE='https://source.denx.de/u-boot/u-boot.git' -fi +[[ $USE_GITHUB_UBOOT_MIRROR == yes ]] && UBOOT_MIRROR=github + +case $UBOOT_MIRROR in + gitee) + MAINLINE_UBOOT_SOURCE='https://gitee.com/mirrors/u-boot.git' + ;; + github) + MAINLINE_UBOOT_SOURCE='https://github.com/u-boot/u-boot' + ;; + *) + MAINLINE_UBOOT_SOURCE='https://source.denx.de/u-boot/u-boot.git' + ;; +esac + MAINLINE_UBOOT_DIR='u-boot' +case $GITHUB_MIRROR in + fastgit) + GITHUB_SOURCE='https://hub.fastgit.org/' + ;; + gitclone) + GITHUB_SOURCE='https://gitclone.com/github.com/' + ;; + cnpmjs) + GITHUB_SOURCE='https://github.com.cnpmjs.org/' + ;; + *) + GITHUB_SOURCE='https://github.com/' + ;; +esac + # Let's set default data if not defined in board configuration above [[ -z $OFFSET ]] && OFFSET=4 # offset to 1st partition (we use 4MiB boundaries by default) ARCH=armhf diff --git a/lib/general.sh b/lib/general.sh index 187042e96a..c861eec721 100644 --- a/lib/general.sh +++ b/lib/general.sh @@ -425,6 +425,9 @@ fetch_from_repo() local ref=$3 local ref_subdir=$4 + # Set GitHub mirror before anything else touches $url + url=${url//'https://github.com/'/$GITHUB_SOURCE} + if [ "$dir" == "linux-mainline" ] && [[ "$LINUXFAMILY" == sunxi* ]]; then unset LINUXSOURCEDIR LINUXSOURCEDIR="linux-mainline/$KERNEL_VERSION_LEVEL"