From 6efb9d5e1c8bd24735d4c5f42b3c9ff0d8deb8cd Mon Sep 17 00:00:00 2001 From: jfgordon2 <55799997+jfgordon2@users.noreply.github.com> Date: Sun, 29 Mar 2020 16:01:51 -0500 Subject: [PATCH] add CLI support to Debian package, add Elementary OS shell and editor support (#231) --- app/static/linux/github | 35 ----------------------------------- script/linux-after-install.sh | 33 +++++++++++++++++++++++++++++++++ script/linux-after-remove.sh | 23 +++++++++++++++++++++++ 3 files changed, 56 insertions(+), 35 deletions(-) delete mode 100644 app/static/linux/github create mode 100644 script/linux-after-install.sh create mode 100644 script/linux-after-remove.sh diff --git a/app/static/linux/github b/app/static/linux/github deleted file mode 100644 index 0f7513eb244..00000000000 --- a/app/static/linux/github +++ /dev/null @@ -1,35 +0,0 @@ -#!/bin/sh - -if [ ! -L "$0" ]; then - # if path is not a symlink, find relatively - GITHUB_PATH=$(dirname "$(dirname "$(dirname "$(dirname "$0")")")") -else - if command -v readlink >/dev/null; then - # if readlink exists, follow the symlink and then find relatively - SYMLINK=$(readlink -f "$0") - GITHUB_PATH=$(dirname "$(dirname "$(dirname "$(dirname "$SYMLINK")")")") - else - # else use the standard install location - GITHUB_PATH="/opt/GitHub Desktop" - fi -fi -# check if this is a dev install or standard -if [ -f "$GITHUB_PATH/github-desktop-dev" ]; then - BINARY_NAME="github-desktop-dev" -else - BINARY_NAME="github-desktop" -fi - -ELECTRON="$GITHUB_PATH/$BINARY_NAME" -CLI="$GITHUB_PATH/resources/app/cli.js" - -case $1 in - # if help in the first variable, return contents to shell - *help*|*--help*) - ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@";; - # any other, redirect to /dev/null to detach from controlling terminal - *) - ELECTRON_RUN_AS_NODE=1 "$ELECTRON" "$CLI" "$@" < /dev/null > /dev/null &;; -esac - -exit $? diff --git a/script/linux-after-install.sh b/script/linux-after-install.sh new file mode 100644 index 00000000000..204b930b83d --- /dev/null +++ b/script/linux-after-install.sh @@ -0,0 +1,33 @@ +#!/bin/bash + +set -e + +PROFILE_D_FILE="/etc/profile.d/github-desktop.sh" +INSTALL_DIR="/opt/${productFilename}" +CLI_DIR="$INSTALL_DIR/resources/app/static" + +case "$1" in + configure) + # add executable permissions for CLI interface + chmod +x "$CLI_DIR"/github || : + # check if this is a dev install or standard + if [ -f "$INSTALL_DIR/github-desktop-dev" ]; then + BINARY_NAME="github-desktop-dev" + else + BINARY_NAME="github-desktop" + fi + # create symbolic links to /usr/bin directory + ln -f -s "$INSTALL_DIR"/$BINARY_NAME /usr/bin || : + ln -f -s "$CLI_DIR"/github /usr/bin || : + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +exit 0 \ No newline at end of file diff --git a/script/linux-after-remove.sh b/script/linux-after-remove.sh new file mode 100644 index 00000000000..64c0803dec3 --- /dev/null +++ b/script/linux-after-remove.sh @@ -0,0 +1,23 @@ +#!/bin/bash +set -e + +PROFILE_D_FILE="/etc/profile.d/github-desktop.sh" + +case "$1" in + purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear) + echo "#!/bin/sh" > "${PROFILE_D_FILE}"; + . "${PROFILE_D_FILE}"; + rm "${PROFILE_D_FILE}"; + # remove symbolic links in /usr/bin directory + unlink /usr/bin/github-desktop || : + unlink /usr/bin/github-desktop-dev || : + unlink /usr/bin/github || : + ;; + + *) + echo "postrm called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +exit 0