From patchwork Fri Oct 7 10:33:15 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mattias Backman X-Patchwork-Id: 4564 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 B88C223EF7 for ; Fri, 7 Oct 2011 10:33:19 +0000 (UTC) Received: from mail-yx0-f180.google.com (mail-yx0-f180.google.com [209.85.213.180]) by fiordland.canonical.com (Postfix) with ESMTP id 57816A18E95 for ; Fri, 7 Oct 2011 10:33:19 +0000 (UTC) Received: by yxm34 with SMTP id 34so5113219yxm.11 for ; Fri, 07 Oct 2011 03:33:18 -0700 (PDT) Received: by 10.223.92.152 with SMTP id r24mr9909960fam.19.1317983598286; Fri, 07 Oct 2011 03:33:18 -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.23.170 with SMTP id n10cs519laf; Fri, 7 Oct 2011 03:33:17 -0700 (PDT) Received: by 10.216.189.82 with SMTP id b60mr603846wen.23.1317983596407; Fri, 07 Oct 2011 03:33:16 -0700 (PDT) Received: from indium.canonical.com (indium.canonical.com. [91.189.90.7]) by mx.google.com with ESMTPS id t64si6190547weq.52.2011.10.07.03.33.15 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 07 Oct 2011 03:33:16 -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 1RC7jv-0004Tr-Fa for ; Fri, 07 Oct 2011 10:33:15 +0000 Received: from ackee.canonical.com (localhost [127.0.0.1]) by ackee.canonical.com (Postfix) with ESMTP id 6D16FE09E7 for ; Fri, 7 Oct 2011 10:33:15 +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: 444 X-Launchpad-Notification-Type: branch-revision To: Linaro Patch Tracker From: noreply@launchpad.net Subject: [Branch ~linaro-image-tools/linaro-image-tools/trunk] Rev 444: Enable just removing a package with linaro-hwpack-replace. Message-Id: <20111007103315.16429.58632.launchpad@ackee.canonical.com> Date: Fri, 07 Oct 2011 10:33:15 -0000 Reply-To: noreply@launchpad.net Sender: bounces@canonical.com Errors-To: bounces@canonical.com Precedence: bulk X-Generated-By: Launchpad (canonical.com); Revision="14085"; Instance="launchpad-lazr.conf" X-Launchpad-Hash: 3c17742b5c3ee98a107cf02c051b3ca24b40c7af Merge authors: Mattias Backman (mabac) Related merge proposals: https://code.launchpad.net/~mabac/linaro-image-tools/hwpack-replace-removes/+merge/78411 proposed by: Mattias Backman (mabac) review: Approve - James Westby (james-w) ------------------------------------------------------------ revno: 444 [merge] committer: Mattias Backman branch nick: linaro-image-tools timestamp: Fri 2011-10-07 12:31:03 +0200 message: Enable just removing a package with linaro-hwpack-replace. 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-08-23 12:06:46 +0000 +++ linaro-hwpack-replace 2011-10-06 13:42:25 +0000 @@ -115,16 +115,21 @@ """ Modify the manifest file to include the new debian information """ debpack_manifest_fname = os.path.join(tempdir, "manifest") - new_debpack_line = '%s=%s\n' % (new_debpack_info.name, new_debpack_info.version) + if new_debpack_info is not None: + new_debpack_line = '%s=%s\n' % (new_debpack_info.name, + new_debpack_info.version) for line in fileinput.FileInput(debpack_manifest_fname, inplace=1): if not should_remove(line, prefix_pkg_remove): sys.stdout.write(line) - logger.debug("Adding the new debian package info to manifest") - fout = open(debpack_manifest_fname, "a") - fout.write(new_debpack_line) - fout.close() + if new_debpack_info is not None: + logger.debug("Adding the new debian package info to manifest") + fout = open(debpack_manifest_fname, "a") + fout.write(new_debpack_line) + fout.close() + else: + logger.debug("Removed the debian package info from manifest") def modify_Packages_info(debpack_dirname, new_debpack_info, prefix_pkg_remove): @@ -138,7 +143,8 @@ for stanza in Packages.iter_paragraphs(f): if not should_remove(stanza["Package"], prefix_pkg_remove): output.append(stanza) - output.append(DummyStanza(new_debpack_info)) + if new_debpack_info is not None: + output.append(DummyStanza(new_debpack_info)) f.seek(0,0) f.truncate() @@ -152,8 +158,7 @@ def main(): # Validate that all the required information is passed on the command line args = parser.parse_args() - if (args.hwpack_name == None or args.deb_pack == None or - args.prefix_pkg_remove == None): + if (args.hwpack_name == None or args.prefix_pkg_remove == None): parser.print_help() parser.error("You must specify both hwpack name "\ "and the debian package information\n") @@ -186,12 +191,15 @@ logger.error("Failed to extract the hwpack: %s ", old_hwpack) return status - new_debpack_info = FetchedPackage.from_deb(new_deb_file_to_copy) + new_debpack_info = None + if new_deb_file_to_copy is not None: + new_debpack_info = FetchedPackage.from_deb(new_deb_file_to_copy) verify_existing_debians(debpack_dirname, prefix_pkg_remove) # Copy the new debian file to the pkgs dir, - shutil.copy2(new_deb_file_to_copy, debpack_dirname) + if new_deb_file_to_copy is not None: + shutil.copy2(new_deb_file_to_copy, debpack_dirname) modify_manifest_info(tempdir, new_debpack_info, prefix_pkg_remove)