-
Notifications
You must be signed in to change notification settings - Fork 0
/
common-envsetup
66 lines (60 loc) · 1.78 KB
/
common-envsetup
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
#!/hint/bash
_wild_yocto_functions=()
_wild_yocto_unset_functions() {
unset -f "${_wild_yocto_functions[@]}"
}
_wild_yocto_functions+=(_wild_yocto_unset_functions)
_wild_yocto_apply_patches() {
if ( ! git -C openembedded-core symbolic-ref HEAD &>/dev/null ) && \
[[ -x meta-wild-common/yocto-patches/apply-patches.sh ]]; then
echo -ne "\nopenembedded-core is in a detached HEAD. Apply patches from meta-wild-common? (Y/n) "
local _apply_patch_answer
read _apply_patch_answer
if [[ -z $_apply_patch_answer ]] || [[ $_apply_patch_answer == [yY]* ]]; then
meta-wild-common/yocto-patches/apply-patches.sh
fi
fi
}
_wild_yocto_functions+=(_wild_yocto_apply_patches)
_wild_yocto_symlink_cache_dir() {
local _name="$1"
if [[ -e ./$_name ]]; then
if [[ ! -d ./$_name ]]; then
echo "WARNING: ./$_name exists but is not a directory!" >&2
fi
return 0
fi
local _dir
if [[ -d "$XDG_CACHE_HOME" ]]; then
_dir="$XDG_CACHE_HOME"
else
_dir="$HOME/.cache"
fi
_dir="$_dir/yocto/$_name"
if [[ -d "$_dir" ]]; then
ln -sv "$_dir" "$_name"
else
echo "WARNING: $_dir doesn't exist" >&2
fi
}
_wild_yocto_functions+=(_wild_yocto_symlink_cache_dir)
_wild_yocto_subst_confvars() {
# use: subst_confvars file1 file2 -- VAR1 VAR2 ...
local _files _var _val _sed_args
_files=()
while (( $# )); do
if [[ "$1" == "--" ]]; then
break
fi
_files+=("$1")
shift
done
shift
_sed_args=()
for _var in "$@"; do
eval _val="\$$_var"
_sed_args+=(-e "s,##$_var##,$_val,g")
done
sed -i "${_sed_args[@]}" "${_files[@]}"
}
_wild_yocto_functions+=(_wild_yocto_subst_confvars)