From patchwork Fri Jul 21 01:05:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnout Vandecappelle X-Patchwork-Id: 791824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xDCK56RPcz9s74 for ; Fri, 21 Jul 2017 11:06:49 +1000 (AEST) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 3DC3D885C0; Fri, 21 Jul 2017 01:06:46 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id ADiQRuz0_k4a; Fri, 21 Jul 2017 01:06:45 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 5889988676; Fri, 21 Jul 2017 01:06:45 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 8D84B1C01DA for ; Fri, 21 Jul 2017 01:06:05 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 82FAA886F5 for ; Fri, 21 Jul 2017 01:06:05 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HgAl-u9Gb37x for ; Fri, 21 Jul 2017 01:06:05 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.7.6 Received: from exchange.essensium.com (220.77.144.195.ipv4.evonet.be [195.144.77.220]) by fraxinus.osuosl.org (Postfix) with ESMTPS id DC22E886F3 for ; Fri, 21 Jul 2017 01:06:04 +0000 (UTC) Received: from localhost.localdomain (10.3.7.11) by beleexch01.local.ess-mail.com (10.3.7.8) with Microsoft SMTP Server (TLS) id 15.0.847.32; Fri, 21 Jul 2017 03:05:48 +0200 From: "Arnout Vandecappelle (Essensium/Mind)" To: Date: Fri, 21 Jul 2017 03:05:26 +0200 Message-ID: <20170721010530.4747-20-arnout@mind.be> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170721010530.4747-1-arnout@mind.be> References: <20170721010530.4747-1-arnout@mind.be> MIME-Version: 1.0 X-Originating-IP: [10.3.7.11] X-ClientProxiedBy: beleexch01.local.ess-mail.com (10.3.7.8) To beleexch01.local.ess-mail.com (10.3.7.8) Cc: Thomas Petazzoni Subject: [Buildroot] [PATCH v7 19/23] genrandconfig: get configs from in-tree toolchain-configs.csv X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" Now we have the toolchain config fragments in the buildroot directory itself, it is no longer necessary to fetch it from the toolchain URL. The --toolchains-url option is renamed to --toolchains-csv. The paths in the toolchains_csv file should be either absolute, or relative to buildrootdir. After this change, the script should be called from autobuild-run as: subprocess.call([os.path.join(srcdir, "utils/genrandconfig"), "-o", outputdir, "-b", srcdir, "--toolchains-csv", kwargs['toolchains_csv']], stdout=devnull, stderr=log) Signed-off-by: Arnout Vandecappelle (Essensium/Mind) --- v7: new patch --- utils/genrandconfig | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/utils/genrandconfig b/utils/genrandconfig index d397b23f36..a67d46fad9 100755 --- a/utils/genrandconfig +++ b/utils/genrandconfig @@ -118,15 +118,15 @@ class SystemInfo: return not missing_requirements -def get_toolchain_configs(toolchains_url): +def get_toolchain_configs(toolchains_csv, buildrootdir): """Fetch and return the possible toolchain configurations This function returns an array of toolchain configurations. Each toolchain configuration is itself an array of lines of the defconfig. """ - with urlopen_closing(toolchains_url) as r: - toolchains_csv = decode_byte_list(r.readlines()) + with open(toolchains_csv) as r: + toolchains = decode_byte_list(r.readlines()) configs = [] (_, _, _, _, hostarch) = os.uname() @@ -134,9 +134,9 @@ def get_toolchain_configs(toolchains_url): if hostarch == 'i686' or hostarch == 'i386' or hostarch == 'x86': hostarch = 'x86' - for row in csv.reader(toolchains_csv): + for row in csv.reader(toolchains): config = {} - url = row[0] + configfile = row[0] config_hostarch = row[1] keep = False @@ -158,8 +158,11 @@ def get_toolchain_configs(toolchains_url): if not keep: continue - with urlopen_closing(url) as r: - config = decode_byte_list(r.readlines()) + if not os.path.isabs(configfile): + configfile = os.path.join(buildrootdir, configfile) + + with open(configfile) as r: + config = r.readlines() configs.append(config) return configs @@ -329,7 +332,7 @@ def gen_config(args): """ # Select a random toolchain configuration - configs = get_toolchain_configs(args.toolchains_url) + configs = get_toolchain_configs(args.toolchains_csv, args.buildrootdir) i = randint(0, len(configs) - 1) toolchainconfig = configs[i] @@ -408,10 +411,10 @@ if __name__ == '__main__': parser.add_argument("--buildrootdir", "-b", help="Buildroot directory (relative to current directory)", type=str, default='.') - parser.add_argument("--toolchains-url", - help="URL of toolchain configuration file", + parser.add_argument("--toolchains-csv", + help="Path of the toolchain configuration file", type=str, - default="http://autobuild.buildroot.org/toolchains/configs/toolchain-configs.csv") + default="support/config-fragments/autobuild/toolchain-configs.csv") args = parser.parse_args() # We need the absolute path to use with O=, because the relative