summaryrefslogtreecommitdiffstats
path: root/pkg/get
diff options
context:
space:
mode:
authorTomasz Kramkowski <tomasz@kramkow.ski>2023-04-21 23:50:38 +0100
committerTomasz Kramkowski <tomasz@kramkow.ski>2023-04-21 23:50:38 +0100
commit16a36c812fabda812ecf3aaa7f12fa6f44c66b2e (patch)
treeccae60abf8301ae451cfa1f21c33b8a62d5306cf /pkg/get
parentdb091bfd1db36ab66340ccad2eb7b6393a0aa3da (diff)
downloadandroid-jetpack-compose-redo-master.tar.gz
android-jetpack-compose-redo-master.tar.xz
android-jetpack-compose-redo-master.zip
Jetpack Compose and materialHEADmaster
Diffstat (limited to 'pkg/get')
-rw-r--r--pkg/get35
1 files changed, 35 insertions, 0 deletions
diff --git a/pkg/get b/pkg/get
new file mode 100644
index 0000000..a26bec6
--- /dev/null
+++ b/pkg/get
@@ -0,0 +1,35 @@
+#!/usr/bin/env bash
+set -e
+redo-ifchange ../packages.rc ../.vars.rc
+. ../.vars.rc
+. ../packages.rc
+
+set -f
+IFS=:; p=($1); d=(${packages[$1]})
+set +f
+group=${p[0]}
+artifact=${p[1]}
+version=${p[2]}
+packaging=${d[0]}
+repo=${d[1]}
+valid_sum=${d[2]}
+
+hash_file() { sha256sum "$1" 2>/dev/null | cut -d ' ' -f 1; }
+
+if [[ $valid_sum ]] && [[ $(hash_file "$1.$packaging") == "$valid_sum" ]]; then
+ cp "$1.$packaging" "$2"
+ exit
+fi
+
+url=${MAVEN_REPO[$repo]}/${group//.//}/$artifact/$version/$artifact-$version.$packaging
+curl --silent --show-error --fail --output "$2" "$url"
+sum=$(hash_file "$2")
+if [[ $valid_sum ]] && [[ $sum != "$valid_sum" ]]; then
+ printf '%s: checksum mismatch (got: %s)\n' "$pkg" "$sum" >&2
+ rm "$2"
+ exit 1
+fi
+if [[ ! $valid_sum ]]; then
+ printf "sed -i 's/^packages(_[a-z]*){0,1}\\[%s:%s:%s\\]=%s:%s:$/&%s/' packages.rc\n" "$group" "$artifact" "$version" "$packaging" "$repo" "$sum" >&2
+fi
+# vim:ft=bash