From 700987b21638e96a7c3a17935f55140b1fa9a6d6 Mon Sep 17 00:00:00 2001 From: Scott Little Date: Wed, 2 Aug 2023 12:36:18 -0400 Subject: [PATCH] downloader fails to follow redirects A redirect is used to aid in the transition from mirror.starlingx.cengn.ca to mirror.starlingx.windriver.com. Curl does not support redirects, unless the -L/--location options are specified. Partial-Bug: 2028678 Signed-off-by: Scott Little Change-Id: I963c4cdbf4239b853ac4240d76b7f75e6e9c1173 --- centos-mirror-tools/dl_rpms_from_url.sh | 2 +- centos-mirror-tools/download_mirror.sh | 2 +- centos-mirror-tools/utils.sh | 6 +++--- toCOPY/generate-centos-repo.sh | 9 +++++---- 4 files changed, 10 insertions(+), 9 deletions(-) diff --git a/centos-mirror-tools/dl_rpms_from_url.sh b/centos-mirror-tools/dl_rpms_from_url.sh index 6a0d7057..a005fe41 100755 --- a/centos-mirror-tools/dl_rpms_from_url.sh +++ b/centos-mirror-tools/dl_rpms_from_url.sh @@ -138,7 +138,7 @@ download () { dl_result=1 download_url="$_url/$rpm_name" - download_cmd="curl --silent --output $rpm_name ${download_url}" + download_cmd="curl -L --silent --output $rpm_name ${download_url}" echo "Looking for $rpm_name" echo "--> run: $download_cmd" diff --git a/centos-mirror-tools/download_mirror.sh b/centos-mirror-tools/download_mirror.sh index 60f8291d..14e74d94 100755 --- a/centos-mirror-tools/download_mirror.sh +++ b/centos-mirror-tools/download_mirror.sh @@ -315,7 +315,7 @@ for key in "${!layer_pkg_urls[@]}"; do url="${layer_pkg_urls[${key}]}" name_from_url=$(url_to_file_name $url) list="${rpms_from_layer_build_dir}/${name_from_url}" - curl --silent --fail ${url} > ${list} || + curl -L --silent --fail ${url} > ${list} || if [ $? -ne 0 ]; then echo "ERROR: Failed to download from url: ${url}" exit 1 diff --git a/centos-mirror-tools/utils.sh b/centos-mirror-tools/utils.sh index 20cff687..f8b81d82 100644 --- a/centos-mirror-tools/utils.sh +++ b/centos-mirror-tools/utils.sh @@ -53,9 +53,9 @@ get_download_file_command() { _opts+=" -O" fi if [[ "$_name" == http?(s)://* ]]; then - _ret="curl $_opts $_name" + _ret="curl -L $_opts $_name" else - _ret="curl $_opts $(koji_url $_name)" + _ret="curl -L $_opts $(koji_url $_name)" fi echo "$_ret" } @@ -81,7 +81,7 @@ download_file() { else local _dest_file="$(basename "$1")" fi - if curl $_opts -o "${_dest_file}.dl_part" "$1" ; then + if curl -L $_opts -o "${_dest_file}.dl_part" "$1" ; then \mv -fT "${_dest_file}.dl_part" "${_dest_file}" return 0 fi diff --git a/toCOPY/generate-centos-repo.sh b/toCOPY/generate-centos-repo.sh index 9bdb7fcf..699f69ff 100755 --- a/toCOPY/generate-centos-repo.sh +++ b/toCOPY/generate-centos-repo.sh @@ -221,7 +221,7 @@ for key in "${!layer_image_inc_urls[@]}"; do done if [ ! -f ${inc_file_dir}/${list} ]; then - curl --silent --fail ${url} > ${inc_file_dir}/${list} + curl -L --silent --fail ${url} > ${inc_file_dir}/${list} if [ $? -ne 0 ]; then echo "ERROR: Failed to download from url '${url}'" exit 1 @@ -252,7 +252,7 @@ for key in "${!layer_wheels_inc_urls[@]}"; do done if [ ! -f ${wheels_file_dir}/${list} ]; then - curl --silent --fail ${url} > ${wheels_file_dir}/${list} + curl -L --silent --fail ${url} > ${wheels_file_dir}/${list} if [ $? -ne 0 ]; then echo "ERROR: Failed to download from url '${url}'" exit 1 @@ -292,7 +292,7 @@ for key in "${!layer_image_inc_urls[@]}"; do done if [ ! -f ${build_info_file_dir}/${list} ]; then - curl --silent --fail ${url} > ${build_info_file_dir}/${list} + curl -L --silent --fail ${url} > ${build_info_file_dir}/${list} if [ $? -ne 0 ]; then echo "WARNING: Failed to download from url '${url}'" fi @@ -319,7 +319,7 @@ for key in "${!layer_pkg_urls[@]}"; do done if [ ! -f ${lst_file_dir}/${list} ]; then - curl --silent --fail ${url} > ${lst_file_dir}/${list} + curl -L --silent --fail ${url} > ${lst_file_dir}/${list} if [ $? -ne 0 ]; then echo "ERROR: Failed to download from url '${url}'" exit 1 @@ -360,6 +360,7 @@ process_lst_file () { local lst_file="${1}" local dest_dir="${2}" + echo "process_lst_file: ${1} ${2}" grep -v "^#" ${lst_file_dir}/${lst_file} | while IFS="#" read rpmname extrafields; do if [ -z "${rpmname}" ]; then continue