From 1df14730e065f97614ecea61e8c310634ef3f00e Mon Sep 17 00:00:00 2001 From: Louis St-Amour Date: Thu, 11 Jun 2020 19:28:14 -0400 Subject: [PATCH] fix: Update kubectl-kui location on macOS to Kui.app/Contents/Resources This change is suggested because I'm submitting a Cask to Homebrew and would like to include the kubectl-kui binary in /usr/local/bin directly while installing the application to /Applications. Additionally, I ran by habit "kubectl kui get pods" from inside Kui and it appeared to hang indefinitely. This script prevents that, though it doesn't produce pretty output like Kui normally would. Signed-off-by: Louis St-Amour --- packages/builder/dist/electron/build.sh | 37 ++++++++++++++++++++----- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/packages/builder/dist/electron/build.sh b/packages/builder/dist/electron/build.sh index e2e28eba46c..6274a073117 100755 --- a/packages/builder/dist/electron/build.sh +++ b/packages/builder/dist/electron/build.sh @@ -219,13 +219,6 @@ function mac { mv "$BUILDDIR/${PRODUCT_NAME}-darwin-x64/" "$BUILDDIR/${CLIENT_NAME}-darwin-x64/" fi - echo "Add kubectl-kui to electron build darwin" - (cd "$BUILDDIR/${CLIENT_NAME}-darwin-x64" && touch kubectl-kui && chmod +x kubectl-kui \ - && echo '#!/usr/bin/env sh -export KUI_POPUP_WINDOW_RESIZE=true -SCRIPTDIR=$(cd $(dirname "$0") && pwd) -"$SCRIPTDIR"/Kui.app/Contents/MacOS/Kui kubectl $@ &' >> kubectl-kui) - # create the installers #if [ -n "$ZIP_INSTALLER" ]; then #node ./builders/zip.js @@ -243,6 +236,36 @@ SCRIPTDIR=$(cd $(dirname "$0") && pwd) MAC_DMG_PID=$! fi + echo "Add kubectl-kui to electron build darwin" + (cd "$BUILDDIR/${CLIENT_NAME}-darwin-x64/${PRODUCT_NAME}.app/Contents/Resources/" \ + && touch kubectl-kui && chmod +x kubectl-kui \ + && echo '#!/usr/bin/env bash +export KUI_POPUP_WINDOW_RESIZE=true + +# credit: https://unix.stackexchange.com/a/521984 +bash_realpath() { + # print the resolved path + # @params + # 1: the path to resolve + # @return + # &1: the resolved link path + + local path="${1}" + while [[ -L ${path} && "$(ls -l "${path}")" =~ -\>\ (.*) ]] + do + path="${BASH_REMATCH[1]}" + done + echo "${path}" +} + +APP_RESOURCES_DIR="$(dirname "$(bash_realpath "$0")")" +if [ "$KUI" != "true" ]; then + "$APP_RESOURCES_DIR/../MacOS/Kui" kubectl $@ & +else + "$APP_RESOURCES_DIR/../MacOS/Kui" kubectl $@ +fi +' >> kubectl-kui) + echo "TGZ build for darwin" tar -C "$BUILDDIR" -jcf "$BUILDDIR/${CLIENT_NAME}-darwin-x64.tar.bz2" "${CLIENT_NAME}-darwin-x64" & MAC_TAR_PID=$!