-
Notifications
You must be signed in to change notification settings - Fork 8
/
yocto-env
executable file
·73 lines (61 loc) · 1.43 KB
/
yocto-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
#! /usr/bin/env bash
usage() {
cat <<EOF
Yocto Project Environment helper
USAGE:
yocto-env <version> [--skip-pull]
OPTIONS
version Environment version to use. This maps to Ubuntu releases
and currently it provides the 14.04, 16.04, 18.04,
20.04, 22.04 and 24.04.
EOF
exit 1
}
case "$1" in
14.04*|16.04*|18.04*|20.04*|22.04*|24.04*)
version=$1
;;
*)
usage
;;
esac
USER=$(whoami)
IMAGE=ossystems/yocto-env:$version
case "$2" in
--skip-pull)
;;
"")
docker pull $IMAGE
;;
*)
usage
;;
esac
DOCKER_EXTRA_ARGS=""
# ssh-agent support
[ -n "$SSH_AUTH_SOCK" ] && DOCKER_EXTRA_ARGS="$DOCKER_EXTRA_ARGS -v $SSH_AUTH_SOCK:/ssh-agent --env=SSH_AUTH_SOCK=/ssh-agent"
# NixOS support
DOCKER_EXTRA_ARGS="$DOCKER_EXTRA_ARGS \
-v /nix:/nix \
-v /run/current-system:/run/current-system \
"
docker run \
--rm \
-t \
-i \
--privileged \
--cap-add=NET_ADMIN \
--device=/dev/kvm \
--device=/dev/net/tun \
-v /tmp/.X11-unix:/tmp/.X11-unix \
-v ${HOME}:${HOME} \
--env DISPLAY=$DISPLAY \
--env=HOST_UID=$(id -u) \
--env=HOST_GID=$(id -g) \
--env=USER=$USER \
--env=SHELL=$SHELL \
--hostname yocto-env \
$DOCKER_EXTRA_ARGS \
$YOCTO_ENV_EXTRA_DOCKER_ARGS \
-w $PWD \
$IMAGE run