#!/bin/bash # Global Variables bundle_stream_name_path="/private/team/linaro/ci-$bundle_stream_name/" log_info=$BUILD_URL"consoleText" pkg_dir="builddir-${kernel_release}" # Default directory where config fragments are or should be stored. conf_dir="linaro/configs" # Default gitweb access URL. default_git_url="http://git.linaro.org/gitweb?p=$conf_git;a=blob_plain;f=$conf_dir/$conf;hb=$conf_branch" boot_wrapper_repo="git://git.kernel.org/pub/scm/linux/kernel/git/cmarinas/boot-wrapper-aarch64.git" echo > hwpack_info # start with empty echo KERNEL_CONFIG=$kernel_config >> hwpack_info echo OS_INFO=`cat /etc/lsb-release | grep DISTRIB_DESCRIPTION | cut -d '=' -f 2` >> hwpack_info echo LOG=$log_info >> hwpack_info echo BUILD_ID=$BUILD_NUMBER >> hwpack_info echo GCC_VERSION=`dpkg -s gcc | grep Version | cut -d ' ' -f2` >> hwpack_info echo GCC_CROSS_COMPILER=$gcc_version >> hwpack_info echo BOARD_TYPES=$board_types >> hwpack_info echo HWPACK_TYPE=$hwpack_type >> hwpack_info echo ROOTFS_TYPE=$rootfs_type >> hwpack_info echo BUNDLE_STREAM_NAME=$bundle_stream_name_path >> hwpack_info echo JOB_URL=http://snapshots.linaro.org/kernel-hwpack/ >> hwpack_info echo KERNEL_VERSION=${kernel_version} >> hwpack_info echo KERNEL_GIT=$KERNEL_GIT >> hwpack_info echo KERNEL_COMMIT=$KERNEL_COMMIT >> hwpack_info echo COMMIT_TIME=`git show -s --format=%cD HEAD` >> hwpack_info echo KERNEL_NAME=$bundle_stream_name >> hwpack_info echo SUBMIT_LAVA_JOB=$submit_job >> hwpack_info echo LAVA_TEST_PLAN=$lava_test_plan >> hwpack_info echo KERNEL_BUILD_URL=$BUILD_URL >> hwpack_info echo KERNEL_BRANCH=`git branch | grep -e '*' | cut -d '*' -f 2` >> hwpack_info echo KERNEL_JOB_NAME=$JOB_NAME >> hwpack_info echo GIT_LOG=`git log -n1 --pretty=format:%s` >> hwpack_info echo GIT_WEB_URL=$git_web_url >> hwpack_info if test -n "$device_tags"; then echo DEVICE_TAGS=$device_tags >> hwpack_info fi build_setup() { rm -f linux-*.deb # The builddeb has the changes to successfully build for armhf/arm64 in linux-linaro-tracking tree. # Hence copy the modified builddeb for other trees only, which is required to do armhf or arm64 builds. # last-modified: 2014-04-11 - linux-linaro-tracking (ll-20140411.1) # https://git.linaro.org/kernel/linux-linaro-tracking.git/blob_plain/refs/heads/linux-linaro:/scripts/package/builddeb repo_name="linux-linaro-tracking" if [[ ! "$KERNEL_GIT" =~ "$repo_name" ]] then if [[ -e $WORKSPACE/lci-build-tools/build-scripts/builddeb ]] then echo "Copying the local builddeb..." cp scripts/package/builddeb scripts/package/builddeb.orig cp $WORKSPACE/lci-build-tools/build-scripts/builddeb scripts/package/builddeb else echo "Missing builddeb file" fi else echo "Using the builddeb available in the tree..." fi rm -rf $pkg_dir mkdir $pkg_dir } create_config_using_config_fragments() { # Retrieve first, if defined, external conf fragment. if test -n "$conf_git" -a -n "$conf_branch"; then echo "Retrieving external configuration file" if test -n "$conf_external"; then # Check that we have a place where to store everything. if ! test -d $conf_dir; then mkdir -p $conf_dir fi for conf in `printf "$conf_external" | tr ',' ' '` do curl "$default_git_url" > "$conf_dir/$conf" if test -e "$conf_dir/$conf"; then # Store everything in $conf_filenames conf_filenames="$conf_filenames $conf_dir/$conf" else echo "Config file $conf not found at $default_git_url" fi done else echo "External configuration file to retrieve not defined, skipping" fi fi scripts/kconfig/merge_config.sh $conf_filenames for cname in `find . -name \.config ` do mv $cname $WORKSPACE/$pkg_dir/ done } build_instructions() { # Calling the function build setup to create build env build_setup START=$(date +%s) cpu_count=`getconf _NPROCESSORS_ONLN` j_count=`expr $cpu_count '*' 2` if [ "${silent}" = "true" ]; then redirect_output=" &>${pkg_dir}/build.log" fi if [ -n "$conf_filenames" -o -n "$conf_git" ] ; then create_config_using_config_fragments eval 'make mrproper'${redirect_output} elif [ -n "$kernel_config" ]; then eval 'make mrproper'${redirect_output} eval 'make O=${pkg_dir} ${kernel_config}'${redirect_output} else echo "Kernel configuration isn't set (kernel_config or conf_filenames or conf_git)" exit 1 fi yes "" | eval 'make O=${pkg_dir} oldconfig'${redirect_output} if [ "${ARCH}" = "arm" ]; then if [ -n "${LOADADDR}" ]; then kernel_img_cmd="uImage LOADADDR=${LOADADDR}" elif grep -Fxq 'CONFIG_ARCH_MULTIPLATFORM=y' ${WORKSPACE}/${pkg_dir}/.config; then kernel_img_cmd=zImage else kernel_img_cmd=uImage fi kernel_debarch=armhf elif [ "${ARCH}" = "arm64" ]; then kernel_img_cmd=Image kernel_debarch=arm64 fi eval 'make KERNELRELEASE=${kernel_release} O=${pkg_dir} -j${j_count} ${kernel_img_cmd}'${redirect_output} if grep -Fxq 'CONFIG_MODULES=y' ${WORKSPACE}/${pkg_dir}/.config; then eval 'make KERNELRELEASE=${kernel_release} O=${pkg_dir} -j${j_count} modules'${redirect_output} fi if [ "$MAKE_DTBS" = "true" ]; then echo "Building with DTBS support..." eval 'make KERNELRELEASE=${kernel_release} O=${pkg_dir} dtbs'${redirect_output} fi if [ "${make_bootwrapper}" = "true" -a "${ARCH}" = "arm64" ]; then echo "Building boot wrapper" rm -rf ${pkg_dir}/boot-wrapper git clone ${boot_wrapper_repo} ${pkg_dir}/boot-wrapper cd ${pkg_dir}/boot-wrapper/ autoreconf -vfi ./configure \ --host=aarch64-linux-gnu \ --with-kernel-dir=${WORKSPACE}/${pkg_dir} \ --with-cmdline="console=ttyAMA0 earlyprintk=pl011,0x1c090000 consolelog=9 rw root=/dev/vda2" make IMAGE=img-foundation.axf clean make DTC=${WORKSPACE}/${pkg_dir}/scripts/dtc/dtc \ IMAGE=img-foundation.axf \ KERNEL_DTB=${WORKSPACE}/${pkg_dir}/arch/arm64/boot/dts/foundation-v8.dtb ./configure \ --host=aarch64-linux-gnu \ --with-kernel-dir=${WORKSPACE}/${pkg_dir} \ --with-cmdline="console=ttyAMA0 earlyprintk=pl011,0x1c090000 consolelog=9 rw root=/dev/mmcblk0p2" make IMAGE=img.axf clean make DTC=${WORKSPACE}/${pkg_dir}/scripts/dtc/dtc \ IMAGE=img.axf \ KERNEL_DTB=${WORKSPACE}/${pkg_dir}/arch/arm64/boot/dts/rtsm_ve-aemv8a.dtb cd ${WORKSPACE} cp -a ${pkg_dir}/boot-wrapper/*.axf ${pkg_dir}/arch/arm64/boot/ fi if [ "${make_deb}" = "true" ]; then [ "${ARCH}" = "arm64" ] && kernel_image_arg="KBUILD_IMAGE=arch/arm64/boot/Image" eval 'make O=${pkg_dir} KERNELRELEASE=${kernel_release} KBUILD_DEBARCH=${kernel_debarch} ${kernel_image_arg} V=1 deb-pkg'${redirect_output} fi if [ "${make_install}" = "true" ]; then install -D -p -m0644 ${pkg_dir}/.config out/kernel.config install -D -p -m0644 ${pkg_dir}/arch/${ARCH}/boot/${kernel_img_cmd} out/${kernel_img_cmd} [ "${silent}" = "true" ] && cp -a ${pkg_dir}/build.log out/ for dtb in `find ${pkg_dir}/arch/${ARCH}/boot/dts/ -type f -name '*.dtb'`; do dtb=`basename ${dtb}` install -D -p -m0644 ${pkg_dir}/arch/${ARCH}/boot/dts/${dtb} out/dtbs/${dtb} done fi END=$(date +%s) EXECUTION_TIME_IN_SEC=$(( $END - $START )) if [ "$submit_job" -eq 1 ]; then hwpack_url=`python lci-build-tools/get_latest_slo_hwpack` python lci-build-tools/download_file ${hwpack_url} latest_hwpack_name=`basename $hwpack_url` hwpack_prefix=`echo ${latest_hwpack_name} | cut -d'_' -f-2` hwpack_version=`date +%Y%m%d`-${BUILD_NUMBER} hwpack_name=${hwpack_prefix}_${hwpack_version}_${kernel_debarch}_supported.tar.gz mv ${latest_hwpack_name} ${hwpack_name} rm -rf linaro-image-tools git clone http://git.linaro.org/git/ci/linaro-image-tools.git python linaro-image-tools/linaro-hwpack-replace -t ${hwpack_name} -p linux-image-${kernel_release}_*.deb -r linux-image -i python linaro-image-tools/linaro-hwpack-replace -t ${hwpack_name} -p linux-headers-${kernel_release}_*.deb -r linux-headers -i echo HWPACK_NAME=${hwpack_name} >> hwpack_info echo URL=${JOB_URL}/ws/${hwpack_name} >> hwpack_info echo EXECUTION_TIME_IN_SEC=$(( $END - $START )) >> hwpack_info echo HWPACK_BUILD_DATE=${hwpack_version} >>hwpack_info fi # Restore the orig buildeb, which was copied to build non linux-linaro-tracking tree repo_name="linux-linaro-tracking" if [[ ! "$KERNEL_GIT" =~ "$repo_name" ]] then if [[ -e scripts/package/builddeb.orig ]] then echo "Copying back the builddeb that was replaced.." cp scripts/package/builddeb.orig scripts/package/builddeb fi fi }