POC fonctionnel

This commit is contained in:
2017-02-09 21:53:24 +01:00
parent 38d236e09b
commit 2375dd6571
25 changed files with 279 additions and 470 deletions

53
lib/buildtools/tamarin_db Executable file
View File

@ -0,0 +1,53 @@
#!/usr/bin/env bash
PROJECT_DB_FILE="/src/.tamarinrc"
GLOBAL_DB_FILE="${TAMARIN_WORKSPACE}/.tamarinrc"
KEY_PREFIX="tamarin_db_"
function tamarin_load_project_db {
if [ -e "${PROJECT_DB_FILE}" ]; then
tamarin_info "Loading project database..."
while read line; do
if [[ ! "${line}" =~ ^\s*# ]]; then
set -- $(echo $line | tr '=' ' ')
local key=$1
local value=$2
tamarin_debug "Load $key=$value"
tamarin_db_set $key $value
fi
done < "${PROJECT_DB_FILE}"
fi
}
function tamarin_db_get {
local opt_name=${KEY_PREFIX}${1}
local default_value=${2}
touch "${GLOBAL_DB_FILE}"
source "${GLOBAL_DB_FILE}"
echo ${!opt_name:-${default_value}}
}
function tamarin_db_set {
local opt_name=${1}
local opt_value=${2}
mkdir -p "$(dirname ${GLOBAL_DB_FILE})"
touch "${GLOBAL_DB_FILE}"
sed -i "s/^${KEY_PREFIX}${opt_name}*$//" "${GLOBAL_DB_FILE}"
echo "local ${KEY_PREFIX}${opt_name}=\"${opt_value}\"" >> "${GLOBAL_DB_FILE}"
}
case $1 in
set)
tamarin_db_set ${@:2}
;;
get)
tamarin_db_get ${@:2}
;;
load)
tamarin_load_project_db
;;
*)
tamarin_error "Invalid action '$1'. Must be get, set or load !"
exit 1
;;
esac

9
lib/buildtools/tamarin_debug Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
if [ -z "$@" ]; then
while read str; do
tamarin_log DEBUG "${str}"
done
else
tamarin_log DEBUG "$@"
fi

9
lib/buildtools/tamarin_error Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
if [ -z "$@" ]; then
while read str; do
tamarin_log ERROR "${str}"
done
else
tamarin_log ERROR "$@"
fi

9
lib/buildtools/tamarin_info Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
if [ -z "$@" ]; then
while read str; do
tamarin_log INFO "${str}"
done
else
tamarin_log INFO "$@"
fi

23
lib/buildtools/tamarin_log Executable file
View File

@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Colors
COLOR_INFO='\e[0;36m'
COLOR_ERROR='\e[0;31m'
COLOR_WARN='\e[0;33m'
COLOR_SUCCESS='\e[0;32m'
COLOR_DEBUG='\e[0;35m'
function log {
local args=( $@ )
local color=COLOR_${args[0]}
echo -e "${!color}[${args[0]}] $(remove_ansi ${args[@]:1})\e[0m"
}
function remove_ansi {
echo "$@" | sed 's,\x1B\[[0-9;]*[a-zA-Z],,g'
}
if [ $# -ne 0 ]; then
log $@
fi

9
lib/buildtools/tamarin_success Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
if [ -z "$@" ]; then
while read str; do
tamarin_log SUCCESS "${str}"
done
else
tamarin_log SUCCESS "$@"
fi

9
lib/buildtools/tamarin_warn Executable file
View File

@ -0,0 +1,9 @@
#!/usr/bin/env bash
if [ -z "$@" ]; then
while read str; do
tamarin_log WARN "${str}"
done
else
tamarin_log WARN "$@"
fi