Yegor Timoshenko | c2e4941 | 2018-10-07 01:58:27 +0000 | [diff] [blame] | 1 | #!/usr/bin/env bash |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 2 | # |
| 3 | # This file is part of the coreboot project. |
| 4 | # |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 5 | # Copyright 2015-2016 Google Inc. |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 6 | # |
| 7 | # This program is free software; you can redistribute it and/or modify |
| 8 | # it under the terms of the GNU General Public License as published by |
| 9 | # the Free Software Foundation; version 2 of the License. |
| 10 | # |
| 11 | # This program is distributed in the hope that it will be useful, |
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | # GNU General Public License for more details. |
| 15 | |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 16 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 17 | # This script creates a list of commits between two releases, broken out into |
| 18 | # fairly inexact categories, based on the directories that files are in. If |
| 19 | # a commit touched anything in the path that is checked earlier, it's counted |
| 20 | # as being in that category. |
| 21 | # |
| 22 | # Don't run this in your current working tree, it checks out different versions |
| 23 | # and can lose things. |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 24 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 25 | # set -x # uncomment for debug |
| 26 | |
| 27 | # Check for tools |
| 28 | |
Patrick Georgi | fa13a64 | 2018-12-20 17:17:03 +0100 | [diff] [blame] | 29 | if ! ( git --version && cloc --version && rename --version ) > /dev/null 2>&1 |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 30 | then |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 31 | echo "ERROR: cloc or git is not installed. Exiting" |
| 32 | exit 1 |
| 33 | fi |
| 34 | |
Alex Thiessen | da384dd | 2018-01-13 16:31:28 +0000 | [diff] [blame] | 35 | if ! { cdup="$(git rev-parse --show-cdup 2>/dev/null)" && [ -z "${cdup}" ]; } |
| 36 | then |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 37 | echo "ERROR: This is not the top directory of a git repo. Exiting." |
| 38 | exit 1 |
| 39 | fi |
| 40 | |
| 41 | # Try to verify that the repo is clean before losing state. |
Patrick Georgi | 35c8dcf | 2018-12-20 17:17:55 +0100 | [diff] [blame] | 42 | if ! git diff-index --quiet --cached HEAD 2>/dev/null; then |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 43 | echo "ERROR: repo is not clean. Exiting." |
| 44 | exit 1 |
| 45 | fi |
| 46 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 47 | # Verify the command line arguments |
| 48 | if [ "$1" == "--help" ] || [ -z "$1" ] || [ -z "$2" ]; then |
| 49 | echo |
| 50 | echo "Usage: $0 <old_version> <new_version> [release notes file]" |
| 51 | echo "Old version should be a tag (4.1), a branch (origin/4.1), or a commit id" |
| 52 | echo "New version can be 'HEAD' a branch (origin/master) a tag (4.2), or a commit id" |
| 53 | echo "Logfile can be a new file or an existing file to update" |
| 54 | echo "Example: \"$0 origin/4.1 4.2 rnotes.txt\"" |
| 55 | echo |
| 56 | echo "Note that the script starts at the commit AFTER the old version." |
| 57 | echo |
| 58 | exit 1 |
| 59 | else |
| 60 | OLD_GIT_VERSION="$1" |
| 61 | NEW_GIT_VERSION="$2" |
| 62 | TOTAL_COMMITS=$(git log --pretty=oneline \ |
| 63 | "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | wc -l) |
| 64 | fi |
| 65 | |
| 66 | TOP=$(pwd) |
| 67 | |
| 68 | if [ -n "$3" ]; then |
| 69 | MAIN_LOGFILE="${TOP}/$3" |
| 70 | else |
| 71 | MAIN_LOGFILE="${TOP}/relnotes.txt" |
| 72 | fi |
| 73 | |
| 74 | # Figure out which logfile we're writing to. If the specified logfile exists, |
| 75 | # we need to write to a temporary logfile, then append changes to the main |
| 76 | # logfile. |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 77 | if [ -f "$MAIN_LOGFILE" ]; then |
| 78 | LOGFILE="$(mktemp "LOGFILE.XXXX")" |
| 79 | LOGFILE="${TOP}/$LOGFILE" |
| 80 | UPDATE_MAIN_LOGFILE=1 |
| 81 | else |
| 82 | LOGFILE="$MAIN_LOGFILE" |
| 83 | fi |
| 84 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 85 | get_author_commit_count() { |
| 86 | git log "${NEW_GIT_VERSION}" 2>/dev/null | grep -c "^Author: $1" |
| 87 | } |
| 88 | |
| 89 | # Print and log the versions |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 90 | log_versions() { |
| 91 | echo "Log of commit $1 to commit $2" |
| 92 | echo "Log of commit $1 to commit $2" >> "$LOGFILE" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 93 | echo "Total commits: ${TOTAL_COMMITS}" |
| 94 | echo "Total commits: ${TOTAL_COMMITS}" >> "$LOGFILE" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 95 | echo |
| 96 | } |
| 97 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 98 | # Get the first commit id in the current tree |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 99 | get_latest_commit_id() { |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 100 | ( |
| 101 | cd "$1" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 102 | git log 2>/dev/null | grep '^commit ' | head -1 | sed 's/commit //' |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 103 | ) |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 104 | } |
| 105 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 106 | # Main get log function |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 107 | _get_log() { |
| 108 | local oldver="$1" |
| 109 | local newver="$2" |
| 110 | local title="$3" |
| 111 | local paths="$4" |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 112 | local keywords="$5" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 113 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 114 | # Leave ${paths} unquoted in the git commands |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 115 | # shellcheck disable=SC2086 |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 116 | { \ |
| 117 | if [ -n "$paths" ]; then \ |
| 118 | git log --abbrev-commit --pretty=oneline \ |
| 119 | "${oldver}..${newver}" -- ${paths} \ |
| 120 | 2>/dev/null; \ |
| 121 | fi; \ |
| 122 | if [ -n "$keywords" ]; then \ |
| 123 | git log --abbrev-commit --pretty=oneline \ |
| 124 | "${oldver}..${newver}" 2>/dev/null \ |
| 125 | | grep -i "$keywords"; \ |
| 126 | fi \ |
| 127 | } | sort -t ' ' -k 2 | uniq |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 128 | } |
| 129 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 130 | # Output to a new log, then compare to the first logfile, and only output |
| 131 | # non duplicated lines to the final file. |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 132 | get_log_dedupe() { |
| 133 | local title="$1" |
| 134 | local paths="$2" |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 135 | local keywords="$3" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 136 | local log |
| 137 | local commits |
| 138 | |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 139 | dedupe_tmpfile="$(mktemp "LOGFILE.XXXX")" |
| 140 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 141 | log=$(_get_log "$OLD_GIT_VERSION" "$NEW_GIT_VERSION" \ |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 142 | "$title" "$paths" "$keywords") |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 143 | |
| 144 | echo "$log" > "$dedupe_tmpfile" |
| 145 | |
| 146 | log=$(grep -Fxv -f "$LOGFILE" "$dedupe_tmpfile") |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 147 | commits=$(echo "$log" | wc -l) |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 148 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 149 | #echo "$title: $paths $keywords" >> "$LOGFILE" |
| 150 | printf "%s\n%s\n\n" "##### $title ($commits commits) #####" \ |
| 151 | "$log" >> "$LOGFILE" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 152 | |
| 153 | rm "$dedupe_tmpfile" |
| 154 | } |
| 155 | |
| 156 | # get logs for the submodules |
| 157 | get_log_submodule() { |
| 158 | local old_version="$1" |
| 159 | local new_version="$2" |
| 160 | local submodule_dir="$3" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 161 | local log |
| 162 | local commits |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 163 | |
| 164 | printf "Submodule %s\n" "$submodule_dir" |
| 165 | printf "commit %s to commit %s\n\n" "$old_version" "$new_version" |
| 166 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 167 | ( |
| 168 | cd "${TOP}/$submodule_dir" |
| 169 | log="$(_get_log "$old_version" "$new_version" "$submodule_dir" "." "")" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 170 | commits=$(echo "$log" | wc -l) |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 171 | |
| 172 | if [ -n "$log" ]; then |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 173 | printf "%s\n" "$submodule_dir ($commits commits)" >> "$LOGFILE" |
| 174 | printf "\n" >> "$LOGFILE" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 175 | fi |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 176 | ) |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 177 | } |
| 178 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 179 | find_areas() { |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 180 | local directory="$1" |
| 181 | local filename="$2" |
| 182 | local skip="$3" |
| 183 | find "$directory" -name "$filename" | sed "s|/$filename||" | sed "s|/$directory||" | grep -v "$skip" | sort |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | # Make sure things get cleaned up if ctl-c is pressed while the old version |
| 187 | # is checked out and files are renamed. This can be a real mess to clean |
| 188 | # up manually. |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 189 | version_ctrl_c() { |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 190 | printf "\n** Trapped CTRL-C\n Cleaning up and exiting.\n" |
| 191 | find 'src' -name 'gnumakefile' \ |
| 192 | -exec rename 's/gnumakefile/Makefile\.inc/' {} \; |
| 193 | git checkout origin/master > /dev/null 2>&1 |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 194 | git submodule update --init --checkout > /dev/null 2>&1 |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 195 | rm "$LOGFILE" |
| 196 | exit 1; |
| 197 | } |
| 198 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 199 | # Calculate areas that have been added or removed based on file lists |
| 200 | show_diff () { |
| 201 | local new |
| 202 | local old |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 203 | |
Patrick Georgi | 1916d68 | 2019-11-20 16:05:21 +0100 | [diff] [blame] | 204 | new="$(comm -13 <(echo "$2") <(echo "$3"))" |
| 205 | old="$(comm -23 <(echo "$2") <(echo "$3"))" |
| 206 | |
| 207 | # Allow running a postprocessor, given as 4th argument over the |
| 208 | # resulting diff, provide context if it's old or new data |
| 209 | if [ -n "$4" ]; then |
| 210 | new=$(echo "$new" | $4 new | sort) |
| 211 | old=$(echo "$old" | $4 old | sort) |
| 212 | fi |
| 213 | new="$(printf "$new" | sed 's/^/* /')" |
| 214 | old="$(printf "$old" | sed 's/^/* /')" |
| 215 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 216 | if [ -n "$new" ]; then |
| 217 | printf "Added %s $1:\n-------------------\n%s\n\n" \ |
| 218 | "$(echo "$new" | wc -l)" "$new" >> "$LOGFILE" |
| 219 | fi |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 220 | if [ -n "$old" ]; then |
| 221 | printf "Removed %s $1:\n-------------------\n%s\n\n" \ |
| 222 | "$(echo "$old" | wc -l)" "$old" >> "$LOGFILE" |
| 223 | fi |
| 224 | } |
| 225 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 226 | get_sloc () { |
| 227 | # Because cloc works on extensions, and .inc identifies as pascal, |
Patrick Georgi | 436296b | 2019-11-20 17:15:13 +0100 | [diff] [blame] | 228 | # while we use it both for Makefile.inc and some files that are |
| 229 | # really C, do three passes: everything but .inc files, all .inc files |
| 230 | # that aren't Makefiles, all Makefile.inc, then combine them. |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 231 | |
Patrick Georgi | 436296b | 2019-11-20 17:15:13 +0100 | [diff] [blame] | 232 | local base=`mktemp` |
| 233 | find src -name Makefile.inc > ${base}.mak |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 234 | |
Patrick Georgi | 436296b | 2019-11-20 17:15:13 +0100 | [diff] [blame] | 235 | cloc --progress-rate=0 --quiet \ |
| 236 | --script-lang="Bourne Shell",bash --exclude-ext=inc \ |
| 237 | --exclude-dir=vendorcode --out=${base} src |
| 238 | cloc --progress-rate=0 --quiet \ |
| 239 | --exclude-list-file=${base}.mak --force-lang=c,inc \ |
| 240 | --exclude-dir=vendorcode --out=${base}.c src |
| 241 | cloc --progress-rate=0 --quiet \ |
| 242 | --list-file=${base}.mak --force-lang=make,inc \ |
| 243 | --exclude-dir=vendorcode --out=${base}.m src |
| 244 | cloc --progress-rate=0 --quiet --sum-reports \ |
| 245 | ${base} ${base}.c ${base}.m --out ${base}.result |
| 246 | |
| 247 | echo |
| 248 | cat ${base}.result.lang |
| 249 | |
| 250 | rm -f ${base}* |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 251 | } |
| 252 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 253 | # Start collecting data from the old and new revisions. |
| 254 | # This is relatively disruptive to the tree, so trap on ctl-c so that |
| 255 | # things can be put back to normal |
| 256 | trap version_ctrl_c SIGINT |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 257 | |
| 258 | #check out old version and get information |
| 259 | printf -- "Finding old submodule versions...\n" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 260 | git checkout "$OLD_GIT_VERSION" > /dev/null 2>&1 |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 261 | git submodule update --init --checkout > /dev/null 2>&1 |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 262 | for module in $(git submodule --quiet foreach pwd); do |
| 263 | name="$(basename "$module" | sed 's/-/_/g')" |
| 264 | version="${name^^}_OLD_VERSION" |
| 265 | declare "$version"=$(get_latest_commit_id "$module") |
| 266 | done |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 267 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 268 | printf "Logging directories in the old tree\n" |
| 269 | mainboard_list_old=$(grep -h "^[[:space:]]*config\>[[:space:]]*\<BOARD_" src/mainboard/*/*/Kconfig.name 2>/dev/null | sed "s,^.*\<BOARD_\([A-Z0-9_]*\)\>.*$,\1," | sort) |
| 270 | cpu_list_old=$(find_areas "src/cpu" "Kconfig" "intel/common") |
| 271 | soc_list_old=$(find_areas "src/soc" "Makefile.inc" "intel/common\|amd/common\|romstage") |
| 272 | northbridge_list_old=$(find_areas "src/northbridge" "Kconfig" "") |
| 273 | sio_list_old=$(find_areas "src/superio" "Makefile.inc" "") |
| 274 | southbridge_list_old=$(find_areas "src/southbridge" "Kconfig" "") |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 275 | |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 276 | printf "Calculating old SLOC\n" |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 277 | OLD_SLOC=$(get_sloc) |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 278 | |
| 279 | #check out new version and get information |
| 280 | printf -- "\nFinding new submodule versions...\n" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 281 | git checkout "$NEW_GIT_VERSION" > /dev/null 2>&1 |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 282 | git submodule update --init --checkout > /dev/null 2>&1 |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 283 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 284 | for module in $(git submodule --quiet foreach pwd); do |
| 285 | name="$(basename "$module" | sed 's/-/_/g')" |
| 286 | version="${name^^}_NEW_VERSION" |
| 287 | declare "$version"=$(get_latest_commit_id "$module") |
| 288 | done |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 289 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 290 | printf "Logging directories in the new tree\n" |
| 291 | mainboard_list_new=$(grep -h "^[[:space:]]*config\>[[:space:]]*\<BOARD_" src/mainboard/*/*/Kconfig.name 2>/dev/null | sed "s,^.*\<BOARD_\([A-Z0-9_]*\)\>.*$,\1," | sort) |
| 292 | cpu_list_new=$(find_areas "src/cpu" "Kconfig" "intel/common") |
| 293 | soc_list_new=$(find_areas "src/soc" "Makefile.inc" "intel/common\|amd/common\|romstage") |
| 294 | northbridge_list_new=$(find_areas "src/northbridge" "Kconfig" "") |
| 295 | sio_list_new=$(find_areas "src/superio" "Makefile.inc" "") |
| 296 | southbridge_list_new=$(find_areas "src/southbridge" "Kconfig" "") |
| 297 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 298 | printf "Calculating new SLOC\n" |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 299 | NEW_SLOC=$(get_sloc) |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 300 | |
| 301 | git checkout origin/master > /dev/null 2>&1 |
| 302 | git submodule update --init --checkout > /dev/null 2>&1 |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 303 | trap "" SIGINT |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 304 | # Done collecting data from the old and new versions |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 305 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 306 | # Start outputting to logfile |
| 307 | echo "Generating release notes from version ${OLD_GIT_VERSION} to ${NEW_GIT_VERSION}" |
| 308 | echo; echo "Main repo" |
| 309 | echo "Main repo" >> "$LOGFILE" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 310 | echo "------------------" >> "$LOGFILE" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 311 | log_versions "$(git log --pretty=%H \ |
| 312 | "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | tail -1)" \ |
| 313 | "$(git log --pretty=%H \ |
| 314 | "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | head -1 )" |
| 315 | echo "" >> "$LOGFILE" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 316 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 317 | ### SPECIFIC AREAS FOR RELEASE ### |
Patrick Georgi | 3b34ef2 | 2019-06-30 11:41:51 +0200 | [diff] [blame] | 318 | get_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 Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 319 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 320 | get_log_dedupe "Google Kahlee / AMD Gardenia" "src/mainboard/google/kahlee src/mainboard/amd/gardenia" "kahlee\|gardenia" |
| 321 | get_log_dedupe "AMD Stoney Ridge" "src/soc/amd/stoneyridge" "stoney" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 322 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 323 | get_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" |
| 324 | #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" |
| 325 | get_log_dedupe "Purism SKL" "src/mainboard/purism/librem_skl" "librem13v2\|librem_skl" |
| 326 | get_log_dedupe "Intel Skylake / Kabylake" "src/soc/intel/skylake" "skylake\|sky.lake\|kabylake\|kaby.lake" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 327 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 328 | get_log_dedupe "Google Cyan / Intel Strago" "src/mainboard/google/cyan src/mainboard/intel/strago" "cyan\|strago" |
| 329 | get_log_dedupe "Intel Braswell" "src/soc/intel/braswell" "braswell" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 330 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 331 | get_log_dedupe "Google Kevin / Gru / Bob / Scarlet / Nefario" "src/mainboard/google/gru" "kevin\|gru[^b]" |
| 332 | get_log_dedupe "Rockchip rk3399" "src/soc/rockchip/rk3399" "rk3399" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 333 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 334 | get_log_dedupe "Google Reef / Pyro / Sand / Snappy / Nasher" "src/mainboard/google/reef" "reef\|pyro\|sand[ :]\|snappy\|nasher" |
| 335 | #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" |
| 336 | get_log_dedupe "Siemens mc_apl1" "src/mainboard/siemens/mc_apl1" "mc_apl1" |
| 337 | get_log_dedupe "Intel Apollolake" "src/soc/intel/apollolake" "apollolake\|apollo.lake" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 338 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 339 | get_log_dedupe "Intel CannonLake" "src/soc/intel/cannonlake src/mainboard/intel/cannonlake_rvp" "cannonlake" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 340 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 341 | get_log_dedupe "Intel Galileo" "src/mainboard/intel/galileo" "galileo" |
| 342 | get_log_dedupe "Intel Quark" "src/soc/intel/quark" "quark" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 343 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 344 | get_log_dedupe "Intel Baytrail" "src/soc/intel/baytrail" "baytrail" |
| 345 | #get_log_dedupe "Google Gale / Qualcomm QX ipq40xx" "src/mainboard/google/gale src/soc/qualcomm/ipq40xx" "gale\|ipq40" |
| 346 | #et_log_dedupe "Google Rotor / Marvell Mvmap2315" "src/soc/marvell/mvmap2315 src/mainboard/google/rotor" "marvell\|mvmap\|rotor" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 347 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 348 | get_log_dedupe "Gigabyte ga-g41m-es2l" "src/mainboard/gigabyte/ga-g41m-es2l" "es2l" |
| 349 | get_log_dedupe "Intel x4x northbridge / LGA775" "src/northbridge/intel/x4x src/cpu/intel/socket_LGA775" "x4x\|lga775" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 350 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 351 | get_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 Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 352 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 353 | get_log_dedupe "Intel Common" "src/soc/intel/common src/southbridge/intel/common src/northbridge/intel/common" "" |
| 354 | get_log_dedupe "Amd Common" "src/soc/amd/common src/southbridge/amd/common" "" |
| 355 | |
Patrick Georgi | 3b34ef2 | 2019-06-30 11:41:51 +0200 | [diff] [blame] | 356 | get_log_dedupe "Nvidia" "src/southbridge/nvidia" "" |
| 357 | get_log_dedupe "Via" "src/northbridge/via src/southbridge/via" "" |
| 358 | get_log_dedupe "Broadcom" "src/southbridge/broadcom" "" |
| 359 | get_log_dedupe "Qualcomm" "src/soc/qualcomm" "" |
| 360 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 361 | get_log_dedupe "Intel vendorcode / FSP" "src/drivers/intel/fsp* src/vendorcode/intel" "" |
| 362 | get_log_dedupe "AMD vendorcode / AGESA / PI" "src/vendorcode/amd" "" |
| 363 | get_log_dedupe "Google vendorcode" "src/vendorcode/google" |
| 364 | |
Patrick Georgi | 3b34ef2 | 2019-06-30 11:41:51 +0200 | [diff] [blame] | 365 | get_log_dedupe "TPM" "src/drivers/i2c/tpm src/security/tpm" "tpm" |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 366 | get_log_dedupe "Vboot" "src/vboot" "vboot" |
| 367 | |
| 368 | |
| 369 | ### GENERAL AREAS FOR RELEASE ### |
| 370 | # shellcheck disable=SC2013 |
| 371 | { |
| 372 | get_log_dedupe "ARM" \ |
| 373 | "$(for codedir in $(grep -rl "_ARM" --include=Kconfig | \ |
| 374 | grep -v 'src/mainboard\|payloads/\|drivers/\|vendorcode/\|console' ); \ |
| 375 | do dirname "$codedir"; done | grep -v '^src$')" |
| 376 | |
| 377 | get_log_dedupe "RISC-V" \ |
| 378 | "$(for codedir in $(grep -rl "_RISCV" --include=Kconfig | grep -v 'payloads/\|drivers/\|vendorcode/\|console' ); do dirname "$codedir"; done | grep -v '^src$')" \ |
Jonathan Neuschäfer | ce8763f | 2018-09-20 23:52:43 +0200 | [diff] [blame] | 379 | "riscv\|risc-v\|sifive" |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 380 | } |
| 381 | |
| 382 | get_log_dedupe "X86 intel" \ |
| 383 | "src/cpu/intel src/soc/intel src/northbridge/intel \ |
| 384 | src/southbridge/intel src/include/intel src/drivers/intel" |
| 385 | |
| 386 | get_log_dedupe "X86 amd" \ |
| 387 | "src/cpu/amd src/northbridge/amd src/southbridge/amd src/include/amd src/soc/amd" \ |
| 388 | "agesa\|binarypi\|binary.pi" |
| 389 | |
| 390 | get_log_dedupe "X86 common" \ |
| 391 | "src/arch/x86 src/cpu/x86 src/include/x86 src/include/pc80" |
| 392 | |
| 393 | get_log_dedupe "Mainboards" "src/mainboard/" |
| 394 | |
| 395 | # Next, print all the rest of the specific areas |
| 396 | get_log_dedupe "ACPI" "src/acpi/" |
| 397 | get_log_dedupe "Console" "src/console src/include/console" |
| 398 | get_log_dedupe "SuperIO" "src/superio src/include/superio" |
| 399 | get_log_dedupe "EC" "src/ec" |
| 400 | get_log_dedupe "Drivers" "src/drivers" |
| 401 | get_log_dedupe "Devices" "src/device src/include/device" |
| 402 | |
| 403 | # 5th, print the generic areas - This goes late so that the specific |
| 404 | # area changes will catch any commits in these areas first. |
| 405 | get_log_dedupe "Toolchain" "util/crossgcc" |
| 406 | get_log_dedupe "cbfstool" "util/cbfstool" |
| 407 | get_log_dedupe "Lint tools" "util/lint" |
| 408 | get_log_dedupe "Lib" "src/lib" |
| 409 | get_log_dedupe "Commonlib" "src/commonlib" |
| 410 | get_log_dedupe "Include" "src/include" |
| 411 | get_log_dedupe "Utilities" "util" |
| 412 | get_log_dedupe "Payloads" "payloads" |
| 413 | get_log_dedupe "Vendorcode" "src/vendorcode" |
| 414 | get_log_dedupe "Documentation" "Documentation README" |
| 415 | |
| 416 | # Then look at areas that are usually outside the mainboards and architectures |
| 417 | get_log_dedupe "Build system" \ |
| 418 | "Makefile Makefile.inc toolchain.inc src/Kconfig src/cpu/Makefile.inc" |
| 419 | |
| 420 | get_log_dedupe "Submodules" "3rdparty util/nvidia/cbootimage" |
Patrick Georgi | 3b34ef2 | 2019-06-30 11:41:51 +0200 | [diff] [blame] | 421 | |
| 422 | get_log_dedupe "Maintainers" "MAINTAINERS" "" |
| 423 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 424 | # Finally, get anything that was missed above |
| 425 | get_log_dedupe "MISC" "." |
| 426 | |
Patrick Georgi | 1916d68 | 2019-11-20 16:05:21 +0100 | [diff] [blame] | 427 | # Replace VENDOR_DEVICE from stdin with their nice names on stdout |
| 428 | real_mainboard_names() { |
| 429 | local tree_version=$1 # "old" or "new" |
| 430 | local git_version_var=${tree_version^^}_GIT_VERSION |
| 431 | local git_version=${!git_version_var} |
| 432 | local line |
| 433 | |
| 434 | while read line; do |
| 435 | local file="$(git grep -l "^[[:space:]]*config\>[[:space:]]*\<BOARD_${line}\$" ${git_version} -- src/mainboard/\*/\*/Kconfig.name | sed "s,^${git_version}:,,")" |
| 436 | if [ -z "$file" ]; then |
| 437 | echo "This shouldn't happen: couldn't find Kconfig for $line" |
| 438 | exit 1 |
| 439 | fi |
| 440 | local vendor="$(git grep \" ${git_version} -- $(echo ${file} | cut -d/ -f1-3,5) | cut -d\" -f2)" |
| 441 | git grep -h -A1 "^[[:space:]]*config\>[[:space:]]*\<BOARD_${line}\$" ${git_version} -- ${file} | grep \" |cut -d\" -f2 |sed "s,^,${vendor} ," |
| 442 | done |
| 443 | } |
| 444 | |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 445 | # Show areas that have been added or removed |
Patrick Georgi | 1916d68 | 2019-11-20 16:05:21 +0100 | [diff] [blame] | 446 | show_diff "mainboards" "$mainboard_list_old" "$mainboard_list_new" real_mainboard_names |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 447 | show_diff "processors" "$cpu_list_old" "$cpu_list_new" |
| 448 | show_diff "socs" "$soc_list_old" "$soc_list_new" |
| 449 | show_diff "northbridges" "$northbridge_list_old" "$northbridge_list_new" |
| 450 | show_diff "southbridges" "$southbridge_list_old" "$southbridge_list_new" |
| 451 | show_diff "sios" "$sio_list_old" "$sio_list_new" |
| 452 | |
| 453 | # Log submodules |
| 454 | printf "Submodules\n----------\n" >> "$LOGFILE" |
| 455 | for module in $(git submodule --quiet foreach pwd); do |
| 456 | name=$(basename "$module") |
| 457 | # shellcheck disable=SC2001 |
Patrick Georgi | 250f01e | 2018-12-20 17:25:50 +0100 | [diff] [blame] | 458 | path=${module#$PWD} |
Martin Roth | 3ce6783 | 2017-11-04 18:36:19 -0600 | [diff] [blame] | 459 | old_version=$(echo "${name^^}_OLD_VERSION" | sed 's/-/_/g') |
| 460 | new_version=$(echo "${name^^}_NEW_VERSION" | sed 's/-/_/g') |
| 461 | get_log_submodule "${!old_version}" "${!new_version}" "$path" |
| 462 | done |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 463 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 464 | printf "\nrepo statistics\n-------------------\n" >> "$LOGFILE" |
| 465 | before_names="$(mktemp "OLDNAMES.XXXX")" |
| 466 | after_names="$(mktemp "NEWNAMES.XXXX")" |
| 467 | NEW_AUTHORS=$(git log --pretty=%an "${OLD_GIT_VERSION}" 2>/dev/null | sort | \ |
| 468 | uniq > "$before_names" && \ |
| 469 | git log --pretty=%an "${NEW_GIT_VERSION}" 2>/dev/null | \ |
| 470 | sort | uniq > "$after_names" && \ |
| 471 | grep -Fxv -c -f "$before_names" "$after_names") |
Patrick Georgi | d653e49 | 2019-11-20 16:49:41 +0100 | [diff] [blame] | 472 | NEW_AUTHOR_LIST=$( grep -Fxv -f "$before_names" "$after_names") |
| 473 | rm -f "$before_names" "$after_names" |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 474 | { |
| 475 | printf -- "- Total commits: %s\n" "$TOTAL_COMMITS" |
| 476 | printf -- "- Total authors: %s\n" \ |
| 477 | "$(git log "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | \ |
| 478 | grep -e '^Author:' | sed 's/.*Author: //' | sed 's/ <.*.>//' | \ |
| 479 | sort | uniq | wc -l)" |
| 480 | printf -- "- New authors: %s\n\nNew Authors:\n%s\n" "$NEW_AUTHORS" \ |
| 481 | "$NEW_AUTHOR_LIST" |
| 482 | } >> "$LOGFILE" |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 483 | |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 484 | printf "Getting developer list\n" |
| 485 | printf "\n%-40s: %5s\n" "Developer" "Commits" >> "$LOGFILE" |
| 486 | git log "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | grep '^Author: ' | \ |
| 487 | sed 's|Author: ||' | sed 's|\s<.*||' | sort | uniq | \ |
| 488 | while read -r line; do |
| 489 | printf "%-40s: %5s %5s\n" "$line" \ |
| 490 | "$(git log "${OLD_GIT_VERSION}" 2>/dev/null | \ |
| 491 | grep -c "^Author: ${line} <")" \ |
| 492 | "$(git log "${NEW_GIT_VERSION}" 2>/dev/null | \ |
| 493 | grep -c "^Author: ${line} <")" >> "$LOGFILE"; |
| 494 | done |
Martin Roth | bec1108 | 2015-11-03 21:01:53 -0700 | [diff] [blame] | 495 | |
| 496 | printf "\nOld SLOC (%s)\n%s" "$NOW" "$OLD_SLOC" >> "$LOGFILE" |
| 497 | printf "\nNew SLOC (%s)\n%s" "$NOW" "$NEW_SLOC" >> "$LOGFILE" |
| 498 | |
| 499 | # Add the collected data to the top of the existing logfile for parsing |
| 500 | if [ -n "$UPDATE_MAIN_LOGFILE" ]; then |
| 501 | tmpfile="$(mktemp "LOGFILE.XXXX")" |
| 502 | grep -Fxv -f "$MAIN_LOGFILE" "$LOGFILE" > "$tmpfile" |
| 503 | printf "\n\n" >> "$tmpfile" |
| 504 | cat "$MAIN_LOGFILE" >> "$tmpfile" |
| 505 | mv "$tmpfile" "$MAIN_LOGFILE" |
| 506 | rm -f "$LOGFILE" |
| 507 | fi |
Martin Roth | fb190ed | 2016-10-01 20:13:43 -0600 | [diff] [blame] | 508 | |
| 509 | printf "Done.\n" |