summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xobsmirror.sh/obsmirror.sh30
1 files changed, 18 insertions, 12 deletions
diff --git a/obsmirror.sh/obsmirror.sh b/obsmirror.sh/obsmirror.sh
index 86180f3..2e913fb 100755
--- a/obsmirror.sh/obsmirror.sh
+++ b/obsmirror.sh/obsmirror.sh
@@ -58,18 +58,24 @@ test -z "${thisuser}" && thisuser=obsmirror
mkdir -p "${workdir}" ; chmod "0755" "${workdir}" ; chown "${thisuser}:$( id -G "${thisuser}" | awk '{print $1}' )" "${workdir}"
cd "${workdir}"
- # get mirrorlist of Packages.gz file and find the one that lists the most packages
- step1="$( curl -s -L "${inurl}/Packages.gz.mirrorlist" )"
- options="$( echo "${step1}" | grep -oE 'href="[^"]+">' | awk '!x[$0]++' | sed -r -e 's/^href="//;' -e 's/">$//;' | grep -iE '^(ht|f)tps?:\/\/.*Packages\.gz$' )"
- results="$(
- for entry in ${options} ; do
- curl -s -L "${entry}" | zgrep -cE '^Package:' | sed -r -e "s@\$@ ${entry}@;"
- done )"
- topresult_line="$( echo "${results}" | sort -nr | head -n1 | sed -r -e 's/\/Packages\.gz$//;' )"
- topresult_packagecount="$( echo "${topresult_line}" | awk '{print $1}' )"
- topresult="$( echo "${topresult_line}" | awk '{print $2}' )"
- echo "USING ${topresult} with ${topresult_packagecount} packages" 1>&2
- inurl="${topresult}"
+ test "${use_top_result}" = "yes" && {
+ # get mirrorlist of Packages.gz file and find the one that lists the most packages
+ step1="$( curl -s -L "${inurl}/Packages.gz.mirrorlist" )"
+ options="$( echo "${step1}" | grep -oE 'href="[^"]+">' | awk '!x[$0]++' | sed -r -e 's/^href="//;' -e 's/">$//;' | grep -iE '^(ht|f)tps?:\/\/.*Packages\.gz$' )"
+ echo "${options}" 1>&2
+ results="$(
+ for entry in ${options} ; do
+ # use package count
+ #curl -s -L "${entry}" | zgrep -cE '^Package:' | sed -r -e "s@\$@ ${entry}@;"
+ # use last modified timestamp of Packages.gz file
+ wget --content-disposition --quiet "${entry}" -O tmpfile.$$ ; find tmpfile.$$ -printf "%T@ ${entry}\n"
+ done ; rm tmpfile.$$ )"
+ topresult_line="$( echo "${results}" | sort -nr | head -n1 | sed -r -e 's/\/Packages\.gz$//;' )"
+ topresult_packagecount="$( echo "${topresult_line}" | awk '{print $1}' )"
+ topresult="$( echo "${topresult_line}" | awk '{print $2}' )"
+ echo "USING ${topresult} with ${topresult_packagecount} packages" 1>&2
+ inurl="${topresult}"
+ }
step1="$( curl -s -L "${inurl}" )"
echo "${step1}" | parse_obs_page_and_subdirs "${inurl}" "${tmpfile}"
bgstack15