-
Notifications
You must be signed in to change notification settings - Fork 0
/
yocto-shell.sh
executable file
·52 lines (43 loc) · 1.47 KB
/
yocto-shell.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
#!/bin/bash -e
SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd)
source $SCRIPT_DIR/container/home/yocto/setting.sh
source ${SCRIPT_DIR}/common-variable.sh
HOST_DOCKER_HOME=$SCRIPT_DIR/container/home/yocto
TARGET_HOME=/home/yocto
REMOTE_URL=$(git remote get-url origin)
BRANCH_NAME=$(git name-rev --name-only HEAD | sed "s/\W/_/g")
CONTAINER_NAME=$(basename $REMOTE_URL)--${BRANCH_NAME}--$(basename $SCRIPT_DIR)__$(git rev-parse --short HEAD)__$(date "+%Y%m%d-%H%M%S")
HOST_DOCKER_OPT=$SCRIPT_DIR/container/opt
TARGET_OPT=/opt
HOST_SSTATE_DIR=$HOME/shared/$IMAGEBASE/sstate-cache
HOST_DL_DIR=$HOME/shared/$IMAGEBASE/downloads
TARGET_SSTATE_DIR=/home/shared/sstate-cache
TARGET_DL_DIR=/home/shared/downloads
mkdir -p $HOST_DOCKER_HOME
mkdir -p $HOST_DOCKER_OPT
mkdir -p $HOST_SSTATE_DIR
mkdir -p $HOST_DL_DIR
COMMAND_ARG=$1
if [ x$COMMAND_ARG = x"build" ] ; then
COMMAND_LINE=$TARGET_HOME/build-yocto.sh
ADDITIONAL_OPT=
elif [ x$COMMAND_ARG = x"shell" ] ; then
COMMAND_LINE=/bin/bash
ADDITIONAL_OPT=-it
else
echo usage:
echo $0 build
echo $0 shell
exit 0
fi
docker run $ADDITIONAL_OPT --rm \
-e LOCAL_UID=$(id -u $USER) -e LOCAL_GID=$(id -g $USER) \
--name $CONTAINER_NAME \
-v $HOST_SSTATE_DIR:$TARGET_SSTATE_DIR \
-v $HOST_DOCKER_OPT:$TARGET_OPT \
-v $HOST_DL_DIR:$TARGET_DL_DIR \
-v $HOST_DOCKER_HOME:$TARGET_HOME \
-w $TARGET_HOME $DOCKERIMAGE $COMMAND_LINE
if [ x$COMMAND_ARG = x"build" ] ; then
ls -Ll $HOST_DOCKER_HOME/$BUILD_DIR/tmp/deploy/images/raspberrypi4/*-image-*
fi