From 1ea12fc8cc8d628790d73dc028e1913294265a8f Mon Sep 17 00:00:00 2001 From: Stephane Desneux Date: Fri, 5 Apr 2013 16:33:09 +0200 Subject: [PATCH] added yoctorc to be sourced from .bashrc for shortcut commands: ycd, ypkg, yed ... --- yoctorc | 137 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 137 insertions(+) create mode 100644 yoctorc diff --git a/yoctorc b/yoctorc new file mode 100644 index 0000000..6dc9af4 --- /dev/null +++ b/yoctorc @@ -0,0 +1,137 @@ +# ----- customize here ---------- + +YOCTODIR=/yocto + +OEDIR=$YOCTODIR/oe-core + +EDITOR="gview -p" + +# -------------------------------- + +if [[ ! "$PATH" =~ "$YOCTODIR/bin:" ]]; then + echo "Adding path" + export PATH=$YOCTODIR/bin:$PATH +fi + +function yinit () { + cd $OEDIR + . ./oe-init-build-env $1 >/dev/null 2>&1 + YOCTO_BUILDDIR=$OEDIR/${1:-build} + cd $YOCTO_BUILDDIR +} + +function ycheck() { + if [[ -z "$YOCTO_BUILDDIR" ]]; then + echo "yinit must be called first" >&2 + return 1 + fi + + return 0 +} + +function ycd () { + ycheck || return 1 + + cd $YOCTO_BUILDDIR + + pkg=$1 + if [[ "$pkg" == "-" ]]; then + pkg=$YOCTO_LAST_PKG + fi + if [[ -n "$pkg" ]]; then + cd $(ls -tr -d tmp*/work/*/$pkg 2>/dev/null | tail -1) || return 1 + + YOCTO_LAST_PKG=$pkg + + subdir=${2:-src} + case "$subdir" in + temp|tmp) cd */temp || return 1 ;; + src) cd git-*/git 2>/dev/null || cd */[0-9]* 2>/dev/null ;; + *) ;; + esac + fi + +} + +function ysrc () { + ycheck || return 1 + + pkg=${1:-$YOCTO_LAST_PKG} + [[ -z "pkg" ]] && { echo "Usage: ytmp " >&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 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+=$(awk '{print "run." $1}' $tmpdir/log.task_order | tac | sed "s|^| $tmpdir/|g") + 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 +} + +if [[ "$PS1" ]]; then + echo "Sourced ~/.yoctorc" +fi -- 2.7.4