예제 #1
0
파일: sync.py 프로젝트: aeroniero33/portage
	def _sync(self, selected_repos, return_messages,
		emaint_opts=None):

		if emaint_opts is not None:
			for k, v in emaint_opts.items():
				if v is not None:
					k = "--" + k.replace("_", "-")
					self.emerge_config.opts[k] = v

		selected_repos = [repo for repo in selected_repos if repo.sync_type is not None]
		msgs = []
		if not selected_repos:
			msgs.append("Emaint sync, nothing to sync... returning")
			if return_messages:
				msgs.extend(self.rmessage([('None', os.EX_OK)], 'sync'))
				return msgs
			return
		# Portage needs to ensure a sane umask for the files it creates.
		os.umask(0o22)

		sync_manager = SyncManager(
			self.emerge_config.target_config.settings, emergelog)

		max_jobs = (self.emerge_config.opts.get('--jobs', 1)
			if 'parallel-fetch' in self.emerge_config.
			target_config.settings.features else 1)
		sync_scheduler = SyncScheduler(emerge_config=self.emerge_config,
			selected_repos=selected_repos, sync_manager=sync_manager,
			max_jobs=max_jobs,
			event_loop=global_event_loop() if portage._internal_caller else
				EventLoop(main=False))

		sync_scheduler.start()
		sync_scheduler.wait()
		retvals = sync_scheduler.retvals
		msgs.extend(sync_scheduler.msgs)

		if retvals:
			msgs.extend(self.rmessage(retvals, 'sync'))
		else:
			msgs.extend(self.rmessage([('None', os.EX_OK)], 'sync'))

		# run the post_sync_hook one last time for
		# run only at sync completion hooks
		if sync_scheduler.global_hooks_enabled:
			rcode = sync_manager.perform_post_sync_hook('')
			if rcode:
				msgs.extend(self.rmessage([('None', rcode)], 'post-sync'))

		# Reload the whole config.
		portage._sync_mode = False
		self._reload_config()
		self._do_pkg_moves()
		msgs.extend(self._check_updates())
		display_news_notification(self.emerge_config.target_config,
			self.emerge_config.opts)

		if return_messages:
			return msgs
		return
예제 #2
0
파일: sync.py 프로젝트: Whissi/portage
	def _sync(self, selected_repos, return_messages,
		emaint_opts=None):

		if emaint_opts is not None:
			for k, v in emaint_opts.items():
				if v is not None:
					k = "--" + k.replace("_", "-")
					self.emerge_config.opts[k] = v

		msgs = []
		if not selected_repos:
			msgs.append("Emaint sync, nothing to sync... returning")
			if return_messages:
				msgs.extend(self.rmessage([('None', os.EX_OK)], 'sync'))
				return msgs
			return
		# Portage needs to ensure a sane umask for the files it creates.
		os.umask(0o22)

		sync_manager = SyncManager(
			self.emerge_config.target_config.settings, emergelog)
		retvals = []
		for repo in selected_repos:
			if repo.sync_type is not None:
				returncode, message = sync_manager.sync(self.emerge_config, repo)
				retvals.append((repo.name, returncode))
				if message:
					msgs.append(message)

		# Reload the whole config.
		portage._sync_mode = False
		self._reload_config()
		self._do_pkg_moves()
		msgs.extend(self._check_updates())
		display_news_notification(self.emerge_config.target_config,
			self.emerge_config.opts)
		# run the post_sync_hook one last time for
		# run only at sync completion hooks
		rcode = sync_manager.perform_post_sync_hook('')
		if retvals:
			msgs.extend(self.rmessage(retvals, 'sync'))
		else:
			msgs.extend(self.rmessage([('None', os.EX_OK)], 'sync'))
		if rcode:
			msgs.extend(self.rmessage([('None', rcode)], 'post-sync'))
		if return_messages:
			return msgs
		return
