From patchwork Thu Oct 4 16:57:14 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fathi Boudra X-Patchwork-Id: 11990 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 60AF224162 for ; Thu, 4 Oct 2012 16:57:18 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id D3F55A18CA9 for ; Thu, 4 Oct 2012 16:57:17 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so1430624iej.11 for ; Thu, 04 Oct 2012 09:57:17 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :content-type: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; bh=V+qoWgbawIbbjy0V5Fi4fCGuzXF6mXYeNfuCodrF9pI=; b=NoIoemiKU8qZ6fQA4LtNn9B2CdbH5JTQnJwoYNaqLTPeC0X2yco33DQAA08lPwWzJ1 n/1vwo5fQqiGEj9t3yewTuYw8Xa7QBzwLtda80vn24xWSeSzMseistMoMfbh1IkQbOzu 61DdgY71dXeIim+EvMQ3BX9U3f2cdDcVRClWUGIUhFrF4rpf0mcduvsoVq3OFOwLIbkN lLk4mwkqaT0I7e/A9osWZDXEtdO5OwcEIQZAx2qlFthQN0E5rJTb8iJAqE/uGY6PeQuK GVkqxpxtD3h4HOmeX1meFbuCDfUYIe5IcilXuqlbkAhK8NQnsPX0SsYXyiUFc/zEyI4O 8+Vg== Received: by 10.50.7.212 with SMTP id l20mr5931382iga.43.1349369837247; Thu, 04 Oct 2012 09:57:17 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.184.232 with SMTP id ex8csp77718igc; Thu, 4 Oct 2012 09:57:16 -0700 (PDT) Received: by 10.180.76.69 with SMTP id i5mr14276678wiw.9.1349369835385; Thu, 04 Oct 2012 09:57:15 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id o1si5759779wea.147.2012.10.04.09.57.14 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 04 Oct 2012 09:57:15 -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; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of bounces@canonical.com designates 91.189.90.7 as permitted sender) smtp.mail=bounces@canonical.com Received: from ackee.canonical.com ([91.189.89.26]) by indium.canonical.com with esmtp (Exim 4.71 #1 (Debian)) id 1TJoja-0004Po-Ad for ; Thu, 04 Oct 2012 16:57:14 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 44CA1E0341 for ; Thu, 4 Oct 2012 16:57:14 +0000 (UTC) MIME-Version: 1.0 X-Launchpad-Project: linaro-image-tools X-Launchpad-Branch: ~linaro-image-tools/linaro-image-tools/trunk X-Launchpad-Message-Rationale: Subscriber X-Launchpad-Branch-Revision-Number: 572 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 572: Add Build-Info support. Message-Id: <20121004165714.32145.49341.launchpad@ackee.canonical.com> Date: Thu, 04 Oct 2012 16:57:14 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="16061"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 515c67b38ef59554a33e0825f08ba978260bae75 X-Gm-Message-State: ALoCoQnWXDJxMp9+yXAqzLiX6r/7fquxOCNF6Wmeh2Q1I+z1+yvzQXJ2ZqgOmEhClsKQpLz5zSBz Merge authors: Fathi Boudra (fboudra) Related merge proposals: https://code.launchpad.net/~fboudra/linaro-image-tools/add-build-info-support/+merge/127799 proposed by: Fathi Boudra (fboudra) review: Needs Fixing - Milo Casagrande (milo) ------------------------------------------------------------ revno: 572 [merge] committer: fboudra@gmail.com branch nick: linaro-image-tools timestamp: Thu 2012-10-04 19:56:35 +0300 message: Add Build-Info support. modified: linaro_image_tools/hwpack/builder.py --- lp:linaro-image-tools https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk You are subscribed to branch lp:linaro-image-tools. To unsubscribe from this branch go to https://code.launchpad.net/~linaro-image-tools/linaro-image-tools/trunk/+edit-subscription === modified file 'linaro_image_tools/hwpack/builder.py' --- linaro_image_tools/hwpack/builder.py 2012-09-11 14:28:20 +0000 +++ linaro_image_tools/hwpack/builder.py 2012-10-04 16:54:48 +0000 @@ -25,6 +25,9 @@ import tempfile import os import shutil +from glob import iglob + +from debian.debfile import DebFile from linaro_image_tools import cmd_runner @@ -65,7 +68,7 @@ shutil.rmtree(self.tempdir) def get_path(self, package_file_name, file_name=''): - "Get package or file path in unpacker tmp dir." + """Get package or file path in unpacker tmp dir.""" package_dir = os.path.basename(package_file_name) return os.path.join(self.tempdir, package_dir, file_name) @@ -214,7 +217,7 @@ self.foreach_boards_and_bootloaders( self.do_find_copy_files_packages) packages = self.copy_files_packages - del(self.copy_files_packages) + del self.copy_files_packages return packages def build(self): @@ -328,3 +331,45 @@ manifest_name += '.manifest.txt' with open(manifest_name, 'w') as f: f.write(self.hwpack.manifest_text()) + + logger.debug("Extracting build-info") + build_info_dir = os.path.join(fetcher.cache.tempdir, + 'build-info') + build_info_available = 0 + for deb_pkg in self.packages: + # Extract Build-Info attribute from debian control + deb_pkg_file_path = deb_pkg.filepath + deb_control = \ + DebFile(deb_pkg_file_path).control.debcontrol() + build_info = deb_control.get('Build-Info') + if build_info is not None: + build_info_available += 1 + # Extract debian packages with build + # information + env = os.environ + env['LC_ALL'] = 'C' + env['NO_PKG_MANGLE'] = '1' + proc = cmd_runner.Popen(['dpkg-deb', '-x', + deb_pkg_file_path, build_info_dir], + env=env, stdout=subprocess.PIPE, + stderr=subprocess.PIPE) + (stdoutdata, stderrdata) = proc.communicate() + if proc.returncode: + raise ValueError('dpkg-deb extract failed!' + '\n%s' % stderrdata) + if stderrdata: + raise ValueError('dpkg-deb extract had ' + 'warnings:\n%s' % stderrdata) + + # Concatenate BUILD-INFO.txt files + if build_info_available > 0: + dst_file = open('BUILD-INFO.txt', 'wb') + build_info_path = \ + r'%s/usr/share/doc/*/BUILD-INFO.txt' % \ + build_info_dir + for src_file in iglob(build_info_path): + with open(src_file, 'rb') as f: + dst_file.write('Files-Pattern: %s\n' % \ + out_name) + shutil.copyfileobj(f, dst_file) + dst_file.close()