mirror of
ssh://git.janware.com/srv/git/janware/proj/jw-pkg
synced 2026-01-23 14:30:39 +01:00
jw-build-functions.sh: Rename ytools-build-functions.sh to jw-build-functions.sh
Signed-off-by: Jan Lindemann <jan@janware.com>
This commit is contained in:
parent
d94dfad4a8
commit
32e4a703d7
1 changed files with 74 additions and 74 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
export PATH=$PATH:/opt/ytools/bin
|
export PATH=$PATH:/opt/jwbuild/bin
|
||||||
|
|
||||||
# -- private stuff not intended for use outside of this script
|
# -- private stuff not intended for use outside of this script
|
||||||
_ytools_check_config_present()
|
_jwbuild_check_config_present()
|
||||||
{
|
{
|
||||||
if [ -z "$ytools_config_files" ]; then
|
if [ -z "$jwbuild_config_files" ]; then
|
||||||
if [ "$1" = true ]; then
|
if [ "$1" = true ]; then
|
||||||
ytools_log "warning: $0 tries to access configuration witout having a config file"
|
jwbuild_log "warning: $0 tries to access configuration witout having a config file"
|
||||||
fi
|
fi
|
||||||
return 1;
|
return 1;
|
||||||
fi
|
fi
|
||||||
|
|
@ -13,31 +13,31 @@ _ytools_check_config_present()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_ytools_check_config_files_readable()
|
_jwbuild_check_config_files_readable()
|
||||||
{
|
{
|
||||||
local new=""
|
local new=""
|
||||||
for f in $ytools_config_files; do
|
for f in $jwbuild_config_files; do
|
||||||
[ -f "$f" -a -r "$f" ] && new="$new $f"
|
[ -f "$f" -a -r "$f" ] && new="$new $f"
|
||||||
done
|
done
|
||||||
ytools_config_files="$new"
|
jwbuild_config_files="$new"
|
||||||
}
|
}
|
||||||
|
|
||||||
_ytools_probe_config_paths()
|
_jwbuild_probe_config_paths()
|
||||||
{
|
{
|
||||||
local f new exp dir
|
local f new exp dir
|
||||||
[ ! "$ytools_config_files" ] && ytools_config_files="
|
[ ! "$jwbuild_config_files" ] && jwbuild_config_files="
|
||||||
/etc/opt/$ytools_project/$ytools_basename.conf
|
/etc/opt/$jwbuild_project/$jwbuild_basename.conf
|
||||||
$HOME/.$ytools_project/$ytools_basename.conf
|
$HOME/.$jwbuild_project/$jwbuild_basename.conf
|
||||||
$HOME/.$ytools_project/$rc
|
$HOME/.$jwbuild_project/$rc
|
||||||
$HOME/.$ytools_basename/$ytools_basename.conf
|
$HOME/.$jwbuild_basename/$jwbuild_basename.conf
|
||||||
$HOME/.$ytools_basename/$rc
|
$HOME/.$jwbuild_basename/$rc
|
||||||
$HOME/.$rc
|
$HOME/.$rc
|
||||||
"
|
"
|
||||||
_ytools_check_config_files_readable
|
_jwbuild_check_config_files_readable
|
||||||
|
|
||||||
# add includes
|
# add includes
|
||||||
new=""
|
new=""
|
||||||
for f in $ytools_config_files; do
|
for f in $jwbuild_config_files; do
|
||||||
|
|
||||||
exp=`sed '
|
exp=`sed '
|
||||||
/^[ ]*include[ ]/ !d
|
/^[ ]*include[ ]/ !d
|
||||||
|
|
@ -54,12 +54,12 @@ _ytools_probe_config_paths()
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
[ "$new" ] && ytools_config_files="$new"
|
[ "$new" ] && jwbuild_config_files="$new"
|
||||||
|
|
||||||
_ytools_check_config_files_readable
|
_jwbuild_check_config_files_readable
|
||||||
}
|
}
|
||||||
|
|
||||||
_ytools_cat_section()
|
_jwbuild_cat_section()
|
||||||
{
|
{
|
||||||
if [ "$2" ]; then
|
if [ "$2" ]; then
|
||||||
sed -n "/\[$2\]/,/[^ ]*\[/ p" $1 | sed '/[^ ]*\[/ d; /^[ ]*include[ ]/ d'
|
sed -n "/\[$2\]/,/[^ ]*\[/ p" $1 | sed '/[^ ]*\[/ d; /^[ ]*include[ ]/ d'
|
||||||
|
|
@ -69,19 +69,19 @@ _ytools_cat_section()
|
||||||
sed -n '0,/[^ ]*\[/ p' $1 | sed '/[^ ]*\[/ d; /^[ ]*include[ ]/ d'
|
sed -n '0,/[^ ]*\[/ p' $1 | sed '/[^ ]*\[/ d; /^[ ]*include[ ]/ d'
|
||||||
}
|
}
|
||||||
|
|
||||||
_ytools_format_config()
|
_jwbuild_format_config()
|
||||||
{
|
{
|
||||||
sed '/^ *$/d; s/$/;/g' | sed 's/ *= */=/'
|
sed '/^ *$/d; s/$/;/g' | sed 's/ *= */=/'
|
||||||
}
|
}
|
||||||
|
|
||||||
_ytools_format_section()
|
_jwbuild_format_section()
|
||||||
{
|
{
|
||||||
_ytools_cat_section $* | _ytools_format_config
|
_jwbuild_cat_section $* | _jwbuild_format_config
|
||||||
}
|
}
|
||||||
|
|
||||||
_ytools_source_section()
|
_jwbuild_source_section()
|
||||||
{
|
{
|
||||||
eval `_ytools_cat_section $* | _ytools_format_config`
|
eval `_jwbuild_cat_section $* | _jwbuild_format_config`
|
||||||
}
|
}
|
||||||
|
|
||||||
_uniq()
|
_uniq()
|
||||||
|
|
@ -90,35 +90,35 @@ _uniq()
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- exported utilities
|
# -- exported utilities
|
||||||
ytools_log_err()
|
jwbuild_log_err()
|
||||||
{
|
{
|
||||||
echo "# $@" >&2
|
echo "# $@" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
ytools_log_stdout()
|
jwbuild_log_stdout()
|
||||||
{
|
{
|
||||||
echo "# $@"
|
echo "# $@"
|
||||||
}
|
}
|
||||||
|
|
||||||
ytools_log_stderr()
|
jwbuild_log_stderr()
|
||||||
{
|
{
|
||||||
echo "# $@" >&2
|
echo "# $@" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
ytools_log_syslog()
|
jwbuild_log_syslog()
|
||||||
{
|
{
|
||||||
logger -t $ytools_basename "$*"
|
logger -t $jwbuild_basename "$*"
|
||||||
}
|
}
|
||||||
|
|
||||||
ytools_log()
|
jwbuild_log()
|
||||||
{
|
{
|
||||||
local logger
|
local logger
|
||||||
for logger in $ytools_loggers; do
|
for logger in $jwbuild_loggers; do
|
||||||
eval ytools_log_$logger "$@"
|
eval jwbuild_log_$logger "$@"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
ytools_empty_config()
|
jwbuild_empty_config()
|
||||||
{
|
{
|
||||||
local o_verbose=""
|
local o_verbose=""
|
||||||
local o_section
|
local o_section
|
||||||
|
|
@ -132,25 +132,25 @@ ytools_empty_config()
|
||||||
-s)
|
-s)
|
||||||
o_section=$2; shift;;
|
o_section=$2; shift;;
|
||||||
*)
|
*)
|
||||||
ytools_log_err unknown option $1
|
jwbuild_log_err unknown option $1
|
||||||
exit 1;;
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
shift
|
shift
|
||||||
|
|
||||||
_ytools_check_config_present $o_verbose || return 1
|
_jwbuild_check_config_present $o_verbose || return 1
|
||||||
|
|
||||||
[ ! -r "$1" ] && return
|
[ ! -r "$1" ] && return
|
||||||
[ "$o_verbose" ] && ytools_log o resetting config "\"$1\""
|
[ "$o_verbose" ] && jwbuild_log o resetting config "\"$1\""
|
||||||
if [ "$o_section" ]; then
|
if [ "$o_section" ]; then
|
||||||
[ "$o_verbose" ] && ytools_log o resetting section "[$o_section]" of config "\"$1\""
|
[ "$o_verbose" ] && jwbuild_log o resetting section "[$o_section]" of config "\"$1\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
eval `_ytools_format_section $1 $o_section | sed 's/=[^;]*;/=;/g'`
|
eval `_jwbuild_format_section $1 $o_section | sed 's/=[^;]*;/=;/g'`
|
||||||
}
|
}
|
||||||
|
|
||||||
ytools_empty_configs()
|
jwbuild_empty_configs()
|
||||||
{
|
{
|
||||||
local section
|
local section
|
||||||
local c
|
local c
|
||||||
|
|
@ -168,27 +168,27 @@ ytools_empty_configs()
|
||||||
-s)
|
-s)
|
||||||
o_section="-s $2"; shift;;
|
o_section="-s $2"; shift;;
|
||||||
*)
|
*)
|
||||||
ytools_log_err unknown option $1
|
jwbuild_log_err unknown option $1
|
||||||
exit 1;;
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
shift
|
shift
|
||||||
|
|
||||||
_ytools_check_config_present $o_verbose || return 1
|
_jwbuild_check_config_present $o_verbose || return 1
|
||||||
|
|
||||||
for section in "" `ytools_config_sections`; do
|
for section in "" `jwbuild_config_sections`; do
|
||||||
|
|
||||||
for c in $ytools_config_files; do
|
for c in $jwbuild_config_files; do
|
||||||
|
|
||||||
ytools_empty_config -s "$section" section $opts $c
|
jwbuild_empty_config -s "$section" section $opts $c
|
||||||
|
|
||||||
if [ -d $c.d ]; then
|
if [ -d $c.d ]; then
|
||||||
|
|
||||||
local dirconfs=`find $c.d -maxdepth 1 -type f`
|
local dirconfs=`find $c.d -maxdepth 1 -type f`
|
||||||
local f
|
local f
|
||||||
for f in $dirconfs; do
|
for f in $dirconfs; do
|
||||||
ytools_empty_config -s "$section" $opts $f
|
jwbuild_empty_config -s "$section" $opts $f
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
@ -197,7 +197,7 @@ ytools_empty_configs()
|
||||||
return 0
|
return 0
|
||||||
}
|
}
|
||||||
|
|
||||||
ytools_source_config()
|
jwbuild_source_config()
|
||||||
{
|
{
|
||||||
local o_verbose=""
|
local o_verbose=""
|
||||||
local o_section
|
local o_section
|
||||||
|
|
@ -212,29 +212,29 @@ ytools_source_config()
|
||||||
-s)
|
-s)
|
||||||
o_section=$2; shift;;
|
o_section=$2; shift;;
|
||||||
*)
|
*)
|
||||||
ytools_log_err unknown option $1
|
jwbuild_log_err unknown option $1
|
||||||
exit 1;;
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
shift
|
shift
|
||||||
|
|
||||||
_ytools_check_config_present $o_verbose || return 1
|
_jwbuild_check_config_present $o_verbose || return 1
|
||||||
|
|
||||||
if [ "$o_verbose" = true ]; then
|
if [ "$o_verbose" = true ]; then
|
||||||
if [ "$o_section" ]; then
|
if [ "$o_section" ]; then
|
||||||
ytools_log o sourcing section "[$o_section]" from config file "\"$1\""
|
jwbuild_log o sourcing section "[$o_section]" from config file "\"$1\""
|
||||||
else
|
else
|
||||||
ytools_log o sourcing config "\"$1\""
|
jwbuild_log o sourcing config "\"$1\""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_ytools_cat_section $1 $o_section
|
_jwbuild_cat_section $1 $o_section
|
||||||
fi
|
fi
|
||||||
|
|
||||||
_ytools_source_section $1 $o_section
|
_jwbuild_source_section $1 $o_section
|
||||||
}
|
}
|
||||||
|
|
||||||
ytools_source_configs()
|
jwbuild_source_configs()
|
||||||
{
|
{
|
||||||
local c
|
local c
|
||||||
local source_opts=""
|
local source_opts=""
|
||||||
|
|
@ -252,28 +252,28 @@ ytools_source_configs()
|
||||||
source_opts="$source_opts -s $2"
|
source_opts="$source_opts -s $2"
|
||||||
shift;;
|
shift;;
|
||||||
*)
|
*)
|
||||||
ytools_log_err unknown option $1
|
jwbuild_log_err unknown option $1
|
||||||
exit 1;;
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
shift
|
shift
|
||||||
|
|
||||||
_ytools_check_config_present $o_verbose || return 1
|
_jwbuild_check_config_present $o_verbose || return 1
|
||||||
|
|
||||||
for c in $ytools_config_files; do
|
for c in $jwbuild_config_files; do
|
||||||
ytools_source_config $source_opts $c
|
jwbuild_source_config $source_opts $c
|
||||||
if [ -d $c.d ]; then
|
if [ -d $c.d ]; then
|
||||||
local dirconfs=`find $c.d -maxdepth 1 -type f`
|
local dirconfs=`find $c.d -maxdepth 1 -type f`
|
||||||
local f
|
local f
|
||||||
for f in $dirconfs; do
|
for f in $dirconfs; do
|
||||||
ytools_source_config $source_opts $f
|
jwbuild_source_config $source_opts $f
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
ytools_config_sections()
|
jwbuild_config_sections()
|
||||||
{
|
{
|
||||||
local o_verbose=""
|
local o_verbose=""
|
||||||
local o_section
|
local o_section
|
||||||
|
|
@ -293,7 +293,7 @@ ytools_config_sections()
|
||||||
e)
|
e)
|
||||||
o_exact=true;;
|
o_exact=true;;
|
||||||
*)
|
*)
|
||||||
ytools_log_err "unknown option -$flag"
|
jwbuild_log_err "unknown option -$flag"
|
||||||
exit 1;;
|
exit 1;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|
@ -301,9 +301,9 @@ ytools_config_sections()
|
||||||
|
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
|
|
||||||
_ytools_check_config_present $o_verbose || return 1
|
_jwbuild_check_config_present $o_verbose || return 1
|
||||||
|
|
||||||
[ "$o_file" ] || o_file="$ytools_config_files"
|
[ "$o_file" ] || o_file="$jwbuild_config_files"
|
||||||
|
|
||||||
if [ "$o_exact" = false ]; then
|
if [ "$o_exact" = false ]; then
|
||||||
|
|
||||||
|
|
@ -337,12 +337,12 @@ ytools_config_sections()
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
ytools_cat()
|
jwbuild_cat()
|
||||||
{
|
{
|
||||||
cat | sed 's/^[ ]*|//'
|
cat | sed 's/^[ ]*|//'
|
||||||
}
|
}
|
||||||
|
|
||||||
ytools_waitpid()
|
jwbuild_waitpid()
|
||||||
{
|
{
|
||||||
local pid=$1
|
local pid=$1
|
||||||
local t=5
|
local t=5
|
||||||
|
|
@ -359,19 +359,19 @@ ytools_waitpid()
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
ytools_terminate()
|
jwbuild_terminate()
|
||||||
{
|
{
|
||||||
local pid
|
local pid
|
||||||
for pid in $@; do
|
for pid in $@; do
|
||||||
[ -f /proc/$pid/status ] && {
|
[ -f /proc/$pid/status ] && {
|
||||||
echo terminating process $pid
|
echo terminating process $pid
|
||||||
kill $pid
|
kill $pid
|
||||||
ytools_waitpid $pid || {
|
jwbuild_waitpid $pid || {
|
||||||
|
|
||||||
echo "failed to normally terminate process $pid, killing it" >&2
|
echo "failed to normally terminate process $pid, killing it" >&2
|
||||||
kill -9 $pid
|
kill -9 $pid
|
||||||
|
|
||||||
ytools_waitpid $pid || {
|
jwbuild_waitpid $pid || {
|
||||||
echo "failed to kill process $pid" >&2
|
echo "failed to kill process $pid" >&2
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
@ -382,13 +382,13 @@ ytools_terminate()
|
||||||
}
|
}
|
||||||
|
|
||||||
# -- exported variables
|
# -- exported variables
|
||||||
if [ "$ytools_functions_sourced" != "yes" ]; then
|
if [ "$jwbuild_functions_sourced" != "yes" ]; then
|
||||||
|
|
||||||
ytools_functions_sourced="yes"
|
jwbuild_functions_sourced="yes"
|
||||||
|
|
||||||
[ -z "$ytools_basename" ] && ytools_basename=`echo "$0" | sed 's/^-*//' | xargs basename | sed 's/\.sh$//'`
|
[ -z "$jwbuild_basename" ] && jwbuild_basename=`echo "$0" | sed 's/^-*//' | xargs basename | sed 's/\.sh$//'`
|
||||||
[ -z "$ytools_project" ] && ytools_project="ytools"
|
[ -z "$jwbuild_project" ] && jwbuild_project="jwbuild"
|
||||||
[ -z "$ytools_rc" ] && ytools_rc="$ytools_basename"rc
|
[ -z "$jwbuild_rc" ] && jwbuild_rc="$jwbuild_basename"rc
|
||||||
_ytools_probe_config_paths
|
_jwbuild_probe_config_paths
|
||||||
[ -z "$ytools_loggers" ] && ytools_loggers="stdout"
|
[ -z "$jwbuild_loggers" ] && jwbuild_loggers="stdout"
|
||||||
fi
|
fi
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue