summarylogtreecommitdiffstats
path: root/generate-pkgbuild.sh
diff options
context:
space:
mode:
authorGerman Lashevich2020-07-13 11:58:37 +0200
committerGerman Lashevich2020-07-13 11:58:37 +0200
commitc128155733663babe93e656c55553203aae260b0 (patch)
tree4db0155cb8d3f41ab6d42a04997f4448bcd891b2 /generate-pkgbuild.sh
parent72361c4b74cb87f7cb2d9e2ea5266da924acb9fe (diff)
downloadaur-c128155733663babe93e656c55553203aae260b0.tar.gz
Automatically detect channel name
Diffstat (limited to 'generate-pkgbuild.sh')
-rwxr-xr-xgenerate-pkgbuild.sh21
1 files changed, 18 insertions, 3 deletions
diff --git a/generate-pkgbuild.sh b/generate-pkgbuild.sh
index 400d48382ad9..778179b04f2b 100755
--- a/generate-pkgbuild.sh
+++ b/generate-pkgbuild.sh
@@ -3,7 +3,11 @@
set -e
usage() {
- echo "Usage: $0 {stable|regular|rapid}" >&2
+ echo "Usage: $0 [{stable|regular|rapid}]" >&2
+}
+
+get_channel() {
+ echo ${PWD##*/} | grep -Eo '\-(stable|regular|rapid)-' | tr -d '\-'
}
get_major_version() {
@@ -13,6 +17,19 @@ get_major_version() {
| rg -o 'v?(\d\.\d+)\.\d+-gke\.\d+' -r '$1'
}
+if [ -z "$1" ];
+then
+ readonly channel=$(get_channel)
+ echo "Channel is not specified, automatically detected: $channel"
+ read -p "Is it correct? y/n " yn
+ case $yn in
+ [Yy]* ) set -- "$channel" ;;
+ * ) usage; exit 0;;
+ esac
+else
+ readonly channel=$1
+fi
+
case $1 in
-h)
usage
@@ -30,8 +47,6 @@ esac
readonly pkgname=kubectl
-readonly channel=$1
-
readonly version=$(curl -sSL "https://gcsweb.k8s.io/gcs/kubernetes-release/release/stable-$major_version.txt")
readonly arches=$( \