From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from pigeon.gentoo.org ([208.92.234.80] helo=lists.gentoo.org) by finch.gentoo.org with esmtp (Exim 4.60) (envelope-from ) id 1QMECD-0007l2-OT for garchives@archives.gentoo.org; Tue, 17 May 2011 06:55:58 +0000 Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 66B271C00B; Tue, 17 May 2011 06:55:20 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) by pigeon.gentoo.org (Postfix) with ESMTP id 353CB1C00B for ; Tue, 17 May 2011 06:55:20 +0000 (UTC) Received: from pelican.gentoo.org (unknown [66.219.59.40]) (using TLSv1 with cipher ADH-CAMELLIA256-SHA (256/256 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 96EB81B400F for ; Tue, 17 May 2011 06:55:14 +0000 (UTC) Received: from localhost.localdomain (localhost [127.0.0.1]) by pelican.gentoo.org (Postfix) with ESMTP id B744180504 for ; Tue, 17 May 2011 06:55:13 +0000 (UTC) From: "Zac Medico" To: gentoo-commits@lists.gentoo.org Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "Zac Medico" Message-ID: Subject: [gentoo-commits] proj/portage:master commit in: pym/_emerge/ X-VCS-Repository: proj/portage X-VCS-Files: pym/_emerge/depgraph.py X-VCS-Directories: pym/_emerge/ X-VCS-Committer: zmedico X-VCS-Committer-Name: Zac Medico X-VCS-Revision: a6ea5746a7837e555a0a590a232f8ecdaf03fd89 Date: Tue, 17 May 2011 06:55:13 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: quoted-printable X-Archives-Salt: X-Archives-Hash: 72ed429b7f8da307449d8c179a42757f commit: a6ea5746a7837e555a0a590a232f8ecdaf03fd89 Author: Zac Medico gentoo org> AuthorDate: Tue May 17 06:54:52 2011 +0000 Commit: Zac Medico gentoo org> CommitDate: Tue May 17 06:54:52 2011 +0000 URL: http://git.overlays.gentoo.org/gitweb/?p=3Dproj/portage.git;a= =3Dcommit;h=3Da6ea5746 --autounmask-write: handle non-existent file --- pym/_emerge/depgraph.py | 22 ++++++++++++++++++++-- 1 files changed, 20 insertions(+), 2 deletions(-) diff --git a/pym/_emerge/depgraph.py b/pym/_emerge/depgraph.py index 3daaf44..9f3c1ac 100644 --- a/pym/_emerge/depgraph.py +++ b/pym/_emerge/depgraph.py @@ -5,6 +5,7 @@ from __future__ import print_function =20 import codecs import difflib +import errno import gc import logging import re @@ -5672,6 +5673,18 @@ class depgraph(object): no suitable file exists. """ file_path =3D os.path.join(abs_user_config, file_name) + + try: + os.lstat(file_path) + except OSError as e: + if e.errno =3D=3D errno.ENOENT: + # The file doesn't exist, so we'll + # simply create it. + return file_path + + # Disk or file system trouble? + return None + last_file_path =3D None stack =3D [file_path] while stack: @@ -5759,6 +5772,7 @@ class depgraph(object): shlex_split(settings.get("CONFIG_PROTECT_MASK", ""))) =20 def write_changes(root, changes, file_to_write_to): + file_contents =3D None try: file_contents =3D codecs.open( _unicode_encode(file_to_write_to, @@ -5766,8 +5780,12 @@ class depgraph(object): mode=3D'r', encoding=3D_encodings['content'], errors=3D'replace').readlines() except IOError as e: - problems.append("!!! Failed to read '%s': %s\n" % (file_to_write_to,= e)) - else: + if e.errno =3D=3D errno.ENOENT: + file_contents =3D [] + else: + problems.append("!!! Failed to read '%s': %s\n" % \ + (file_to_write_to, e)) + if file_contents is not None: file_contents.extend(changes) if protect_obj[root].isprotected(file_to_write_to): file_to_write_to =3D new_protect_filename(file_to_write_to)