#!/bin/bash set -e # workaround EDK2 is confused by the long path used during the build # and truncate files name expected by VfrCompile sudo mkdir -p /srv/oe sudo chown buildslave:buildslave /srv/oe cd /srv/oe trap cleanup_exit INT TERM EXIT cleanup_exit() { echo "Running cleanup_exit..." } # XXX: In Debian buster use newer tool img2simg because in certain cases ext2img corrupt rootfs images, # this workaround is meanwhile all RPB builds are switch to use Debian buster. if [ "$label" == "docker-buster-amd64" ]; then android_tools="img2simg" simg_cmd="img2simg" else android_tools="android-tools-fsutils" simg_cmd="ext2simg -v" fi if ! sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 update; then echo "INFO: apt update error - try again in a moment" sleep 15 sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 update || true fi pkg_list="python-pip $android_tools chrpath cpio diffstat gawk libmagickwand-dev libmath-prime-util-perl libsdl1.2-dev libssl-dev python-requests texinfo vim-tiny whiptail pigz" if ! sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 install -y ${pkg_list}; then echo "INFO: apt install error - try again in a moment" sleep 15 sudo DEBIAN_FRONTEND=noninteractive apt-get -q=2 install -y ${pkg_list} fi # Install ruamel.yaml pip install --user --force-reinstall ruamel.yaml set -ex mkdir -p ${HOME}/bin curl https://storage.googleapis.com/git-repo-downloads/repo > ${HOME}/bin/repo chmod a+x ${HOME}/bin/repo export PATH=${HOME}/bin:${PATH} # initialize repo if not done already if [ ! -e ".repo/manifest.xml" ]; then repo init -u ${MANIFEST_URL} -b ${MANIFEST_BRANCH_PREFIX}${MANIFEST_BRANCH} # link to shared downloads on persistent disk # our builds config is expecting downloads and sstate-cache, here. # DL_DIR = "${OEROOT}/sources/downloads" # SSTATE_DIR = "${OEROOT}/build/sstate-cache" mkdir -p ${HOME}/srv/oe/downloads ${HOME}/srv/oe/sstate-cache-${DISTRO}-${MANIFEST_BRANCH} mkdir -p build ln -s ${HOME}/srv/oe/downloads ln -s ${HOME}/srv/oe/sstate-cache-${DISTRO}-${MANIFEST_BRANCH} sstate-cache fi if [ "${ghprbPullId}" ]; then echo "Applying Github pull-request #${ghprbPullId} from ${ghprbGhRepository}" sed -i -e "s|name=\"${ghprbGhRepository}\"|name=\"${ghprbGhRepository}\" revision=\"refs/pull/${ghprbPullId}/head\"|" .repo/manifest.xml fi repo sync cp .repo/manifest.xml source-manifest.xml repo manifest -r -o pinned-manifest.xml MANIFEST_COMMIT=$(cd .repo/manifests && git rev-parse --short HEAD) pushd conf git log -1 popd # record changes since last build, if available if wget -q ${BASE_URL}${PUB_DEST/\/${BUILD_NUMBER}\//\/latest\/}/pinned-manifest.xml -O pinned-manifest-latest.xml; then # https://github.com/96boards/oe-rpb-manifest/commit/0be354483a124903982103dc937f9e5c1a094a3a if grep -q ".*linkfile.*\.\./\.\./\.repo/manifests/setup-environment" pinned-manifest-latest.xml ; then echo "detected old style symlink with relative path, skipping diff report" else repo diffmanifests ${PWD}/pinned-manifest-latest.xml ${PWD}/pinned-manifest.xml > manifest-changes.txt fi else echo "latest build published does not have pinned-manifest.xml, skipping diff report" fi if [ -n "$GERRIT_PROJECT" ] && [ $GERRIT_EVENT_TYPE == "patchset-created" ]; then GERRIT_URL="http://${GERRIT_HOST}/${GERRIT_PROJECT}" cd `grep -rni $GERRIT_PROJECT\" .repo/manifest.xml | grep -Po 'path="\K[^"]*'` if git pull ${GERRIT_URL} ${GERRIT_REFSPEC} | grep -q "Automatic merge failed"; then git reset --hard echo "Error: *** Error patch merge failed" exit 1 fi cd - fi # the setup-environment will create auto.conf and site.conf # make sure we get rid of old config. # let's remove the previous TMPDIR as well. # we want to preserve build/buildhistory though. rm -rf build/conf build/tmp-*glibc/ # Accept EULA if/when needed export EULA_dragonboard410c=1 export EULA_stih410b2260=1 source setup-environment build # Accept freescale EULA cat << EOF >> conf/local.conf ACCEPT_FSL_EULA = "1" EOF #RMH # Add job BUILD_NUMBER to output files names #RMH cat << EOF >> conf/auto.conf #RMH IMAGE_NAME_append = "-${BUILD_NUMBER}" #RMH KERNEL_IMAGE_BASE_NAME_append = "-${BUILD_NUMBER}" #RMH MODULE_IMAGE_BASE_NAME_append = "-${BUILD_NUMBER}" #RMH DT_IMAGE_BASE_NAME_append = "-${BUILD_NUMBER}" #RMH BOOT_IMAGE_BASE_NAME_append = "-${BUILD_NUMBER}" #RMH EOF # get build stats to make sure that we use sstate properly cat << EOF >> conf/auto.conf INHERIT += "buildstats buildstats-summary" EOF # Make sure we don't use rm_work in CI slaves since they are non persistent build nodes cat << EOF >> conf/auto.conf INHERIT_remove = "rm_work" EOF # allow the top level job to append to auto.conf if [ -f ${WORKSPACE}/auto.conf ]; then cat ${WORKSPACE}/auto.conf >> conf/auto.conf fi # add useful debug info cat conf/{site,auto}.conf [ "${DISTRO}" = "rpb" ] && IMAGES+=" ${IMAGES_RPB}" [ "${DISTRO}" = "rpb-wayland" ] && IMAGES+=" ${IMAGES_RPB_WAYLAND}" # These machines only build the basic rpb-console-image case "${MACHINE}" in am57xx-evm|intel-core2-32|intel-corei7-64) IMAGES="rpb-console-image" ;; esac time bitbake ${IMAGES} DEPLOY_DIR_IMAGE=$(bitbake -e | grep "^DEPLOY_DIR_IMAGE="| cut -d'=' -f2 | tr -d '"') # Prepare files to publish rm -f ${DEPLOY_DIR_IMAGE}/*.txt find ${DEPLOY_DIR_IMAGE} -type l -delete mv /srv/oe/{source,pinned}-manifest.xml ${DEPLOY_DIR_IMAGE} cat ${DEPLOY_DIR_IMAGE}/pinned-manifest.xml # FIXME: IMAGE_FSTYPES_remove doesn't work rm -f ${DEPLOY_DIR_IMAGE}/*.rootfs.ext4 \ ${DEPLOY_DIR_IMAGE}/*.rootfs.iso \ ${DEPLOY_DIR_IMAGE}/*.rootfs.wic \ ${DEPLOY_DIR_IMAGE}/*.iso \ ${DEPLOY_DIR_IMAGE}/*.stimg # FIXME: Sparse images here, until it gets done by OE case "${MACHINE}" in juno|stih410-b2260|orangepi-i96) ;; *) for rootfs in $(find ${DEPLOY_DIR_IMAGE} -type f -name *.rootfs.ext4.gz); do pigz -d -k ${rootfs} sudo $simg_cmd ${rootfs%.gz} ${rootfs%.ext4.gz}.img rm -f ${rootfs%.gz} pigz -9 ${rootfs%.ext4.gz}.img done ;; esac # Create MD5SUMS file find ${DEPLOY_DIR_IMAGE} -type f | xargs md5sum > MD5SUMS.txt sed -i "s|${DEPLOY_DIR_IMAGE}/||" MD5SUMS.txt mv MD5SUMS.txt ${DEPLOY_DIR_IMAGE} # Build information cat > ${DEPLOY_DIR_IMAGE}/HEADER.textile << EOF h4. Reference Platform Build - CE OpenEmbedded Build description: * Build URL: "$BUILD_URL":$BUILD_URL * Manifest URL: "${MANIFEST_URL}":${MANIFEST_URL} * Manifest branch: ${MANIFEST_BRANCH_PREFIX}${MANIFEST_BRANCH} * Manifest commit: "${MANIFEST_COMMIT}":${MANIFEST_URL/.git/\/commit}/${MANIFEST_COMMIT} EOF if [ -e "/srv/oe/manifest-changes.txt" ]; then # the space after pre.. tag is on purpose cat > ${DEPLOY_DIR_IMAGE}/README.textile << EOF h4. Manifest changes pre.. EOF cat /srv/oe/manifest-changes.txt >> ${DEPLOY_DIR_IMAGE}/README.textile mv /srv/oe/manifest-changes.txt ${DEPLOY_DIR_IMAGE} fi # Need different files for each machine BOOT_IMG=$(find ${DEPLOY_DIR_IMAGE} -type f -name "boot-*-${MACHINE}-*.img" | sort | xargs -r basename) ROOTFS_EXT4_IMG=$(find ${DEPLOY_DIR_IMAGE} -type f -name "rpb-console-image-test-${MACHINE}-*.rootfs.ext4.gz" | xargs -r basename) ROOTFS_TARXZ_IMG=$(find ${DEPLOY_DIR_IMAGE} -type f -name "rpb-console-image-test-${MACHINE}-*.rootfs.tar.xz" | xargs -r basename) ROOTFS_IMG=$(find ${DEPLOY_DIR_IMAGE} -type f -name "rpb-console-image-test-${MACHINE}-*.rootfs.img.gz" | xargs -r basename) ROOTFS_DESKTOP_IMG=$(find ${DEPLOY_DIR_IMAGE} -type f -name "rpb-desktop-image-test-${MACHINE}-*.rootfs.img.gz" | xargs -r basename) KERNEL_IMG=$(find ${DEPLOY_DIR_IMAGE} -type f -name "*Image-*-${MACHINE}-*.bin" | xargs -r basename) DISK_IMG=$(find ${DEPLOY_DIR_IMAGE} -type f -name "*-${MACHINE}-*.rootfs.wic.*z*" | grep -v empty | xargs -r basename) case "${MACHINE}" in am57xx-evm) # LAVA image is too big for am57xx-evm ROOTFS_IMG=$(find ${DEPLOY_DIR_IMAGE} -type f -name "rpb-console-image-${MACHINE}-*-${BUILD_NUMBER}.rootfs.img.gz" | xargs -r basename) # FIXME: several dtb files case ;; intel-core2-32|intel-corei7-64) # No LAVA testing on intel-core* machines ROOTFS_TARXZ_IMG=$(find ${DEPLOY_DIR_IMAGE} -type f -name "rpb-console-image-${MACHINE}-*-${BUILD_NUMBER}.rootfs.tar.xz" | xargs -r basename) ;; juno) # FIXME: several dtb files case ;; *) DTB_IMG=$(find ${DEPLOY_DIR_IMAGE} -type f -name "*-${MACHINE}-*-${BUILD_NUMBER}.dtb" | xargs -r basename) ;; esac # Note: the main job script allows to override the default value for # BASE_URL and PUB_DEST, typically used for OE RPB builds cat << EOF > ${WORKSPACE}/post_build_lava_parameters DEPLOY_DIR_IMAGE=${DEPLOY_DIR_IMAGE} MANIFEST_COMMIT=${MANIFEST_COMMIT} BOOT_URL=${BASE_URL}${PUB_DEST}/${BOOT_IMG} ROOTFS_BUILD_URL=${BASE_URL}${PUB_DEST}/${ROOTFS_EXT4_IMG} ROOTFS_SPARSE_BUILD_URL=${BASE_URL}${PUB_DEST}/${ROOTFS_IMG} ROOTFS_DESKTOP_SPARSE_BUILD_URL=${BASE_URL}${PUB_DEST}/${ROOTFS_DESKTOP_IMG} SYSTEM_URL=${BASE_URL}${PUB_DEST}/${ROOTFS_EXT4_IMG} KERNEL_URL=${BASE_URL}${PUB_DEST}/${KERNEL_IMG} DTB_URL=${BASE_URL}${PUB_DEST}/${DTB_IMG} NFSROOTFS_URL=${BASE_URL}${PUB_DEST}/${ROOTFS_TARXZ_IMG} RECOVERY_IMAGE_URL=${BASE_URL}${PUB_DEST}/juno-oe-uboot.zip LXC_BOOT_IMG=${BOOT_IMG} LXC_ROOTFS_IMG=$(basename ${ROOTFS_IMG} .gz) INITRD_URL="${INITRD_URL}" KERNEL_ARGS="" EOF