From 37493ea8be801f9424858711e4b31a4aede50130 Mon Sep 17 00:00:00 2001 From: Julien Roche Date: Tue, 26 Jan 2016 18:41:15 +0100 Subject: [PATCH 1/7] (install) command process to install globally `exx` --- README.md | 2 +- libexec/exx-install | 49 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100755 libexec/exx-install diff --git a/README.md b/README.md index e2c507e..d64123a 100755 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@ ones. ## Installation - Clone this repo ```git clone https://github.com/CaptainQuirk/exx ``` -- Add ```/bin/exx``` to your __$PATH__ ## Commands @@ -15,6 +14,7 @@ ones. - ```switch ```: Switch to a specified version of Xcode - ```update```: Backs up the current Xcode.app and upgrade via __softwareupdate__ - ```reset```: Resets Xcode version to the latest +- ```install```: Install `exx` globally ## Directory Structure diff --git a/libexec/exx-install b/libexec/exx-install new file mode 100755 index 0000000..b90cde2 --- /dev/null +++ b/libexec/exx-install @@ -0,0 +1,49 @@ +#!/usr/bin/env sh +# Usage: exx install +# Summary: Install `exx` globally + +PATH_INSTALL=$HOME/.sub + +installation(){ + CURRENT_PATH=`pwd` + read -p "Do you wish install exx into $path ? (Y/n) : " yn + + case $yn in + [Yy]*) cp -R $CURRENT_PATH $path; symlinks; break;; + [Nn]*) echo "non"; break;; + *) echo "Please select Y/n" + esac +} + +symlinks(){ + BINARY_PATH="/usr/local/bin/exx" + + if [ ! -f $BINARY_PATH ]; then + echo "Create symlinks into $BINARY_PATH" + ln -s $path/exx/libexec/exx $BINARY_PATH + echo "Done !" + echo "Check vertification installation by running ``exx info`` for example" + fi +} + +# test if installation path exists +# if not, we create folder +if [ ! -d $PATH_INSTALL ]; then + mkdir $PATH_INSTALL +fi + +# we ask the user installation path +read -p "Path to install (default: $PATH_INSTALL) : " path +if [ -z "$path" ]; then + path=$PATH_INSTALL +fi + +# we check if exx exists into path +if [ ! -d "$path/exx" ]; then + installation +else + echo "exx is already install into $path" + symlinks +fi + + From 9b37351c5c7c7e04c31f95f31662d9da17a134f8 Mon Sep 17 00:00:00 2001 From: Julien Roche Date: Wed, 27 Jan 2016 09:48:26 +0100 Subject: [PATCH 2/7] (install) rename "PATH_INSTALL" to "INSTALL_PATH" --- libexec/exx-install | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libexec/exx-install b/libexec/exx-install index b90cde2..64860e7 100755 --- a/libexec/exx-install +++ b/libexec/exx-install @@ -2,7 +2,7 @@ # Usage: exx install # Summary: Install `exx` globally -PATH_INSTALL=$HOME/.sub +INSTALL_PATH=$HOME/.sub installation(){ CURRENT_PATH=`pwd` @@ -28,14 +28,14 @@ symlinks(){ # test if installation path exists # if not, we create folder -if [ ! -d $PATH_INSTALL ]; then - mkdir $PATH_INSTALL +if [ ! -d $INSTALL_PATH ]; then + mkdir $INSTALL_PATH fi # we ask the user installation path -read -p "Path to install (default: $PATH_INSTALL) : " path +read -p "Path to install (default: $INSTALL_PATH) : " path if [ -z "$path" ]; then - path=$PATH_INSTALL + path=$INSTALL_PATH fi # we check if exx exists into path From 2bff27f0c6b53e39fc5a9217939fffdebdac2e22 Mon Sep 17 00:00:00 2001 From: Julien Roche Date: Wed, 27 Jan 2016 09:49:21 +0100 Subject: [PATCH 3/7] (install) rename "symlinks" to "symlink" --- libexec/exx-install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libexec/exx-install b/libexec/exx-install index 64860e7..0dd0aff 100755 --- a/libexec/exx-install +++ b/libexec/exx-install @@ -9,13 +9,13 @@ installation(){ read -p "Do you wish install exx into $path ? (Y/n) : " yn case $yn in - [Yy]*) cp -R $CURRENT_PATH $path; symlinks; break;; + [Yy]*) cp -R $CURRENT_PATH $path; symlink; break;; [Nn]*) echo "non"; break;; *) echo "Please select Y/n" esac } -symlinks(){ +symlink(){ BINARY_PATH="/usr/local/bin/exx" if [ ! -f $BINARY_PATH ]; then @@ -43,7 +43,7 @@ if [ ! -d "$path/exx" ]; then installation else echo "exx is already install into $path" - symlinks + symlink fi From 3eb3a33dfff8159003c4625f204c0f2ceeb4dd18 Mon Sep 17 00:00:00 2001 From: Julien Roche Date: Wed, 27 Jan 2016 10:33:30 +0100 Subject: [PATCH 4/7] (install) Test if CURRENT_PATH is not equivalent to PATH_INSTALL --- libexec/exx-install | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/libexec/exx-install b/libexec/exx-install index 0dd0aff..676e7c7 100755 --- a/libexec/exx-install +++ b/libexec/exx-install @@ -3,13 +3,17 @@ # Summary: Install `exx` globally INSTALL_PATH=$HOME/.sub +COPY_DIR=$true -installation(){ +copy(){ CURRENT_PATH=`pwd` read -p "Do you wish install exx into $path ? (Y/n) : " yn case $yn in - [Yy]*) cp -R $CURRENT_PATH $path; symlink; break;; + [Yy]*) + #cp -R $CURRENT_PATH $path; + #symlink; + break;; [Nn]*) echo "non"; break;; *) echo "Please select Y/n" esac @@ -18,7 +22,7 @@ installation(){ symlink(){ BINARY_PATH="/usr/local/bin/exx" - if [ ! -f $BINARY_PATH ]; then + if [ ! -L $BINARY_PATH ]; then echo "Create symlinks into $BINARY_PATH" ln -s $path/exx/libexec/exx $BINARY_PATH echo "Done !" @@ -34,13 +38,24 @@ fi # we ask the user installation path read -p "Path to install (default: $INSTALL_PATH) : " path + if [ -z "$path" ]; then path=$INSTALL_PATH fi +if [ "$path" == "." ]; then + path=$INSTALL_PATH + COPY_DIR=$false +fi + +if [ "$path" == "$INSTALL_PATH" ] && [ !$COPY_DIR ]; then + symlink + exit +fi + # we check if exx exists into path if [ ! -d "$path/exx" ]; then - installation + copy else echo "exx is already install into $path" symlink From 23ada3658429c255534ecbcc7e6425bbfd6c82df Mon Sep 17 00:00:00 2001 From: Julien Roche Date: Wed, 27 Jan 2016 11:17:11 +0100 Subject: [PATCH 5/7] (install) fix installation when path is current directory --- libexec/exx-install | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libexec/exx-install b/libexec/exx-install index 676e7c7..874db3d 100755 --- a/libexec/exx-install +++ b/libexec/exx-install @@ -11,8 +11,8 @@ copy(){ case $yn in [Yy]*) - #cp -R $CURRENT_PATH $path; - #symlink; + cp -R $CURRENT_PATH $path; + symlink; break;; [Nn]*) echo "non"; break;; *) echo "Please select Y/n" @@ -21,10 +21,15 @@ copy(){ symlink(){ BINARY_PATH="/usr/local/bin/exx" + SOURCE_PATH=$path - if [ ! -L $BINARY_PATH ]; then + if [[ "$SOURCE_PATH" == */exx ]]; then + SOURCE_PATH=$(dirname $path) + fi + + if [ ! \( -e "${BINARY_PATH}" \) ]; then echo "Create symlinks into $BINARY_PATH" - ln -s $path/exx/libexec/exx $BINARY_PATH + ln -s $SOURCE_PATH/exx/libexec/exx $BINARY_PATH echo "Done !" echo "Check vertification installation by running ``exx info`` for example" fi @@ -44,11 +49,11 @@ if [ -z "$path" ]; then fi if [ "$path" == "." ]; then - path=$INSTALL_PATH + path=`pwd` COPY_DIR=$false fi -if [ "$path" == "$INSTALL_PATH" ] && [ !$COPY_DIR ]; then +if [ "$path" == `pwd` ] && [ !$COPY_DIR ]; then symlink exit fi From 6c5d4823adb29a38a67bdbbace375de889f2508b Mon Sep 17 00:00:00 2001 From: Julien Roche Date: Wed, 27 Jan 2016 11:22:00 +0100 Subject: [PATCH 6/7] (install) comments --- libexec/exx-install | 1 + 1 file changed, 1 insertion(+) diff --git a/libexec/exx-install b/libexec/exx-install index 874db3d..5c8466f 100755 --- a/libexec/exx-install +++ b/libexec/exx-install @@ -48,6 +48,7 @@ if [ -z "$path" ]; then path=$INSTALL_PATH fi +# if path is the current directory, don't copy if [ "$path" == "." ]; then path=`pwd` COPY_DIR=$false From 036af76a4f7c45e7adc406a087c6497f23619127 Mon Sep 17 00:00:00 2001 From: Julien Roche Date: Wed, 27 Jan 2016 14:00:54 +0100 Subject: [PATCH 7/7] (install) remove "vertification" --- libexec/exx-install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libexec/exx-install b/libexec/exx-install index 5c8466f..c9aa08b 100755 --- a/libexec/exx-install +++ b/libexec/exx-install @@ -31,7 +31,7 @@ symlink(){ echo "Create symlinks into $BINARY_PATH" ln -s $SOURCE_PATH/exx/libexec/exx $BINARY_PATH echo "Done !" - echo "Check vertification installation by running ``exx info`` for example" + echo "Check installation by running ``exx info`` for example" fi }