# Yocto shortcut functions # # source this file manually or from bashrc # ----- customize here ---------- #YOCTODIR="${HOME}" YOCTODIR=${YOCTODIR:-$HOME} #OEDIR=${YOCTODIR}/oe-core OEDIR=${OEDIR:-$YOCTODIR/yoctoTizen_IVI} #EDITOR="gview -p" EDITOR=${EDITOR:-kate} # -------------------------------- if [[ ! "$PATH" =~ "$YOCTODIR/bin:" ]]; then echo "Adding path" export PATH=$YOCTODIR/bin:$PATH fi function yinit () { cd $OEDIR YOCTO_BUILDDIR=$OEDIR/${1:-build} init=no if [[ ! -d $YOCTO_BUILDDIR ]]; then init=yes fi . ./oe-init-build-env $1 >/dev/null 2>&1 cd $YOCTO_BUILDDIR if [[ x$init == xyes ]]; then cp -v ../meta-tizen-ivi/conf/bblayers.conf.sample conf/bblayers.conf cp -v ../meta-tizen-ivi/conf/local.conf.sample conf/local.conf ${EDITOR} conf/local.conf fi } function ycheck() { if [[ -z "$YOCTO_BUILDDIR" ]]; then echo "yinit must be called first" >&2 return 1 fi return 0 } function ystatus() { if [[ -z "$YOCTO_BUILDDIR" ]]; then echo "yinit not called" >&2 return 1 fi echo "YOCTODIR=$YOCTODIR" echo "OEDIR=$OEDIR" echo "YOCTO_BUILDDIR=$YOCTO_BUILDDIR" echo "YOCTO_LAST_PKG=$YOCTO_LAST_PKG" return 0 } function ycd () { ycheck || return 1 cd $YOCTO_BUILDDIR pkg=$1 if [[ "$pkg" == "-" ]]; then pkg=$YOCTO_LAST_PKG fi if [[ -n "$pkg" ]]; then subdir=${2:-src} case "$subdir" in bb) pkgdir=$(ls -tr -d ../meta-tizen-ivi/recipes-tizen/$pkg 2>/dev/null | tail -1) ;; *) pkgdir=$(ls -tr -d tmp*/work/*/$pkg 2>/dev/null | tail -1) ;; esac [[ -z "$pkgdir" ]] && { echo "Unable to find package dir" >&2; return 1; } cd $pkgdir case "$subdir" in temp|tmp) cd */temp || return 1 ;; src) cd git-*/git 2>/dev/null || cd */[0-9]* 2>/dev/null ;; *) ;; esac YOCTO_LAST_PKG=$pkg fi } function ybb () { ycheck || return 1 pkg=${1:-$YOCTO_LAST_PKG} [[ -z "pkg" ]] && { echo "Usage: ybb " >&2; return 1; } ycd $pkg bb } function ysrc () { ycheck || return 1 pkg=${1:-$YOCTO_LAST_PKG} [[ -z "pkg" ]] && { echo "Usage: ysrc " >&2; return 1; } ycd $pkg src } function ytmp () { ycheck || return 1 pkg=${1:-$YOCTO_LAST_PKG} [[ -z "pkg" ]] && { echo "Usage: ytmp " >&2; return 1; } ycd $pkg temp } function ydep () { ycheck || return 1 pkg=${1:-$YOCTO_LAST_PKG} [[ -z "pkg" ]] && { echo "Usage: ydep " >&2; return 1; } pushd $YOCTO_BUILDDIR >/dev/null || return bitbake -g -u depexp $pkg & popd >/dev/null } function yshell () { ycheck || return 1 pkg=${1:-$YOCTO_LAST_PKG} [[ -z "pkg" ]] && { echo "Usage: yshell " >&2; return 1; } pushd $YOCTO_BUILDDIR >/dev/null || return bitbake -c devshell $pkg popd >/dev/null } function bbake() { ycheck || return 1 pushd $YOCTO_BUILDDIR >/dev/null || return bitbake "$@" popd >/dev/null } function yed() { ycheck || return 1 pkg=${1:-$YOCTO_LAST_PKG} shift what=${@:-configure log spec} [[ -z "$pkg" ]] && { echo "Usage: yed [configure|log|spec]" >&2; return 2; } pushd $YOCTO_BUILDDIR >/dev/null || return for x in $(ls -d tmp*/work/*/$pkg); do echo "$pkg: $x" files= pushd $x >/dev/null # find log files if [[ "$what" =~ "log" ]]; then for tmpdir in $(ls -d */temp); do echo "tmpdir: $tmpdir" files+=$(awk '{print "log." $1}' $tmpdir/log.task_order | tac | sed "s|^| $tmpdir/|g") files+=" $tmpdir" done fi # find run files if [[ "$what" =~ "run" ]]; then for tmpdir in $(ls -d */temp); do echo "tmpdir: $tmpdir" files+=$(ls $tmpdir/run*) files+=" $tmpdir" done fi # find spec files if [[ "$what" =~ "spec" ]]; then for spec in $(ls */*/packaging/*.spec 2>/dev/null); do files+=" $spec" files+=" $(dirname $(dirname $spec))" done fi # find autoconf files if [[ "$what" =~ "configure" ]]; then for p in configure.ac configure.in config.log configure; do for f in $(ls */*/$p 2>/dev/null); do files+=" $f" done done fi ${EDITOR:-xdg-open} $files popd >/dev/null done popd >/dev/null } function ymount_work() { ycheck || return 1 pushd $YOCTO_BUILDDIR >/dev/null || return workdir=$(ls -d tmp-*/work 2>/dev/null) [[ -z "$workdir" ]] && { echo "Unable to find work dir"; return 1; } realwdir=$(cd $workdir && pwd -P) if grep $realwdir /proc/mounts >/dev/null; then echo "$workdir already mounted" popd >/dev/null return 1 fi mv $workdir ${workdir}.old mkdir -p $workdir sudo mount tmpfs -t tmpfs $workdir || return 2 mv ${workdir}.old/* $workdir/ rmdir ${workdir}.old popd >/dev/null } function yumount_work() { ycheck || return 1 pushd $YOCTO_BUILDDIR >/dev/null || return workdir=$(ls -d tmp-*/work 2>/dev/null) [[ -z "$workdir" ]] && { echo "Unable to find work dir"; return 1; } realwdir=$(cd $workdir && pwd -P) if ! grep $realwdir /proc/mounts >/dev/null; then echo "$workdir already unmounted" popd >/dev/null return 1 fi mkdir -p ${workdir}.new mv $workdir/* ${workdir}.new sudo umount $workdir rmdir $workdir mv ${workdir}.new $workdir popd >/dev/null } function yreport() { ycheck || return 1 pushd $YOCTO_BUILDDIR >/dev/null || return workdir=$(ls -d tmp-* 2>/dev/null) [[ -z "$workdir" ]] && { echo "Unable to find work dir"; return 1; } pushd $workdir/stamps >/dev/null || return 2 echo "Architecture;Package;Version;State" for arch in $(ls -d * 2>/dev/null); do pushd $arch >/dev/null || return 3 for pkg in $(ls -d * 2>/dev/null); do data=$(ls -tr $pkg | grep -v ".sigdata." | tail -1 | awk '{ x=$0; gsub(/\.do_.+$/,"",x); y=substr($0,length(x)+5); gsub(/\..+$/,"",y); printf("%s;%s",x,y); }') ver=$(cut -f1 -d';' <<<$data) step=$(cut -f2 -d';' <<<$data) state=$(egrep "^$step:" </dev/null done popd >/dev/null popd >/dev/null } if [[ "$PS1" ]]; then echo "Sourced ~/.yoctorc" fi