manage update : load bes dependencies recursively

This commit is contained in:
a-sansara 2018-06-18 16:15:13 +02:00
parent 3d2df2da3c
commit 9b7bf95b94
2 changed files with 246 additions and 144 deletions

189
dist/bes-build vendored
View File

@ -529,8 +529,8 @@ function bes.build ()
fi fi
} }
BES_LIB="echo install ini" BES_LIB="echo install ini dep1 dep2"
BES_LOADED_LIB=
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.inlist () function bes.inlist ()
{ {
@ -541,78 +541,25 @@ function bes.inlist ()
return $rs return $rs
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.update () function bes.addLoadedLib ()
{ {
bes.echo.title "Reading Project" $APP_NAME local sep=" "
bes.echo.keyval path $APP_DIR if [ -z "$BES_LOADED_LIB" ]; then
sep=""
if [ -f $APP_DIR/bes.ini ]; then
bes.ini $APP_DIR/bes.ini -p bes -b 1
local keys="vendor name version license author"
local value=""
for key in $keys; do
value="bes_project_$key"
if [ ! -z "${!value}" ]; then
bes.echo.keyval $key "${!value}"
fi fi
done BES_LOADED_LIB=$BES_LOADED_LIB$sep$1
}
bes.ini "$APP_DIR/bes.ini" require -p bes -b 1 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local prefix="bes_require" function bes.loadExtDep ()
local key="" {
local bescheck=1; local name=$1
if [ ! -z "${bes_ALL_VARS}" ]; then local prefix=$2
bes.echo.title "Checking Dependencies" local key=${name:${#prefix}+1}
for name in ${bes_ALL_VARS}; do
key=${name:${#prefix}+1}
bes.echo.keyval ${key//_/.} ${!name}
done
echo
for name in ${bes_ALL_VARS}; do
key=${name:${#prefix}+1}
bes.echo.title "Loading" "${key//_/.}${Cusa} ${!name}${Coff}"
local project=${key#*_} local project=${key#*_}
local vendor=${key%_*} local vendor=${key%_*}
local version=${!name} local version=${!name}
bes.inlist "$project" "$BES_LIB" if [ ! "$vendor" = "bes" ]; then
if [ "$vendor" = "bes" ]; then bes.echo.title "Loading" "${key//_/.}${Cusa} ${!name}${Coff}"
if bes.inlist "$project" "$BES_LIB"; then
if [ "$bescheck" = "1" ]; then
if [ ! -d "$APP_DIR/vendor/$vendor" ]; then
bes.echo.action "creating vendor directory ${Cusa}$vendor"
mkdir -p "$APP_DIR/vendor/$vendor"
else
bes.echo.action "checking vendor directory ${Cusa}$vendor"
fi
bes.echo.state $?
bescheck=0
fi
cd "$APP_DIR/vendor/$vendor"
bes.echo.action "updating repository $Cusa$vendor.$project ${Coff}:$Cusa $version"
if [ ! -d "$project" ]; then
git clone -q "https://git.pluie.org/meta-tech/$vendor-$project" "$project" 2>&1 >/dev/null
#~ bes.echo.state $?
cd $project
else
cd $project
git fetch --all -q 2>&1 >/dev/null
#~ bes.echo.state $?
fi
#~ bes.echo.action "checkout to version $Cusa$version"
local branch=$(git branch --no-color | grep \* | cut -d ' ' -f2-)
# branch=${branch:5: -3}
if [ "$branch" != "$version" ]; then
git checkout -q $version 2>&1 >/dev/null
fi
bes.echo.state $?
for entry in "$APP_DIR/vendor/$vendor/$project/src"/*.sh; do
bes.echo " ${Cspe}- ${Cok}set for autoloading ${Coff}src/$(basename $entry)"
# tail -n +2 "$entry" >> "$APP_BIN"
done
bes.echo.state $?
fi
else
if [ ! -d "$APP_DIR/vendor/$vendor" ]; then if [ ! -d "$APP_DIR/vendor/$vendor" ]; then
bes.echo.action "creating vendor directory ${Cusa}$vendor" bes.echo.action "creating vendor directory ${Cusa}$vendor"
mkdir -p "$APP_DIR/vendor/$vendor" mkdir -p "$APP_DIR/vendor/$vendor"
@ -640,6 +587,110 @@ function bes.update ()
fi fi
fi fi
bes.echo.rs bes.echo.rs
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.loadDep ()
{
local name=$1
local prefix=$2
local key=${name:${#prefix}+1}
local project=${key#*_}
local vendor=${key%_*}
local version=${!name}
if [ "$vendor" = "bes" ]; then
bes.echo.title "Loading" "${key//_/.}${Cusa} ${!name}${Coff}"
if bes.inlist "$project" "$BES_LIB"; then
if bes.inlist "$project" "$BES_LOADED_LIB"; then
bes.echo.action "dependencies already loaded for ${Cusa}$project"
bes.echo
else
if [ "$bescheck" = "1" ]; then
if [ ! -d "$APP_DIR/vendor/$vendor" ]; then
bes.echo.action "creating vendor directory ${Cusa}$vendor"
mkdir -p "$APP_DIR/vendor/$vendor"
else
bes.echo.action "checking vendor directory ${Cusa}$vendor"
fi
bes.echo.state $?
bescheck=0
echo "[bes_vendor]" > $APP_DIR/vendor/.bes
fi
echo "$project = $version" >> $APP_DIR/vendor/.bes
cd "$APP_DIR/vendor/$vendor"
bes.echo.action "updating repository $Cusa$vendor.$project ${Coff}:$Cusa $version"
if [ ! -d "$project" ]; then
git clone -q "https://git.pluie.org/meta-tech/$vendor-$project" "$project" 2>&1 >/dev/null
#~ bes.echo.state $?
cd $project
else
cd $project
git fetch --all -q 2>&1 >/dev/null
#~ bes.echo.state $?
fi
#~ bes.echo.action "checkout to version $Cusa$version"
local branch=$(git branch --no-color | grep \* | cut -d ' ' -f2-)
# branch=${branch:5: -3}
if [ "$branch" != "$version" ]; then
git checkout -q $version 2>&1 >/dev/null
fi
bes.echo.state $?
for entry in "$APP_DIR/vendor/$vendor/$project/src"/*.sh; do
bes.echo " ${Cspe}- ${Cok}set for autoloading ${Coff}src/$(basename $entry)"
# tail -n +2 "$entry" >> "$APP_BIN"
done
bes.echo.state $?
bes.addLoadedLib $project
bes.ini "$APP_DIR/vendor/$vendor/$project/bes.ini" require -p bes$project -b 1
local suballvarname=bes${project}_ALL_VARS
for subname in ${!suballvarname}; do
bes.loadDep "$subname" "bes${project}_require"
done
fi
fi
fi
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.update ()
{
bes.echo.title "Reading Project" $APP_NAME
bes.echo.keyval path $APP_DIR
if [ -f $APP_DIR/bes.ini ]; then
bes.ini $APP_DIR/bes.ini -p bes -b 1
local keys="vendor name version license author"
local value=""
for key in $keys; do
value="bes_project_$key"
if [ ! -z "${!value}" ]; then
bes.echo.keyval $key "${!value}"
fi
done
if [ -f "$APP_DIR/vendor/.bes" ]; then
bes.ini "$APP_DIR/vendor/.bes" bes_vendor -p bessed -b 1
local prefix="bes_vendor"
for name in ${bessed_ALL_VARS}; do
local key=${name:${#prefix}+1}
local project=${key#*_}
bes.addLoadedLib "$project"
done
fi
bes.ini "$APP_DIR/bes.ini" require -p bes -b 1
local prefix="bes_require"
local key=""
local bescheck=1;
if [ ! -z "${bes_ALL_VARS}" ]; then
bes.echo.title "Checking Dependencies"
for name in ${bes_ALL_VARS}; do
key=${name:${#prefix}+1}
bes.echo.keyval ${key//_/.} ${!name}
done
echo
for name in ${bes_ALL_VARS}; do
bes.loadDep "$name" "$prefix"
bes.loadExtDep "$name" "$prefix"
done done
fi fi
else else

View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
BES_LIB="echo install ini" BES_LIB="echo install ini dep1 dep2"
BES_LOADED_LIB=
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.inlist () function bes.inlist ()
{ {
@ -12,78 +12,25 @@ function bes.inlist ()
return $rs return $rs
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.update () function bes.addLoadedLib ()
{ {
bes.echo.title "Reading Project" $APP_NAME local sep=" "
bes.echo.keyval path $APP_DIR if [ -z "$BES_LOADED_LIB" ]; then
sep=""
if [ -f $APP_DIR/bes.ini ]; then
bes.ini $APP_DIR/bes.ini -p bes -b 1
local keys="vendor name version license author"
local value=""
for key in $keys; do
value="bes_project_$key"
if [ ! -z "${!value}" ]; then
bes.echo.keyval $key "${!value}"
fi fi
done BES_LOADED_LIB=$BES_LOADED_LIB$sep$1
}
bes.ini "$APP_DIR/bes.ini" require -p bes -b 1 # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
local prefix="bes_require" function bes.loadExtDep ()
local key="" {
local bescheck=1; local name=$1
if [ ! -z "${bes_ALL_VARS}" ]; then local prefix=$2
bes.echo.title "Checking Dependencies" local key=${name:${#prefix}+1}
for name in ${bes_ALL_VARS}; do
key=${name:${#prefix}+1}
bes.echo.keyval ${key//_/.} ${!name}
done
echo
for name in ${bes_ALL_VARS}; do
key=${name:${#prefix}+1}
bes.echo.title "Loading" "${key//_/.}${Cusa} ${!name}${Coff}"
local project=${key#*_} local project=${key#*_}
local vendor=${key%_*} local vendor=${key%_*}
local version=${!name} local version=${!name}
bes.inlist "$project" "$BES_LIB" if [ ! "$vendor" = "bes" ]; then
if [ "$vendor" = "bes" ]; then bes.echo.title "Loading" "${key//_/.}${Cusa} ${!name}${Coff}"
if bes.inlist "$project" "$BES_LIB"; then
if [ "$bescheck" = "1" ]; then
if [ ! -d "$APP_DIR/vendor/$vendor" ]; then
bes.echo.action "creating vendor directory ${Cusa}$vendor"
mkdir -p "$APP_DIR/vendor/$vendor"
else
bes.echo.action "checking vendor directory ${Cusa}$vendor"
fi
bes.echo.state $?
bescheck=0
fi
cd "$APP_DIR/vendor/$vendor"
bes.echo.action "updating repository $Cusa$vendor.$project ${Coff}:$Cusa $version"
if [ ! -d "$project" ]; then
git clone -q "https://git.pluie.org/meta-tech/$vendor-$project" "$project" 2>&1 >/dev/null
#~ bes.echo.state $?
cd $project
else
cd $project
git fetch --all -q 2>&1 >/dev/null
#~ bes.echo.state $?
fi
#~ bes.echo.action "checkout to version $Cusa$version"
local branch=$(git branch --no-color | grep \* | cut -d ' ' -f2-)
# branch=${branch:5: -3}
if [ "$branch" != "$version" ]; then
git checkout -q $version 2>&1 >/dev/null
fi
bes.echo.state $?
for entry in "$APP_DIR/vendor/$vendor/$project/src"/*.sh; do
bes.echo " ${Cspe}- ${Cok}set for autoloading ${Coff}src/$(basename $entry)"
# tail -n +2 "$entry" >> "$APP_BIN"
done
bes.echo.state $?
fi
else
if [ ! -d "$APP_DIR/vendor/$vendor" ]; then if [ ! -d "$APP_DIR/vendor/$vendor" ]; then
bes.echo.action "creating vendor directory ${Cusa}$vendor" bes.echo.action "creating vendor directory ${Cusa}$vendor"
mkdir -p "$APP_DIR/vendor/$vendor" mkdir -p "$APP_DIR/vendor/$vendor"
@ -111,6 +58,110 @@ function bes.update ()
fi fi
fi fi
bes.echo.rs bes.echo.rs
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.loadDep ()
{
local name=$1
local prefix=$2
local key=${name:${#prefix}+1}
local project=${key#*_}
local vendor=${key%_*}
local version=${!name}
if [ "$vendor" = "bes" ]; then
bes.echo.title "Loading" "${key//_/.}${Cusa} ${!name}${Coff}"
if bes.inlist "$project" "$BES_LIB"; then
if bes.inlist "$project" "$BES_LOADED_LIB"; then
bes.echo.action "dependencies already loaded for ${Cusa}$project"
bes.echo
else
if [ "$bescheck" = "1" ]; then
if [ ! -d "$APP_DIR/vendor/$vendor" ]; then
bes.echo.action "creating vendor directory ${Cusa}$vendor"
mkdir -p "$APP_DIR/vendor/$vendor"
else
bes.echo.action "checking vendor directory ${Cusa}$vendor"
fi
bes.echo.state $?
bescheck=0
echo "[bes_vendor]" > $APP_DIR/vendor/.bes
fi
echo "$project = $version" >> $APP_DIR/vendor/.bes
cd "$APP_DIR/vendor/$vendor"
bes.echo.action "updating repository $Cusa$vendor.$project ${Coff}:$Cusa $version"
if [ ! -d "$project" ]; then
git clone -q "https://git.pluie.org/meta-tech/$vendor-$project" "$project" 2>&1 >/dev/null
#~ bes.echo.state $?
cd $project
else
cd $project
git fetch --all -q 2>&1 >/dev/null
#~ bes.echo.state $?
fi
#~ bes.echo.action "checkout to version $Cusa$version"
local branch=$(git branch --no-color | grep \* | cut -d ' ' -f2-)
# branch=${branch:5: -3}
if [ "$branch" != "$version" ]; then
git checkout -q $version 2>&1 >/dev/null
fi
bes.echo.state $?
for entry in "$APP_DIR/vendor/$vendor/$project/src"/*.sh; do
bes.echo " ${Cspe}- ${Cok}set for autoloading ${Coff}src/$(basename $entry)"
# tail -n +2 "$entry" >> "$APP_BIN"
done
bes.echo.state $?
bes.addLoadedLib $project
bes.ini "$APP_DIR/vendor/$vendor/$project/bes.ini" require -p bes$project -b 1
local suballvarname=bes${project}_ALL_VARS
for subname in ${!suballvarname}; do
bes.loadDep "$subname" "bes${project}_require"
done
fi
fi
fi
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.update ()
{
bes.echo.title "Reading Project" $APP_NAME
bes.echo.keyval path $APP_DIR
if [ -f $APP_DIR/bes.ini ]; then
bes.ini $APP_DIR/bes.ini -p bes -b 1
local keys="vendor name version license author"
local value=""
for key in $keys; do
value="bes_project_$key"
if [ ! -z "${!value}" ]; then
bes.echo.keyval $key "${!value}"
fi
done
if [ -f "$APP_DIR/vendor/.bes" ]; then
bes.ini "$APP_DIR/vendor/.bes" bes_vendor -p bessed -b 1
local prefix="bes_vendor"
for name in ${bessed_ALL_VARS}; do
local key=${name:${#prefix}+1}
local project=${key#*_}
bes.addLoadedLib "$project"
done
fi
bes.ini "$APP_DIR/bes.ini" require -p bes -b 1
local prefix="bes_require"
local key=""
local bescheck=1;
if [ ! -z "${bes_ALL_VARS}" ]; then
bes.echo.title "Checking Dependencies"
for name in ${bes_ALL_VARS}; do
key=${name:${#prefix}+1}
bes.echo.keyval ${key//_/.} ${!name}
done
echo
for name in ${bes_ALL_VARS}; do
bes.loadDep "$name" "$prefix"
bes.loadExtDep "$name" "$prefix"
done done
fi fi
else else