/
find_fixes_in_queue
executable file
·119 lines (98 loc) · 2.6 KB
/
find_fixes_in_queue
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
#!/bin/bash
# SPDX-License-Identifier: GPL-2.0
#
# Copyright 2020 Greg Kroah-Hartman <gregkh@linuxfoundation.org>
#
#
STABLE_TREE="/home/gregkh/linux/stable/linux-stable"
STABLE_QUEUE="/home/gregkh/linux/stable/stable-queue/"
REAL_SCRIPT=$(realpath -e "${BASH_SOURCE[0]}")
SCRIPT_TOP="${SCRIPT_TOP:-$(dirname "${REAL_SCRIPT}")}"
source "${SCRIPT_TOP}"/lib/common
TMPDIR="/home/gregkh/tmp"
PREFIX="$(basename "${REAL_SCRIPT}")_"
TMP_PREFIX="${TMPDIR}/${PREFIX}"
GEN_CID="${SCRIPT_TOP}/generate_cid.sh"
ID_FIXED_IN="${SCRIPT_TOP}/id_fixed_in"
usage()
{
echo "error, kernel version not found"
echo "usage:"
echo " $0 KERNEL_VERSION"
exit 2
}
save_commit()
{
local commit version mbox
commit=$1
version=$2
mbox=$3
#log "${txtylw}in ${version} release, SAVING!${txtrst}"
git show --pretty=email "${commit}" | sed -e "s/\[PATCH\]/\[PATCH ${version}\]/" >> "${mbox}"
}
check_patch()
{
local patch commit message
patch=$1
cd "${STABLE_QUEUE}/queue-${KERNEL_VERSION}/"
commit=$(cat ${patch} | awk '{if(NR>1)print}' | grep -E -o '[0-9a-f]{40}' | head -n 1)
if [ "${commit}" == "" ] ; then
return
fi
# ${ID_FIXED_IN} will shorten the commit id
message="${txtcyn}looking at ${txtgrn}${commit}${txtrst} "
result=$(${ID_FIXED_IN} ${commit})
retval=$?
if [ $retval -eq 2 ] ; then
log "${message}${txtred}not found!${txtrst}"
return
fi
if [ $retval -ne 0 ] ; then
log "${message}${txtpur}no fixes${txtrst}"
return
fi
for line in ${result}; do
line_array=(${line//:/ })
sha1=${line_array[0]}
kernel_version=${line_array[1]}
commit_id=${line_array[2]}
message+="${txtred}fix found in ${txtylw}${kernel_version}${txtrst} "
# see if commit is already in the queue
found=$(grep -l -r "${commit_id}" "${STABLE_QUEUE}/queue-${KERNEL_VERSION}/")
if [ "${found}" == "" ] ; then
save_commit "${commit_id}" "${kernel_version}" "${MBOX}"
message+="${txtgrn}saved"
else
message+="${txtblu}already in queue"
fi
done
log "${message}"
}
KERNEL_VERSION=$1
if [ "${KERNEL_VERSION}" == "" ] ; then
usage
fi
MBOX=$(mktemp ${TMP_PREFIX}mbox.XXXXXX) || exit 1
cd "${STABLE_QUEUE}/queue-${KERNEL_VERSION}/"
threads=$(nproc)
log "using ${txtpur}${threads}${txtrst} threads"
for patch in *.patch ; do
while :
do
if [ $(jobs -p | wc -l) -lt ${threads} ]; then
check_patch $patch &
break
else
sleep 1
fi
done
done
wait
num_commits=$(grep -c '^From ' ${MBOX})
if [ "${num_commits}" == "0" ] ; then
echo "${txtgrn}No missing fixes found!${txtrst}"
rm "${MBOX}"
else
echo "# ${txtred}${num_commits}${txtrst} commits are in ${MBOX}"
echo "mutt -f ${MBOX}"
fi