env_update: ensure_dirs, encode filename
authorZac Medico <zmedico@gentoo.org>
Tue, 14 May 2013 00:30:05 +0000 (17:30 -0700)
committerZac Medico <zmedico@gentoo.org>
Tue, 14 May 2013 00:30:05 +0000 (17:30 -0700)
pym/portage/util/env_update.py

index cf95467af3c0ce0abaffac3fed7882d83fe91df4..e9c06c5d0ffb67f5934de26590cbf12f6bf3ea67 100644 (file)
@@ -1,4 +1,4 @@
-# Copyright 2010-2012 Gentoo Foundation
+# Copyright 2010-2013 Gentoo Foundation
 # Distributed under the terms of the GNU General Public License v2
 
 __all__ = ['env_update']
@@ -210,8 +210,7 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env,
        # Update prelink.conf if we are prelink-enabled
        if prelink_capable:
                prelink_d = os.path.join(eroot, 'etc', 'prelink.conf.d')
-               if not os.path.isdir(prelink_d):
-                       os.makedirs(prelink_d)
+               ensure_dirs(prelink_d)
                newprelink = atomic_ofstream(os.path.join(prelink_d, 'portage.conf'))
                newprelink.write("# prelink.conf autogenerated by env-update; make all changes to\n")
                newprelink.write("# contents of /etc/env.d directory\n")
@@ -247,7 +246,8 @@ def _env_update(makelinks, target_root, prev_mtimes, contents, env,
                # point it to the new stuff until the prelink package re-installs.
                prelink_conf = os.path.join(eroot, 'etc', 'prelink.conf')
                try:
-                       with open(prelink_conf, 'rb') as f:
+                       with open(_unicode_encode(prelink_conf,
+                               encoding=_encodings['fs'], errors='strict'), 'rb') as f:
                                if f.readline() == b'# prelink.conf autogenerated by env-update; make all changes to\n':
                                        f = atomic_ofstream(prelink_conf)
                                        f.write('-c /etc/prelink.conf.d/*.conf\n')