blob: 63691e2fe8c705a5a40f0fd13925f6df77cbee97 [file] [log] [blame]
Cyril Burbbf7e092018-02-06 16:50:30 +11001#!/bin/bash
2
3# This build script is for running the Jenkins builds using docker.
4#
5
6# Trace bash processing
7#set -x
8
9# Default variables
10WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
11http_proxy=${http_proxy:-}
12
13# Timestamp for job
14echo "Build started, $(date)"
15
16# Configure docker build
17if [[ -n "${http_proxy}" ]]; then
Patrick Williams476a7e92022-12-06 09:52:53 -060018 PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
Cyril Burbbf7e092018-02-06 16:50:30 +110019fi
20
21Dockerfile=$(cat << EOF
22FROM ubuntu:latest
23
24${PROXY}
25
26ENV DEBIAN_FRONTEND noninteractive
27RUN apt-get update && apt-get install -yy \
28 bc \
29 build-essential \
30 git \
31 gcc-powerpc64le-linux-gnu \
32 software-properties-common \
33 libssl-dev \
34 iputils-ping \
35 bison \
36 flex
37
38RUN apt-add-repository -y multiverse && apt-get update && apt-get install -yy \
39 dwarves \
40 sparse
41
Patrick Williams384d7412020-11-06 16:15:41 -060042RUN grep -q ${GROUPS[0]} /etc/group || groupadd -g ${GROUPS[0]} ${USER}
43RUN grep -q ${UID} /etc/passwd || useradd -d ${HOME} -m -u ${UID} -g ${GROUPS[0]} ${USER}
Cyril Burbbf7e092018-02-06 16:50:30 +110044
45USER ${USER}
46ENV HOME ${HOME}
47RUN /bin/bash
48EOF
49)
50
51# Build the docker container
Patrick Williams384d7412020-11-06 16:15:41 -060052if ! docker build -t trace-linux-build/ubuntu - <<< "${Dockerfile}" ; then
Patrick Williams476a7e92022-12-06 09:52:53 -060053 echo "Failed to build docker container."
54 exit 1
Cyril Burbbf7e092018-02-06 16:50:30 +110055fi
56
57# Create the docker run script
58export PROXY_HOST=${http_proxy/#http*:\/\/}
59export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
60export PROXY_PORT=${http_proxy/#http*:\/\/*:}
61
Patrick Williams384d7412020-11-06 16:15:41 -060062mkdir -p "${WORKSPACE}"
Cyril Burbbf7e092018-02-06 16:50:30 +110063
64cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
65#!/bin/bash
66
Joel Stanleyc5243f02018-12-13 13:11:49 +103067set -xe
Cyril Burbbf7e092018-02-06 16:50:30 +110068
69cd ${WORKSPACE}
70
71# Go into the linux directory (the script will put us in a build subdir)
72cd linux
73
74# Record the version in the logs
75powerpc64le-linux-gnu-gcc --version
76
77# Build kernel prep
78ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make mrproper
79
80# Generate the config
81echo "CONFIG_PPC_PSERIES=y" >> fragment.config
82echo "CONFIG_PPC_POWERNV=y" >> fragment.config
83echo "CONFIG_MTD=y" >> fragment.config
84echo "CONFIG_MTD_BLOCK=y" >> fragment.config
85echo "CONFIG_MTD_POWERNV_FLASH=y" >> fragment.config
86ARCH=powerpc scripts/kconfig/merge_config.sh \
87 arch/powerpc/configs/ppc64_defconfig \
88 arch/powerpc/configs/le.config \
89 fragment.config
90
Joel Stanley4ec31c62018-08-02 13:30:19 +093091# Ensure config is up to date and no questions will be asked
92yes "" | ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make oldconfig
93
Cyril Burbbf7e092018-02-06 16:50:30 +110094# Build kernel
Joel Stanley4ec31c62018-08-02 13:30:19 +093095ARCH=powerpc CROSS_COMPILE=powerpc64le-linux-gnu- make -j$(nproc) vmlinux
Cyril Burbbf7e092018-02-06 16:50:30 +110096
97EOF_SCRIPT
98
Patrick Williams384d7412020-11-06 16:15:41 -060099chmod a+x "${WORKSPACE}"/build.sh
Cyril Burbbf7e092018-02-06 16:50:30 +1100100
101# Run the docker container, execute the build script we just built
Patrick Williams384d7412020-11-06 16:15:41 -0600102docker run --cap-add=sys_admin --net=host --rm=true -e WORKSPACE="${WORKSPACE}" --user="${USER}" \
Patrick Williams476a7e92022-12-06 09:52:53 -0600103 -w "${WORKSPACE}" -v "${WORKSPACE}":"${WORKSPACE}" \
104 -t trace-linux-build/ubuntu "${WORKSPACE}"/build.sh
Cyril Burbbf7e092018-02-06 16:50:30 +1100105
106result=${?}
107
108# Timestamp for build
109echo "Build completed, $(date)"
110
111exit ${result}