forked from openbmc/openbmc-build-scripts
-
Notifications
You must be signed in to change notification settings - Fork 5
/
kernel-build-setup.sh
executable file
·134 lines (101 loc) · 3.18 KB
/
kernel-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
#!/bin/bash
# This build script is for running the Jenkins builds using docker.
#
# It expects a variable as part of Jenkins build job matrix:
# distro = fedora|ubuntu
# WORKSPACE =
# Trace bash processing
set -x
# Default variables
distro=${distro:-ubuntu}
WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
http_proxy=${http_proxy:-}
# Timestamp for job
echo "Build started, $(date)"
# Configure docker build
if [[ "${distro}" == fedora ]];then
if [[ -n "${http_proxy}" ]]; then
PROXY="RUN echo \"proxy=${http_proxy}\" >> /etc/dnf/dnf.conf"
fi
Dockerfile=$(cat << EOF
FROM fedora:latest
${PROXY}
RUN dnf --refresh install -y \
bc \
findutils \
git \
gcc \
gcc-arm-linux-gnu \
hostname \
make \
uboot-tools xz
RUN grep -q ${GROUPS[0]} /etc/group || groupadd -g ${GROUPS[0]} ${USER}
RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS[0]} ${USER}
USER ${USER}
ENV HOME ${HOME}
RUN /bin/bash
EOF
)
elif [[ "${distro}" == ubuntu ]]; then
if [[ -n "${http_proxy}" ]]; then
PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
fi
Dockerfile=$(cat << EOF
FROM ubuntu:latest
${PROXY}
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -yy \
bc \
build-essential \
git \
gcc-arm-linux-gnueabi \
binutils-arm-linux-gnueabi \
libssl-dev \
bison \
flex \
u-boot-tools
RUN grep -q ${GROUPS[0]} /etc/group || groupadd -g ${GROUPS[0]} ${USER}
RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS[0]} ${USER}
USER ${USER}
ENV HOME ${HOME}
RUN /bin/bash
EOF
)
fi
# Build the docker container
if ! docker build -t "linux-aspeed/${distro}" - <<< "${Dockerfile}" ; then
echo "Failed to build docker container."
exit 1
fi
# Create the docker run script
export PROXY_HOST=${http_proxy/#http*:\/\/}
export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
export PROXY_PORT=${http_proxy/#http*:\/\/*:}
mkdir -p "${WORKSPACE}"
cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
#!/bin/bash
set -x
cd ${WORKSPACE}
# Go into the linux-aspeed directory (the script will put us in a build subdir)
cd linux-aspeed
# Configure a build
if [ "${distro}" == "fedora" ]; then
CROSS_COMPILER="arm-linux-gnu-"
else
CROSS_COMPILER="arm-linux-gnueabi-"
fi
# Record the version in the logs
$\{CROSS_COMPILER}gcc --version
ARCH=arm CROSS_COMPILE=\${CROSS_COMPILER} make aspeed_defconfig
ARCH=arm CROSS_COMPILE=\${CROSS_COMPILER} make -j$(($(nproc) / 4))
# build palmetto image
ARCH=arm CROSS_COMPILE=\${CROSS_COMPILER} make aspeed-bmc-opp-palmetto.dtb
cat arch/arm/boot/zImage arch/arm/boot/dts/aspeed-bmc-opp-palmetto.dtb > palmetto-zimage
./scripts/mkuboot.sh -A arm -O linux -C none -T kernel -a 0x40008000 -e 0x40008000 -d-e 0x40008000 -n obmc-palm-\$(date +%Y%m%d%H%M) -d palmetto-zimage uImage.palmetto
EOF_SCRIPT
chmod a+x "${WORKSPACE}"/build.sh
# Run the docker container, execute the build script we just built
docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE="${WORKSPACE}" --user="${USER}" \
-w "${HOME}" -v "${HOME}":"${HOME}" -t linux-aspeed/"${distro}" "${WORKSPACE}"/build.sh
# Timestamp for build
echo "Build completed, $(date)"