From patchwork Mon Apr 22 12:06:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Senthil Kumaran X-Patchwork-Id: 16314 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f199.google.com (mail-vc0-f199.google.com [209.85.220.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id E08D323919 for ; Mon, 22 Apr 2013 12:07:20 +0000 (UTC) Received: by mail-vc0-f199.google.com with SMTP id gf12sf3740448vcb.2 for ; Mon, 22 Apr 2013 05:06:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:x-beenthere:x-received:received-spf:x-received :x-forwarded-to:x-forwarded-for:delivered-to:x-received:received-spf :mime-version:x-launchpad-project:x-launchpad-branch :x-launchpad-message-rationale:x-launchpad-branch-revision-number :x-launchpad-notification-type:to:from:subject:message-id:date :reply-to:sender:errors-to:precedence:x-generated-by :x-launchpad-hash:x-gm-message-state:x-original-sender :x-original-authentication-results:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe :content-type; bh=8h0bSuMY4Colk8YPb2TxghIXkGF7LLtc2o4uirsGORA=; b=A7ONZ/gO95qjLh3bicc+vifHDNfQn0b6Y6CoWsfZ1WymT+XxMGB8bQHIvv5inYdCnR 2DLbIBh0HfcDwrK1ZR2tCDybdvhDaCPWEwknx68GZmf6wDghcv0kIU07EzjJbJignEiW Nj5iPXUn49uN3s6KOBnuKjSYuVrw7clQIg5xor7X/Uc74epkOqLZEVSjqJK91T7xrnTY nuwjtdeszGyGad7d+I0/n1llkebQIgZqUQd8cefKF22H//VIQHKwUpWiJCxtuz+MMg2F IEzMuUFFzYoC+dyIDmbAHtQKNfVSu/FT6pRwhtL6JweS15whBS4i64aquI4830YWY7x/ AGfg== X-Received: by 10.236.98.105 with SMTP id u69mr12999129yhf.26.1366632394624; Mon, 22 Apr 2013 05:06:34 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.35.136 with SMTP id h8ls566638qej.31.gmail; Mon, 22 Apr 2013 05:06:34 -0700 (PDT) X-Received: by 10.220.137.145 with SMTP id w17mr18874037vct.73.1366632394451; Mon, 22 Apr 2013 05:06:34 -0700 (PDT) Received: from mail-vb0-x22b.google.com (mail-vb0-x22b.google.com [2607:f8b0:400c:c02::22b]) by mx.google.com with ESMTPS id sa4si15739585vdc.101.2013.04.22.05.06.34 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 22 Apr 2013 05:06:34 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::22b is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::22b; Received: by mail-vb0-f43.google.com with SMTP id q12so5715682vbe.2 for ; Mon, 22 Apr 2013 05:06:34 -0700 (PDT) X-Received: by 10.52.166.103 with SMTP id zf7mr16038850vdb.94.1366632394266; Mon, 22 Apr 2013 05:06:34 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp73620veb; Mon, 22 Apr 2013 05:06:30 -0700 (PDT) X-Received: by 10.194.235.169 with SMTP id un9mr14302504wjc.1.1366632389839; Mon, 22 Apr 2013 05:06:29 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id s8si5787515wju.45.2013.04.22.05.06.29 (version=TLSv1 cipher=RC4-SHA bits=128/128); Mon, 22 Apr 2013 05:06:29 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) client-ip=91.189.90.7; Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1UUFVt-00039H-9l for ; Mon, 22 Apr 2013 12:06:29 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 3D71EE3055 for ; Mon, 22 Apr 2013 12:06:29 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: lava-dispatcher X-Launchpad-Branch: ~linaro-validation/lava-dispatcher/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 585 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 585: Untangle boot commands from lava dispatcher. See BP: Message-Id: <20130422120629.24704.70920.launchpad@ackee.canonical.com> Date: Mon, 22 Apr 2013 12:06:29 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: list X-Generated-By: Launchpad (canonical.com); Revision="16567"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: c73acf377b11ace5891ce646b387194f08ae7840 X-Gm-Message-State: ALoCoQn/fxueDOMas0oh3lEoF7CnQ6JScUalq/3xPCOKJ3mtn8paqi/2kqkwYHWbnQI0YgELSGvE X-Original-Sender: noreply@launchpad.net X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::22b is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Merge authors: Senthil Kumaran S (stylesen) Related merge proposals: https://code.launchpad.net/~stylesen/lava-dispatcher/untangle-boot-cmds/+merge/158274 proposed by: Senthil Kumaran S (stylesen) review: Needs Fixing - Antonio Terceiro (terceiro) ------------------------------------------------------------ revno: 585 [merge] committer: Senthil Kumaran branch nick: trunk timestamp: Mon 2013-04-22 17:35:02 +0530 message: Untangle boot commands from lava dispatcher. See BP: https://blueprints.launchpad.net/lava-dispatcher/+spec/untangle-boot-commands-from-dispatcher modified: lava_dispatcher/config.py lava_dispatcher/device/master.py --- lp:lava-dispatcher https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk You are subscribed to branch lp:lava-dispatcher. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-validation/lava-dispatcher/trunk/+edit-subscription === modified file 'lava_dispatcher/config.py' --- lava_dispatcher/config.py 2013-04-08 13:29:48 +0000 +++ lava_dispatcher/config.py 2013-04-22 09:39:22 +0000 @@ -71,6 +71,7 @@ possible_partitions_files = schema.ListOption(default=["init.partitions.rc", "fstab.partitions", "init.rc"]) + boot_files = schema.ListOption(default=['boot.txt', 'uEnv.txt']) # see doc/sdmux.rst for details sdmux_id = schema.StringOption() sdmux_version = schema.StringOption(default="unknown") === modified file 'lava_dispatcher/device/master.py' --- lava_dispatcher/device/master.py 2013-04-16 02:59:05 +0000 +++ lava_dispatcher/device/master.py 2013-04-22 09:39:22 +0000 @@ -23,6 +23,7 @@ import logging import os import time +import re import pexpect @@ -171,6 +172,41 @@ logging.exception("Deployment failed") raise CriticalError("Deployment failed") + def _rewrite_partition_number(self, matchobj): + """ Returns the partition number after rewriting it to n+2. + """ + partition = int(matchobj.group('partition')) + 2 + return matchobj.group(0)[:2] + ':' + str(partition) + ' ' + + def _rewrite_boot_cmds(self, boot_cmds): + """ + Returns boot_cmds list after rewriting things such as: + + partition number from n to n+2 + root=LABEL=testrootfs instead of root=UUID=ab34-... + """ + boot_cmds = re.sub( + r"root=UUID=\S+", "root=LABEL=testrootfs", boot_cmds, re.MULTILINE) + pattern = "\s+\d+:(?P\d+)\s+" + boot_cmds = re.sub( + pattern, self._rewrite_partition_number, boot_cmds, re.MULTILINE) + + return boot_cmds.split('\n') + + def _customize_linux(self, image): + super(MasterImageTarget, self)._customize_linux(image) + boot_part = self.config.boot_part + + # Read boot related file from the boot partition of image. + with image_partition_mounted(image, boot_part) as mnt: + for boot_file in self.config.boot_files: + boot_path = os.path.join(mnt, boot_file) + if os.path.exists(boot_path): + with open(boot_path, 'r') as f: + boot_cmds = self._rewrite_boot_cmds(f.read()) + self.deployment_data['boot_cmds_dynamic'] = boot_cmds + break + def _format_testpartition(self, runner, fstype): logging.info("Format testboot and testrootfs partitions") runner.run('umount /dev/disk/by-label/testrootfs', failok=True) @@ -421,8 +457,15 @@ boot_cmds = options['boot_cmds'].value logging.info('boot_cmds attribute: %s', boot_cmds) - boot_cmds = self.config.cp.get('__main__', boot_cmds) - self._boot(string_to_list(boot_cmds.encode('ascii'))) + + # Check if we have already got some values from image's boot file. + if self.deployment_data.get('boot_cmds_dynamic'): + boot_cmds = self.deployment_data['boot_cmds_dynamic'] + else: + boot_cmds = self.config.cp.get('__main__', boot_cmds) + boot_cmds = string_to_list(boot_cmds.encode('ascii')) + + self._boot(boot_cmds) def _boot(self, boot_cmds): try: