forked from lukaszgard/bitbake-completion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bitbake_diffsigs_completion
86 lines (70 loc) · 2.6 KB
/
bitbake_diffsigs_completion
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
#!bash
# Bash completion support for bitbake-diffsigs tool,
# compatible with Bitbake 1.40.1.
#
# Copyright (C) 2018 Lukasz Gardon <[email protected]>
#
# Distributed under the MIT License (MIT)
#
_bitbake_diffsigs()
{
local cur prev opts_short opts_long tasks colors
local bb_layers_conf bb_layers_md5 bb_recipes
COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}"
opts_short="-h -d -t -s"
opts_long="--help --debug --color --task --signature"
tasks="build compile compile_ptest_base configure configure_ptest_base deploy \
distrodata fetch image image_complete install install_ptest_base package \
package_qa package_write_deb package_write_ipk package_write_rpm package_write_tar \
packagedata patch populate_lic populate_sdk populate_sysroot prepare_recipe_sysroot \
rm_work unpack checkpkg checkuri clean cleanall cleansstate devpyshell devshell \
listtasks package_index bootimg bundle_initramfs rootfs testimage testimage_auto \
compile_kernelmodules diffconfig kernel_checkout kernel_configcheck kernel_configme \
kernel_menuconfig kernel_metadata menuconfig savedefconfig shared_workdir sizecheck \
strip validate_branches spdx"
colors="auto always never"
case "$cur" in
"--"*)
COMPREPLY=( $(compgen -W "${opts_long}" -- ${cur}) )
return 0
;;
"-"*)
COMPREPLY=( $(compgen -W "${opts_short}" -- ${cur}) )
return 0
;;
esac
bb_layers_conf="conf/bblayers.conf"
bb_layers_md5=".bb_layers_conf.md5"
bb_recipes=".bb_recipes"
_parse_recipes () {
bitbake -s | sed -e '0,/^=.*/d' -e '/^\s*$/d' -e '/^Summary:/d' | awk '{print $1}' > $bb_recipes
}
if [ ! -e $bb_layers_conf ]; then
return 0
fi
if [ "$prev" = "bitbake" -a "$cur" = "" ]; then
_parse_recipes
fi
md5sum --quiet --status -c $bb_layers_md5 2>/dev/null
if [ $? != 0 -o ! -e $bb_recipes ]; then
md5sum $bb_layers_conf > $bb_layers_md5
_parse_recipes
fi
recipes=$(cat $bb_recipes)
case "$prev" in
"-c"|"--color")
COMPREPLY=( $(compgen -W "${colors}" -- ${cur}) )
return 0
;;
"-t"|"--task")
COMPREPLY=( $(compgen -W "${recipes}" -- ${cur}) )
return 0
esac
if [[ ${COMP_WORDS[COMP_CWORD -2]} == "-t" ]] || [[ ${COMP_WORDS[COMP_CWORD -2]} == "--task" ]]; then
COMPREPLY=( $(compgen -W "${tasks}" -- ${cur}) )
return 0
fi
}
complete -F _bitbake_diffsigs bitbake-diffsigs