-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
executable file
·76 lines (63 loc) · 1.97 KB
/
run.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
#!/usr/bin/env bash
set -euo pipefail
function usage() {
>&2 echo -e "Usage: $0 [shell|tlc]\n" \
" build -- Build the yocto image\n" \
" shell -- Get a shell in the yocto docker environment"
}
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE[0]}) && pwd)
# Source environment variables for location of yocto cache etc
source "${SCRIPT_DIR}/yocto.env"
DL_DIR=${DL_DIR:-${LEMDIG_YOCTO_CACHE}/cache/downloads}
SSTATE_DIR=${SSTATE_DIR:-${LEMDIG_YOCTO_CACHE}/cache/sstate-cache}
SKIP_SERVICES_START=${SKIP_SERVICES_START:-1}
# Allow getopts above if needed
ARG1=${@:$OPTIND:1}
shift
DOCKER_OPT=""
if [ "x$ARG1" == "xshell" ]; then
CMD="/bin/bash"
elif [ "x$ARG1" == "xbuild" ]; then
CMD="/lemdig/build.sh"
else
usage
exit 1
fi
SSTATE_MIRROR=${SSTATE_MIRROR:-}
if [ -n "$SSTATE_MIRROR" ]; then
SSTATE_MIRRORS="file://.* file://$SSTATE_MIRROR/PATH"
DOCKER_OPT="$DOCKER_OPT -v $SSTATE_MIRROR:$SSTATE_MIRROR"
else
SSTATE_MIRRORS=""
fi
NO_TERM_OUTPUT=${NO_TERM_OUTPUT:-0}
# Make our docker interactive if we have a TTY
if [ -t 1 ] && [ "$NO_TERM_OUTPUT" != "1" ]; then
DOCKER_OPT="$DOCKER_OPT -it"
fi
# Specifically used to allow Jenkins to use a tag besides "latest"
DOCKER_TAG=${DOCKER_TAG:-latest}
# Run the docker
# * Must be last so the return value of the build/docker is the return value of this script
# Removed to save copy of build products \
docker run \
-e LEMDIG_PROFILE="$LEMDIG_PROFILE" \
-e YOCTO_DL_DIR=$DL_DIR \
-e YOCTO_SSTATE_DIR=$SSTATE_DIR \
-e YOCTO_SSTATE_MIRRORS="$SSTATE_MIRRORS" \
-e USER_ID=$(id -u) \
-e SKIP_SERVICES_START=$SKIP_SERVICES_START \
-v $DL_DIR:$DL_DIR \
-v $SSTATE_DIR:$SSTATE_DIR \
-v $LEMDIG_TOP_DIR:$LEMDIG_TOP_DIR \
-v $SCRIPT_DIR:/lemdig \
-v /var/run/docker.sock:/var/run/docker.sock \
-v /dev/serial:/dev/serial \
--net=host \
--privileged \
-w /lemdig \
--rm \
--init \
$DOCKER_OPT \
yocto-lemdig:${DOCKER_TAG} \
"$CMD"