#!/bin/bash ###################################################### # Make sure script has been sourced # if [ "$0" = "$BASH_SOURCE" ]; then echo "####################################" echo " ERROR : YOU MUST SOURCE THE SCRIPT" echo "####################################" exit 1 fi BUILD_DIR=$1 # Init env var ROOT_DIR=`realpath $PWD` META_DIR="meta-kineintercom" if [ "a${DL_DIR}" = "a" ]; then DL_DIR="$ROOT_DIR/oe-downloads" fi if [ "a${SSTATE_DIR}" = "a" ]; then SSTATE_DIR="$ROOT_DIR/sstate-cache" fi # Use utf-8 encoding if ! echo $LANG | grep -q "en_US.UTF-8" then export LANG="en_US.UTF-8" fi if [ "a${DISTRO}" = "a" ]; then DISTRO="kineintercom" fi if [ "a${MACHINE}" = "a" ]; then MACHINE="raspberrypi" fi _TEMPLATECONF="${ROOT_DIR}/${META_DIR}/conf/template/" ###################################################### # Standard Openembedded init # echo -e "[source ${ROOT_DIR}/poky/oe-init-build-env]" TEMPLATECONF=${_TEMPLATECONF} source ${ROOT_DIR}/poky/oe-init-build-env ${BUILD_DIR} > /dev/null 2> /dev/null _FORMAT_PATTERN='::-::' ###################################################### # Choose target machine # conf_machine() { local choices=$(find ${ROOT_DIR}/${META_DIR}/conf/machine -name "*.conf" 2>/dev/null | sort | uniq) for ITEM in $choices do if [[ -z $(grep "#@DESCRIPTION" $ITEM) ]]; then echo "" echo "ERROR: No '#@DESCRIPTION' field available in $__CONFIG file:" echo "$ITEM" echo "" return 1 fi done unset ITEM if [ $(echo $choices | wc -l) -eq 1 ]; then # return only file name (distro or machine) echo "$(echo $choices | sed 's|^.*/\(.ยต\)\.conf|\1|')" else echo "$(echo $choices | xargs grep "#@DESCRIPTION" | sed 's|^.*/\(.*\)\.conf:#DESCRIPTION:[ \t]*\(.*$\)|\1'"${_FORMAT_PATTERN}"'\2|')" fi } ###################################################### # Apply configuration to site.conf file # conf_siteconf() { _NCPU=$(grep '^processor' /proc/cpuinfo 2>/dev/null | wc -l) # Sanity check that we have a valid number, if not then fallback to a safe default [ "$_NCPU" -ge 1 ] 2>/dev/null || _NCPU=2 cat > conf/site.conf < !!!! [WARNING] site.conf already exists. Nothing done ... !!!!" else conf_siteconf fi update_layerconf ${ROOT_DIR}/${META_DIR} list_images ${META_DIR}