-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbuild-octoson
executable file
·103 lines (90 loc) · 2.32 KB
/
build-octoson
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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/bin/bash
# TODOs:
# Add support for building Dockerfile. Current command is:
# docker build . -f Dockerfile.ubuntu_trusty-pyro64-htot -t vincent/ubuntu14-yocto:pyro64
set -o errexit
set -o xtrace
script="${0##*/}"
print_date ()
{
date -I
}
usage ()
{
cat << EOF
Usage: build-octoson [--work-dir|--run-dir|--branch|--no-clone]
--work-dir: set work directory (use when clone already exists)
--root-dir: set root directory to clone and build repo in
--branch : override default branch (pyro64-acpi)
--no-clone: do not reclone repo (use --work-dir with it)
EOF
}
do_clone ()
{
local dirname="$1"
local branch="$2"
cd $dirname
git clone https://github.com/htot/meta-intel-edison.git -b $branch
ln -s meta-intel-edison/utils/Makefile.mk Makefile
}
do_clone=1
while [ "$#" -ne "0" ]; do
case $1 in
# Work dir allows to specify full path to working clone, when not
# recloning.
--work-dir)
shift
work_dir="$1"
;;
# Root dir is where repo should live after being cloned.
--root-dir)
shift
root_dir="$1"
;;
--branch)
shift
branch="$1"
;;
--docker-dir)
# Can be omitted for now, as building the Docker container is not
# implemented by the script
shift
docker_dir="$1"
;;
--no-clone)
do_clone=0
;;
-h|--help)
usage
exit 0
;;
*)
echo "Unknown argument $1!"
exit 1
esac
shift
done
base="htot-meta-intel-edison"
if [[ -z "$branch" ]]; then
branch="rocko64-acpi"
fi
# Docker image tag must match repo branch
docker_tag="vincent/ubuntu14-yocto:$branch"
if [[ ! -z "$work_dir" && ! -z "$root_dir" ]]; then
echo "Cannot set both root and work dir"
exit 1
fi
if [[ -z "$work_dir" ]]; then
work_dir="$root_dir/${base}_${branch}_$(print_date)"
fi
if [[ ! -d "$work_dir" ]]; then
mkdir $work_dir
fi
work_dir="$(readlink -f $work_dir)"
if [[ "$do_clone" == 1 ]]; then
do_clone $work_dir $branch
fi
echo "Directory setup under $work_dir"
# Use 'z' to correctly apply the SELinux labels inside the container. Mark is as
# shareable.
sudo docker run -i -t -v $work_dir:/yocto:z $docker_tag