blob: cc9f21d631b3aa18fa4e71ab6e766ce874316716 [file] [log] [blame]
Martin Rothbec11082015-11-03 21:01:53 -07001#!/bin/bash
2#
3# This file is part of the coreboot project.
4#
Martin Rothfb190ed2016-10-01 20:13:43 -06005# Copyright 2015-2016 Google Inc.
Martin Rothbec11082015-11-03 21:01:53 -07006#
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 Rothbec11082015-11-03 21:01:53 -070016
Martin Rothfb190ed2016-10-01 20:13:43 -060017# 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 Rothbec11082015-11-03 21:01:53 -070024
Martin Rothfb190ed2016-10-01 20:13:43 -060025# set -x # uncomment for debug
26
27# Check for tools
28
29if ! ( git --version cloc --version ) > /dev/null 2>&1
30then
Martin Rothbec11082015-11-03 21:01:53 -070031 echo "ERROR: cloc or git is not installed. Exiting"
32 exit 1
33fi
34
Martin Rothfb190ed2016-10-01 20:13:43 -060035if [ ! -e ".git" ];then
36 echo "ERROR: This is not the top directory of a git repo. Exiting."
37 exit 1
38fi
39
40# Try to verify that the repo is clean before losing state.
41if ! git diff-index --quiet --cached HEAD 2>/dev/null || \
42 [ "$(git diff origin/master --shortstat 2>/dev/null | tail -n1)" != "" ]; then
Martin Rothbec11082015-11-03 21:01:53 -070043 echo "ERROR: repo is not clean. Exiting."
44 exit 1
45fi
46
Martin Rothfb190ed2016-10-01 20:13:43 -060047if grep -q 'review.coreboot.org' .git/config; then
48 COREBOOT=1
Martin Rothbec11082015-11-03 21:01:53 -070049else
Martin Rothfb190ed2016-10-01 20:13:43 -060050 echo "This doesn't look like a coreboot repo. Disabling coreboot specifics"
51 COREBOOT=0
Martin Rothbec11082015-11-03 21:01:53 -070052fi
53
Martin Rothfb190ed2016-10-01 20:13:43 -060054# Verify the command line arguments
55if [ "$1" == "--help" ] || [ -z "$1" ] || [ -z "$2" ]; then
56 echo
57 echo "Usage: $0 <old_version> <new_version> [release notes file]"
58 echo "Old version should be a tag (4.1), a branch (origin/4.1), or a commit id"
59 echo "New version can be 'HEAD' a branch (origin/master) a tag (4.2), or a commit id"
60 echo "Logfile can be a new file or an existing file to update"
61 echo "Example: \"$0 origin/4.1 4.2 rnotes.txt\""
62 echo
63 echo "Note that the script starts at the commit AFTER the old version."
64 echo
65 exit 1
66else
67 OLD_GIT_VERSION="$1"
68 NEW_GIT_VERSION="$2"
69 TOTAL_COMMITS=$(git log --pretty=oneline \
70 "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | wc -l)
71fi
72
73TOP=$(pwd)
74
75if [ -n "$3" ]; then
76 MAIN_LOGFILE="${TOP}/$3"
77else
78 MAIN_LOGFILE="${TOP}/relnotes.txt"
79fi
80
81# Figure out which logfile we're writing to. If the specified logfile exists,
82# we need to write to a temporary logfile, then append changes to the main
83# logfile.
Martin Rothbec11082015-11-03 21:01:53 -070084if [ -f "$MAIN_LOGFILE" ]; then
85 LOGFILE="$(mktemp "LOGFILE.XXXX")"
86 LOGFILE="${TOP}/$LOGFILE"
87 UPDATE_MAIN_LOGFILE=1
88else
89 LOGFILE="$MAIN_LOGFILE"
90fi
91
Martin Rothfb190ed2016-10-01 20:13:43 -060092
93
94get_author_commit_count() {
95 git log "${NEW_GIT_VERSION}" 2>/dev/null | grep -c "^Author: $1"
96}
97
98# Print and log the versions
Martin Rothbec11082015-11-03 21:01:53 -070099log_versions() {
100 echo "Log of commit $1 to commit $2"
101 echo "Log of commit $1 to commit $2" >> "$LOGFILE"
Martin Rothfb190ed2016-10-01 20:13:43 -0600102 echo "Total commits: ${TOTAL_COMMITS}"
103 echo "Total commits: ${TOTAL_COMMITS}" >> "$LOGFILE"
Martin Rothbec11082015-11-03 21:01:53 -0700104 echo
105}
106
Martin Rothfb190ed2016-10-01 20:13:43 -0600107# Get the first commit id in the current tree
Martin Rothbec11082015-11-03 21:01:53 -0700108get_latest_commit_id() {
109 pushd "$1" > /dev/null
Martin Rothfb190ed2016-10-01 20:13:43 -0600110 git log 2>/dev/null | grep '^commit ' | head -1 | sed 's/commit //'
Martin Rothbec11082015-11-03 21:01:53 -0700111 popd > /dev/null
112}
113
Martin Rothfb190ed2016-10-01 20:13:43 -0600114# Main get log function
Martin Rothbec11082015-11-03 21:01:53 -0700115_get_log() {
116 local oldver="$1"
117 local newver="$2"
118 local title="$3"
119 local paths="$4"
120
Martin Rothfb190ed2016-10-01 20:13:43 -0600121 # Leave ${paths} unquoted
122 # shellcheck disable=SC2086
123 git log --abbrev-commit --pretty=oneline \
124 "${oldver}..${newver}" -- ${paths} 2>/dev/null | \
125 sort -t ' ' -k 2 | \
126 uniq
Martin Rothbec11082015-11-03 21:01:53 -0700127}
128
Martin Rothfb190ed2016-10-01 20:13:43 -0600129# Output to a new log, then compare to the first logfile, and only output
130# non duplicated lines to the final file.
Martin Rothbec11082015-11-03 21:01:53 -0700131get_log_dedupe() {
132 local title="$1"
133 local paths="$2"
Martin Rothfb190ed2016-10-01 20:13:43 -0600134 local log
135 local commits
136
Martin Rothbec11082015-11-03 21:01:53 -0700137 dedupe_tmpfile="$(mktemp "LOGFILE.XXXX")"
138
Martin Rothfb190ed2016-10-01 20:13:43 -0600139 log=$(_get_log "$OLD_GIT_VERSION" "$NEW_GIT_VERSION" \
140 "$title" "$paths")
Martin Rothbec11082015-11-03 21:01:53 -0700141
142 echo "$log" > "$dedupe_tmpfile"
143
144 log=$(grep -Fxv -f "$LOGFILE" "$dedupe_tmpfile")
Martin Rothfb190ed2016-10-01 20:13:43 -0600145 commits=$(echo "$log" | wc -l)
Martin Rothbec11082015-11-03 21:01:53 -0700146
147 if [ -n "$log" ]; then
Martin Rothfb190ed2016-10-01 20:13:43 -0600148 printf "%s\n%s\n\n" "$title ($commits commits)" \
149 "$log" >> "$LOGFILE"
Martin Rothbec11082015-11-03 21:01:53 -0700150 fi
151
152 rm "$dedupe_tmpfile"
153}
154
155# get logs for the submodules
156get_log_submodule() {
157 local old_version="$1"
158 local new_version="$2"
159 local submodule_dir="$3"
Martin Rothfb190ed2016-10-01 20:13:43 -0600160 local log
161 local commits
Martin Rothbec11082015-11-03 21:01:53 -0700162
163 printf "Submodule %s\n" "$submodule_dir"
164 printf "commit %s to commit %s\n\n" "$old_version" "$new_version"
165
166 pushd "${TOP}/$submodule_dir" > /dev/null
Martin Rothfb190ed2016-10-01 20:13:43 -0600167 log=$(_get_log "$old_version" "$new_version" "$submodule_dir" ".")
168 commits=$(echo "$log" | wc -l)
Martin Rothbec11082015-11-03 21:01:53 -0700169
170 if [ -n "$log" ]; then
Martin Rothfb190ed2016-10-01 20:13:43 -0600171 printf "%s\n%s\n\n" "$submodule_dir ($commits commits)" \
172 "$log" >> "$LOGFILE"
Martin Rothbec11082015-11-03 21:01:53 -0700173 fi
174
175 popd > /dev/null
176}
177
Martin Rothfb190ed2016-10-01 20:13:43 -0600178find_areas() {
179 find "$1" -name "$2" | sed "s|$1/||" | sed "s|/$2||" | sort
180}
181
182# Make sure things get cleaned up if ctl-c is pressed while the old version
183# is checked out and files are renamed. This can be a real mess to clean
184# up manually.
Martin Rothbec11082015-11-03 21:01:53 -0700185version_ctrl_c() {
Martin Rothfb190ed2016-10-01 20:13:43 -0600186 printf "\n** Trapped CTRL-C\n Cleaning up and exiting.\n"
187 find 'src' -name 'gnumakefile' \
188 -exec rename 's/gnumakefile/Makefile\.inc/' {} \;
189 git checkout origin/master > /dev/null 2>&1
Martin Rothbec11082015-11-03 21:01:53 -0700190 git submodule update --init --checkout > /dev/null 2>&1
191 rm -f "$mainboard_list_old" "$mainboard_list_new"
192 rm "$LOGFILE"
193 exit 1;
194}
195
Martin Rothfb190ed2016-10-01 20:13:43 -0600196# Calculate areas that have been added or removed based on file lists
197show_diff () {
198 local new
199 local old
Martin Rothbec11082015-11-03 21:01:53 -0700200
Martin Rothfb190ed2016-10-01 20:13:43 -0600201 new="$(comm -13 <(echo "$2") <(echo "$3"))"
202 if [ -n "$new" ]; then
203 printf "Added %s $1:\n-------------------\n%s\n\n" \
204 "$(echo "$new" | wc -l)" "$new" >> "$LOGFILE"
205 fi
206 old="$(comm -23 <(echo "$2") <(echo "$3"))"
207 if [ -n "$old" ]; then
208 printf "Removed %s $1:\n-------------------\n%s\n\n" \
209 "$(echo "$old" | wc -l)" "$old" >> "$LOGFILE"
210 fi
211}
212
213# Start collecting data from the old and new revisions.
214# This is relatively disruptive to the tree, so trap on ctl-c so that
215# things can be put back to normal
216trap version_ctrl_c SIGINT
Martin Rothbec11082015-11-03 21:01:53 -0700217
218#check out old version and get information
219printf -- "Finding old submodule versions...\n"
Martin Rothfb190ed2016-10-01 20:13:43 -0600220git checkout "$OLD_GIT_VERSION" > /dev/null 2>&1
Martin Rothbec11082015-11-03 21:01:53 -0700221git submodule update --init --checkout > /dev/null 2>&1
Martin Rothfb190ed2016-10-01 20:13:43 -0600222if [ "$COREBOOT" -eq "1" ]; then
223 BLOBS_OLD_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/blobs")
224 VBOOT_OLD_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/vboot")
225 ARM_OLD_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/arm-trusted-firmware")
226 CHROME_EC_OLD_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/chromeec/")
227 NVIDIA_OLD_VERSION=$(get_latest_commit_id "${TOP}/util/nvidia/cbootimage")
228
229 printf "Logging directories in the old tree\n"
230 mainboard_list_old=$(find_areas "src/mainboard" 'Kconfig.name' | grep '/')
231 cpu_list_old=$(find_areas "src/cpu" "Kconfig")
232 soc_list_old=$(find_areas "src/soc" "Kconfig")
233 northbridge_list_old=$(find_areas "src/northbridge" "Kconfig")
234 sio_list_old=$(find_areas "src/superio" "Makefile.inc")
235 southbridge_list_old=$(find_areas "src/southbridge" "Kconfig")
236
237 # Because cloc works on extensions, and .inc identifies as pascal,
238 # rename Makefile.inc, then remap the other .inc files to c
239 find 'src' -name 'Makefile.inc' -exec rename 's/Makefile\.inc/gnumakefile/' {} \;
240fi
Martin Rothbec11082015-11-03 21:01:53 -0700241printf "Calculating old SLOC\n"
Martin Rothfb190ed2016-10-01 20:13:43 -0600242OLD_SLOC=$(cloc --progress-rate=0 --quiet --script-lang="Bourne Shell",bash \
243 --force-lang=c,inc --exclude-dir=vendorcode src)
244if [ "$COREBOOT" -eq "1" ]; then
245 find 'src' -name 'gnumakefile' -exec rename 's/gnumakefile/Makefile\.inc/' {} \;
246fi
Martin Rothbec11082015-11-03 21:01:53 -0700247
248#check out new version and get information
249printf -- "\nFinding new submodule versions...\n"
Martin Rothfb190ed2016-10-01 20:13:43 -0600250git checkout "$NEW_GIT_VERSION" > /dev/null 2>&1
Martin Rothbec11082015-11-03 21:01:53 -0700251git submodule update --init --checkout > /dev/null 2>&1
Martin Rothfb190ed2016-10-01 20:13:43 -0600252if [ "$COREBOOT" -eq "1" ]; then
253 BLOBS_NEW_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/blobs")
254 VBOOT_NEW_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/vboot")
255 ARM_NEW_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/arm-trusted-firmware")
256 CHROME_EC_NEW_VERSION=$(get_latest_commit_id "${TOP}/3rdparty/chromeec/")
257 NVIDIA_NEW_VERSION=$(get_latest_commit_id "${TOP}/util/nvidia/cbootimage")
Martin Rothbec11082015-11-03 21:01:53 -0700258
Martin Rothfb190ed2016-10-01 20:13:43 -0600259 printf "Logging directories in the new tree\n"
260 mainboard_list_new=$(find_areas "src/mainboard" 'Kconfig.name' | grep '/')
261 cpu_list_new=$(find_areas "src/cpu" "Kconfig")
262 soc_list_new=$(find_areas "src/soc" "Kconfig")
263 northbridge_list_new=$(find_areas "src/northbridge" "Kconfig")
264 sio_list_new=$(find_areas "src/superio" "Makefile.inc")
265 southbridge_list_new=$(find_areas "src/southbridge" "Kconfig")
266
267 find 'src' -name 'Makefile.inc' -exec rename 's/Makefile\.inc/gnumakefile/' {} \;
268fi
269printf "Calculating new SLOC\n"
270NEW_SLOC=$(cloc --progress-rate=0 --quiet --script-lang="Bourne Shell",bash \
271 --force-lang=c,inc --exclude-dir=vendorcode src)
272if [ "$COREBOOT" -eq "1" ]; then
273 find 'src' -name 'gnumakefile' -exec rename 's/gnumakefile/Makefile\.inc/' {} \;
274fi
Martin Rothbec11082015-11-03 21:01:53 -0700275
276git checkout origin/master > /dev/null 2>&1
277git submodule update --init --checkout > /dev/null 2>&1
Martin Rothbec11082015-11-03 21:01:53 -0700278trap "" SIGINT
Martin Rothfb190ed2016-10-01 20:13:43 -0600279# Done collecting data from the old and new versions
Martin Rothbec11082015-11-03 21:01:53 -0700280
Martin Rothfb190ed2016-10-01 20:13:43 -0600281# Start outputting to logfile
282echo "Generating release notes from version ${OLD_GIT_VERSION} to ${NEW_GIT_VERSION}"
283echo; echo "Main repo"
284echo "Main repo" >> "$LOGFILE"
Martin Rothbec11082015-11-03 21:01:53 -0700285echo "------------------" >> "$LOGFILE"
Martin Rothfb190ed2016-10-01 20:13:43 -0600286log_versions "$(git log --pretty=%H \
287 "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | tail -1)" \
288 "$(git log --pretty=%H \
289 "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | head -1 )"
290echo "" >> "$LOGFILE"
Martin Rothbec11082015-11-03 21:01:53 -0700291
Martin Rothfb190ed2016-10-01 20:13:43 -0600292if [ "$COREBOOT" -eq "1" ]; then
Martin Rothbec11082015-11-03 21:01:53 -0700293
Martin Rothfb190ed2016-10-01 20:13:43 -0600294 # 1st, Show mainboards so that changes that are mainboard specific don't get
295 # grabbed by changes in the architectures
296 get_log_dedupe "Mainboards" "src/mainboard/"
Martin Rothbec11082015-11-03 21:01:53 -0700297
Martin Rothfb190ed2016-10-01 20:13:43 -0600298 # Show architectures 2nd - separate the various pieces out
299 # This works by getting a list of directories that have Kconfigs containing _ARCH
300 # then filtering out generic areas. X86 has too many non-compliant directories
301 # for that to work well, so just supply a list
302 # shellcheck disable=SC2013
303 {
304 get_log_dedupe "ARM" \
305 "$(for codedir in $(grep -rl "_ARM" --include=Kconfig | \
306 grep -v 'src/mainboard\|payloads/\|drivers/\|vendorcode/\|console' ); \
307 do dirname "$codedir"; done | grep -v '^src$')"
Martin Rothbec11082015-11-03 21:01:53 -0700308
Martin Rothfb190ed2016-10-01 20:13:43 -0600309 get_log_dedupe "RISC-V" \
310 "$(for codedir in $(grep -rl "_RISCV" --include=Kconfig | \
311 grep -v 'src/mainboard\|payloads/\|drivers/\|vendorcode/\|console' ); \
312 do dirname "$codedir"; done | grep -v '^src$')"
Martin Rothbec11082015-11-03 21:01:53 -0700313
Martin Rothfb190ed2016-10-01 20:13:43 -0600314 get_log_dedupe "X86" \
315 "src/arch/x86 src/cpu/x86 src/cpu/intel src/soc/intel src/cpu/amd \
316 src/northbridge/intel src/northbridge/amd src/southbridge/intel \
317 src/southbridge/amd src/drivers/intel/fsp1_0 src/drivers/intel/fsp1_1 \
318 src/include/amd src/include/intel src/include/x86 src/include/pc80"
Martin Rothbec11082015-11-03 21:01:53 -0700319
Martin Rothfb190ed2016-10-01 20:13:43 -0600320 get_log_dedupe "MIPS" \
321 "$(for codedir in $(grep -rl "_MIPS" --include=Kconfig | \
322 grep -v 'src/mainboard\|payloads/\|drivers/\|vendorcode/\|console' ); \
323 do dirname "$codedir"; done | grep -v '^src$')"
324 }
325 # Next, print all the rest of the specific areas
326 get_log_dedupe "ACPI" "src/acpi/"
327 get_log_dedupe "Console" "src/console/ src/include/console"
328 get_log_dedupe "SuperIO" "src/superio/ src/include/superio"
329 get_log_dedupe "EC " "src/ec"
330 get_log_dedupe "Drivers" "src/drivers/"
331 get_log_dedupe "Devices" "src/device/ src/include/device"
Martin Rothbec11082015-11-03 21:01:53 -0700332
Martin Rothfb190ed2016-10-01 20:13:43 -0600333 # 5th, print the generic areas - This goes late so that the specific
334 # area changes will catch any commits in these areas first.
335 get_log_dedupe "Lib" "src/lib/"
336 get_log_dedupe "Commonlib" "src/commonlib/"
337 get_log_dedupe "Include" "src/include/"
338 get_log_dedupe "Utilities" "util/"
339 get_log_dedupe "Payloads" "payloads/"
340 get_log_dedupe "Vendorcode" "src/vendorcode/"
341 get_log_dedupe "Documentation" "Documentation/ README"
342
343 # Then look at areas that are usually outside the mainboards and architectures
344 get_log_dedupe "Build system" \
345 "Makefile Makefile.inc toolchain.inc src/Kconfig src/cpu/Makefile.inc"
346
347 # Finally, get anything that was missed above
348 get_log_dedupe "MISC" "."
349
350 # Show areas that have been added or removed
351 show_diff "mainboards" "$mainboard_list_old" "$mainboard_list_new"
352 show_diff "processors" "$cpu_list_old" "$cpu_list_new"
353 show_diff "socs" "$soc_list_old" "$soc_list_new"
354 show_diff "northbridges" "$northbridge_list_old" "$northbridge_list_new"
355 show_diff "southbridges" "$southbridge_list_old" "$southbridge_list_new"
356 show_diff "sios" "$sio_list_old" "$sio_list_new"
357
358 # Log submodules
359 printf "Submodules\n----------\n" >> "$LOGFILE"
360 get_log_submodule "$BLOBS_OLD_VERSION" "$BLOBS_NEW_VERSION" \
361 "3rdparty/blobs"
362 get_log_submodule "$ARM_OLD_VERSION" "$ARM_NEW_VERSION" \
363 "3rdparty/arm-trusted-firmware"
364 get_log_submodule "$VBOOT_OLD_VERSION" "$VBOOT_NEW_VERSION" \
365 "3rdparty/vboot"
366 get_log_submodule "$CHROME_EC_OLD_VERSION" "$CHROME_EC_NEW_VERSION" \
367 "3rdparty/chromeec/"
368 get_log_submodule "$NVIDIA_OLD_VERSION" "$NVIDIA_NEW_VERSION" \
369 "util/nvidia/cbootimage"
370
371else
372 get_log_dedupe "Commits" "."
Martin Rothbec11082015-11-03 21:01:53 -0700373fi
374
Martin Rothfb190ed2016-10-01 20:13:43 -0600375printf "\nrepo statistics\n-------------------\n" >> "$LOGFILE"
376before_names="$(mktemp "OLDNAMES.XXXX")"
377after_names="$(mktemp "NEWNAMES.XXXX")"
378NEW_AUTHORS=$(git log --pretty=%an "${OLD_GIT_VERSION}" 2>/dev/null | sort | \
379 uniq > "$before_names" && \
380 git log --pretty=%an "${NEW_GIT_VERSION}" 2>/dev/null | \
381 sort | uniq > "$after_names" && \
382 grep -Fxv -c -f "$before_names" "$after_names")
383NEW_AUTHOR_LIST=$( grep -Fxv -f "$before_names" "$after_names" && \
384 rm "$before_names" "$after_names")
385{
386 printf -- "- Total commits: %s\n" "$TOTAL_COMMITS"
387 printf -- "- Total authors: %s\n" \
388 "$(git log "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | \
389 grep -e '^Author:' | sed 's/.*Author: //' | sed 's/ <.*.>//' | \
390 sort | uniq | wc -l)"
391 printf -- "- New authors: %s\n\nNew Authors:\n%s\n" "$NEW_AUTHORS" \
392 "$NEW_AUTHOR_LIST"
393} >> "$LOGFILE"
Martin Rothbec11082015-11-03 21:01:53 -0700394
Martin Rothfb190ed2016-10-01 20:13:43 -0600395printf "Getting developer list\n"
396printf "\n%-40s: %5s\n" "Developer" "Commits" >> "$LOGFILE"
397git log "${OLD_GIT_VERSION}..${NEW_GIT_VERSION}" 2>/dev/null | grep '^Author: ' | \
398 sed 's|Author: ||' | sed 's|\s<.*||' | sort | uniq | \
399 while read -r line; do
400 printf "%-40s: %5s %5s\n" "$line" \
401 "$(git log "${OLD_GIT_VERSION}" 2>/dev/null | \
402 grep -c "^Author: ${line} <")" \
403 "$(git log "${NEW_GIT_VERSION}" 2>/dev/null | \
404 grep -c "^Author: ${line} <")" >> "$LOGFILE";
405 done
Martin Rothbec11082015-11-03 21:01:53 -0700406
407printf "\nOld SLOC (%s)\n%s" "$NOW" "$OLD_SLOC" >> "$LOGFILE"
408printf "\nNew SLOC (%s)\n%s" "$NOW" "$NEW_SLOC" >> "$LOGFILE"
409
410# Add the collected data to the top of the existing logfile for parsing
411if [ -n "$UPDATE_MAIN_LOGFILE" ]; then
412 tmpfile="$(mktemp "LOGFILE.XXXX")"
413 grep -Fxv -f "$MAIN_LOGFILE" "$LOGFILE" > "$tmpfile"
414 printf "\n\n" >> "$tmpfile"
415 cat "$MAIN_LOGFILE" >> "$tmpfile"
416 mv "$tmpfile" "$MAIN_LOGFILE"
417 rm -f "$LOGFILE"
418fi
Martin Rothfb190ed2016-10-01 20:13:43 -0600419
420printf "Done.\n"