2023-01-17 15:42:56 -08:00
|
|
|
#!/bin/bash
|
2023-03-25 11:27:22 -07:00
|
|
|
builder=$(dirname "$(realpath "$BASH_SOURCE")")
|
|
|
|
target=$1
|
|
|
|
[[ $# -eq 2 ]] && target=$1/$2
|
2023-04-01 07:17:43 -07:00
|
|
|
target=${target:-/opt/bin/udbuild}
|
2023-03-25 11:27:22 -07:00
|
|
|
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\'
|
2023-04-01 07:17:43 -07:00
|
|
|
if ln -ns $builder/build $target; then
|
2023-03-25 11:27:22 -07:00
|
|
|
[[ ! $(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 $parent not in current path
|
|
|
|
echo $PATH
|
|
|
|
echo link to script not created
|
2023-04-01 07:17:43 -07:00
|
|
|
echo "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 ( e.g $UDBUILD -e mybuild.env)'
|
|
|
|
echo "or rerun this script using a directory in the system path (e.g ./install /usr/bin build)"
|
2023-03-25 11:27:22 -07:00
|
|
|
fi
|