update boot sequence

This commit is contained in:
a-sansara 2018-12-22 17:25:03 +01:00
parent 808a6cfb90
commit fa7aa891b5
4 changed files with 167 additions and 40 deletions

View File

@ -1,7 +1,7 @@
[project] [project]
vendor = bes vendor = bes
name = build name = build
version = 0.6 version = 0.9
license = "GNU GPL v3" license = "GNU GPL v3"
author = a-Sansara author = a-Sansara
type = application type = application
@ -10,6 +10,4 @@ description = "bash bes build application for bash programs"
keywords = "bash, bes, build" keywords = "bash, bes, build"
[require] [require]
bes.ini = 1.1 bes.install = 1.2
bes.echo = 1.2
bes.install = 1.1

167
dist/bes-build vendored
View File

@ -1,5 +1,31 @@
#!/bin/bash #!/bin/bash
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BES_BOOT=
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.exists () {
declare -f $1 > /dev/null
#~ [ x$(type -t $1) = xfunction ];
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.boot ()
{
for fn in $BES_BOOT; do
if bes.exists $fn.boot; then
$fn.boot
fi
done
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.reg ()
{
local sep=" "
if [ -z "$BES_BOOT" ]; then
sep=""
fi
BES_BOOT=$BES_BOOT$sep$1
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
# @author a-Sansara - https://git.pluie.org/meta-tech/bes-color # @author a-Sansara - https://git.pluie.org/meta-tech/bes-color
# @app bes-color # @app bes-color
@ -10,52 +36,67 @@
function bes.color.boot () { function bes.color.boot () {
BES_NOCOLOR=${BES_NOCOLOR:-0} BES_NOCOLOR=${BES_NOCOLOR:-0}
if [ "$BES_NOCOLOR" -eq 0 ]; then if [ "$BES_NOCOLOR" -eq 0 ]; then
# by convention all colors begins with 'C' uppercase color.load
# followed by a name in lowercase if [ $? -eq 1 ]; then
# background foreground # by convention all colors begins with 'C' uppercase
# R G B R G B # followed by a name in lowercase
color.set "Chead" 53 114 160 195 223 255 # but in this calls you dont need to prefix names
color.set "Cheadsep" 53 114 160 252 212 102 #
# background # background foreground
# R G B # R G B R G B
color.bg "Cdone" 63 172 138 color.set "head" 53 114 160 195 223 255
color.bg "Cfail" 172 63 85 color.set "headsep" 53 114 160 252 212 102
# foreground # background
# R G B # R G B
color.fg "Ctitle" 133 92 181 color.bg "done" 63 172 138
color.fg "Cheadline" 22 74 133 color.bg "fail" 172 63 85
color.fg "Csep" 80 80 80 # foreground
color.fg "Cerr" 194 48 64 # R G B
color.fg "Cval" 255 175 95 color.fg "title" 133 92 181
color.fg "Ckey" 40 168 134 color.fg "headline" 22 74 133
color.fg "Caction" 106 183 241 color.fg "sep" 80 80 80
color.fg "Csymbol" 255 175 95 color.fg "err" 194 48 64
color.fg "Citem" 92 147 181 color.fg "val" 255 175 95
color.fg "Cusa" 255 172 0 color.fg "key" 40 168 134
color.fg "Cspe" 255 214 166 color.fg "action" 106 183 241
color.fg "Copt" 94 215 255 color.fg "symbol" 255 175 95
color.fg "Ccom" 175 135 175 color.fg "item" 92 147 181
color.fg "Ctext" 0 132 101 color.fg "usa" 255 172 0
color.fg "Cmeta" 39 100 170 color.fg "spe" 255 214 166
color.fg "opt" 94 215 255
color.fg "com" 175 135 175
color.fg "text" 0 132 101
color.fg "meta" 39 100 170
echo -e "$Cerr warning ${Coff}cannot load colors config file"
fi
Coff="\\033[m" Coff="\\033[m"
fi fi
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function color.fg() function color.fg()
{ {
local -n var=$1 local s=${1}
if [ ${s:0:1} = "C" ]; then s=${s:1}; fi
s=${s,,}
local -n var=C$1
var="\033[1;38;2;$2;$3;$4m" var="\033[1;38;2;$2;$3;$4m"
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function color.bg() function color.bg()
{ {
local -n var=$1 local s=${1}
if [ ${s:0:1} = "C" ]; then s=${s:1}; fi
s=${s,,}
local -n var=C$1
var="\033[1;48;2;$2;$3;$4m" var="\033[1;48;2;$2;$3;$4m"
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function color.set() function color.set()
{ {
local -n var=$1 local s=${1}
if [ ${s:0:1} = "C" ]; then s=${s:1}; fi
s=${s,,}
local -n var=C$1
var="\033[1;48;2;$2;$3;$4;1;38;2;$5;$6;$7m" var="\033[1;48;2;$2;$3;$4;1;38;2;$5;$6;$7m"
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@ -96,7 +137,30 @@ function color.env () {
var=${!v} var=${!v}
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bes.color.boot function color.load () {
local file=${1:-/usr/share/bes/colors.ini}
if [ -f "$file" ]; then
local prefix="bes_colors"
bes.ini "$file" -p "$prefix" -b 1
for name in ${bes_colors_ALL_VARS}; do
key="${name:${#prefix}+1}"
if [ "${key:0:2}" = "fg" ]; then
color.fg "${key:3}" ${!name}
elif [ "${key:0:2}" == "bg" ]; then
color.bg "${key:3}" ${!name}
elif [ "${key:0:3}" == "set" ]; then
color.set "${key:4}" ${!name}
fi
done
else
return 1
fi
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
declare -f bes.reg > /dev/null
if [ $? -eq 0 ]; then
bes.reg bes.color
fi
# #
# @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
@ -193,7 +257,10 @@ function echo.app ()
echo.sepline echo.sepline
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bes.echo.boot declare -f bes.reg > /dev/null
if [ $? -eq 0 ]; then
bes.reg bes.echo
fi
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
# @author a-Sansara - https://git.pluie.org/meta-tech/bes-echo # @author a-Sansara - https://git.pluie.org/meta-tech/bes-echo
@ -543,7 +610,35 @@ function bes.build ()
fi fi
echo.state $? echo.state $?
fi fi
echo "#!/bin/bash" > $APP_BIN echo "#!/bin/bash
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BES_BOOT=
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.exists () {
declare -f \$1 > /dev/null
#~ [ x\$(type -t \$1) = xfunction ];
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.boot ()
{
for fn in \$BES_BOOT; do
if bes.exists \$fn.boot; then
\$fn.boot
fi
done
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.reg ()
{
local sep=\" \"
if [ -z \"\$BES_BOOT\" ]; then
sep=\"\"
fi
BES_BOOT=\$BES_BOOT\$sep\$1
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" > $APP_BIN
#~ echo "#!/bin/bash" > $APP_BIN
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
@ -573,6 +668,8 @@ function bes.build ()
tail -n +2 "$entry" >> "$APP_BIN" tail -n +2 "$entry" >> "$APP_BIN"
fi fi
done done
echo "# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bes.boot" >> "$APP_BIN"
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"
echo.msg " ${Cspe}- ${Cok}appending ${Coff}src/main.sh" echo.msg " ${Cspe}- ${Cok}appending ${Coff}src/main.sh"
@ -778,6 +875,8 @@ function bes.usage ()
echo -e "${Coff}" echo -e "${Coff}"
} }
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bes.boot
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# #
# @author a-Sansara - https://git.pluie.org/meta-tech/bes-build # @author a-Sansara - https://git.pluie.org/meta-tech/bes-build
# @app bes-build # @app bes-build
@ -785,7 +884,7 @@ function bes.usage ()
# @date 2017-06-16 04:38:52 CET # @date 2017-06-16 04:38:52 CET
# #
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ # ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BES_VERSION=0.8 BES_VERSION=0.9
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)

View File

@ -20,7 +20,35 @@ function bes.build ()
fi fi
echo.state $? echo.state $?
fi fi
echo "#!/bin/bash" > $APP_BIN echo "#!/bin/bash
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
BES_BOOT=
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.exists () {
declare -f \$1 > /dev/null
#~ [ x\$(type -t \$1) = xfunction ];
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.boot ()
{
for fn in \$BES_BOOT; do
if bes.exists \$fn.boot; then
\$fn.boot
fi
done
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
function bes.reg ()
{
local sep=\" \"
if [ -z \"\$BES_BOOT\" ]; then
sep=\"\"
fi
BES_BOOT=\$BES_BOOT\$sep\$1
}
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
" > $APP_BIN
#~ echo "#!/bin/bash" > $APP_BIN
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
@ -50,6 +78,8 @@ function bes.build ()
tail -n +2 "$entry" >> "$APP_BIN" tail -n +2 "$entry" >> "$APP_BIN"
fi fi
done done
echo "# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bes.boot" >> "$APP_BIN"
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"
echo.msg " ${Cspe}- ${Cok}appending ${Coff}src/main.sh" echo.msg " ${Cspe}- ${Cok}appending ${Coff}src/main.sh"

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.8 BES_VERSION=0.9
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)