sh-elf-vhex - v2.0.0-rc6 : rework bootstrap preliminary checks
*update* > [project] | [readme] simplify the curl operation > [scripts] | [bootstrap] allow cloned folder if install aborted | [bootstrap] proper check if the project already installed *fix* > [scripts] | [bootstrap] avoid cloning if uninstall operation | [_uninstall] check for executable file instead of simple file | [_install] check for executable file instead of simple file
This commit is contained in:
parent
c44e992e64
commit
432220b796
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 '<sh-elf-vhex> 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 '<sh-elf-vhex> 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
|
||||
|
||||
#---
|
||||
|
|
Loading…
Reference in New Issue