Skip to content

Commit 77f47b6

Browse files
committed
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
1 parent 5364eb0 commit 77f47b6

2 files changed

Lines changed: 33 additions & 64 deletions

File tree

download_xml.sh

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,49 @@
11
#!/bin/bash
22

33
if [ "$#" -ne "4" ]; then
4-
echo "Incorrect invocation: Should be download_xml.sh plugin_name plugin_version cloudsmith_user cloudsmith_level"
4+
echo "Incorrect invocation: Should be download_xml.sh cloudsmith_repository plugin_version cloudsmith_user cloudsmith_level"
55
echo "where:"
6-
echo " plugin_name is the name of the plugin, i.e. testplugin_pi"
6+
echo " cloudsmith_repository is the name of the repository on cloudsmith the files are in, i.e. testplugin"
77
echo " plugin_version is the version number, i.e. 1.0.114.0"
8-
echo " cloudsmith_user is the user name associated with the cloudsmith repository, i.e. jon-gough"
8+
echo " cloudsmith_user is the user name associated with the cloudsmith repository, i.e. jon-gough or opencpn"
99
echo " cloudsmith_level is the level of the repository and is one of: prod, beta, alpha"
1010
echo ""
1111
echo " Full command should look like:"
12-
echo " download_xml.sh testplugin_pi 1.0.114.0 jon-gough alpha"
12+
echo " download_xml.sh testplugin_pi 1.0.114.0 jon-gough prod"
13+
echo " download_xml.sh weather-routing 1.13.8.0 opencpn prod"
1314
exit
1415
fi
1516

16-
REPO="https://cloudsmith.io/~$3/repos/"
17-
echo "Issuing command: lynx -dump $REPO$1-$4/packages/?q=*$2*.xml | awk {'print $2'} |grep '.xml$' |grep $1-$2"
18-
my_array=()
17+
NAME="$1"
18+
VERSION="$2"
19+
USER="$3"
20+
LEVEL="$4"
21+
22+
REPO="https://cloudsmith.io/~${USER}/repos/"
23+
echo "Issuing command: wget -q -O - $REPO${NAME}-${LEVEL}/packages/?q=*${VERSION}*.xml"
1924
echo "Show current files that match criteria"
20-
ls metadata/$1-$2*xml -la
25+
ls metadata/${NAME}*-*${VERSION}*xml -la
2126
echo "Deleting current files that match criteria"
22-
rm metadata/$1-$2*xml
27+
rm metadata/${NAME}*-*${VERSION}*xml
2328
echo "Finding files on remote cloudsmith repository"
24-
while IFS= read -r line; do
25-
my_array+=( "$line" )
26-
done < <( lynx -dump $REPO$1-$4/packages/?q=*$2*.xml | awk {'print $2'} |grep '.xml$' |grep $1-$2 )
27-
29+
delimiter="href=\""
30+
delimiter1=".xml"
31+
my_array=();
32+
while read -r line; do
33+
if [[ "$line" =~ ^$delimiter && "$line" =~ $delimiter1.$ ]]; then
34+
start=`awk -v a="$line" -v b="$delimiter" 'BEGIN{print index(a,b)}'`
35+
start=$((start + ${#delimiter} - 1))
36+
end=`awk -v a="$line" -v b="$delimiter1" 'BEGIN{print index(a,b)}'`
37+
end=$((end + 3 - start))
38+
line=${line:$start:$end}
39+
my_array+=( $line );
40+
fi
41+
done < <(wget -q -O - "${REPO}${NAME}-${LEVEL}/packages/?q=*${VERSION}*+tag:latest&page_size=50")
2842
echo "Downloading files found that match criteria"
2943
for URL in "${my_array[@]}"
3044
do
31-
echo $URL
45+
echo "URL: $URL"
3246
wget --progress=bar:force:noscroll -c $URL -P metadata
3347
done
3448
echo "Files downloaded"
35-
ls metadata/$1-$2*xml -la
36-
49+
ls -la metadata/$NAME*-*$VERSION*xml

download_xml_bash.sh

Lines changed: 4 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,5 @@
11
#!/bin/bash
2-
3-
if [ "$#" -ne "4" ]; then
4-
echo "Incorrect invocation: Should be download_xml_bash.sh cloudsmith_repository plugin_version cloudsmith_user cloudsmith_level"
5-
echo "where:"
6-
echo " cloudsmith_repository is the name of the repository on cloudsmith the files are in, i.e. testplugin"
7-
echo " plugin_version is the version number, i.e. 1.0.114.0"
8-
echo " cloudsmith_user is the user name associated with the cloudsmith repository, i.e. jon-gough or opencpn"
9-
echo " cloudsmith_level is the level of the repository and is one of: prod, beta, alpha"
10-
echo ""
11-
echo " Full command should look like:"
12-
echo " download_xml_bash.sh testplugin_pi 1.0.114.0 jon-gough prod"
13-
echo " download_xml_bash.sh weather-routing 1.13.8.0 opencpn prod"
14-
exit
15-
fi
16-
17-
NAME="$1"
18-
VERSION="$2"
19-
USER="$3"
20-
LEVEL="$4"
21-
22-
REPO="https://cloudsmith.io/~${USER}/repos/"
23-
echo "Issuing command: wget -q -O - $REPO${NAME}-${LEVEL}/packages/?q=*${VERSION}*.xml"
24-
echo "Show current files that match criteria"
25-
ls metadata/${NAME}*-*${VERSION}*xml -la
26-
echo "Deleting current files that match criteria"
27-
rm metadata/${NAME}*-*${VERSION}*xml
28-
echo "Finding files on remote cloudsmith repository"
29-
delimiter="href=\""
30-
delimiter1=".xml"
31-
my_array=();
32-
while read -r line; do
33-
if [[ "$line" =~ ^$delimiter && "$line" =~ $delimiter1.$ ]]; then
34-
start=`awk -v a="$line" -v b="$delimiter" 'BEGIN{print index(a,b)}'`
35-
start=$((start + ${#delimiter} - 1))
36-
end=`awk -v a="$line" -v b="$delimiter1" 'BEGIN{print index(a,b)}'`
37-
end=$((end + 3 - start))
38-
line=${line:$start:$end}
39-
my_array+=( $line );
40-
fi
41-
done < <(wget -q -O - "${REPO}${NAME}-${LEVEL}/packages/?q=*${VERSION}*")
42-
echo "Downloading files found that match criteria"
43-
for URL in "${my_array[@]}"
44-
do
45-
echo "URL: $URL"
46-
wget --progress=bar:force:noscroll -c $URL -P metadata
47-
done
48-
echo "Files downloaded"
49-
ls -la metadata/$NAME*-*$VERSION*xml
2+
echo "This script is now redundant and calls 'download_xml.sh' to process the request."
3+
read -n 1 -s -p "Press any key to continue..."
4+
bash ./download_xml.sh $*
5+
exit

0 commit comments

Comments
 (0)