#!/bin/bash # UEFI builds use the WORSKPACE variable, so save it and restore it later JENKINS_WORKSPACE=${WORKSPACE} unset WORKSPACE case "$1" in "release" ) JOB_TYPE=release YYMM=`date +%y`.`date +%m` PINNED="pinned-" ;; "snapshot" ) JOB_TYPE=snapshot YYMM=master PINNED="pinned-" ;; * ) JOB_TYPE=snapshot YYMM=master PINNED= esac echo "platforms-ci.sh: doing a $PINNED $JOB_TYPE build for branch $YYMM" # pre-requisites if [ "$JOB_NAME" != "" ]; then # 32 bit libraries needed for BusyBox sudo apt-get update sudo apt-get install -y --force-yes gcc-multilib sudo apt-get install -y --force-yes zip sudo apt-get install -y --force-yes libssl-dev sudo apt-get install -y --force-yes python-crypto # Toolchain echo ls ${HOME}/srv/toolchain/ ls ${HOME}/srv/toolchain # Use pre-installed linaro toolchain export PATH="${HOME}/srv/toolchain/arm-tc-15.02/bin:${HOME}/srv/toolchain/arm64-tc-15.02/bin:$PATH" # REPO curl https://storage.googleapis.com/git-repo-downloads/repo > ./repo chmod a+x repo repo=$PWD/repo ls -al else echo "Not installing stuff for a non-Jenkins build" repo=repo fi # functions function quit { echo "ERROR: It doesn't look like you're in a platforms repo" echo "ERROR: This is missing: $1" exit 1 } function gitnuke { echo "cleaning directory $*" pushd $* git reset --hard HEAD && git clean -dfx popd } function clean_workspace { export -f gitnuke find . -name ".git" -type d -exec bash -c 'gitnuke "{}/.."' \; rm ramdisk.img } function check_workspace { mandatory_dirs=( .repo arm-tf build-scripts busybox linux model-scripts ramdisk recovery u-boot uefi/edk2 vexpress-firmware ) for ((i=0;i<${#mandatory_dirs[@]};++i)); do if [ ! -e ${mandatory_dirs[i]} ]; then quit ${mandatory_dirs[i]} else #debugging - make sure we have what we expected to have in each dir pushd ${mandatory_dirs[i]} git log --pretty=format:"%h %ad %s%x09[%an]" --date=short -5 ls -al popd fi done } function show_commit { gitdir=$1 dir=`echo $gitdir | sed -e "s#^\.\/##g" -e "s#\\/\.git/\.\.##g"` pushd $dir > /dev/null #git remote -v | grep fetch commitid=`git log --oneline -1 --pretty=format:"%h" --date=short` echo "$commitid $dir" popd > /dev/null } function sha_list { export -f show_commit echo "commit repo" echo "------- --------------------- " find . -name ".git" -type d -exec bash -c 'show_commit "{}/.."' \; } function create_release_zip { local variant=$1 # variant (eg. juno, fvp, ...) local manifest=$2 # manifest we used to build the code local os=$3 # OS (eg. oe, android, ...) local boot=$4 # bootloader (uboot or uefi) local to=$5 local workspace=workspace-${manifest} local from=$workspace/output/${variant}-${os}/${boot} echo copying output $from $to mkdir -p $to case $variant in juno ) cp -R $workspace/recovery/* $to cp -R $from/* $to/SOFTWARE cp $workspace/uefi/edk2/Build/ArmJuno/DEBUG_GCC49/FV/BL33_AP_UEFI.fd $to/SOFTWARE/bl33-uefi.bin cp $workspace/u-boot/output/vexpress_aemv8a_juno/u-boot.bin $to/SOFTWARE/bl33-uboot.bin ;; fvp ) cp $workspace/model-scripts/run_model.sh $to cp -R $from/* $to cp $workspace/uefi/edk2/Build/ArmVExpress-FVP-AArch64/DEBUG_GCC49/FV/FVP_AARCH64_EFI.fd $to/bl33-uefi.bin cp $workspace/u-boot/output/vexpress_aemv8a_dram/u-boot.bin $to/bl33-uboot.bin ;; tc2 ) cp -R $workspace/vexpress-firmware/* $to cp -R $from/* $to/SOFTWARE ;; * ) echo "WARNING: variant not recognised" echo " you will get a default set of files in your ZIP" echo " and you may not be expecting that." cp -R $from/* $to ;; esac pushd ${to} # Generate report for this build # First decide the report filename - use an absolute path so we can change # directories and still write to the correct report file if [ "$YYMM" == "master" ]; then # use date and time in the marker file report=$PWD/${to}-`date +%Y%m%d-%H%M`.txt else report=$PWD/${to}-${YYMM}.txt fi # Add the ms5sums of the files for this build echo "md5sum file" > ${report} echo "-------------------------------- -----------------------------------" >> ${report} find . -name "*" -type f | grep -v -e ${report} | sort | xargs md5sum >> ${report} # Add the commit ids for the repos we built from echo "" >> $report pushd ../$workspace sha_list >> $report popd # zip up the build zip -r ../${to}.zip * popd } function dobuilds { manifest=$1 # pinned-lsk, lsk, pinned-latest or latest branch=$2 workspace=workspace-$1 mkdir -p $workspace pushd $workspace # just in case this is a rebuild, clean the workspace clean_workspace # remove old code and builds before syncing rm -rf * # just for debugging purposes ls -al echo Using repo command: ${repo} init -u https://git.linaro.org/landing-teams/working/arm/manifest -b ${branch} -m ${manifest}.xml ${repo} init -u https://git.linaro.org/landing-teams/working/arm/manifest -b ${branch} -m ${manifest}.xml ${repo} sync -j8 sha_list # just for debugging purposes ls -al check_workspace variants=( fvp-busybox fvp-oe fvp-android fvp-uefi juno-busybox juno-oe juno-android juno-uefi tc2-busybox tc2-oe tc2-android tc2-uefi ) # This should be 'latest', however, occasionally the latest links are broken, or we specifically # want to reference an old version. # So for now, specificy the exact version we'd like to build with. android_version=6.0-16.02 for ((i=0;i<${#variants[@]};++i)); do rm -f ramdisk.img if [ "${variants[i]}" == "fvp-android" ]; then wget http://releases.linaro.org/android/reference-lcr/fvp/${android_version}/ramdisk.img elif [ "${variants[i]}" == "juno-android" ]; then wget http://releases.linaro.org/android/reference-lcr/juno/${android_version}/ramdisk.img elif [ "${variants[i]}" == "tc2-android" ]; then wget http://releases.linaro.org/android/reference-lcr/vexpress/${android_version}/ramdisk.img fi ./build-scripts/build-all.sh ${variants[i]} ./build-scripts/build-all.sh ${variants[i]} package done popd } echo "aarch32 cross compiler:" which arm-linux-gnueabihf-gcc && arm-linux-gnueabihf-gcc -v echo "aarch64 cross compiler:" which aarch64-linux-gnu-gcc && aarch64-linux-gnu-gcc -v # build the two kernel variants dobuilds ${PINNED}lsk $YYMM dobuilds ${PINNED}latest $YYMM # Create the recovery directories for each variant create_release_zip juno ${PINNED}latest busybox uboot juno-latest-busybox-uboot create_release_zip juno ${PINNED}latest oe uboot juno-latest-oe-uboot create_release_zip juno ${PINNED}lsk android uboot juno-lsk-android-uboot create_release_zip juno ${PINNED}lsk uefi uefi juno-uefi create_release_zip fvp ${PINNED}latest busybox uboot fvp-latest-busybox-uboot create_release_zip fvp ${PINNED}latest oe uboot fvp-latest-oe-uboot create_release_zip fvp ${PINNED}lsk android uboot fvp-lsk-android-uboot create_release_zip fvp ${PINNED}lsk uefi uefi fvp-uefi if [ "$JOB_TYPE" != "release" ]; then # only generate TC2 zips for the non-release job create_release_zip tc2 ${PINNED}latest busybox bootmon tc2-latest-busybox-bootmon create_release_zip tc2 ${PINNED}latest oe bootmon tc2-latest-oe-bootmon create_release_zip tc2 ${PINNED}lsk android bootmon tc2-lsk-oe-bootmon create_release_zip tc2 ${PINNED}lsk uefi uefi tc2-uefi fi # create the final release zips if [ "$PLATFORMS_ZIPS" == "yes" ]; then zip juno-platforms.zip juno-l*.zip zip fvp-platforms.zip fvp-l*.zip zip tc2-platforms.zip tc2-l*.zip fi if [ "$UBER_ZIP" == "yes" ]; then zip platforms.zip juno-l*.zip fvp-l*.zip tc2-l*.zip fi ls -al # restore the WORKSPACE variable now we're finished building unset WORKSPACE export WORKSPACE=${JENKINS_WORKSPACE}