#!/bin/bash ################################################################################ # # The MIT License (MIT) # # Copyright (c) 2016 Stéphane Desneux # (c) 2016 Jan-Simon Möller # # 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. # ################################################################################ # this script shouldn't be called directly, but through aglsetup.sh that will in # turn execute (source) generated instructions back in the parent shell, # whether it's bash, zsh, or any other supported shell VERSION=1.1.0 DEFAULT_MACHINE=qemux86-64 DEFAULT_BUILDDIR=./build VERBOSE=0 DEBUG=0 #SCRIPT=$(basename $BASH_SOURCE) SCRIPT=aglsetup.sh SCRIPTDIR=$(cd $(dirname $BASH_SOURCE) && pwd -P) METADIR=$(cd $(dirname $BASH_SOURCE)/../.. && pwd -P) function info() { echo "$@" >&2; } function infon() { echo -n "$@" >&2; } function error() { echo "ERROR: $@" >&2; return 1; } function verbose() { [[ $VERBOSE == 1 ]] && echo "$@" >&2; return 0; } function debug() { [[ $DEBUG == 1 ]] && echo "DEBUG: $@" >&2; return 0;} info "------------ $SCRIPT: Starting" #compute AGL_REPOSITORIES AGL_REPOSITORIES=$(for x in $(ls -d $METADIR/*/templates/{machine,feature}); do echo $(basename $(dirname $(dirname $x))); done | sort -u) function list_machines() { for x in $@; do for y in $(ls -d $METADIR/$x/templates/machine/* 2>/dev/null); do echo $(basename $y) done done } function list_all_machines() { for x in $AGL_REPOSITORIES; do list_machines $x done } function validate_builddir() { if [[ "$BUILDDIR" =~ [[:space:]] ]]; then error "Build dir '$BUILDDIR' shouldn't contain any space" fi debug "Build dir is valid" } function validate_machines() { list_all_machines | sort | uniq -c | while read cnt machine; do [[ $cnt == 1 ]] && continue info "Machine $machine found in the following repositories:" for x in $(ls -d $METADIR/*/templates/machine/$machine); do info " - $x" done error "Multiple machine templates are not allowed" done debug "Machines list has no duplicate." } function list_features() { for x in $@; do for y in $(ls -d $METADIR/$x/templates/feature/* 2>/dev/null); do echo $(basename $y) done done } function list_all_features() { for x in $AGL_REPOSITORIES; do list_features $x done } function validate_features() { list_all_features | sort | uniq -c | while read cnt feature; do [[ $cnt == 1 ]] && continue; info "Feature $feature found in the following repositories:" for x in $(ls -d $METADIR/*/templates/feature/$feature); do info " - $x" done error "Multiple feature templates are not allowed" done debug "Features list has no duplicate." } function find_machine_dir() { machine=$1 for x in $AGL_REPOSITORIES; do dir=$METADIR/$x/templates/machine/$machine [[ -d $dir ]] && { echo $dir; return 0; } done return 1 } function find_feature_dir() { feature=$1 for x in $AGL_REPOSITORIES; do dir=$METADIR/$x/templates/feature/$feature [[ -d $dir ]] && { echo $dir; return 0; } done return 1 } function usage() { cat <&2 Usage: . $SCRIPT [options] [feature [feature [... ]]] Version: $VERSION Compatibility: bash, zsh, ksh Options: -m|--machine what machine to use default: '$DEFAULT_MACHINE' -b|--build build directory to use default: '$DEFAULT_BUILDDIR' -s|--script file where setup script is generated default: none (no script) -f|--force flag to force overwriting any existing configuration default: false -r|--rpm-revision Specify how to handle RPM packages revisions can be: 'prservice[:
]' : Use a PR service daemon. if
is not specified, the default value 'localhost:0' is used (shortcut for a PR service started by bitbake) 'timestamp' : Use a generated time stamp (UTC). 'value:' : Use explicitly. 'none' : Do nothing. -v|--verbose verbose mode default: false -d|--debug debug mode default: false -h|--help get some help EOF local buf echo "Available machines:" >&2 for x in $AGL_REPOSITORIES; do buf=$(list_machines $x) [[ -z "$buf" ]] && continue echo " [$x]" for y in $buf; do [[ $y == $DEFAULT_MACHINE ]] && def="* " || def=" " echo " $def$y" done done echo >&2 echo "Available features:" >&2 for x in $AGL_REPOSITORIES; do buf=$(list_features $x) [[ -z "$buf" ]] && continue echo " [$x]" for feature in $buf; do print_feature="$feature" featuredir=$(find_feature_dir $feature) if [ -e $featuredir/included.dep ];then print_feature="$print_feature :($(find_feature_dependency $feature $feature))" fi; echo " $print_feature" done done echo >&2 } function append_fragment() { basefile=$1; shift # output file f=$1; shift # input file label=$(echo "$@") debug "adding fragment to $basefile: $f" echo >>$basefile echo "# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #" >>$basefile echo "# fragment { " >>$basefile [[ -f $f ]] && echo "# $f" >>$basefile || true echo "#" >>$basefile [[ -n "$label" ]] && echo "$label" >>$basefile [[ -f $f ]] && cat $f >>$basefile || true echo "#" >>$basefile echo "# }" >>$basefile echo "# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #" >>$basefile [[ -f $f ]] && echo $f >>$BUILDDIR/conf/fragments.log || true } function execute_setup() { script=$1 debug "Executing script $script" opts="-e" [[ $DEBUG == 1 ]] && opts="$opts -x" pushd $BUILDDIR &>/dev/null $BASH $opts $script \ && rc=0 \ || { rc=$?; error "Script $s
# This config is for the beaglebone (inspired from the vayu config).

#