[U-Boot] [PATCH v2 0/2] Fill blank fields of doc/README.scrapyard with a tool

Changes in v2: - Remove unnecessary lines - Rebased on commit 5f88ed5cde
Masahiro Yamada (2): scripts: add a utility to fill blank fields of doc/README.scrapyard README.scrapyard: fill commit and date fields
doc/README.scrapyard | 136 ++++++++++++++++++------------------- scripts/fill_scrapyard.py | 166 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 234 insertions(+), 68 deletions(-) create mode 100755 scripts/fill_scrapyard.py

We are removing bunch of non-generic boards these days.
Updating doc/README.scrapyard is a really tedious task, but it can be automated. I hope this tool will make our life easier.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com Reviewed-by: Simon Glass sjg@chromium.org ---
Changes in v2: - Remove unnecessary lines
scripts/fill_scrapyard.py | 166 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 166 insertions(+) create mode 100755 scripts/fill_scrapyard.py
diff --git a/scripts/fill_scrapyard.py b/scripts/fill_scrapyard.py new file mode 100755 index 0000000..9a94354 --- /dev/null +++ b/scripts/fill_scrapyard.py @@ -0,0 +1,166 @@ +#!/usr/bin/env python2 +# +# Author: Masahiro Yamada yamada.m@jp.panasonic.com +# +# SPDX-License-Identifier: GPL-2.0+ +# + +""" +Fill the "Commit" and "Removed" fields of doc/README.scrapyard + +The file doc/README.scrapyard is used to keep track of removed boards. + +When we remove support for boards, we are supposed to add entries to +doc/README.scrapyard leaving "Commit" and "Removed" fields blank. + +The "Commit" field is the commit hash in which the board was removed +and the "Removed" is the date at which the board was removed. Those +two are known only after the board removal patch was applied, thus they +need to be filled in later. + +This effectively means that the person who removes other boards is +supposed to fill in the blank fields before adding new entries to +doc/README.scrapyard. + +That is a really tedious task that should be automated. +This script fills the blank fields of doc/README.scrapyard for you! + +Usage: + +The "Commit" and "Removed" fields must be "-". The other fields should +have already been filled in by a former commit. + +Run + scripts/fill_scrapyard.py +""" + +import os +import subprocess +import sys +import tempfile + +DOC='doc/README.scrapyard' + +def get_last_modify_commit(file, line_num): + """Get the commit that last modified the given line. + + This function runs "git blame" against the given line of the given + file and returns the commit hash that last modified it. + + Arguments: + file: the file to be git-blame'd. + line_num: the line number to be git-blame'd. This line number + starts from 1, not 0. + + Returns: + Commit hash that last modified the line. The number of digits is + long enough to form a unique commit. + """ + result = subprocess.check_output(['git', 'blame', '-L', + '%d,%d' % (line_num, line_num), file]) + commit = result.split()[0] + + if commit[0] == '^': + sys.exit('%s: line %d: ' % (file, line_num) + + 'this line was modified before the beginning of git history') + + if commit == '0' * len(commit): + sys.exit('%s: line %d: locally modified\n' % (file, line_num) + + 'Please run this script in a clean repository.') + + return commit + +def get_committer_date(commit): + """Get the committer date of the given commit. + + This function returns the date when the given commit was applied. + + Arguments: + commit: commit-ish object. + + Returns: + The committer date of the given commit in the form YY-MM-DD. + """ + committer_date = subprocess.check_output(['git', 'show', '-s', + '--format=%ci', commit]) + return committer_date.split()[0] + +def move_to_topdir(): + """Change directory to the top of the git repository. + + Or, exit with an error message if called out of a git repository. + """ + try: + toplevel = subprocess.check_output(['git', 'rev-parse', + '--show-toplevel']) + except subprocess.CalledProcessError: + sys.exit('Please run in a git repository.') + + # strip '\n' + toplevel = toplevel.rstrip() + + # Change the current working directory to the toplevel of the respository + # for our easier life. + os.chdir(toplevel) + +class TmpFile: + + """Useful class to handle a temporary file. + + tempfile.mkstemp() is often used to create a unique temporary file, + but what is inconvenient is that the caller is responsible for + deleting the file when done with it. + + Even when the caller errors out on the way, the temporary file must + be deleted somehow. The idea here is that we delete the file in + the destructor of this class because the destructor is always + invoked when the instance of the class is freed. + """ + + def __init__(self): + """Constructor - create a temporary file""" + fd, self.filename = tempfile.mkstemp() + self.file = os.fdopen(fd, 'w') + + def __del__(self): + """Destructor - delete the temporary file""" + try: + os.remove(self.filename) + except: + pass + +def main(): + move_to_topdir() + + line_num = 1 + + tmpfile = TmpFile() + for line in open(DOC): + tmp = line.split(None, 5) + modified = False + + if len(tmp) >= 5: + # fill "Commit" field + if tmp[3] == '-': + tmp[3] = get_last_modify_commit(DOC, line_num) + modified = True + # fill "Removed" field + if tmp[4] == '-': + tmp[4] = get_committer_date(tmp[3]) + if modified: + line = tmp[0].ljust(17) + line += tmp[1].ljust(12) + line += tmp[2].ljust(15) + line += tmp[3].ljust(12) + line += tmp[4].ljust(12) + if len(tmp) >= 6: + line += tmp[5] + line = line.rstrip() + '\n' + + tmpfile.file.write(line) + line_num += 1 + + os.rename(tmpfile.filename, DOC) + +if __name__ == '__main__': + main()

