From patchwork Thu Jul 24 04:00:14 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 373109 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from theia.denx.de (theia.denx.de [85.214.87.163]) by ozlabs.org (Postfix) with ESMTP id DA03A1401DE for ; Thu, 24 Jul 2014 14:02:36 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 7F86EA76DF; Thu, 24 Jul 2014 06:02:16 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id FI7xum0beeOE; Thu, 24 Jul 2014 06:02:16 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 29226A7718; Thu, 24 Jul 2014 06:01:11 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id C29C0A76E3 for ; Thu, 24 Jul 2014 06:00:51 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at theia.denx.de Received: from theia.denx.de ([127.0.0.1]) by localhost (theia.denx.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id PRhNJVqs3i03 for ; Thu, 24 Jul 2014 06:00:50 +0200 (CEST) X-policyd-weight: NOT_IN_SBL_XBL_SPAMHAUS=-1.5 NOT_IN_SPAMCOP=-1.5 NOT_IN_BL_NJABL=-1.5 (only DNSBL check requested) Received: from smtp.mei.co.jp (smtp.mei.co.jp [133.183.100.20]) by theia.denx.de (Postfix) with ESMTP id 3A92FA76E2 for ; Thu, 24 Jul 2014 06:00:34 +0200 (CEST) Received: from mail-gw.jp.panasonic.com ([157.8.1.157]) by smtp.mei.co.jp (8.12.11.20060614/3.7W/kc-maile12) with ESMTP id s6O40OaD006911; Thu, 24 Jul 2014 13:00:24 +0900 (JST) Received: from epochmail.jp.panasonic.com ([157.8.1.130]) by mail.jp.panasonic.com (8.11.6p2/3.7W/kc-maili17) with ESMTP id s6O40P307209; Thu, 24 Jul 2014 13:00:25 +0900 Received: by epochmail.jp.panasonic.com (8.12.11.20060308/3.7W/lomi14) id s6O40PBM022141; Thu, 24 Jul 2014 13:00:25 +0900 Received: from poodle by lomi14.jp.panasonic.com (8.12.11.20060308/3.7W) with ESMTP id s6O40ONP021909; Thu, 24 Jul 2014 13:00:24 +0900 Received: from beagle.diag.org (beagle.diag.org [10.184.179.16]) by poodle (Postfix) with ESMTP id 884012743A5E; Thu, 24 Jul 2014 13:00:24 +0900 (JST) From: Masahiro Yamada To: u-boot@lists.denx.de Date: Thu, 24 Jul 2014 13:00:14 +0900 Message-Id: <1406174422-13966-8-git-send-email-yamada.m@jp.panasonic.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1406174422-13966-1-git-send-email-yamada.m@jp.panasonic.com> References: <1406174422-13966-1-git-send-email-yamada.m@jp.panasonic.com> Cc: Tom Rini Subject: [U-Boot] [PATCH v5 07/15] Do not apply: tools: add gen_maintainers.py X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.11 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: u-boot-bounces@lists.denx.de Errors-To: u-boot-bounces@lists.denx.de ======================================== Do not apply this patch to the main line ======================================== This tool generates MAINTAINERS files based on boards.cfg file. Because it is used only once, it should not be applied. Signed-off-by: Masahiro Yamada --- Changes in v5: None Changes in v4: - Newly added Changes in v3: None Changes in v2: None tools/gen_maintainers.py | 117 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100755 tools/gen_maintainers.py diff --git a/tools/gen_maintainers.py b/tools/gen_maintainers.py new file mode 100755 index 0000000..c448402 --- /dev/null +++ b/tools/gen_maintainers.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python + +import os +import sys +import subprocess + +INPUT_FILE = 'boards.cfg' + +def get_board_name(board, target): + board = board.upper() + target = target.upper() + if board == '': + return target + elif board == target[:len(board)]: + return board + else: + print "other cases:", board, ':', target + return target + +def get_status(status): + if status == 'Active': + return 'Maintained' + elif status == 'Orphan': + return 'Orphan (since %s)' % orphaned_date + else: + print 'Error: %s: unknown status' % status + sys.exit(1) + +class Board: + def __init__(self, name, status, files, maintainers): + self.name = name + self.status = status + self.files = files + self.maintainers = maintainers + def append(self, files): + self.files += files + +# remove old MAINTAINERS files +subprocess.call("find board -name MAINTAINERS | xargs -r rm", shell=True) + +# store all the boards in this dictionary +all_boards = {} + +for line in open(INPUT_FILE): + if line[0] == '#' or line == '\n': + if line == '# The following were moved to "Orphan" in June, 2014\n': + orphaned_date = '2014-06' + elif line == '# The following were moved to "Orphan" in April, 2014\n': + orphaned_date = '2014-04' + elif line == '# The following were moved to "Orphan" in March, 2014\n': + orphaned_date = '2014-03' + elif line == '# The following were move to "Orphan" in September, 2013\n': + orphaned_date = '2013-09' + continue + (status, arch, cpu, soc, vendor, board, target, options, maintainers) = \ + line.rstrip().split(None, 8) + status = get_status(status) + if options == '-': + config = target + else: + config = options.split(':')[0] + # path of MAINTAINERS file: board//MAINTAINERS + if board == '-': + path = vendor + elif vendor == '-': + path = board + else: + path = os.path.join(vendor, board) + #name = get_board_name(board, target) + if board == '-': + files = [] + elif vendor == '-': + files = [ 'board/' + board + '/' ] + else: + files = [ 'board/' + vendor + '/' + board + '/' ] + files.append('include/configs/' + config + '.h') + files.append('configs/' + target + '_defconfig') + # On the first occurance of this MAINTAINERS path, add an empty list + if not path in all_boards: + all_boards[path] = [] + # boards_list is the list of boards that share the same MAINTAINERS file + boards_list = all_boards[path] + for b in boards_list: + remove_list = [] + for f in files: + if f in b.files: + remove_list.append(f) + for f in remove_list: + files.remove(f) + i = 0 + for b in boards_list: + if status == b.status and maintainers == b.maintainers: + b.append(files) + break + i += 1 + else: + if i == 0: + name = board.upper() + else: + name = target.upper() + boards_list.append(Board(name, status, files, maintainers)) + +for path, boards_list in all_boards.items(): + path = os.path.join('board', path, 'MAINTAINERS') + wfile = open(path, 'w') + first_loop = True + for b in boards_list: + if first_loop: + first_loop = False + else: + wfile.write('\n') + wfile.write(b.name.upper() + ' BOARD\n') + for maintainer in b.maintainers.split(':'): + wfile.write('M:\t%s\n' % maintainer) + wfile.write('S:\t%s\n' % b.status) + for file in b.files: + wfile.write('F:\t%s\n' % file)