From 9a2d73f570f589e3d3a29ec646b5925cf8a47585 Mon Sep 17 00:00:00 2001 From: YannMagnin Date: Sun, 3 Dec 2023 14:16:59 +0100 Subject: [PATCH] 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 --- scripts/install.sh | 17 ++++++--- scripts/uninstall.sh | 14 ++++---- scripts/update.sh | 83 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 102 insertions(+), 12 deletions(-) create mode 100755 scripts/update.sh diff --git a/scripts/install.sh b/scripts/install.sh index 3e9a3b1..4a6c4bf 100755 --- a/scripts/install.sh +++ b/scripts/install.sh @@ -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 diff --git a/scripts/uninstall.sh b/scripts/uninstall.sh index df3030e..a181b69 100755 --- a/scripts/uninstall.sh +++ b/scripts/uninstall.sh @@ -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 diff --git a/scripts/update.sh b/scripts/update.sh new file mode 100755 index 0000000..81c84e6 --- /dev/null +++ b/scripts/update.sh @@ -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