From patchwork Wed Oct 19 05:39:54 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Masahiro Yamada X-Patchwork-Id: 78173 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp72562qge; Tue, 18 Oct 2016 22:37:57 -0700 (PDT) X-Received: by 10.194.204.198 with SMTP id la6mr2825921wjc.2.1476855476989; Tue, 18 Oct 2016 22:37:56 -0700 (PDT) Return-Path: Received: from theia.denx.de (theia.denx.de. [85.214.87.163]) by mx.google.com with ESMTP id t185si2859667wmt.119.2016.10.18.22.37.54; Tue, 18 Oct 2016 22:37:56 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) client-ip=85.214.87.163; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@nifty.com; spf=pass (google.com: best guess record for domain of u-boot-bounces@lists.denx.de designates 85.214.87.163 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id 604F0A754C; Wed, 19 Oct 2016 07:37:53 +0200 (CEST) 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 rPsoRrANZc1V; Wed, 19 Oct 2016 07:37:53 +0200 (CEST) Received: from theia.denx.de (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id F3C82A7533; Wed, 19 Oct 2016 07:37:51 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by theia.denx.de (Postfix) with ESMTP id E0B1EA7533 for ; Wed, 19 Oct 2016 07:37:35 +0200 (CEST) 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 pRN4-AvnkvcL for ; Wed, 19 Oct 2016 07:37:34 +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 conuserg-07.nifty.com (conuserg-07.nifty.com [210.131.2.74]) by theia.denx.de (Postfix) with ESMTPS id 400ACA752D for ; Wed, 19 Oct 2016 07:37:28 +0200 (CEST) Received: from beagle.diag.org (p14092-ipngnfx01kyoto.kyoto.ocn.ne.jp [153.142.97.92]) (authenticated) by conuserg-07.nifty.com with ESMTP id u9J5bOjG002241; Wed, 19 Oct 2016 14:37:24 +0900 DKIM-Filter: OpenDKIM Filter v2.10.3 conuserg-07.nifty.com u9J5bOjG002241 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nifty.com; s=dec2015msa; t=1476855444; bh=3O0KQykZCZJMRrduZqgUi6TNjMOKMeMmhU837Pi2I2E=; h=From:To:Cc:Subject:Date:From; b=wW0mmvOPiirn2R65/phYBhnw/Q/HW4Gy3QglvlCeDxZCUIw0AlHUFlcXqSH0u2YBk E/tauZp5a96dpt8670/dU8f6qlC+Z66QsN5cxK7Fb+9AxjQoEpRzNAQTQT4AFbpnNg 5620cT3hst92pENoidICdnfCx6xa3ngHIPep/KZBgKLsxlB44IwELvQ4pLPb8sL4fP WjTZZWaQuCI1+Gifprqvbw6RHFUojfj6+z8C6dvuRsjbJAaQJnEAR9L4vhnA0tNHo5 Vj9zyk3UgXQ7gsRQr5sP6uVQoN2S6jXq+hIsotKB2P3DsnM/k2/GvVHXY6cgY93IbR y/mEfyz3k/LKQ== X-Nifty-SrcIP: [153.142.97.92] From: Masahiro Yamada To: u-boot@lists.denx.de Date: Wed, 19 Oct 2016 14:39:54 +0900 Message-Id: <1476855594-23654-1-git-send-email-yamada.masahiro@socionext.com> X-Mailer: git-send-email 1.9.1 Cc: Joe Hershberger Subject: [U-Boot] [PATCH v2] tools: moveconfig: support wildcards in --defconfigs file X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.15 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Supporting shell-style wildcards for the --defconfigs option will be useful to run the moveconfig tool against a specific platform. For example, "uniphier*" in the file passed by --defconfigs option will be expanded to defconfig files that start with "uniphier". This is easier than listing out all defconfig files you are interested in. Signed-off-by: Masahiro Yamada --- Changes in v2: - Warn when a pattern does not match any defconfig. (suggested by Joe) tools/moveconfig.py | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) -- 1.9.1 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot Reviewed-by: Joe Hershberger diff --git a/tools/moveconfig.py b/tools/moveconfig.py index 87e2bb2..228d098 100755 --- a/tools/moveconfig.py +++ b/tools/moveconfig.py @@ -127,7 +127,8 @@ Available options standard commit message is used which may need to be edited. -d, --defconfigs - Specify a file containing a list of defconfigs to move + Specify a file containing a list of defconfigs to move. The defconfig + files can be given with shell-style wildcards. -n, --dry-run Perform a trial run that does not make any changes. It is useful to @@ -180,6 +181,7 @@ import copy import difflib import filecmp import fnmatch +import glob import multiprocessing import optparse import os @@ -284,6 +286,24 @@ def get_make_cmd(): sys.exit('GNU Make not found') return ret[0].rstrip() +def get_matched_defconfigs(defconfigs_file): + """Get all the defconfig files that match the patterns in a file.""" + defconfigs = [] + for i, line in enumerate(open(defconfigs_file)): + line = line.strip() + if not line: + continue # skip blank lines silently + pattern = os.path.join('configs', line) + matched = glob.glob(pattern) + glob.glob(pattern + '_defconfig') + if not matched: + print >> sys.stderr, "warning: %s:%d: no defconfig matched '%s'" % \ + (defconfigs_file, i + 1, line) + + defconfigs += matched + + # use set() to drop multiple matching + return [ defconfig[len('configs') + 1:] for defconfig in set(defconfigs) ] + def get_all_defconfigs(): """Get all the defconfig files under the configs/ directory.""" defconfigs = [] @@ -1204,13 +1224,7 @@ def move_config(configs, options): reference_src_dir = None if options.defconfigs: - defconfigs = [line.strip() for line in open(options.defconfigs)] - for i, defconfig in enumerate(defconfigs): - if not defconfig.endswith('_defconfig'): - defconfigs[i] = defconfig + '_defconfig' - if not os.path.exists(os.path.join('configs', defconfigs[i])): - sys.exit('%s - defconfig does not exist. Stopping.' % - defconfigs[i]) + defconfigs = get_matched_defconfigs(options.defconfigs) else: defconfigs = get_all_defconfigs()