vxOpenLibm - v1.0.0-dev4 : update support

*add*
> [scripts]
  | [update] support update operation
  | [install] support `--overwrite` option

*update*
> [scripts]
  | [install] expose sysroot information in build folder
  | [install] allow overwrite the current build (remove and reclone)

*fix*
> [scripts]
  | [uninstall] fix typo in help message
This commit is contained in:
YannMagnin 2023-12-03 14:16:59 +01:00
parent 14a9385edd
commit 9a2d73f570
No known key found for this signature in database
GPG Key ID: D82629D933EADC59
3 changed files with 102 additions and 12 deletions

View File

@ -15,6 +15,7 @@ Options:
-y, --yes do not display validation step
-v, --verbose display more information during operations
--prefix-sysroot sysroot (install) prefix path
--overwrite remove the cloned OpenLibm repo if already exists
Notes:
This project is mainly automatically installed as a dependency of the
@ -29,6 +30,7 @@ EOF
verbose=false
skip_input=false
overwrite=false
prefix=''
for arg; do
case "$arg" in
@ -36,6 +38,7 @@ for arg; do
-y | --yes) skip_input=true;;
-v | --verbose) verbose=true;;
--prefix-sysroot=*) prefix=${arg#*=};;
--overwrite) overwrite=true;;
*)
echo "error: unreconized argument '$arg', giving up." >&2
exit 1
@ -66,17 +69,18 @@ _src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "$_src" || exit 1
source ./_utils.sh
if [[ -d '../openlibm' ]]
if [[ -d '../openlibm' && "$overwrite" != 'true' ]]
then
echo 'OpenLibm already exists, abord' >&2
exit 1
echo 'vxOpenLibm already installed, nothing to do'
exit 0
fi
if [[ "$skip_input" != 'true' ]]
then
echo 'This script will compile and install the vxOpenLibm project'
echo " - prefix = $prefix"
echo " - verbose = $verbose"
echo " - prefix = $prefix"
echo " - verbose = $verbose"
echo " - overwrite = $overwrite"
read -p 'Perform operations [Yn] ? ' -r valid
if [[ "$valid" == 'n' ]]; then
echo 'Operation aborted' >&2
@ -84,6 +88,8 @@ then
fi
fi
[[ -d '../openlibm' ]] && rm -rf ../openlibm
[[ "$verbose" == 'true' ]] && export VERBOSE=1
#---
@ -110,3 +116,4 @@ callcmd cmake --build ../openlibm/_build-vhex/
echo "$TAG install..."
callcmd cmake --install ../openlibm/_build-vhex/
echo "$prefix" > ../openlibm/_build-vhex/sysroot.txt

View File

@ -6,14 +6,14 @@
function help() {
cat << EOF
Uninstallation script for vxOpenLibm project (for of OpenLibm)
Uninstallation script for vxOpenLibm project (fork of OpenLibm)
Usage: $0 [options...]
Options:
-h, --help display this help
-y, --yes do not display validation step
-v, --verbose display more information during operations
-h, --help display this help
-y, --yes do not display validation step
-v, --verbose display more information during operations
Notes:
This project is a dependency of "sh-elf-vhex" compiler, manual
@ -30,9 +30,9 @@ verbose=false
skip_input=false
for arg; do
case "$arg" in
-h | --help) help;;
-y | --yes) skip_input=true;;
-v | --verbose) verbose=true;;
-h | --help) help;;
-y | --yes) skip_input=true;;
-v | --verbose) verbose=true;;
*)
echo "error: unreconized argument '$arg', giving up." >&2
exit 1

83
scripts/update.sh Executable file
View File

@ -0,0 +1,83 @@
#!/usr/bin/env bash
#---
# Help screen
#---
function help() {
cat << EOF
Update script the for vxOpenLibm script (fork of OpenLibm)
Usage: $0 [options...]
Options:
-h, --help display this help
-y, --yes do not display validation step
-v, --verbose display more information during operations
Notes:
This project is a dependency of "sh-elf-vhex" compiler, manual
uninstallation can break all the toolchain.
EOF
exit 0
}
#---
# Parse arguments
#---
verbose=false
skip_input=false
for arg; do
case "$arg" in
-h | --help) help;;
-y | --yes) skip_input=true;;
-v | --verbose) verbose=true;;
*)
echo "error: unreconized argument '$arg', giving up." >&2
exit 1
esac
done
#---
# Preliminary check
#---
_src=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
cd "$_src" || exit 1
source ./_utils.sh
if ! test -f '../openlibm/_build-vhex/sysroot.txt'
then
echo 'vxOpenLibm not installed, nothing to do'
exit 0
fi
prefix=$(cat '../openlibm/_build-vhex/sysroot.txt')
if [[ "$skip_input" != 'true' ]]
then
echo "This script will update the vxOpenLibm for the sysroot '$prefix'"
read -p 'Perform operation [Yn] ? ' -r valid
if [[ "$valid" == 'n' ]]
then
echo 'Operation aborded' >&2
exit 1
fi
fi
#---
# Manual update
#---
[[ "$verbose" == 'true' ]] && export VERBOSE=1
if test -d '../.git'
then
echo "$TAG try to bump the repository..."
callcmd git pull
else
echo "$TAG WARNING: not a git repository"
fi
echo "$TAG update operation will reclone and rebuild the project..."
./install.sh --prefix-sysroot="$prefix" --yes --overwrite