-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlkhh-kernel-list
More file actions
executable file
·102 lines (90 loc) · 2.33 KB
/
lkhh-kernel-list
File metadata and controls
executable file
·102 lines (90 loc) · 2.33 KB
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
#! /bin/bash
_rootdir=${_rootdir:-"$(dirname "$(readlink -f "$0")")"}
_ver="0.0.1-dev"
#_author="Wei Peng <me@1pengw.com>"
source "${_rootdir}/_shared_prologue"
#
# parameters
#
declare -i all=${all:-0}
declare foreach=${foreach:-}
#
# getopt processing
#
function my_getopt_cont () {
local n_shift=1 # number of shifts in the outer loop; shift by 1 by default
case "$1" in
-a|--all)
all=1
n_shift=1
;;
-f|--foreach)
shift
foreach=$1
n_shift=2
;;
esac
return $n_shift
}
my_getopt "af:" "all,foreach:" "my_getopt_cont" "List state of build/target instances." "$(
cat <<END
[-a|--all] [-f|--foreach=<foreach>]
END
)" "$(
cat <<END
-a --all List all initialized instances, not only non-empty ones (default: $all).
-f --foreach A snippet of shell script to be eval'd, which takes each build path from stdin (default: $foreach).
END
)" "$@"
ret=$?
eval set -- "$_getopt"
shift $ret
# sanity check
vecho 0 <<END
$(
dumpparam <<END1
$(
for name in all foreach; do
echo "$name=$(echo $(eval "echo \$$name"))"
done
)
END1
)
END
build_root="$(readlink -f "$LKHH_ARENA/build")"
[[ -d "$build_root" ]] || die 1 <<END
ERROR: $build_root does not exist; consider "lkhh-init" first.
END
vecho 0 <<END
$build_root
END
ls -d "$build_root"/* | sort -V | while IFS= read -r line; do
n=${line##$build_root/}
output_p=0
output="$n:"
if [[ -f "$line/.config" ]]; then
output+="\tconfigured"; (( output_p++ ));
krel=$(cat "$line/include/config/kernel.release" 2> /dev/null)
if [[ -n "$krel" ]]; then
output+="($krel)"
fi
fi
if [[ -h "$line/source" ]]; then output+="\tsource@($(readlink -f "$line/source"))"; (( output_p++ )); fi
if [[ -f "$line/vmlinux" ]]; then
output+="\tbuilt";
if [[ -f "$line/.config" ]]; then
if [[ "$line/vmlinux" -nt "$line/.config" ]]; then
output+="(vmlinux is up to date with .config)"
elif [[ "$line/vmlinux" -ot "$line/.config" ]]; then
output+="(vmlinux is older than .config)"
fi
fi
fi
output+="\n"
if (( output_p > 0 )) || (( all > 0 )); then
printf "$output"
fi
if [[ -n "$foreach" ]]; then
eval "echo '$line' | $foreach"
fi
done