From patchwork Tue Apr 30 12:31:19 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Senthil Kumaran X-Patchwork-Id: 16521 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qe0-f71.google.com (mail-qe0-f71.google.com [209.85.128.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 4F97520065 for ; Tue, 30 Apr 2013 12:31:28 +0000 (UTC) Received: by mail-qe0-f71.google.com with SMTP id 1sf765966qee.6 for ; Tue, 30 Apr 2013 05:31:25 -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=ayrL+cfZsHhgBViQDA5c0IYB4OcqNtv43caV0wsbMC8=; b=PGjcNRh7uBXmvSwTJOBfIS2e958LySp7V8EB6eA+zM7VGeeb8O7ss5N1zalCY05ur3 pOcf9H10m6J/ZmpSCzEiskxaBdlQFEg4AUwuXyyDe4q8DtsdOdx0BShx8oSAFUYeT6qu nszfnGH2Jd/NDNvBMSofBT067DK6R9nV5HApSV8w9soQrF0PQp7VyY5jP7dQl/Q5T5LB tLVI6poMCvrMNuJbRCavAQBF1AjqzUSkeWApzvIWsZkdxtV9AjBMWnTd/9CPh5WnZcX+ xqgN5snAuDAK5feAd67g7k+Qhep/O07w7bheX8lR1cosdON6T5u76mF3ykLo5mXBeMbG SghA== X-Received: by 10.236.170.7 with SMTP id o7mr30094205yhl.1.1367325085389; Tue, 30 Apr 2013 05:31:25 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.106.133 with SMTP id gu5ls219839qeb.28.gmail; Tue, 30 Apr 2013 05:31:25 -0700 (PDT) X-Received: by 10.52.69.179 with SMTP id f19mr29529275vdu.93.1367325082492; Tue, 30 Apr 2013 05:31:22 -0700 (PDT) Received: from mail-vc0-f180.google.com (mail-vc0-f180.google.com [209.85.220.180]) by mx.google.com with ESMTPS id q17si11951884vcw.76.2013.04.30.05.31.22 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Apr 2013 05:31:22 -0700 (PDT) Received-SPF: neutral (google.com: 209.85.220.180 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=209.85.220.180; Received: by mail-vc0-f180.google.com with SMTP id m17so339101vca.25 for ; Tue, 30 Apr 2013 05:31:22 -0700 (PDT) X-Received: by 10.220.189.9 with SMTP id dc9mr21348778vcb.8.1367325082356; Tue, 30 Apr 2013 05:31:22 -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 nf2csp104320veb; Tue, 30 Apr 2013 05:31:20 -0700 (PDT) X-Received: by 10.194.92.231 with SMTP id cp7mr16337362wjb.3.1367325080230; Tue, 30 Apr 2013 05:31:20 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id ay8si5590538wib.61.2013.04.30.05.31.19 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 30 Apr 2013 05:31:20 -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 1UX9iJ-00075j-Lu for ; Tue, 30 Apr 2013 12:31:19 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 9560EE092D for ; Tue, 30 Apr 2013 12:31:19 +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: 592 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-validation/lava-dispatcher/trunk] Rev 592: Fix bug #1174179 - Obtain test boot partition from config. Message-Id: <20130430123119.21169.61160.launchpad@ackee.canonical.com> Date: Tue, 30 Apr 2013 12:31:19 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: list X-Generated-By: Launchpad (canonical.com); Revision="16580"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: a3ac15f5413d71674abe2787b84d270a1b7d7f68 X-Gm-Message-State: ALoCoQmyu4VEkQZR/Bs0NfBYZvsJlhajlHjpWZc/LQoZ6uPpN4/kpETeJRGdPpVwEvt/On2MDz4J X-Original-Sender: noreply@launchpad.net X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 209.85.220.180 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/fix-bug-1174179/+merge/161584 proposed by: Senthil Kumaran S (stylesen) review: Approve - Dave Pigott (dpigott) ------------------------------------------------------------ revno: 592 [merge] committer: Senthil Kumaran branch nick: trunk timestamp: Tue 2013-04-30 17:59:48 +0530 message: Fix bug #1174179 - Obtain test boot partition from config. modified: lava_dispatcher/config.py lava_dispatcher/default-config/lava-dispatcher/device-defaults.conf 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-23 10:47:45 +0000 +++ lava_dispatcher/config.py 2013-04-29 10:31:06 +0000 @@ -72,6 +72,8 @@ "fstab.partitions", "init.rc"]) boot_files = schema.ListOption(default=['boot.txt', 'uEnv.txt']) + boot_device = schema.IntOption(fatal=True) + testboot_offset = schema.IntOption(fatal=True) # see doc/sdmux.rst for details sdmux_id = schema.StringOption() sdmux_version = schema.StringOption(default="unknown") === modified file 'lava_dispatcher/default-config/lava-dispatcher/device-defaults.conf' --- lava_dispatcher/default-config/lava-dispatcher/device-defaults.conf 2012-11-30 01:54:29 +0000 +++ lava_dispatcher/default-config/lava-dispatcher/device-defaults.conf 2013-04-29 10:31:06 +0000 @@ -122,3 +122,12 @@ # how long the disablesuspend script should take to complete #disablesuspend_timeout = 240 + +# This is the actual boot device for test images. Can be overridden in device +# specific config file. +boot_device = 0 + +# The test boot offset that should be added to the boot partition for data +# obtained from boot.txt or uEnv.txt and others. Can be overridden in device +# specific config file. +testboot_offset = 2 === modified file 'lava_dispatcher/device/master.py' --- lava_dispatcher/device/master.py 2013-04-25 11:36:15 +0000 +++ lava_dispatcher/device/master.py 2013-04-30 11:45:15 +0000 @@ -50,6 +50,8 @@ mk_targz, string_to_list, rmtree, + mkdtemp, + extract_targz, ) from lava_dispatcher.client.lmc_utils import ( generate_image, @@ -106,6 +108,7 @@ image_file = generate_image(self, hwpack, rfs, self.scratch_dir, bootloader) (boot_tgz, root_tgz, data) = self._generate_tarballs(image_file) + self._read_boot_cmds(boot_tgz=boot_tgz) self._deploy_tarballs(boot_tgz, root_tgz) def deploy_android(self, boot, system, userdata): @@ -153,6 +156,7 @@ image_file = download_image(image, self.context, self.scratch_dir) (boot_tgz, root_tgz, data) = self._generate_tarballs(image_file) + self._read_boot_cmds(boot_tgz=boot_tgz) self._deploy_tarballs(boot_tgz, root_tgz) def _deploy_tarballs(self, boot_tgz, root_tgz): @@ -173,16 +177,19 @@ raise CriticalError("Deployment failed") def _rewrite_partition_number(self, matchobj): - """ Returns the partition number after rewriting it to n+2. + """ Returns the partition number after rewriting it to + n + testboot_offset. """ - partition = int(matchobj.group('partition')) + 2 - return matchobj.group(0)[:2] + ':' + str(partition) + ' ' + boot_device = str(self.config.boot_device) + testboot_offset = self.config.testboot_offset + partition = int(matchobj.group('partition')) + testboot_offset + return ' ' + boot_device + ':' + 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 + * partition number from n to n + testboot_offset * root=LABEL=testrootfs instead of root=UUID=ab34-... """ boot_cmds = re.sub( @@ -194,19 +201,39 @@ 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: + def _read_boot_cmds(self, image=None, boot_tgz=None): + boot_file_path = None + + # If we have already obtained boot commands dynamically, then return. + if self.deployment_data.get('boot_cmds_dynamic', False): + logging.debug("We already have boot commands in place.") + return + + if 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): + boot_file_path = boot_path + break + + elif boot_tgz: + tmp_dir = mkdtemp() + extracted_files = extract_targz(boot_tgz, tmp_dir) 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 + for file_path in extracted_files: + if boot_file == os.path.basename(file_path): + boot_file_path = file_path + break + + if boot_file_path and os.path.exists(boot_file_path): + with open(boot_file_path, 'r') as f: + boot_cmds = self._rewrite_boot_cmds(f.read()) + self.deployment_data['boot_cmds_dynamic'] = boot_cmds + else: + logging.debug("Unable to read boot commands dynamically.") def _format_testpartition(self, runner, fstype): logging.info("Format testboot and testrootfs partitions") @@ -218,6 +245,7 @@ def _generate_tarballs(self, image_file): self._customize_linux(image_file) + self._read_boot_cmds(image=image_file) boot_tgz = os.path.join(self.scratch_dir, "boot.tgz") root_tgz = os.path.join(self.scratch_dir, "root.tgz") try: