forked from openbmc/openbmc-build-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathopenpower-build-setup.sh
executable file
·181 lines (149 loc) · 3.47 KB
/
openpower-build-setup.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
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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
#!/bin/bash
# This build script is for running the Jenkins builds using docker.
#
# It expects a few variables which are part of Jenkins build job matrix:
# target = palmetto|qemu|habanero|firestone|garrison
# distro = ubuntu|fedora
# WORKSPACE = Random Number by Default
# Trace bash processing
set -x
# Default variables
target=${target:-palmetto}
distro=${distro:-ubuntu}
WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
# Timestamp for job
echo "Build started, $(date)"
# if there is no open-power directory clone in master into workspace
if [ ! -e ${WORKSPACE}/op-build ]; then
echo "Clone in openpower master to ${WORKSPACE}/op-build"
git clone --recursive https://github.com/open-power/op-build ${WORKSPACE}/op-build
fi
# Determine the architecture
ARCH=$(uname -m)
# Determine the prefix of the Dockerfile's base image
case ${ARCH} in
"ppc64le")
DOCKER_BASE="ppc64le/"
;;
"x86_64")
DOCKER_BASE=""
;;
*)
echo "Unsupported system architecture(${ARCH}) found for docker image"
exit 1
esac
# Configure docker build
if [[ "${distro}" == fedora ]];then
Dockerfile=$(cat << EOF
FROM ${DOCKER_BASE}fedora:latest
RUN dnf --refresh repolist && dnf install -y \
bc \
bison \
bzip2 \
cpio \
cscope \
ctags \
expat-devel \
findutils \
flex \
gcc-c++ \
git \
libxml2-devel \
ncurses-devel \
openssl-devel \
patch \
perl \
perl-bignum \
"perl(Digest::SHA1)" \
"perl(Env)" \
"perl(Fatal)" \
"perl(Thread::Queue)" \
"perl(XML::SAX)" \
"perl(XML::Simple)" \
"perl(YAML)" \
"perl(XML::LibXML)" \
python \
python3 \
tar \
unzip \
vim \
wget \
which \
zlib-devel \
zlib-static \
iputils-ping
RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
USER ${USER}
ENV HOME ${HOME}
RUN /bin/bash
EOF
)
elif [[ "${distro}" == ubuntu ]]; then
Dockerfile=$(cat << EOF
FROM ${DOCKER_BASE}ubuntu:latest
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -yy \
bc \
bison \
build-essential \
cscope \
cpio \
ctags \
flex \
g++ \
git \
libssl-dev \
libexpat-dev \
libz-dev \
libxml-sax-perl \
libxml-simple-perl \
libxml2-dev \
libxml2-utils \
language-pack-en \
python \
python3 \
texinfo \
unzip \
vim-common \
wget\
xsltproc \
libssl-dev \
iputils-ping
RUN grep -q ${GROUPS} /etc/group || groupadd -g ${GROUPS} ${USER}
RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS} ${USER}
USER ${USER}
ENV HOME ${HOME}
RUN /bin/bash
EOF
)
fi
# Build the docker container
docker build -t op-build/${distro} - <<< "${Dockerfile}"
if [[ "$?" -ne 0 ]]; then
echo "Failed to build docker container."
exit 1
fi
mkdir -p ${WORKSPACE}
cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
#!/bin/bash
set -x
# This ensures that the alias set in op-build-env is
# avalaible in this script
shopt -s expand_aliases
cd ${WORKSPACE}/op-build
# Source our build env
. op-build-env
# Configure
op-build ${target}_defconfig
# Kick off a build
op-build
EOF_SCRIPT
chmod a+x ${WORKSPACE}/build.sh
# Run the docker container, execute the build script we just built
docker run --net=host --rm=true -e WORKSPACE=${WORKSPACE} --user="${USER}" \
-w "${HOME}" -v "${HOME}":"${HOME}" -t op-build/${distro} ${WORKSPACE}/build.sh
# Create link to images for archiving
ln -sf ${WORKSPACE}/op-build/output/images ${WORKSPACE}/images
# Timestamp for build
echo "Build completed, $(date)"