sh-elf-vhex - v2.0.0-rc7 : remove bootstrap script
*update* > [project] | [readme] update the install curl operation information | [readme] add the uninstall curl operation information | [readme] move technical notes > [scripts] | [install] merge bootstrap code | [uninstall] merge bootstrap code | [bootstrap] remove the bootstrap script
This commit is contained in:
parent
432220b796
commit
8b7d15faf4
45
README.md
45
README.md
|
@ -43,37 +43,29 @@ particular GCC.
|
|||
* compilation of the libgcc in PIC (`t-libgcc-pic`)
|
||||
* compilation of the library for emulated floating point numbers (`t-fdpbit`)
|
||||
|
||||
## Technical notes
|
||||
|
||||
The bootstrap process will clone this repository at
|
||||
`~/.local/share/sh-elf-vhex` then will start the installation using:
|
||||
|
||||
* `prefix-clone` = `~/.local/share/sh-elf-vhex`
|
||||
* `prefix-sysroot` = `~/.local/share/sh-elf-vhex/_sysroot`
|
||||
* `prefix-install` = `~/.local/bin/`
|
||||
|
||||
The project also automatically installs
|
||||
[vxOpenLibm](https://github.com/YannMagnin/vxOpenLibm)
|
||||
and [vxLibc](https://github.com/YannMagnin/vxLibc)
|
||||
|
||||
## Installing
|
||||
|
||||
The build is relatively simple and can be done in two different ways:
|
||||
|
||||
Using `curl` and `jq`:
|
||||
Using `curl`:
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/YannMagnin/sh-elf-vhex/HEAD/scripts/bootstrap.sh | bash
|
||||
curl -fsSL https://raw.githubusercontent.com/YannMagnin/sh-elf-vhex/HEAD/scripts/install.sh | bash
|
||||
```
|
||||
|
||||
Or by cloning the project and using the `bootstrap.sh` script, see
|
||||
`./scripts/bootstrap.sh --help` for more information about possible operations
|
||||
you can do with it (like uninstalling the compiler)
|
||||
Note that you can do the uninstallation using `curl` too:
|
||||
```bash
|
||||
curl -fsSL https://raw.githubusercontent.com/YannMagnin/sh-elf-vhex/HEAD/scripts/uninstall.sh | bash
|
||||
```
|
||||
|
||||
Or by cloning the project and using the `install.sh` script, see
|
||||
`./scripts/install.sh --help` for more information about possible operations
|
||||
you can do with it
|
||||
|
||||
```bash
|
||||
cd /tmp/
|
||||
git clone 'https://github.com/YannMagnin/sh-elf-vhex.git' --depth=1
|
||||
cd /tmp/sh-elf-vhex || exit 1
|
||||
./script/bootstrap.sh
|
||||
./script/install.sh
|
||||
```
|
||||
|
||||
It takes about twenty minutes for the build.
|
||||
|
@ -87,6 +79,21 @@ found for the superh backend
|
|||
- GCC `13.2.0` and binutils `2.41`
|
||||
- GCC `11.2.0` and binutils `2.31`
|
||||
|
||||
## Technical notes
|
||||
|
||||
The bootstrap process will clone this repository at
|
||||
`~/.local/share/sh-elf-vhex` then will start the installation using:
|
||||
|
||||
* `prefix-clone` = `~/.local/share/sh-elf-vhex`
|
||||
* `prefix-sysroot` = `~/.local/share/sh-elf-vhex/_sysroot`
|
||||
* `prefix-install` = `~/.local/bin/`
|
||||
|
||||
The project also automatically installs
|
||||
[vxOpenLibm](https://github.com/YannMagnin/vxOpenLibm)
|
||||
and [vxLibc](https://github.com/YannMagnin/vxLibc)
|
||||
|
||||
|
||||
|
||||
## Special thanks
|
||||
|
||||
A big thanks to [Lephenixnoir](https://silent-tower.net/research/) who helped
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
#---
|
||||
# Help screen
|
||||
#---
|
||||
|
||||
function help() {
|
||||
cat << EOF
|
||||
Script for the installation step of binutils/GCC tools for the Vhex project.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
--cache Keep the build and the sources directory
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
#---
|
||||
# Parse arguments
|
||||
#---
|
||||
|
||||
cache=false
|
||||
verbose=false
|
||||
prefix_install=
|
||||
prefix_sysroot=
|
||||
|
||||
for arg; do
|
||||
case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose | -v) verbose=true;;
|
||||
--cache) cache=true;;
|
||||
--prefix-sysroot=*) prefix_sysroot=${arg#*=};;
|
||||
--prefix-install=*) prefix_install=${arg#*=};;
|
||||
*)
|
||||
echo "error: unrecognized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
#---
|
||||
# Installation step
|
||||
#---
|
||||
|
||||
_src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
cd "$_src" || exit 1
|
||||
source ./_utils.sh
|
||||
|
||||
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
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ "$cache" == 'false' ]]
|
||||
then
|
||||
echo "$TAG Cleaning up built files..."
|
||||
rm -rf ../../build
|
||||
fi
|
||||
|
||||
[[ "$verbose" == 'true' ]] && export VERBOSE=1
|
||||
|
||||
#---
|
||||
# Symbolic link executables to $PREFIX
|
||||
#---
|
||||
|
||||
echo "$TAG Symlinking binaries..."
|
||||
|
||||
mkdir -p "$prefix_install"
|
||||
for x in "$prefix_sysroot/bin"/*; do
|
||||
utils_callcmd ln -sf "$x" "$prefix_install/$(basename "$x")"
|
||||
done
|
|
@ -13,10 +13,11 @@ Usage $0 [options...]
|
|||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
-v, --verbose Display extra information during operation
|
||||
--prefix-install Installation (bin) prefix
|
||||
--prefix-sysroot Sysroot (lib, header, ...) prefix
|
||||
--prefix-clone Clone prefix
|
||||
--purge Remove the cloned folder
|
||||
--no-purge Do not remove the cloned folder
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
@ -25,14 +26,14 @@ EOF
|
|||
# Parse arguments
|
||||
#---
|
||||
|
||||
prefix_install=''
|
||||
prefix_sysroot=''
|
||||
prefix_clone=''
|
||||
purge='false'
|
||||
purge='true'
|
||||
prefix_install=~/.local/bin
|
||||
prefix_sysroot=~/.local/share/sh-elf-vhex/_sysroot
|
||||
prefix_clone=~/.local/share/sh-elf-vhex
|
||||
for arg
|
||||
do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--purge) purge='true';;
|
||||
--no-purge) purge='false';;
|
||||
--prefix-install=*) prefix_install=${arg#*=};;
|
||||
--prefix-sysroot=*) prefix_sysroot=${arg#*=};;
|
||||
--prefix-clone=*) prefix_clone=${arg#*=};;
|
||||
|
@ -46,16 +47,35 @@ done
|
|||
# Preliminary check
|
||||
#---
|
||||
|
||||
if [[ -z "$prefix_install" || -z "$prefix_sysroot" || -z "$prefix_clone" ]]
|
||||
if [[ ! -d "$prefix_clone" ]]
|
||||
then
|
||||
echo 'Missing prefix information, abort' >&2
|
||||
echo -e \
|
||||
'Are you sure to have installed the project ?\n' \
|
||||
'\rIt seems that the cloned prefix does not exists' \
|
||||
>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$prefix_install" ]]
|
||||
then
|
||||
echo -e \
|
||||
'WARNING: seems that the install prefix does not exists\n' \
|
||||
'WARNING: if you continue, the install prefix will be ignored and' \
|
||||
'nothing will be removed' \
|
||||
>&2
|
||||
read -p 'Proccess anyway ? [yN]' -r valid < /dev/tty
|
||||
if [[ "$valid" != 'y' ]]; then
|
||||
echo 'Operation aborted o(x_x)o' >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
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
|
||||
echo -e \
|
||||
'ERROR: Are you sure to have built sh-elf-vhex ? Seems that the' \
|
||||
'sh-elf-vhex-as cannot be found in the sysroot prefix' \
|
||||
>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
@ -63,17 +83,19 @@ fi
|
|||
# Unistall step
|
||||
#---
|
||||
|
||||
_src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
_src=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
|
||||
cd "$_src" || exit 1
|
||||
source ./_utils.sh
|
||||
|
||||
echo "$TAG Removing symlinks to binaries..."
|
||||
echo "$TAG removing symlinks to binaries..."
|
||||
for x in "$prefix_sysroot"/bin/*; do
|
||||
utils_callcmd unlink "$x"
|
||||
utils_callcmd unlink "$prefix_install/$(basename "$x")"
|
||||
if [[ -L "$prefix_install/$(basename "$x")" ]]; then
|
||||
utils_callcmd unlink "$prefix_install/$(basename "$x")"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$TAG Removing sysroot..."
|
||||
echo "$TAG removing sysroot..."
|
||||
rm -rf "$prefix_sysroot"
|
||||
|
||||
if [[ "$purge" == 'true' ]]
|
||||
|
|
|
@ -1,181 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
#---
|
||||
# Help screen
|
||||
#---
|
||||
|
||||
function help() {
|
||||
cat << EOF
|
||||
Bootstrap script used to install or uninstall the sh-elf-vhex compiler.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Options:
|
||||
-h, --help Display this help
|
||||
-v, --verbose Display extra information during operation
|
||||
--prefix-install Installation (bin) prefix
|
||||
--prefix-sysroot Sysroot (lib, header, ...) prefix
|
||||
--prefix-clone Clone prefix
|
||||
--overwrite Remove the cloned version if exists and install
|
||||
--uninstall Uninstall operation
|
||||
|
||||
Notes:
|
||||
This project will automatically install the vxLibc. You can use the
|
||||
VERBOSE env var to enable the verbose mode without explicit use of the
|
||||
'--verbose' option.
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
#---
|
||||
# Parse arguments
|
||||
#---
|
||||
|
||||
action='install'
|
||||
verbose='false'
|
||||
overwrite='false'
|
||||
prefix_install=~/.local/bin
|
||||
prefix_sysroot=~/.local/share/sh-elf-vhex/_sysroot
|
||||
prefix_clone=~/.local/share/sh-elf-vhex
|
||||
|
||||
for arg; do
|
||||
case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose | -v) verbose=true;;
|
||||
--prefix-install=*) prefix_install=${arg#*=};;
|
||||
--prefix-sysroot=*) prefix_sysroot=${arg#*=};;
|
||||
--prefix-clone=*) prefix_clone=${arg#*=};;
|
||||
--uninstall) action='uninstall';;
|
||||
--overwrite) overwrite='true';;
|
||||
*)
|
||||
echo "error: unrecognized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
#---
|
||||
# Handle self-clone if needed
|
||||
#---
|
||||
|
||||
# export verbose now to handle the self-clone if needed
|
||||
[[ "$verbose" == 'true' ]] && export VERBOSE=1
|
||||
|
||||
_src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
|
||||
cd "$_src" || exit 1
|
||||
|
||||
has_been_cloned='false'
|
||||
if [[ "$prefix_clone/scripts" != "$_src" ]]
|
||||
then
|
||||
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 installed :pouce:\n' \
|
||||
'If you really want to reinstall this project use the "--overwrite"' \
|
||||
'option.'
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
source ./_utils.sh
|
||||
|
||||
#---
|
||||
# Preliminary checks
|
||||
#---
|
||||
|
||||
version_gcc=$(utils_find_last_version ../patches/gcc)
|
||||
version_binutils=$(utils_find_last_version ../patches/binutils)
|
||||
|
||||
if [[ "$verbose" == 'true' ]]
|
||||
then
|
||||
echo "Debug fetched information:"
|
||||
echo " - VHEX_VERBOSE = $verbose"
|
||||
echo " - VHEX_VERSION_BINUTILS = $version_binutils"
|
||||
echo " - VHEX_VERSION_GCC = $version_gcc"
|
||||
echo " - VHEX_PREFIX_INSTALL = $prefix_install"
|
||||
echo " - VHEX_PREFIX_SYSROOT = $prefix_sysroot"
|
||||
echo " - VHEX_PREFIX_CLONE = $prefix_clone"
|
||||
fi
|
||||
|
||||
if [[ "$action" == 'install' ]]
|
||||
then
|
||||
echo 'The script will install the sh-elf-vhex compiler with:'
|
||||
echo " - GCC version: $version_gcc"
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
#---
|
||||
# Performs install/uninstall operation
|
||||
#---
|
||||
|
||||
if [[ "$action" == 'install' ]]
|
||||
then
|
||||
{
|
||||
./binutils/configure.sh \
|
||||
--prefix-sysroot="$prefix_sysroot" \
|
||||
--version="$version_binutils" \
|
||||
&& ./binutils/build.sh \
|
||||
&& ./gcc/configure.sh \
|
||||
--prefix-sysroot="$prefix_sysroot" \
|
||||
--version="$version_gcc" \
|
||||
&& ./gcc/build.sh \
|
||||
&& ./_install.sh \
|
||||
--prefix-sysroot="$prefix_sysroot" \
|
||||
--prefix-install="$prefix_install"
|
||||
} || {
|
||||
echo 'Error during bootstraping operations' >&2
|
||||
exit 1
|
||||
}
|
||||
echo 'Successfully installed sh-elf-vhex !'
|
||||
echo "Do not forget to export the binary path '$prefix_install'"
|
||||
else
|
||||
{
|
||||
./_uninstall.sh \
|
||||
--prefix-sysroot="$prefix_sysroot" \
|
||||
--prefix-install="$prefix_install" \
|
||||
--prefix-clone="$prefix_clone" \
|
||||
--purge
|
||||
} || {
|
||||
echo 'Error during uninstallation step, abort' >&2
|
||||
exit 1
|
||||
}
|
||||
echo 'Successfully uninstalled sh-elf-vhex'
|
||||
fi
|
|
@ -0,0 +1,165 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
#---
|
||||
# Help screen
|
||||
#---
|
||||
|
||||
function help() {
|
||||
cat << EOF
|
||||
Script for the installation step of binutils/GCC tools for the Vhex project.
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
-v, --verbose Display extra information during operation
|
||||
--prefix-install Installation (bin) prefix
|
||||
--prefix-sysroot Sysroot (lib, header, ...) prefix
|
||||
--prefix-clone Clone prefix
|
||||
--overwrite Remove the cloned version if exists and install
|
||||
--cache Keep the build and the sources directory
|
||||
|
||||
Notes:
|
||||
This project will automatically install the vxLibc. You can use the
|
||||
VERBOSE env var to enable the verbose mode without explicit use of the
|
||||
'--verbose' option.
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
#---
|
||||
# Parse arguments
|
||||
#---
|
||||
|
||||
cache='false'
|
||||
verbose='false'
|
||||
overwrite='false'
|
||||
prefix_install=~/.local/bin
|
||||
prefix_sysroot=~/.local/share/sh-elf-vhex/_sysroot
|
||||
prefix_clone=~/.local/share/sh-elf-vhex
|
||||
|
||||
for arg; do
|
||||
case "$arg" in
|
||||
--help | -h) help;;
|
||||
--verbose | -v) verbose=true;;
|
||||
--cache) cache=true;;
|
||||
--prefix-sysroot=*) prefix_sysroot=${arg#*=};;
|
||||
--prefix-install=*) prefix_install=${arg#*=};;
|
||||
--prefix-clone=*) prefix_clone=${arg#*=};;
|
||||
--overwrite) overwrite='true';;
|
||||
*)
|
||||
echo "error: unrecognized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
#---
|
||||
# Handle bootstraping
|
||||
#---
|
||||
|
||||
_src=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
|
||||
cd "$_src" || exit 1
|
||||
|
||||
has_been_cloned='false'
|
||||
if [[ "$prefix_clone/scripts" != "$_src" ]]
|
||||
then
|
||||
if [ -x "$prefix_sysroot/bin/sh-elf-vhex-gcc" ]
|
||||
then
|
||||
echo -e \
|
||||
'It seems that the project is already installed :pouce:\n' \
|
||||
'\rIf you really want to reinstall this project use the ' \
|
||||
'"--overwrite" option.'
|
||||
exit 1
|
||||
fi
|
||||
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
|
||||
source ./_utils.sh
|
||||
|
||||
#---
|
||||
# Preliminary checks
|
||||
#---
|
||||
|
||||
version_gcc=$(utils_find_last_version ../patches/gcc)
|
||||
version_binutils=$(utils_find_last_version ../patches/binutils)
|
||||
|
||||
echo 'The script will install the sh-elf-vhex compiler with:'
|
||||
echo " - GCC version: $version_gcc"
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
[[ "$verbose" == 'true' ]] && export VERBOSE=1
|
||||
|
||||
#---
|
||||
# Handle GGC/Binutils build
|
||||
#---
|
||||
|
||||
{
|
||||
./binutils/configure.sh \
|
||||
--prefix-sysroot="$prefix_sysroot" \
|
||||
--version="$version_binutils" \
|
||||
&& ./binutils/build.sh \
|
||||
&& ./gcc/configure.sh \
|
||||
--prefix-sysroot="$prefix_sysroot" \
|
||||
--version="$version_gcc" \
|
||||
&& ./gcc/build.sh \
|
||||
&& ./_install.sh \
|
||||
--prefix-sysroot="$prefix_sysroot" \
|
||||
--prefix-install="$prefix_install"
|
||||
} || {
|
||||
echo 'Error during installing operations' >&2
|
||||
exit 1
|
||||
}
|
||||
|
||||
#---
|
||||
# Handle manual installation to the install path
|
||||
#---
|
||||
|
||||
echo "$TAG Symlinking binaries..."
|
||||
|
||||
mkdir -p "$prefix_install"
|
||||
for x in "$prefix_sysroot/bin"/*; do
|
||||
utils_callcmd ln -sf "$x" "$prefix_install/$(basename "$x")"
|
||||
done
|
||||
|
||||
#---
|
||||
# Cleaning and exit
|
||||
#---
|
||||
|
||||
if [[ "$cache" == 'false' ]]
|
||||
then
|
||||
echo "$TAG Cleaning up built files..."
|
||||
rm -rf ../../build
|
||||
fi
|
||||
|
||||
echo 'Successfully installed sh-elf-vhex !'
|
||||
echo "Do not forget to export the binary path '$prefix_install'"
|
|
@ -0,0 +1,105 @@
|
|||
#! /usr/bin/env bash
|
||||
|
||||
#---
|
||||
# Help screen
|
||||
#---
|
||||
|
||||
function help()
|
||||
{
|
||||
cat << EOF
|
||||
Script for the uninstallation of sh-elf-vhex
|
||||
|
||||
Usage $0 [options...]
|
||||
|
||||
Configurations:
|
||||
-h, --help Display this help
|
||||
-v, --verbose Display extra information during operation
|
||||
--prefix-install Installation (bin) prefix
|
||||
--prefix-sysroot Sysroot (lib, header, ...) prefix
|
||||
--prefix-clone Clone prefix
|
||||
--no-purge Do not remove the cloned folder
|
||||
EOF
|
||||
exit 0
|
||||
}
|
||||
|
||||
#---
|
||||
# Parse arguments
|
||||
#---
|
||||
|
||||
purge='true'
|
||||
prefix_install=~/.local/bin
|
||||
prefix_sysroot=~/.local/share/sh-elf-vhex/_sysroot
|
||||
prefix_clone=~/.local/share/sh-elf-vhex
|
||||
for arg
|
||||
do case "$arg" in
|
||||
--help | -h) help;;
|
||||
--no-purge) purge='false';;
|
||||
--prefix-install=*) prefix_install=${arg#*=};;
|
||||
--prefix-sysroot=*) prefix_sysroot=${arg#*=};;
|
||||
--prefix-clone=*) prefix_clone=${arg#*=};;
|
||||
*)
|
||||
echo "error: unrecognized argument '$arg', giving up." >&2
|
||||
exit 1
|
||||
esac
|
||||
done
|
||||
|
||||
#---
|
||||
# Preliminary check
|
||||
#---
|
||||
|
||||
if [[ ! -d "$prefix_clone" ]]
|
||||
then
|
||||
echo -e \
|
||||
'Are you sure to have installed the project ?\n' \
|
||||
'\rIt seems that the cloned prefix does not exists' \
|
||||
>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ ! -d "$prefix_install" ]]
|
||||
then
|
||||
echo -e \
|
||||
'WARNING: seems that the install prefix does not exists\n' \
|
||||
'WARNING: if you continue, the install prefix will be ignore and' \
|
||||
'nothing will be removed' \
|
||||
>&2
|
||||
read -p 'Proccess anyway ? [yN]' -r valid < /dev/tty
|
||||
if [[ "$valid" != 'y' ]]; then
|
||||
echo 'Operation aborted o(x_x)o' >&2
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -x "$prefix_sysroot/bin/sh-elf-vhex-as" ]]
|
||||
then
|
||||
echo -e \
|
||||
'ERROR: Are you sure to have built sh-elf-vhex ? Seems that the' \
|
||||
'sh-elf-vhex-as cannot be found in the sysroot prefix' \
|
||||
>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#---
|
||||
# Unistall step
|
||||
#---
|
||||
|
||||
_src=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
|
||||
cd "$_src" || exit 1
|
||||
source ./_utils.sh
|
||||
|
||||
echo "$TAG removing symlinks to binaries..."
|
||||
for x in "$prefix_sysroot"/bin/*; do
|
||||
utils_callcmd unlink "$x"
|
||||
if [[ -L "$prefix_install/$(basename "$x")" ]]; then
|
||||
utils_callcmd unlink "$prefix_install/$(basename "$x")"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "$TAG removing sysroot..."
|
||||
rm -rf "$prefix_sysroot"
|
||||
|
||||
if [[ "$purge" == 'true' ]]
|
||||
then
|
||||
echo "$TAG removing cloned folder..."
|
||||
rm -rf "$prefix_clone"
|
||||
fi
|
Loading…
Reference in New Issue