aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/setup-mel-builddir
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/setup-mel-builddir')
-rwxr-xr-xscripts/setup-mel-builddir388
1 files changed, 0 insertions, 388 deletions
diff --git a/scripts/setup-mel-builddir b/scripts/setup-mel-builddir
deleted file mode 100755
index 5c394533..00000000
--- a/scripts/setup-mel-builddir
+++ /dev/null
@@ -1,388 +0,0 @@
-#!/bin/sh
-#
-# ---------------------------------------------------------------------------------------------------------------------
-# SPDX-License-Identifier: GPL-2.0
-# ---------------------------------------------------------------------------------------------------------------------
-#
-# Copyright 2022 Siemens
-#
-# This file is licensed under the terms of the GNU General Public License
-# version 2. This program is licensed "as is" without any warranty of any
-# kind, whether express or implied.
-
-DISTRO="${DISTRO:-mel}"
-CORELAYERS="${CORELAYERS:-}"
-OPTIONALLAYERS="${OPTIONALLAYERS-}"
-EXTRAMELLAYERS="${EXTRAMELLAYERS-}"
-layer_priority_overrides="openembedded-layer=1"
-
-
-usage () {
- cat >&2 <<END
-Usage: $0 [OPTIONS...] [MACHINE]
-
-When operating from a MEL install, this script will use the template config
-files from the installed BSP. If multiple BSPs are installed, you must specify
-MACHINE, and the script will use the templates from that BSP.
-
-When no installed BSP is available, MACHINE is required, and this script will
-set up the build directory with a base set of layers + all layers which
-include the machine .conf file for this machine, sorted by layer recipe
-priority.
-
-If the build directory already exists and is configured, you can leave MACHINE
-unspecified, and the script will set you up for that build directory without
-changing its configuration.
-
-All layers whose directory name is update-* or meta-mentor-cve, at toplevel or
-a subdir, of the parent of meta-mentor, will be automatically included, as
-a mechanism for delivering sets of updates for releases.
-
-Options:
-
- -b BUILDDIR Specify the build directory to create (default: 'build')
- -o MELDIR Specify the root of the MEL install, where you can find bitbake
- and the layers
- -p PATHS Specify colon separated list of paths, where you can find layers
- in addition to the root of the MEL install (default: empty).
- If any path in this list contains wildcards, the list must be quoted
- to avoid wildcard substitution by the shell
- -l LAYERS Space-separated list of layer names for additional layers you
- want to be included in the configuration. This argument is
- cumulative. Both '-l "meta-foo meta-bar"' and
- '-l meta-foo -l meta-bar' are valid and include both layers.
- -f Force overwrite of existing configuration files in the build
- directory. This includes local.conf and bblayers.conf, but not
- site.conf
- -h Show this usage information
-
-END
-}
-
-prompt_choice () {
- non_interactive=0
- while getopts n opt; do
- case "$opt" in
- n)
- non_interactive=1
- ;;
- esac
- done
- shift $(expr $OPTIND - 1)
-
- prompt_message="$1"
- prompt_default="${2:-}"
-
- prompt_options="$tmpdir/prompt-choice"
- cat >"$prompt_options"
-
- prompt_count="$(wc -l <"$prompt_options")"
- case $prompt_count in
- 0)
- # No choices provided
- return 1
- ;;
- 1)
- # Only one choice
- cat "$prompt_options"
- return 0
- ;;
- esac
-
- if [ $non_interactive -eq 1 ]; then
- printf >&2 'Error: unable to prompt for `%s` interactively\n' "$prompt_message"
- return 1
- fi
-
- while [ -z "$prompt_value" ]; do
- prompt_num=0
- while read choice; do
- prompt_num=$(expr $prompt_num + 1)
- eval prompt_value_${prompt_num}="$choice"
- printf >&2 "%s) %s\n" "$prompt_num" "$choice"
- done <"$prompt_options"
- printf >&2 "%s: " "$prompt_message"
- read selection </dev/tty
- prompt_value="$(eval echo \${prompt_value_$selection})"
- done
- printf "%s\n" "$prompt_value"
-}
-
-abspath () {
- readlink -f "$1"
-}
-
-configure_builddir () {
- if [ -n "$EXCLUDEDLAYERS" ]; then
- set -- "$@" -x "$EXCLUDEDLAYERS"
- fi
- if [ "$verbose" -eq 1 ]; then
- set -- "$@" -v
- fi
-
-
- sed -i -e"s/^#*MACHINE *?*=.*/MACHINE ??= \"$MACHINE\"/" $BUILDDIR/conf/local.conf
- sed -n -i -e "s|##COREBASE##|$OEROOT|g" -e '/^BBLAYERS /{ :start; /\\$/{n; b start}; d; }; p' -e "/BBFILE_PRIORITY/d" $BUILDDIR/conf/bblayers.conf
-
- echo 'BBLAYERS ?= "\' >> $BUILDDIR/conf/bblayers.conf
- layersfile="$tmpdir/layers"
-
- # Convert layer paths to layer names for bb-determine-layers
- extralayernames=
- for layer in $extralayers; do
- if [ -d "$layer" ]; then
- layerpaths="$layerpaths:$layer"
- layer="$(PATH="$OEROOT/scripts:$OEROOT/bitbake/bin:$PATH" $(dirname "$0")/bb-print-layer-data 2>/dev/null "$layer" | cut -d: -f1)"
- fi
- extralayernames="$extralayernames $layer"
- done
-
- updatelayernames=
- for layer in $updatelayers; do
- if [ -d "$layer" ]; then
- layer="$(PATH="$OEROOT/scripts:$OEROOT/bitbake/bin:$PATH" $(dirname "$0")/bb-print-layer-data 2>/dev/null "$layer" | cut -d: -f1)"
- layerpaths="$layerpaths:$layer"
- fi
- updatelayernames="$updatelayernames $layer"
- done
-
- $layerdir/scripts/bb-determine-layers -g "$layerpaths" -l "$CORELAYERS $extralayernames" -o "$EXTRAMELLAYERS $OPTIONALLAYERS" -e "$updatelayernames" -O "$layer_priority_overrides" -m "$MACHINE" -d "$DISTRO" "$@" >$layersfile
- if [ $? -ne 0 ]; then
- echo >&2 "Error in execution of bb-determine-layers, aborting"
- return 1
- fi
- sed -e "s#^$BUILDDIR/#\${TOPDIR}/#g;" -e 's,^, ,; s,$, \\,' <$layersfile >>$BUILDDIR/conf/bblayers.conf
- echo '"' >> $BUILDDIR/conf/bblayers.conf
- configured_layers="$(PATH="$OEROOT/scripts:$BITBAKEDIR/bin:$PATH" $(dirname "$0")/bb-print-layer-data $(cat $layersfile) 2>/dev/null | cut -d: -f1 | xargs)"
-
- echo "$layer_priority_overrides" | tr " " "\n" | \
- while IFS== read -r layer priority; do
- case " $configured_layers " in
- *\ $layer\ *)
- printf 'BBFILE_PRIORITY_%s_%s = "%d"\n' "$layer" "$DISTRO" "$priority" >> $BUILDDIR/conf/bblayers.conf
- ;;
- esac
- done
-}
-
-process_arguments () {
- BUILDDIR=
- MELDIR=
- OEROOT=
- extrasearchpaths=
- extralayers=
- force_overwrite=0
- verbose=0
- while getopts b:o:p:l:fvh opt; do
- case "$opt" in
- b)
- BUILDDIR="$(abspath $OPTARG)"
- ;;
- o)
- MELDIR="$(abspath $OPTARG)"
- ;;
- p)
- extrasearchpaths="$OPTARG"
- ;;
- l)
- extralayers="$extralayers $OPTARG"
- ;;
- f)
- force_overwrite=1
- ;;
- v)
- verbose=1
- ;;
- \?|h)
- usage
- return 1
- ;;
- esac
- done
-
- if [ -z $BUILDDIR ]; then
- if [ -f conf/local.conf -o -f conf/bblayers.conf ]; then
- # Assuming we're already in the build dir
- BUILDDIR=$PWD
- else
- BUILDDIR=$PWD/build
- fi
- fi
-
- if [ -z "$MELDIR" ]; then
- MELDIR=$(dirname $layerdir)
- fi
-
- updatelayers=
- for lconf in $MELDIR/update-*/conf/layer.conf \
- $MELDIR/*/update-*/conf/layer.conf \
- $MELDIR/meta-mentor-cve/conf/layer.conf; do
- updatelayer="${lconf%/conf/layer.conf}"
- if [ -e "$updatelayer" ]; then
- updatelayers="$updatelayers $updatelayer"
- fi
- done
-
- layerpaths="*:*/*:meta*/*/*:$MELDIR/*:$MELDIR/*/*:$MELDIR/meta*/*/*${extrasearchpaths:+:}$extrasearchpaths"
-}
-
-setup_builddir () {
- process_arguments "$@" || return $?
- shift $(expr $OPTIND - 1)
-
- OEROOT="$($layerdir/scripts/bb-determine-layers -g "$layerpaths" -l core 2>/dev/null)/.." || {
- echo >&2 "Error: unable to locate core layer (oe-core) in $MELDIR, aborting"
- return 3
- }
-
- if [ $# -gt 0 ]; then
- MACHINE="$1"
- fi
-
- if [ -z "$MACHINE" ]; then
- if [ -e "$MELDIR/.machine" ]; then
- MACHINE="$(cat "$MELDIR/.machine")"
- elif [ -e "$BUILDDIR/conf/local.conf" ]; then
- MACHINE=$(sed -n 's/^MACHINE ?*= "\([^"]*\)"/\1/p' $BUILDDIR/conf/local.conf)
- fi
- fi
-
- if [ -n "$MACHINE" ]; then
- if [ -e $MELDIR/$MACHINE/binary ]; then
- # User specified machine and we have the binary content for this BSP
- TEMPLATECONF=$MELDIR/$MACHINE/conf
- fi
- else
- if [ ! -e $BUILDDIR/conf/local.conf -o ! -e $BUILDDIR/conf/bblayers.conf ] || [ -z "$MACHINE" ]; then
- if ! [ -t 1 ] || ! [ -t 0 ]; then
- non_interactive=-n
- else
- non_interactive=
- fi
- ls -1d $MELDIR/*/binary 2>/dev/null | sed "s,^$MELDIR/,,; s,/binary$,," | \
- while read machine; do
- if [ ! -e "$MELDIR/$machine/conf/local.conf.sample" ]; then
- continue
- fi
- echo "$machine"
- done | prompt_choice $non_interactive "Select BSP to use" >$tmpdir/machine || {
- echo >&2 "Error: unable to prompt for an installed MEL BSP, please specify MACHINE"
- return 1
- }
- MACHINE="$(cat "$tmpdir/machine")"
- if [ -z "$MACHINE" ]; then
- echo >&2 "Error: unable to locate installed MEL BSP, please specify MACHINE"
- return 1
- else
- TEMPLATECONF=$MELDIR/$MACHINE/conf
- fi
- fi
- fi
-
- # Pick up qemu layers from meta-mentor-bsp as we do
- # not create separate machines for them
- case ${MACHINE} in
- qemu*)
- OPTIONALLAYERS="$OPTIONALLAYERS mentor-bsp-$MACHINE"
- ;;
- esac
-
-
- if [ $force_overwrite -eq 1 ]; then
- rm -f $BUILDDIR/conf/local.conf $BUILDDIR/conf/bblayers.conf
- fi
-
- if [ -d "$BUILDDIR" ]; then
- existing_builddir=1
- else
- existing_builddir=0
- fi
-
- mkdir -p $BUILDDIR/conf
-
- if [ -z "$TEMPLATECONF" ]; then
- if [ -f "$BUILDDIR/conf/templateconf.cfg" ]; then
- TEMPLATECONF="$(cat "$BUILDDIR/conf/templateconf.cfg")"
- elif [ -e "$layerdir/conf/local.conf.sample" ]; then
- TEMPLATECONF="$layerdir/conf"
- elif [ -e "$OEROOT/.templateconf" ]; then
- . "$OEROOT/.templateconf"
- # Convert to absolute path
- TEMPLATECONF="$(cd "$(dirname "$TEMPLATECONF")" && pwd -P)/$(basename "$TEMPLATECONF")"
- else
- echo >&2 "Unable to determine TEMPLATECONF"
- return 1
- fi
- fi
-
- if [ ! -f "$BUILDDIR/conf/templateconf.cfg" ]; then
- echo "$TEMPLATECONF" >"$BUILDDIR/conf/templateconf.cfg"
- fi
-
- if [ ! -e $BUILDDIR/conf/local.conf ]; then
- cp $TEMPLATECONF/local.conf.sample $BUILDDIR/conf/local.conf
- echo "You had no local.conf file. This configuration file has therefore been"
- echo "created for you with some default values."
-
- if [ -h "$MELDIR/toolchains" ]; then
- toolchains_path="$MELDIR/toolchains"
- sedexpr='${MELDIR}/toolchains'
- else
- toolchains_path="$MELDIR/../../toolchains"
- sedexpr='${MELDIR}/../../toolchains'
- fi
- if [ -d "$toolchains_path" ]; then
- sed -i -e "s,^#\?EXTERNAL_TOOLCHAIN.*,TOOLCHAINS_PATH ?= \"$toolchains_path\"," "$BUILDDIR/conf/local.conf"
- fi
- else
- if [ -n "$MACHINE" ]; then
- echo "Configuring existing local.conf for $MACHINE"
- fi
- fi
-
- if [ ! -e $BUILDDIR/conf/bblayers.conf ]; then
- echo "MELDIR = \"$MELDIR\"" >$BUILDDIR/conf/bblayers.conf
- echo >>$BUILDDIR/conf/bblayers.conf
- cat $TEMPLATECONF/bblayers.conf.sample >>$BUILDDIR/conf/bblayers.conf
- echo "You had no bblayers.conf file. This configuration file has therefore been"
- echo "created for you with some default values."
- else
- if [ -n "$MACHINE" ]; then
- echo "Configuring existing bblayers.conf for $MACHINE"
- fi
- fi
-
- if [ -d "$MELDIR/bitbake" ]; then
- BITBAKEDIR="$MELDIR/bitbake"
- else
- BITBAKEDIR="$OEROOT/bitbake"
- fi
-
- if [ -e "$layerdir/pre-setup.$MACHINE" ]; then
- . "$layerdir/pre-setup.$MACHINE"
- fi
- PATH="$OEROOT/scripts:$BITBAKEDIR/bin:$PATH" configure_builddir || return $?
-
- cat "$scriptsdir/build-setup-environment.in" \
- | sed -e "s#@OEROOT@#$OEROOT#g" \
- -e "s#@BITBAKEDIR@#$BITBAKEDIR#g" \
- -e "s#@TEMPLATECONF@#$TEMPLATECONF#g" >"$BUILDDIR/setup-environment"
-}
-
-scriptsdir="$(cd $(dirname $0) && pwd)"
-scriptsdir="$(abspath $scriptsdir)"
-layerdir="${scriptsdir%/*}"
-
-tmpdir="$(mktemp -d -t "${0##*/}.XXXXX")" || exit 1
-trap 'rm -rf "$tmpdir"' EXIT INT TERM
-
-setup_builddir "$@" || {
- if [ "$existing_builddir" = 0 ]; then
- rm -rf "$BUILDDIR"
- fi
- exit $?
-}
-if [ -e $BUILDDIR/conf/local.conf ]; then
- sed -i -e "s/^DISTRO.*/DISTRO = \'$DISTRO\'/" $BUILDDIR/conf/local.conf
-fi
-