From patchwork Wed Oct 12 07:39:14 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Deepti B. Kalakeri" X-Patchwork-Id: 4640 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 2524C23EF5 for ; Wed, 12 Oct 2011 07:39:17 +0000 (UTC) Received: from mail-ey0-f180.google.com (mail-ey0-f180.google.com [209.85.215.180]) by fiordland.canonical.com (Postfix) with ESMTP id 07DE1A18473 for ; Wed, 12 Oct 2011 07:39:17 +0000 (UTC) Received: by eyg5 with SMTP id 5so598543eyg.11 for ; Wed, 12 Oct 2011 00:39:16 -0700 (PDT) Received: by 10.223.85.134 with SMTP id o6mr45007693fal.8.1318405156708; Wed, 12 Oct 2011 00:39:16 -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.152.24.41 with SMTP id r9cs201336laf; Wed, 12 Oct 2011 00:39:16 -0700 (PDT) Received: by 10.216.135.194 with SMTP id u44mr4291357wei.42.1318405155448; Wed, 12 Oct 2011 00:39:15 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id f17si858390wed.28.2011.10.12.00.39.15 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 12 Oct 2011 00:39: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 1RDtPG-000676-Si for ; Wed, 12 Oct 2011 07:39:14 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id CD59FE0030 for ; Wed, 12 Oct 2011 07:39: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: 445 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 445: Add a -i, --in-place option to modify the specified hwpack rather than making a new one and also ... Message-Id: <20111012073914.8063.31826.launchpad@ackee.canonical.com> Date: Wed, 12 Oct 2011 07:39: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="14124"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 218964ba8323fdaf6c0d4b879bea33fd1a4f47d4 Merge authors: Paul Larson (pwlars) Related merge proposals: https://code.launchpad.net/~pwlars/linaro-image-tools/linaro-hwpack-replace-in-place/+merge/79049 proposed by: Paul Larson (pwlars) review: Approve - Deepti B. Kalakeri (deeptik) ------------------------------------------------------------ revno: 445 [merge] committer: Deepti B. Kalakeri branch nick: linaro-image-tools timestamp: Wed 2011-10-12 13:04:51 +0530 message: Add a -i, --in-place option to modify the specified hwpack rather than making a new one and also cleanup tempdir modified: linaro-hwpack-replace --- 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-hwpack-replace' --- linaro-hwpack-replace 2011-10-06 13:42:25 +0000 +++ linaro-hwpack-replace 2011-10-12 07:34:51 +0000 @@ -45,6 +45,8 @@ parser.add_argument("-r", "--prefix-pkg-remove", dest="prefix_pkg_remove", help="Specify the prefix of the old debian package to "\ "replace (default: None).") +parser.add_argument("-i", "--in-place", action="store_true", dest="inplace", + help="Modify the hwpack rather than creating a new one") parser.add_argument("-d", "--debug-output", action="store_true", dest="debug", help="Verbose messages are displayed when specified") @@ -182,6 +184,7 @@ tar = tarfile.open(old_hwpack, "r:gz") tempdir = tempfile.mkdtemp() tar.extractall(tempdir) + tar.close() # Search if a similar package with the same name exists, if yes then # replace it. IF the old and new debian have the same name then we @@ -206,15 +209,26 @@ modify_Packages_info(debpack_dirname, new_debpack_info, prefix_pkg_remove) #tar the hardware pack with the new debian file included in it - tar = tarfile.open( hwpack_name , "w:gz") + tar = tarfile.open(hwpack_name , "w:gz") + origdir = os.getcwd() os.chdir(tempdir) for file_name in glob.glob('*'): tar.add(file_name, recursive=True) tar.close() + + # Retain old hwpack name instead of using a new name + os.chdir(origdir) + if args.inplace: + os.rename(hwpack_name, old_hwpack) + hwpack_name = old_hwpack + except Exception, details: logger.error("Error Details: %s", details) status = 1 + finally: + shutil.rmtree(tempdir) + if status == 0: logger.info("The debian package '%s' has been been included in '%s'", new_deb_file_to_copy, hwpack_name)