예제 #3
0
파일: sync.py 프로젝트: timlianov/portage
    def _sync(self, selected_repos, return_messages, emaint_opts=None):

        if emaint_opts is not None:
            for k, v in emaint_opts.items():
                if v is not None:
                    k = "--" + k.replace("_", "-")
                    self.emerge_config.opts[k] = v

        msgs = []
        if not selected_repos:
            msgs.append("Emaint sync, nothing to sync... returning")
            if return_messages:
                msgs.extend(self.rmessage([('None', os.EX_OK)], 'sync'))
                return msgs
            return
        # Portage needs to ensure a sane umask for the files it creates.
        os.umask(0o22)

        sync_manager = SyncManager(self.emerge_config.target_config.settings,
                                   emergelog)
        retvals = []
        for repo in selected_repos:
            if repo.sync_type is not None:
                returncode, message = sync_manager.sync(
                    self.emerge_config, repo)
                retvals.append((repo.name, returncode))
                if message:
                    msgs.append(message)

        # Reload the whole config.
        portage._sync_mode = False
        self._reload_config()
        self._do_pkg_moves()
        msgs.extend(self._check_updates())
        display_news_notification(self.emerge_config.target_config,
                                  self.emerge_config.opts)
        # run the post_sync_hook one last time for
        # run only at sync completion hooks
        rcode = sync_manager.perform_post_sync_hook('')
        if retvals:
            msgs.extend(self.rmessage(retvals, 'sync'))
        else:
            msgs.extend(self.rmessage([('None', os.EX_OK)], 'sync'))
        if rcode:
            msgs.extend(self.rmessage([('None', rcode)], 'post-sync'))
        if return_messages:
            return msgs
        return
예제 #4
0
파일: sync.py 프로젝트: BoleynSu/PR-portage
    def _sync(self, selected_repos, return_messages, emaint_opts=None):
        msgs = []
        if not selected_repos:
            if return_messages:
                msgs.append("Nothing to sync... returning")
                return (True, msgs)
            return (True, None)

        if emaint_opts is not None:
            for k, v in emaint_opts.items():
                if v is not None:
                    k = "--" + k.replace("_", "-")
                    self.emerge_config.opts[k] = v

        # Portage needs to ensure a sane umask for the files it creates.
        os.umask(0o22)

        sync_manager = SyncManager(self.emerge_config.target_config.settings,
                                   emergelog)

        max_jobs = (
            self.emerge_config.opts.get('--jobs', 1) if 'parallel-fetch'
            in self.emerge_config.target_config.settings.features else 1)
        sync_scheduler = SyncScheduler(emerge_config=self.emerge_config,
                                       selected_repos=selected_repos,
                                       sync_manager=sync_manager,
                                       max_jobs=max_jobs,
                                       event_loop=asyncio._safe_loop())

        sync_scheduler.start()
        sync_scheduler.wait()
        retvals = sync_scheduler.retvals
        msgs.extend(sync_scheduler.msgs)
        returncode = True

        if retvals:
            msgs.extend(self.rmessage(retvals, 'sync'))
            for repo, retval in retvals:
                if retval != os.EX_OK:
                    returncode = False
                    break
        else:
            msgs.extend(self.rmessage([('None', os.EX_OK)], 'sync'))

        # run the post_sync_hook one last time for
        # run only at sync completion hooks
        if sync_scheduler.global_hooks_enabled:
            rcode = sync_manager.perform_post_sync_hook('')
            if rcode:
                msgs.extend(self.rmessage([('None', rcode)], 'post-sync'))
                if rcode != os.EX_OK:
                    returncode = False

        # Reload the whole config.
        portage._sync_mode = False
        self._reload_config()
        self._do_pkg_moves()
        msgs.extend(self._check_updates())
        display_news_notification(self.emerge_config.target_config,
                                  self.emerge_config.opts)

        if return_messages:
            return (returncode, msgs)
        return (returncode, None)