blob: 988fac0f1e77b6e39aeb6bfb4043176aa0169d47 (
plain)
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#!/bin/bash
CONTAINERS="ubuntu1804 fedora29"
SDK_ONLY=0
while getopts ":ab:hp:c:rs:S" opt; do
case $opt in
s)
echo "SDK Cache dir"
SDK_CACHE="$OPTARG"
;;
S)
echo "Build SDK Only"
SDK_ONLY=1
;;
a)
echo "Build firmware images for all the platforms"
PLATFORMS=""
;;
b)
echo "Directory to bind to container: $OPTARG"
BIND="$OPTARG"
;;
p)
echo "Build firmware images for the platforms: $OPTARG"
PLATFORMS=$OPTARG
;;
c)
echo "Build in container: $OPTARG"
CONTAINERS=$OPTARG
;;
h)
echo "Usage: ./ci/build.sh [options] [--]"
echo "-h Print this help and exit successfully."
echo "-a Build firmware images for all the platform defconfig's."
echo "-b DIR Bind DIR to container."
echo "-p List of comma separated platform names to build images for particular platforms."
echo "-s DIR SDK cache dir (must exist)."
echo "-S Build SDK only"
echo "-c Container to run in"
echo ""
echo "Note: set environment variables HTTP_PROXY and HTTPS_PROXY if a proxy is required."
echo ""
echo "Example:DOCKER_PREFIX=sudo ./ci/build.sh -a"
echo -e "\tDOCKER_PREFIX=sudo ./ci/build.sh -p firestone"
echo -e "\tDOCKER_PREFIX=sudo ./ci/build.sh -p garrison,palmetto,opal"
exit 1
;;
r)
echo "Build for release"
release_args="-r"
;;
\?)
echo "Invalid option: -$OPTARG"
exit 1
;;
:)
echo "Option -$OPTARG requires an argument."
exit 1
;;
esac
done
set -ex
set -eo pipefail
function run_docker
{
if [ -n "$BIND" ]; then
BINDARG="--mount=type=bind,src=${BIND},dst=${BIND}"
else
BINDARG="--mount=type=bind,src=${PWD},dst=${PWD}"
fi
$DOCKER_PREFIX docker run --init --cap-add=sys_admin --net=host --rm=true \
--user="${USER}" -w "${PWD}" "${BINDARG}" \
-t $1 $2
}
function toolchain_hash
{
echo -n 'toolchain-'$((git submodule ; cd openpower/configs/; cat `ls -1 |grep '_defconfig$'|sort`)|sha1sum |sed -e 's/ .*//')
}
env
for distro in $CONTAINERS;
do
base_dockerfile=ci/Dockerfile/$distro.`uname -m`
if [ ! -f $base_dockerfile ]; then
echo "$distro not supported on $(uname -m).";
continue
fi
if [[ -n "$HTTP_PROXY" ]]; then
http_proxy=$HTTP_PROXY
HTTP_PROXY_ENV="ENV http_proxy $HTTP_PROXY"
fi
if [[ -n "$HTTPS_PROXY" ]]; then
https_proxy=$HTTPS_PROXY
HTTPS_PROXY_ENV="ENV https_proxy $HTTPS_PROXY"
fi
if [[ -n "$http_proxy" ]]; then
if [[ "$distro" == fedora29 ]]; then
PROXY="RUN echo \"proxy=${http_proxy}\" >> /etc/dnf/dnf.conf"
fi
if [[ "$distro" == ubuntu1804 ]]; then
PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
fi
fi
if [ ! -z ${DL_DIR+x} ]; then
DL_DIR_ENV="ENV DL_DIR $DL_DIR"
fi
if [ ! -z ${CCACHE_DIR+x} ]; then
CCACHE_DIR_ENV="ENV CCACHE_DIR $CCACHE_DIR"
fi
Dockerfile=$(head -n1 $base_dockerfile; echo ${PROXY}; tail -n +2 $base_dockerfile; cat << EOF
${PROXY}
RUN useradd -d ${HOME} -m -u ${UID} ${USER}
ENV HOME ${HOME}
${HTTP_PROXY_ENV}
${HTTPS_PROXY_ENV}
${DL_DIR_ENV}
${CCACHE_DIR_ENV}
EOF
)
$DOCKER_PREFIX docker build --network=host -t openpower/op-build-$distro - <<< "${Dockerfile}"
if [ -d "$SDK_CACHE" ]; then
SDK_DIR=$SDK_CACHE/$(toolchain_hash)-$distro
if [ ! -d "$SDK_DIR" ]; then
chmod +x ci/build-sdk.sh
run_docker openpower/op-build-$distro "./ci/build-sdk.sh $distro witherspoon_defconfig"
mv output-$distro-witherspoon_defconfig $SDK_DIR
$SDK_DIR/host/relocate-sdk.sh
fi
sdk_args="-s $SDK_DIR/host"
else
sdk_args=""
fi
if [ $SDK_ONLY == 0 ]; then
run_docker openpower/op-build-$distro "./ci/build-all-defconfigs.sh -o `pwd`/output-$distro -p $PLATFORMS ${release_args} ${sdk_args}"
fi
if [ $? != 0 ]; then
exit $?;
fi
done;
|