-
Notifications
You must be signed in to change notification settings - Fork 7
/
include.sh
executable file
·74 lines (60 loc) · 1.57 KB
/
include.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# SPDX-License-Identifier: MIT
# Copyright (C) 2019 Tree Davies
export BUILDROOT='/mnt/physix'
export BR_SOURCE_DIR=$BUILDROOT/opt/admin/sources.physix/BUILDBOX
export SOURCE_DIR=/opt/admin/sources.physix/BUILDBOX
export NPROC=`grep -e ^processor /proc/cpuinfo | wc -l`
export PKG_DIR_PATH=$( cd "$(dirname "$0")" >/dev/null 2>&1 ; pwd -P )
function ok() {
local MSG=$1
local BR=''
local TIME=`date "+%D %T"`
if [ -r '/mnt/physix/opt/logs.physix/' ] && [ -r '/mnt/physix/opt/physix/' ] ; then
BR=$BUILDROOT
fi
echo -e "\e[92m[OK]\e[0m $TIME : $MSG"
#echo -e "[OK] $TIME : $MSG" >> $BR/opt/physix/logs.physix/physix-build.log
}
function error() {
local MSG=$1
local BR=''
if [ -r '/mnt/physix/opt/logs.physix/' ] && [ -r '/mnt/opt/physix/' ] ; then
BR=$BUILDROOT
fi
echo -e "\e[31m[ERROR]\e[0m $TIME :$MSG"
#echo -e "[ERROR] $TIME : $MSG" >> $BR/opt/physix/logs.physix/physix-build.log
#echo -e "[ERROR] $TIME : $MSG" >> $BR/var/physix/system-build-logs/build.log
}
# Check, handle and log return code
# used for scripts executed 'within' chroot'd envs
function chroot_check() {
local RTN=$1
local MSG=$2
local NOEXIT=${3:-"FALSE"}
if [ $RTN -ne 0 ] ; then
error "$RTN:$MSG"
if [ $NOEXIT == "FALSE" ] ; then
exit 1
fi
else
ok "$MSG"
return 0
fi
}
# Check, handle and log return code
# used for scripts executed outside chroot'd envs
function check() {
local RTN=$1
local MSG=$2
local NOEXIT=${3:-"FALSE"}
local BR=''
if [ $RTN -ne 0 ] ; then
error "$RTN:$MSG"
if [ $NOEXIT == "FALSE" ] ; then
exit 1
fi
else
ok "$MSG"
return 0
fi
}