This repository has been archived by the owner on Jun 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
docker-bake.sh
executable file
·58 lines (52 loc) · 1.64 KB
/
docker-bake.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
#!/bin/bash
function printHelp {
echo -e "Runs bitbake inside Yocto build container\n"
echo -e "\t --extra-cmd \"flag1 flag2\" - pass optional flags for extra commands before bitbake starts\n"
echo "Example:"
echo "BUILD_DIR=build ./docker-bake --extra-cmd \"github git-ti\" core-image-minimal"
}
EXTRA_CMD=""
# this switch must not collide with bitbake switches
if [ "$1" = "--extra-cmd" ]; then
for param in $2; do
case $param in
"github")
EXTRA_CMD+="ssh -T -o StrictHostKeyChecking=no [email protected];"
;;
"gitlab")
EXTRA_CMD+="ssh -T -o StrictHostKeyChecking=no [email protected];"
;;
"git-ti")
EXTRA_CMD+="ssh -T -o StrictHostKeyChecking=no [email protected];"
;;
*)
echo "Unknown flag"
printHelp
exit 1
;;
esac
done
shift 2
fi
if [ -z $POKY_DIR ]; then
POKY_DIR="$PWD"
echo "[WARNING]: \"POKY_DIR\" variable not present in environment"
echo "[WARNING]: Defaulting to POKY_DIR=\"$POKY_DIR\""
fi
if [ -z $BUILD_DIR ]; then
BUILD_DIR="$POKY_DIR/build"
echo "[WARNING]: \"BUILD_DIR\" variable not present in environment"
echo "[WARNING]: Defaulting to BUILD_DIR=\"$BUILD_DIR\""
fi
if [ -z $SSH_AUTH_SOCK ]; then
eval `ssh-agent`
ssh-add
fi
docker run --rm -t \
-u $(id -u) \
-v $(pwd):$(pwd) \
-v $(dirname $SSH_AUTH_SOCK):$(dirname $SSH_AUTH_SOCK) -e SSH_AUTH_SOCK=$SSH_AUTH_SOCK \
3mdeb/yocto-docker \
/bin/bash -c " \
${EXTRA_CMD} \
cd $POKY_DIR && source oe-init-build-env $BUILD_DIR && bitbake $*"