-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhipos-init.sh.template
executable file
·105 lines (84 loc) · 2.64 KB
/
hipos-init.sh.template
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#!/bin/bash
# vim:set ts=4 sw=4 noexpandtab:
#
# Copyright (C) 2013-2023 DResearch Fahrzeugelektronik GmbH
#
# \brief Build specific init script example.
# \description This script has to be placed into the root repository and should be
# called after fetching the root repository.
# It initializes/updates all submodules and creates appropriate
# bitbake configurations. Optionally, local sublayer can be included
# here.
#
# \author Ralf Schröder
# \pre GIT (environment) optionally set to the git binary
#
#############################
# #
# D A N G E R Z O N E #
# #
#############################
#
# This must _always_ be set to the name of this script
# or "sourceing" detection will fail.
INIT_SCRIPT_NAME="hipos-init.sh"
#############################
# Log helper to realize project specific log locations
log()
{
local TIMESTAMP=`date -u +%Y-%m-%d-%H:%M:%S`
# to the logfile
echo "${TIMESTAMP} [HIPOS Build] $@"
# and to the new stdout
[ -f "${BUILD_LOG}" ] && echo "${TIMESTAMP} [HIPOS Build] $@" >&3
# clear return value polluted by the test above (reason for a lot of headaches...)
return 0
}
# Project specific sanity checks.
# We check for git and set GIT as variable
sanity()
{
log "I: linux sanity check"
if test -z "$GIT" || ! $GIT --version > /dev/null; then
export GIT=`which git`
fi
if test -z "$GIT" || ! $GIT --version > /dev/null; then
log "E: couldn't find git" && return 1;
fi
log "I: check `$GIT --version`: OK"
return 0
}
# Helper to check existence of a given file, tries to git-checkout if not exists.
check_file()
{
if [ ! -f "$1" ]; then
log "I: $1 not found, checking out from git"
"${GIT}" checkout $1 &&
test -f "$1" ||
{ log "E: $1 not available from git repository"; return 1; }
fi
return 0
}
main_init()
{
echo -e '***'
echo -e '*** '$INIT_SCRIPT_NAME
echo -e '***'
sanity &&
# fetch the base init script an start it
if [ ! -f hipos-base/init.sh ]; then
"${GIT}" submodule init hipos-base &&
"${GIT}" submodule sync hipos-base &&
"${GIT}" submodule update --remote hipos-base ||
{ log "E: updating hipos-base failed"; return 1; }
fi &&
check_file hipos-base/init.sh &&
. hipos-base/init.sh &&
# optional: modify layer and update variables here...
# BB_LAYERS_INCLUDED: ordered list of default layers
# BB_BUILD_DIR_BASE: temporary build directory
{ test "`basename -- \"$0\"`" != "$INIT_SCRIPT_NAME" && SCRIPT_SOURCED=true || SCRIPT_SOURCED=false; } &&
hipos_base_init ||
{ log "E: bitbake initialization failed"; return 1; }
}
main_init