forked from armbian/build
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate_CODEOWNERS.sh
More file actions
executable file
·120 lines (100 loc) · 4 KB
/
Copy pathgenerate_CODEOWNERS.sh
File metadata and controls
executable file
·120 lines (100 loc) · 4 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
SRC="$(realpath "${BASH_SOURCE%/*}/../")"
# Maintainers flagged inactive (one GitHub username per line) are dropped from
# CODEOWNERS so they aren't review-requested on PRs touching "their" code — they
# stay listed in each board's BOARD_MAINTAINER. The sync workflow writes this file
# from the contacts DB's Days_since_last_activity; absent/unset => no filtering.
declare -A INACTIVE
if [[ -n "${INACTIVE_MAINTAINERS_FILE:-}" && -f "${INACTIVE_MAINTAINERS_FILE}" ]]; then
while read -r _u; do _u="${_u#@}"; [[ -n "$_u" ]] && INACTIVE["$_u"]=1; done < "${INACTIVE_MAINTAINERS_FILE}"
fi
# Dummy function for successful source
function display_alert() { :; }
function enable_extension() { :; }
function add_packages_to_image() { :; }
function run_hook() {
local hook_point="$1"
while read -r hook_point_function; do
"${hook_point_function}"
done < <(compgen -A function | grep "^${hook_point}__" | LC_ALL=C.UTF-8 sort)
}
# $1: board config
function generate_for_board() {
local board_config="$1"
(
BOARD="${board_config%.*}"
source "${SRC}/config/boards/${board_config}"
LINUXFAMILY="${BOARDFAMILY}"
[[ -n "${BOARD_MAINTAINER}" ]] || return
# CODEOWNERS owners = ACTIVE maintainers only — drop any flagged inactive so
# they aren't pinged (BOARD_MAINTAINER above keeps the full list untouched).
local _m maintainers=""
for _m in ${BOARD_MAINTAINER}; do
[[ -n "${INACTIVE[$_m]:-}" ]] || maintainers+="@${_m} "
done
maintainers="${maintainers% }"
# all maintainers inactive -> emit no entry (the path simply gets no owner)
[[ -n "${maintainers}" ]] || return
while read -r BRANCH; do
(
source "${SRC}/config/sources/families/${LINUXFAMILY}.conf"
source "${SRC}/config/sources/common.conf"
source "${SRC}/config/sources/${ARCH}.conf"
run_hook "post_family_config"
run_hook "post_family_config_branch_${BRANCH,,}"
[[ -z $LINUXCONFIG ]] && LINUXCONFIG="linux-${LINUXFAMILY}-${BRANCH}"
[[ -z $KERNELPATCHDIR ]] && KERNELPATCHDIR="archive/${LINUXFAMILY}-${KERNEL_MAJOR_MINOR}"
[[ -z $BOOTPATCHDIR ]] && BOOTPATCHDIR="u-boot-${LINUXFAMILY}"
[[ -z $ATFPATCHDIR ]] && ATFPATCHDIR="atf-${LINUXFAMILY}"
cat <<-EOF
config/boards/${board_config} ${maintainers}
config/kernel/${LINUXCONFIG%-*}-*.config ${maintainers}
sources/families/${BOARDFAMILY}.conf ${maintainers}
patch/kernel/${KERNELPATCHDIR%-*}-*/ ${maintainers}
EOF
local patch_archive="$(readlink "patch/kernel/${KERNELPATCHDIR}" || true)"
if [[ -n "${patch_archive}" ]]; then
patch_archive="${patch_archive%/}"
echo "patch/kernel/${patch_archive%-*}-*/ ${maintainers}"
fi
if [[ -n "${BOOTCONFIG}" && "${BOOTCONFIG}" != "none" ]]; then
while read -r d; do
echo "patch/u-boot/${d}/ ${maintainers}"
done < <(echo "${BOOTPATCHDIR}" | xargs -n1)
fi
if [[ -n "${ATFSOURCE}" && "${ATFSOURCE}" != "none" ]]; then
echo "patch/atf/${ATFPATCHDIR}/ ${maintainers}"
fi
)
done < <(echo "${KERNEL_TARGET}" | tr ',' '\n')
)
}
function generate_for_all_board() {
local board_config
while read -r board_config; do
local type="${board_config##*.}"
[[ "conf wip csc eos tvb" == *"${type}"* ]] || continue
generate_for_board "${board_config}"
done < <(ls "${SRC}/config/boards/")
}
function merge() {
local line
declare -A codeowners
while read -r line; do
local file="$(echo "${line}" | tr -s '[:space:]' ' ' | cut -d' ' -f1)"
local maintainers="$(echo "${line}" | tr -s '[:space:]' ' ' | cut -d' ' -f2-)"
codeowners["$file"]+=" ${maintainers}"
done
local file
while read -r file; do
declare -a maintainers
readarray -t maintainers < <(echo "${codeowners["$file"]}" | xargs -n1 | LC_ALL=C.UTF-8 sort -u)
echo "${file} ${maintainers[*]}"
done < <(printf "%s\n" "${!codeowners[@]}" | LC_ALL=C.UTF-8 sort)
}
cat <<-EOF >"${SRC}/.github/CODEOWNERS"
# PLEASE DON'T EDIT THIS FILE
# Auto generated by ".github/generate_CODEOWNERS.sh"
# The following contents are generated by board configs
$(generate_for_all_board | merge)
EOF