updating echo dependency to 1.2

This commit is contained in:
a-sansara 2018-12-22 02:29:00 +01:00
parent 9b7bf95b94
commit 808a6cfb90
6 changed files with 251 additions and 191 deletions

View File

@ -11,5 +11,5 @@ keywords = "bash, bes, build"
[require] [require]
bes.ini = 1.1 bes.ini = 1.1
bes.echo = 1.1 bes.echo = 1.2
bes.install = 1.0 bes.install = 1.1

340
dist/bes-build vendored
View File

@ -1,6 +1,103 @@
#!/bin/bash #!/bin/bash
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
# @author a-Sansara - https://git.pluie.org/meta-tech/bes-color
# @app bes-color
# @license GNU GPL v3
# @date 2017-10-23 23:30:54 CET
#
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.color.boot () {
BES_NOCOLOR=${BES_NOCOLOR:-0}
if [ "$BES_NOCOLOR" -eq 0 ]; then
# by convention all colors begins with 'C' uppercase
# followed by a name in lowercase
# background foreground
# R G B R G B
color.set "Chead" 53 114 160 195 223 255
color.set "Cheadsep" 53 114 160 252 212 102
# background
# R G B
color.bg "Cdone" 63 172 138
color.bg "Cfail" 172 63 85
# foreground
# R G B
color.fg "Ctitle" 133 92 181
color.fg "Cheadline" 22 74 133
color.fg "Csep" 80 80 80
color.fg "Cerr" 194 48 64
color.fg "Cval" 255 175 95
color.fg "Ckey" 40 168 134
color.fg "Caction" 106 183 241
color.fg "Csymbol" 255 175 95
color.fg "Citem" 92 147 181
color.fg "Cusa" 255 172 0
color.fg "Cspe" 255 214 166
color.fg "Copt" 94 215 255
color.fg "Ccom" 175 135 175
color.fg "Ctext" 0 132 101
color.fg "Cmeta" 39 100 170
Coff="\\033[m"
fi
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function color.fg()
{
local -n var=$1
var="\033[1;38;2;$2;$3;$4m"
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function color.bg()
{
local -n var=$1
var="\033[1;48;2;$2;$3;$4m"
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function color.set()
{
local -n var=$1
var="\033[1;48;2;$2;$3;$4;1;38;2;$5;$6;$7m"
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function color.rgb ()
{
local c=${3:-0}
local v=$1
local -n r=${2}_r
local -n g=${2}_g
local -n b=${2}_b
if [ -z "$v" ]; then
r=$c
g=$c
b=$c
return
fi
r=${v%%;*}
[ "$v" = "$r" ] && v='' || v="${v#*;}"
if [ -z "$r" ]; then r=$c; fi
g=${v%%;*}
[ "$v" = "$g" ] && v='' || v="${v#*;}"
if [ -z "$g" ]; then g=$c; fi
b=${v%%;*}
if [ -z "$b" ]; then b=$c; fi
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function color.env () {
local -n var=${2:-shenv}
local v=ctx$1
local ctxPROD="174 8 49"
local ctxINT="218 84 0"
local ctxDEV="218 159 0"
local ctxLOCAL="122 122 122"
if [ -z "${!v}" ]; then
v=ctxLOCAL
SHENV_CTX=LOCAL
fi
var=${!v}
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bes.color.boot
#
# @author a-Sansara - https://git.pluie.org/meta-tech/bes-echo # @author a-Sansara - https://git.pluie.org/meta-tech/bes-echo
# @app bes-echo # @app bes-echo
# @license GNU GPL v3 # @license GNU GPL v3
@ -9,80 +106,49 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.echo.boot () function bes.echo.boot ()
{ {
BES_TERM_WIDTH=${BES_TERM_WIDTH:-105} BES_TERM_WIDTH=${COLUMNS:-130}
BES_NOCOLOR=${BES_NOCOLOR:-0} BES_TERM_WIDTH=$(($BES_TERM_WIDTH - 20))
if [ "$BES_NOCOLOR" -eq 0 ]; then
Cok="\033[0;38;5;43m"; Cko="\033[0;38;5;217m"
Coff="\033[m"; Ctitle="\033[1;48;5;24;1;38;5;15m"
Cdone="\033[1;48;5;36;1;38;5;15m"; Cfail="\033[1;48;5;196;1;38;5;15m"
Cspe="\033[1;38;5;223m"; Citem="\033[1;38;5;214m"
Cval="\033[1;38;5;215m"; Cusa="\033[1;38;5;214m"
Cbra="\033[1;38;5;203m"; Crepo="\033[1;38;5;223m"
Cmeta="\033[1;38;5;30m"; Ctext="\033[1;38;5;30m"
Copt="\033[1;38;5;81m"; Csep="\033[1;38;5;241m"
Cerr="\033[1;38;5;196m"; Ccom="\033[0;38;5;139m"
Csection="\033[1;38;5;97m"; Caction="\033[0;38;5;37m"
fi
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.echo () function echo.msg ()
{ {
local msg=${1:-''} local c=${2:-}
local isAction=${2:-'0'} local m=${1:-}
local symbol=${3:-' *'} echo -e " $c$m$Coff"
if [ ! "$BES_NOCOLOR" = 1 ]; then
local c=" "
if [ -z "$isAction" ] || [ "$isAction" = 1 ]; then
c=$Caction
fi
if [ ! "$isAction" = 0 ]; then
c=" $Citem$symbol $c"
fi
echo -e " $c$msg$Coff"
else
if [ ! "$isAction" = 0 ]; then
msg=" $symbol $msg"
fi
echo -e "$msg"
fi
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.echo.action () function echo.state ()
{ {
bes.echo "$1" 1 local len=14
} echo -en " $Csep"
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ printf "%0.s-" $(seq 1 $(($BES_TERM_WIDTH-${len})))
function bes.echo.title ()
{
echo
bes.echo " ${Citem}☪ ${Csection}$1 ${Cspe}$2${Coff}"
echo
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.echo.keyval ()
{
local c=': '
if [ ! "$BES_NOCOLOR" = 1 ]; then
c="$Citem: ${Cval}"
fi
local len="%-15s "
# printf "%s %s [UP]\n" $PROC_NAME "${line:${#PROC_NAME}}"
bes.echo "$(printf $len $1) $c$2 " 1 " "
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.echo.state ()
{
local len=8
printf "%0.s " $(seq 1 $(($BES_TERM_WIDTH-${len})))
if [ "$1" = 0 ]; then if [ "$1" = 0 ]; then
echo -e "${Cdone} OK ${Coff}" echo -e "$Coff $Cdone OK $Coff\n"
else else
echo -e "${Cfail} KO ${Coff}" echo -e "$Coff $Cfail KO $Coff\n"
fi fi
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.echo.rs () function echo.action ()
{
local symbol=${3:-*}
local color=${4:-Citem}
echo -e " $Csymbol$symbol ${Caction}$1 ${!color}$2$Coff"
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function echo.title ()
{
echo -e "\n $Csymbol☪ $Ctitle$1 $Coff$Cspe$2$Coff\n"
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function echo.keyval ()
{
local len=${3:-20}
local c="$Ckey: ${Cval}"
echo -e " $Ckey $(printf "%-${len}s " "$1") ${c}${2} $Coff"
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function echo.rs ()
{ {
local rs=${1:-0} local rs=${1:-0}
if [ "$rs" -eq 0 ]; then if [ "$rs" -eq 0 ]; then
@ -92,47 +158,39 @@ function bes.echo.rs ()
fi fi
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.echo.error () function echo.error ()
{ {
local leave=${2:-0}
echo -e "\n${Cerr} error : ${Coff}\n\t$1 ${Coff}\n" echo -e "\n${Cerr} error : ${Coff}\n\t$1 ${Coff}\n"
if [ "$leave" = "1" ]; then
exit 1;
fi
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.echo.sepline () function echo.sepline ()
{ {
local char=${1:-'_'} local char=${1:-'_'}
local width=${2:-$BES_TERM_WIDTH} local width=${2:-$BES_TERM_WIDTH}
echo -ne "${Csep} " echo -ne "${Cheadline} "
printf "%0.s$char" $(seq 1 $width) printf "%0.s$char" $(seq 1 $width)
echo -e "${Coff}" echo -e "${Coff}"
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.echo.app () function echo.app ()
{ {
local msg=${1:-''} local msg=${1:-''}
local version=${2:-''} local version=${2:-''}
local author=${3:-'a-Sansara'} local author=${3:-'a-Sansara'}
local license=${3:-'GNU GPL v3'}
if [ ! -z "$2" ]; then if [ ! -z "$2" ]; then
msg="$msg ${Cval}v$version" msg="$msg ${Cval}v$version"
fi fi
local len="$1${version}license : GNU GPL v3 author:$author" local len="$1${version}license : $license author:$author"
bes.echo.sepline echo.sepline
echo -ne "\n $Ctitle $msg $Coff" echo -ne "\n $Chead $msg $Coff"
printf "%0.s " $(seq 1 $(($BES_TERM_WIDTH-${#len}-15))) printf "%0.s " $(seq 1 $(($BES_TERM_WIDTH-${#len}-15)))
echo -e " ${Cmeta}license : ${Coff}GNU GPL v3 ${Cmeta}author : ${Cval}$author" echo -e " ${Cmeta}license : ${Coff}$license ${Cmeta}author : ${Cval}$author"
bes.echo.sepline echo.sepline
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.echo.colormap ()
{
for fgbg in 38 48 ; do
for color in {0..256} ; do
echo -en "\e[${fgbg};5;${color}m ${color}\t\e[0m"
if [ $((($color + 1) % 7)) == 0 ] ; then
echo
fi
done
echo
done
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bes.echo.boot bes.echo.boot
@ -442,8 +500,10 @@ function bes.install ()
local url=${2} local url=${2}
local path=${3:-/usr/local/bin} local path=${3:-/usr/local/bin}
local done=1 local done=1
bes.echo.title "Installing $app ${Coff}in" "$path" echo.title "Installing $app ${Coff}in" "$path"
if [ -z "$app" ] || [ -s "$url" ]; then
echo.error "in bes.install : \$app '$app' & \$url '$url' are required" 1
fi
if [ -f "./$app" ]; then if [ -f "./$app" ]; then
rm ./$app rm ./$app
fi fi
@ -453,38 +513,38 @@ function bes.install ()
if [ -d $path ]; then if [ -d $path ]; then
sudo mv ./$app $path/$app sudo mv ./$app $path/$app
local done=$? local done=$?
bes.echo.state $done echo.state $done
else else
bes.echo.error "install directory do not exists : ${Cspe}$path" echo.error "install directory do not exists : ${Cspe}$path"
fi fi
else else
bes.echo.error "can not download latest version of app $app. please check url : $url" echo.error "can not download latest version of app $app. please check url : $url"
fi fi
bes.echo.rs $done echo.rs $done
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.build () function bes.build ()
{ {
bes.echo.title "building project" "$APP_NAME" echo.title "building project" "$APP_NAME"
if [ -d "$APP_DIR/src" ]; then if [ -d "$APP_DIR/src" ]; then
if [ ! -d "$APP_DIR/dist" ]; then if [ ! -d "$APP_DIR/dist" ]; then
bes.echo.action "creating dist directory" echo.action "creating dist directory"
mkdir $APP_DIR/dist mkdir $APP_DIR/dist
bes.echo.state $? cho.state $?
fi fi
if [ -f "$APP_BIN" ]; then if [ -f "$APP_BIN" ]; then
if [ "$1" = "backup" ] || [ "$1" = "-b" ]; then if [ "$1" = "backup" ] || [ "$1" = "-b" ]; then
bes.echo.action "backup last build to ${Coff}dist/$(date +%y%m%d)-$APP_NAME${Coff}" echo.action "backup last build to ${Coff}dist/$(date +%y%m%d)-$APP_NAME${Coff}"
mv $APP_BIN $APP_DIR/dist/$(date +%y%m%d)-$APP_NAME mv $APP_BIN $APP_DIR/dist/$(date +%y%m%d)-$APP_NAME
else else
bes.echo.action "removing ${Coff}dist/$APP_NAME${Coff}" echo.action "removing ${Coff}dist/$APP_NAME${Coff}"
rm $APP_BIN rm $APP_BIN
fi fi
bes.echo.state $? echo.state $?
fi fi
echo "#!/bin/bash" > $APP_BIN echo "#!/bin/bash" > $APP_BIN
bes.echo.action "reading ${Coff}dependencies" echo.action "reading ${Coff}dependencies"
if [ -d "$APP_DIR/vendor" ]; then if [ -d "$APP_DIR/vendor" ]; then
for vendor in $(ls $APP_DIR/vendor/); do for vendor in $(ls $APP_DIR/vendor/); do
if [ "$vendor" != "." ] && [ "$vendor" != ".." ]; then if [ "$vendor" != "." ] && [ "$vendor" != ".." ]; then
@ -494,7 +554,7 @@ function bes.build ()
local entrypath="$APP_DIR/vendor/$vendor/$project/src/$(basename $entry)" local entrypath="$APP_DIR/vendor/$vendor/$project/src/$(basename $entry)"
if [ -f "$entrypath" ] && [ "${entrypath: -3}" = ".sh" ]; then if [ -f "$entrypath" ] && [ "${entrypath: -3}" = ".sh" ]; then
tail -n +2 "$entrypath" >> "$APP_BIN" tail -n +2 "$entrypath" >> "$APP_BIN"
bes.echo " ${Cspe}- ${Cok}appending ${Cusa}$vendorName/$project/${Coff}src/$(basename $entry)" echo.msg " ${Cspe}- ${Cok}appending ${Cusa}$vendorName/$project/${Coff}src/$(basename $entry)"
fi fi
done done
fi fi
@ -502,34 +562,34 @@ function bes.build ()
fi fi
done done
else else
bes.echo " no dependencies, did you forget to run bes-build update ?" echo.msg " no dependencies, did you forget to run bes-build update ?"
fi fi
bes.echo.state 0 echo.state 0
bes.echo.action "reading ${Coff}src/" echo.action "reading ${Coff}src/"
for entry in "$APP_DIR/src"/*.sh; do for entry in "$APP_DIR/src"/*.sh; do
if [ "$(basename $entry)" != "main.sh" ]; then if [ "$(basename $entry)" != "main.sh" ]; then
bes.echo " ${Cspe}- ${Cok}appending ${Coff}src/$(basename $entry)" echo.msg " ${Cspe}- ${Cok}appending ${Coff}src/$(basename $entry)"
tail -n +2 "$entry" >> "$APP_BIN" tail -n +2 "$entry" >> "$APP_BIN"
fi fi
done done
if [ -f "$APP_DIR/src/main.sh" ]; then if [ -f "$APP_DIR/src/main.sh" ]; then
tail -n +2 "$APP_DIR/src/main.sh" >> "$APP_BIN" tail -n +2 "$APP_DIR/src/main.sh" >> "$APP_BIN"
bes.echo " ${Cspe}- ${Cok}appending ${Coff}src/main.sh" echo.msg " ${Cspe}- ${Cok}appending ${Coff}src/main.sh"
fi fi
bes.echo.state 0 echo.state 0
bes.echo.action "set execution mode" echo.action "set execution mode"
chmod +x $APP_BIN chmod +x $APP_BIN
done=$? done=$?
bes.echo.state $done echo.state $done
bes.echo.rs $done echo.rs $done
else else
bes.echo.error "no src/ directory. exit" echo.error "no src/ directory. exit"
bes.echo.state 1 echo.state 1
fi fi
} }
BES_LIB="echo install ini dep1 dep2" BES_LIB="color echo install ini dep1 dep2"
BES_LOADED_LIB= BES_LOADED_LIB=
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.inlist () function bes.inlist ()
@ -559,11 +619,11 @@ function bes.loadExtDep ()
local vendor=${key%_*} local vendor=${key%_*}
local version=${!name} local version=${!name}
if [ ! "$vendor" = "bes" ]; then if [ ! "$vendor" = "bes" ]; then
bes.echo.title "Loading" "${key//_/.}${Cusa} ${!name}${Coff}" echo.title "Loading" "${key//_/.}${Cusa} ${!name}${Coff}"
if [ ! -d "$APP_DIR/vendor/$vendor" ]; then if [ ! -d "$APP_DIR/vendor/$vendor" ]; then
bes.echo.action "creating vendor directory ${Cusa}$vendor" echo.action "creating vendor directory ${Cusa}$vendor"
mkdir -p "$APP_DIR/vendor/$vendor" mkdir -p "$APP_DIR/vendor/$vendor"
bes.echo.state $? echo.state $?
fi fi
if [ "${version:0:4}" = "http" ]; then if [ "${version:0:4}" = "http" ]; then
local req=${!name} local req=${!name}
@ -580,13 +640,13 @@ function bes.loadExtDep ()
cd "$APP_DIR/vendor/$vendor/$project" cd "$APP_DIR/vendor/$vendor/$project"
git checkout $tag git checkout $tag
for entry in "$APP_DIR/vendor/$vendor/$project/src"/*.sh; do for entry in "$APP_DIR/vendor/$vendor/$project/src"/*.sh; do
bes.echo " ${Cspe}- ${Cok}set for autoloading ${Coff}src/$(basename $entry)" echo.msg " ${Cspe}- ${Cok}set for autoloading ${Coff}src/$(basename $entry)"
# tail -n +2 "$entry" >> "$APP_BIN" # tail -n +2 "$entry" >> "$APP_BIN"
done done
bes.echo.state $? echo.state $?
fi fi
fi fi
bes.echo.rs echo.rs
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.loadDep () function bes.loadDep ()
@ -598,47 +658,47 @@ function bes.loadDep ()
local vendor=${key%_*} local vendor=${key%_*}
local version=${!name} local version=${!name}
if [ "$vendor" = "bes" ]; then if [ "$vendor" = "bes" ]; then
bes.echo.title "Loading" "${key//_/.}${Cusa} ${!name}${Coff}" echo.title "Loading" "${key//_/.}${Cusa} ${!name}${Coff}"
if bes.inlist "$project" "$BES_LIB"; then if bes.inlist "$project" "$BES_LIB"; then
if bes.inlist "$project" "$BES_LOADED_LIB"; then if bes.inlist "$project" "$BES_LOADED_LIB"; then
bes.echo.action "dependencies already loaded for ${Cusa}$project" echo.action "dependencies already loaded for ${Cusa}$project"
bes.echo echo
else else
if [ "$bescheck" = "1" ]; then if [ "$bescheck" = "1" ]; then
if [ ! -d "$APP_DIR/vendor/$vendor" ]; then if [ ! -d "$APP_DIR/vendor/$vendor" ]; then
bes.echo.action "creating vendor directory ${Cusa}$vendor" echo.action "creating vendor directory ${Cusa}$vendor"
mkdir -p "$APP_DIR/vendor/$vendor" mkdir -p "$APP_DIR/vendor/$vendor"
else else
bes.echo.action "checking vendor directory ${Cusa}$vendor" echo.action "checking vendor directory ${Cusa}$vendor"
fi fi
bes.echo.state $? echo.state $?
bescheck=0 bescheck=0
echo "[bes_vendor]" > $APP_DIR/vendor/.bes echo "[bes_vendor]" > $APP_DIR/vendor/.bes
fi fi
echo "$project = $version" >> $APP_DIR/vendor/.bes echo "$project = $version" >> $APP_DIR/vendor/.bes
cd "$APP_DIR/vendor/$vendor" cd "$APP_DIR/vendor/$vendor"
bes.echo.action "updating repository $Cusa$vendor.$project ${Coff}:$Cusa $version" echo.action "updating repository $Cusa$vendor.$project ${Coff}:$Cusa $version"
if [ ! -d "$project" ]; then if [ ! -d "$project" ]; then
git clone -q "https://git.pluie.org/meta-tech/$vendor-$project" "$project" 2>&1 >/dev/null git clone -q "https://git.pluie.org/meta-tech/$vendor-$project" "$project" 2>&1 >/dev/null
#~ bes.echo.state $? #~ echo.state $?
cd $project cd $project
else else
cd $project cd $project
git fetch --all -q 2>&1 >/dev/null git fetch --all -q 2>&1 >/dev/null
#~ bes.echo.state $? #~ echo.state $?
fi fi
#~ bes.echo.action "checkout to version $Cusa$version" #~ echo.action "checkout to version $Cusa$version"
local branch=$(git branch --no-color | grep \* | cut -d ' ' -f2-) local branch=$(git branch --no-color | grep \* | cut -d ' ' -f2-)
# branch=${branch:5: -3} # branch=${branch:5: -3}
if [ "$branch" != "$version" ]; then if [ "$branch" != "$version" ]; then
git checkout -q $version 2>&1 >/dev/null git checkout -q $version 2>&1 >/dev/null
fi fi
bes.echo.state $? echo.state $?
for entry in "$APP_DIR/vendor/$vendor/$project/src"/*.sh; do for entry in "$APP_DIR/vendor/$vendor/$project/src"/*.sh; do
bes.echo " ${Cspe}- ${Cok}set for autoloading ${Coff}src/$(basename $entry)" echo.msg " ${Cspe}- ${Cok}set for autoloading ${Coff}src/$(basename $entry)"
# tail -n +2 "$entry" >> "$APP_BIN" # tail -n +2 "$entry" >> "$APP_BIN"
done done
bes.echo.state $? echo.state $?
bes.addLoadedLib $project bes.addLoadedLib $project
bes.ini "$APP_DIR/vendor/$vendor/$project/bes.ini" require -p bes$project -b 1 bes.ini "$APP_DIR/vendor/$vendor/$project/bes.ini" require -p bes$project -b 1
local suballvarname=bes${project}_ALL_VARS local suballvarname=bes${project}_ALL_VARS
@ -652,8 +712,8 @@ function bes.loadDep ()
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.update () function bes.update ()
{ {
bes.echo.title "Reading Project" $APP_NAME echo.title "Reading Project" $APP_NAME
bes.echo.keyval path $APP_DIR echo.keyval path $APP_DIR
if [ -f $APP_DIR/bes.ini ]; then if [ -f $APP_DIR/bes.ini ]; then
bes.ini $APP_DIR/bes.ini -p bes -b 1 bes.ini $APP_DIR/bes.ini -p bes -b 1
@ -663,7 +723,7 @@ function bes.update ()
for key in $keys; do for key in $keys; do
value="bes_project_$key" value="bes_project_$key"
if [ ! -z "${!value}" ]; then if [ ! -z "${!value}" ]; then
bes.echo.keyval $key "${!value}" echo.keyval $key "${!value}"
fi fi
done done
@ -682,10 +742,10 @@ function bes.update ()
local key="" local key=""
local bescheck=1; local bescheck=1;
if [ ! -z "${bes_ALL_VARS}" ]; then if [ ! -z "${bes_ALL_VARS}" ]; then
bes.echo.title "Checking Dependencies" echo.title "Checking Dependencies"
for name in ${bes_ALL_VARS}; do for name in ${bes_ALL_VARS}; do
key=${name:${#prefix}+1} key=${name:${#prefix}+1}
bes.echo.keyval ${key//_/.} ${!name} echo.keyval ${key//_/.} ${!name}
done done
echo echo
for name in ${bes_ALL_VARS}; do for name in ${bes_ALL_VARS}; do
@ -695,8 +755,8 @@ function bes.update ()
fi fi
else else
echo echo
bes.echo ' no bes.ini file for your project' echo.msg ' no bes.ini file for your project'
bes.echo.state echo.state
fi fi
} }
@ -708,7 +768,7 @@ function bes.usage ()
${Cspe}\t$APP_NAME ${Copt} ${Cspe}\t$APP_NAME ${Copt}
${Ccom}\tBuild current project and backup existing build ${Ccom}\tBuild current project and backup existing build
${Cspe}\t$APP_NAME ${Copt}-b${Ctext}, ${Copt}backup ${Cspe}\t$APP_NAME ${Copt}-b${Ctext}, ${Copt}backup
${Ccom}\tInstall or update $APP_NAME on specified BINDIR directory or in /etc/local/bin directory ${Ccom}\tInstall or update $APP_NAME on specified BINDIR directory or in /usr/local/bin directory
${Cspe}\t$APP_NAME ${Copt}-i${Ctext}, ${Copt}install ${Copt}[ ${Ctext}BINDIR${Copt} ] ${Cspe}\t$APP_NAME ${Copt}-i${Ctext}, ${Copt}install ${Copt}[ ${Ctext}BINDIR${Copt} ]
${Ccom}\tDisplay program version ${Ccom}\tDisplay program version
${Cspe}\t$APP_NAME ${Copt}-v${Ctext}, ${Copt}version ${Cspe}\t$APP_NAME ${Copt}-v${Ctext}, ${Copt}version
@ -725,7 +785,7 @@ function bes.usage ()
# @date 2017-06-16 04:38:52 CET # @date 2017-06-16 04:38:52 CET
# #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BES_VERSION=0.7 BES_VERSION=0.8
BES_NAME="bes-build" BES_NAME="bes-build"
BES_URL="https://git.pluie.org/meta-tech/$BES_NAME/raw/latest/dist/$BES_NAME" BES_URL="https://git.pluie.org/meta-tech/$BES_NAME/raw/latest/dist/$BES_NAME"
APP_DIR=$(pwd) APP_DIR=$(pwd)
@ -738,7 +798,7 @@ function bes.main ()
if [ "$1" = "version" ] || [ "$1" = "-v" ]; then if [ "$1" = "version" ] || [ "$1" = "-v" ]; then
echo $BES_VERSION echo $BES_VERSION
else else
bes.echo.app "$BES_NAME" "$BES_VERSION" echo.app "$BES_NAME" "$BES_VERSION"
echo echo
if [ "$1" = "install" ] || [ "$1" = "-i" ]; then if [ "$1" = "install" ] || [ "$1" = "-i" ]; then
bes.install "$BES_NAME" "$BES_URL" "$2" bes.install "$BES_NAME" "$BES_URL" "$2"

View File

@ -3,25 +3,25 @@
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.build () function bes.build ()
{ {
bes.echo.title "building project" "$APP_NAME" echo.title "building project" "$APP_NAME"
if [ -d "$APP_DIR/src" ]; then if [ -d "$APP_DIR/src" ]; then
if [ ! -d "$APP_DIR/dist" ]; then if [ ! -d "$APP_DIR/dist" ]; then
bes.echo.action "creating dist directory" echo.action "creating dist directory"
mkdir $APP_DIR/dist mkdir $APP_DIR/dist
bes.echo.state $? cho.state $?
fi fi
if [ -f "$APP_BIN" ]; then if [ -f "$APP_BIN" ]; then
if [ "$1" = "backup" ] || [ "$1" = "-b" ]; then if [ "$1" = "backup" ] || [ "$1" = "-b" ]; then
bes.echo.action "backup last build to ${Coff}dist/$(date +%y%m%d)-$APP_NAME${Coff}" echo.action "backup last build to ${Coff}dist/$(date +%y%m%d)-$APP_NAME${Coff}"
mv $APP_BIN $APP_DIR/dist/$(date +%y%m%d)-$APP_NAME mv $APP_BIN $APP_DIR/dist/$(date +%y%m%d)-$APP_NAME
else else
bes.echo.action "removing ${Coff}dist/$APP_NAME${Coff}" echo.action "removing ${Coff}dist/$APP_NAME${Coff}"
rm $APP_BIN rm $APP_BIN
fi fi
bes.echo.state $? echo.state $?
fi fi
echo "#!/bin/bash" > $APP_BIN echo "#!/bin/bash" > $APP_BIN
bes.echo.action "reading ${Coff}dependencies" echo.action "reading ${Coff}dependencies"
if [ -d "$APP_DIR/vendor" ]; then if [ -d "$APP_DIR/vendor" ]; then
for vendor in $(ls $APP_DIR/vendor/); do for vendor in $(ls $APP_DIR/vendor/); do
if [ "$vendor" != "." ] && [ "$vendor" != ".." ]; then if [ "$vendor" != "." ] && [ "$vendor" != ".." ]; then
@ -31,7 +31,7 @@ function bes.build ()
local entrypath="$APP_DIR/vendor/$vendor/$project/src/$(basename $entry)" local entrypath="$APP_DIR/vendor/$vendor/$project/src/$(basename $entry)"
if [ -f "$entrypath" ] && [ "${entrypath: -3}" = ".sh" ]; then if [ -f "$entrypath" ] && [ "${entrypath: -3}" = ".sh" ]; then
tail -n +2 "$entrypath" >> "$APP_BIN" tail -n +2 "$entrypath" >> "$APP_BIN"
bes.echo " ${Cspe}- ${Cok}appending ${Cusa}$vendorName/$project/${Coff}src/$(basename $entry)" echo.msg " ${Cspe}- ${Cok}appending ${Cusa}$vendorName/$project/${Coff}src/$(basename $entry)"
fi fi
done done
fi fi
@ -39,29 +39,29 @@ function bes.build ()
fi fi
done done
else else
bes.echo " no dependencies, did you forget to run bes-build update ?" echo.msg " no dependencies, did you forget to run bes-build update ?"
fi fi
bes.echo.state 0 echo.state 0
bes.echo.action "reading ${Coff}src/" echo.action "reading ${Coff}src/"
for entry in "$APP_DIR/src"/*.sh; do for entry in "$APP_DIR/src"/*.sh; do
if [ "$(basename $entry)" != "main.sh" ]; then if [ "$(basename $entry)" != "main.sh" ]; then
bes.echo " ${Cspe}- ${Cok}appending ${Coff}src/$(basename $entry)" echo.msg " ${Cspe}- ${Cok}appending ${Coff}src/$(basename $entry)"
tail -n +2 "$entry" >> "$APP_BIN" tail -n +2 "$entry" >> "$APP_BIN"
fi fi
done done
if [ -f "$APP_DIR/src/main.sh" ]; then if [ -f "$APP_DIR/src/main.sh" ]; then
tail -n +2 "$APP_DIR/src/main.sh" >> "$APP_BIN" tail -n +2 "$APP_DIR/src/main.sh" >> "$APP_BIN"
bes.echo " ${Cspe}- ${Cok}appending ${Coff}src/main.sh" echo.msg " ${Cspe}- ${Cok}appending ${Coff}src/main.sh"
fi fi
bes.echo.state 0 echo.state 0
bes.echo.action "set execution mode" echo.action "set execution mode"
chmod +x $APP_BIN chmod +x $APP_BIN
done=$? done=$?
bes.echo.state $done echo.state $done
bes.echo.rs $done echo.rs $done
else else
bes.echo.error "no src/ directory. exit" echo.error "no src/ directory. exit"
bes.echo.state 1 echo.state 1
fi fi
} }

View File

@ -7,7 +7,7 @@
# @date 2017-06-16 04:38:52 CET # @date 2017-06-16 04:38:52 CET
# #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BES_VERSION=0.7 BES_VERSION=0.8
BES_NAME="bes-build" BES_NAME="bes-build"
BES_URL="https://git.pluie.org/meta-tech/$BES_NAME/raw/latest/dist/$BES_NAME" BES_URL="https://git.pluie.org/meta-tech/$BES_NAME/raw/latest/dist/$BES_NAME"
APP_DIR=$(pwd) APP_DIR=$(pwd)
@ -20,7 +20,7 @@ function bes.main ()
if [ "$1" = "version" ] || [ "$1" = "-v" ]; then if [ "$1" = "version" ] || [ "$1" = "-v" ]; then
echo $BES_VERSION echo $BES_VERSION
else else
bes.echo.app "$BES_NAME" "$BES_VERSION" echo.app "$BES_NAME" "$BES_VERSION"
echo echo
if [ "$1" = "install" ] || [ "$1" = "-i" ]; then if [ "$1" = "install" ] || [ "$1" = "-i" ]; then
bes.install "$BES_NAME" "$BES_URL" "$2" bes.install "$BES_NAME" "$BES_URL" "$2"

View File

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

View File

@ -8,7 +8,7 @@ function bes.usage ()
${Cspe}\t$APP_NAME ${Copt} ${Cspe}\t$APP_NAME ${Copt}
${Ccom}\tBuild current project and backup existing build ${Ccom}\tBuild current project and backup existing build
${Cspe}\t$APP_NAME ${Copt}-b${Ctext}, ${Copt}backup ${Cspe}\t$APP_NAME ${Copt}-b${Ctext}, ${Copt}backup
${Ccom}\tInstall or update $APP_NAME on specified BINDIR directory or in /etc/local/bin directory ${Ccom}\tInstall or update $APP_NAME on specified BINDIR directory or in /usr/local/bin directory
${Cspe}\t$APP_NAME ${Copt}-i${Ctext}, ${Copt}install ${Copt}[ ${Ctext}BINDIR${Copt} ] ${Cspe}\t$APP_NAME ${Copt}-i${Ctext}, ${Copt}install ${Copt}[ ${Ctext}BINDIR${Copt} ]
${Ccom}\tDisplay program version ${Ccom}\tDisplay program version
${Cspe}\t$APP_NAME ${Copt}-v${Ctext}, ${Copt}version ${Cspe}\t$APP_NAME ${Copt}-v${Ctext}, ${Copt}version