From 7ecdc828248020ec59f2763401d8931f3b78bbc0 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 20 Nov 2022 20:16:29 -0800 Subject: [PATCH] install.sh: Improve brew integration and documentation --- ci/release/_install.sh | 22 ++++++++++++++++++---- docs/CONTRIBUTING.md | 3 +-- docs/INSTALL.md | 17 +---------------- install.sh | 22 ++++++++++++++++++---- 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/ci/release/_install.sh b/ci/release/_install.sh index f1432a555..524d317be 100755 --- a/ci/release/_install.sh +++ b/ci/release/_install.sh @@ -162,8 +162,13 @@ main() { detect) case "$OS" in macos) - log "detected macOS, using homebrew for (un)installation" - METHOD=homebrew + if command -v brew >/dev/null; then + log "detected macOS with homebrew, using homebrew for (un)installation" + METHOD=homebrew + else + warn "detected macOS without homebrew, falling back to --method=standalone" + METHOD=standalone + fi ;; *) warn "unrecognized OS $OS, falling back to --method=standalone" @@ -181,8 +186,14 @@ main() { if [ -n "${UNINSTALL-}" ]; then uninstall + if [ -n "${DRY_RUN-}" ]; then + log "Rerun without --dry-run to execute printed commands and perform uninstall." + fi else install + if [ -n "${DRY_RUN-}" ]; then + log "Rerun without --dry-run to execute printed commands and perform install." + fi fi } @@ -313,7 +324,6 @@ install_d2_brew() { header "installing d2 with homebrew" sh_c brew tap terrastruct/d2 sh_c brew install d2 - sh_c brew test d2 } install_tala_standalone() { @@ -361,7 +371,6 @@ install_tala_brew() { header "installing tala with homebrew" sh_c brew tap terrastruct/d2 sh_c brew install tala - sh_c brew test tala } uninstall() { @@ -492,4 +501,9 @@ fetch_gh() { sh_c mv "$file.inprogress" "$file" } +brew() { + # Makes brew sane. + HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 command brew "$@" +} + main "$@" diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index 41c82f89a..bd8851e7b 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -65,8 +65,7 @@ language. Sometimes it gives controversial sentences -- don't use those. Script to generate one line of random text: ``` ipsum1() { - fortune | head -n1 | sed 's/^ *//;s/ *$//' | tr -d '\n' | pbcopy - echo "$(pbpaste -Prefer txt)" + fortune | head -n1 | sed 's/^ *//;s/ *$//' | tr -d '\n' | tee /dev/stderr | pbcopy } ``` diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 38fa92748..57828c04e 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -1,7 +1,6 @@ # install -This file documents how the install.sh script installs d2 and how you can -manually install yourself. +This file documents all the ways by which you can install d2. @@ -59,8 +58,6 @@ The install script places the standalone release into `$PREFIX/lib/d2/d2-/dev/null; then + log "detected macOS with homebrew, using homebrew for (un)installation" + METHOD=homebrew + else + warn "detected macOS without homebrew, falling back to --method=standalone" + METHOD=standalone + fi ;; *) warn "unrecognized OS $OS, falling back to --method=standalone" @@ -645,8 +650,14 @@ main() { if [ -n "${UNINSTALL-}" ]; then uninstall + if [ -n "${DRY_RUN-}" ]; then + log "Rerun without --dry-run to execute printed commands and perform uninstall." + fi else install + if [ -n "${DRY_RUN-}" ]; then + log "Rerun without --dry-run to execute printed commands and perform install." + fi fi } @@ -777,7 +788,6 @@ install_d2_brew() { header "installing d2 with homebrew" sh_c brew tap terrastruct/d2 sh_c brew install d2 - sh_c brew test d2 } install_tala_standalone() { @@ -825,7 +835,6 @@ install_tala_brew() { header "installing tala with homebrew" sh_c brew tap terrastruct/d2 sh_c brew install tala - sh_c brew test tala } uninstall() { @@ -956,4 +965,9 @@ fetch_gh() { sh_c mv "$file.inprogress" "$file" } +brew() { + # Makes brew sane. + HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 command brew "$@" +} + main "$@"