forked from openbmc/openbmc-build-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinitramfs-build.sh
executable file
·161 lines (129 loc) · 3.15 KB
/
initramfs-build.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
#!/bin/bash
# This build script is for running the Jenkins builds using docker.
#
# Debug
if grep -q debug <<< "$@"; then
set -x
fi
set -o errexit
set -o pipefail
set -o nounset
# Default variables
WORKSPACE=${WORKSPACE:-${HOME}/${RANDOM}${RANDOM}}
http_proxy=${http_proxy:-}
ENDIANESS=${ENDIANESS:-le}
PROXY=""
function usage() {
cat << EOF_USAGE
Usage: $0 [options]
Options:
--endianess <le|be> build an LE or BE initramfs
Short Options:
-e same as --endianess
EOF_USAGE
exit 1
}
# Arguments
CMD_LINE=$(getopt -o d,e: --longoptions debug,endianess: -n "$0" -- "$@")
eval set -- "${CMD_LINE}"
while true ; do
case "${1}" in
-e|--endianess)
if [[ "${2,,}" == "be" ]]; then
ENDIANESS=""
fi
shift 2
;;
-d|--debug)
set -x
shift
;;
--)
shift
break
;;
*)
usage
;;
esac
done
# Timestamp for job
echo "Build started, $(date)"
# Configure docker build
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:18.04
${PROXY}
ENV DEBIAN_FRONTEND noninteractive
RUN apt-get update && apt-get install -yy \
bc \
build-essential \
ccache \
cpio \
git \
python \
unzip \
wget \
rsync \
iputils-ping \
locales
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}
RUN locale-gen en_AU.utf8
USER ${USER}
ENV HOME ${HOME}
RUN /bin/bash
EOF
)
# Build the docker container
if ! docker build -t initramfs-build/ubuntu - <<< "${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
export http_proxy=${http_proxy}
export https_proxy=${http_proxy}
export ftp_proxy=${http_proxy}
cd "${WORKSPACE}"
# Go into the linux directory (the script will put us in a build subdir)
cd buildroot && make clean
# Build PPC64 defconfig
cat >> configs/powerpc64${ENDIANESS}_openpower_defconfig << EOF_BUILDROOT
BR2_powerpc64${ENDIANESS}=y
BR2_CCACHE=y
BR2_SYSTEM_BIN_SH_BASH=y
BR2_TARGET_GENERIC_GETTY_PORT="hvc0"
BR2_PACKAGE_BUSYBOX_SHOW_OTHERS=y
BR2_TARGET_ROOTFS_CPIO=y
BR2_TARGET_ROOTFS_CPIO_XZ=y
BR2_PACKAGE_IPMITOOL=y
# BR2_TARGET_ROOTFS_TAR is not set
EOF_BUILDROOT
# Build buildroot
export BR2_DL_DIR="${HOME}/buildroot_downloads"
make powerpc64${ENDIANESS}_openpower_defconfig
make
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 initramfs-build/ubuntu \
"${WORKSPACE}/build.sh"
# Timestamp for build
echo "Build completed, $(date)"