efe8d0fa2d
refactor src/ to be just a basic build add examples write up help.md and usage subcommand add test folder for dev testing improve install script many numerous improved to build script, moved portions of build script to functions in helpers.lib
36 lines
No EOL
1.4 KiB
Bash
Executable file
36 lines
No EOL
1.4 KiB
Bash
Executable file
#!/bin/bash
|
|
builder=$(dirname "$(realpath "$BASH_SOURCE")")
|
|
target=$1
|
|
[[ $# -eq 2 ]] && target=$1/$2
|
|
target=${target:-/opt/bin/udbuild}
|
|
cmd=$(basename $target)
|
|
parent=$(dirname $target)
|
|
echo NOTE: the uci build script can be called directly at $builder
|
|
# echo "$PATH --- $parent"
|
|
declare -a a="(${PATH//:/ })"
|
|
for i in ${a[*]}; do [[ $i == $parent ]] && found=true; done
|
|
if [[ $found ]]; then
|
|
echo creating a link \'$cmd\' in \'$parent\' to \'$builder\'
|
|
if [[ -f $target ]]; then
|
|
echo "$target already exists do you want to overwrite? (y/n) "
|
|
read -e ans
|
|
[[ ! $ans == "y" ]] && exit 1
|
|
fi
|
|
if ln -fns $builder/build $target; then
|
|
[[ ! $(command -v $cmd) ]] && echo FATAL: link failed $cmd not found in path \
|
|
|| echo install success: try \'$cmd -h\' now
|
|
else
|
|
echo Error creating link
|
|
echo if \': Permission denied\' 'then' run \'sudo ./install\'
|
|
fi
|
|
else
|
|
echo "Install failed: $parent not in current path"
|
|
echo $PATH
|
|
echo "link to script not created. your install options are:"
|
|
echo "1. add $parent to your PATH"
|
|
echo "2. rerun this script using a directory in the system path (e.g ./install /usr/bin build)"
|
|
echo "3. add the following export somewhere in your shell (e.g. ~/.bashrc)"
|
|
echo " export UDBUILD=$builder/build"
|
|
echo ' and then use $UDBUILD to invoke the build script'
|
|
echo ' ( e.g $UDBUILD -e Smybuild.env)'
|
|
fi |