Skip to content

Commit 9cbf447

Browse files
authored
Merge pull request #1295 from jongough/Alpha
Update to cater for new cloudsmith page format
2 parents 16d3d19 + 16e7f2f commit 9cbf447

1 file changed

Lines changed: 13 additions & 13 deletions

File tree

download_xml_bash.sh

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,36 +14,36 @@ if [ "$#" -ne "4" ]; then
1414
exit
1515
fi
1616

17-
REPO="https://cloudsmith.io/~$3/repos/"
18-
echo "Issuing command: wget -q -O - $REPO$1-$4/packages/?q=*$2*.xml"
19-
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"
2024
echo "Show current files that match criteria"
21-
ls metadata/$1*-$2*xml -la
25+
ls metadata/${NAME}*-*${VERSION}*xml -la
2226
echo "Deleting current files that match criteria"
23-
rm metadata/$1*-$2*xml
27+
rm metadata/${NAME}*-*${VERSION}*xml
2428
echo "Finding files on remote cloudsmith repository"
2529
delimiter="href=\""
26-
delimiter1=".xml\" title"
30+
delimiter1=".xml"
2731
my_array=();
2832
while read -r line; do
29-
if [[ $line == *$delimiter* ]] && [[ $line == *$delimiter1* ]]; then
30-
echo "line: $line"
33+
if [[ "$line" =~ ^$delimiter && "$line" =~ $delimiter1.$ ]]; then
3134
start=`awk -v a="$line" -v b="$delimiter" 'BEGIN{print index(a,b)}'`
3235
start=$((start + ${#delimiter} - 1))
3336
end=`awk -v a="$line" -v b="$delimiter1" 'BEGIN{print index(a,b)}'`
3437
end=$((end + 3 - start))
3538
line=${line:$start:$end}
3639
my_array+=( $line );
37-
echo "found: $line"
3840
fi
39-
done < <(wget -q -O - "$REPO$1-$4/packages/?q=*$2*xml+tag:latest&page_size=50")
40-
41+
done < <(wget -q -O - "${REPO}${NAME}-${LEVEL}/packages/?q=*${VERSION}*")
4142
echo "Downloading files found that match criteria"
4243
for URL in "${my_array[@]}"
4344
do
4445
echo "URL: $URL"
4546
wget --progress=bar:force:noscroll -c $URL -P metadata
4647
done
4748
echo "Files downloaded"
48-
ls metadata/$1*-$2*xml -la
49-
49+
ls -la metadata/$NAME*-*$VERSION*xml

0 commit comments

Comments
 (0)