On Wed, Jan 14, 2015 at 12:35:23PM +0900, Masahiro Yamada wrote:
We are removing bunch of non-generic boards these days.
Updating doc/README.scrapyard is a really tedious task, but it can be automated. I hope this tool will make our life easier.
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/master, thanks!

This commit was generated by the following command:
scripts/fill_scrapyard.py
The commit-ID of CPCIISER4 removal has been fixed by hand because the board was removed by commit 370572601027 (ppc4xx: remove CPCIISER4 board), but it was added to README.scrapyard by commit 9a4018e09a2f (ppc4xx: remove DP405 board).
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com ---
Changes in v2: - Rebased on commit 5f88ed5cde
doc/README.scrapyard | 136 +++++++++++++++++++++++++-------------------------- 1 file changed, 68 insertions(+), 68 deletions(-)
diff --git a/doc/README.scrapyard b/doc/README.scrapyard index 9172f6c..e1a81d3 100644 --- a/doc/README.scrapyard +++ b/doc/README.scrapyard @@ -12,74 +12,74 @@ The list should be sorted in reverse chronological order.
Board Arch CPU Commit Removed Last known maintainer/contact ================================================================================================= -CPCI405 ppc4xx 405gp - - Matthias Fuchs matthias.fuchs@esd.eu -CPCI405DT ppc4xx 405gpr - - Matthias Fuchs matthias.fuchs@esd.eu -CPCI405AB ppc4xx 405gpr - - Matthias Fuchs matthias.fuchs@esd.eu -G2000 ppc4xx 405ep - - Matthias Fuchs matthias.fuchs@esd.eu -WUH405 ppc4xx 405ep - - Matthias Fuchs matthias.fuchs@esd.eu -VOH405 ppc4xx 405ep - - Matthias Fuchs matthias.fuchs@esd.eu -PMC405 ppc4xx 405gp - - Matthias Fuchs matthias.fuchs@esd.eu -PCI405 ppc4xx 405gp - - Matthias Fuchs matthias.fuchs@esd.eu -OCRTC ppc4xx 405gpr - - Matthias Fuchs matthias.fuchs@esd.eu -HUB405 ppc4xx 405ep - - Matthias Fuchs matthias.fuchs@esd.eu -HH405 ppc4xx 405ep - - Matthias Fuchs matthias.fuchs@esd.eu -DU440 ppc4xx 440epx - - Matthias Fuchs matthias.fuchs@esd.eu -DU405 ppc4xx 405gpr - - Matthias Fuchs matthias.fuchs@esd.eu -DP405 ppc4xx 405ep - - Matthias Fuchs matthias.fuchs@esd.eu -CPCIISER4 ppc4xx 405gp - - Matthias Fuchs matthias.fuchs@esd.eu -CMS700 ppc4xx 405ep - - Matthias Fuchs matthias.fuchs@esd.eu -ASH405 ppc4xx 405ep - - Matthias Fuchs matthias.fuchs@esd.eu -AR405 ppc4xx 405gpr - - Matthias Fuchs matthias.fuchs@esd.eu -APC405 ppc4xx 405gpr - - Matthias Fuchs matthias.fuchs@esd.eu -TASREG m68k mcf52x2 - - Matthias Fuchs matthias.fuchs@esd.eu -A3000 powerpc mpc824x - - -CPC45 powerpc mpc824x - - Josef Wagner Wagner@Microsys.de -CU824 powerpc mpc824x - - Wolfgang Denk wd@denx.de -eXalion powerpc mpc824x - - Torsten Demke torsten.demke@fci.com -MVBLUE powerpc mpc824x - - -MUSENKI powerpc mpc824x - - Jim Thompson jim@musenki.com -Sandpoint8240 powerpc mpc824x - - Wolfgang Denk wd@denx.de -Sandpoint8245 powerpc mpc824x - - Jim Thompson jim@musenki.com -utx8245 powerpc mpc824x - - Greg Allen gallen@arlut.utexas.edu -atc powerpc mpc8260 - - Wolfgang Denk wd@denx.de -CPU86 powerpc mpc8260 - - Wolfgang Denk wd@denx.de -CPU87 powerpc mpc8260 - - -ep82xxm powerpc mpc8260 - - -gw8260 powerpc mpc8260 - - Oliver Brown obrown@adventnetworks.com -IPHASE4539 powerpc mpc8260 - - Wolfgang Grandegger wg@denx.de -muas3001 powerpc mpc8260 - - Heiko Schocher hs@denx.de -PM825 powerpc mpc8260 - - Wolfgang Denk wd@denx.de -PM826 powerpc mpc8260 - - Wolfgang Denk wd@denx.de -PM828 powerpc mpc8260 - - -MPC8266ADS powerpc mpc8260 - - Rune Torgersen runet@innovsys.com -VoVPN-GW powerpc mpc8260 - - -ep8260 powerpc mpc8260 - - Frank Panno fpanno@delphintech.com -ppmc8260 powerpc mpc8260 - - Brad Kemp Brad.Kemp@seranoa.com -sacsng powerpc mpc8260 - - Jerry Van Baren gerald.vanbaren@smiths-aerospace.com -cogent_mpc8260 powerpc mpc8260 - - Murray Jensen Murray.Jensen@csiro.au -cogent_8xx powerpc mpc8xx - - Murray Jensen Murray.Jensen@csiro.au -ESTEEM192E powerpc mpc8xx - - Conn Clark clark@esteem.com -IP860 powerpc mpc8xx - - Wolfgang Denk wd@denx.de -IVML24 powerpc mpc8xx - - Wolfgang Denk wd@denx.de -IVMS8 powerpc mpc8xx - - Wolfgang Denk wd@denx.de -lwmon powerpc mpc8xx - - Wolfgang Denk wd@denx.de -NETVIA powerpc mpc8xx - - Pantelis Antoniou panto@intracom.gr -R360MPI powerpc mpc8xx - - Wolfgang Denk wd@denx.de -RRvision powerpc mpc8xx - - Wolfgang Denk wd@denx.de -SPD823TS powerpc mpc8xx - - Wolfgang Denk wd@denx.de -KUP4K powerpc mpc8xx - - Klaus Heydeck heydeck@kieback-peter.de -KUP4X powerpc mpc8xx - - Klaus Heydeck heydeck@kieback-peter.de -ELPT860 powerpc mpc8xx - - The LEOX team team@leox.org -hmi1001 powerpc mpc5xxx - - -mucmc52 powerpc mpc5xxx - - Heiko Schocher hs@denx.de -uc101 powerpc mpc5xxx - - Heiko Schocher hs@denx.de -uc100 powerpc mpc8xx - - Stefan Roese sr@denx.de -FPS850L powerpc mpc8xx - - Wolfgang Denk wd@denx.de -FPS860L powerpc mpc8xx - - Wolfgang Denk wd@denx.de -NSCU powerpc mpc8xx - - -SM850 powerpc mpc8xx - - Wolfgang Denk wd@denx.de -TK885D powerpc mpc8xx - - -virtlab2 powerpc mpc8xx - - Wolfgang Denk wd@denx.de +CPCI405 ppc4xx 405gp 5f1459dc 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +CPCI405DT ppc4xx 405gpr 5f1459dc 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +CPCI405AB ppc4xx 405gpr 5f1459dc 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +G2000 ppc4xx 405ep 5f8f6294 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +WUH405 ppc4xx 405ep fc88a5bf 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +VOH405 ppc4xx 405ep 807db88b 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +PMC405 ppc4xx 405gp d5263304 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +PCI405 ppc4xx 405gp dbe7bb0d 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +OCRTC ppc4xx 405gpr cc6e715f 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +HUB405 ppc4xx 405ep e434d5d7 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +HH405 ppc4xx 405ep 843125da 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +DU440 ppc4xx 440epx 7ac9d47a 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +DU405 ppc4xx 405gpr bc114076 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +DP405 ppc4xx 405ep 9a4018e0 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +CPCIISER4 ppc4xx 405gp 37057260 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +CMS700 ppc4xx 405ep 2404124c 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +ASH405 ppc4xx 405ep b5e7c84f 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +AR405 ppc4xx 405gpr 61b57c4a 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +APC405 ppc4xx 405gpr 2b8a04e5 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +TASREG m68k mcf52x2 cbdc662a 2015-01-13 Matthias Fuchs matthias.fuchs@esd.eu +A3000 powerpc mpc824x d622ac39 2015-01-05 +CPC45 powerpc mpc824x d622ac39 2015-01-05 Josef Wagner Wagner@Microsys.de +CU824 powerpc mpc824x d622ac39 2015-01-05 Wolfgang Denk wd@denx.de +eXalion powerpc mpc824x d622ac39 2015-01-05 Torsten Demke torsten.demke@fci.com +MVBLUE powerpc mpc824x d622ac39 2015-01-05 +MUSENKI powerpc mpc824x d622ac39 2015-01-05 Jim Thompson jim@musenki.com +Sandpoint8240 powerpc mpc824x d622ac39 2015-01-05 Wolfgang Denk wd@denx.de +Sandpoint8245 powerpc mpc824x d622ac39 2015-01-05 Jim Thompson jim@musenki.com +utx8245 powerpc mpc824x d622ac39 2015-01-05 Greg Allen gallen@arlut.utexas.edu +atc powerpc mpc8260 9067b300 2015-01-05 Wolfgang Denk wd@denx.de +CPU86 powerpc mpc8260 f7e1af86 2015-01-05 Wolfgang Denk wd@denx.de +CPU87 powerpc mpc8260 f7e1af86 2015-01-05 +ep82xxm powerpc mpc8260 e2b19629 2015-01-05 +gw8260 powerpc mpc8260 8eecbaf3 2015-01-05 Oliver Brown obrown@adventnetworks.com +IPHASE4539 powerpc mpc8260 87882f57 2015-01-05 Wolfgang Grandegger wg@denx.de +muas3001 powerpc mpc8260 d2fd1d66 2015-01-05 Heiko Schocher hs@denx.de +PM825 powerpc mpc8260 dc0b2fb4 2015-01-05 Wolfgang Denk wd@denx.de +PM826 powerpc mpc8260 dc0b2fb4 2015-01-05 Wolfgang Denk wd@denx.de +PM828 powerpc mpc8260 dc0b2fb4 2015-01-05 +MPC8266ADS powerpc mpc8260 b3a2bbe1 2015-01-05 Rune Torgersen runet@innovsys.com +VoVPN-GW powerpc mpc8260 cc90905f 2015-01-05 +ep8260 powerpc mpc8260 4ad015ba 2015-01-05 Frank Panno fpanno@delphintech.com +ppmc8260 powerpc mpc8260 793116d2 2015-01-05 Brad Kemp Brad.Kemp@seranoa.com +sacsng powerpc mpc8260 b35c0ad6 2015-01-05 Jerry Van Baren gerald.vanbaren@smiths-aerospace.com +cogent_mpc8260 powerpc mpc8260 d19f6a60 2015-01-05 Murray Jensen Murray.Jensen@csiro.au +cogent_8xx powerpc mpc8xx d19f6a60 2015-01-05 Murray Jensen Murray.Jensen@csiro.au +ESTEEM192E powerpc mpc8xx af0e3514 2015-01-05 Conn Clark clark@esteem.com +IP860 powerpc mpc8xx 5ec71100 2015-01-05 Wolfgang Denk wd@denx.de +IVML24 powerpc mpc8xx ca620cd1 2015-01-05 Wolfgang Denk wd@denx.de +IVMS8 powerpc mpc8xx ca620cd1 2015-01-05 Wolfgang Denk wd@denx.de +lwmon powerpc mpc8xx acc2372d 2015-01-05 Wolfgang Denk wd@denx.de +NETVIA powerpc mpc8xx f017cd7f 2015-01-05 Pantelis Antoniou panto@intracom.gr +R360MPI powerpc mpc8xx 79cbecb8 2015-01-05 Wolfgang Denk wd@denx.de +RRvision powerpc mpc8xx 8737fc75 2015-01-05 Wolfgang Denk wd@denx.de +SPD823TS powerpc mpc8xx 72ba368f 2015-01-05 Wolfgang Denk wd@denx.de +KUP4K powerpc mpc8xx 4317d070 2015-01-05 Klaus Heydeck heydeck@kieback-peter.de +KUP4X powerpc mpc8xx 4317d070 2015-01-05 Klaus Heydeck heydeck@kieback-peter.de +ELPT860 powerpc mpc8xx 3c5b20f1 2015-01-05 The LEOX team team@leox.org +hmi1001 powerpc mpc5xxx ceaf499b 2015-01-05 +mucmc52 powerpc mpc5xxx ceaf499b 2015-01-05 Heiko Schocher hs@denx.de +uc101 powerpc mpc5xxx ceaf499b 2015-01-05 Heiko Schocher hs@denx.de +uc100 powerpc mpc8xx ceaf499b 2015-01-05 Stefan Roese sr@denx.de +FPS850L powerpc mpc8xx 5d2a5ef7 2015-01-05 Wolfgang Denk wd@denx.de +FPS860L powerpc mpc8xx 5d2a5ef7 2015-01-05 Wolfgang Denk wd@denx.de +NSCU powerpc mpc8xx 5d2a5ef7 2015-01-05 +SM850 powerpc mpc8xx 5d2a5ef7 2015-01-05 Wolfgang Denk wd@denx.de +TK885D powerpc mpc8xx 5d2a5ef7 2015-01-05 +virtlab2 powerpc mpc8xx 5d2a5ef7 2015-01-05 Wolfgang Denk wd@denx.de hermes powerpc mpc8xx 36da51e 2014-12-08 Wolfgang Denk wd@denx.de PRS200 powerpc mpc5200 ecfdcee 2014-11-12 MCC200 powerpc mpc5200 ecfdcee 2014-11-12

On Wed, Jan 14, 2015 at 12:35:24PM +0900, Masahiro Yamada wrote:
This commit was generated by the following command:
scripts/fill_scrapyard.py
The commit-ID of CPCIISER4 removal has been fixed by hand because the board was removed by commit 370572601027 (ppc4xx: remove CPCIISER4 board), but it was added to README.scrapyard by commit 9a4018e09a2f (ppc4xx: remove DP405 board).
Signed-off-by: Masahiro Yamada yamada.m@jp.panasonic.com
Applied to u-boot/master, thanks!
participants (2)
-
Masahiro Yamada
-
Tom Rini