def __enter__(self): assert not self._joined, "cannot join environment twice" for directory in ['/dev', '/sys', '/proc']: execute_command('mount', '--bind', directory, joinpaths(self.root, directory[1:])) execute_command('mount', '--bind', config.GLOBAL_PACMAN_CACHE, joinpaths(self.root, 'var/cache/pacman')) self._joined = True
def __exit__(self, *exc_info): for directory in ['dev', 'sys', 'proc', 'var/cache/pacman']: execute_command('umount', joinpaths(self.root, directory)) self._joined = False
def execute(self, *command): assert self._joined, "join first" execute_command('chroot', self.root, *command)
def execute(self, *args): execute_command(*self._get_command(*args))