-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit-atm.sh
executable file
·134 lines (108 loc) · 3.5 KB
/
init-atm.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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/bin/bash
# vim:set ts=4 sw=4 noexpandtab:
#
# \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="init-atm.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 &&
"${GIT}" submodule init HIPOS &&
"${GIT}" submodule sync HIPOS &&
"${GIT}" submodule update HIPOS ||
{ log "E: updating HIPOS failed"; return 1; }
cd HIPOS
# 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 &&
# overwrite update_submodules() from init.sh because we like
# to have some special handling for some submodules
update_submodules()
{
# <original function code>
log "I: updating submodules (OE layers + bitbake)"
"${GIT}" submodule init &&
"${GIT}" submodule sync &&
"${GIT}" submodule update ||
{ log "E: updating submodules failed"; return 1; }
# </original function code>
# <additional function code>
log "I: updating selected submodules which should track HEAD branches" &&
"${GIT}" submodule update --remote hipos-base &&
"${GIT}" submodule update --remote meta-hipos ||
{ log "E: updating selected submodules failed"; return 1; }
# </additional function code>
}
# optional: modify layer and update variables here...
# BB_LAYERS_INCLUDED: ordered list of default layers
# BB_BUILD_DIR_BASE: temporary build directory
BB_LAYERS_INCLUDED+="../meta-atm \
"
BB_BUILD_DIR_BASE=build-open
{ test "`basename -- \"$0\"`" != "$INIT_SCRIPT_NAME" && SCRIPT_SOURCED=true || SCRIPT_SOURCED=false; } &&
hipos_base_init ||
{ log "E: bitbake initialization failed"; return 1; }
}
main_init