summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJavier Martinez Canillas <javier.martinez@collabora.co.uk>2013-02-20 10:40:49 (GMT)
committerJavier Martinez Canillas <javier.martinez@collabora.co.uk>2013-04-01 00:17:57 (GMT)
commit5ff42a4306490536c26de530e21518b53dcbce88 (patch)
tree1fe3689a7bff147c54b432668ce9a68cfe277672
downloadjenkins-scripts-5ff42a4306490536c26de530e21518b53dcbce88.tar.gz
jenkins-scripts-5ff42a4306490536c26de530e21518b53dcbce88.tar.xz
jenkins-scripts: add a Bash shell script to launch BitBake/oe builds
The build_poky.sh shell script can be used to build Poky images from Jenkins CI jobs. Currently it supports OMAP4 Panda, i.MX6 QSabrelite and Raspberry PI boards. Signed-off-by: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
-rwxr-xr-xbuild_poky.sh198
1 files changed, 198 insertions, 0 deletions
diff --git a/build_poky.sh b/build_poky.sh
new file mode 100755
index 0000000..e7ac011
--- /dev/null
+++ b/build_poky.sh
@@ -0,0 +1,198 @@
+#!/bin/bash
+#
+# build_poky Shell script to launch Poky builds from the Jenkins CI server
+#
+# Author: Javier Martinez Canillas <javier.martinez@collabora.co.uk>
+#
+
+# Update this paths according to your environment
+BRANCH="danny"
+YOCTO_PATH="${HOME}/yocto"
+SSTATE_DIR="${YOCTO_PATH}/sstate-cache"
+DL_DIR="${YOCTO_PATH}/downloads"
+
+declare -A LAYERS
+LAYERS["poky"]="poky"
+LAYERS["ti"]="meta-ti"
+LAYERS["fsl"]="meta-fsl-arm"
+LAYERS["rpi"]="meta-raspberrypi"
+LAYERS["singularity"]="meta-singularity"
+LAYERS["singularity-ti"]="meta-singularity-ti"
+LAYERS["singularity-fsl"]="meta-singularity-fsl-arm"
+LAYERS["singularity-rpi"]="meta-singularity-raspberrypi"
+
+declare -A REPOS
+REPOS["poky"]="git://git.yoctoproject.org/poky"
+REPOS["singularity"]="git://git.collabora.co.uk/git/singularity/meta-singularity.git"
+REPOS["ti"]="git://git.yoctoproject.org/meta-ti"
+REPOS["fsl"]="git://git.yoctoproject.org/meta-fsl-arm"
+REPOS["rpi"]="git://github.com/djwillis/meta-raspberrypi.git"
+REPOS["singularity-ti"]="git://git.collabora.co.uk/git/singularity/meta-singularity-ti.git"
+REPOS["singularity-fsl"]="git://git.collabora.co.uk/git/singularity/meta-singularity-fsl-arm.git"
+REPOS["singularity-rpi"]="git://git.collabora.co.uk/git/singularity/meta-singularity-raspberrypi.git"
+
+ARGS=2
+
+if [ $# -ne $ARGS ]; then
+ echo "Usage: `basename $0` [MACHINE] [IMAGE]"
+ exit 1
+fi
+
+IMAGE=$2
+MACHINE=$1
+
+case "${MACHINE}" in
+ "pandaboard")
+ ;;
+ "raspberrypi")
+ ;;
+ "imx6qsabrelite")
+ ;;
+ *)
+ echo "MACHINE ${MACHINE} is not valid"
+ exit 1
+ ;;
+esac
+
+echo "
+Building a ${IMAGE} image for ${MACHINE} machine
+"
+
+echo "Layers:"
+for layer in "${!LAYERS[@]}"; do
+ echo "${LAYERS["$layer"]} (${REPOS["$layer"]})"
+done
+
+echo "
+Configuration:
+BRANCH=${BRANCH}
+YOCTO_PATH=${YOCTO_PATH}
+SSTATE_DIR=${SSTATE_DIR}
+DL_DIR=${DL_DIR}
+"
+if [ ! -d ${YOCTO_PATH} ]; then
+ if ! mkdir -p ${YOCTO_PATH}; then
+ echo "creating ${LAYERS_PATH} directory failed"
+ exit 1
+ fi
+fi
+
+for layer in "${!LAYERS[@]}"; do
+ if [ ! -d ${YOCTO_PATH}/${LAYERS["$layer"]} ]; then
+ echo "Layer ${LAYERS["$layer"]} not found"
+ if ! git clone ${REPOS["$layer"]} ${YOCTO_PATH}/${LAYERS["$layer"]}; then
+ echo "cloning ${REPOS["$layer"]} failed"
+ exit 1
+ fi
+ fi
+
+ if ! pushd ${YOCTO_PATH}/${LAYERS["$layer"]} > /dev/null; then
+ echo "pushd to ${YOCTO_PATH}/${LAYERS["$layer"]} failed"
+ exit 1
+ else
+
+ if ! git branch | grep -q $BRANCH; then
+ if ! git checkout -b $BRANCH origin/$BRANCH; then
+ echo "checking out $BRANCH in ${LAYERS["$layer"]} repo failed"
+ exit 1
+ fi
+ fi
+ if ! grep -q $BRANCH .git/HEAD; then
+ git checkout $BRANCH
+ fi
+ popd > /dev/null
+ fi
+done
+
+if ! cd ${YOCTO_PATH}/${LAYERS["poky"]}; then
+ echo "cd ${YOCTO_PATH}/${LAYERS["poky"]} failed"
+ exit 1
+fi
+
+if [ ! -d build-${MACHINE}-${IMAGE} ]; then
+ NEW_BUILD=1
+fi
+
+if ! source oe-init-build-env build-${MACHINE}-${IMAGE}; then
+ echo "source oe-init-build-env build-${MACHINE}-${IMAGE} failed"
+ exit 1
+fi
+
+echo "Entered $(pwd)"
+
+# if the build directory didn't exist before, we have to do some setup first
+if [ ! -z $NEW_BUILD ]; then
+ echo 'SCONF_VERSION = "1"' >> conf/site.conf
+ echo 'BB_NUMBER_THREADS = "4"' >> conf/site.conf
+ echo 'PARALLEL_MAKE = "-j 2"' >> conf/site.conf
+ echo "MACHINE ?= \"${MACHINE}\"" >> conf/site.conf
+ echo "DL_DIR ?= \"${DL_DIR}\"" >> conf/site.conf
+ echo "SSTATE_DIR ?= \"${SSTATE_DIR}\"" >> conf/site.conf
+ echo 'INHERIT += "rm_work"' >> conf/site.conf
+
+ echo "BBLAYERS += \"${YOCTO_PATH}/${LAYERS["singularity"]}\"" >> conf/bblayers.conf
+
+ case "${MACHINE}" in
+ "pandaboard")
+ echo "MACHINE is pandaboard, adding TI layer to BBLAYERS"
+ echo "BBLAYERS += \"${YOCTO_PATH}/${LAYERS["ti"]}\"" >> conf/bblayers.conf
+ echo "BBLAYERS += \"${YOCTO_PATH}/${LAYERS["singularity-ti"]}\"" >> conf/bblayers.conf
+ # TI layer currently requires to BBMASK some recipes
+ echo 'BBMASK = "meta-ti/recipes-misc"' >> conf/site.conf
+ ;;
+ "raspberrypi")
+ echo "MACHINE is raspberrypi, adding RPI layer to BBLAYERS"
+ echo "BBLAYERS += \"${YOCTO_PATH}/${LAYERS["rpi"]}\"" >> conf/bblayers.conf
+ echo "BBLAYERS += \"${YOCTO_PATH}/${LAYERS["singularity-rpi"]}\"" >> conf/bblayers.conf
+ ;;
+ "imx6qsabrelite")
+ echo "MACHINE is imx6qsabrelite, adding FSL layer to BBLAYERS"
+ echo "BBLAYERS += \"${YOCTO_PATH}/${LAYERS["fsl"]}\"" >> conf/bblayers.conf
+ echo "BBLAYERS += \"${YOCTO_PATH}/${LAYERS["singularity-fsl"]}\"" >> conf/bblayers.conf
+ # FSL layer needs the user to accept the EULA
+ echo 'ACCEPT_FSL_EULA = "1"' >> conf/site.conf
+ # FSL layer currently is broken and some append recipes have to be masked
+ echo 'BBMASK = "meta-fsl-arm/recipes-core/udev/udev_173.bbappend"' >> conf/site.conf
+ ;;
+ esac
+fi
+
+echo "Running BitBake ${IMAGE}"
+if ! bitbake ${IMAGE}; then
+ echo "bitbake ${IMAGE} failed"
+ exit 1
+fi
+
+# The script can be used as standalone or from the Jenkins CI server
+if [ -z $JENKINS_HOME ]; then
+ echo "Not called from Jenkins CI, leaving now"
+ exit 0
+fi
+
+if ! mkdir ${WORKSPACE}/${BUILD_TAG}; then
+ echo "mkdir ${WORKSPACE}/${BUILD_TAG} failed"
+ exit 1
+fi
+
+case "${MACHINE}" in
+ "pandaboard")
+ FILES="MLO u-boot.img uImage modules*.tgz ${IMAGE}-${MACHINE}.tar.gz"
+ ;;
+ "raspberrypi")
+ FILES="${IMAGE}-${MACHINE}.rpi-sdimg"
+ ;;
+ "imx6qsabrelite")
+ FILES="${IMAGE}-${MACHINE}.sdcard"
+ ;;
+esac
+
+echo "Copying ${FILES} to Workspace directory"
+for file in ${FILES}
+ do cp -RL tmp/deploy/images/${file} ${WORKSPACE}/${BUILD_TAG}/
+ if [ $? -ne 0 ]; then
+ echo "Copying file ${file} failed"
+ exit 1
+ fi
+done
+
+exit 0