1 # Yocto shortcut functions
3 # source this file manually or from bashrc
5 # ----- customize here ----------
8 YOCTODIR=${YOCTODIR:-$HOME}
10 #OEDIR=${YOCTODIR}/oe-core
11 OEDIR=${OEDIR:-$YOCTODIR/yoctoTizen_IVI}
14 EDITOR=${EDITOR:-kate}
16 # --------------------------------
18 if [[ ! "$PATH" =~ "$YOCTODIR/bin:" ]]; then
20 export PATH=$YOCTODIR/bin:$PATH
25 YOCTO_BUILDDIR=$OEDIR/${1:-build}
27 if [[ ! -d $YOCTO_BUILDDIR ]]; then
31 . ./oe-init-build-env $1 >/dev/null 2>&1
34 if [[ x$init == xyes ]]; then
35 cp -v ../meta-tizen-ivi/conf/bblayers.conf.sample conf/bblayers.conf
36 cp -v ../meta-tizen-ivi/conf/local.conf.sample conf/local.conf
37 ${EDITOR} conf/local.conf
42 if [[ -z "$YOCTO_BUILDDIR" ]]; then
43 echo "yinit must be called first" >&2
51 if [[ -z "$YOCTO_BUILDDIR" ]]; then
52 echo "yinit not called" >&2
56 echo "YOCTODIR=$YOCTODIR"
58 echo "YOCTO_BUILDDIR=$YOCTO_BUILDDIR"
59 echo "YOCTO_LAST_PKG=$YOCTO_LAST_PKG"
70 if [[ "$pkg" == "-" ]]; then
73 if [[ -n "$pkg" ]]; then
78 pkgdir=$(ls -tr -d ../meta-tizen-ivi/recipes-tizen/$pkg 2>/dev/null | tail -1)
81 pkgdir=$(ls -tr -d tmp*/work/*/$pkg 2>/dev/null | tail -1)
84 [[ -z "$pkgdir" ]] && { echo "Unable to find package dir" >&2; return 1; }
88 temp|tmp) cd */temp || return 1 ;;
89 src) cd git-*/git 2>/dev/null || cd */[0-9]* 2>/dev/null ;;
100 pkg=${1:-$YOCTO_LAST_PKG}
101 [[ -z "pkg" ]] && { echo "Usage: ybb <pkg>" >&2; return 1; }
108 pkg=${1:-$YOCTO_LAST_PKG}
109 [[ -z "pkg" ]] && { echo "Usage: ysrc <pkg>" >&2; return 1; }
116 pkg=${1:-$YOCTO_LAST_PKG}
117 [[ -z "pkg" ]] && { echo "Usage: ytmp <pkg>" >&2; return 1; }
124 pkg=${1:-$YOCTO_LAST_PKG}
125 [[ -z "pkg" ]] && { echo "Usage: ydep <pkg>" >&2; return 1; }
127 pushd $YOCTO_BUILDDIR >/dev/null || return
128 bitbake -g -u depexp $pkg &
135 pkg=${1:-$YOCTO_LAST_PKG}
136 [[ -z "pkg" ]] && { echo "Usage: yshell <pkg>" >&2; return 1; }
137 pushd $YOCTO_BUILDDIR >/dev/null || return
138 bitbake -c devshell $pkg
144 pushd $YOCTO_BUILDDIR >/dev/null || return
153 pkg=${1:-$YOCTO_LAST_PKG}
155 what=${@:-configure log spec}
157 [[ -z "$pkg" ]] && { echo "Usage: yed <pkgname> [configure|log|spec]" >&2; return 2; }
159 pushd $YOCTO_BUILDDIR >/dev/null || return
161 for x in $(ls -d tmp*/work/*/$pkg); do
168 if [[ "$what" =~ "log" ]]; then
169 for tmpdir in $(ls -d */temp); do
170 echo "tmpdir: $tmpdir"
172 files+=$(awk '{print "log." $1}' $tmpdir/log.task_order | tac | sed "s|^| $tmpdir/|g")
178 if [[ "$what" =~ "run" ]]; then
179 for tmpdir in $(ls -d */temp); do
180 echo "tmpdir: $tmpdir"
182 files+=$(ls $tmpdir/run*)
188 if [[ "$what" =~ "spec" ]]; then
189 for spec in $(ls */*/packaging/*.spec 2>/dev/null); do
191 files+=" $(dirname $(dirname $spec))"
195 # find autoconf files
196 if [[ "$what" =~ "configure" ]]; then
197 for p in configure.ac configure.in config.log configure; do
198 for f in $(ls */*/$p 2>/dev/null); do
204 ${EDITOR:-xdg-open} $files
213 function ymount_work() {
216 pushd $YOCTO_BUILDDIR >/dev/null || return
218 workdir=$(ls -d tmp-*/work 2>/dev/null)
219 [[ -z "$workdir" ]] && { echo "Unable to find work dir"; return 1; }
221 realwdir=$(cd $workdir && pwd -P)
222 if grep $realwdir /proc/mounts >/dev/null; then
223 echo "$workdir already mounted"
228 mv $workdir ${workdir}.old
230 sudo mount tmpfs -t tmpfs $workdir || return 2
231 mv ${workdir}.old/* $workdir/
237 function yumount_work() {
240 pushd $YOCTO_BUILDDIR >/dev/null || return
242 workdir=$(ls -d tmp-*/work 2>/dev/null)
243 [[ -z "$workdir" ]] && { echo "Unable to find work dir"; return 1; }
245 realwdir=$(cd $workdir && pwd -P)
246 if ! grep $realwdir /proc/mounts >/dev/null; then
247 echo "$workdir already unmounted"
252 mkdir -p ${workdir}.new
253 mv $workdir/* ${workdir}.new
256 mv ${workdir}.new $workdir
264 pushd $YOCTO_BUILDDIR >/dev/null || return
266 workdir=$(ls -d tmp-* 2>/dev/null)
267 [[ -z "$workdir" ]] && { echo "Unable to find work dir"; return 1; }
269 pushd $workdir/stamps >/dev/null || return 2
271 echo "Architecture;Package;Version;State"
272 for arch in $(ls -d * 2>/dev/null); do
273 pushd $arch >/dev/null || return 3
274 for pkg in $(ls -d * 2>/dev/null); do
275 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); }')
277 ver=$(cut -f1 -d';' <<<$data)
278 step=$(cut -f2 -d';' <<<$data)
280 state=$(egrep "^$step:" <<EOF
289 populate_sysroot:FAIL
290 populate_sysroot_setscene:FAIL
292 packagedata_setscene:OK
296 package_write_rpm_setscene:OK
299 state=$(cut -f2 -d':' <<<$state)
301 echo "$arch;$pkg;$ver;$step;$state"
310 if [[ "$PS1" ]]; then
311 echo "Sourced ~/.yoctorc"