initramfs_build: Update with the actual script being run
The buildroot-master initramfs build job was using a version of this
script from https://github.com/csmart/openbmc-build-scripts.git#endianess
Change-Id: I702656c7f2738bc928959eed7a280b2d78edf2ba
Signed-off-by: Joel Stanley <joel@jms.id.au>
diff --git a/initramfs-build.sh b/initramfs-build.sh
index 4af4ec0..4ae3d9f 100755
--- a/initramfs-build.sh
+++ b/initramfs-build.sh
@@ -3,23 +3,70 @@
# This build script is for running the Jenkins builds using docker.
#
-# Trace bash processing
-#set -x
+# 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=""
+
+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"
+ PROXY="RUN echo \"Acquire::http::Proxy \\"\"${http_proxy}/\\"\";\" > /etc/apt/apt.conf.d/000apt-cacher-ng-proxy"
fi
Dockerfile=$(cat << EOF
-FROM ubuntu:latest
+FROM ubuntu:18.04
${PROXY}
@@ -27,6 +74,7 @@
RUN apt-get update && apt-get install -yy \
bc \
build-essential \
+ ccache \
cpio \
git \
python \
@@ -49,8 +97,8 @@
# Build the docker container
docker build -t initramfs-build/ubuntu - <<< "${Dockerfile}"
if [[ "$?" -ne 0 ]]; then
- echo "Failed to build docker container."
- exit 1
+ echo "Failed to build docker container."
+ exit 1
fi
# Create the docker run script
@@ -58,38 +106,54 @@
export PROXY_HOST=${PROXY_HOST/%:[0-9]*}
export PROXY_PORT=${http_proxy/#http*:\/\/*:}
-mkdir -p ${WORKSPACE}
+mkdir -p "${WORKSPACE}"
-cat > "${WORKSPACE}"/build.sh << EOF_SCRIPT
+cat > "${WORKSPACE}/build.sh" << EOF_SCRIPT
#!/bin/bash
set -x
-cd ${WORKSPACE}
+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
+cd buildroot && make clean
-cat > configs/powerpc64_openpower_defconfig << EOF_BUILDROOT
-BR2_powerpc64le=y
+# 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_TARGET_GENERIC_GETTY_PORT="hvc0"
-BR2_SYSTEM_DHCP="eth0"
+# BR2_TARGET_ROOTFS_TAR is not set
EOF_BUILDROOT
# Build buildroot
-export BR2_DL_DIR=${HOME}/buildroot_downloads
-make powerpc64_openpower_defconfig || exit 1
-make || exit 1
+export BR2_DL_DIR="${HOME}/buildroot_downloads"
+make powerpc64${ENDIANESS}_openpower_defconfig
+make
EOF_SCRIPT
-chmod a+x ${WORKSPACE}/build.sh
+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
+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)"