aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Uvarov <maxim.uvarov@linaro.org>2021-10-15 11:07:28 +0100
committerMaxim Uvarov <maxim.uvarov@linaro.org>2021-10-15 11:07:28 +0100
commit06eec6cf93008f72a7d28393240a742af9c0ecca (patch)
treeb014e52005ada28ecfb60e8265d451d1d2c51e7d
initial commit
Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
-rw-r--r--.gitignore1
-rw-r--r--LICENSE20
-rw-r--r--README.md17
-rw-r--r--conf/ledge-qemuarm64/bblayers.conf35
-rw-r--r--conf/ledge-qemuarm64/local.conf1
-rw-r--r--conf/qemuarm64-secureboot/bblayers.conf35
-rw-r--r--conf/qemuarm64-secureboot/local.conf1
-rw-r--r--default.xml21
-rw-r--r--patches/0002-wic-add-UEFI-kernel-as-UEFI-stub.patch67
-rw-r--r--patches/0003-wic-bootimg-efi-implement-include-path.patch32
-rwxr-xr-xsetup-environment21
-rw-r--r--setup-environment-internal362
12 files changed, 613 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..46a32d3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1 @@
+conf/multiconfig/multiconfig
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..fd01b39
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,20 @@
+The MIT License (MIT)
+
+Copyright (c) 2013 Khem Raj
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..48c6e7f
--- /dev/null
+++ b/README.md
@@ -0,0 +1,17 @@
+Ledge-oe-manifest
+
+This is the main manifest file to build the LEDGE Reference Platform from source. For detailed build environment
+and build instructions please refer to ledge-dev-howto.pdf (generated from https://github.com/Linaro/ledge-doc
+sources).
+
+For advanced users quick steps to build are:
+1. repo init -u https://github.com/Linaro/ledge-oe-manifest.git -b master
+2. MACHINE=ledge-multi-armv7 DISTRO=rpb source ./setup-environment build-rpb-mc
+3. Follow printed instructions to build ledge-iot and ledge-gateway images.
+Note: supported MACHINEs are: ledge-multi-armv7, ledge-multi-armv8, ledge-qemux86-64
+
+User guide to run pre-built binaries is at ledge-user-guide.pdf (generated from https://github.com/Linaro/ledge-doc).
+
+CI system is located at https://ci.linaro.org/job/ledge-oe
+
+Mailing list: team-ledge@linaro.org
diff --git a/conf/ledge-qemuarm64/bblayers.conf b/conf/ledge-qemuarm64/bblayers.conf
new file mode 100644
index 0000000..e1a5414
--- /dev/null
+++ b/conf/ledge-qemuarm64/bblayers.conf
@@ -0,0 +1,35 @@
+# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
+# changes incompatibly
+LCONF_VERSION = "7"
+OEROOT := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)))}/../.."
+
+BBPATH = "${TOPDIR}"
+
+BBFILES = ""
+
+# These layers hold recipe metadata not found in OE-core, but lack any machine or distro content
+BASELAYERS ?= " \
+ ${OEROOT}/layers/meta-yocto/meta-poky \
+ ${OEROOT}/layers/meta-openembedded/meta-oe \
+ ${OEROOT}/layers/meta-arm/meta-arm \
+ ${OEROOT}/layers/meta-trusted-substrate \
+"
+
+# These layers hold machine specific content, aka Board Support Packages
+
+BSPLAYERS ?= " \
+ ${OEROOT}/layers/meta-arm/meta-arm-bsp \
+"
+
+# Add your overlay location to EXTRALAYERS
+# Make sure to have a conf/layers.conf in there
+EXTRALAYERS ?= " \
+ ${OEROOT}/layers/meta-arm/meta-arm-toolchain \
+"
+
+BBLAYERS = " \
+ ${BASELAYERS} \
+ ${BSPLAYERS} \
+ ${EXTRALAYERS} \
+ ${OEROOT}/layers/openembedded-core/meta \
+"
diff --git a/conf/ledge-qemuarm64/local.conf b/conf/ledge-qemuarm64/local.conf
new file mode 100644
index 0000000..0e8784b
--- /dev/null
+++ b/conf/ledge-qemuarm64/local.conf
@@ -0,0 +1 @@
+IMAGE_FEATURES += "debug-tweaks"
diff --git a/conf/qemuarm64-secureboot/bblayers.conf b/conf/qemuarm64-secureboot/bblayers.conf
new file mode 100644
index 0000000..e1a5414
--- /dev/null
+++ b/conf/qemuarm64-secureboot/bblayers.conf
@@ -0,0 +1,35 @@
+# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
+# changes incompatibly
+LCONF_VERSION = "7"
+OEROOT := "${@os.path.abspath(os.path.dirname(d.getVar('FILE', True)))}/../.."
+
+BBPATH = "${TOPDIR}"
+
+BBFILES = ""
+
+# These layers hold recipe metadata not found in OE-core, but lack any machine or distro content
+BASELAYERS ?= " \
+ ${OEROOT}/layers/meta-yocto/meta-poky \
+ ${OEROOT}/layers/meta-openembedded/meta-oe \
+ ${OEROOT}/layers/meta-arm/meta-arm \
+ ${OEROOT}/layers/meta-trusted-substrate \
+"
+
+# These layers hold machine specific content, aka Board Support Packages
+
+BSPLAYERS ?= " \
+ ${OEROOT}/layers/meta-arm/meta-arm-bsp \
+"
+
+# Add your overlay location to EXTRALAYERS
+# Make sure to have a conf/layers.conf in there
+EXTRALAYERS ?= " \
+ ${OEROOT}/layers/meta-arm/meta-arm-toolchain \
+"
+
+BBLAYERS = " \
+ ${BASELAYERS} \
+ ${BSPLAYERS} \
+ ${EXTRALAYERS} \
+ ${OEROOT}/layers/openembedded-core/meta \
+"
diff --git a/conf/qemuarm64-secureboot/local.conf b/conf/qemuarm64-secureboot/local.conf
new file mode 100644
index 0000000..0e8784b
--- /dev/null
+++ b/conf/qemuarm64-secureboot/local.conf
@@ -0,0 +1 @@
+IMAGE_FEATURES += "debug-tweaks"
diff --git a/default.xml b/default.xml
new file mode 100644
index 0000000..b597d1f
--- /dev/null
+++ b/default.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<manifest>
+ <remote fetch="https://github.com" name="github"/>
+ <remote fetch="https://git.yoctoproject.org/git" name="yocto"/>
+ <remote fetch="https://git.openembedded.org/" name="openembedded"/>
+ <remote fetch="https://gitlab.com" name="gitlab"/>
+ <remote fetch="https://git.linaro.org" name="linaro"/>
+ <remote fetch="https://git.linaro.org/ledge" name="linaro-ledge"/>
+
+ <project name="trusted-substrate-manifest.git" path="trusted-substrate-manifest" remote="linaro-ledge" revision="master">
+ <linkfile dest="setup-environment" src="setup-environment"/>
+ <linkfile dest="conf" src="conf"/>
+ </project>
+
+ <project name="meta-yocto" path="layers/meta-yocto" remote="yocto" revision="42bbcad8d49bb50f829c7ca47a834a1afaea8f39"/>
+ <project name="bitbake" path="bitbake" remote="openembedded" revision="5d02c98489d3a5836676b9c3fb3bd0157449db2b"/>
+ <project name="meta-openembedded" path="layers/meta-openembedded" remote="openembedded" revision="29ca52c7826ad3044b53ccb5224016bd73abdb5c"/>
+ <project name="openembedded-core" path="layers/openembedded-core" remote="openembedded" revision="147a08dced5e565f19f4987a3c199780dc00f878"/>
+ <project name="meta-arm" path="layers/meta-arm" remote="yocto" revision="e219ef606e297b98512887c96522d8d8c536bd6b"/>
+ <project name="meta-trusted-substrate" path="layers/meta-trusted-substrate" remote="linaro-ledge" revision="master"/>
+</manifest>
diff --git a/patches/0002-wic-add-UEFI-kernel-as-UEFI-stub.patch b/patches/0002-wic-add-UEFI-kernel-as-UEFI-stub.patch
new file mode 100644
index 0000000..dcdd65c
--- /dev/null
+++ b/patches/0002-wic-add-UEFI-kernel-as-UEFI-stub.patch
@@ -0,0 +1,67 @@
+From 072d6d122bdfd4be3f0b5e870e32f7822b8160b4 Mon Sep 17 00:00:00 2001
+From: Richard Purdie <richard.purdie@linuxfoundation.org>
+Date: Thu, 6 May 2021 07:12:32 -1000
+Subject: [PATCH] wic: add UEFI kernel as UEFI stub
+
+Linux kernel can be compiled as UEFI stub and loaded directly
+with UEFI firmware without grub or other UEFI shell.
+
+Tested with wic file:
+bootloader --ptable gpt --timeout=0 --append="rootwait"
+part /boot --source bootimg-efi --sourceparams="loader=kernel" \
+ --ondisk sda --fstype=vfat --label bootfs \
+ --active --align 1024 --use-uuid
+part / --source rootfs --fstype=ext4 --label rootfs \
+ --align 1024 --exclude-path boot/ --use-label
+
+Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
+---
+ scripts/lib/wic/plugins/source/bootimg-efi.py | 25 +++++++++++++++++++
+ 1 file changed, 25 insertions(+)
+
+diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
+index cdc72543c2..937e06c6e6 100644
+--- a/openembedded-core/scripts/lib/wic/plugins/source/bootimg-efi.py
++++ b/openembedded-core/scripts/lib/wic/plugins/source/bootimg-efi.py
+@@ -207,6 +207,8 @@ class BootimgEFIPlugin(SourcePlugin):
+ cls.do_configure_grubefi(hdddir, creator, cr_workdir, source_params)
+ elif source_params['loader'] == 'systemd-boot':
+ cls.do_configure_systemdboot(hdddir, creator, cr_workdir, source_params)
++ elif source_params['loader'] == 'kernel':
++ return
+ else:
+ raise WicError("unrecognized bootimg-efi loader: %s" % source_params['loader'])
+ except KeyError:
+@@ -312,6 +314,29 @@ class BootimgEFIPlugin(SourcePlugin):
+ for mod in [x for x in os.listdir(kernel_dir) if x.startswith("systemd-")]:
+ cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, mod[8:])
+ exec_cmd(cp_cmd, True)
++ elif source_params['loader'] == 'kernel':
++ kernel = get_bitbake_var("KERNEL_IMAGETYPE")
++ if not kernel:
++ raise WicError("Empty KERNEL_IMAGETYPE %s\n" % target)
++ target = get_bitbake_var("TARGET_SYS")
++ if not target:
++ raise WicError("Unknown arch (TARGET_SYS) %s\n" % target)
++
++ if re.match("x86_64", target):
++ kernel_efi_image = "bootx64.efi"
++ elif re.match('i.86', target):
++ kernel_efi_image = "bootia32.efi"
++ elif re.match('aarch64', target):
++ kernel_efi_image = "bootaa64.efi"
++ elif re.match('arm', target):
++ kernel_efi_image = "bootarm.efi"
++ else:
++ raise WicError("kernel efi is incompatible with target %s" % target)
++
++ for mod in [x for x in os.listdir(kernel_dir) if x.startswith(kernel)]:
++ cp_cmd = "cp %s/%s %s/EFI/BOOT/%s" % (kernel_dir, mod, hdddir, kernel_efi_image)
++ WicError("cp_cmd = %s" % cp_cmd);
++ exec_cmd(cp_cmd, True)
+ else:
+ raise WicError("unrecognized bootimg-efi loader: %s" %
+ source_params['loader'])
+--
+2.17.1
+
diff --git a/patches/0003-wic-bootimg-efi-implement-include-path.patch b/patches/0003-wic-bootimg-efi-implement-include-path.patch
new file mode 100644
index 0000000..e76278e
--- /dev/null
+++ b/patches/0003-wic-bootimg-efi-implement-include-path.patch
@@ -0,0 +1,32 @@
+From 9a490cad141e2a341674b847126916f4ada6fa3a Mon Sep 17 00:00:00 2001
+From: Maxim Uvarov <maxim.uvarov@linaro.org>
+Date: Mon, 20 Jan 2020 19:22:52 +0000
+Subject: [PATCH] wic: bootimg-efi: implement --include-path
+
+--include-path can be used for placing files on ESP,
+like dtbs.
+
+Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
+---
+ scripts/lib/wic/plugins/source/bootimg-efi.py | 5 +++++
+ 1 file changed, 5 insertions(+)
+
+diff --git a/scripts/lib/wic/plugins/source/bootimg-efi.py b/scripts/lib/wic/plugins/source/bootimg-efi.py
+index 937e06c6e6..b3454e1bc8 100644
+--- a/openembedded-core/scripts/lib/wic/plugins/source/bootimg-efi.py
++++ b/openembedded-core/scripts/lib/wic/plugins/source/bootimg-efi.py
+@@ -348,6 +348,11 @@ class BootimgEFIPlugin(SourcePlugin):
+ cp_cmd = "cp %s %s/" % (startup, hdddir)
+ exec_cmd(cp_cmd, True)
+
++ for paths in part.include_path or []:
++ for path in paths:
++ cp_cmd = "cp -r %s %s/" % (path, hdddir)
++ exec_cmd(cp_cmd, True)
++
+ du_cmd = "du -bks %s" % hdddir
+ out = exec_cmd(du_cmd)
+ blocks = int(out.split()[0])
+--
+2.17.1
+
diff --git a/setup-environment b/setup-environment
new file mode 100755
index 0000000..9c5cf11
--- /dev/null
+++ b/setup-environment
@@ -0,0 +1,21 @@
+#!/bin/sh
+# -*- mode: shell-script-mode; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+#
+# Copyright (C) 2012-13 O.S. Systems Software LTDA.
+# Authored-by: Otavio Salvador <otavio@ossystems.com.br>
+# Adopted to Angstrom: Khem Raj <raj.khem@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+. .repo/manifests/setup-environment-internal
diff --git a/setup-environment-internal b/setup-environment-internal
new file mode 100644
index 0000000..61b4c51
--- /dev/null
+++ b/setup-environment-internal
@@ -0,0 +1,362 @@
+#!/bin/bash
+# -*- mode: shell-script-mode; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
+#
+# Copyright (C) 2012-13 O.S. Systems Software LTDA.
+# Authored-by: Otavio Salvador <otavio@ossystems.com.br>
+# Adopted to Angstrom: Khem Raj <raj.khem@gmail.com>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2 as
+# published by the Free Software Foundation.
+#
+# 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, write to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+#
+RPBcleanup() {
+ unset MACHINETABLE MACHLAYERS DISTROTABLE DISTROLAYERS DISTRO_DIRNAME OEROOT
+ unset ITEM MANIFESTS EULA EULA_MACHINE REPLY READ_EULA
+ unset usage oldmach
+
+ if [ -n "$BUILDDIR" ]; then
+ export BUILDDIR
+ fi
+}
+trap RPBcleanup RETURN
+
+if [ "$(whoami)" = "root" ]; then
+ echo "ERROR: do not use the BSP as root. Exiting..."
+ return
+fi
+
+OEROOT=$(pwd)
+cd "$OEROOT"
+if [ -n "$ZSH_VERSION" ]; then
+ setopt sh_word_split
+ setopt clobber
+elif [ -n "$BASH_VERSION" ]; then
+ set +o noclobber
+fi
+
+usage () {
+ cat <<EOF
+
+Usage: [DISTRO=<DISTRO>] [MACHINE=<MACHINE>] source ${BASH_SOURCE[0]} [BUILDDIR]
+
+If no MACHINE is set, list all possible machines, and ask user to choose.
+If no DISTRO is set, list all possible distros, and ask user to choose.
+If no BUILDIR is set, it will be set to build-DISTRO.
+
+EOF
+}
+
+if [ $# -gt 1 ]; then
+ usage
+ return 1
+fi
+# create a common list of "<machine>(<layer>)", sorted by <machine>
+# Blacklist OE-core and meta-linaro, we only want 96boards + vendor layers
+MACHLAYERS=$(find layers -print | grep "conf/machine/.*\.conf" | grep -v scripts | grep -v openembedded-core | grep -v meta-linaro | sed -e 's/\.conf//g' -e 's/layers\///' | awk -F'/conf/machine/' '{print $NF "(" $1 ")"}' | LANG=C sort)
+
+if [ -z "${MACHINE}" ]; then
+ # whiptail
+ which whiptail > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ MACHINETABLE=
+ for ITEM in $MACHLAYERS; do
+ MACHINETABLE="${MACHINETABLE} $(echo "$ITEM" | cut -d'(' -f1) $(echo "$ITEM" | cut -d'(' -f2 | cut -d')' -f1)"
+ done
+ MACHINE=$(whiptail --title "Available Machines" --menu \
+ "Please choose a machine" 0 0 20 \
+ ${MACHINETABLE} 3>&1 1>&2 2>&3)
+ fi
+
+ # dialog
+ if [ -z "$MACHINE" ]; then
+ which dialog > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ MACHINETABLE=
+ for ITEM in $MACHLAYERS; do
+ MACHINETABLE="$MACHINETABLE $(echo "$ITEM" | cut -d'(' -f1) $(echo "$ITEM" | cut -d'(' -f2 | cut -d')' -f1)"
+ done
+ MACHINE=$(dialog --title "Available Machines" --menu "Please choose a machine" 0 0 20 $MACHINETABLE 3>&1 1>&2 2>&3)
+ fi
+ fi
+fi
+
+# create a common list of "<distro>(<layer>)", sorted by <distro>
+# Blacklist OE-core and meta-linaro, we only want 96boards + vendor layers
+DISTROLAYERS=$(find layers -print | grep "conf/distro/.*\.conf" | grep -v scripts | grep -v openembedded-core | grep -v meta-linaro | sed -e 's/\.conf//g' -e 's/layers\///' | awk -F'/conf/distro/' '{print $NF "(" $1 ")"}' | LANG=C sort)
+
+if [ -n "${DISTROLAYERS}" ] && [ -z "${DISTRO}" ]; then
+ # whiptail
+ which whiptail > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ DISTROTABLE=
+ for ITEM in $DISTROLAYERS; do
+ DISTROTABLE="${DISTROTABLE} $(echo "$ITEM" | cut -d'(' -f1) $(echo "$ITEM" | cut -d'(' -f2 | cut -d')' -f1)"
+ done
+ DISTRO=$(whiptail --title "Available Distributions" --menu \
+ "Please choose a distribution" 0 0 20 \
+ ${DISTROTABLE} 3>&1 1>&2 2>&3)
+ fi
+
+ # dialog
+ if [ -z "$DISTRO" ]; then
+ which dialog > /dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ DISTROTABLE=
+ for ITEM in $DISTROLAYERS; do
+ DISTROTABLE="$DISTROTABLE $(echo "$ITEM" | cut -d'(' -f1) $(echo "$ITEM" | cut -d'(' -f2 | cut -d')' -f1)"
+ done
+ DISTRO=$(dialog --title "Available Distributions" --menu "Please choose a distribution" 0 0 20 $DISTROTABLE 3>&1 1>&2 2>&3)
+ fi
+ fi
+fi
+
+# If nothing has been set, go for 'nodistro'
+if [ -z "$DISTRO" ]; then
+ DISTRO="nodistro"
+fi
+
+# guard against Ctrl-D or cancel
+if [ -z "$MACHINE" ]; then
+ echo "To choose a machine interactively please install whiptail or dialog."
+ echo "To choose a machine non-interactively please use the following syntax:"
+ echo " MACHINE=<your-machine> . ./setup-environment"
+ echo ""
+ echo "Press <ENTER> to see a list of your choices"
+ read -r
+ echo "$MACHLAYERS" | sed -e 's/(/ (/g' | sed -e 's/)/)\n/g' | sed -e 's/^ */\t/g'
+ return
+fi
+
+if [ -z "${SDKMACHINE}" ]; then
+ SDKMACHINE='x86_64'
+fi
+
+MANIFESTS="${OEROOT}"/.repo/manifests
+
+# we can be called with only 1 parameter max, <build> folder, or default to build-$distro
+BUILDDIR=build-$DISTRO
+if [ $# -eq 1 ]; then
+ BUILDDIR=$1
+fi
+BUILDDIR=$OEROOT/$BUILDDIR
+
+# Clean up PATH, because if it includes tokens to current directories somehow,
+# wrong binaries can be used instead of the expected ones during task execution
+export PATH=$(echo "${PATH}" | sed 's/\(:.\|:\)*:/:/g;s/^.\?://;s/:.\?$//')
+export PATH="${OEROOT}"/layers/openembedded-core/scripts:"${OEROOT}"/bitbake/bin:"${OEROOT}"/.repo/repo:"${PATH}"
+#remove duplicate path entries
+export PATH=$(echo "$PATH" | awk -F: '{for (i=1;i<=NF;i++) { if ( !x[$i]++ ) printf("%s:",$i); }}' | sed 's/:$//')
+# Make sure Bitbake doesn't filter out the following variables from our
+# environment.
+export BB_ENV_EXTRAWHITE="MACHINE DISTRO TCLIBC TCMODE GIT_PROXY_COMMAND http_proxy ftp_proxy https_proxy all_proxy ALL_PROXY no_proxy SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY SDKMACHINE BB_NUMBER_THREADS"
+
+# Helper command for building images for mixed 32bit/64bit
+# ARM builds. The command allow to specify a secondary MACHINE
+# and image that will be built next to the primary target.
+# If no secondary image is specified the rpb-minimal-image image
+# will be built.
+
+
+bitbake_secondary_image () {
+ BITBAKE_OPTIONS=""
+ unset EXTRA_MACHINE
+ unset SECONDARY_IMAGE
+
+ SECONDARY_IMAGE='rpb-minimal-image'
+ while [[ $# -gt 1 ]]
+ do
+ key="$1"
+ case $key in
+ --extra-machine)
+ EXTRA_MACHINE="$2"
+ shift
+ ;;
+ --secondary-image)
+ SECONDARY_IMAGE="$2"
+ shift
+ ;;
+ *)
+ BITBAKE_OPTIONS=$BITBAKE_OPTIONS" "$1
+ ;;
+ esac
+ shift
+ done
+ BITBAKE_OPTIONS=$BITBAKE_OPTIONS" "$1
+ if [ -z "$EXTRA_MACHINE" ]
+ then
+ echo " Error: you need to run $FUNCNAME with --extra-machine agument"
+ echo
+ echo " Example:"
+ echo " $ $FUNCNAME --extra-machine hikey rpb-weston-image"
+ return
+ fi
+
+ if [ "$EXTRA_MACHINE" == "$MACHINE" ]
+ then
+ echo "Error: the extra machine must be different from the machine you already set using setup-environment: "$MACHINE
+ return
+ fi
+
+ echo "Building first image. MACHINE:" $EXTRA_MACHINE " DISTRO:" $DISTRO
+
+ MACHINE=$EXTRA_MACHINE bitbake $SECONDARY_IMAGE
+
+ if [ $? != 0 ]; then
+ printf "Error building image"
+ return
+ fi
+ echo "Building second image. MACHINE:" $MACHINE " DISTRO:" $DISTRO
+
+ MACHINE=$MACHINE bitbake $BITBAKE_OPTIONS
+}
+mkdir -p "${BUILDDIR}"/conf && cd "${BUILDDIR}"
+if [ -f "conf/auto.conf" ]; then
+ oldmach=$(egrep "^MACHINE" "conf/auto.conf" | sed -e 's%^MACHINE ?= %%' | sed -e 's/^"//' -e 's/"$//')
+fi
+if [ -e conf/checksum -a "${MACHINE}" = "$oldmach" ]
+then
+ sha512sum --quiet -c conf/checksum > /dev/null 2>&1
+ if [ $? -eq 0 ]
+ then
+ return
+ fi
+fi
+
+# evaluate new checksum and regenerate the conf files
+sha512sum "${OEROOT}"/conf/setup-environment-internal 2>&1 > conf/checksum
+
+ln -sf "${OEROOT}"/conf/${MACHINE}/local.conf conf/local.conf
+ln -sf "${OEROOT}"/conf/${MACHINE}/bblayers.conf conf/bblayers.conf
+ln -sf "${MANIFESTS}"/README.md README.md
+
+ln -sf "${MANIFESTS}" "${OEROOT}"/layers/
+
+DISTRO_DIRNAME=$(echo "${DISTRO}" | sed 's#[.-]#_#g')
+
+cat > conf/auto.conf <<EOF
+DISTRO ?= "${DISTRO}"
+MACHINE ?= "${MACHINE}"
+SDKMACHINE ?= "${SDKMACHINE}"
+
+# Extra options that can be changed by the user
+INHERIT += "rm_work"
+EOF
+
+# If a machine provides some additional configuration, append it to auto.conf
+# to allow the user to change it in local.conf
+if [ -f "${OEROOT}/conf/${MACHINE}/local.conf" ]; then
+ cat "${OEROOT}/conf/${MACHINE}/local.conf" >> conf/auto.conf
+fi
+
+if [ ! -e conf/site.conf ]; then
+ cat > conf/site.conf <<_EOF
+
+SCONF_VERSION = "1"
+
+# Where to store sources
+DL_DIR ?= "${OEROOT}/downloads"
+
+# Where to save shared state
+SSTATE_DIR ?= "${OEROOT}/sstate-cache"
+
+TMPDIR = "${BUILDDIR}/tmp-${DISTRO_DIRNAME}"
+
+# Go through the Firewall
+#HTTP_PROXY = "http://${PROXYHOST}:${PROXYPORT}/"
+
+_EOF
+fi
+
+# Handle EULA , if needed. This is a generic method to handle BSPs
+# that might (or not) come with a EULA. If a machine has a EULA, we
+# assume that its corresponding layers has conf/EULA/$MACHINE file
+# with the EULA text, which we will display to the user and request
+# for acceptance. If accepted, the variable ACCEPT_EULA_$MACHINE is
+# set to 1 in auto.conf, which can later be used by the BSP.
+# If the env variable EULA_$MACHINE is set it is used by default,
+# without prompting the user.
+# FIXME: there is a potential issue if the same $MACHINE is set in more than one layer.. but we should assert that earlier
+EULA=$(find ../layers -path "*/conf/eula/$MACHINE" -print | grep -v scripts | grep -v openembedded-core | grep -v meta-linaro || true)
+
+if [ -n "$EULA" ]; then
+
+ # remove '-' since we are constructing a bash variable name here
+ EULA_MACHINE="EULA_$(echo "$MACHINE" | sed 's/-//g')"
+
+ # NOTE: indirect reference / dynamic variable
+ if [ -n "${!EULA_MACHINE}" ]; then
+ # the EULA_$MACHINE variable is set in the environment, so we just configure
+ # ACCEPT_EULA_$MACHINE in auto.conf
+ echo "ACCEPT_EULA_$MACHINE = \"${!EULA_MACHINE}\"" >> conf/auto.conf
+ else
+ # so we need to ask user if he/she accepts the EULA:
+ cat <<EOF
+
+The BSP for $MACHINE depends on packages and firmware which are covered by an End
+User License Agreement (EULA). To have the right to use these binaries
+in your images, you need to read and accept the following...
+
+EOF
+
+ echo
+ REPLY=
+ while [ -z "$REPLY" ]; do
+ echo -n "Would you like to read the EULA ? (y/n) "
+ read -r REPLY
+ case "$REPLY" in
+ y|Y)
+ READ_EULA=1
+ ;;
+ n|N)
+ READ_EULA=0
+ ;;
+ *)
+ REPLY=
+ ;;
+ esac
+ done
+
+ if [ "$READ_EULA" = 1 ]; then
+ more -d "${EULA}"
+ echo
+ REPLY=
+ while [ -z "$REPLY" ]; do
+ echo -n "Do you accept the EULA you just read? (y/n) "
+ read -r REPLY
+ case "$REPLY" in
+ y|Y)
+ echo "EULA has been accepted."
+ echo "ACCEPT_EULA_$MACHINE = \"1\"" >> conf/auto.conf
+ ;;
+ n|N)
+ echo "EULA has not been accepted."
+ ;;
+ *)
+ REPLY=
+ ;;
+ esac
+ done
+ fi
+ fi
+fi
+
+cat <<EOF
+
+Your build environment has been configured with:
+
+ MACHINE = ${MACHINE}
+ SDKMACHINE = ${SDKMACHINE}
+ DISTRO = ${DISTRO}
+
+You can now run 'bitbake <target>'
+
+EOF