#!/bin/bash RUN="true" SCRIPTNAME="runme.sh"; TMPFILE="/tmp/ans" tempfile1=/tmp/dialog_1_$$ tempfile2=/tmp/dialog_2_$$ tempfile3=/tmp/dialog_3_$ trap "rm -f $tempfile1 $tempfile2 $tempfile3" 0 1 2 5 15 # check if script is being sorced or not. if [ "$0" == "./$SCRIPTNAME" ]; then echo "option accepted: -x to run dialog graphic mode"; echo "This script must me lanched using: source $0 or . $0 "; exit; fi function header { PS1="amakha :\w > " #clear echo "############### @ Amakha Cross-Compiling Environment @ ###############" echo "# http://www.amakha.org #" echo "######################################################################" echo "" } function diaghead { dialog --title "Dialog message box" \ --msgbox "\n############### @ Amakha Cross-Compiling Environment @ ############### \n# http://www.amakha.org # \n######################################################################" 10 80 } function bitbakeopt { dialog --menu "Choose one:" 0 0 0 \ "1" "cleanup" "2" "compile" 2> $TMPFILE W=$( cat $TMPFILE ); if [ "$W" == "" ]; then return; fi case $W in 1) setcleanup ;; 2) setbuild ;; esac } function editconf { dialog --editbox $localconffile 25 60 2> $tempfile1 dialog --title "Confirmation" --yesno "Commit ?" 0 0 case $? in 0) cat $tempfile1 > $localconffile dialog --infobox "File Saved " 0 0 sleep 2 ;; 1|255) dialog --infobox "No Changes done" 0 0 sleep 2 ;; esac dialog --textbox $localconffile 0 0 } function conflocal { localconffile="$BUILDDIR/conf/local.conf" dialog --title "Amakha local.conf editor" \ --menu "Please choose an option:" 15 55 5 \ 1 "View the config file" \ 2 "Edit config file" \ 3 "Exit from this menu" 2> $tempfile3 retv=$? choice=$(cat $tempfile3) [ $retv -eq 1 -o $retv -eq 255 ] && return case $choice in 1) dialog --textbox $localconffile 0 0 conflocal ;; 2) editconf conflocal ;; 3) return ;; esac } function setcleanup { dialog --yesno "Start build now ?" 0 0 if [ "$?" = "0" ]; then header start=$(date); echo "$start - Cleaning Up now your Amakha for $R using: bitbake -c clean ${CMD[$S]} ..."; bitbake -c clean ${CMD[$S]}; end=$(date); diff=$( echo $( date +%s -d "$end" ) - $(date +%s -d "$start") | bc ); echo "$end - Clean ended, total time: $diff sec -> $(($diff/3600))h $(($diff/60-($(($diff/3600))*60)))m $(($diff-($(($diff/60))*60)))s"; else header echo -e "\nStart cleaning up your Amakha for $R using:\n\t bitbake -c clean ${CMD[$S]}"; fi } function envset { dialog --menu "Choose one:" 0 0 0 \ $( a="0"; for x in `ls --color=none build`; do echo $x $a; ((a++)); done) 2> $TMPFILE R=$( cat $TMPFILE ); if [ "$R" == "" ]; then return; fi OEROOT=`pwd` if [ "x$BDIR" = "x" ]; then if [ "x$R" = "x" ]; then BDIR="build/$R" else BDIR="build/$R" fi fi BUILDDIR="$OEROOT/$BDIR/" unset BDIR BITBAKEDIR="$OEROOT/tools/bitbake$BBEXTRA/" PKGDIR="$OEROOT/meta-amakha/" BBPATH="${OEROOT}/build/$R $BITBAKEDIR $PKGDIR" BBPATH=" $BBPATH $OEROOT/meta-oe" NEWPATH="" for p in $BBPATH do p2=`readlink -f "$p"` NEWPATH="$p2:$NEWPATH" done BBPATH="$NEWPATH" MSG='' BUILD_ARCH=`uname -m` BUILD_OS=`uname | tr '[A-Z]' '[a-z]'` BUILD_SYS="$BUILD_ARCH-$BUILD_OS" PATH="$BITBAKEDIR/bin/:$OEROOT/tools/scripts:$PATH" cd "$BUILDDIR/" if [ "$?" == "1" ]; then clear echo "Invalid board name." return; fi BITBAKEDIR=`readlink -f "$BITBAKEDIR"` PKGDIR=`readlink -f "$PKGDIR"` BUILDDIR=`readlink -f "$BUILDDIR"` export BBPATH OEROOT BUILD_SYS BUILDDIR unset TERMINFO unset LD_LIBRARY_PATH export PATH LD_LIBRARY_PATH OEROOT export LANG=C unset PYTHONPATH unset GCONF_SCHEMA_INSTALL_SOURCE export BB_ENV_EXTRAWHITE="MACHINE DISTRO POKYMODE POKYLIBC OEROOT SSH_AGENT_PID SSH_AUTH_SOCK BB_SRCREV_POLICY" conflocal Y=0; i=0 for x in $( ls --color=none $PKGDIR/recipes/amakha-images/*.bb ); do Y=$[$Y+1]; if [ "$Y" == "5" ]; then break; fi; DESC=$( cat $x | grep DESCRIPTION| awk -F\" '{print $2}' ); CMD[Y]="$( basename $x .bb )"; options[i++]="$Y"; array[i++]="$Y ${CMD[$Y]} - $DESC"; array[i++]=""; done dialog --menu "Choose one:" 0 100 ${#options[@]} "${array[@]}" 2> $TMPFILE S=$( cat $TMPFILE | cut -d" " -f1 ); if [ "$S" == "" ]; then return; fi rm $TMPFILE bitbakeopt } function setbuild { dialog --yesno "Start build now ?" 0 0 if [ "$?" = "0" ]; then header start=$(date); echo "$start - Building now your Amakha for $R using: bitbake ${CMD[$S]} ..."; bitbake ${CMD[$S]}; end=$(date); diff=$( echo $( date +%s -d "$end" ) - $(date +%s -d "$start") | bc ); echo "$end - Building ended, total time: $diff sec -> $(($diff/3600))h $(($diff/60-($(($diff/3600))*60)))m $(($diff-($(($diff/60))*60)))s"; else header echo -e "\nStart build your Amakha for $R using:\n\t bitbake ${CMD[$S]}"; fi } if [ -e $( which dialog ) ] && [ "$1" == "-x" ]; then diaghead envset else if [ "$1" == "" ]; then echo "Use . $SCRIPTNAME " echo "" echo "Board supported :" for x in `ls --color=none build`; do echo " -> $x"; done else source ./tools/scripts/set-environment.sh $1 fi fi