-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommon.env
80 lines (66 loc) · 3.28 KB
/
common.env
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
SCRIPT_DIR=${SCRIPT_DIR:-"$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"}
echo "common.env SCRIPT_DIR = $SCRIPT_DIR"
# usage: print_step "message string" [true|false]
# param1: string title of step
# param2: true (or blank) to including trailing \n, false to exclude it
function print_step() {
if $2; then
nl="\n"
else
nl=""
fi
printf "========== $1 ==========${nl}"
}
# usage: error "message string"
# param1: string indicating error
function error() {
echo "****************************************"
echo $1
exit 1
}
# usage: warn "message string"
# param1: string indicating warning
function warn() {
echo "----------------------------------------"
echo "WARNING: $1"
echo "----------------------------------------"
}
# Enters build directory
# usage: cd_build
function cd_build() {
echo "cd_build - $LEMDIG_BUILD_DIR"
sudo mkdir -p "${LEMDIG_BUILD_DIR}" || error "Couldn't create build directory"
sudo chown ${USER}:${USER} "${LEMDIG_BUILD_DIR}" || error "Couldn't take ownership of shared directory"
pushd "${LEMDIG_BUILD_DIR}" &>/dev/null || error "Couldn't enter build directory"
}
# Root directory of the 'air' repo.
LEMDIG_SOURCE_DIR="${SCRIPT_DIR}/lemdig"
# Top directory for build
LEMDIG_TOP_DIR=${LEMDIG_TOP_DIR:-"/opt/lemdig-image"}
# Directory that has the downloads and the sstate cache
LEMDIG_YOCTO_CACHE=${LEMDIG_YOCTO_CACHE:-${LEMDIG_TOP_DIR}}
# LEMDIG_PROFILE defaults to the 'generic' profile if a payload-specific one is not specified.
LEMDIG_PROFILE=${LEMDIG_PROFILE:-"generic"}
LEMDIG_BUILD_DIR="${LEMDIG_TOP_DIR}/${LEMDIG_PROFILE}"
# Source the profile environment vars
source "${SCRIPT_DIR}/meta-${LEMDIG_PROFILE}/${LEMDIG_PROFILE}.env"
# Create shared directories
sudo mkdir -p "${LEMDIG_YOCTO_CACHE}" || error "Couldn't create shared directory"
sudo chown ${USER}:${USER} "${LEMDIG_YOCTO_CACHE}" || error "Couldn't take ownership of shared directory"
sudo mkdir -p "${LEMDIG_YOCTO_CACHE}/cache" || error "Couldn't create cache directory"
sudo chown ${USER}:${USER} "${LEMDIG_YOCTO_CACHE}/cache" || error "Couldn't take ownership of cache directory"
sudo mkdir -p "${LEMDIG_YOCTO_CACHE}/cache/downloads" || error "Couldn't create cache downloads directory"
sudo chown ${USER}:${USER} "${LEMDIG_YOCTO_CACHE}/cache/downloads" || error "Couldn't take ownership of cache downloads directory"
sudo mkdir -p "${LEMDIG_YOCTO_CACHE}/cache/sstate-cache" || error "Couldn't create cache sstate-cache directory"
sudo chown ${USER}:${USER} "${LEMDIG_YOCTO_CACHE}/cache/sstate-cache" || error "Couldn't take ownership of cache sstate-cache directory"
# Env vars
echo "SCRIPT_DIR = $SCRIPT_DIR"
echo "LEMDIG_TOP_DIR = $LEMDIG_TOP_DIR"
echo "LEMDIG_SOURCE_DIR = $LEMDIG_SOURCE_DIR"
echo "LEMDIG_YOCTO_CACHE = $LEMDIG_YOCTO_CACHE"
echo "LEMDIG_PROFILE = $LEMDIG_PROFILE"
echo "Profile specific env vars"
echo "LEMDIG_PAYLOAD_LAYER = $LEMDIG_PAYLOAD_LAYER"
echo "LEMDIG_PAYLOAD_LOCAL_CONF = $LEMDIG_PAYLOAD_LOCAL_CONF"
echo "LEMDIG_PAYLOAD_LOCAL_BBLAYERS = $LEMDIG_PAYLOAD_LOCAL_BBLAYERS"
echo "LEMDIG_BUILD_DIR = $LEMDIG_BUILD_DIR"