Move post_src_install metadata code to one func.
authorZac Medico <zmedico@gentoo.org>
Mon, 11 Jun 2012 23:08:21 +0000 (16:08 -0700)
committerZac Medico <zmedico@gentoo.org>
Mon, 11 Jun 2012 23:08:21 +0000 (16:08 -0700)
pym/_emerge/EbuildPhase.py
pym/portage/dbapi/bintree.py
pym/portage/package/ebuild/doebuild.py

index 741f6083eff1546b6354c2b6960136cc02f3d3cc..fe44abcbd274be434bb9843f398985e7b14cbbf8 100644 (file)
@@ -27,9 +27,9 @@ portage.proxy.lazyimport.lazyimport(globals(),
        'portage.elog:messages@elog_messages',
        'portage.package.ebuild.doebuild:_check_build_log,' + \
                '_post_phase_cmds,_post_phase_userpriv_perms,' + \
-               '_post_src_install_chost_fix,' + \
                '_post_src_install_soname_symlinks,' + \
                '_post_src_install_uid_fix,_postinst_bsdflags,' + \
+               '_post_src_install_write_metadata,' + \
                '_preinst_bsdflags'
 )
 from portage import os
@@ -215,7 +215,7 @@ class EbuildPhase(CompositeTask):
 
                if self.phase == "install":
                        out = io.StringIO()
-                       _post_src_install_chost_fix(settings)
+                       _post_src_install_write_metadata(settings)
                        _post_src_install_uid_fix(settings, out)
                        msg = out.getvalue()
                        if msg:
index a8027ee6c187a91e4ed0009931525feda2853760..fb315729c02c982e520e145854dfa5bc5c92af29 100644 (file)
@@ -10,7 +10,6 @@ portage.proxy.lazyimport.lazyimport(globals(),
        'portage.dep:dep_getkey,isjustname,match_from_list',
        'portage.output:EOutput,colorize',
        'portage.locks:lockfile,unlockfile',
-       'portage.package.ebuild.doebuild:_vdb_use_conditional_atoms',
        'portage.package.ebuild.fetch:_check_distfile,_hide_url_passwd',
        'portage.update:update_dbentries',
        'portage.util:atomic_ofstream,ensure_dirs,normalize_path,' + \
index bb2c2e02b0efbcb91eb4768a2e8422f9a5365152..edc5d0b6e031c08e1932d28d0af7ddacab51470f 100644 (file)
@@ -1623,7 +1623,7 @@ def _check_build_log(mysettings, out=None):
        if f_real is not None:
                f_real.close()
 
-def _post_src_install_chost_fix(settings):
+def _post_src_install_write_metadata(settings):
        """
        It's possible that the ebuild has changed the
        CHOST variable, so revert it to the initial
@@ -1646,9 +1646,44 @@ def _post_src_install_chost_fix(settings):
                        if v is not None:
                                write_atomic(os.path.join(build_info_dir, k), v + '\n')
 
+       with io.open(_unicode_encode(os.path.join(build_info_dir,
+               'BUILD_TIME'), encoding=_encodings['fs'], errors='strict'),
+               mode='w', encoding=_encodings['repo.content'],
+               errors='strict') as f:
+               f.write(_unicode_decode("%.0f\n" % (time.time(),)))
+
+       use = frozenset(settings['PORTAGE_USE'].split())
+       for k in _vdb_use_conditional_keys:
+               v = settings.configdict['pkg'].get(k)
+               filename = os.path.join(build_info_dir, k)
+               if v is None:
+                       try:
+                               os.unlink(filename)
+                       except OSError:
+                               pass
+                       continue
+
+               if k.endswith('DEPEND'):
+                       token_class = Atom
+               else:
+                       token_class = None
+
+               v = use_reduce(v, uselist=use, token_class=token_class)
+               v = paren_enclose(v)
+               if not v:
+                       try:
+                               os.unlink(filename)
+                       except OSError:
+                               pass
+                       continue
+               with io.open(_unicode_encode(os.path.join(build_info_dir,
+                       k), encoding=_encodings['fs'], errors='strict'),
+                       mode='w', encoding=_encodings['repo.content'],
+                       errors='strict') as f:
+                       f.write(_unicode_decode(v + '\n'))
+
 _vdb_use_conditional_keys = ('DEPEND', 'LICENSE', 'PDEPEND',
        'PROPERTIES', 'PROVIDE', 'RDEPEND', 'RESTRICT',)
-_vdb_use_conditional_atoms = frozenset(['DEPEND', 'PDEPEND', 'RDEPEND'])
 
 def _preinst_bsdflags(mysettings):
        if bsd_chflags:
@@ -1817,44 +1852,6 @@ def _post_src_install_uid_fix(mysettings, out):
        f.write(_unicode_decode(str(size) + '\n'))
        f.close()
 
-       f = io.open(_unicode_encode(os.path.join(build_info_dir,
-               'BUILD_TIME'), encoding=_encodings['fs'], errors='strict'),
-               mode='w', encoding=_encodings['repo.content'],
-               errors='strict')
-       f.write(_unicode_decode("%.0f\n" % (time.time(),)))
-       f.close()
-
-       use = frozenset(mysettings['PORTAGE_USE'].split())
-       for k in _vdb_use_conditional_keys:
-               v = mysettings.configdict['pkg'].get(k)
-               filename = os.path.join(build_info_dir, k)
-               if v is None:
-                       try:
-                               os.unlink(filename)
-                       except OSError:
-                               pass
-                       continue
-
-               if k.endswith('DEPEND'):
-                       token_class = Atom
-               else:
-                       token_class = None
-
-               v = use_reduce(v, uselist=use, token_class=token_class)
-               v = paren_enclose(v)
-               if not v:
-                       try:
-                               os.unlink(filename)
-                       except OSError:
-                               pass
-                       continue
-               f = io.open(_unicode_encode(os.path.join(build_info_dir,
-                       k), encoding=_encodings['fs'], errors='strict'),
-                       mode='w', encoding=_encodings['repo.content'],
-                       errors='strict')
-               f.write(_unicode_decode(v + '\n'))
-               f.close()
-
        _reapply_bsdflags_to_image(mysettings)
 
 def _reapply_bsdflags_to_image(mysettings):