diff options
author | Zac Medico <zmedico@gentoo.org> | 2012-10-25 01:35:31 -0700 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2012-10-25 01:45:22 -0700 |
commit | 10b6d0129d062f4d5d8a7611023c3f8cc43f1eab (patch) | |
tree | 840851adbd0f61a807311444b845244b25cf5492 /pym/portage | |
parent | 978f3c6d514f0fcf9329d536cc43cf1230e23112 (diff) | |
download | portage-10b6d0129d062f4d5d8a7611023c3f8cc43f1eab.tar.gz portage-10b6d0129d062f4d5d8a7611023c3f8cc43f1eab.tar.bz2 portage-10b6d0129d062f4d5d8a7611023c3f8cc43f1eab.zip |
Add FEATURES=merge-sync, for bug #439584.
Diffstat (limited to 'pym/portage')
-rw-r--r-- | pym/portage/const.py | 1 | ||||
-rw-r--r-- | pym/portage/dbapi/vartree.py | 41 |
2 files changed, 41 insertions, 1 deletions
diff --git a/pym/portage/const.py b/pym/portage/const.py index 3242861cf..8c5bbf308 100644 --- a/pym/portage/const.py +++ b/pym/portage/const.py @@ -96,6 +96,7 @@ SUPPORTED_FEATURES = frozenset([ "downgrade-backup", "ebuild-locks", "fakeroot", "fail-clean", "force-mirror", "force-prefix", "getbinpkg", "installsources", "keeptemp", "keepwork", "fixlafiles", "lmirror", + "merge-sync", "metadata-transfer", "mirror", "multilib-strict", "news", "noauto", "noclean", "nodoc", "noinfo", "noman", "nostrip", "notitles", "parallel-fetch", "parallel-install", diff --git a/pym/portage/dbapi/vartree.py b/pym/portage/dbapi/vartree.py index cb7b39b02..edc477a09 100644 --- a/pym/portage/dbapi/vartree.py +++ b/pym/portage/dbapi/vartree.py @@ -30,6 +30,7 @@ portage.proxy.lazyimport.lazyimport(globals(), 'portage.util.env_update:env_update', 'portage.util.listdir:dircache,listdir', 'portage.util.movefile:movefile', + 'portage.util._ctypes:find_library,LoadLibrary', 'portage.util._dyn_libs.PreservedLibsRegistry:PreservedLibsRegistry', 'portage.util._dyn_libs.LinkageMapELF:LinkageMapELF@LinkageMap', 'portage.util._async.SchedulerInterface:SchedulerInterface', @@ -73,6 +74,7 @@ import io from itertools import chain import logging import os as _os +import platform import pwd import re import stat @@ -4688,7 +4690,44 @@ class dblink(object): disk and avoid data-loss in the event of a power failure. This method does nothing if FEATURES=merge-sync is disabled. """ - pass + if not self._device_path_map or \ + "merge-sync" not in self.settings.features: + return + + syncfs = self._get_syncfs() + if syncfs is None: + try: + proc = subprocess.Popen(["sync"]) + except EnvironmentError: + pass + else: + proc.wait() + else: + for path in self._device_path_map.values(): + try: + fd = os.open(path, os.O_RDONLY) + except OSError: + pass + else: + try: + syncfs(fd) + except OSError: + pass + finally: + os.close(fd) + + def _get_syncfs(self): + if platform.system() == "Linux": + filename = find_library("c") + if filename is not None: + library = LoadLibrary(filename) + if library is not None: + try: + return library.syncfs + except AttributeError: + pass + + return None def merge(self, mergeroot, inforoot, myroot=None, myebuild=None, cleanup=0, mydbapi=None, prev_mtimes=None, counter=None): |