-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun-oe-build.sh
executable file
·70 lines (66 loc) · 1.76 KB
/
run-oe-build.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
#!/bin/bash
#
# Run a oe-build image as current user with access to source folder and optionally with system wide SSTATE and DOWNLOADS
#
set -e
# Parse arguments
source_dir=""
sstate_dir=""
downloads_dir=""
pass_ssh=false
working_directory=""
bb_env_extrawhite=""
while getopts "h?s:c:d:kw:" opt; do
case "$opt" in
h|\?)
echo "Usage: $(basename $0) [OPTIONS]"
echo
echo "Options:"
echo " -c Source directory to pass into container"
echo " -s sstate-cache directory to pass into container"
echo " -d downloads directory to pass into container"
echo " -w container working directory"
echo
exit 0
;;
c) source_dir="$(realpath $OPTARG)"
;;
d) downloads_dir="$(realpath $OPTARG)"
;;
s) sstate_dir="$(realpath $OPTARG)"
;;
k) pass_ssh=true
;;
w) working_directory="$(realpath $OPTARG)"
;;
esac
done
cmd="docker run -it"
if [ ! -z ${source_dir} ]; then
cmd="$cmd -v $source_dir:$source_dir"
fi
if [ ! -z ${sstate_dir} ]; then
export SSTATE_DIR="${sstate_dir}"
cmd="$cmd -v $sstate_dir:$sstate_dir -e SSTATE_DIR"
bb_env_extrawhite="$bb_env_extrawhite SSTATE_DIR"
fi
if [ ! -z ${downloads_dir} ]; then
export DL_DIR="${downloads_dir}"
cmd="$cmd -v $downloads_dir:$downloads_dir -e DL_DIR"
bb_env_extrawhite="${bb_env_extrawhite} DL_DIR"
fi
if [ ! -z "${bb_env_extrawhite}" ]; then
export BB_ENV_EXTRAWHITE="${bb_env_extrawhite}"
cmd="$cmd -e BB_ENV_EXTRAWHITE"
fi
if ${pass_ssh}; then
ssh_dir="/home/$(id -un)/.ssh"
cmd="$cmd -v $ssh_dir:$ssh_dir"
fi
if [ ! -z ${working_directory} ]; then
cmd="$cmd -w $working_directory"
fi
cmd="$cmd oe:$(id -un)" # add name:tag of image
echo "Running command:"
echo "$cmd"
$cmd