* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-04-22 2:36 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-04-22 2:36 UTC (permalink / raw
To: gentoo-commits
commit: 0f01fb9953e5e3675dc4468a608ae523430f607c
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 21 18:30:00 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Apr 22 02:20:07 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0f01fb99
emaint/modules: New emaint module "sync"
This code is a migration from _emerge.actions.action_sync.
The code has been split up into logical blocks.
Some changes have been made to handle multiple repositories better.
It also adds more flexibility as to what is synced.
---
pym/portage/emaint/modules/sync/__init__.py | 44 +++++
pym/portage/emaint/modules/sync/sync.py | 238 ++++++++++++++++++++++++++++
2 files changed, 282 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
new file mode 100644
index 0000000..4070200
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/__init__.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""Check repos.conf settings and sync repositories.
+"""
+
+
+module_spec = {
+ 'name': 'sync',
+ 'description': __doc__,
+ 'provides':{
+ 'sync-module': {
+ 'name': "sync",
+ 'class': "SyncRepos",
+ 'description': __doc__,
+ 'functions': ['allrepos', 'auto', 'repo'],
+ 'func_desc': {
+ 'repo': {
+ "short": "-r", "long": "--repo",
+ "help": "(sync module only): -r, --repo Sync the specified repo",
+ 'status': "Syncing %s",
+ 'action': 'store',
+ 'func': 'repo',
+ },
+ 'allrepos': {
+ "short": "-A", "long": "--allrepos",
+ "help": "(sync module only): -A, --allrepos Sync all repos that have a sync-url defined",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'allrepos',
+ 'func': 'all_repos',
+ },
+ 'auto': {
+ "short": "-a", "long": "--auto",
+ "help": "(sync module only): -a, --auto Sync auto-sync enabled repos only",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'auto',
+ 'func': 'auto_sync',
+ },
+ }
+ }
+ }
+ }
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
new file mode 100644
index 0000000..153f659
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -0,0 +1,238 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import logging
+import os
+import sys
+
+import portage
+from portage.localization import _
+from portage.output import bold, create_color_func
+from portage.sync import get_syncer
+from portage._global_updates import _global_updates
+from portage.util import writemsg_level
+
+import _emerge
+from _emerge.emergelog import emergelog
+
+
+portage.proxy.lazyimport.lazyimport(globals(),
+ '_emerge.actions:adjust_configs,load_emerge_config',
+ '_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
+ '_emerge.main:parse_opts',
+ '_emerge.post_emerge:display_news_notification',
+)
+
+warn = create_color_func("WARN")
+
+if sys.hexversion >= 0x3000000:
+ _basestring = str
+else:
+ _basestring = basestring
+
+
+class SyncRepos(object):
+
+ short_desc = "Check repos.conf settings and/or sync repositories"
+
+ @staticmethod
+ def name():
+ return "sync"
+
+
+ def can_progressbar(self, func):
+ return False
+
+
+ def __init__(self, emerge_config=None, emerge_logging=False):
+ '''Class init function
+
+ @param emerge_config: optional an emerge_config instance to use
+ @param emerge_logging: boolean, defaults to False
+ '''
+ if emerge_config:
+ self.emerge_config = emerge_config
+ else:
+ # need a basic options instance
+ actions, opts, _files = parse_opts([], silent=True)
+ self.emerge_config = load_emerge_config(
+ action='sync', args=_files, trees=[], opts=opts)
+ if emerge_logging:
+ _emerge.emergelog._disable = False
+ self.xterm_titles = "notitles" not in \
+ self.emerge_config.target_config.settings.features
+ emergelog(self.xterm_titles, " === sync")
+
+
+ def auto_sync(self, **kwargs):
+ '''Sync auto-sync enabled repos'''
+ options = kwargs.get('options', None)
+ selected = self._get_repos(True)
+ if options.get('return-messages', False):
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ def all_repos(self, **kwargs):
+ '''Sync all repos defined in repos.conf'''
+ selected = self._get_repos(auto_sync_only=False)
+ options = kwargs.get('options', None)
+ if options.get('return-messages', False):
+ return self.rmessage(
+ self._sync(selected),
+ 'sync')
+ return self._sync(selected)
+
+
+ def repo(self, **kwargs):
+ '''Sync the specified repo'''
+ options = kwargs.get('options', None)
+ if options:
+ repos = options.get('repo', '')
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ if isinstance(repos, _basestring):
+ repos = repos.split()
+ print("!!!! repos =", repos)
+ available = self._get_repos(auto_sync_only=False)
+ selected = self._match_repos(repos, available)
+ if return_messages:
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ @staticmethod
+ def _match_repos(repos, available):
+ '''Internal search, matches up the repo.name in repos
+
+ @param repos: list, of repo names to match
+ @param avalable: list of repo objects to search
+ @return: list of repo objects that match
+ '''
+ selected = []
+ for repo in available:
+ if repo.name in repos:
+ selected.append(repo)
+ return selected
+
+
+ def _get_repos(self, auto_sync_only=True):
+ selected_repos = []
+ unknown_repo_names = []
+ missing_sync_type = []
+ if self.emerge_config.args:
+ for repo_name in self.emerge_config.args:
+ print("_get_repos(): repo_name =", repo_name)
+ try:
+ repo = self.emerge_config.target_config.settings.repositories[repo_name]
+ except KeyError:
+ unknown_repo_names.append(repo_name)
+ else:
+ selected_repos.append(repo)
+ if repo.sync_type is None:
+ missing_sync_type.append(repo)
+
+ if unknown_repo_names:
+ writemsg_level("!!! %s\n" % _("Unknown repo(s): %s") %
+ " ".join(unknown_repo_names),
+ level=logging.ERROR, noiselevel=-1)
+
+ if missing_sync_type:
+ writemsg_level("!!! %s\n" %
+ _("Missing sync-type for repo(s): %s") %
+ " ".join(repo.name for repo in missing_sync_type),
+ level=logging.ERROR, noiselevel=-1)
+
+ if unknown_repo_names or missing_sync_type:
+ print("missing or unknown repos... returning")
+ return []
+
+ else:
+ selected_repos.extend(self.emerge_config.target_config.settings.repositories)
+ #print("_get_repos(), selected =", selected_repos)
+ if auto_sync_only:
+ return self._filter_auto(selected_repos)
+ return selected_repos
+
+
+ def _filter_auto(self, repos):
+ selected = []
+ for repo in repos:
+ if repo.auto_sync in ['yes', 'true']:
+ selected.append(repo)
+ return selected
+
+
+ def _sync(self, selected_repos):
+ if not selected_repos:
+ print("_sync(), nothing to sync... returning")
+ return [('None', os.EX_OK)]
+ # Portage needs to ensure a sane umask for the files it creates.
+ os.umask(0o22)
+ portage._sync_mode = True
+
+ sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
+ retvals = []
+ for repo in selected_repos:
+ print("syncing repo:", repo.name)
+ if repo.sync_type is not None:
+ returncode = sync_manager.sync(self.emerge_config, repo)
+ #if returncode != os.EX_OK:
+ retvals.append((repo.name, returncode))
+
+ # Reload the whole config.
+ portage._sync_mode = False
+ self._reload_config()
+ self._do_pkg_moves()
+ self._check_updates()
+ display_news_notification(self.emerge_config.target_config,
+ self.emerge_config.opts)
+ if retvals:
+ return retvals
+ return [('None', os.EX_OK)]
+
+
+ def _do_pkg_moves(self):
+ if self.emerge_config.opts.get('--package-moves') != 'n' and \
+ _global_updates(self.emerge_config.trees,
+ self.emerge_config.target_config.mtimedb["updates"],
+ quiet=("--quiet" in self.emerge_config.opts)):
+ self.emerge_config.target_config.mtimedb.commit()
+ # Reload the whole config.
+ self._reload_config()
+
+
+ def _check_updates(self):
+ mybestpv = self.emerge_config.target_config.trees['porttree'].dbapi.xmatch(
+ "bestmatch-visible", portage.const.PORTAGE_PACKAGE_ATOM)
+ mypvs = portage.best(
+ self.emerge_config.target_config.trees['vartree'].dbapi.match(
+ portage.const.PORTAGE_PACKAGE_ATOM))
+
+ chk_updated_cfg_files(self.emerge_config.target_config.root,
+ portage.util.shlex_split(
+ self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+
+ if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
+ print()
+ print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ print(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ print()
+ print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ print()
+
+
+ def _reload_config(self):
+ '''Reload the whole config from scratch.'''
+ load_emerge_config(emerge_config=self.emerge_config)
+ adjust_configs(self.emerge_config.opts, self.emerge_config.trees)
+
+
+ def rmessage(self, rvals, action):
+ '''Creates emaint style messages to return to the task handler'''
+ messages = []
+ for rval in rvals:
+ messages.append("Action: %s for repo: %s, returned code = %s"
+ % (action, rval[0], rval[1]))
+ return messages
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-05-02 23:13 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-05-02 23:13 UTC (permalink / raw
To: gentoo-commits
commit: d998b427e535c0c7190c2fc3af9c1995ee82821e
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 21 18:30:00 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri May 2 23:10:53 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d998b427
emaint/modules: New emaint module "sync"
This code is a migration from _emerge.actions.action_sync.
The code has been split up into logical blocks.
Some changes have been made to handle multiple repositories better.
It also adds more flexibility as to what is synced.
---
pym/portage/emaint/modules/sync/__init__.py | 44 ++++++
pym/portage/emaint/modules/sync/sync.py | 237 ++++++++++++++++++++++++++++
2 files changed, 281 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
new file mode 100644
index 0000000..4070200
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/__init__.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""Check repos.conf settings and sync repositories.
+"""
+
+
+module_spec = {
+ 'name': 'sync',
+ 'description': __doc__,
+ 'provides':{
+ 'sync-module': {
+ 'name': "sync",
+ 'class': "SyncRepos",
+ 'description': __doc__,
+ 'functions': ['allrepos', 'auto', 'repo'],
+ 'func_desc': {
+ 'repo': {
+ "short": "-r", "long": "--repo",
+ "help": "(sync module only): -r, --repo Sync the specified repo",
+ 'status': "Syncing %s",
+ 'action': 'store',
+ 'func': 'repo',
+ },
+ 'allrepos': {
+ "short": "-A", "long": "--allrepos",
+ "help": "(sync module only): -A, --allrepos Sync all repos that have a sync-url defined",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'allrepos',
+ 'func': 'all_repos',
+ },
+ 'auto': {
+ "short": "-a", "long": "--auto",
+ "help": "(sync module only): -a, --auto Sync auto-sync enabled repos only",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'auto',
+ 'func': 'auto_sync',
+ },
+ }
+ }
+ }
+ }
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
new file mode 100644
index 0000000..3aa318a
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -0,0 +1,237 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import logging
+import os
+import sys
+
+import portage
+from portage.localization import _
+from portage.output import bold, create_color_func
+from portage.sync import get_syncer
+from portage._global_updates import _global_updates
+from portage.util import writemsg_level
+
+import _emerge
+from _emerge.emergelog import emergelog
+
+
+portage.proxy.lazyimport.lazyimport(globals(),
+ '_emerge.actions:adjust_configs,load_emerge_config',
+ '_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
+ '_emerge.main:parse_opts',
+ '_emerge.post_emerge:display_news_notification',
+)
+
+warn = create_color_func("WARN")
+
+if sys.hexversion >= 0x3000000:
+ _basestring = str
+else:
+ _basestring = basestring
+
+
+class SyncRepos(object):
+
+ short_desc = "Check repos.conf settings and/or sync repositories"
+
+ @staticmethod
+ def name():
+ return "sync"
+
+
+ def can_progressbar(self, func):
+ return False
+
+
+ def __init__(self, emerge_config=None, emerge_logging=False):
+ '''Class init function
+
+ @param emerge_config: optional an emerge_config instance to use
+ @param emerge_logging: boolean, defaults to False
+ '''
+ if emerge_config:
+ self.emerge_config = emerge_config
+ else:
+ # need a basic options instance
+ actions, opts, _files = parse_opts([], silent=True)
+ self.emerge_config = load_emerge_config(
+ action='sync', args=_files, trees=[], opts=opts)
+ if emerge_logging:
+ _emerge.emergelog._disable = False
+ self.xterm_titles = "notitles" not in \
+ self.emerge_config.target_config.settings.features
+ emergelog(self.xterm_titles, " === sync")
+
+
+ def auto_sync(self, **kwargs):
+ '''Sync auto-sync enabled repos'''
+ options = kwargs.get('options', None)
+ selected = self._get_repos(True)
+ if options.get('return-messages', False):
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ def all_repos(self, **kwargs):
+ '''Sync all repos defined in repos.conf'''
+ selected = self._get_repos(auto_sync_only=False)
+ options = kwargs.get('options', None)
+ if options.get('return-messages', False):
+ return self.rmessage(
+ self._sync(selected),
+ 'sync')
+ return self._sync(selected)
+
+
+ def repo(self, **kwargs):
+ '''Sync the specified repo'''
+ options = kwargs.get('options', None)
+ if options:
+ repos = options.get('repo', '')
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ if isinstance(repos, _basestring):
+ repos = repos.split()
+ available = self._get_repos(auto_sync_only=False)
+ selected = self._match_repos(repos, available)
+ if return_messages:
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ @staticmethod
+ def _match_repos(repos, available):
+ '''Internal search, matches up the repo.name in repos
+
+ @param repos: list, of repo names to match
+ @param avalable: list of repo objects to search
+ @return: list of repo objects that match
+ '''
+ selected = []
+ for repo in available:
+ if repo.name in repos:
+ selected.append(repo)
+ return selected
+
+
+ def _get_repos(self, auto_sync_only=True):
+ selected_repos = []
+ unknown_repo_names = []
+ missing_sync_type = []
+ if self.emerge_config.args:
+ for repo_name in self.emerge_config.args:
+ print("_get_repos(): repo_name =", repo_name)
+ try:
+ repo = self.emerge_config.target_config.settings.repositories[repo_name]
+ except KeyError:
+ unknown_repo_names.append(repo_name)
+ else:
+ selected_repos.append(repo)
+ if repo.sync_type is None:
+ missing_sync_type.append(repo)
+
+ if unknown_repo_names:
+ writemsg_level("!!! %s\n" % _("Unknown repo(s): %s") %
+ " ".join(unknown_repo_names),
+ level=logging.ERROR, noiselevel=-1)
+
+ if missing_sync_type:
+ writemsg_level("!!! %s\n" %
+ _("Missing sync-type for repo(s): %s") %
+ " ".join(repo.name for repo in missing_sync_type),
+ level=logging.ERROR, noiselevel=-1)
+
+ if unknown_repo_names or missing_sync_type:
+ print("missing or unknown repos... returning")
+ return []
+
+ else:
+ selected_repos.extend(self.emerge_config.target_config.settings.repositories)
+ #print("_get_repos(), selected =", selected_repos)
+ if auto_sync_only:
+ return self._filter_auto(selected_repos)
+ return selected_repos
+
+
+ def _filter_auto(self, repos):
+ selected = []
+ for repo in repos:
+ if repo.auto_sync in ['yes', 'true']:
+ selected.append(repo)
+ return selected
+
+
+ def _sync(self, selected_repos):
+ if not selected_repos:
+ print("_sync(), nothing to sync... returning")
+ return [('None', os.EX_OK)]
+ # Portage needs to ensure a sane umask for the files it creates.
+ os.umask(0o22)
+ portage._sync_mode = True
+
+ sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
+ retvals = []
+ for repo in selected_repos:
+ print("syncing repo:", repo.name)
+ if repo.sync_type is not None:
+ returncode = sync_manager.sync(self.emerge_config, repo)
+ #if returncode != os.EX_OK:
+ retvals.append((repo.name, returncode))
+
+ # Reload the whole config.
+ portage._sync_mode = False
+ self._reload_config()
+ self._do_pkg_moves()
+ self._check_updates()
+ display_news_notification(self.emerge_config.target_config,
+ self.emerge_config.opts)
+ if retvals:
+ return retvals
+ return [('None', os.EX_OK)]
+
+
+ def _do_pkg_moves(self):
+ if self.emerge_config.opts.get('--package-moves') != 'n' and \
+ _global_updates(self.emerge_config.trees,
+ self.emerge_config.target_config.mtimedb["updates"],
+ quiet=("--quiet" in self.emerge_config.opts)):
+ self.emerge_config.target_config.mtimedb.commit()
+ # Reload the whole config.
+ self._reload_config()
+
+
+ def _check_updates(self):
+ mybestpv = self.emerge_config.target_config.trees['porttree'].dbapi.xmatch(
+ "bestmatch-visible", portage.const.PORTAGE_PACKAGE_ATOM)
+ mypvs = portage.best(
+ self.emerge_config.target_config.trees['vartree'].dbapi.match(
+ portage.const.PORTAGE_PACKAGE_ATOM))
+
+ chk_updated_cfg_files(self.emerge_config.target_config.root,
+ portage.util.shlex_split(
+ self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+
+ if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
+ print()
+ print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ print(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ print()
+ print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ print()
+
+
+ def _reload_config(self):
+ '''Reload the whole config from scratch.'''
+ load_emerge_config(emerge_config=self.emerge_config)
+ adjust_configs(self.emerge_config.opts, self.emerge_config.trees)
+
+
+ def rmessage(self, rvals, action):
+ '''Creates emaint style messages to return to the task handler'''
+ messages = []
+ for rval in rvals:
+ messages.append("Action: %s for repo: %s, returned code = %s"
+ % (action, rval[0], rval[1]))
+ return messages
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-05-11 17:22 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-05-11 17:22 UTC (permalink / raw
To: gentoo-commits
commit: 3400a7746c10abf416c51a1030d7af7c68471ba8
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sun May 11 17:21:00 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3400a774
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-06-16 15:18 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-06-16 15:18 UTC (permalink / raw
To: gentoo-commits
commit: 9d596ca1de71f92bce0a687d368b2320dec0c799
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 21 18:30:00 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue May 13 04:17:42 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9d596ca1
emaint/modules: New emaint module "sync"
This code is a migration from _emerge.actions.action_sync.
The code has been split up into logical blocks.
Some changes have been made to handle multiple repositories better.
It also adds more flexibility as to what is synced.
---
pym/portage/emaint/modules/sync/__init__.py | 44 ++++++
pym/portage/emaint/modules/sync/sync.py | 237 ++++++++++++++++++++++++++++
2 files changed, 281 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
new file mode 100644
index 0000000..4070200
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/__init__.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""Check repos.conf settings and sync repositories.
+"""
+
+
+module_spec = {
+ 'name': 'sync',
+ 'description': __doc__,
+ 'provides':{
+ 'sync-module': {
+ 'name': "sync",
+ 'class': "SyncRepos",
+ 'description': __doc__,
+ 'functions': ['allrepos', 'auto', 'repo'],
+ 'func_desc': {
+ 'repo': {
+ "short": "-r", "long": "--repo",
+ "help": "(sync module only): -r, --repo Sync the specified repo",
+ 'status': "Syncing %s",
+ 'action': 'store',
+ 'func': 'repo',
+ },
+ 'allrepos': {
+ "short": "-A", "long": "--allrepos",
+ "help": "(sync module only): -A, --allrepos Sync all repos that have a sync-url defined",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'allrepos',
+ 'func': 'all_repos',
+ },
+ 'auto': {
+ "short": "-a", "long": "--auto",
+ "help": "(sync module only): -a, --auto Sync auto-sync enabled repos only",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'auto',
+ 'func': 'auto_sync',
+ },
+ }
+ }
+ }
+ }
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
new file mode 100644
index 0000000..3aa318a
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -0,0 +1,237 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import logging
+import os
+import sys
+
+import portage
+from portage.localization import _
+from portage.output import bold, create_color_func
+from portage.sync import get_syncer
+from portage._global_updates import _global_updates
+from portage.util import writemsg_level
+
+import _emerge
+from _emerge.emergelog import emergelog
+
+
+portage.proxy.lazyimport.lazyimport(globals(),
+ '_emerge.actions:adjust_configs,load_emerge_config',
+ '_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
+ '_emerge.main:parse_opts',
+ '_emerge.post_emerge:display_news_notification',
+)
+
+warn = create_color_func("WARN")
+
+if sys.hexversion >= 0x3000000:
+ _basestring = str
+else:
+ _basestring = basestring
+
+
+class SyncRepos(object):
+
+ short_desc = "Check repos.conf settings and/or sync repositories"
+
+ @staticmethod
+ def name():
+ return "sync"
+
+
+ def can_progressbar(self, func):
+ return False
+
+
+ def __init__(self, emerge_config=None, emerge_logging=False):
+ '''Class init function
+
+ @param emerge_config: optional an emerge_config instance to use
+ @param emerge_logging: boolean, defaults to False
+ '''
+ if emerge_config:
+ self.emerge_config = emerge_config
+ else:
+ # need a basic options instance
+ actions, opts, _files = parse_opts([], silent=True)
+ self.emerge_config = load_emerge_config(
+ action='sync', args=_files, trees=[], opts=opts)
+ if emerge_logging:
+ _emerge.emergelog._disable = False
+ self.xterm_titles = "notitles" not in \
+ self.emerge_config.target_config.settings.features
+ emergelog(self.xterm_titles, " === sync")
+
+
+ def auto_sync(self, **kwargs):
+ '''Sync auto-sync enabled repos'''
+ options = kwargs.get('options', None)
+ selected = self._get_repos(True)
+ if options.get('return-messages', False):
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ def all_repos(self, **kwargs):
+ '''Sync all repos defined in repos.conf'''
+ selected = self._get_repos(auto_sync_only=False)
+ options = kwargs.get('options', None)
+ if options.get('return-messages', False):
+ return self.rmessage(
+ self._sync(selected),
+ 'sync')
+ return self._sync(selected)
+
+
+ def repo(self, **kwargs):
+ '''Sync the specified repo'''
+ options = kwargs.get('options', None)
+ if options:
+ repos = options.get('repo', '')
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ if isinstance(repos, _basestring):
+ repos = repos.split()
+ available = self._get_repos(auto_sync_only=False)
+ selected = self._match_repos(repos, available)
+ if return_messages:
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ @staticmethod
+ def _match_repos(repos, available):
+ '''Internal search, matches up the repo.name in repos
+
+ @param repos: list, of repo names to match
+ @param avalable: list of repo objects to search
+ @return: list of repo objects that match
+ '''
+ selected = []
+ for repo in available:
+ if repo.name in repos:
+ selected.append(repo)
+ return selected
+
+
+ def _get_repos(self, auto_sync_only=True):
+ selected_repos = []
+ unknown_repo_names = []
+ missing_sync_type = []
+ if self.emerge_config.args:
+ for repo_name in self.emerge_config.args:
+ print("_get_repos(): repo_name =", repo_name)
+ try:
+ repo = self.emerge_config.target_config.settings.repositories[repo_name]
+ except KeyError:
+ unknown_repo_names.append(repo_name)
+ else:
+ selected_repos.append(repo)
+ if repo.sync_type is None:
+ missing_sync_type.append(repo)
+
+ if unknown_repo_names:
+ writemsg_level("!!! %s\n" % _("Unknown repo(s): %s") %
+ " ".join(unknown_repo_names),
+ level=logging.ERROR, noiselevel=-1)
+
+ if missing_sync_type:
+ writemsg_level("!!! %s\n" %
+ _("Missing sync-type for repo(s): %s") %
+ " ".join(repo.name for repo in missing_sync_type),
+ level=logging.ERROR, noiselevel=-1)
+
+ if unknown_repo_names or missing_sync_type:
+ print("missing or unknown repos... returning")
+ return []
+
+ else:
+ selected_repos.extend(self.emerge_config.target_config.settings.repositories)
+ #print("_get_repos(), selected =", selected_repos)
+ if auto_sync_only:
+ return self._filter_auto(selected_repos)
+ return selected_repos
+
+
+ def _filter_auto(self, repos):
+ selected = []
+ for repo in repos:
+ if repo.auto_sync in ['yes', 'true']:
+ selected.append(repo)
+ return selected
+
+
+ def _sync(self, selected_repos):
+ if not selected_repos:
+ print("_sync(), nothing to sync... returning")
+ return [('None', os.EX_OK)]
+ # Portage needs to ensure a sane umask for the files it creates.
+ os.umask(0o22)
+ portage._sync_mode = True
+
+ sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
+ retvals = []
+ for repo in selected_repos:
+ print("syncing repo:", repo.name)
+ if repo.sync_type is not None:
+ returncode = sync_manager.sync(self.emerge_config, repo)
+ #if returncode != os.EX_OK:
+ retvals.append((repo.name, returncode))
+
+ # Reload the whole config.
+ portage._sync_mode = False
+ self._reload_config()
+ self._do_pkg_moves()
+ self._check_updates()
+ display_news_notification(self.emerge_config.target_config,
+ self.emerge_config.opts)
+ if retvals:
+ return retvals
+ return [('None', os.EX_OK)]
+
+
+ def _do_pkg_moves(self):
+ if self.emerge_config.opts.get('--package-moves') != 'n' and \
+ _global_updates(self.emerge_config.trees,
+ self.emerge_config.target_config.mtimedb["updates"],
+ quiet=("--quiet" in self.emerge_config.opts)):
+ self.emerge_config.target_config.mtimedb.commit()
+ # Reload the whole config.
+ self._reload_config()
+
+
+ def _check_updates(self):
+ mybestpv = self.emerge_config.target_config.trees['porttree'].dbapi.xmatch(
+ "bestmatch-visible", portage.const.PORTAGE_PACKAGE_ATOM)
+ mypvs = portage.best(
+ self.emerge_config.target_config.trees['vartree'].dbapi.match(
+ portage.const.PORTAGE_PACKAGE_ATOM))
+
+ chk_updated_cfg_files(self.emerge_config.target_config.root,
+ portage.util.shlex_split(
+ self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+
+ if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
+ print()
+ print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ print(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ print()
+ print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ print()
+
+
+ def _reload_config(self):
+ '''Reload the whole config from scratch.'''
+ load_emerge_config(emerge_config=self.emerge_config)
+ adjust_configs(self.emerge_config.opts, self.emerge_config.trees)
+
+
+ def rmessage(self, rvals, action):
+ '''Creates emaint style messages to return to the task handler'''
+ messages = []
+ for rval in rvals:
+ messages.append("Action: %s for repo: %s, returned code = %s"
+ % (action, rval[0], rval[1]))
+ return messages
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-06-16 15:18 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-06-16 15:18 UTC (permalink / raw
To: gentoo-commits
commit: 8e2522537b5d06f22360c872a802a4c0443c3d1f
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue May 13 04:24:34 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8e252253
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-06-16 15:46 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-06-16 15:46 UTC (permalink / raw
To: gentoo-commits
commit: 5783614c85f6fc8da53f404fffbf4a888d530c30
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 21 18:30:00 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Jun 16 15:36:57 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5783614c
emaint/modules: New emaint module "sync"
This code is a migration from _emerge.actions.action_sync.
The code has been split up into logical blocks.
Some changes have been made to handle multiple repositories better.
It also adds more flexibility as to what is synced.
---
pym/portage/emaint/modules/sync/__init__.py | 44 ++++++
pym/portage/emaint/modules/sync/sync.py | 237 ++++++++++++++++++++++++++++
2 files changed, 281 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
new file mode 100644
index 0000000..4070200
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/__init__.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""Check repos.conf settings and sync repositories.
+"""
+
+
+module_spec = {
+ 'name': 'sync',
+ 'description': __doc__,
+ 'provides':{
+ 'sync-module': {
+ 'name': "sync",
+ 'class': "SyncRepos",
+ 'description': __doc__,
+ 'functions': ['allrepos', 'auto', 'repo'],
+ 'func_desc': {
+ 'repo': {
+ "short": "-r", "long": "--repo",
+ "help": "(sync module only): -r, --repo Sync the specified repo",
+ 'status': "Syncing %s",
+ 'action': 'store',
+ 'func': 'repo',
+ },
+ 'allrepos': {
+ "short": "-A", "long": "--allrepos",
+ "help": "(sync module only): -A, --allrepos Sync all repos that have a sync-url defined",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'allrepos',
+ 'func': 'all_repos',
+ },
+ 'auto': {
+ "short": "-a", "long": "--auto",
+ "help": "(sync module only): -a, --auto Sync auto-sync enabled repos only",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'auto',
+ 'func': 'auto_sync',
+ },
+ }
+ }
+ }
+ }
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
new file mode 100644
index 0000000..3aa318a
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -0,0 +1,237 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import logging
+import os
+import sys
+
+import portage
+from portage.localization import _
+from portage.output import bold, create_color_func
+from portage.sync import get_syncer
+from portage._global_updates import _global_updates
+from portage.util import writemsg_level
+
+import _emerge
+from _emerge.emergelog import emergelog
+
+
+portage.proxy.lazyimport.lazyimport(globals(),
+ '_emerge.actions:adjust_configs,load_emerge_config',
+ '_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
+ '_emerge.main:parse_opts',
+ '_emerge.post_emerge:display_news_notification',
+)
+
+warn = create_color_func("WARN")
+
+if sys.hexversion >= 0x3000000:
+ _basestring = str
+else:
+ _basestring = basestring
+
+
+class SyncRepos(object):
+
+ short_desc = "Check repos.conf settings and/or sync repositories"
+
+ @staticmethod
+ def name():
+ return "sync"
+
+
+ def can_progressbar(self, func):
+ return False
+
+
+ def __init__(self, emerge_config=None, emerge_logging=False):
+ '''Class init function
+
+ @param emerge_config: optional an emerge_config instance to use
+ @param emerge_logging: boolean, defaults to False
+ '''
+ if emerge_config:
+ self.emerge_config = emerge_config
+ else:
+ # need a basic options instance
+ actions, opts, _files = parse_opts([], silent=True)
+ self.emerge_config = load_emerge_config(
+ action='sync', args=_files, trees=[], opts=opts)
+ if emerge_logging:
+ _emerge.emergelog._disable = False
+ self.xterm_titles = "notitles" not in \
+ self.emerge_config.target_config.settings.features
+ emergelog(self.xterm_titles, " === sync")
+
+
+ def auto_sync(self, **kwargs):
+ '''Sync auto-sync enabled repos'''
+ options = kwargs.get('options', None)
+ selected = self._get_repos(True)
+ if options.get('return-messages', False):
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ def all_repos(self, **kwargs):
+ '''Sync all repos defined in repos.conf'''
+ selected = self._get_repos(auto_sync_only=False)
+ options = kwargs.get('options', None)
+ if options.get('return-messages', False):
+ return self.rmessage(
+ self._sync(selected),
+ 'sync')
+ return self._sync(selected)
+
+
+ def repo(self, **kwargs):
+ '''Sync the specified repo'''
+ options = kwargs.get('options', None)
+ if options:
+ repos = options.get('repo', '')
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ if isinstance(repos, _basestring):
+ repos = repos.split()
+ available = self._get_repos(auto_sync_only=False)
+ selected = self._match_repos(repos, available)
+ if return_messages:
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ @staticmethod
+ def _match_repos(repos, available):
+ '''Internal search, matches up the repo.name in repos
+
+ @param repos: list, of repo names to match
+ @param avalable: list of repo objects to search
+ @return: list of repo objects that match
+ '''
+ selected = []
+ for repo in available:
+ if repo.name in repos:
+ selected.append(repo)
+ return selected
+
+
+ def _get_repos(self, auto_sync_only=True):
+ selected_repos = []
+ unknown_repo_names = []
+ missing_sync_type = []
+ if self.emerge_config.args:
+ for repo_name in self.emerge_config.args:
+ print("_get_repos(): repo_name =", repo_name)
+ try:
+ repo = self.emerge_config.target_config.settings.repositories[repo_name]
+ except KeyError:
+ unknown_repo_names.append(repo_name)
+ else:
+ selected_repos.append(repo)
+ if repo.sync_type is None:
+ missing_sync_type.append(repo)
+
+ if unknown_repo_names:
+ writemsg_level("!!! %s\n" % _("Unknown repo(s): %s") %
+ " ".join(unknown_repo_names),
+ level=logging.ERROR, noiselevel=-1)
+
+ if missing_sync_type:
+ writemsg_level("!!! %s\n" %
+ _("Missing sync-type for repo(s): %s") %
+ " ".join(repo.name for repo in missing_sync_type),
+ level=logging.ERROR, noiselevel=-1)
+
+ if unknown_repo_names or missing_sync_type:
+ print("missing or unknown repos... returning")
+ return []
+
+ else:
+ selected_repos.extend(self.emerge_config.target_config.settings.repositories)
+ #print("_get_repos(), selected =", selected_repos)
+ if auto_sync_only:
+ return self._filter_auto(selected_repos)
+ return selected_repos
+
+
+ def _filter_auto(self, repos):
+ selected = []
+ for repo in repos:
+ if repo.auto_sync in ['yes', 'true']:
+ selected.append(repo)
+ return selected
+
+
+ def _sync(self, selected_repos):
+ if not selected_repos:
+ print("_sync(), nothing to sync... returning")
+ return [('None', os.EX_OK)]
+ # Portage needs to ensure a sane umask for the files it creates.
+ os.umask(0o22)
+ portage._sync_mode = True
+
+ sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
+ retvals = []
+ for repo in selected_repos:
+ print("syncing repo:", repo.name)
+ if repo.sync_type is not None:
+ returncode = sync_manager.sync(self.emerge_config, repo)
+ #if returncode != os.EX_OK:
+ retvals.append((repo.name, returncode))
+
+ # Reload the whole config.
+ portage._sync_mode = False
+ self._reload_config()
+ self._do_pkg_moves()
+ self._check_updates()
+ display_news_notification(self.emerge_config.target_config,
+ self.emerge_config.opts)
+ if retvals:
+ return retvals
+ return [('None', os.EX_OK)]
+
+
+ def _do_pkg_moves(self):
+ if self.emerge_config.opts.get('--package-moves') != 'n' and \
+ _global_updates(self.emerge_config.trees,
+ self.emerge_config.target_config.mtimedb["updates"],
+ quiet=("--quiet" in self.emerge_config.opts)):
+ self.emerge_config.target_config.mtimedb.commit()
+ # Reload the whole config.
+ self._reload_config()
+
+
+ def _check_updates(self):
+ mybestpv = self.emerge_config.target_config.trees['porttree'].dbapi.xmatch(
+ "bestmatch-visible", portage.const.PORTAGE_PACKAGE_ATOM)
+ mypvs = portage.best(
+ self.emerge_config.target_config.trees['vartree'].dbapi.match(
+ portage.const.PORTAGE_PACKAGE_ATOM))
+
+ chk_updated_cfg_files(self.emerge_config.target_config.root,
+ portage.util.shlex_split(
+ self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+
+ if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
+ print()
+ print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ print(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ print()
+ print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ print()
+
+
+ def _reload_config(self):
+ '''Reload the whole config from scratch.'''
+ load_emerge_config(emerge_config=self.emerge_config)
+ adjust_configs(self.emerge_config.opts, self.emerge_config.trees)
+
+
+ def rmessage(self, rvals, action):
+ '''Creates emaint style messages to return to the task handler'''
+ messages = []
+ for rval in rvals:
+ messages.append("Action: %s for repo: %s, returned code = %s"
+ % (action, rval[0], rval[1]))
+ return messages
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-06-16 15:46 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-06-16 15:46 UTC (permalink / raw
To: gentoo-commits
commit: 8ab0a0e26cc996e1116d8e1667c5d83c58218100
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Jun 16 15:36:57 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8ab0a0e2
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-06-16 22:45 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-06-16 22:45 UTC (permalink / raw
To: gentoo-commits
commit: 9510644cf0efd9b82741f4b7d2c5f96cbf1a45b5
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 21 18:30:00 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Jun 16 22:43:11 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=9510644c
emaint/modules: New emaint module "sync"
This code is a migration from _emerge.actions.action_sync.
The code has been split up into logical blocks.
Some changes have been made to handle multiple repositories better.
It also adds more flexibility as to what is synced.
---
pym/portage/emaint/modules/sync/__init__.py | 44 ++++++
pym/portage/emaint/modules/sync/sync.py | 237 ++++++++++++++++++++++++++++
2 files changed, 281 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
new file mode 100644
index 0000000..4070200
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/__init__.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""Check repos.conf settings and sync repositories.
+"""
+
+
+module_spec = {
+ 'name': 'sync',
+ 'description': __doc__,
+ 'provides':{
+ 'sync-module': {
+ 'name': "sync",
+ 'class': "SyncRepos",
+ 'description': __doc__,
+ 'functions': ['allrepos', 'auto', 'repo'],
+ 'func_desc': {
+ 'repo': {
+ "short": "-r", "long": "--repo",
+ "help": "(sync module only): -r, --repo Sync the specified repo",
+ 'status': "Syncing %s",
+ 'action': 'store',
+ 'func': 'repo',
+ },
+ 'allrepos': {
+ "short": "-A", "long": "--allrepos",
+ "help": "(sync module only): -A, --allrepos Sync all repos that have a sync-url defined",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'allrepos',
+ 'func': 'all_repos',
+ },
+ 'auto': {
+ "short": "-a", "long": "--auto",
+ "help": "(sync module only): -a, --auto Sync auto-sync enabled repos only",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'auto',
+ 'func': 'auto_sync',
+ },
+ }
+ }
+ }
+ }
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
new file mode 100644
index 0000000..3aa318a
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -0,0 +1,237 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import logging
+import os
+import sys
+
+import portage
+from portage.localization import _
+from portage.output import bold, create_color_func
+from portage.sync import get_syncer
+from portage._global_updates import _global_updates
+from portage.util import writemsg_level
+
+import _emerge
+from _emerge.emergelog import emergelog
+
+
+portage.proxy.lazyimport.lazyimport(globals(),
+ '_emerge.actions:adjust_configs,load_emerge_config',
+ '_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
+ '_emerge.main:parse_opts',
+ '_emerge.post_emerge:display_news_notification',
+)
+
+warn = create_color_func("WARN")
+
+if sys.hexversion >= 0x3000000:
+ _basestring = str
+else:
+ _basestring = basestring
+
+
+class SyncRepos(object):
+
+ short_desc = "Check repos.conf settings and/or sync repositories"
+
+ @staticmethod
+ def name():
+ return "sync"
+
+
+ def can_progressbar(self, func):
+ return False
+
+
+ def __init__(self, emerge_config=None, emerge_logging=False):
+ '''Class init function
+
+ @param emerge_config: optional an emerge_config instance to use
+ @param emerge_logging: boolean, defaults to False
+ '''
+ if emerge_config:
+ self.emerge_config = emerge_config
+ else:
+ # need a basic options instance
+ actions, opts, _files = parse_opts([], silent=True)
+ self.emerge_config = load_emerge_config(
+ action='sync', args=_files, trees=[], opts=opts)
+ if emerge_logging:
+ _emerge.emergelog._disable = False
+ self.xterm_titles = "notitles" not in \
+ self.emerge_config.target_config.settings.features
+ emergelog(self.xterm_titles, " === sync")
+
+
+ def auto_sync(self, **kwargs):
+ '''Sync auto-sync enabled repos'''
+ options = kwargs.get('options', None)
+ selected = self._get_repos(True)
+ if options.get('return-messages', False):
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ def all_repos(self, **kwargs):
+ '''Sync all repos defined in repos.conf'''
+ selected = self._get_repos(auto_sync_only=False)
+ options = kwargs.get('options', None)
+ if options.get('return-messages', False):
+ return self.rmessage(
+ self._sync(selected),
+ 'sync')
+ return self._sync(selected)
+
+
+ def repo(self, **kwargs):
+ '''Sync the specified repo'''
+ options = kwargs.get('options', None)
+ if options:
+ repos = options.get('repo', '')
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ if isinstance(repos, _basestring):
+ repos = repos.split()
+ available = self._get_repos(auto_sync_only=False)
+ selected = self._match_repos(repos, available)
+ if return_messages:
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ @staticmethod
+ def _match_repos(repos, available):
+ '''Internal search, matches up the repo.name in repos
+
+ @param repos: list, of repo names to match
+ @param avalable: list of repo objects to search
+ @return: list of repo objects that match
+ '''
+ selected = []
+ for repo in available:
+ if repo.name in repos:
+ selected.append(repo)
+ return selected
+
+
+ def _get_repos(self, auto_sync_only=True):
+ selected_repos = []
+ unknown_repo_names = []
+ missing_sync_type = []
+ if self.emerge_config.args:
+ for repo_name in self.emerge_config.args:
+ print("_get_repos(): repo_name =", repo_name)
+ try:
+ repo = self.emerge_config.target_config.settings.repositories[repo_name]
+ except KeyError:
+ unknown_repo_names.append(repo_name)
+ else:
+ selected_repos.append(repo)
+ if repo.sync_type is None:
+ missing_sync_type.append(repo)
+
+ if unknown_repo_names:
+ writemsg_level("!!! %s\n" % _("Unknown repo(s): %s") %
+ " ".join(unknown_repo_names),
+ level=logging.ERROR, noiselevel=-1)
+
+ if missing_sync_type:
+ writemsg_level("!!! %s\n" %
+ _("Missing sync-type for repo(s): %s") %
+ " ".join(repo.name for repo in missing_sync_type),
+ level=logging.ERROR, noiselevel=-1)
+
+ if unknown_repo_names or missing_sync_type:
+ print("missing or unknown repos... returning")
+ return []
+
+ else:
+ selected_repos.extend(self.emerge_config.target_config.settings.repositories)
+ #print("_get_repos(), selected =", selected_repos)
+ if auto_sync_only:
+ return self._filter_auto(selected_repos)
+ return selected_repos
+
+
+ def _filter_auto(self, repos):
+ selected = []
+ for repo in repos:
+ if repo.auto_sync in ['yes', 'true']:
+ selected.append(repo)
+ return selected
+
+
+ def _sync(self, selected_repos):
+ if not selected_repos:
+ print("_sync(), nothing to sync... returning")
+ return [('None', os.EX_OK)]
+ # Portage needs to ensure a sane umask for the files it creates.
+ os.umask(0o22)
+ portage._sync_mode = True
+
+ sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
+ retvals = []
+ for repo in selected_repos:
+ print("syncing repo:", repo.name)
+ if repo.sync_type is not None:
+ returncode = sync_manager.sync(self.emerge_config, repo)
+ #if returncode != os.EX_OK:
+ retvals.append((repo.name, returncode))
+
+ # Reload the whole config.
+ portage._sync_mode = False
+ self._reload_config()
+ self._do_pkg_moves()
+ self._check_updates()
+ display_news_notification(self.emerge_config.target_config,
+ self.emerge_config.opts)
+ if retvals:
+ return retvals
+ return [('None', os.EX_OK)]
+
+
+ def _do_pkg_moves(self):
+ if self.emerge_config.opts.get('--package-moves') != 'n' and \
+ _global_updates(self.emerge_config.trees,
+ self.emerge_config.target_config.mtimedb["updates"],
+ quiet=("--quiet" in self.emerge_config.opts)):
+ self.emerge_config.target_config.mtimedb.commit()
+ # Reload the whole config.
+ self._reload_config()
+
+
+ def _check_updates(self):
+ mybestpv = self.emerge_config.target_config.trees['porttree'].dbapi.xmatch(
+ "bestmatch-visible", portage.const.PORTAGE_PACKAGE_ATOM)
+ mypvs = portage.best(
+ self.emerge_config.target_config.trees['vartree'].dbapi.match(
+ portage.const.PORTAGE_PACKAGE_ATOM))
+
+ chk_updated_cfg_files(self.emerge_config.target_config.root,
+ portage.util.shlex_split(
+ self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+
+ if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
+ print()
+ print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ print(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ print()
+ print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ print()
+
+
+ def _reload_config(self):
+ '''Reload the whole config from scratch.'''
+ load_emerge_config(emerge_config=self.emerge_config)
+ adjust_configs(self.emerge_config.opts, self.emerge_config.trees)
+
+
+ def rmessage(self, rvals, action):
+ '''Creates emaint style messages to return to the task handler'''
+ messages = []
+ for rval in rvals:
+ messages.append("Action: %s for repo: %s, returned code = %s"
+ % (action, rval[0], rval[1]))
+ return messages
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-06-16 22:45 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-06-16 22:45 UTC (permalink / raw
To: gentoo-commits
commit: f776cf717ce68193b63dede273bccbdbca23c361
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Jun 16 22:44:15 2014 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f776cf71
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-03 23:36 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-03 23:36 UTC (permalink / raw
To: gentoo-commits
commit: dfe477f0b9d867678f0942a4bc0ea6cb84701e96
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 21 18:30:00 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Sep 3 23:34:53 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=dfe477f0
emaint/modules: New emaint module "sync"
This code is a migration from _emerge.actions.action_sync.
The code has been split up into logical blocks.
Some changes have been made to handle multiple repositories better.
It also adds more flexibility as to what is synced.
---
pym/portage/emaint/modules/sync/__init__.py | 44 ++++++
pym/portage/emaint/modules/sync/sync.py | 237 ++++++++++++++++++++++++++++
2 files changed, 281 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
new file mode 100644
index 0000000..4070200
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/__init__.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""Check repos.conf settings and sync repositories.
+"""
+
+
+module_spec = {
+ 'name': 'sync',
+ 'description': __doc__,
+ 'provides':{
+ 'sync-module': {
+ 'name': "sync",
+ 'class': "SyncRepos",
+ 'description': __doc__,
+ 'functions': ['allrepos', 'auto', 'repo'],
+ 'func_desc': {
+ 'repo': {
+ "short": "-r", "long": "--repo",
+ "help": "(sync module only): -r, --repo Sync the specified repo",
+ 'status': "Syncing %s",
+ 'action': 'store',
+ 'func': 'repo',
+ },
+ 'allrepos': {
+ "short": "-A", "long": "--allrepos",
+ "help": "(sync module only): -A, --allrepos Sync all repos that have a sync-url defined",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'allrepos',
+ 'func': 'all_repos',
+ },
+ 'auto': {
+ "short": "-a", "long": "--auto",
+ "help": "(sync module only): -a, --auto Sync auto-sync enabled repos only",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'auto',
+ 'func': 'auto_sync',
+ },
+ }
+ }
+ }
+ }
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
new file mode 100644
index 0000000..3aa318a
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -0,0 +1,237 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import logging
+import os
+import sys
+
+import portage
+from portage.localization import _
+from portage.output import bold, create_color_func
+from portage.sync import get_syncer
+from portage._global_updates import _global_updates
+from portage.util import writemsg_level
+
+import _emerge
+from _emerge.emergelog import emergelog
+
+
+portage.proxy.lazyimport.lazyimport(globals(),
+ '_emerge.actions:adjust_configs,load_emerge_config',
+ '_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
+ '_emerge.main:parse_opts',
+ '_emerge.post_emerge:display_news_notification',
+)
+
+warn = create_color_func("WARN")
+
+if sys.hexversion >= 0x3000000:
+ _basestring = str
+else:
+ _basestring = basestring
+
+
+class SyncRepos(object):
+
+ short_desc = "Check repos.conf settings and/or sync repositories"
+
+ @staticmethod
+ def name():
+ return "sync"
+
+
+ def can_progressbar(self, func):
+ return False
+
+
+ def __init__(self, emerge_config=None, emerge_logging=False):
+ '''Class init function
+
+ @param emerge_config: optional an emerge_config instance to use
+ @param emerge_logging: boolean, defaults to False
+ '''
+ if emerge_config:
+ self.emerge_config = emerge_config
+ else:
+ # need a basic options instance
+ actions, opts, _files = parse_opts([], silent=True)
+ self.emerge_config = load_emerge_config(
+ action='sync', args=_files, trees=[], opts=opts)
+ if emerge_logging:
+ _emerge.emergelog._disable = False
+ self.xterm_titles = "notitles" not in \
+ self.emerge_config.target_config.settings.features
+ emergelog(self.xterm_titles, " === sync")
+
+
+ def auto_sync(self, **kwargs):
+ '''Sync auto-sync enabled repos'''
+ options = kwargs.get('options', None)
+ selected = self._get_repos(True)
+ if options.get('return-messages', False):
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ def all_repos(self, **kwargs):
+ '''Sync all repos defined in repos.conf'''
+ selected = self._get_repos(auto_sync_only=False)
+ options = kwargs.get('options', None)
+ if options.get('return-messages', False):
+ return self.rmessage(
+ self._sync(selected),
+ 'sync')
+ return self._sync(selected)
+
+
+ def repo(self, **kwargs):
+ '''Sync the specified repo'''
+ options = kwargs.get('options', None)
+ if options:
+ repos = options.get('repo', '')
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ if isinstance(repos, _basestring):
+ repos = repos.split()
+ available = self._get_repos(auto_sync_only=False)
+ selected = self._match_repos(repos, available)
+ if return_messages:
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ @staticmethod
+ def _match_repos(repos, available):
+ '''Internal search, matches up the repo.name in repos
+
+ @param repos: list, of repo names to match
+ @param avalable: list of repo objects to search
+ @return: list of repo objects that match
+ '''
+ selected = []
+ for repo in available:
+ if repo.name in repos:
+ selected.append(repo)
+ return selected
+
+
+ def _get_repos(self, auto_sync_only=True):
+ selected_repos = []
+ unknown_repo_names = []
+ missing_sync_type = []
+ if self.emerge_config.args:
+ for repo_name in self.emerge_config.args:
+ print("_get_repos(): repo_name =", repo_name)
+ try:
+ repo = self.emerge_config.target_config.settings.repositories[repo_name]
+ except KeyError:
+ unknown_repo_names.append(repo_name)
+ else:
+ selected_repos.append(repo)
+ if repo.sync_type is None:
+ missing_sync_type.append(repo)
+
+ if unknown_repo_names:
+ writemsg_level("!!! %s\n" % _("Unknown repo(s): %s") %
+ " ".join(unknown_repo_names),
+ level=logging.ERROR, noiselevel=-1)
+
+ if missing_sync_type:
+ writemsg_level("!!! %s\n" %
+ _("Missing sync-type for repo(s): %s") %
+ " ".join(repo.name for repo in missing_sync_type),
+ level=logging.ERROR, noiselevel=-1)
+
+ if unknown_repo_names or missing_sync_type:
+ print("missing or unknown repos... returning")
+ return []
+
+ else:
+ selected_repos.extend(self.emerge_config.target_config.settings.repositories)
+ #print("_get_repos(), selected =", selected_repos)
+ if auto_sync_only:
+ return self._filter_auto(selected_repos)
+ return selected_repos
+
+
+ def _filter_auto(self, repos):
+ selected = []
+ for repo in repos:
+ if repo.auto_sync in ['yes', 'true']:
+ selected.append(repo)
+ return selected
+
+
+ def _sync(self, selected_repos):
+ if not selected_repos:
+ print("_sync(), nothing to sync... returning")
+ return [('None', os.EX_OK)]
+ # Portage needs to ensure a sane umask for the files it creates.
+ os.umask(0o22)
+ portage._sync_mode = True
+
+ sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
+ retvals = []
+ for repo in selected_repos:
+ print("syncing repo:", repo.name)
+ if repo.sync_type is not None:
+ returncode = sync_manager.sync(self.emerge_config, repo)
+ #if returncode != os.EX_OK:
+ retvals.append((repo.name, returncode))
+
+ # Reload the whole config.
+ portage._sync_mode = False
+ self._reload_config()
+ self._do_pkg_moves()
+ self._check_updates()
+ display_news_notification(self.emerge_config.target_config,
+ self.emerge_config.opts)
+ if retvals:
+ return retvals
+ return [('None', os.EX_OK)]
+
+
+ def _do_pkg_moves(self):
+ if self.emerge_config.opts.get('--package-moves') != 'n' and \
+ _global_updates(self.emerge_config.trees,
+ self.emerge_config.target_config.mtimedb["updates"],
+ quiet=("--quiet" in self.emerge_config.opts)):
+ self.emerge_config.target_config.mtimedb.commit()
+ # Reload the whole config.
+ self._reload_config()
+
+
+ def _check_updates(self):
+ mybestpv = self.emerge_config.target_config.trees['porttree'].dbapi.xmatch(
+ "bestmatch-visible", portage.const.PORTAGE_PACKAGE_ATOM)
+ mypvs = portage.best(
+ self.emerge_config.target_config.trees['vartree'].dbapi.match(
+ portage.const.PORTAGE_PACKAGE_ATOM))
+
+ chk_updated_cfg_files(self.emerge_config.target_config.root,
+ portage.util.shlex_split(
+ self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+
+ if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
+ print()
+ print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ print(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ print()
+ print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ print()
+
+
+ def _reload_config(self):
+ '''Reload the whole config from scratch.'''
+ load_emerge_config(emerge_config=self.emerge_config)
+ adjust_configs(self.emerge_config.opts, self.emerge_config.trees)
+
+
+ def rmessage(self, rvals, action):
+ '''Creates emaint style messages to return to the task handler'''
+ messages = []
+ for rval in rvals:
+ messages.append("Action: %s for repo: %s, returned code = %s"
+ % (action, rval[0], rval[1]))
+ return messages
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-03 23:36 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-03 23:36 UTC (permalink / raw
To: gentoo-commits
commit: c03935c17ce8a65f24302d42dfe721ca5d42dce8
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Wed Sep 3 23:34:54 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c03935c1
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-04 1:18 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-04 1:18 UTC (permalink / raw
To: gentoo-commits
commit: 80d2e9961d62b7c00c20743fce0e2032d1912f6e
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Sep 4 01:18:02 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=80d2e996
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-05 4:38 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-05 4:38 UTC (permalink / raw
To: gentoo-commits
commit: 416919a2f02fbb967929575a327312a9ef7aa71e
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Sep 4 07:20:42 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=416919a2
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-05 4:38 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-05 4:38 UTC (permalink / raw
To: gentoo-commits
commit: f2023de96e2a9bf9a31bea10e4b7579094f215a0
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:28:16 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Sep 5 04:28:16 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f2023de9
emaint sync: migrate print staements to emaint style messages
Comment out some debug prints.
---
pym/portage/emaint/modules/sync/sync.py | 62 +++++++++++++++++++--------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index ab7591d..b657133 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -70,20 +70,22 @@ class SyncRepos(object):
'''Sync auto-sync enabled repos'''
options = kwargs.get('options', None)
selected = self._get_repos(True)
- if options.get('return-messages', False):
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def all_repos(self, **kwargs):
'''Sync all repos defined in repos.conf'''
selected = self._get_repos(auto_sync_only=False)
options = kwargs.get('options', None)
- if options.get('return-messages', False):
- return self.rmessage(
- self._sync(selected),
- 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def repo(self, **kwargs):
@@ -98,9 +100,7 @@ class SyncRepos(object):
repos = repos.split()
available = self._get_repos(auto_sync_only=False)
selected = self._match_repos(repos, available)
- if return_messages:
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ return self._sync(selected, return_messages)
@staticmethod
@@ -124,7 +124,7 @@ class SyncRepos(object):
missing_sync_type = []
if self.emerge_config.args:
for repo_name in self.emerge_config.args:
- print("_get_repos(): repo_name =", repo_name)
+ #print("_get_repos(): repo_name =", repo_name)
try:
repo = self.emerge_config.target_config.settings.repositories[repo_name]
except KeyError:
@@ -146,7 +146,8 @@ class SyncRepos(object):
level=logging.ERROR, noiselevel=-1)
if unknown_repo_names or missing_sync_type:
- print("missing or unknown repos... returning")
+ writemsg_level("Missing or unknown repos... returning",
+ level=logging.INFO, noiselevel=2)
return []
else:
@@ -165,17 +166,20 @@ class SyncRepos(object):
return selected
- def _sync(self, selected_repos):
+ def _sync(self, selected_repos, return_messages):
+ msgs = []
if not selected_repos:
- print("_sync(), nothing to sync... returning")
- return [('None', os.EX_OK)]
+ msgs.append("Emaint sync, nothing to sync... returning")
+ if return_messages:
+ return msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ return
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
for repo in selected_repos:
- print("syncing repo:", repo.name)
+ #print("syncing repo:", repo.name)
if repo.sync_type is not None:
returncode = sync_manager.sync(self.emerge_config, repo)
#if returncode != os.EX_OK:
@@ -185,12 +189,16 @@ class SyncRepos(object):
portage._sync_mode = False
self._reload_config()
self._do_pkg_moves()
- self._check_updates()
+ msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
if retvals:
- return retvals
- return [('None', os.EX_OK)]
+ msgs.extend(self.rmessage(retvals, 'sync'))
+ else:
+ msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if return_messages:
+ return msgs
+ return
def _do_pkg_moves(self):
@@ -214,13 +222,15 @@ class SyncRepos(object):
portage.util.shlex_split(
self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+ msgs = []
if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
- print()
- print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
- print(warn(" * ")+"that you update portage now, before any other packages are updated.")
- print()
- print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
- print()
+ msgs.append('')
+ msgs.append(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ msgs.append(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ msgs.append('')
+ msgs.append(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ msgs.append('')
+ return msgs
def _reload_config(self):
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-05 4:38 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-05 4:38 UTC (permalink / raw
To: gentoo-commits
commit: 21788efe20f2bd5a142ab4cd0518052449fce1db
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:37:10 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Sep 5 04:37:10 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=21788efe
emaint sync: Fix bug 522032, add a one time only post-sync hook call
After all repos have been synced, the emaint sync module runs another post-sync hook call
passing it the 'PORTAGE_SYNC_HOOK_FINAL' value as the url.
This value can be read by the post-sync hook to decide if it needs to run or pass.
This allows flexible, precise control over post-sync hooks for multiple repositories.
Caveat: Current app-portage/portage-utils post_sync hook script does not pass on the url
to the postsync.d/* scripts that it intiates.
---
pym/portage/emaint/modules/sync/sync.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index b657133..9b0d82c 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -192,10 +192,13 @@ class SyncRepos(object):
msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
+ rcode = sync_manager.perform_post_sync_hook('PORTAGE_SYNC_HOOK_FINAL')
if retvals:
msgs.extend(self.rmessage(retvals, 'sync'))
else:
msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if rcode:
+ msgs.append(self.rmessage('None', rcode), 'post-sync')
if return_messages:
return msgs
return
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-05 21:15 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-05 21:15 UTC (permalink / raw
To: gentoo-commits
commit: 74152a2196dd5a634abdda5db1f79da4d2944b21
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Sep 5 20:26:13 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=74152a21
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-05 21:15 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-05 21:15 UTC (permalink / raw
To: gentoo-commits
commit: 633289928b51b14e9bf7111498e910ea5faf8d09
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 21 18:30:00 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Sep 5 20:26:12 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=63328992
emaint/modules: New emaint module "sync"
This code is a migration from _emerge.actions.action_sync.
The code has been split up into logical blocks.
Some changes have been made to handle multiple repositories better.
It also adds more flexibility as to what is synced.
---
pym/portage/emaint/modules/sync/__init__.py | 44 ++++++
pym/portage/emaint/modules/sync/sync.py | 237 ++++++++++++++++++++++++++++
2 files changed, 281 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
new file mode 100644
index 0000000..4070200
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/__init__.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""Check repos.conf settings and sync repositories.
+"""
+
+
+module_spec = {
+ 'name': 'sync',
+ 'description': __doc__,
+ 'provides':{
+ 'sync-module': {
+ 'name': "sync",
+ 'class': "SyncRepos",
+ 'description': __doc__,
+ 'functions': ['allrepos', 'auto', 'repo'],
+ 'func_desc': {
+ 'repo': {
+ "short": "-r", "long": "--repo",
+ "help": "(sync module only): -r, --repo Sync the specified repo",
+ 'status': "Syncing %s",
+ 'action': 'store',
+ 'func': 'repo',
+ },
+ 'allrepos': {
+ "short": "-A", "long": "--allrepos",
+ "help": "(sync module only): -A, --allrepos Sync all repos that have a sync-url defined",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'allrepos',
+ 'func': 'all_repos',
+ },
+ 'auto': {
+ "short": "-a", "long": "--auto",
+ "help": "(sync module only): -a, --auto Sync auto-sync enabled repos only",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'auto',
+ 'func': 'auto_sync',
+ },
+ }
+ }
+ }
+ }
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
new file mode 100644
index 0000000..3aa318a
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -0,0 +1,237 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import logging
+import os
+import sys
+
+import portage
+from portage.localization import _
+from portage.output import bold, create_color_func
+from portage.sync import get_syncer
+from portage._global_updates import _global_updates
+from portage.util import writemsg_level
+
+import _emerge
+from _emerge.emergelog import emergelog
+
+
+portage.proxy.lazyimport.lazyimport(globals(),
+ '_emerge.actions:adjust_configs,load_emerge_config',
+ '_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
+ '_emerge.main:parse_opts',
+ '_emerge.post_emerge:display_news_notification',
+)
+
+warn = create_color_func("WARN")
+
+if sys.hexversion >= 0x3000000:
+ _basestring = str
+else:
+ _basestring = basestring
+
+
+class SyncRepos(object):
+
+ short_desc = "Check repos.conf settings and/or sync repositories"
+
+ @staticmethod
+ def name():
+ return "sync"
+
+
+ def can_progressbar(self, func):
+ return False
+
+
+ def __init__(self, emerge_config=None, emerge_logging=False):
+ '''Class init function
+
+ @param emerge_config: optional an emerge_config instance to use
+ @param emerge_logging: boolean, defaults to False
+ '''
+ if emerge_config:
+ self.emerge_config = emerge_config
+ else:
+ # need a basic options instance
+ actions, opts, _files = parse_opts([], silent=True)
+ self.emerge_config = load_emerge_config(
+ action='sync', args=_files, trees=[], opts=opts)
+ if emerge_logging:
+ _emerge.emergelog._disable = False
+ self.xterm_titles = "notitles" not in \
+ self.emerge_config.target_config.settings.features
+ emergelog(self.xterm_titles, " === sync")
+
+
+ def auto_sync(self, **kwargs):
+ '''Sync auto-sync enabled repos'''
+ options = kwargs.get('options', None)
+ selected = self._get_repos(True)
+ if options.get('return-messages', False):
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ def all_repos(self, **kwargs):
+ '''Sync all repos defined in repos.conf'''
+ selected = self._get_repos(auto_sync_only=False)
+ options = kwargs.get('options', None)
+ if options.get('return-messages', False):
+ return self.rmessage(
+ self._sync(selected),
+ 'sync')
+ return self._sync(selected)
+
+
+ def repo(self, **kwargs):
+ '''Sync the specified repo'''
+ options = kwargs.get('options', None)
+ if options:
+ repos = options.get('repo', '')
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ if isinstance(repos, _basestring):
+ repos = repos.split()
+ available = self._get_repos(auto_sync_only=False)
+ selected = self._match_repos(repos, available)
+ if return_messages:
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ @staticmethod
+ def _match_repos(repos, available):
+ '''Internal search, matches up the repo.name in repos
+
+ @param repos: list, of repo names to match
+ @param avalable: list of repo objects to search
+ @return: list of repo objects that match
+ '''
+ selected = []
+ for repo in available:
+ if repo.name in repos:
+ selected.append(repo)
+ return selected
+
+
+ def _get_repos(self, auto_sync_only=True):
+ selected_repos = []
+ unknown_repo_names = []
+ missing_sync_type = []
+ if self.emerge_config.args:
+ for repo_name in self.emerge_config.args:
+ print("_get_repos(): repo_name =", repo_name)
+ try:
+ repo = self.emerge_config.target_config.settings.repositories[repo_name]
+ except KeyError:
+ unknown_repo_names.append(repo_name)
+ else:
+ selected_repos.append(repo)
+ if repo.sync_type is None:
+ missing_sync_type.append(repo)
+
+ if unknown_repo_names:
+ writemsg_level("!!! %s\n" % _("Unknown repo(s): %s") %
+ " ".join(unknown_repo_names),
+ level=logging.ERROR, noiselevel=-1)
+
+ if missing_sync_type:
+ writemsg_level("!!! %s\n" %
+ _("Missing sync-type for repo(s): %s") %
+ " ".join(repo.name for repo in missing_sync_type),
+ level=logging.ERROR, noiselevel=-1)
+
+ if unknown_repo_names or missing_sync_type:
+ print("missing or unknown repos... returning")
+ return []
+
+ else:
+ selected_repos.extend(self.emerge_config.target_config.settings.repositories)
+ #print("_get_repos(), selected =", selected_repos)
+ if auto_sync_only:
+ return self._filter_auto(selected_repos)
+ return selected_repos
+
+
+ def _filter_auto(self, repos):
+ selected = []
+ for repo in repos:
+ if repo.auto_sync in ['yes', 'true']:
+ selected.append(repo)
+ return selected
+
+
+ def _sync(self, selected_repos):
+ if not selected_repos:
+ print("_sync(), nothing to sync... returning")
+ return [('None', os.EX_OK)]
+ # Portage needs to ensure a sane umask for the files it creates.
+ os.umask(0o22)
+ portage._sync_mode = True
+
+ sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
+ retvals = []
+ for repo in selected_repos:
+ print("syncing repo:", repo.name)
+ if repo.sync_type is not None:
+ returncode = sync_manager.sync(self.emerge_config, repo)
+ #if returncode != os.EX_OK:
+ retvals.append((repo.name, returncode))
+
+ # Reload the whole config.
+ portage._sync_mode = False
+ self._reload_config()
+ self._do_pkg_moves()
+ self._check_updates()
+ display_news_notification(self.emerge_config.target_config,
+ self.emerge_config.opts)
+ if retvals:
+ return retvals
+ return [('None', os.EX_OK)]
+
+
+ def _do_pkg_moves(self):
+ if self.emerge_config.opts.get('--package-moves') != 'n' and \
+ _global_updates(self.emerge_config.trees,
+ self.emerge_config.target_config.mtimedb["updates"],
+ quiet=("--quiet" in self.emerge_config.opts)):
+ self.emerge_config.target_config.mtimedb.commit()
+ # Reload the whole config.
+ self._reload_config()
+
+
+ def _check_updates(self):
+ mybestpv = self.emerge_config.target_config.trees['porttree'].dbapi.xmatch(
+ "bestmatch-visible", portage.const.PORTAGE_PACKAGE_ATOM)
+ mypvs = portage.best(
+ self.emerge_config.target_config.trees['vartree'].dbapi.match(
+ portage.const.PORTAGE_PACKAGE_ATOM))
+
+ chk_updated_cfg_files(self.emerge_config.target_config.root,
+ portage.util.shlex_split(
+ self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+
+ if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
+ print()
+ print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ print(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ print()
+ print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ print()
+
+
+ def _reload_config(self):
+ '''Reload the whole config from scratch.'''
+ load_emerge_config(emerge_config=self.emerge_config)
+ adjust_configs(self.emerge_config.opts, self.emerge_config.trees)
+
+
+ def rmessage(self, rvals, action):
+ '''Creates emaint style messages to return to the task handler'''
+ messages = []
+ for rval in rvals:
+ messages.append("Action: %s for repo: %s, returned code = %s"
+ % (action, rval[0], rval[1]))
+ return messages
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-05 21:15 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-05 21:15 UTC (permalink / raw
To: gentoo-commits
commit: 84376c0e10bdcfcb280f310ef2461262c6d51236
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:28:16 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Sep 5 20:26:14 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=84376c0e
emaint sync: migrate print staements to emaint style messages
Comment out some debug prints.
---
pym/portage/emaint/modules/sync/sync.py | 62 +++++++++++++++++++--------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index ab7591d..b657133 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -70,20 +70,22 @@ class SyncRepos(object):
'''Sync auto-sync enabled repos'''
options = kwargs.get('options', None)
selected = self._get_repos(True)
- if options.get('return-messages', False):
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def all_repos(self, **kwargs):
'''Sync all repos defined in repos.conf'''
selected = self._get_repos(auto_sync_only=False)
options = kwargs.get('options', None)
- if options.get('return-messages', False):
- return self.rmessage(
- self._sync(selected),
- 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def repo(self, **kwargs):
@@ -98,9 +100,7 @@ class SyncRepos(object):
repos = repos.split()
available = self._get_repos(auto_sync_only=False)
selected = self._match_repos(repos, available)
- if return_messages:
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ return self._sync(selected, return_messages)
@staticmethod
@@ -124,7 +124,7 @@ class SyncRepos(object):
missing_sync_type = []
if self.emerge_config.args:
for repo_name in self.emerge_config.args:
- print("_get_repos(): repo_name =", repo_name)
+ #print("_get_repos(): repo_name =", repo_name)
try:
repo = self.emerge_config.target_config.settings.repositories[repo_name]
except KeyError:
@@ -146,7 +146,8 @@ class SyncRepos(object):
level=logging.ERROR, noiselevel=-1)
if unknown_repo_names or missing_sync_type:
- print("missing or unknown repos... returning")
+ writemsg_level("Missing or unknown repos... returning",
+ level=logging.INFO, noiselevel=2)
return []
else:
@@ -165,17 +166,20 @@ class SyncRepos(object):
return selected
- def _sync(self, selected_repos):
+ def _sync(self, selected_repos, return_messages):
+ msgs = []
if not selected_repos:
- print("_sync(), nothing to sync... returning")
- return [('None', os.EX_OK)]
+ msgs.append("Emaint sync, nothing to sync... returning")
+ if return_messages:
+ return msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ return
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
for repo in selected_repos:
- print("syncing repo:", repo.name)
+ #print("syncing repo:", repo.name)
if repo.sync_type is not None:
returncode = sync_manager.sync(self.emerge_config, repo)
#if returncode != os.EX_OK:
@@ -185,12 +189,16 @@ class SyncRepos(object):
portage._sync_mode = False
self._reload_config()
self._do_pkg_moves()
- self._check_updates()
+ msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
if retvals:
- return retvals
- return [('None', os.EX_OK)]
+ msgs.extend(self.rmessage(retvals, 'sync'))
+ else:
+ msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if return_messages:
+ return msgs
+ return
def _do_pkg_moves(self):
@@ -214,13 +222,15 @@ class SyncRepos(object):
portage.util.shlex_split(
self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+ msgs = []
if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
- print()
- print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
- print(warn(" * ")+"that you update portage now, before any other packages are updated.")
- print()
- print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
- print()
+ msgs.append('')
+ msgs.append(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ msgs.append(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ msgs.append('')
+ msgs.append(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ msgs.append('')
+ return msgs
def _reload_config(self):
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-05 21:15 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-05 21:15 UTC (permalink / raw
To: gentoo-commits
commit: 5aef3c2954243c76b8a4e96e97992d9bbad1d136
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:37:10 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Fri Sep 5 20:26:14 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5aef3c29
emaint sync: Fix bug 522032, add a one time only post-sync hook call
After all repos have been synced, the emaint sync module runs another post-sync hook call
passing it the 'PORTAGE_SYNC_HOOK_FINAL' value as the url.
This value can be read by the post-sync hook to decide if it needs to run or pass.
This allows flexible, precise control over post-sync hooks for multiple repositories.
Caveat: Current app-portage/portage-utils post_sync hook script does not pass on the url
to the postsync.d/* scripts that it intiates.
---
pym/portage/emaint/modules/sync/sync.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index b657133..9b0d82c 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -192,10 +192,13 @@ class SyncRepos(object):
msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
+ rcode = sync_manager.perform_post_sync_hook('PORTAGE_SYNC_HOOK_FINAL')
if retvals:
msgs.extend(self.rmessage(retvals, 'sync'))
else:
msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if rcode:
+ msgs.append(self.rmessage('None', rcode), 'post-sync')
if return_messages:
return msgs
return
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-27 2:20 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-27 2:20 UTC (permalink / raw
To: gentoo-commits
commit: b247cd2709fb3837b38cfbf7771b65a3130fe953
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 21 18:30:00 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Sep 27 01:40:15 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b247cd27
emaint/modules: New emaint module "sync"
This code is a migration from _emerge.actions.action_sync.
The code has been split up into logical blocks.
Some changes have been made to handle multiple repositories better.
It also adds more flexibility as to what is synced.
---
pym/portage/emaint/modules/sync/__init__.py | 44 ++++++
pym/portage/emaint/modules/sync/sync.py | 237 ++++++++++++++++++++++++++++
2 files changed, 281 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
new file mode 100644
index 0000000..4070200
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/__init__.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""Check repos.conf settings and sync repositories.
+"""
+
+
+module_spec = {
+ 'name': 'sync',
+ 'description': __doc__,
+ 'provides':{
+ 'sync-module': {
+ 'name': "sync",
+ 'class': "SyncRepos",
+ 'description': __doc__,
+ 'functions': ['allrepos', 'auto', 'repo'],
+ 'func_desc': {
+ 'repo': {
+ "short": "-r", "long": "--repo",
+ "help": "(sync module only): -r, --repo Sync the specified repo",
+ 'status': "Syncing %s",
+ 'action': 'store',
+ 'func': 'repo',
+ },
+ 'allrepos': {
+ "short": "-A", "long": "--allrepos",
+ "help": "(sync module only): -A, --allrepos Sync all repos that have a sync-url defined",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'allrepos',
+ 'func': 'all_repos',
+ },
+ 'auto': {
+ "short": "-a", "long": "--auto",
+ "help": "(sync module only): -a, --auto Sync auto-sync enabled repos only",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'auto',
+ 'func': 'auto_sync',
+ },
+ }
+ }
+ }
+ }
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
new file mode 100644
index 0000000..3aa318a
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -0,0 +1,237 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import logging
+import os
+import sys
+
+import portage
+from portage.localization import _
+from portage.output import bold, create_color_func
+from portage.sync import get_syncer
+from portage._global_updates import _global_updates
+from portage.util import writemsg_level
+
+import _emerge
+from _emerge.emergelog import emergelog
+
+
+portage.proxy.lazyimport.lazyimport(globals(),
+ '_emerge.actions:adjust_configs,load_emerge_config',
+ '_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
+ '_emerge.main:parse_opts',
+ '_emerge.post_emerge:display_news_notification',
+)
+
+warn = create_color_func("WARN")
+
+if sys.hexversion >= 0x3000000:
+ _basestring = str
+else:
+ _basestring = basestring
+
+
+class SyncRepos(object):
+
+ short_desc = "Check repos.conf settings and/or sync repositories"
+
+ @staticmethod
+ def name():
+ return "sync"
+
+
+ def can_progressbar(self, func):
+ return False
+
+
+ def __init__(self, emerge_config=None, emerge_logging=False):
+ '''Class init function
+
+ @param emerge_config: optional an emerge_config instance to use
+ @param emerge_logging: boolean, defaults to False
+ '''
+ if emerge_config:
+ self.emerge_config = emerge_config
+ else:
+ # need a basic options instance
+ actions, opts, _files = parse_opts([], silent=True)
+ self.emerge_config = load_emerge_config(
+ action='sync', args=_files, trees=[], opts=opts)
+ if emerge_logging:
+ _emerge.emergelog._disable = False
+ self.xterm_titles = "notitles" not in \
+ self.emerge_config.target_config.settings.features
+ emergelog(self.xterm_titles, " === sync")
+
+
+ def auto_sync(self, **kwargs):
+ '''Sync auto-sync enabled repos'''
+ options = kwargs.get('options', None)
+ selected = self._get_repos(True)
+ if options.get('return-messages', False):
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ def all_repos(self, **kwargs):
+ '''Sync all repos defined in repos.conf'''
+ selected = self._get_repos(auto_sync_only=False)
+ options = kwargs.get('options', None)
+ if options.get('return-messages', False):
+ return self.rmessage(
+ self._sync(selected),
+ 'sync')
+ return self._sync(selected)
+
+
+ def repo(self, **kwargs):
+ '''Sync the specified repo'''
+ options = kwargs.get('options', None)
+ if options:
+ repos = options.get('repo', '')
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ if isinstance(repos, _basestring):
+ repos = repos.split()
+ available = self._get_repos(auto_sync_only=False)
+ selected = self._match_repos(repos, available)
+ if return_messages:
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ @staticmethod
+ def _match_repos(repos, available):
+ '''Internal search, matches up the repo.name in repos
+
+ @param repos: list, of repo names to match
+ @param avalable: list of repo objects to search
+ @return: list of repo objects that match
+ '''
+ selected = []
+ for repo in available:
+ if repo.name in repos:
+ selected.append(repo)
+ return selected
+
+
+ def _get_repos(self, auto_sync_only=True):
+ selected_repos = []
+ unknown_repo_names = []
+ missing_sync_type = []
+ if self.emerge_config.args:
+ for repo_name in self.emerge_config.args:
+ print("_get_repos(): repo_name =", repo_name)
+ try:
+ repo = self.emerge_config.target_config.settings.repositories[repo_name]
+ except KeyError:
+ unknown_repo_names.append(repo_name)
+ else:
+ selected_repos.append(repo)
+ if repo.sync_type is None:
+ missing_sync_type.append(repo)
+
+ if unknown_repo_names:
+ writemsg_level("!!! %s\n" % _("Unknown repo(s): %s") %
+ " ".join(unknown_repo_names),
+ level=logging.ERROR, noiselevel=-1)
+
+ if missing_sync_type:
+ writemsg_level("!!! %s\n" %
+ _("Missing sync-type for repo(s): %s") %
+ " ".join(repo.name for repo in missing_sync_type),
+ level=logging.ERROR, noiselevel=-1)
+
+ if unknown_repo_names or missing_sync_type:
+ print("missing or unknown repos... returning")
+ return []
+
+ else:
+ selected_repos.extend(self.emerge_config.target_config.settings.repositories)
+ #print("_get_repos(), selected =", selected_repos)
+ if auto_sync_only:
+ return self._filter_auto(selected_repos)
+ return selected_repos
+
+
+ def _filter_auto(self, repos):
+ selected = []
+ for repo in repos:
+ if repo.auto_sync in ['yes', 'true']:
+ selected.append(repo)
+ return selected
+
+
+ def _sync(self, selected_repos):
+ if not selected_repos:
+ print("_sync(), nothing to sync... returning")
+ return [('None', os.EX_OK)]
+ # Portage needs to ensure a sane umask for the files it creates.
+ os.umask(0o22)
+ portage._sync_mode = True
+
+ sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
+ retvals = []
+ for repo in selected_repos:
+ print("syncing repo:", repo.name)
+ if repo.sync_type is not None:
+ returncode = sync_manager.sync(self.emerge_config, repo)
+ #if returncode != os.EX_OK:
+ retvals.append((repo.name, returncode))
+
+ # Reload the whole config.
+ portage._sync_mode = False
+ self._reload_config()
+ self._do_pkg_moves()
+ self._check_updates()
+ display_news_notification(self.emerge_config.target_config,
+ self.emerge_config.opts)
+ if retvals:
+ return retvals
+ return [('None', os.EX_OK)]
+
+
+ def _do_pkg_moves(self):
+ if self.emerge_config.opts.get('--package-moves') != 'n' and \
+ _global_updates(self.emerge_config.trees,
+ self.emerge_config.target_config.mtimedb["updates"],
+ quiet=("--quiet" in self.emerge_config.opts)):
+ self.emerge_config.target_config.mtimedb.commit()
+ # Reload the whole config.
+ self._reload_config()
+
+
+ def _check_updates(self):
+ mybestpv = self.emerge_config.target_config.trees['porttree'].dbapi.xmatch(
+ "bestmatch-visible", portage.const.PORTAGE_PACKAGE_ATOM)
+ mypvs = portage.best(
+ self.emerge_config.target_config.trees['vartree'].dbapi.match(
+ portage.const.PORTAGE_PACKAGE_ATOM))
+
+ chk_updated_cfg_files(self.emerge_config.target_config.root,
+ portage.util.shlex_split(
+ self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+
+ if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
+ print()
+ print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ print(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ print()
+ print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ print()
+
+
+ def _reload_config(self):
+ '''Reload the whole config from scratch.'''
+ load_emerge_config(emerge_config=self.emerge_config)
+ adjust_configs(self.emerge_config.opts, self.emerge_config.trees)
+
+
+ def rmessage(self, rvals, action):
+ '''Creates emaint style messages to return to the task handler'''
+ messages = []
+ for rval in rvals:
+ messages.append("Action: %s for repo: %s, returned code = %s"
+ % (action, rval[0], rval[1]))
+ return messages
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-27 2:20 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-27 2:20 UTC (permalink / raw
To: gentoo-commits
commit: 49bf16638b2b723743c328e6b377f65fdf77f127
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:28:16 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Sep 27 01:40:45 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=49bf1663
emaint sync: migrate print staements to emaint style messages
Comment out some debug prints.
---
pym/portage/emaint/modules/sync/sync.py | 62 +++++++++++++++++++--------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index ab7591d..b657133 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -70,20 +70,22 @@ class SyncRepos(object):
'''Sync auto-sync enabled repos'''
options = kwargs.get('options', None)
selected = self._get_repos(True)
- if options.get('return-messages', False):
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def all_repos(self, **kwargs):
'''Sync all repos defined in repos.conf'''
selected = self._get_repos(auto_sync_only=False)
options = kwargs.get('options', None)
- if options.get('return-messages', False):
- return self.rmessage(
- self._sync(selected),
- 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def repo(self, **kwargs):
@@ -98,9 +100,7 @@ class SyncRepos(object):
repos = repos.split()
available = self._get_repos(auto_sync_only=False)
selected = self._match_repos(repos, available)
- if return_messages:
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ return self._sync(selected, return_messages)
@staticmethod
@@ -124,7 +124,7 @@ class SyncRepos(object):
missing_sync_type = []
if self.emerge_config.args:
for repo_name in self.emerge_config.args:
- print("_get_repos(): repo_name =", repo_name)
+ #print("_get_repos(): repo_name =", repo_name)
try:
repo = self.emerge_config.target_config.settings.repositories[repo_name]
except KeyError:
@@ -146,7 +146,8 @@ class SyncRepos(object):
level=logging.ERROR, noiselevel=-1)
if unknown_repo_names or missing_sync_type:
- print("missing or unknown repos... returning")
+ writemsg_level("Missing or unknown repos... returning",
+ level=logging.INFO, noiselevel=2)
return []
else:
@@ -165,17 +166,20 @@ class SyncRepos(object):
return selected
- def _sync(self, selected_repos):
+ def _sync(self, selected_repos, return_messages):
+ msgs = []
if not selected_repos:
- print("_sync(), nothing to sync... returning")
- return [('None', os.EX_OK)]
+ msgs.append("Emaint sync, nothing to sync... returning")
+ if return_messages:
+ return msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ return
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
for repo in selected_repos:
- print("syncing repo:", repo.name)
+ #print("syncing repo:", repo.name)
if repo.sync_type is not None:
returncode = sync_manager.sync(self.emerge_config, repo)
#if returncode != os.EX_OK:
@@ -185,12 +189,16 @@ class SyncRepos(object):
portage._sync_mode = False
self._reload_config()
self._do_pkg_moves()
- self._check_updates()
+ msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
if retvals:
- return retvals
- return [('None', os.EX_OK)]
+ msgs.extend(self.rmessage(retvals, 'sync'))
+ else:
+ msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if return_messages:
+ return msgs
+ return
def _do_pkg_moves(self):
@@ -214,13 +222,15 @@ class SyncRepos(object):
portage.util.shlex_split(
self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+ msgs = []
if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
- print()
- print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
- print(warn(" * ")+"that you update portage now, before any other packages are updated.")
- print()
- print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
- print()
+ msgs.append('')
+ msgs.append(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ msgs.append(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ msgs.append('')
+ msgs.append(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ msgs.append('')
+ return msgs
def _reload_config(self):
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-27 2:20 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-27 2:20 UTC (permalink / raw
To: gentoo-commits
commit: 48e6790a7098b1cabdfe74f956ae53e25eeda21b
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Sep 27 01:40:44 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=48e6790a
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-27 2:20 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-27 2:20 UTC (permalink / raw
To: gentoo-commits
commit: c4024a1948b15e099833a1a68314fd11cb9ff052
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:37:10 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Sat Sep 27 01:40:45 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=c4024a19
emaint sync: Fix bug 522032, add a one time only post-sync hook call
After all repos have been synced, the emaint sync module runs another post-sync hook call
passing it the 'PORTAGE_SYNC_HOOK_FINAL' value as the url.
This value can be read by the post-sync hook to decide if it needs to run or pass.
This allows flexible, precise control over post-sync hooks for multiple repositories.
Caveat: Current app-portage/portage-utils post_sync hook script does not pass on the url
to the postsync.d/* scripts that it intiates.
---
pym/portage/emaint/modules/sync/sync.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index b657133..9b0d82c 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -192,10 +192,13 @@ class SyncRepos(object):
msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
+ rcode = sync_manager.perform_post_sync_hook('PORTAGE_SYNC_HOOK_FINAL')
if retvals:
msgs.extend(self.rmessage(retvals, 'sync'))
else:
msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if rcode:
+ msgs.append(self.rmessage('None', rcode), 'post-sync')
if return_messages:
return msgs
return
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-29 18:29 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-29 18:29 UTC (permalink / raw
To: gentoo-commits
commit: 651e1b56d44f2b47d5168a6753437e6da15f36af
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Sep 29 17:20:21 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=651e1b56
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-29 18:29 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-29 18:29 UTC (permalink / raw
To: gentoo-commits
commit: 954f3077a1463429d968838d237997dbc327f154
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 21 18:30:00 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Sep 29 17:20:20 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=954f3077
emaint/modules: New emaint module "sync"
This code is a migration from _emerge.actions.action_sync.
The code has been split up into logical blocks.
Some changes have been made to handle multiple repositories better.
It also adds more flexibility as to what is synced.
---
pym/portage/emaint/modules/sync/__init__.py | 44 ++++++
pym/portage/emaint/modules/sync/sync.py | 237 ++++++++++++++++++++++++++++
2 files changed, 281 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
new file mode 100644
index 0000000..4070200
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/__init__.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""Check repos.conf settings and sync repositories.
+"""
+
+
+module_spec = {
+ 'name': 'sync',
+ 'description': __doc__,
+ 'provides':{
+ 'sync-module': {
+ 'name': "sync",
+ 'class': "SyncRepos",
+ 'description': __doc__,
+ 'functions': ['allrepos', 'auto', 'repo'],
+ 'func_desc': {
+ 'repo': {
+ "short": "-r", "long": "--repo",
+ "help": "(sync module only): -r, --repo Sync the specified repo",
+ 'status': "Syncing %s",
+ 'action': 'store',
+ 'func': 'repo',
+ },
+ 'allrepos': {
+ "short": "-A", "long": "--allrepos",
+ "help": "(sync module only): -A, --allrepos Sync all repos that have a sync-url defined",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'allrepos',
+ 'func': 'all_repos',
+ },
+ 'auto': {
+ "short": "-a", "long": "--auto",
+ "help": "(sync module only): -a, --auto Sync auto-sync enabled repos only",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'auto',
+ 'func': 'auto_sync',
+ },
+ }
+ }
+ }
+ }
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
new file mode 100644
index 0000000..3aa318a
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -0,0 +1,237 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import logging
+import os
+import sys
+
+import portage
+from portage.localization import _
+from portage.output import bold, create_color_func
+from portage.sync import get_syncer
+from portage._global_updates import _global_updates
+from portage.util import writemsg_level
+
+import _emerge
+from _emerge.emergelog import emergelog
+
+
+portage.proxy.lazyimport.lazyimport(globals(),
+ '_emerge.actions:adjust_configs,load_emerge_config',
+ '_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
+ '_emerge.main:parse_opts',
+ '_emerge.post_emerge:display_news_notification',
+)
+
+warn = create_color_func("WARN")
+
+if sys.hexversion >= 0x3000000:
+ _basestring = str
+else:
+ _basestring = basestring
+
+
+class SyncRepos(object):
+
+ short_desc = "Check repos.conf settings and/or sync repositories"
+
+ @staticmethod
+ def name():
+ return "sync"
+
+
+ def can_progressbar(self, func):
+ return False
+
+
+ def __init__(self, emerge_config=None, emerge_logging=False):
+ '''Class init function
+
+ @param emerge_config: optional an emerge_config instance to use
+ @param emerge_logging: boolean, defaults to False
+ '''
+ if emerge_config:
+ self.emerge_config = emerge_config
+ else:
+ # need a basic options instance
+ actions, opts, _files = parse_opts([], silent=True)
+ self.emerge_config = load_emerge_config(
+ action='sync', args=_files, trees=[], opts=opts)
+ if emerge_logging:
+ _emerge.emergelog._disable = False
+ self.xterm_titles = "notitles" not in \
+ self.emerge_config.target_config.settings.features
+ emergelog(self.xterm_titles, " === sync")
+
+
+ def auto_sync(self, **kwargs):
+ '''Sync auto-sync enabled repos'''
+ options = kwargs.get('options', None)
+ selected = self._get_repos(True)
+ if options.get('return-messages', False):
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ def all_repos(self, **kwargs):
+ '''Sync all repos defined in repos.conf'''
+ selected = self._get_repos(auto_sync_only=False)
+ options = kwargs.get('options', None)
+ if options.get('return-messages', False):
+ return self.rmessage(
+ self._sync(selected),
+ 'sync')
+ return self._sync(selected)
+
+
+ def repo(self, **kwargs):
+ '''Sync the specified repo'''
+ options = kwargs.get('options', None)
+ if options:
+ repos = options.get('repo', '')
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ if isinstance(repos, _basestring):
+ repos = repos.split()
+ available = self._get_repos(auto_sync_only=False)
+ selected = self._match_repos(repos, available)
+ if return_messages:
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ @staticmethod
+ def _match_repos(repos, available):
+ '''Internal search, matches up the repo.name in repos
+
+ @param repos: list, of repo names to match
+ @param avalable: list of repo objects to search
+ @return: list of repo objects that match
+ '''
+ selected = []
+ for repo in available:
+ if repo.name in repos:
+ selected.append(repo)
+ return selected
+
+
+ def _get_repos(self, auto_sync_only=True):
+ selected_repos = []
+ unknown_repo_names = []
+ missing_sync_type = []
+ if self.emerge_config.args:
+ for repo_name in self.emerge_config.args:
+ print("_get_repos(): repo_name =", repo_name)
+ try:
+ repo = self.emerge_config.target_config.settings.repositories[repo_name]
+ except KeyError:
+ unknown_repo_names.append(repo_name)
+ else:
+ selected_repos.append(repo)
+ if repo.sync_type is None:
+ missing_sync_type.append(repo)
+
+ if unknown_repo_names:
+ writemsg_level("!!! %s\n" % _("Unknown repo(s): %s") %
+ " ".join(unknown_repo_names),
+ level=logging.ERROR, noiselevel=-1)
+
+ if missing_sync_type:
+ writemsg_level("!!! %s\n" %
+ _("Missing sync-type for repo(s): %s") %
+ " ".join(repo.name for repo in missing_sync_type),
+ level=logging.ERROR, noiselevel=-1)
+
+ if unknown_repo_names or missing_sync_type:
+ print("missing or unknown repos... returning")
+ return []
+
+ else:
+ selected_repos.extend(self.emerge_config.target_config.settings.repositories)
+ #print("_get_repos(), selected =", selected_repos)
+ if auto_sync_only:
+ return self._filter_auto(selected_repos)
+ return selected_repos
+
+
+ def _filter_auto(self, repos):
+ selected = []
+ for repo in repos:
+ if repo.auto_sync in ['yes', 'true']:
+ selected.append(repo)
+ return selected
+
+
+ def _sync(self, selected_repos):
+ if not selected_repos:
+ print("_sync(), nothing to sync... returning")
+ return [('None', os.EX_OK)]
+ # Portage needs to ensure a sane umask for the files it creates.
+ os.umask(0o22)
+ portage._sync_mode = True
+
+ sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
+ retvals = []
+ for repo in selected_repos:
+ print("syncing repo:", repo.name)
+ if repo.sync_type is not None:
+ returncode = sync_manager.sync(self.emerge_config, repo)
+ #if returncode != os.EX_OK:
+ retvals.append((repo.name, returncode))
+
+ # Reload the whole config.
+ portage._sync_mode = False
+ self._reload_config()
+ self._do_pkg_moves()
+ self._check_updates()
+ display_news_notification(self.emerge_config.target_config,
+ self.emerge_config.opts)
+ if retvals:
+ return retvals
+ return [('None', os.EX_OK)]
+
+
+ def _do_pkg_moves(self):
+ if self.emerge_config.opts.get('--package-moves') != 'n' and \
+ _global_updates(self.emerge_config.trees,
+ self.emerge_config.target_config.mtimedb["updates"],
+ quiet=("--quiet" in self.emerge_config.opts)):
+ self.emerge_config.target_config.mtimedb.commit()
+ # Reload the whole config.
+ self._reload_config()
+
+
+ def _check_updates(self):
+ mybestpv = self.emerge_config.target_config.trees['porttree'].dbapi.xmatch(
+ "bestmatch-visible", portage.const.PORTAGE_PACKAGE_ATOM)
+ mypvs = portage.best(
+ self.emerge_config.target_config.trees['vartree'].dbapi.match(
+ portage.const.PORTAGE_PACKAGE_ATOM))
+
+ chk_updated_cfg_files(self.emerge_config.target_config.root,
+ portage.util.shlex_split(
+ self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+
+ if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
+ print()
+ print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ print(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ print()
+ print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ print()
+
+
+ def _reload_config(self):
+ '''Reload the whole config from scratch.'''
+ load_emerge_config(emerge_config=self.emerge_config)
+ adjust_configs(self.emerge_config.opts, self.emerge_config.trees)
+
+
+ def rmessage(self, rvals, action):
+ '''Creates emaint style messages to return to the task handler'''
+ messages = []
+ for rval in rvals:
+ messages.append("Action: %s for repo: %s, returned code = %s"
+ % (action, rval[0], rval[1]))
+ return messages
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-29 18:29 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-29 18:29 UTC (permalink / raw
To: gentoo-commits
commit: 8ef3bfb4f187be83b39a779ca73da350e4780a25
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:37:10 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Sep 29 17:20:21 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=8ef3bfb4
emaint sync: Fix bug 522032, add a one time only post-sync hook call
After all repos have been synced, the emaint sync module runs another post-sync hook call
passing it the 'PORTAGE_SYNC_HOOK_FINAL' value as the url.
This value can be read by the post-sync hook to decide if it needs to run or pass.
This allows flexible, precise control over post-sync hooks for multiple repositories.
Caveat: Current app-portage/portage-utils post_sync hook script does not pass on the url
to the postsync.d/* scripts that it intiates.
---
pym/portage/emaint/modules/sync/sync.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index b657133..9b0d82c 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -192,10 +192,13 @@ class SyncRepos(object):
msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
+ rcode = sync_manager.perform_post_sync_hook('PORTAGE_SYNC_HOOK_FINAL')
if retvals:
msgs.extend(self.rmessage(retvals, 'sync'))
else:
msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if rcode:
+ msgs.append(self.rmessage('None', rcode), 'post-sync')
if return_messages:
return msgs
return
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-29 18:29 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-29 18:29 UTC (permalink / raw
To: gentoo-commits
commit: ff34d37193745e915b9213d72c0be4d5e0eeec80
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:28:16 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Mon Sep 29 17:20:21 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=ff34d371
emaint sync: migrate print staements to emaint style messages
Comment out some debug prints.
---
pym/portage/emaint/modules/sync/sync.py | 62 +++++++++++++++++++--------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index ab7591d..b657133 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -70,20 +70,22 @@ class SyncRepos(object):
'''Sync auto-sync enabled repos'''
options = kwargs.get('options', None)
selected = self._get_repos(True)
- if options.get('return-messages', False):
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def all_repos(self, **kwargs):
'''Sync all repos defined in repos.conf'''
selected = self._get_repos(auto_sync_only=False)
options = kwargs.get('options', None)
- if options.get('return-messages', False):
- return self.rmessage(
- self._sync(selected),
- 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def repo(self, **kwargs):
@@ -98,9 +100,7 @@ class SyncRepos(object):
repos = repos.split()
available = self._get_repos(auto_sync_only=False)
selected = self._match_repos(repos, available)
- if return_messages:
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ return self._sync(selected, return_messages)
@staticmethod
@@ -124,7 +124,7 @@ class SyncRepos(object):
missing_sync_type = []
if self.emerge_config.args:
for repo_name in self.emerge_config.args:
- print("_get_repos(): repo_name =", repo_name)
+ #print("_get_repos(): repo_name =", repo_name)
try:
repo = self.emerge_config.target_config.settings.repositories[repo_name]
except KeyError:
@@ -146,7 +146,8 @@ class SyncRepos(object):
level=logging.ERROR, noiselevel=-1)
if unknown_repo_names or missing_sync_type:
- print("missing or unknown repos... returning")
+ writemsg_level("Missing or unknown repos... returning",
+ level=logging.INFO, noiselevel=2)
return []
else:
@@ -165,17 +166,20 @@ class SyncRepos(object):
return selected
- def _sync(self, selected_repos):
+ def _sync(self, selected_repos, return_messages):
+ msgs = []
if not selected_repos:
- print("_sync(), nothing to sync... returning")
- return [('None', os.EX_OK)]
+ msgs.append("Emaint sync, nothing to sync... returning")
+ if return_messages:
+ return msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ return
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
for repo in selected_repos:
- print("syncing repo:", repo.name)
+ #print("syncing repo:", repo.name)
if repo.sync_type is not None:
returncode = sync_manager.sync(self.emerge_config, repo)
#if returncode != os.EX_OK:
@@ -185,12 +189,16 @@ class SyncRepos(object):
portage._sync_mode = False
self._reload_config()
self._do_pkg_moves()
- self._check_updates()
+ msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
if retvals:
- return retvals
- return [('None', os.EX_OK)]
+ msgs.extend(self.rmessage(retvals, 'sync'))
+ else:
+ msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if return_messages:
+ return msgs
+ return
def _do_pkg_moves(self):
@@ -214,13 +222,15 @@ class SyncRepos(object):
portage.util.shlex_split(
self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+ msgs = []
if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
- print()
- print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
- print(warn(" * ")+"that you update portage now, before any other packages are updated.")
- print()
- print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
- print()
+ msgs.append('')
+ msgs.append(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ msgs.append(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ msgs.append('')
+ msgs.append(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ msgs.append('')
+ return msgs
def _reload_config(self):
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-30 0:46 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-30 0:46 UTC (permalink / raw
To: gentoo-commits
commit: 82b99bbdb1dcc6327d80dc4b07f878ca14177080
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 21 18:30:00 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 30 00:42:25 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=82b99bbd
emaint/modules: New emaint module "sync"
This code is a migration from _emerge.actions.action_sync.
The code has been split up into logical blocks.
Some changes have been made to handle multiple repositories better.
It also adds more flexibility as to what is synced.
---
pym/portage/emaint/modules/sync/__init__.py | 44 ++++++
pym/portage/emaint/modules/sync/sync.py | 237 ++++++++++++++++++++++++++++
2 files changed, 281 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
new file mode 100644
index 0000000..4070200
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/__init__.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""Check repos.conf settings and sync repositories.
+"""
+
+
+module_spec = {
+ 'name': 'sync',
+ 'description': __doc__,
+ 'provides':{
+ 'sync-module': {
+ 'name': "sync",
+ 'class': "SyncRepos",
+ 'description': __doc__,
+ 'functions': ['allrepos', 'auto', 'repo'],
+ 'func_desc': {
+ 'repo': {
+ "short": "-r", "long": "--repo",
+ "help": "(sync module only): -r, --repo Sync the specified repo",
+ 'status': "Syncing %s",
+ 'action': 'store',
+ 'func': 'repo',
+ },
+ 'allrepos': {
+ "short": "-A", "long": "--allrepos",
+ "help": "(sync module only): -A, --allrepos Sync all repos that have a sync-url defined",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'allrepos',
+ 'func': 'all_repos',
+ },
+ 'auto': {
+ "short": "-a", "long": "--auto",
+ "help": "(sync module only): -a, --auto Sync auto-sync enabled repos only",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'auto',
+ 'func': 'auto_sync',
+ },
+ }
+ }
+ }
+ }
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
new file mode 100644
index 0000000..3aa318a
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -0,0 +1,237 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import logging
+import os
+import sys
+
+import portage
+from portage.localization import _
+from portage.output import bold, create_color_func
+from portage.sync import get_syncer
+from portage._global_updates import _global_updates
+from portage.util import writemsg_level
+
+import _emerge
+from _emerge.emergelog import emergelog
+
+
+portage.proxy.lazyimport.lazyimport(globals(),
+ '_emerge.actions:adjust_configs,load_emerge_config',
+ '_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
+ '_emerge.main:parse_opts',
+ '_emerge.post_emerge:display_news_notification',
+)
+
+warn = create_color_func("WARN")
+
+if sys.hexversion >= 0x3000000:
+ _basestring = str
+else:
+ _basestring = basestring
+
+
+class SyncRepos(object):
+
+ short_desc = "Check repos.conf settings and/or sync repositories"
+
+ @staticmethod
+ def name():
+ return "sync"
+
+
+ def can_progressbar(self, func):
+ return False
+
+
+ def __init__(self, emerge_config=None, emerge_logging=False):
+ '''Class init function
+
+ @param emerge_config: optional an emerge_config instance to use
+ @param emerge_logging: boolean, defaults to False
+ '''
+ if emerge_config:
+ self.emerge_config = emerge_config
+ else:
+ # need a basic options instance
+ actions, opts, _files = parse_opts([], silent=True)
+ self.emerge_config = load_emerge_config(
+ action='sync', args=_files, trees=[], opts=opts)
+ if emerge_logging:
+ _emerge.emergelog._disable = False
+ self.xterm_titles = "notitles" not in \
+ self.emerge_config.target_config.settings.features
+ emergelog(self.xterm_titles, " === sync")
+
+
+ def auto_sync(self, **kwargs):
+ '''Sync auto-sync enabled repos'''
+ options = kwargs.get('options', None)
+ selected = self._get_repos(True)
+ if options.get('return-messages', False):
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ def all_repos(self, **kwargs):
+ '''Sync all repos defined in repos.conf'''
+ selected = self._get_repos(auto_sync_only=False)
+ options = kwargs.get('options', None)
+ if options.get('return-messages', False):
+ return self.rmessage(
+ self._sync(selected),
+ 'sync')
+ return self._sync(selected)
+
+
+ def repo(self, **kwargs):
+ '''Sync the specified repo'''
+ options = kwargs.get('options', None)
+ if options:
+ repos = options.get('repo', '')
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ if isinstance(repos, _basestring):
+ repos = repos.split()
+ available = self._get_repos(auto_sync_only=False)
+ selected = self._match_repos(repos, available)
+ if return_messages:
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ @staticmethod
+ def _match_repos(repos, available):
+ '''Internal search, matches up the repo.name in repos
+
+ @param repos: list, of repo names to match
+ @param avalable: list of repo objects to search
+ @return: list of repo objects that match
+ '''
+ selected = []
+ for repo in available:
+ if repo.name in repos:
+ selected.append(repo)
+ return selected
+
+
+ def _get_repos(self, auto_sync_only=True):
+ selected_repos = []
+ unknown_repo_names = []
+ missing_sync_type = []
+ if self.emerge_config.args:
+ for repo_name in self.emerge_config.args:
+ print("_get_repos(): repo_name =", repo_name)
+ try:
+ repo = self.emerge_config.target_config.settings.repositories[repo_name]
+ except KeyError:
+ unknown_repo_names.append(repo_name)
+ else:
+ selected_repos.append(repo)
+ if repo.sync_type is None:
+ missing_sync_type.append(repo)
+
+ if unknown_repo_names:
+ writemsg_level("!!! %s\n" % _("Unknown repo(s): %s") %
+ " ".join(unknown_repo_names),
+ level=logging.ERROR, noiselevel=-1)
+
+ if missing_sync_type:
+ writemsg_level("!!! %s\n" %
+ _("Missing sync-type for repo(s): %s") %
+ " ".join(repo.name for repo in missing_sync_type),
+ level=logging.ERROR, noiselevel=-1)
+
+ if unknown_repo_names or missing_sync_type:
+ print("missing or unknown repos... returning")
+ return []
+
+ else:
+ selected_repos.extend(self.emerge_config.target_config.settings.repositories)
+ #print("_get_repos(), selected =", selected_repos)
+ if auto_sync_only:
+ return self._filter_auto(selected_repos)
+ return selected_repos
+
+
+ def _filter_auto(self, repos):
+ selected = []
+ for repo in repos:
+ if repo.auto_sync in ['yes', 'true']:
+ selected.append(repo)
+ return selected
+
+
+ def _sync(self, selected_repos):
+ if not selected_repos:
+ print("_sync(), nothing to sync... returning")
+ return [('None', os.EX_OK)]
+ # Portage needs to ensure a sane umask for the files it creates.
+ os.umask(0o22)
+ portage._sync_mode = True
+
+ sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
+ retvals = []
+ for repo in selected_repos:
+ print("syncing repo:", repo.name)
+ if repo.sync_type is not None:
+ returncode = sync_manager.sync(self.emerge_config, repo)
+ #if returncode != os.EX_OK:
+ retvals.append((repo.name, returncode))
+
+ # Reload the whole config.
+ portage._sync_mode = False
+ self._reload_config()
+ self._do_pkg_moves()
+ self._check_updates()
+ display_news_notification(self.emerge_config.target_config,
+ self.emerge_config.opts)
+ if retvals:
+ return retvals
+ return [('None', os.EX_OK)]
+
+
+ def _do_pkg_moves(self):
+ if self.emerge_config.opts.get('--package-moves') != 'n' and \
+ _global_updates(self.emerge_config.trees,
+ self.emerge_config.target_config.mtimedb["updates"],
+ quiet=("--quiet" in self.emerge_config.opts)):
+ self.emerge_config.target_config.mtimedb.commit()
+ # Reload the whole config.
+ self._reload_config()
+
+
+ def _check_updates(self):
+ mybestpv = self.emerge_config.target_config.trees['porttree'].dbapi.xmatch(
+ "bestmatch-visible", portage.const.PORTAGE_PACKAGE_ATOM)
+ mypvs = portage.best(
+ self.emerge_config.target_config.trees['vartree'].dbapi.match(
+ portage.const.PORTAGE_PACKAGE_ATOM))
+
+ chk_updated_cfg_files(self.emerge_config.target_config.root,
+ portage.util.shlex_split(
+ self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+
+ if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
+ print()
+ print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ print(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ print()
+ print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ print()
+
+
+ def _reload_config(self):
+ '''Reload the whole config from scratch.'''
+ load_emerge_config(emerge_config=self.emerge_config)
+ adjust_configs(self.emerge_config.opts, self.emerge_config.trees)
+
+
+ def rmessage(self, rvals, action):
+ '''Creates emaint style messages to return to the task handler'''
+ messages = []
+ for rval in rvals:
+ messages.append("Action: %s for repo: %s, returned code = %s"
+ % (action, rval[0], rval[1]))
+ return messages
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-30 0:46 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-30 0:46 UTC (permalink / raw
To: gentoo-commits
commit: e1d416d9adef218b3389545057aa2601aafd337e
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 30 00:42:26 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=e1d416d9
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-30 0:46 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-30 0:46 UTC (permalink / raw
To: gentoo-commits
commit: 4ef7f0486823afd6b78aa43434c2e35e59c15c53
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:28:16 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 30 00:42:27 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=4ef7f048
emaint sync: Migrate print statements to emaint style messages
Comment out some debug prints.
---
pym/portage/emaint/modules/sync/sync.py | 62 +++++++++++++++++++--------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index ab7591d..b657133 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -70,20 +70,22 @@ class SyncRepos(object):
'''Sync auto-sync enabled repos'''
options = kwargs.get('options', None)
selected = self._get_repos(True)
- if options.get('return-messages', False):
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def all_repos(self, **kwargs):
'''Sync all repos defined in repos.conf'''
selected = self._get_repos(auto_sync_only=False)
options = kwargs.get('options', None)
- if options.get('return-messages', False):
- return self.rmessage(
- self._sync(selected),
- 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def repo(self, **kwargs):
@@ -98,9 +100,7 @@ class SyncRepos(object):
repos = repos.split()
available = self._get_repos(auto_sync_only=False)
selected = self._match_repos(repos, available)
- if return_messages:
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ return self._sync(selected, return_messages)
@staticmethod
@@ -124,7 +124,7 @@ class SyncRepos(object):
missing_sync_type = []
if self.emerge_config.args:
for repo_name in self.emerge_config.args:
- print("_get_repos(): repo_name =", repo_name)
+ #print("_get_repos(): repo_name =", repo_name)
try:
repo = self.emerge_config.target_config.settings.repositories[repo_name]
except KeyError:
@@ -146,7 +146,8 @@ class SyncRepos(object):
level=logging.ERROR, noiselevel=-1)
if unknown_repo_names or missing_sync_type:
- print("missing or unknown repos... returning")
+ writemsg_level("Missing or unknown repos... returning",
+ level=logging.INFO, noiselevel=2)
return []
else:
@@ -165,17 +166,20 @@ class SyncRepos(object):
return selected
- def _sync(self, selected_repos):
+ def _sync(self, selected_repos, return_messages):
+ msgs = []
if not selected_repos:
- print("_sync(), nothing to sync... returning")
- return [('None', os.EX_OK)]
+ msgs.append("Emaint sync, nothing to sync... returning")
+ if return_messages:
+ return msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ return
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
for repo in selected_repos:
- print("syncing repo:", repo.name)
+ #print("syncing repo:", repo.name)
if repo.sync_type is not None:
returncode = sync_manager.sync(self.emerge_config, repo)
#if returncode != os.EX_OK:
@@ -185,12 +189,16 @@ class SyncRepos(object):
portage._sync_mode = False
self._reload_config()
self._do_pkg_moves()
- self._check_updates()
+ msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
if retvals:
- return retvals
- return [('None', os.EX_OK)]
+ msgs.extend(self.rmessage(retvals, 'sync'))
+ else:
+ msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if return_messages:
+ return msgs
+ return
def _do_pkg_moves(self):
@@ -214,13 +222,15 @@ class SyncRepos(object):
portage.util.shlex_split(
self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+ msgs = []
if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
- print()
- print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
- print(warn(" * ")+"that you update portage now, before any other packages are updated.")
- print()
- print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
- print()
+ msgs.append('')
+ msgs.append(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ msgs.append(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ msgs.append('')
+ msgs.append(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ msgs.append('')
+ return msgs
def _reload_config(self):
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-09-30 0:46 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-09-30 0:46 UTC (permalink / raw
To: gentoo-commits
commit: 3ba858e6079858f2cc762ab1a65304291aeb4b40
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:37:10 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Tue Sep 30 00:42:27 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=3ba858e6
emaint sync: Fix bug 522032, add a one time only post-sync hook call
After all repos have been synced, the emaint sync module runs another post-sync hook call
passing it the 'PORTAGE_SYNC_HOOK_FINAL' value as the url.
This value can be read by the post-sync hook to decide if it needs to run or pass.
This allows flexible, precise control over post-sync hooks for multiple repositories.
Caveat: Current app-portage/portage-utils post_sync hook script does not pass on the url
to the postsync.d/* scripts that it intiates.
---
pym/portage/emaint/modules/sync/sync.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index b657133..9b0d82c 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -192,10 +192,13 @@ class SyncRepos(object):
msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
+ rcode = sync_manager.perform_post_sync_hook('PORTAGE_SYNC_HOOK_FINAL')
if retvals:
msgs.extend(self.rmessage(retvals, 'sync'))
else:
msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if rcode:
+ msgs.append(self.rmessage('None', rcode), 'post-sync')
if return_messages:
return msgs
return
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-10-20 3:54 Zac Medico
0 siblings, 0 replies; 51+ messages in thread
From: Zac Medico @ 2014-10-20 3:54 UTC (permalink / raw
To: gentoo-commits
commit: 957160d020ce6a31912932495ff17382442509f4
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Mon Apr 21 18:30:00 2014 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct 20 03:48:33 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=957160d0
emaint/modules: New emaint module "sync"
This code is a migration from _emerge.actions.action_sync.
The code has been split up into logical blocks.
Some changes have been made to handle multiple repositories better.
It also adds more flexibility as to what is synced.
---
pym/portage/emaint/modules/sync/__init__.py | 44 ++++++
pym/portage/emaint/modules/sync/sync.py | 237 ++++++++++++++++++++++++++++
2 files changed, 281 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/__init__.py b/pym/portage/emaint/modules/sync/__init__.py
new file mode 100644
index 0000000..4070200
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/__init__.py
@@ -0,0 +1,44 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+"""Check repos.conf settings and sync repositories.
+"""
+
+
+module_spec = {
+ 'name': 'sync',
+ 'description': __doc__,
+ 'provides':{
+ 'sync-module': {
+ 'name': "sync",
+ 'class': "SyncRepos",
+ 'description': __doc__,
+ 'functions': ['allrepos', 'auto', 'repo'],
+ 'func_desc': {
+ 'repo': {
+ "short": "-r", "long": "--repo",
+ "help": "(sync module only): -r, --repo Sync the specified repo",
+ 'status': "Syncing %s",
+ 'action': 'store',
+ 'func': 'repo',
+ },
+ 'allrepos': {
+ "short": "-A", "long": "--allrepos",
+ "help": "(sync module only): -A, --allrepos Sync all repos that have a sync-url defined",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'allrepos',
+ 'func': 'all_repos',
+ },
+ 'auto': {
+ "short": "-a", "long": "--auto",
+ "help": "(sync module only): -a, --auto Sync auto-sync enabled repos only",
+ 'status': "Syncing %s",
+ 'action': 'store_true',
+ 'dest': 'auto',
+ 'func': 'auto_sync',
+ },
+ }
+ }
+ }
+ }
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
new file mode 100644
index 0000000..3aa318a
--- /dev/null
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -0,0 +1,237 @@
+# Copyright 2014 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+
+import logging
+import os
+import sys
+
+import portage
+from portage.localization import _
+from portage.output import bold, create_color_func
+from portage.sync import get_syncer
+from portage._global_updates import _global_updates
+from portage.util import writemsg_level
+
+import _emerge
+from _emerge.emergelog import emergelog
+
+
+portage.proxy.lazyimport.lazyimport(globals(),
+ '_emerge.actions:adjust_configs,load_emerge_config',
+ '_emerge.chk_updated_cfg_files:chk_updated_cfg_files',
+ '_emerge.main:parse_opts',
+ '_emerge.post_emerge:display_news_notification',
+)
+
+warn = create_color_func("WARN")
+
+if sys.hexversion >= 0x3000000:
+ _basestring = str
+else:
+ _basestring = basestring
+
+
+class SyncRepos(object):
+
+ short_desc = "Check repos.conf settings and/or sync repositories"
+
+ @staticmethod
+ def name():
+ return "sync"
+
+
+ def can_progressbar(self, func):
+ return False
+
+
+ def __init__(self, emerge_config=None, emerge_logging=False):
+ '''Class init function
+
+ @param emerge_config: optional an emerge_config instance to use
+ @param emerge_logging: boolean, defaults to False
+ '''
+ if emerge_config:
+ self.emerge_config = emerge_config
+ else:
+ # need a basic options instance
+ actions, opts, _files = parse_opts([], silent=True)
+ self.emerge_config = load_emerge_config(
+ action='sync', args=_files, trees=[], opts=opts)
+ if emerge_logging:
+ _emerge.emergelog._disable = False
+ self.xterm_titles = "notitles" not in \
+ self.emerge_config.target_config.settings.features
+ emergelog(self.xterm_titles, " === sync")
+
+
+ def auto_sync(self, **kwargs):
+ '''Sync auto-sync enabled repos'''
+ options = kwargs.get('options', None)
+ selected = self._get_repos(True)
+ if options.get('return-messages', False):
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ def all_repos(self, **kwargs):
+ '''Sync all repos defined in repos.conf'''
+ selected = self._get_repos(auto_sync_only=False)
+ options = kwargs.get('options', None)
+ if options.get('return-messages', False):
+ return self.rmessage(
+ self._sync(selected),
+ 'sync')
+ return self._sync(selected)
+
+
+ def repo(self, **kwargs):
+ '''Sync the specified repo'''
+ options = kwargs.get('options', None)
+ if options:
+ repos = options.get('repo', '')
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ if isinstance(repos, _basestring):
+ repos = repos.split()
+ available = self._get_repos(auto_sync_only=False)
+ selected = self._match_repos(repos, available)
+ if return_messages:
+ return self.rmessage(self._sync(selected), 'sync')
+ return self._sync(selected)
+
+
+ @staticmethod
+ def _match_repos(repos, available):
+ '''Internal search, matches up the repo.name in repos
+
+ @param repos: list, of repo names to match
+ @param avalable: list of repo objects to search
+ @return: list of repo objects that match
+ '''
+ selected = []
+ for repo in available:
+ if repo.name in repos:
+ selected.append(repo)
+ return selected
+
+
+ def _get_repos(self, auto_sync_only=True):
+ selected_repos = []
+ unknown_repo_names = []
+ missing_sync_type = []
+ if self.emerge_config.args:
+ for repo_name in self.emerge_config.args:
+ print("_get_repos(): repo_name =", repo_name)
+ try:
+ repo = self.emerge_config.target_config.settings.repositories[repo_name]
+ except KeyError:
+ unknown_repo_names.append(repo_name)
+ else:
+ selected_repos.append(repo)
+ if repo.sync_type is None:
+ missing_sync_type.append(repo)
+
+ if unknown_repo_names:
+ writemsg_level("!!! %s\n" % _("Unknown repo(s): %s") %
+ " ".join(unknown_repo_names),
+ level=logging.ERROR, noiselevel=-1)
+
+ if missing_sync_type:
+ writemsg_level("!!! %s\n" %
+ _("Missing sync-type for repo(s): %s") %
+ " ".join(repo.name for repo in missing_sync_type),
+ level=logging.ERROR, noiselevel=-1)
+
+ if unknown_repo_names or missing_sync_type:
+ print("missing or unknown repos... returning")
+ return []
+
+ else:
+ selected_repos.extend(self.emerge_config.target_config.settings.repositories)
+ #print("_get_repos(), selected =", selected_repos)
+ if auto_sync_only:
+ return self._filter_auto(selected_repos)
+ return selected_repos
+
+
+ def _filter_auto(self, repos):
+ selected = []
+ for repo in repos:
+ if repo.auto_sync in ['yes', 'true']:
+ selected.append(repo)
+ return selected
+
+
+ def _sync(self, selected_repos):
+ if not selected_repos:
+ print("_sync(), nothing to sync... returning")
+ return [('None', os.EX_OK)]
+ # Portage needs to ensure a sane umask for the files it creates.
+ os.umask(0o22)
+ portage._sync_mode = True
+
+ sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
+ retvals = []
+ for repo in selected_repos:
+ print("syncing repo:", repo.name)
+ if repo.sync_type is not None:
+ returncode = sync_manager.sync(self.emerge_config, repo)
+ #if returncode != os.EX_OK:
+ retvals.append((repo.name, returncode))
+
+ # Reload the whole config.
+ portage._sync_mode = False
+ self._reload_config()
+ self._do_pkg_moves()
+ self._check_updates()
+ display_news_notification(self.emerge_config.target_config,
+ self.emerge_config.opts)
+ if retvals:
+ return retvals
+ return [('None', os.EX_OK)]
+
+
+ def _do_pkg_moves(self):
+ if self.emerge_config.opts.get('--package-moves') != 'n' and \
+ _global_updates(self.emerge_config.trees,
+ self.emerge_config.target_config.mtimedb["updates"],
+ quiet=("--quiet" in self.emerge_config.opts)):
+ self.emerge_config.target_config.mtimedb.commit()
+ # Reload the whole config.
+ self._reload_config()
+
+
+ def _check_updates(self):
+ mybestpv = self.emerge_config.target_config.trees['porttree'].dbapi.xmatch(
+ "bestmatch-visible", portage.const.PORTAGE_PACKAGE_ATOM)
+ mypvs = portage.best(
+ self.emerge_config.target_config.trees['vartree'].dbapi.match(
+ portage.const.PORTAGE_PACKAGE_ATOM))
+
+ chk_updated_cfg_files(self.emerge_config.target_config.root,
+ portage.util.shlex_split(
+ self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+
+ if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
+ print()
+ print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ print(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ print()
+ print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ print()
+
+
+ def _reload_config(self):
+ '''Reload the whole config from scratch.'''
+ load_emerge_config(emerge_config=self.emerge_config)
+ adjust_configs(self.emerge_config.opts, self.emerge_config.trees)
+
+
+ def rmessage(self, rvals, action):
+ '''Creates emaint style messages to return to the task handler'''
+ messages = []
+ for rval in rvals:
+ messages.append("Action: %s for repo: %s, returned code = %s"
+ % (action, rval[0], rval[1]))
+ return messages
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-10-20 3:54 Zac Medico
0 siblings, 0 replies; 51+ messages in thread
From: Zac Medico @ 2014-10-20 3:54 UTC (permalink / raw
To: gentoo-commits
commit: 472ff464965372155d07540d96935c5f5efc67af
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:28:16 2014 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct 20 03:48:35 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=472ff464
emaint sync: Migrate print statements to emaint style messages
Comment out some debug prints.
---
pym/portage/emaint/modules/sync/sync.py | 62 +++++++++++++++++++--------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index ab7591d..b657133 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -70,20 +70,22 @@ class SyncRepos(object):
'''Sync auto-sync enabled repos'''
options = kwargs.get('options', None)
selected = self._get_repos(True)
- if options.get('return-messages', False):
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def all_repos(self, **kwargs):
'''Sync all repos defined in repos.conf'''
selected = self._get_repos(auto_sync_only=False)
options = kwargs.get('options', None)
- if options.get('return-messages', False):
- return self.rmessage(
- self._sync(selected),
- 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def repo(self, **kwargs):
@@ -98,9 +100,7 @@ class SyncRepos(object):
repos = repos.split()
available = self._get_repos(auto_sync_only=False)
selected = self._match_repos(repos, available)
- if return_messages:
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ return self._sync(selected, return_messages)
@staticmethod
@@ -124,7 +124,7 @@ class SyncRepos(object):
missing_sync_type = []
if self.emerge_config.args:
for repo_name in self.emerge_config.args:
- print("_get_repos(): repo_name =", repo_name)
+ #print("_get_repos(): repo_name =", repo_name)
try:
repo = self.emerge_config.target_config.settings.repositories[repo_name]
except KeyError:
@@ -146,7 +146,8 @@ class SyncRepos(object):
level=logging.ERROR, noiselevel=-1)
if unknown_repo_names or missing_sync_type:
- print("missing or unknown repos... returning")
+ writemsg_level("Missing or unknown repos... returning",
+ level=logging.INFO, noiselevel=2)
return []
else:
@@ -165,17 +166,20 @@ class SyncRepos(object):
return selected
- def _sync(self, selected_repos):
+ def _sync(self, selected_repos, return_messages):
+ msgs = []
if not selected_repos:
- print("_sync(), nothing to sync... returning")
- return [('None', os.EX_OK)]
+ msgs.append("Emaint sync, nothing to sync... returning")
+ if return_messages:
+ return msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ return
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
for repo in selected_repos:
- print("syncing repo:", repo.name)
+ #print("syncing repo:", repo.name)
if repo.sync_type is not None:
returncode = sync_manager.sync(self.emerge_config, repo)
#if returncode != os.EX_OK:
@@ -185,12 +189,16 @@ class SyncRepos(object):
portage._sync_mode = False
self._reload_config()
self._do_pkg_moves()
- self._check_updates()
+ msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
if retvals:
- return retvals
- return [('None', os.EX_OK)]
+ msgs.extend(self.rmessage(retvals, 'sync'))
+ else:
+ msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if return_messages:
+ return msgs
+ return
def _do_pkg_moves(self):
@@ -214,13 +222,15 @@ class SyncRepos(object):
portage.util.shlex_split(
self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+ msgs = []
if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
- print()
- print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
- print(warn(" * ")+"that you update portage now, before any other packages are updated.")
- print()
- print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
- print()
+ msgs.append('')
+ msgs.append(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ msgs.append(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ msgs.append('')
+ msgs.append(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ msgs.append('')
+ return msgs
def _reload_config(self):
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-10-20 3:54 Zac Medico
0 siblings, 0 replies; 51+ messages in thread
From: Zac Medico @ 2014-10-20 3:54 UTC (permalink / raw
To: gentoo-commits
commit: 5f8d42361964d3e9654a33941f6056f2c75a69ec
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct 20 03:48:34 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=5f8d4236
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-10-20 3:54 Zac Medico
0 siblings, 0 replies; 51+ messages in thread
From: Zac Medico @ 2014-10-20 3:54 UTC (permalink / raw
To: gentoo-commits
commit: 053661b1c649433b5ef047b4e64a098db3c728e6
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:37:10 2014 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Oct 20 03:48:35 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=053661b1
emaint sync: Fix bug 522032, add a one time only post-sync hook call
After all repos have been synced, the emaint sync module runs another post-sync hook call
passing it the 'PORTAGE_SYNC_HOOK_FINAL' value as the url.
This value can be read by the post-sync hook to decide if it needs to run or pass.
This allows flexible, precise control over post-sync hooks for multiple repositories.
Caveat: Current app-portage/portage-utils post_sync hook script does not pass on the url
to the postsync.d/* scripts that it intiates.
---
pym/portage/emaint/modules/sync/sync.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index b657133..9b0d82c 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -192,10 +192,13 @@ class SyncRepos(object):
msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
+ rcode = sync_manager.perform_post_sync_hook('PORTAGE_SYNC_HOOK_FINAL')
if retvals:
msgs.extend(self.rmessage(retvals, 'sync'))
else:
msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if rcode:
+ msgs.append(self.rmessage('None', rcode), 'post-sync')
if return_messages:
return msgs
return
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-10-21 5:05 Zac Medico
0 siblings, 0 replies; 51+ messages in thread
From: Zac Medico @ 2014-10-21 5:05 UTC (permalink / raw
To: gentoo-commits
commit: b1626483475677df9be407203c1f411c8bd09c92
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Oct 21 05:04:07 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=b1626483
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-10-21 5:05 Zac Medico
0 siblings, 0 replies; 51+ messages in thread
From: Zac Medico @ 2014-10-21 5:05 UTC (permalink / raw
To: gentoo-commits
commit: fd6d2fd3c5bf8ea97b1a206c7892930e1e1272dd
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:28:16 2014 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Oct 21 05:04:07 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=fd6d2fd3
emaint sync: Migrate print statements to emaint style messages
Comment out some debug prints.
---
pym/portage/emaint/modules/sync/sync.py | 62 +++++++++++++++++++--------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index ab7591d..b657133 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -70,20 +70,22 @@ class SyncRepos(object):
'''Sync auto-sync enabled repos'''
options = kwargs.get('options', None)
selected = self._get_repos(True)
- if options.get('return-messages', False):
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def all_repos(self, **kwargs):
'''Sync all repos defined in repos.conf'''
selected = self._get_repos(auto_sync_only=False)
options = kwargs.get('options', None)
- if options.get('return-messages', False):
- return self.rmessage(
- self._sync(selected),
- 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def repo(self, **kwargs):
@@ -98,9 +100,7 @@ class SyncRepos(object):
repos = repos.split()
available = self._get_repos(auto_sync_only=False)
selected = self._match_repos(repos, available)
- if return_messages:
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ return self._sync(selected, return_messages)
@staticmethod
@@ -124,7 +124,7 @@ class SyncRepos(object):
missing_sync_type = []
if self.emerge_config.args:
for repo_name in self.emerge_config.args:
- print("_get_repos(): repo_name =", repo_name)
+ #print("_get_repos(): repo_name =", repo_name)
try:
repo = self.emerge_config.target_config.settings.repositories[repo_name]
except KeyError:
@@ -146,7 +146,8 @@ class SyncRepos(object):
level=logging.ERROR, noiselevel=-1)
if unknown_repo_names or missing_sync_type:
- print("missing or unknown repos... returning")
+ writemsg_level("Missing or unknown repos... returning",
+ level=logging.INFO, noiselevel=2)
return []
else:
@@ -165,17 +166,20 @@ class SyncRepos(object):
return selected
- def _sync(self, selected_repos):
+ def _sync(self, selected_repos, return_messages):
+ msgs = []
if not selected_repos:
- print("_sync(), nothing to sync... returning")
- return [('None', os.EX_OK)]
+ msgs.append("Emaint sync, nothing to sync... returning")
+ if return_messages:
+ return msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ return
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
for repo in selected_repos:
- print("syncing repo:", repo.name)
+ #print("syncing repo:", repo.name)
if repo.sync_type is not None:
returncode = sync_manager.sync(self.emerge_config, repo)
#if returncode != os.EX_OK:
@@ -185,12 +189,16 @@ class SyncRepos(object):
portage._sync_mode = False
self._reload_config()
self._do_pkg_moves()
- self._check_updates()
+ msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
if retvals:
- return retvals
- return [('None', os.EX_OK)]
+ msgs.extend(self.rmessage(retvals, 'sync'))
+ else:
+ msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if return_messages:
+ return msgs
+ return
def _do_pkg_moves(self):
@@ -214,13 +222,15 @@ class SyncRepos(object):
portage.util.shlex_split(
self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+ msgs = []
if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
- print()
- print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
- print(warn(" * ")+"that you update portage now, before any other packages are updated.")
- print()
- print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
- print()
+ msgs.append('')
+ msgs.append(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ msgs.append(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ msgs.append('')
+ msgs.append(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ msgs.append('')
+ return msgs
def _reload_config(self):
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-10-21 5:05 Zac Medico
0 siblings, 0 replies; 51+ messages in thread
From: Zac Medico @ 2014-10-21 5:05 UTC (permalink / raw
To: gentoo-commits
commit: 15c1fc96c87d7e74084dac796ab44e268662a0ca
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:37:10 2014 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Oct 21 05:04:07 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=15c1fc96
emaint sync: Fix bug 522032, add a one time only post-sync hook call
After all repos have been synced, the emaint sync module runs another post-sync hook call
passing it the 'PORTAGE_SYNC_HOOK_FINAL' value as the url.
This value can be read by the post-sync hook to decide if it needs to run or pass.
This allows flexible, precise control over post-sync hooks for multiple repositories.
Caveat: Current app-portage/portage-utils post_sync hook script does not pass on the url
to the postsync.d/* scripts that it intiates.
---
pym/portage/emaint/modules/sync/sync.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index b657133..9b0d82c 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -192,10 +192,13 @@ class SyncRepos(object):
msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
+ rcode = sync_manager.perform_post_sync_hook('PORTAGE_SYNC_HOOK_FINAL')
if retvals:
msgs.extend(self.rmessage(retvals, 'sync'))
else:
msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if rcode:
+ msgs.append(self.rmessage('None', rcode), 'post-sync')
if return_messages:
return msgs
return
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-10-21 20:55 Zac Medico
0 siblings, 0 replies; 51+ messages in thread
From: Zac Medico @ 2014-10-21 20:55 UTC (permalink / raw
To: gentoo-commits
commit: 0d63acaf3b42daa4c68e242f2490e923a96ee21f
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 21 20:55:20 2014 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Tue Oct 21 20:55:20 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=0d63acaf
SyncRepos: fix rmessage usage
---
pym/portage/emaint/modules/sync/sync.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 1316eaa..1bec1b1 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -206,9 +206,9 @@ class SyncRepos(object):
if retvals:
msgs.extend(self.rmessage(retvals, 'sync'))
else:
- msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ msgs.extend(self.rmessage([('None', os.EX_OK)], 'sync'))
if rcode:
- msgs.append(self.rmessage('None', rcode), 'post-sync')
+ msgs.extend(self.rmessage([('None', rcode)], 'post-sync'))
if return_messages:
return msgs
return
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-10-22 12:30 Zac Medico
0 siblings, 0 replies; 51+ messages in thread
From: Zac Medico @ 2014-10-22 12:30 UTC (permalink / raw
To: gentoo-commits
commit: 6c33f2b46105b1b41c00991e199545cc00657f9f
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 22 12:30:19 2014 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Oct 22 12:30:19 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=6c33f2b4
SyncRepos: parse EMERGE_DEFAULT_OPTS
We need to parse EMERGE_DEFAULT_OPTS, for settings like
--package-moves=n.
---
pym/portage/emaint/modules/sync/sync.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 1bec1b1..390a168 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -58,6 +58,13 @@ class SyncRepos(object):
emerge_config = load_emerge_config(
action='sync', args=_files, opts=opts)
+ # Parse EMERGE_DEFAULT_OPTS, for settings like
+ # --package-moves=n.
+ cmdline = portage.util.shlex_split(
+ emerge_config.target_config.settings.get(
+ "EMERGE_DEFAULT_OPTS", ""))
+ emerge_config.opts = parse_opts(cmdline, silent=True)[1]
+
if hasattr(portage, 'settings'):
# cleanly destroy global objects
portage._reset_legacy_globals()
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-10-22 13:36 Zac Medico
0 siblings, 0 replies; 51+ messages in thread
From: Zac Medico @ 2014-10-22 13:36 UTC (permalink / raw
To: gentoo-commits
commit: 51a3ce033cc7c5d36bbfbff2379c631077976bed
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 22 12:30:19 2014 +0000
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Wed Oct 22 13:33:16 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=51a3ce03
SyncRepos: parse EMERGE_DEFAULT_OPTS
We need to parse EMERGE_DEFAULT_OPTS, for settings like
--package-moves=n.
---
pym/portage/emaint/modules/sync/sync.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 1bec1b1..390a168 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -58,6 +58,13 @@ class SyncRepos(object):
emerge_config = load_emerge_config(
action='sync', args=_files, opts=opts)
+ # Parse EMERGE_DEFAULT_OPTS, for settings like
+ # --package-moves=n.
+ cmdline = portage.util.shlex_split(
+ emerge_config.target_config.settings.get(
+ "EMERGE_DEFAULT_OPTS", ""))
+ emerge_config.opts = parse_opts(cmdline, silent=True)[1]
+
if hasattr(portage, 'settings'):
# cleanly destroy global objects
portage._reset_legacy_globals()
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-12-01 21:50 Michał Górny
0 siblings, 0 replies; 51+ messages in thread
From: Michał Górny @ 2014-12-01 21:50 UTC (permalink / raw
To: gentoo-commits
commit: d59c479206cf5cd866cc21f40d76ff9157c73e6c
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Sun May 11 16:46:09 2014 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Dec 1 21:49:40 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d59c4792
emaint/modules/sync/sync.py: Set portage _sync_mode immediately
This way it will not discard non-existent repos if thier directory does not exist.
---
pym/portage/emaint/modules/sync/sync.py | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 3aa318a..ab7591d 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -6,6 +6,8 @@ import os
import sys
import portage
+portage._internal_caller = True
+portage._sync_mode = True
from portage.localization import _
from portage.output import bold, create_color_func
from portage.sync import get_syncer
@@ -169,7 +171,6 @@ class SyncRepos(object):
return [('None', os.EX_OK)]
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
- portage._sync_mode = True
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-12-01 21:50 Michał Górny
0 siblings, 0 replies; 51+ messages in thread
From: Michał Górny @ 2014-12-01 21:50 UTC (permalink / raw
To: gentoo-commits
commit: 690b4314ceaafb8bce748b5be9704f3d6abcee61
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:37:10 2014 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Dec 1 21:49:41 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=690b4314
emaint sync: Fix bug 522032, add a one time only post-sync hook call
After all repos have been synced, the emaint sync module runs another post-sync hook call
passing it the 'PORTAGE_SYNC_HOOK_FINAL' value as the url.
This value can be read by the post-sync hook to decide if it needs to run or pass.
This allows flexible, precise control over post-sync hooks for multiple repositories.
Caveat: Current app-portage/portage-utils post_sync hook script does not pass on the url
to the postsync.d/* scripts that it intiates.
---
pym/portage/emaint/modules/sync/sync.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index b657133..9b0d82c 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -192,10 +192,13 @@ class SyncRepos(object):
msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
+ rcode = sync_manager.perform_post_sync_hook('PORTAGE_SYNC_HOOK_FINAL')
if retvals:
msgs.extend(self.rmessage(retvals, 'sync'))
else:
msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if rcode:
+ msgs.append(self.rmessage('None', rcode), 'post-sync')
if return_messages:
return msgs
return
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-12-01 21:50 Michał Górny
0 siblings, 0 replies; 51+ messages in thread
From: Michał Górny @ 2014-12-01 21:50 UTC (permalink / raw
To: gentoo-commits
commit: 2ce2ae959e5de6c31a60b4b87be27e8a913179e8
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 21 20:55:20 2014 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Dec 1 21:49:42 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=2ce2ae95
SyncRepos: fix rmessage usage
---
pym/portage/emaint/modules/sync/sync.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 1316eaa..1bec1b1 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -206,9 +206,9 @@ class SyncRepos(object):
if retvals:
msgs.extend(self.rmessage(retvals, 'sync'))
else:
- msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ msgs.extend(self.rmessage([('None', os.EX_OK)], 'sync'))
if rcode:
- msgs.append(self.rmessage('None', rcode), 'post-sync')
+ msgs.extend(self.rmessage([('None', rcode)], 'post-sync'))
if return_messages:
return msgs
return
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-12-01 21:50 Michał Górny
0 siblings, 0 replies; 51+ messages in thread
From: Michał Górny @ 2014-12-01 21:50 UTC (permalink / raw
To: gentoo-commits
commit: 7fbe03d5cb50601a92cf83e5f67ef542fc64a4ed
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:28:16 2014 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Dec 1 21:49:41 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=7fbe03d5
emaint sync: Migrate print statements to emaint style messages
Comment out some debug prints.
---
pym/portage/emaint/modules/sync/sync.py | 62 +++++++++++++++++++--------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index ab7591d..b657133 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -70,20 +70,22 @@ class SyncRepos(object):
'''Sync auto-sync enabled repos'''
options = kwargs.get('options', None)
selected = self._get_repos(True)
- if options.get('return-messages', False):
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def all_repos(self, **kwargs):
'''Sync all repos defined in repos.conf'''
selected = self._get_repos(auto_sync_only=False)
options = kwargs.get('options', None)
- if options.get('return-messages', False):
- return self.rmessage(
- self._sync(selected),
- 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def repo(self, **kwargs):
@@ -98,9 +100,7 @@ class SyncRepos(object):
repos = repos.split()
available = self._get_repos(auto_sync_only=False)
selected = self._match_repos(repos, available)
- if return_messages:
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ return self._sync(selected, return_messages)
@staticmethod
@@ -124,7 +124,7 @@ class SyncRepos(object):
missing_sync_type = []
if self.emerge_config.args:
for repo_name in self.emerge_config.args:
- print("_get_repos(): repo_name =", repo_name)
+ #print("_get_repos(): repo_name =", repo_name)
try:
repo = self.emerge_config.target_config.settings.repositories[repo_name]
except KeyError:
@@ -146,7 +146,8 @@ class SyncRepos(object):
level=logging.ERROR, noiselevel=-1)
if unknown_repo_names or missing_sync_type:
- print("missing or unknown repos... returning")
+ writemsg_level("Missing or unknown repos... returning",
+ level=logging.INFO, noiselevel=2)
return []
else:
@@ -165,17 +166,20 @@ class SyncRepos(object):
return selected
- def _sync(self, selected_repos):
+ def _sync(self, selected_repos, return_messages):
+ msgs = []
if not selected_repos:
- print("_sync(), nothing to sync... returning")
- return [('None', os.EX_OK)]
+ msgs.append("Emaint sync, nothing to sync... returning")
+ if return_messages:
+ return msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ return
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
for repo in selected_repos:
- print("syncing repo:", repo.name)
+ #print("syncing repo:", repo.name)
if repo.sync_type is not None:
returncode = sync_manager.sync(self.emerge_config, repo)
#if returncode != os.EX_OK:
@@ -185,12 +189,16 @@ class SyncRepos(object):
portage._sync_mode = False
self._reload_config()
self._do_pkg_moves()
- self._check_updates()
+ msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
if retvals:
- return retvals
- return [('None', os.EX_OK)]
+ msgs.extend(self.rmessage(retvals, 'sync'))
+ else:
+ msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if return_messages:
+ return msgs
+ return
def _do_pkg_moves(self):
@@ -214,13 +222,15 @@ class SyncRepos(object):
portage.util.shlex_split(
self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+ msgs = []
if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
- print()
- print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
- print(warn(" * ")+"that you update portage now, before any other packages are updated.")
- print()
- print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
- print()
+ msgs.append('')
+ msgs.append(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ msgs.append(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ msgs.append('')
+ msgs.append(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ msgs.append('')
+ return msgs
def _reload_config(self):
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-12-01 21:50 Michał Górny
0 siblings, 0 replies; 51+ messages in thread
From: Michał Górny @ 2014-12-01 21:50 UTC (permalink / raw
To: gentoo-commits
commit: 728087c4a9110d432f05fb685aa639529d8af69a
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 22 12:30:19 2014 +0000
Commit: Michał Górny <mgorny <AT> gentoo <DOT> org>
CommitDate: Mon Dec 1 21:49:42 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=728087c4
SyncRepos: parse EMERGE_DEFAULT_OPTS
We need to parse EMERGE_DEFAULT_OPTS, for settings like
--package-moves=n.
---
pym/portage/emaint/modules/sync/sync.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 1bec1b1..390a168 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -58,6 +58,13 @@ class SyncRepos(object):
emerge_config = load_emerge_config(
action='sync', args=_files, opts=opts)
+ # Parse EMERGE_DEFAULT_OPTS, for settings like
+ # --package-moves=n.
+ cmdline = portage.util.shlex_split(
+ emerge_config.target_config.settings.get(
+ "EMERGE_DEFAULT_OPTS", ""))
+ emerge_config.opts = parse_opts(cmdline, silent=True)[1]
+
if hasattr(portage, 'settings'):
# cleanly destroy global objects
portage._reset_legacy_globals()
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
2014-12-04 20:16 [gentoo-commits] proj/portage:master " Brian Dolbec
@ 2014-12-04 20:04 ` Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-12-04 20:04 UTC (permalink / raw
To: gentoo-commits
commit: f9ae6e5a3de3dfdf536b5928c4ad5cfef376f1cc
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:37:10 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 4 19:56:34 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=f9ae6e5a
emaint sync: Fix bug 522032, add a one time only post-sync hook call
After all repos have been synced, the emaint sync module runs another post-sync hook call
passing it the '' value as the repo name.
This value can be read by the post-sync hook to decide if it needs to run or pass.
This allows flexible, precise control over post-sync hooks for multiple repositories.
Caveat: Current app-portage/portage-utils post_sync hook script does not pass on any parameters
to the postsync.d/* scripts that it intiates.
---
pym/portage/emaint/modules/sync/sync.py | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index b657133..86d16a3 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -192,10 +192,15 @@ class SyncRepos(object):
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.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if rcode:
+ msgs.append(self.rmessage('None', rcode), 'post-sync')
if return_messages:
return msgs
return
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
2014-12-04 20:16 [gentoo-commits] proj/portage:master " Brian Dolbec
@ 2014-12-04 20:04 ` Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-12-04 20:04 UTC (permalink / raw
To: gentoo-commits
commit: 19f5d813acf9e5c591107c383dadf3399d3dfa0a
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Fri Sep 5 04:28:16 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 4 19:56:34 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=19f5d813
emaint sync: Migrate print statements to emaint style messages
Comment out some debug prints.
---
pym/portage/emaint/modules/sync/sync.py | 62 +++++++++++++++++++--------------
1 file changed, 36 insertions(+), 26 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index ab7591d..b657133 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -70,20 +70,22 @@ class SyncRepos(object):
'''Sync auto-sync enabled repos'''
options = kwargs.get('options', None)
selected = self._get_repos(True)
- if options.get('return-messages', False):
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def all_repos(self, **kwargs):
'''Sync all repos defined in repos.conf'''
selected = self._get_repos(auto_sync_only=False)
options = kwargs.get('options', None)
- if options.get('return-messages', False):
- return self.rmessage(
- self._sync(selected),
- 'sync')
- return self._sync(selected)
+ if options:
+ return_messages = options.get('return-messages', False)
+ else:
+ return_messages = False
+ return self._sync(selected, return_messages)
def repo(self, **kwargs):
@@ -98,9 +100,7 @@ class SyncRepos(object):
repos = repos.split()
available = self._get_repos(auto_sync_only=False)
selected = self._match_repos(repos, available)
- if return_messages:
- return self.rmessage(self._sync(selected), 'sync')
- return self._sync(selected)
+ return self._sync(selected, return_messages)
@staticmethod
@@ -124,7 +124,7 @@ class SyncRepos(object):
missing_sync_type = []
if self.emerge_config.args:
for repo_name in self.emerge_config.args:
- print("_get_repos(): repo_name =", repo_name)
+ #print("_get_repos(): repo_name =", repo_name)
try:
repo = self.emerge_config.target_config.settings.repositories[repo_name]
except KeyError:
@@ -146,7 +146,8 @@ class SyncRepos(object):
level=logging.ERROR, noiselevel=-1)
if unknown_repo_names or missing_sync_type:
- print("missing or unknown repos... returning")
+ writemsg_level("Missing or unknown repos... returning",
+ level=logging.INFO, noiselevel=2)
return []
else:
@@ -165,17 +166,20 @@ class SyncRepos(object):
return selected
- def _sync(self, selected_repos):
+ def _sync(self, selected_repos, return_messages):
+ msgs = []
if not selected_repos:
- print("_sync(), nothing to sync... returning")
- return [('None', os.EX_OK)]
+ msgs.append("Emaint sync, nothing to sync... returning")
+ if return_messages:
+ return msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ return
# Portage needs to ensure a sane umask for the files it creates.
os.umask(0o22)
sync_manager = get_syncer(self.emerge_config.target_config.settings, emergelog)
retvals = []
for repo in selected_repos:
- print("syncing repo:", repo.name)
+ #print("syncing repo:", repo.name)
if repo.sync_type is not None:
returncode = sync_manager.sync(self.emerge_config, repo)
#if returncode != os.EX_OK:
@@ -185,12 +189,16 @@ class SyncRepos(object):
portage._sync_mode = False
self._reload_config()
self._do_pkg_moves()
- self._check_updates()
+ msgs.extend(self._check_updates())
display_news_notification(self.emerge_config.target_config,
self.emerge_config.opts)
if retvals:
- return retvals
- return [('None', os.EX_OK)]
+ msgs.extend(self.rmessage(retvals, 'sync'))
+ else:
+ msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ if return_messages:
+ return msgs
+ return
def _do_pkg_moves(self):
@@ -214,13 +222,15 @@ class SyncRepos(object):
portage.util.shlex_split(
self.emerge_config.target_config.settings.get("CONFIG_PROTECT", "")))
+ msgs = []
if mybestpv != mypvs and "--quiet" not in self.emerge_config.opts:
- print()
- print(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
- print(warn(" * ")+"that you update portage now, before any other packages are updated.")
- print()
- print(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
- print()
+ msgs.append('')
+ msgs.append(warn(" * ")+bold("An update to portage is available.")+" It is _highly_ recommended")
+ msgs.append(warn(" * ")+"that you update portage now, before any other packages are updated.")
+ msgs.append('')
+ msgs.append(warn(" * ")+"To update portage, run 'emerge --oneshot portage' now.")
+ msgs.append('')
+ return msgs
def _reload_config(self):
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
2014-12-04 20:16 [gentoo-commits] proj/portage:master " Brian Dolbec
@ 2014-12-04 20:04 ` Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-12-04 20:04 UTC (permalink / raw
To: gentoo-commits
commit: d86cafaf0cb68f8745306f22f423b7db20b18715
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Tue Oct 21 20:55:20 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 4 19:56:35 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d86cafaf
SyncRepos: fix rmessage usage
---
pym/portage/emaint/modules/sync/sync.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index e9f5e0b..845e8c7 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -208,9 +208,9 @@ class SyncRepos(object):
if retvals:
msgs.extend(self.rmessage(retvals, 'sync'))
else:
- msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ msgs.extend(self.rmessage([('None', os.EX_OK)], 'sync'))
if rcode:
- msgs.append(self.rmessage('None', rcode), 'post-sync')
+ msgs.extend(self.rmessage([('None', rcode)], 'post-sync'))
if return_messages:
return msgs
return
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-12-04 20:04 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-12-04 20:04 UTC (permalink / raw
To: gentoo-commits
commit: d3b91ee6493a9a5ac63e47e119ed7b73a2119e94
Author: Brian Dolbec <dolsen <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 4 18:20:13 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 4 19:58:27 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=d3b91ee6
emaint/modules/sync/sync.py: Fix a bug in the output if a specified repo did not exist
---
pym/portage/emaint/modules/sync/sync.py | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 1dade6f..77c685c 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -9,7 +9,7 @@ import portage
portage._internal_caller = True
portage._sync_mode = True
from portage.localization import _
-from portage.output import bold, create_color_func
+from portage.output import bold, red, create_color_func
from portage._global_updates import _global_updates
from portage.sync.controller import SyncManager
from portage.util import writemsg_level
@@ -116,6 +116,13 @@ class SyncRepos(object):
repos = repos.split()
available = self._get_repos(auto_sync_only=False)
selected = self._match_repos(repos, available)
+ if not selected:
+ msgs = [red(" * ") + "Emaint sync, The specified repos were not found: %s"
+ % (bold(", ".join(repos))) + "\n ...returning"
+ ]
+ if return_messages:
+ return msgs
+ return
return self._sync(selected, return_messages)
@@ -187,7 +194,8 @@ class SyncRepos(object):
if not selected_repos:
msgs.append("Emaint sync, nothing to sync... returning")
if return_messages:
- return msgs.append(self.rmessage(('None', os.EX_OK), 'sync'))
+ 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)
^ permalink raw reply related [flat|nested] 51+ messages in thread
* [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/
@ 2014-12-04 20:04 Brian Dolbec
0 siblings, 0 replies; 51+ messages in thread
From: Brian Dolbec @ 2014-12-04 20:04 UTC (permalink / raw
To: gentoo-commits
commit: 75f86cc121deed1df25c2cbafe22483828397c67
Author: Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 22 12:30:19 2014 +0000
Commit: Brian Dolbec <brian.dolbec <AT> gmail <DOT> com>
CommitDate: Thu Dec 4 19:56:35 2014 +0000
URL: http://sources.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=75f86cc1
SyncRepos: parse EMERGE_DEFAULT_OPTS
We need to parse EMERGE_DEFAULT_OPTS, for settings like
--package-moves=n.
---
pym/portage/emaint/modules/sync/sync.py | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/pym/portage/emaint/modules/sync/sync.py b/pym/portage/emaint/modules/sync/sync.py
index 845e8c7..1dade6f 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -58,6 +58,13 @@ class SyncRepos(object):
emerge_config = load_emerge_config(
action='sync', args=_files, opts=opts)
+ # Parse EMERGE_DEFAULT_OPTS, for settings like
+ # --package-moves=n.
+ cmdline = portage.util.shlex_split(
+ emerge_config.target_config.settings.get(
+ "EMERGE_DEFAULT_OPTS", ""))
+ emerge_config.opts = parse_opts(cmdline, silent=True)[1]
+
if hasattr(portage, 'settings'):
# cleanly destroy global objects
portage._reset_legacy_globals()
^ permalink raw reply related [flat|nested] 51+ messages in thread
end of thread, other threads:[~2014-12-04 20:04 UTC | newest]
Thread overview: 51+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-09-27 2:20 [gentoo-commits] proj/portage:plugin-sync commit in: pym/portage/emaint/modules/sync/ Brian Dolbec
-- strict thread matches above, loose matches on Subject: below --
2014-12-04 20:16 [gentoo-commits] proj/portage:master " Brian Dolbec
2014-12-04 20:04 ` [gentoo-commits] proj/portage:plugin-sync " Brian Dolbec
2014-12-04 20:16 [gentoo-commits] proj/portage:master " Brian Dolbec
2014-12-04 20:04 ` [gentoo-commits] proj/portage:plugin-sync " Brian Dolbec
2014-12-04 20:16 [gentoo-commits] proj/portage:master " Brian Dolbec
2014-12-04 20:04 ` [gentoo-commits] proj/portage:plugin-sync " Brian Dolbec
2014-12-04 20:04 Brian Dolbec
2014-12-04 20:04 Brian Dolbec
2014-12-01 21:50 Michał Górny
2014-12-01 21:50 Michał Górny
2014-12-01 21:50 Michał Górny
2014-12-01 21:50 Michał Górny
2014-12-01 21:50 Michał Górny
2014-10-22 13:36 Zac Medico
2014-10-22 12:30 Zac Medico
2014-10-21 20:55 Zac Medico
2014-10-21 5:05 Zac Medico
2014-10-21 5:05 Zac Medico
2014-10-21 5:05 Zac Medico
2014-10-20 3:54 Zac Medico
2014-10-20 3:54 Zac Medico
2014-10-20 3:54 Zac Medico
2014-10-20 3:54 Zac Medico
2014-09-30 0:46 Brian Dolbec
2014-09-30 0:46 Brian Dolbec
2014-09-30 0:46 Brian Dolbec
2014-09-30 0:46 Brian Dolbec
2014-09-29 18:29 Brian Dolbec
2014-09-29 18:29 Brian Dolbec
2014-09-29 18:29 Brian Dolbec
2014-09-29 18:29 Brian Dolbec
2014-09-27 2:20 Brian Dolbec
2014-09-27 2:20 Brian Dolbec
2014-09-27 2:20 Brian Dolbec
2014-09-05 21:15 Brian Dolbec
2014-09-05 21:15 Brian Dolbec
2014-09-05 21:15 Brian Dolbec
2014-09-05 21:15 Brian Dolbec
2014-09-05 4:38 Brian Dolbec
2014-09-05 4:38 Brian Dolbec
2014-09-05 4:38 Brian Dolbec
2014-09-04 1:18 Brian Dolbec
2014-09-03 23:36 Brian Dolbec
2014-09-03 23:36 Brian Dolbec
2014-06-16 22:45 Brian Dolbec
2014-06-16 22:45 Brian Dolbec
2014-06-16 15:46 Brian Dolbec
2014-06-16 15:46 Brian Dolbec
2014-06-16 15:18 Brian Dolbec
2014-06-16 15:18 Brian Dolbec
2014-05-11 17:22 Brian Dolbec
2014-05-02 23:13 Brian Dolbec
2014-04-22 2:36 Brian Dolbec
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox