From 040dbf85c707a6e8c7da2396dd5377c28ad7a499 Mon Sep 17 00:00:00 2001 From: Adrian Dudau Date: Thu, 12 Dec 2013 13:50:35 +0100 Subject: add enea init script to poky folder Signed-off-by: Adrian Dudau --- enea-init-build-env | 187 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 187 insertions(+) create mode 100755 enea-init-build-env diff --git a/enea-init-build-env b/enea-init-build-env new file mode 100755 index 0000000000..2e53f8e69f --- /dev/null +++ b/enea-init-build-env @@ -0,0 +1,187 @@ +#!/bin/bash +if [ "$_" = "$0" ]; then + echo "Error: This script needs to be sourced." + echo "Please run as 'source $0'." + exit +fi + +# always unset these in case something goes wrong in the previous run +unset OPTERR OPTIND OPTION MACHINE EXITME SSTATE_DIR DOWNLOAD_DLDIR METALAYERS +unset DOWNLOAD_MIRRORS LOCAL_CONF_EXISTS BBLAYERS_CONF_EXISTS + +NUM_CORES=$(grep -c processor /proc/cpuinfo || echo 2) +BUILD_PATH="build" +METALAYERS="meta-enea" + +function usage() { +cat < + Build dir + default: build + + -g + download mirror e.g., file:///media/downloads + default: http://linux.enea.com + + -j + Number of cores to use in build. + default: all + + -k + Shared local sstate cache, type -k /sstate + if you want to use private sstate cache. + + -l + List of meta-layers, e.g., -l meta-fsl-ppc,meta-enea-lwrt + default: none + + -m + Machine name (required) + + -h + Help - this text +EOF +} + +DOWNLOAD_MIRRORS='http://linux.enea.com/${DISTRO_VERSION}/sources/' +SSTATE_MIRRORS='http://linux.enea.com/${DISTRO_VERSION}/sstate-cache/PATH' + +while getopts ":hb:d:f:g:j:k:l:m:t:" OPTION; do + case $OPTION in + b) + BUILD_PATH=$OPTARG + ;; + d) + # set DL_DIR. be careful when using this, as it's easy to + # introduce isseues if this dir is shared + DOWNLOAD_DLDIR=$(readlink -m $OPTARG) + ;; + g) + DOWNLOAD_MIRRORS=$OPTARG + ;; + j) + NUM_CORES=$OPTARG + ;; + k) + SSTATE_DIR=$(readlink -m $OPTARG) + ;; + l) + METALAYERS="$METALAYERS,$OPTARG" + ;; + m) + MACHINE=$OPTARG + ;; + h) + usage + EXITME=1 + ;; + \?) + echo "Unknown option '-$OPTARG'" + usage + EXITME=1 + ;; + esac +done + +ENEAROOT="$(pwd)" +ENEAROOT=$(readlink -f "$ENEAROOT") + +if [[ ! -d $SSTATE_DIR && ! -z $SSTATE_DIR ]]; then + mkdir -p $SSTATE_DIR + if [[ $? -ne 0 ]]; then + echo "Error: Unable to create directory $SSTATE_DIR. Do you have permissions?" + EXITME=1 + fi +fi +if [[ ! -d $DOWNLOAD_DLDIR && ! -z $DOWNLOAD_DLDIR ]]; then + mkdir -p $DOWNLOAD_DLDIR + if [[ $? -ne 0 ]]; then + echo "Error: Unable to create directory $DOWNLOAD_DLDIR. Do you have permissions?" + EXITME=1 + fi +fi + +if [[ -n $EXITME ]]; then + echo +elif [[ -z $BASH_VERSINFO ]]; then + echo "This script requires bash." +elif [ "$MACHINE"x = "x" -a ! -r "$BUILD_PATH/conf/local.conf" ]; then +cat <> conf/local.conf + echo "*** Info: Setting SSTATE_MIRRORS to http://linux.enea.com" + + if [[ -n $SSTATE_DIR ]]; then + sed -i -e "s|^#SSTATE_DIR ?=.*|SSTATE_DIR ?= \"$SSTATE_DIR\"|" conf/local.conf + echo "*** Info: Setting SSTATE_DIR to $SSTATE_DIR" + fi + + sed -i -e 's|^PACKAGE_CLASSES ?= "package_rpm"|PACKAGE_CLASSES ?= "package_ipk"|' conf/local.conf + echo "*** Info: Setting PACKAGE_CLASSES to ipk" + + echo "SOURCE_MIRROR_URL ?= \"$DOWNLOAD_MIRRORS\"" >> conf/local.conf + echo "INHERIT += \"own-mirrors\"" >> conf/local.conf + echo "*** Info: Setting SOURCE_MIRROR_URL to http://linux.enea.com" + + if [[ -n $DOWNLOAD_DLDIR ]]; then + sed -i -e "s|^#DL_DIR ?=.*|DL_DIR ?= \"$DOWNLOAD_DLDIR\"|" conf/local.conf + echo "*** Info: Setting DL_DIR to $DOWNLOAD_DLDIR" + fi + else + echo "You already had conf/local.conf file, no modification is done." + fi + + if [[ -n $BBLAYERS_CONF_EXISTS ]]; then + if [[ ""x != "${METALAYERS}"x ]]; then + for layer in $(echo $METALAYERS | tr ',' ' '); do + layer=$ENEAROOT/$layer + if [[ ! -d $layer ]]; then + echo "*** Error: There is no meta-layer called: $layer" + else + egrep "$layer " conf/bblayers.conf >/dev/null || + sed -i -e '/.*meta-yocto .*/i\'" $layer \\\\" conf/bblayers.conf + echo "*** Info: Adding $layer to bblayers.conf" + fi + done + fi + else + echo "You already had conf/bblayers.conf file, no modification is done." + fi +fi + +unset OPTERR OPTIND OPTION MACHINE EXITME SSTATE_DIR DOWNLOAD_DLDIR METALAYERS +unset DOWNLOAD_MIRRORS LOCAL_CONF_EXISTS BBLAYERS_CONF_EXISTS SSTATE_MIRRORS -- cgit v1.2.3-54-g00ecf