From d20a448227dc682c4bffa89ab0753255a12cc13e Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Fri, 2 Dec 2022 12:10:11 -0800 Subject: [PATCH] ci: Update --- ci/release/template/scripts/lib.sh | 39 +++++++++++++++++++----------- ci/sub | 2 +- install.sh | 39 +++++++++++++++++++----------- 3 files changed, 51 insertions(+), 29 deletions(-) diff --git a/ci/release/template/scripts/lib.sh b/ci/release/template/scripts/lib.sh index 88e9c2972..68e45059d 100644 --- a/ci/release/template/scripts/lib.sh +++ b/ci/release/template/scripts/lib.sh @@ -23,7 +23,12 @@ pick() { shift seed_file="$(mktemp)" - echo "$seed" > "$seed_file" + echo "$seed" >"$seed_file" + # We add 16 more bytes to the seed file for sufficient entropy. Otherwise Cygwin's sort + # for example complains and I'm sure there are more platforms that would too. + # edit: nvm disabled for now, we don't use Cygwin anyway, we use MinGW who has a sort + # that behaves correctly. + # echo "================" >"$seed_file" while [ $# -gt 0 ]; do echo "$1" @@ -85,11 +90,16 @@ _echo() { printf '%s\n' "$*" } -get_rand_color() { # 1-6 are regular and 9-14 are bright. - # 1,2 and 9,10 are red and green but we use those for success and failure. - pick "$*" 1 2 3 4 5 6 \ - 9 10 11 12 13 14 +get_rand_color() { + colors="" + ncolors=$(command tput colors) + if [ "$ncolors" -ge 8 ]; then + colors="$colors 1 2 3 4 5 6" + elif [ "$ncolors" -ge 16 ]; then + colors="$colors 9 10 11 12 13 14" + fi + pick "$*" $colors } echop() { @@ -301,27 +311,28 @@ LIB_RELEASE=1 goos() { case $1 in - macos) echo darwin ;; - *) echo $1 ;; + macos) echo darwin;; + *) echo $1;; esac } os() { uname=$(uname) case $uname in - Linux) echo linux ;; - Darwin) echo macos ;; - FreeBSD) echo freebsd ;; - *) echo "$uname" ;; + Linux) echo linux;; + Darwin) echo macos;; + FreeBSD) echo freebsd;; + CYGWIN_NT*|MINGW32_NT*) echo windows;; + *) echo "$uname";; esac } arch() { uname_m=$(uname -m) case $uname_m in - aarch64) echo arm64 ;; - x86_64) echo amd64 ;; - *) echo "$uname_m" ;; + aarch64) echo arm64;; + x86_64) echo amd64;; + *) echo "$uname_m";; esac } diff --git a/ci/sub b/ci/sub index 4d9ab8f8d..98bd6a2a9 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit 4d9ab8f8d7fb298a7b1b948b8910986b9703f2bd +Subproject commit 98bd6a2a9a1a4e4051326c0f32d158570fe05977 diff --git a/install.sh b/install.sh index ac96ca52e..4a3b74ed4 100755 --- a/install.sh +++ b/install.sh @@ -28,7 +28,12 @@ pick() { shift seed_file="$(mktemp)" - echo "$seed" > "$seed_file" + echo "$seed" >"$seed_file" + # We add 16 more bytes to the seed file for sufficient entropy. Otherwise Cygwin's sort + # for example complains and I'm sure there are more platforms that would too. + # edit: nvm disabled for now, we don't use Cygwin anyway, we use MinGW who has a sort + # that behaves correctly. + # echo "================" >"$seed_file" while [ $# -gt 0 ]; do echo "$1" @@ -90,11 +95,16 @@ _echo() { printf '%s\n' "$*" } -get_rand_color() { # 1-6 are regular and 9-14 are bright. - # 1,2 and 9,10 are red and green but we use those for success and failure. - pick "$*" 1 2 3 4 5 6 \ - 9 10 11 12 13 14 +get_rand_color() { + colors="" + ncolors=$(command tput colors) + if [ "$ncolors" -ge 8 ]; then + colors="$colors 1 2 3 4 5 6" + elif [ "$ncolors" -ge 16 ]; then + colors="$colors 9 10 11 12 13 14" + fi + pick "$*" $colors } echop() { @@ -437,27 +447,28 @@ LIB_RELEASE=1 goos() { case $1 in - macos) echo darwin ;; - *) echo $1 ;; + macos) echo darwin;; + *) echo $1;; esac } os() { uname=$(uname) case $uname in - Linux) echo linux ;; - Darwin) echo macos ;; - FreeBSD) echo freebsd ;; - *) echo "$uname" ;; + Linux) echo linux;; + Darwin) echo macos;; + FreeBSD) echo freebsd;; + CYGWIN_NT*|MINGW32_NT*) echo windows;; + *) echo "$uname";; esac } arch() { uname_m=$(uname -m) case $uname_m in - aarch64) echo arm64 ;; - x86_64) echo amd64 ;; - *) echo "$uname_m" ;; + aarch64) echo arm64;; + x86_64) echo amd64;; + *) echo "$uname_m";; esac }