-
Notifications
You must be signed in to change notification settings - Fork 0
/
make-buildroots.sh
executable file
·109 lines (80 loc) · 1.65 KB
/
make-buildroots.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
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
104
105
106
107
108
109
#!/bin/bash
set -euo pipefail
source common/rc
me=${0##*/}
spawn_id=
basedir=
targetdir="$(pwd)/targets"
quiet=
usage()
{
cat <<EOF
$me
Usage: $me [OPTION] TARGETS...
Known values for OPTION are:
-h|--help display this help and exit
-q|--quiet all outputs are redirected to a logfile per machine
-b|--basedir <DIR> buildroot base directory
-t|--targetdir <DIR> target directory (default: "$targetdir")
Default targets are:
${TARGETS[@]}
EOF
exit 1
}
# runtime dependencies
for cmd in jq expect; do
if ! command -v $cmd &> /dev/null; then
echo "$me: please install '$cmd' command"
exit 1
fi
done
shortargs="hqb:t:"
longargs="help,quiet,basedir:,targetdir:"
if ! tmp=$(getopt -o "$shortargs" -l "$longargs" -- "$@"); then
usage
fi
eval set -- "$tmp"
unset tmp
while true; do
case "$1" in
"-h" | "--help" )
usage
;;
"-q" | "--quiet" )
quiet=1
shift 1
;;
"-b" | "--basedir" )
basedir="$2"
shift 2
;;
"-t" | "--targetdir" )
targetdir="$2"
shift 2
;;
"--" )
shift 1
break
;;
* )
break
;;
esac
done
if [ -z "$basedir" ]; then
>2 echo "$me: missing buildroot base directory"
exit 1
fi
export PATH="${basedir}/utils:${PATH}"
export BR2_EXTERNAL="$(pwd)/br2-external"
targets=(${*:-"${TARGETS[@]}"})
for target in "${targets[@]}"; do
defconfig="$(jq -rc ".[] | select(.name == \"$target\") | .defconfig" config.json)"
pushd "${basedir}" >/dev/null
make O="${targetdir}/${target}" "$defconfig"
popd >/dev/null
echo "building $target using $defconfig"
pushd "${targetdir}/${target}" >/dev/null
brmake
popd >/dev/null
done