#!/bin/bash # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation version 2. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see unset sync show_setup() { echo "" echo "GCC version: $gcc" echo "Target architecture: $arch" echo "Manifest branch: $manifest_branch" echo "Manifest URL: $manifest_repository" echo "Manifest groups: $manifest_groups" echo "Init env: $init_env" echo "Verbose: $bitbake_verbose" echo "Local download directory: $LOCALDLDIR" echo "Enable ptest: $ptest_enabled" if [ $external_url ]; then echo "External toolchain URL: $external_url" fi echo "" } git_clone_update() { if [ -n "${WORKSPACE}" ]; then # always run repo init again, even if the workspace already exists, in # case a parameter has changed echo "jenkins repo init" repo init -u $manifest_repository -b $manifest_branch -m default.xml $manifest_groups --repo-url=git://android.git.linaro.org/tools/repo echo "jenkins repo sync" repo sync -j4 # FIXME: check if the following code is really needed elif [[ -d .repo ]]; then echo "rebase" for project in $(cat .repo/project.list); do if [[ ! -d $project ]]; then sync=1 fi done if [[ $sync = 1 ]]; then repo sync fi repo rebase else repo init --quiet -u $manifest_repository -b $manifest_branch -m default.xml $manifest_groups --repo-url=git://android.git.linaro.org/tools/repo time repo sync --quiet -j3 fi } fix_oe_core_git() { cd openembedded-core; git reset --hard 62f1122ef166eba56441d669c6b3b3fe5f367418 git revert --no-edit 1a7b843d575b290917d1e379c2ba106460988230 git revert --no-edit a2b278a6eaa9e9b48d858e3be6712267c0122598 git revert --no-edit 4097694b13cd5f0d68987551c3f9af80c87dc6ae git cherry-pick b6a1c7ed0a5955fb15dcd9e14431cb11a5e2e3a0 git cherry-pick 3a599e9d9df4aee25b6aa887563ef833559d96f8 git cherry-pick 4e8840aa7adf91f04da2a1947b8d1dff7f88df50 git cherry-pick 4b4a1295b8476d2820935eb5661b2d24a49b29b2 git cherry-pick c350812523017f113f63e0b863fd526b4d6331b9 cd - cd meta-linaro git revert --no-edit bd4487ec3d11921ac19cbff315765ed468b26d1e cd - } conf_bblayers() { # add required layers cat > conf/bblayers.conf <>conf/bblayers.conf echo "BBLAYERS += '`realpath $PWD/../poky/meta-yocto`'">>conf/bblayers.conf else echo "BBLAYERS += '`realpath $PWD/../openembedded-core/meta`'">>conf/bblayers.conf fi } conf_siteconf() { # Add some Linaro related options if [ "${arch}" = "x86" ] || [ "${arch}" = "x86-64" ]; then machinearch="qemu${arch}" else machinearch="generic${arch}" fi cat > conf/site.conf <> conf/site.conf <>conf/site.conf # allow the user to specify a local, pre-existing download directory if [ -n "$LOCALDLDIR" ]; then cat >> conf/site.conf <>conf/site.conf echo 'PNBLACKLIST[glibc] = "Using external toolchain"' >>conf/site.conf echo 'PNBLACKLIST[libgcc] = "Using external toolchain"' >>conf/site.conf echo 'PNBLACKLIST[gcc-cross] = "Using external toolchain"' >>conf/site.conf tarball_name=`basename $external_url` if [ -z $tarball_name ] ; then tarball_name=`basename $external_url` fi if [ -z $tarball_name ] ; then tarball_name=`basename $external_url` fi mkdir -p toolchain if [ -n "${WORKSPACE}" ]; then mkdir -p ${WORKBASE}/downloads/ local_tarball_name=${WORKBASE}/downloads/$tarball_name else local_tarball_name=toolchain/$tarball_name fi protocol="`echo $external_url | cut -d ':' -f 1`" if test $protocol = "file"; then local_tarball_name="`echo $external_url | sed -e 's:file./::'`" else if [ ! -e $local_tarball_name ];then wget -cv $external_url -O $local_tarball_name fi fi md5sum $local_tarball_name tar xf $local_tarball_name -C toolchain echo "EXTERNAL_TOOLCHAIN = \"`pwd`/toolchain/`echo $tarball_name|sed -e 's/\(.*\)\.tar..*/\1/g'`\"" >> conf/site.conf case $arch in armv7a) echo 'ELT_TARGET_SYS = "arm-linux-gnueabihf"' >>conf/site.conf ;; armv8) echo 'ELT_TARGET_SYS = "aarch64-linux-gnu"' >>conf/site.conf ;; esac set +xe fi } conf_jenkins() { if [ -n "${WORKSPACE}" ]; then # As noted during jdk8 integration, toolchain has subtle ties to the build location. Thus in # jenkins use same tmpdir for all builds. # XXX: make this tmpfs, 10G of ram should be enough echo "TMPDIR = \"${base_dir}/workspace/tmp\"" >>conf/site.conf echo 'TCLIBCAPPEND = ""' >>conf/site.conf fi } conf_localconf() { # get rid of MACHINE setting from local.conf # also disable SDL support in qemu-native sed -i -e "s/^MACHINE.*//g" \ -e "/PACKAGECONFIG_append_pn-qemu-native/d" \ conf/local.conf if [ "$ptest_enabled" = "1" ]; then echo 'DISTRO_FEATURES += "ptest"' >> conf/local.conf fi } cleanup_soft() { sstate_dir=`bitbake -e | grep "^SSTATE_DIR="| cut -d'=' -f2 | tr -d '"'` if [ -e "$sstate_dir" ]; then echo "soft cleanup at $sstate_dir" df -h ${WORKBASE} extra_layers=`bitbake-layers show-layers | awk 'NR>2 {print $2}' | tr "\\n" ","` echo $extra_layers ../openembedded-core/scripts/sstate-cache-management.sh --yes --remove-duplicated \ -d -v \ --extra-layer=$extra_layers \ --cache-dir=$sstate_dir df -h ${WORKBASE} ../openembedded-core/scripts/cleanup-workdir df -h ${WORKBASE} else echo "no sstate-cache to clean up" fi } cleanup_hard() { if [ -n "${WORKBASE}" ]; then echo "hard cleanup at ${WORKBASE}" df -h ${WORKBASE} sstate_dir=`bitbake -e | grep "^SSTATE_DIR="| cut -d'=' -f2 | tr -d '"'` if [ -n "$sstate_dir" ]; then rm -rf $sstate_dir fi #rm -rf ${WORKBASE}/downloads df -h ${WORKBASE} fi } cleanup_auto() { diskspace=`df -h ${WORKBASE}|tail -n1` echo $diskpace used=`echo $diskspace | awk '{ print $5}' | cut -d'%' -f1 ` if [ $used -ge 90 ]; then echo "more then 90% of disk used, hard cleanup" cleanup_hard elif [ $used -ge 50 ]; then echo "more then 50% of disk used, soft cleanup" cleanup_soft else echo "plenty of space, no cleanup" fi } init_env() { if [[ -d openembedded-core ]]; then cd openembedded-core else cd poky fi # set up OE enviroment variables . ./oe-init-build-env ../build conf_bblayers conf_siteconf conf_localconf conf_toolchain conf_jenkins } # Enable some Linaro CI site specific options init_env_linaro_ci() { SSTATE_DIR="${base_dir}/workspace/sstate-cache" if [ -n "$sstatedir" ]; then SSTATE_DIR="${SSTATE_DIR}/$sstatedir" fi cat >> conf/site.conf <