-
Notifications
You must be signed in to change notification settings - Fork 1
/
ye-cd
116 lines (104 loc) · 3.14 KB
/
ye-cd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
# -*- shell-script -*-
# If ye-cd has been source'd already, YE_SCRIPT will be in the
# environment, so we should not re-source it, unless YE_FORCE_RELOAD
# is set.
if [ -n "$YE_SCRIPT" ] && [ ! -n "$YE_FORCE_RELOAD" ]; then
cat <<EOF >&2
ye-cd has already been source'd. If you really want to re-evaluate it,
set the YE_FORCE_RELOAD environment variable and source it again.
EOF
return
fi
YE_SCRIPT=`which ye`
if [ $? -ne 0 ]; then
echo "ERROR: could not find ye (is it in \$PATH?)." >&2
return
fi
export YE_SCRIPT
YE_PLUMBING_DIR=$HOME/.ye/plumbing
yecd_error() {
echo "ERROR: " $* >&2
}
yecd_get_bb_var() {
if [ -e "$YE_PLUMBING_DIR/x" ]; then
awk -F= "/^$1/"' {print $2}' $YE_PLUMBING_DIR/x
else
yecd_error "yecd_get_bb_var: could not determine $1."
fi
}
ye() {
if [ "$1" != "cd" ]; then
$YE_SCRIPT "$@"
return $?
fi
shift
if [ -z "$BUILDDIR" ]; then
yecd_error "BUILDDIR is not set"
return 1
fi
local dir_shortcut=$1
local topdir
case $dir_shortcut in
"top"|"topdir")
topdir=`$YE_SCRIPT plumbing topdir`
[ $? -eq 0 ] && cd $topdir
;;
"wd"|"work"|"workdir")
local recipe=$2
if [ -z "$recipe" ]; then
cd $BUILDDIR/tmp/work/
else
$YE_SCRIPT plumbing wd "$recipe"
if [ -e "$YE_PLUMBING_DIR/wd" ]; then
cd `cat $YE_PLUMBING_DIR/wd`
fi
fi
;;
"bd"|"build"|"builddir")
cd $BUILDDIR
;;
"bh"|"buildhistory")
cd $BUILDDIR/buildhistory
;;
"sd"|"sysroot"|"sysrootdir")
$YE_SCRIPT plumbing x MACHINE
local machine=`yecd_get_bb_var MACHINE | tr - _`
[ -n "$machine" ] && cd $BUILDDIR/tmp/sysroots-components/$machine
;;
"src"|"sources")
local recipe=$2
if [ -z "$recipe" ]; then
topdir=`$YE_SCRIPT plumbing topdir`
[ $? -eq 0 ] && cd $topdir/sources
else
cd $BUILDDIR
$YE_SCRIPT plumbing find $recipe
cd `dirname $(cat $YE_PLUMBING_DIR/find)`
fi
;;
"img"|"images")
$YE_SCRIPT plumbing x MACHINE
local machine=`yecd_get_bb_var MACHINE`
[ -n "$machine" ] && cd $BUILDDIR/tmp/deploy/images/$machine
;;
"pkg"|"packages")
$YE_SCRIPT plumbing x IMAGE_PKGTYPE MACHINE
local pkg_type=`yecd_get_bb_var IMAGE_PKGTYPE`
local machine=`yecd_get_bb_var MACHINE | tr - _`
[ -n "$pkg_type" ] && [ -n "$machine" ] && \
cd $BUILDDIR/tmp/deploy/$pkg_type/$machine
;;
"manifest"|"manifests")
topdir=`$YE_SCRIPT plumbing topdir`
[ $? -eq 0 ] && cd $topdir/.repo/manifests
;;
*)
if [ -z "$dir_shortcut" ]; then
cd $BUILDDIR
else
$YE_SCRIPT -h
return $?
fi
;;
esac
}