From 77f47b6625fb09e8f6ca993fcda18be3dff008e7 Mon Sep 17 00:00:00 2001 From: jongough <2803240+jongough@users.noreply.github.com> Date: Fri, 4 Jul 2025 08:12:24 +1000 Subject: [PATCH] Update to get 50 entries in list. Move processing to download_xml.sh and make download_xml_bash.sh call this script with information about this change --- download_xml.sh | 45 ++++++++++++++++++++++++-------------- download_xml_bash.sh | 52 ++++---------------------------------------- 2 files changed, 33 insertions(+), 64 deletions(-) diff --git a/download_xml.sh b/download_xml.sh index d626281e4f..ec0ad88a1b 100755 --- a/download_xml.sh +++ b/download_xml.sh @@ -1,36 +1,49 @@ #!/bin/bash if [ "$#" -ne "4" ]; then - echo "Incorrect invocation: Should be download_xml.sh plugin_name plugin_version cloudsmith_user cloudsmith_level" + echo "Incorrect invocation: Should be download_xml.sh cloudsmith_repository plugin_version cloudsmith_user cloudsmith_level" echo "where:" - echo " plugin_name is the name of the plugin, i.e. testplugin_pi" + echo " cloudsmith_repository is the name of the repository on cloudsmith the files are in, i.e. testplugin" echo " plugin_version is the version number, i.e. 1.0.114.0" - echo " cloudsmith_user is the user name associated with the cloudsmith repository, i.e. jon-gough" + echo " cloudsmith_user is the user name associated with the cloudsmith repository, i.e. jon-gough or opencpn" echo " cloudsmith_level is the level of the repository and is one of: prod, beta, alpha" echo "" echo " Full command should look like:" - echo " download_xml.sh testplugin_pi 1.0.114.0 jon-gough alpha" + echo " download_xml.sh testplugin_pi 1.0.114.0 jon-gough prod" + echo " download_xml.sh weather-routing 1.13.8.0 opencpn prod" exit fi -REPO="https://cloudsmith.io/~$3/repos/" -echo "Issuing command: lynx -dump $REPO$1-$4/packages/?q=*$2*.xml | awk {'print $2'} |grep '.xml$' |grep $1-$2" -my_array=() +NAME="$1" +VERSION="$2" +USER="$3" +LEVEL="$4" + +REPO="https://cloudsmith.io/~${USER}/repos/" +echo "Issuing command: wget -q -O - $REPO${NAME}-${LEVEL}/packages/?q=*${VERSION}*.xml" echo "Show current files that match criteria" -ls metadata/$1-$2*xml -la +ls metadata/${NAME}*-*${VERSION}*xml -la echo "Deleting current files that match criteria" -rm metadata/$1-$2*xml +rm metadata/${NAME}*-*${VERSION}*xml echo "Finding files on remote cloudsmith repository" -while IFS= read -r line; do - my_array+=( "$line" ) -done < <( lynx -dump $REPO$1-$4/packages/?q=*$2*.xml | awk {'print $2'} |grep '.xml$' |grep $1-$2 ) - +delimiter="href=\"" +delimiter1=".xml" +my_array=(); +while read -r line; do + if [[ "$line" =~ ^$delimiter && "$line" =~ $delimiter1.$ ]]; then + start=`awk -v a="$line" -v b="$delimiter" 'BEGIN{print index(a,b)}'` + start=$((start + ${#delimiter} - 1)) + end=`awk -v a="$line" -v b="$delimiter1" 'BEGIN{print index(a,b)}'` + end=$((end + 3 - start)) + line=${line:$start:$end} + my_array+=( $line ); + fi +done < <(wget -q -O - "${REPO}${NAME}-${LEVEL}/packages/?q=*${VERSION}*+tag:latest&page_size=50") echo "Downloading files found that match criteria" for URL in "${my_array[@]}" do - echo $URL + echo "URL: $URL" wget --progress=bar:force:noscroll -c $URL -P metadata done echo "Files downloaded" -ls metadata/$1-$2*xml -la - +ls -la metadata/$NAME*-*$VERSION*xml diff --git a/download_xml_bash.sh b/download_xml_bash.sh index 7644a3d68f..040e1880a4 100755 --- a/download_xml_bash.sh +++ b/download_xml_bash.sh @@ -1,49 +1,5 @@ #!/bin/bash - -if [ "$#" -ne "4" ]; then - echo "Incorrect invocation: Should be download_xml_bash.sh cloudsmith_repository plugin_version cloudsmith_user cloudsmith_level" - echo "where:" - echo " cloudsmith_repository is the name of the repository on cloudsmith the files are in, i.e. testplugin" - echo " plugin_version is the version number, i.e. 1.0.114.0" - echo " cloudsmith_user is the user name associated with the cloudsmith repository, i.e. jon-gough or opencpn" - echo " cloudsmith_level is the level of the repository and is one of: prod, beta, alpha" - echo "" - echo " Full command should look like:" - echo " download_xml_bash.sh testplugin_pi 1.0.114.0 jon-gough prod" - echo " download_xml_bash.sh weather-routing 1.13.8.0 opencpn prod" - exit -fi - -NAME="$1" -VERSION="$2" -USER="$3" -LEVEL="$4" - -REPO="https://cloudsmith.io/~${USER}/repos/" -echo "Issuing command: wget -q -O - $REPO${NAME}-${LEVEL}/packages/?q=*${VERSION}*.xml" -echo "Show current files that match criteria" -ls metadata/${NAME}*-*${VERSION}*xml -la -echo "Deleting current files that match criteria" -rm metadata/${NAME}*-*${VERSION}*xml -echo "Finding files on remote cloudsmith repository" -delimiter="href=\"" -delimiter1=".xml" -my_array=(); -while read -r line; do - if [[ "$line" =~ ^$delimiter && "$line" =~ $delimiter1.$ ]]; then - start=`awk -v a="$line" -v b="$delimiter" 'BEGIN{print index(a,b)}'` - start=$((start + ${#delimiter} - 1)) - end=`awk -v a="$line" -v b="$delimiter1" 'BEGIN{print index(a,b)}'` - end=$((end + 3 - start)) - line=${line:$start:$end} - my_array+=( $line ); - fi -done < <(wget -q -O - "${REPO}${NAME}-${LEVEL}/packages/?q=*${VERSION}*") -echo "Downloading files found that match criteria" -for URL in "${my_array[@]}" -do - echo "URL: $URL" - wget --progress=bar:force:noscroll -c $URL -P metadata -done -echo "Files downloaded" -ls -la metadata/$NAME*-*$VERSION*xml +echo "This script is now redundant and calls 'download_xml.sh' to process the request." +read -n 1 -s -p "Press any key to continue..." +bash ./download_xml.sh $* +exit