blob: 5bd1a965e5daabd430e8764855c9e46d2f1b97d3 [file] [log] [blame]
Yegor Timoshenkoc2e49412018-10-07 01:58:27 +00001#!/usr/bin/env bash
Martin Rothbec11082015-11-03 21:01:53 -07002#
Patrick Georgi7333a112020-05-08 20:48:04 +02003# SPDX-License-Identifier: GPL-2.0-only
Martin Rothbec11082015-11-03 21:01:53 -07004
Martin Rothfb190ed2016-10-01 20:13:43 -06005# This script creates a list of commits between two releases, broken out into
6# fairly inexact categories, based on the directories that files are in. If
7# a commit touched anything in the path that is checked earlier, it's counted
8# as being in that category.
9#
10# Don't run this in your current working tree, it checks out different versions
11# and can lose things.
Martin Rothbec11082015-11-03 21:01:53 -070012
Martin Rothfb190ed2016-10-01 20:13:43 -060013# set -x # uncomment for debug
14
15# Check for tools
16
Patrick Georgifa13a642018-12-20 17:17:03 +010017if ! ( git --version && cloc --version && rename --version ) > /dev/null 2>&1
Martin Rothfb190ed2016-10-01 20:13:43 -060018then
Patrick Georgid906b212020-05-11 23:43:40 +020019 echo "ERROR: cloc, git or rename is not installed. Exiting"
Martin Rothbec11082015-11-03 21:01:53 -070020 exit 1
21fi
22
Alex Thiessenda384dd2018-01-13 16:31:28 +000023if ! { cdup="$(git rev-parse --show-cdup 2>/dev/null)" && [ -z "${cdup}" ]; }
24then
Martin Rothfb190ed2016-10-01 20:13:43 -060025 echo "ERROR: This is not the top directory of a git repo. Exiting."
26 exit 1
27fi
28
29# Try to verify that the repo is clean before losing state.
Patrick Georgi35c8dcf2018-12-20 17:17:55 +010030if ! git diff-index --quiet --cached HEAD 2>/dev/null; then
Martin Rothbec11082015-11-03 21:01:53 -070031 echo "ERROR: repo is not clean. Exiting."
32 exit 1
33fi
34
Martin Rothfb190ed2016-10-01 20:13:43 -060035# Verify the command line arguments
36if [ "$1" == "--help" ] || [ -z "$1" ] || [ -z "$2" ]; then
37 echo
38 echo "Usage: $0 <old_version> <new_version> [release notes file]"
39 echo "Old version should be a tag (4.1), a branch (origin/4.1), or a commit id"
40 echo "New version can be 'HEAD' a branch (origin/master) a tag (4.2), or a commit id"
41 echo "Logfile can be a new file or an existing file to update"
42 echo "Example: \"$0 origin/4.1 4.2 rnotes.txt\""
43 echo
44 echo "Note that the script starts at the commit AFTER the old version."
45 echo
46 exit 1
47else
48 OLD_GIT_VERSION="$1"
49 NEW_GIT_VERSION="$2"
Patrick Georgi81a30ec2020-05-11 23:47:12 +020050 if [ "$OLD_GIT_VERSION" = "HEAD" -o "$NEW_GIT_VERSION" = "HEAD" ]; then
51 echo "Error: using HEAD as a reference doesn't work"
52 echo
53 exit 1
54 fi
Martin Rothfb190ed2016-10-01 20:13:43 -060055 TOTAL_COMMITS=$(git log --pretty=oneline \
56 "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | wc -l)
57fi
58
59TOP=$(pwd)
60
61if [ -n "$3" ]; then
62 MAIN_LOGFILE="${TOP}/$3"
63else
64 MAIN_LOGFILE="${TOP}/relnotes.txt"
65fi
66
67# Figure out which logfile we're writing to. If the specified logfile exists,
68# we need to write to a temporary logfile, then append changes to the main
69# logfile.
Martin Rothbec11082015-11-03 21:01:53 -070070if [ -f "$MAIN_LOGFILE" ]; then
71 LOGFILE="$(mktemp "LOGFILE.XXXX")"
72 LOGFILE="${TOP}/$LOGFILE"
73 UPDATE_MAIN_LOGFILE=1
74else
75 LOGFILE="$MAIN_LOGFILE"
76fi
77
Martin Rothfb190ed2016-10-01 20:13:43 -060078get_author_commit_count() {
79 git log "${NEW_GIT_VERSION}" 2>/dev/null | grep -c "^Author: $1"
80}
81
82# Print and log the versions
Martin Rothbec11082015-11-03 21:01:53 -070083log_versions() {
84 echo "Log of commit $1 to commit $2"
85 echo "Log of commit $1 to commit $2" >> "$LOGFILE"
Martin Rothfb190ed2016-10-01 20:13:43 -060086 echo "Total commits: ${TOTAL_COMMITS}"
87 echo "Total commits: ${TOTAL_COMMITS}" >> "$LOGFILE"
Martin Rothbec11082015-11-03 21:01:53 -070088 echo
89}
90
Martin Rothfb190ed2016-10-01 20:13:43 -060091# Get the first commit id in the current tree
Martin Rothbec11082015-11-03 21:01:53 -070092get_latest_commit_id() {
Martin Roth3ce67832017-11-04 18:36:19 -060093(
94 cd "$1"
Martin Rothfb190ed2016-10-01 20:13:43 -060095 git log 2>/dev/null | grep '^commit ' | head -1 | sed 's/commit //'
Martin Roth3ce67832017-11-04 18:36:19 -060096)
Martin Rothbec11082015-11-03 21:01:53 -070097}
98
Martin Rothfb190ed2016-10-01 20:13:43 -060099# Main get log function
Martin Rothbec11082015-11-03 21:01:53 -0700100_get_log() {
101 local oldver="$1"
102 local newver="$2"
103 local title="$3"
104 local paths="$4"
Martin Roth3ce67832017-11-04 18:36:19 -0600105 local keywords="$5"
Martin Rothbec11082015-11-03 21:01:53 -0700106
Martin Roth3ce67832017-11-04 18:36:19 -0600107 # Leave ${paths} unquoted in the git commands
Martin Rothfb190ed2016-10-01 20:13:43 -0600108 # shellcheck disable=SC2086
Martin Roth3ce67832017-11-04 18:36:19 -0600109 { \
110 if [ -n "$paths" ]; then \
111 git log --abbrev-commit --pretty=oneline \
112 "${oldver}..${newver}" -- ${paths} \
113 2>/dev/null; \
114 fi; \
115 if [ -n "$keywords" ]; then \
116 git log --abbrev-commit --pretty=oneline \
117 "${oldver}..${newver}" 2>/dev/null \
118 | grep -i "$keywords"; \
119 fi \
120 } | sort -t ' ' -k 2 | uniq
Martin Rothbec11082015-11-03 21:01:53 -0700121}
122
Martin Rothfb190ed2016-10-01 20:13:43 -0600123# Output to a new log, then compare to the first logfile, and only output
124# non duplicated lines to the final file.
Martin Rothbec11082015-11-03 21:01:53 -0700125get_log_dedupe() {
126 local title="$1"
127 local paths="$2"
Martin Roth3ce67832017-11-04 18:36:19 -0600128 local keywords="$3"
Martin Rothfb190ed2016-10-01 20:13:43 -0600129 local log
130 local commits
131
Martin Rothbec11082015-11-03 21:01:53 -0700132 dedupe_tmpfile="$(mktemp "LOGFILE.XXXX")"
133
Martin Rothfb190ed2016-10-01 20:13:43 -0600134 log=$(_get_log "$OLD_GIT_VERSION" "$NEW_GIT_VERSION" \
Martin Roth3ce67832017-11-04 18:36:19 -0600135 "$title" "$paths" "$keywords")
Martin Rothbec11082015-11-03 21:01:53 -0700136
137 echo "$log" > "$dedupe_tmpfile"
138
139 log=$(grep -Fxv -f "$LOGFILE" "$dedupe_tmpfile")
Martin Rothfb190ed2016-10-01 20:13:43 -0600140 commits=$(echo "$log" | wc -l)
Martin Rothbec11082015-11-03 21:01:53 -0700141
Martin Roth3ce67832017-11-04 18:36:19 -0600142 #echo "$title: $paths $keywords" >> "$LOGFILE"
143 printf "%s\n%s\n\n" "##### $title ($commits commits) #####" \
144 "$log" >> "$LOGFILE"
Martin Rothbec11082015-11-03 21:01:53 -0700145
146 rm "$dedupe_tmpfile"
147}
148
149# get logs for the submodules
150get_log_submodule() {
151 local old_version="$1"
152 local new_version="$2"
153 local submodule_dir="$3"
Martin Rothfb190ed2016-10-01 20:13:43 -0600154 local log
155 local commits
Martin Rothbec11082015-11-03 21:01:53 -0700156
157 printf "Submodule %s\n" "$submodule_dir"
158 printf "commit %s to commit %s\n\n" "$old_version" "$new_version"
159
Martin Roth3ce67832017-11-04 18:36:19 -0600160 (
161 cd "${TOP}/$submodule_dir"
162 log="$(_get_log "$old_version" "$new_version" "$submodule_dir" "." "")"
Martin Rothfb190ed2016-10-01 20:13:43 -0600163 commits=$(echo "$log" | wc -l)
Martin Rothbec11082015-11-03 21:01:53 -0700164
165 if [ -n "$log" ]; then
Martin Roth3ce67832017-11-04 18:36:19 -0600166 printf "%s\n" "$submodule_dir ($commits commits)" >> "$LOGFILE"
167 printf "\n" >> "$LOGFILE"
Martin Rothbec11082015-11-03 21:01:53 -0700168 fi
Martin Roth3ce67832017-11-04 18:36:19 -0600169 )
Martin Rothbec11082015-11-03 21:01:53 -0700170}
171
Martin Rothfb190ed2016-10-01 20:13:43 -0600172find_areas() {
Martin Roth3ce67832017-11-04 18:36:19 -0600173 local directory="$1"
174 local filename="$2"
175 local skip="$3"
176 find "$directory" -name "$filename" | sed "s|/$filename||" | sed "s|/$directory||" | grep -v "$skip" | sort
Martin Rothfb190ed2016-10-01 20:13:43 -0600177}
178
179# Make sure things get cleaned up if ctl-c is pressed while the old version
180# is checked out and files are renamed. This can be a real mess to clean
181# up manually.
Martin Rothbec11082015-11-03 21:01:53 -0700182version_ctrl_c() {
Martin Rothfb190ed2016-10-01 20:13:43 -0600183 printf "\n** Trapped CTRL-C\n Cleaning up and exiting.\n"
184 find 'src' -name 'gnumakefile' \
185 -exec rename 's/gnumakefile/Makefile\.inc/' {} \;
186 git checkout origin/master > /dev/null 2>&1
Martin Rothbec11082015-11-03 21:01:53 -0700187 git submodule update --init --checkout > /dev/null 2>&1
Martin Rothbec11082015-11-03 21:01:53 -0700188 rm "$LOGFILE"
189 exit 1;
190}
191
Martin Rothfb190ed2016-10-01 20:13:43 -0600192# Calculate areas that have been added or removed based on file lists
193show_diff () {
194 local new
195 local old
Martin Rothbec11082015-11-03 21:01:53 -0700196
Patrick Georgi1916d682019-11-20 16:05:21 +0100197 new="$(comm -13 <(echo "$2") <(echo "$3"))"
198 old="$(comm -23 <(echo "$2") <(echo "$3"))"
199
200 # Allow running a postprocessor, given as 4th argument over the
201 # resulting diff, provide context if it's old or new data
202 if [ -n "$4" ]; then
203 new=$(echo "$new" | $4 new | sort)
204 old=$(echo "$old" | $4 old | sort)
205 fi
206 new="$(printf "$new" | sed 's/^/* /')"
207 old="$(printf "$old" | sed 's/^/* /')"
208
Martin Rothfb190ed2016-10-01 20:13:43 -0600209 if [ -n "$new" ]; then
210 printf "Added %s $1:\n-------------------\n%s\n\n" \
211 "$(echo "$new" | wc -l)" "$new" >> "$LOGFILE"
212 fi
Martin Rothfb190ed2016-10-01 20:13:43 -0600213 if [ -n "$old" ]; then
214 printf "Removed %s $1:\n-------------------\n%s\n\n" \
215 "$(echo "$old" | wc -l)" "$old" >> "$LOGFILE"
216 fi
217}
218
Martin Roth3ce67832017-11-04 18:36:19 -0600219get_sloc () {
220 # Because cloc works on extensions, and .inc identifies as pascal,
Patrick Georgi436296b2019-11-20 17:15:13 +0100221 # while we use it both for Makefile.inc and some files that are
222 # really C, do three passes: everything but .inc files, all .inc files
223 # that aren't Makefiles, all Makefile.inc, then combine them.
Martin Roth3ce67832017-11-04 18:36:19 -0600224
Patrick Georgi436296b2019-11-20 17:15:13 +0100225 local base=`mktemp`
226 find src -name Makefile.inc > ${base}.mak
Martin Roth3ce67832017-11-04 18:36:19 -0600227
Patrick Georgi436296b2019-11-20 17:15:13 +0100228 cloc --progress-rate=0 --quiet \
229 --script-lang="Bourne Shell",bash --exclude-ext=inc \
230 --exclude-dir=vendorcode --out=${base} src
231 cloc --progress-rate=0 --quiet \
232 --exclude-list-file=${base}.mak --force-lang=c,inc \
233 --exclude-dir=vendorcode --out=${base}.c src
234 cloc --progress-rate=0 --quiet \
235 --list-file=${base}.mak --force-lang=make,inc \
236 --exclude-dir=vendorcode --out=${base}.m src
237 cloc --progress-rate=0 --quiet --sum-reports \
238 ${base} ${base}.c ${base}.m --out ${base}.result
239
240 echo
241 cat ${base}.result.lang
242
243 rm -f ${base}*
Martin Roth3ce67832017-11-04 18:36:19 -0600244}
245
Martin Rothfb190ed2016-10-01 20:13:43 -0600246# Start collecting data from the old and new revisions.
247# This is relatively disruptive to the tree, so trap on ctl-c so that
248# things can be put back to normal
249trap version_ctrl_c SIGINT
Martin Rothbec11082015-11-03 21:01:53 -0700250
251#check out old version and get information
252printf -- "Finding old submodule versions...\n"
Martin Rothfb190ed2016-10-01 20:13:43 -0600253git checkout "$OLD_GIT_VERSION" > /dev/null 2>&1
Martin Rothbec11082015-11-03 21:01:53 -0700254git submodule update --init --checkout > /dev/null 2>&1
Martin Roth3ce67832017-11-04 18:36:19 -0600255for module in $(git submodule --quiet foreach pwd); do
256 name="$(basename "$module" | sed 's/-/_/g')"
257 version="${name^^}_OLD_VERSION"
258 declare "$version"=$(get_latest_commit_id "$module")
259done
Martin Rothfb190ed2016-10-01 20:13:43 -0600260
Martin Roth3ce67832017-11-04 18:36:19 -0600261printf "Logging directories in the old tree\n"
262mainboard_list_old=$(grep -h "^[[:space:]]*config\>[[:space:]]*\<BOARD_" src/mainboard/*/*/Kconfig.name 2>/dev/null | sed "s,^.*\<BOARD_\([A-Z0-9_]*\)\>.*$,\1," | sort)
263cpu_list_old=$(find_areas "src/cpu" "Kconfig" "intel/common")
264soc_list_old=$(find_areas "src/soc" "Makefile.inc" "intel/common\|amd/common\|romstage")
265northbridge_list_old=$(find_areas "src/northbridge" "Kconfig" "")
266sio_list_old=$(find_areas "src/superio" "Makefile.inc" "")
267southbridge_list_old=$(find_areas "src/southbridge" "Kconfig" "")
Martin Rothfb190ed2016-10-01 20:13:43 -0600268
Martin Rothbec11082015-11-03 21:01:53 -0700269printf "Calculating old SLOC\n"
Martin Roth3ce67832017-11-04 18:36:19 -0600270OLD_SLOC=$(get_sloc)
Martin Rothbec11082015-11-03 21:01:53 -0700271
272#check out new version and get information
273printf -- "\nFinding new submodule versions...\n"
Martin Rothfb190ed2016-10-01 20:13:43 -0600274git checkout "$NEW_GIT_VERSION" > /dev/null 2>&1
Martin Rothbec11082015-11-03 21:01:53 -0700275git submodule update --init --checkout > /dev/null 2>&1
Martin Rothbec11082015-11-03 21:01:53 -0700276
Martin Roth3ce67832017-11-04 18:36:19 -0600277for module in $(git submodule --quiet foreach pwd); do
278 name="$(basename "$module" | sed 's/-/_/g')"
279 version="${name^^}_NEW_VERSION"
280 declare "$version"=$(get_latest_commit_id "$module")
281done
Martin Rothfb190ed2016-10-01 20:13:43 -0600282
Martin Roth3ce67832017-11-04 18:36:19 -0600283printf "Logging directories in the new tree\n"
284mainboard_list_new=$(grep -h "^[[:space:]]*config\>[[:space:]]*\<BOARD_" src/mainboard/*/*/Kconfig.name 2>/dev/null | sed "s,^.*\<BOARD_\([A-Z0-9_]*\)\>.*$,\1," | sort)
285cpu_list_new=$(find_areas "src/cpu" "Kconfig" "intel/common")
286soc_list_new=$(find_areas "src/soc" "Makefile.inc" "intel/common\|amd/common\|romstage")
287northbridge_list_new=$(find_areas "src/northbridge" "Kconfig" "")
288sio_list_new=$(find_areas "src/superio" "Makefile.inc" "")
289southbridge_list_new=$(find_areas "src/southbridge" "Kconfig" "")
290
Martin Rothfb190ed2016-10-01 20:13:43 -0600291printf "Calculating new SLOC\n"
Martin Roth3ce67832017-11-04 18:36:19 -0600292NEW_SLOC=$(get_sloc)
Martin Rothbec11082015-11-03 21:01:53 -0700293
294git checkout origin/master > /dev/null 2>&1
295git submodule update --init --checkout > /dev/null 2>&1
Martin Rothbec11082015-11-03 21:01:53 -0700296trap "" SIGINT
Martin Rothfb190ed2016-10-01 20:13:43 -0600297# Done collecting data from the old and new versions
Martin Rothbec11082015-11-03 21:01:53 -0700298
Martin Rothfb190ed2016-10-01 20:13:43 -0600299# Start outputting to logfile
300echo "Generating release notes from version ${OLD_GIT_VERSION} to ${NEW_GIT_VERSION}"
301echo; echo "Main repo"
302echo "Main repo" >> "$LOGFILE"
Martin Rothbec11082015-11-03 21:01:53 -0700303echo "------------------" >> "$LOGFILE"
Martin Rothfb190ed2016-10-01 20:13:43 -0600304log_versions "$(git log --pretty=%H \
305 "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | tail -1)" \
306 "$(git log --pretty=%H \
307 "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | head -1 )"
308echo "" >> "$LOGFILE"
Martin Rothbec11082015-11-03 21:01:53 -0700309
Martin Roth3ce67832017-11-04 18:36:19 -0600310### SPECIFIC AREAS FOR RELEASE ###
Patrick Georgi3b34ef22019-06-30 11:41:51 +0200311get_log_dedupe "cleanup" "" "spelling\|Use tabs\|transition away from device_t\|space [around\|before]\|code formatting\|commented code\|code cleanup\|capitalize\|unnecessary whitespace\|checkpatch\|remove unused\|remove.*not used"
Martin Rothbec11082015-11-03 21:01:53 -0700312
Martin Roth3ce67832017-11-04 18:36:19 -0600313get_log_dedupe "Google Kahlee / AMD Gardenia" "src/mainboard/google/kahlee src/mainboard/amd/gardenia" "kahlee\|gardenia"
314get_log_dedupe "AMD Stoney Ridge" "src/soc/amd/stoneyridge" "stoney"
Martin Rothbec11082015-11-03 21:01:53 -0700315
Martin Roth3ce67832017-11-04 18:36:19 -0600316get_log_dedupe "Google Eve / Poppy / Fizz / Soraka / Nautilus / Intel KblRvp" "src/mainboard/google/eve src/mainboard/google/poppy src/mainboard/google/fizz src/mainboard/intel/kblrvp" "eve[ :]\|poppy\|fizz\|soraka\|nautilus\|kblrvp"
317#get_log_dedupe "Intel Kunimitsu / Google Chell / Lars / Glados" "src/mainboard/google/lars src/mainboard/google/chell src/mainboard/google/glados src/mainboard/intel/kunimitsu" "chell\|lars\|kunimitsu"
318get_log_dedupe "Purism SKL" "src/mainboard/purism/librem_skl" "librem13v2\|librem_skl"
319get_log_dedupe "Intel Skylake / Kabylake" "src/soc/intel/skylake" "skylake\|sky.lake\|kabylake\|kaby.lake"
Martin Rothbec11082015-11-03 21:01:53 -0700320
Martin Roth3ce67832017-11-04 18:36:19 -0600321get_log_dedupe "Google Cyan / Intel Strago" "src/mainboard/google/cyan src/mainboard/intel/strago" "cyan\|strago"
322get_log_dedupe "Intel Braswell" "src/soc/intel/braswell" "braswell"
Martin Rothbec11082015-11-03 21:01:53 -0700323
Martin Roth3ce67832017-11-04 18:36:19 -0600324get_log_dedupe "Google Kevin / Gru / Bob / Scarlet / Nefario" "src/mainboard/google/gru" "kevin\|gru[^b]"
325get_log_dedupe "Rockchip rk3399" "src/soc/rockchip/rk3399" "rk3399"
Martin Rothbec11082015-11-03 21:01:53 -0700326
Martin Roth3ce67832017-11-04 18:36:19 -0600327get_log_dedupe "Google Reef / Pyro / Sand / Snappy / Nasher" "src/mainboard/google/reef" "reef\|pyro\|sand[ :]\|snappy\|nasher"
328#get_log_dedupe "Intel apollolake_rvp leafhill minnow3" "src/mainboard/intel/apollolake_rvp src/mainboard/intel/leafhill src/mainboard/intel/minnow3" "apollolake_rvp\|leafhill\|minnow3"
329get_log_dedupe "Siemens mc_apl1" "src/mainboard/siemens/mc_apl1" "mc_apl1"
330get_log_dedupe "Intel Apollolake" "src/soc/intel/apollolake" "apollolake\|apollo.lake"
Martin Rothbec11082015-11-03 21:01:53 -0700331
Martin Roth3ce67832017-11-04 18:36:19 -0600332get_log_dedupe "Intel CannonLake" "src/soc/intel/cannonlake src/mainboard/intel/cannonlake_rvp" "cannonlake"
Martin Rothfb190ed2016-10-01 20:13:43 -0600333
Martin Roth3ce67832017-11-04 18:36:19 -0600334get_log_dedupe "Intel Galileo" "src/mainboard/intel/galileo" "galileo"
335get_log_dedupe "Intel Quark" "src/soc/intel/quark" "quark"
Martin Rothfb190ed2016-10-01 20:13:43 -0600336
Martin Roth3ce67832017-11-04 18:36:19 -0600337get_log_dedupe "Intel Baytrail" "src/soc/intel/baytrail" "baytrail"
338#get_log_dedupe "Google Gale / Qualcomm QX ipq40xx" "src/mainboard/google/gale src/soc/qualcomm/ipq40xx" "gale\|ipq40"
339#et_log_dedupe "Google Rotor / Marvell Mvmap2315" "src/soc/marvell/mvmap2315 src/mainboard/google/rotor" "marvell\|mvmap\|rotor"
Martin Rothfb190ed2016-10-01 20:13:43 -0600340
Martin Roth3ce67832017-11-04 18:36:19 -0600341get_log_dedupe "Gigabyte ga-g41m-es2l" "src/mainboard/gigabyte/ga-g41m-es2l" "es2l"
342get_log_dedupe "Intel x4x northbridge / LGA775" "src/northbridge/intel/x4x src/cpu/intel/socket_LGA775" "x4x\|lga775"
Martin Rothfb190ed2016-10-01 20:13:43 -0600343
Martin Roth3ce67832017-11-04 18:36:19 -0600344get_log_dedupe "Intel Sandybridge / Ivybridge" "src/southbridge/intel/bd82x6x src/southbridge/intel/fsp_bd82x6x src/northbridge/intel/sandybridge src/northbridge/intel/fsp_sandybridge src/cpu/intel/fsp_model_206ax src/cpu/intel/model_206ax" "sandybridge\|ivybridge\|bd82x6x"
Martin Rothfb190ed2016-10-01 20:13:43 -0600345
Martin Roth3ce67832017-11-04 18:36:19 -0600346get_log_dedupe "Intel Common" "src/soc/intel/common src/southbridge/intel/common src/northbridge/intel/common" ""
347get_log_dedupe "Amd Common" "src/soc/amd/common src/southbridge/amd/common" ""
348
Patrick Georgi3b34ef22019-06-30 11:41:51 +0200349get_log_dedupe "Nvidia" "src/southbridge/nvidia" ""
350get_log_dedupe "Via" "src/northbridge/via src/southbridge/via" ""
351get_log_dedupe "Broadcom" "src/southbridge/broadcom" ""
352get_log_dedupe "Qualcomm" "src/soc/qualcomm" ""
353
Martin Roth3ce67832017-11-04 18:36:19 -0600354get_log_dedupe "Intel vendorcode / FSP" "src/drivers/intel/fsp* src/vendorcode/intel" ""
355get_log_dedupe "AMD vendorcode / AGESA / PI" "src/vendorcode/amd" ""
356get_log_dedupe "Google vendorcode" "src/vendorcode/google"
357
Patrick Georgi3b34ef22019-06-30 11:41:51 +0200358get_log_dedupe "TPM" "src/drivers/i2c/tpm src/security/tpm" "tpm"
Martin Roth3ce67832017-11-04 18:36:19 -0600359get_log_dedupe "Vboot" "src/vboot" "vboot"
360
361
362### GENERAL AREAS FOR RELEASE ###
363# shellcheck disable=SC2013
364{
365get_log_dedupe "ARM" \
366 "$(for codedir in $(grep -rl "_ARM" --include=Kconfig | \
367 grep -v 'src/mainboard\|payloads/\|drivers/\|vendorcode/\|console' ); \
368 do dirname "$codedir"; done | grep -v '^src$')"
369
370get_log_dedupe "RISC-V" \
371 "$(for codedir in $(grep -rl "_RISCV" --include=Kconfig | grep -v 'payloads/\|drivers/\|vendorcode/\|console' ); do dirname "$codedir"; done | grep -v '^src$')" \
Jonathan Neuschäferce8763f2018-09-20 23:52:43 +0200372 "riscv\|risc-v\|sifive"
Martin Roth3ce67832017-11-04 18:36:19 -0600373}
374
375get_log_dedupe "X86 intel" \
376 "src/cpu/intel src/soc/intel src/northbridge/intel \
377 src/southbridge/intel src/include/intel src/drivers/intel"
378
379get_log_dedupe "X86 amd" \
380 "src/cpu/amd src/northbridge/amd src/southbridge/amd src/include/amd src/soc/amd" \
381 "agesa\|binarypi\|binary.pi"
382
383get_log_dedupe "X86 common" \
384 "src/arch/x86 src/cpu/x86 src/include/x86 src/include/pc80"
385
386get_log_dedupe "Mainboards" "src/mainboard/"
387
388# Next, print all the rest of the specific areas
389get_log_dedupe "ACPI" "src/acpi/"
390get_log_dedupe "Console" "src/console src/include/console"
391get_log_dedupe "SuperIO" "src/superio src/include/superio"
392get_log_dedupe "EC" "src/ec"
393get_log_dedupe "Drivers" "src/drivers"
394get_log_dedupe "Devices" "src/device src/include/device"
395
396# 5th, print the generic areas - This goes late so that the specific
397# area changes will catch any commits in these areas first.
398get_log_dedupe "Toolchain" "util/crossgcc"
399get_log_dedupe "cbfstool" "util/cbfstool"
400get_log_dedupe "Lint tools" "util/lint"
401get_log_dedupe "Lib" "src/lib"
402get_log_dedupe "Commonlib" "src/commonlib"
403get_log_dedupe "Include" "src/include"
404get_log_dedupe "Utilities" "util"
405get_log_dedupe "Payloads" "payloads"
406get_log_dedupe "Vendorcode" "src/vendorcode"
407get_log_dedupe "Documentation" "Documentation README"
408
409# Then look at areas that are usually outside the mainboards and architectures
410get_log_dedupe "Build system" \
411 "Makefile Makefile.inc toolchain.inc src/Kconfig src/cpu/Makefile.inc"
412
413get_log_dedupe "Submodules" "3rdparty util/nvidia/cbootimage"
Patrick Georgi3b34ef22019-06-30 11:41:51 +0200414
415get_log_dedupe "Maintainers" "MAINTAINERS" ""
416
Martin Roth3ce67832017-11-04 18:36:19 -0600417# Finally, get anything that was missed above
418get_log_dedupe "MISC" "."
419
Patrick Georgi1916d682019-11-20 16:05:21 +0100420# Replace VENDOR_DEVICE from stdin with their nice names on stdout
421real_mainboard_names() {
422 local tree_version=$1 # "old" or "new"
423 local git_version_var=${tree_version^^}_GIT_VERSION
424 local git_version=${!git_version_var}
425 local line
426
427 while read line; do
428 local file="$(git grep -l "^[[:space:]]*config\>[[:space:]]*\<BOARD_${line}\$" ${git_version} -- src/mainboard/\*/\*/Kconfig.name | sed "s,^${git_version}:,,")"
429 if [ -z "$file" ]; then
430 echo "This shouldn't happen: couldn't find Kconfig for $line"
431 exit 1
432 fi
433 local vendor="$(git grep \" ${git_version} -- $(echo ${file} | cut -d/ -f1-3,5) | cut -d\" -f2)"
434 git grep -h -A1 "^[[:space:]]*config\>[[:space:]]*\<BOARD_${line}\$" ${git_version} -- ${file} | grep \" |cut -d\" -f2 |sed "s,^,${vendor} ,"
435 done
436}
437
Martin Roth3ce67832017-11-04 18:36:19 -0600438# Show areas that have been added or removed
Patrick Georgi1916d682019-11-20 16:05:21 +0100439show_diff "mainboards" "$mainboard_list_old" "$mainboard_list_new" real_mainboard_names
Martin Roth3ce67832017-11-04 18:36:19 -0600440show_diff "processors" "$cpu_list_old" "$cpu_list_new"
441show_diff "socs" "$soc_list_old" "$soc_list_new"
442show_diff "northbridges" "$northbridge_list_old" "$northbridge_list_new"
443show_diff "southbridges" "$southbridge_list_old" "$southbridge_list_new"
444show_diff "sios" "$sio_list_old" "$sio_list_new"
445
446# Log submodules
447printf "Submodules\n----------\n" >> "$LOGFILE"
448for module in $(git submodule --quiet foreach pwd); do
449 name=$(basename "$module")
450 # shellcheck disable=SC2001
Patrick Georgi250f01e2018-12-20 17:25:50 +0100451 path=${module#$PWD}
Martin Roth3ce67832017-11-04 18:36:19 -0600452 old_version=$(echo "${name^^}_OLD_VERSION" | sed 's/-/_/g')
453 new_version=$(echo "${name^^}_NEW_VERSION" | sed 's/-/_/g')
454 get_log_submodule "${!old_version}" "${!new_version}" "$path"
455done
Martin Rothbec11082015-11-03 21:01:53 -0700456
Martin Rothfb190ed2016-10-01 20:13:43 -0600457printf "\nrepo statistics\n-------------------\n" >> "$LOGFILE"
458before_names="$(mktemp "OLDNAMES.XXXX")"
459after_names="$(mktemp "NEWNAMES.XXXX")"
460NEW_AUTHORS=$(git log --pretty=%an "${OLD_GIT_VERSION}" 2>/dev/null | sort | \
461 uniq > "$before_names" && \
462 git log --pretty=%an "${NEW_GIT_VERSION}" 2>/dev/null | \
463 sort | uniq > "$after_names" && \
464 grep -Fxv -c -f "$before_names" "$after_names")
Patrick Georgid653e492019-11-20 16:49:41 +0100465NEW_AUTHOR_LIST=$( grep -Fxv -f "$before_names" "$after_names")
466rm -f "$before_names" "$after_names"
Martin Rothfb190ed2016-10-01 20:13:43 -0600467{
468 printf -- "- Total commits: %s\n" "$TOTAL_COMMITS"
469 printf -- "- Total authors: %s\n" \
470 "$(git log "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | \
471 grep -e '^Author:' | sed 's/.*Author: //' | sed 's/ <.*.>//' | \
472 sort | uniq | wc -l)"
473 printf -- "- New authors: %s\n\nNew Authors:\n%s\n" "$NEW_AUTHORS" \
474 "$NEW_AUTHOR_LIST"
475} >> "$LOGFILE"
Martin Rothbec11082015-11-03 21:01:53 -0700476
Martin Rothfb190ed2016-10-01 20:13:43 -0600477printf "Getting developer list\n"
478printf "\n%-40s: %5s\n" "Developer" "Commits" >> "$LOGFILE"
479git log "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | grep '^Author: ' | \
480 sed 's|Author: ||' | sed 's|\s<.*||' | sort | uniq | \
481 while read -r line; do
482 printf "%-40s: %5s %5s\n" "$line" \
483 "$(git log "${OLD_GIT_VERSION}" 2>/dev/null | \
484 grep -c "^Author: ${line} <")" \
485 "$(git log "${NEW_GIT_VERSION}" 2>/dev/null | \
486 grep -c "^Author: ${line} <")" >> "$LOGFILE";
487 done
Martin Rothbec11082015-11-03 21:01:53 -0700488
489printf "\nOld SLOC (%s)\n%s" "$NOW" "$OLD_SLOC" >> "$LOGFILE"
490printf "\nNew SLOC (%s)\n%s" "$NOW" "$NEW_SLOC" >> "$LOGFILE"
491
492# Add the collected data to the top of the existing logfile for parsing
493if [ -n "$UPDATE_MAIN_LOGFILE" ]; then
494 tmpfile="$(mktemp "LOGFILE.XXXX")"
495 grep -Fxv -f "$MAIN_LOGFILE" "$LOGFILE" > "$tmpfile"
496 printf "\n\n" >> "$tmpfile"
497 cat "$MAIN_LOGFILE" >> "$tmpfile"
498 mv "$tmpfile" "$MAIN_LOGFILE"
499 rm -f "$LOGFILE"
500fi
Martin Rothfb190ed2016-10-01 20:13:43 -0600501
502printf "Done.\n"