diff --git a/README.md b/README.md index e155356..ffaed46 100644 --- a/README.md +++ b/README.md @@ -62,7 +62,7 @@ The build is relatively simple and can be done in two different ways: Using `curl` and `jq`: ```bash -curl 'https://api.github.com/repos/YannMagnin/sh-elf-vhex/contents/scripts/bootstrap.sh' | jq -r '.content' | base64 --decode | bash +curl -fsSL https://raw.githubusercontent.com/YannMagnin/sh-elf-vhex/HEAD/scripts/bootstrap.sh | bash ``` Or by cloning the project and using the `bootstrap.sh` script, see diff --git a/scripts/_install.sh b/scripts/_install.sh index bfd8fa7..f92f377 100755 --- a/scripts/_install.sh +++ b/scripts/_install.sh @@ -47,7 +47,7 @@ _src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) cd "$_src" || exit 1 source ./_utils.sh -if [[ ! -f "$prefix_sysroot/bin/sh-elf-vhex-gcc" ]] +if [[ ! -x "$prefix_sysroot/bin/sh-elf-vhex-gcc" ]] then echo "error: Are you sure to have built sh-elf-vhex ? it seems that" >&2 echo " the 'sh-elf-vhex-gcc' tool is missing..." >&2 diff --git a/scripts/_uninstall.sh b/scripts/_uninstall.sh index dfecea8..bdf6f2a 100755 --- a/scripts/_uninstall.sh +++ b/scripts/_uninstall.sh @@ -52,7 +52,7 @@ then exit 1 fi -if [[ ! -f "$prefix_sysroot/bin/sh-elf-vhex-as" ]] +if [[ ! -x "$prefix_sysroot/bin/sh-elf-vhex-as" ]] then echo 'error: Are you sure to have built sh-elf-vhex ?' >&2 echo ' Missing '\''sh-elf-vhex-as'\'' tool' >&2 diff --git a/scripts/bootstrap.sh b/scripts/bootstrap.sh index cd064ba..a3bb4b4 100755 --- a/scripts/bootstrap.sh +++ b/scripts/bootstrap.sh @@ -63,23 +63,38 @@ done _src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ) cd "$_src" || exit 1 +has_been_cloned='false' if [[ "$prefix_clone/scripts" != "$_src" ]] then - if [[ -d "$prefix_clone" && "$overwrite" != 'true' ]] + if [[ "$action" != 'install' ]]; then + echo \ + 'No need to uninstall the sh-elf-vhex since no cloned repository' \ + 'has been found, ignored' + exit 0 + fi + if [ -x "$prefix_sysroot/bin/sh-elf-vhex-gcc" ] then echo -e \ - "It seems that the project is already existing :pouce:\n" \ + 'It seems that the project is already installed :pouce:\n' \ 'If you really want to reinstall this project use the "--overwrite"' \ 'option.' exit 1 fi - [[ -d "$prefix_clone" ]] && rm -rf "$prefix_clone" - echo ' self-clone repository...' - git \ - clone \ - --depth=1 \ - https://github.com/YannMagnin/sh-elf-vhex.git \ - "$prefix_clone" + if [[ ! -d "$prefix_clone" || "$overwrite" == 'true' ]] + then + [[ -d "$prefix_clone" ]] && rm -rf "$prefix_clone" + echo ' self-clone repository...' + { + git \ + clone \ + --depth=1 \ + https://github.com/YannMagnin/sh-elf-vhex.git \ + "$prefix_clone" + } || { + exit 1 + } + has_been_cloned='true' + fi fi cd "$prefix_clone/scripts" || exit 1 @@ -110,19 +125,21 @@ then echo " - Binutils version: $version_binutils" echo " - Clone directory: $prefix_clone" echo " - Compliler install at: $prefix_install" + if [[ "$has_been_cloned" == 'true' ]]; then + echo 'Note that the cloned repository will be removed if aborted' + fi read -p 'Process ? [yN]: ' -r valid < /dev/tty else read -p 'Uninstall the sh-elf-vhex compiler ? [yN]: ' -r valid < /dev/tty fi -# check if the stdin exists, which is not the case when the script is piped -# with bash (cat ./script/bootstrap.sh | bash) -if [[ -t 0 ]] -then - if [[ "$valid" != 'y' ]]; then +if [[ "$valid" != 'y' ]]; then + if [[ "$has_been_cloned" == 'true' ]]; then + echo 'Removing the cloned repository...' + rm -rf "$prefix_clone" + fi echo 'Operation aborted o(x_x)o' exit 1 - fi fi #---