Re: [gentoo-portage-dev] [PATCH V2] sync.py: extend the checks in _get_repos() and fail when necessary (bugs 567478, 576272, 601054)

2017-02-19 Thread Zac Medico
On 02/19/2017 01:02 PM, Alexandru Elisei wrote:
>   if auto_sync_only:
> - return self._filter_auto(selected_repos)
> - return selected_repos
> + selected_repos = self._filter_auto(selected_repos)
> + #print("_get_repos(), selected =", selected_repos)
> + if emerge_repos:
> + skipped_repos = set(emerge_repos) - set(selected_repos)
> + if skipped_repos:
> + msgs.append(warn(" * ") + "auto-sync is 
> disabled for repo(s): %s" %
> + " ".join(repo.name for repo in 
> skipped_repos) + "\n")
> + return (False, selected_repos, msgs)
> + return (True, selected_repos, msgs)

I feel like it should be possible to use emerge_repos arguments to sync
repos that have auto-sync disabled, but that seems to be disallowed
here, because _filter_auto will have filtered out those repos that have
auto-sync disabled.
-- 
Thanks,
Zac



Re: [gentoo-portage-dev] [PATCH V2] sync.py: extend the checks in _get_repos() and fail when necessary (bugs 567478, 576272, 601054)

2017-02-19 Thread Zac Medico
On 02/19/2017 01:02 PM, Alexandru Elisei wrote:
> + valid_repos = []
> + missing_sync_type = []
> + for repo in selected_repos:
> + if repo.sync_type is None:
> + missing_sync_type.append(repo.name)
> + else:
> + valid_repos.append(repo)
> + if missing_sync_type:
> + msgs.append(warn(" * ") + "Missing sync-type for 
> repo(s): %s" %
> + " ".join(missing_sync_type) + "\n")
> + return (False, valid_repos, msgs)
> +
>   if auto_sync_only:
> - return self._filter_auto(selected_repos)
> - return selected_repos
> + selected_repos = self._filter_auto(selected_repos)

Do we support local repos that don't have a sync-uri? If so, what
sync-type should be set for such a repo? Is it also necessary to set
auto-sync = no, in order to avoid an error for such a repo?
-- 
Thanks,
Zac



[gentoo-portage-dev] [PATCH V2] sync.py: extend the checks in _get_repos() and fail when necessary (bugs 567478, 576272, 601054)

2017-02-19 Thread Alexandru Elisei
The existence of the sync-type attribute is now being checked for all
repos, not just for the repos given as arguments to emerge --sync. A
message is returned when a repo without sync-type is found and sync
will fail.

Emerge will now fail if at least one of the repos given to emerge --sync
doesn't exist or has auto-sync disabled.

auto_sync() and all_repos() also fail when no valid repos are found, but
they return success when no auto-sync repos are defined, or no repos are
defined at all on the system.

This commit and commit f57ae38 'emerge: make emerge --sync print
messages from SyncRepos.auto_sync()' shoulg solve bugs 567478, 576282
and partly 601054.
---
 pym/portage/emaint/modules/sync/sync.py | 104 +++-
 1 file changed, 62 insertions(+), 42 deletions(-)

diff --git a/pym/portage/emaint/modules/sync/sync.py 
b/pym/portage/emaint/modules/sync/sync.py
index 08a92a7..4d66411 100644
--- a/pym/portage/emaint/modules/sync/sync.py
+++ b/pym/portage/emaint/modules/sync/sync.py
@@ -89,25 +89,45 @@ class SyncRepos(object):
def auto_sync(self, **kwargs):
'''Sync auto-sync enabled repos'''
options = kwargs.get('options', None)
-   selected = self._get_repos(True)
if options:
return_messages = options.get('return-messages', False)
else:
return_messages = False
-   return self._sync(selected, return_messages,
-   emaint_opts=options)
+   success, selected, msgs = self._get_repos(True)
+   if not success:
+   if return_messages:
+   msgs.append(red(" * ") + \
+   "Errors were encountered while getting 
repos... returning")
+   return (False, msgs)
+   return (False, None)
+   if not selected:
+   if return_messages:
+   msgs.append("Nothing to sync... returning")
+   return (True, msgs)
+   return (True, None)
+   return self._sync(selected, return_messages, 
emaint_opts=options)
 
 
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:
return_messages = options.get('return-messages', False)
else:
return_messages = False
-   return self._sync(selected, return_messages,
-   emaint_opts=options)
+   success, selected, msgs = self._get_repos(auto_sync_only=False)
+   if not success:
+   if return_messages:
+   msgs.append(red(" * ") + \
+   "Errors were encountered while getting 
repos... returning")
+   return (False, msgs)
+   return (False, None)
+   if not selected:
+   if return_messages:
+   msgs.append("Nothing to sync... returning")
+   return (True, msgs)
+   return (True, None)
+   return self._sync(selected, return_messages, 
emaint_opts=options)
 
 
def repo(self, **kwargs):
@@ -120,16 +140,17 @@ class SyncRepos(object):
return_messages = False
if isinstance(repos, _basestring):
repos = repos.split()
-   available = self._get_repos(auto_sync_only=False)
+   success, available, msgs = self._get_repos(auto_sync_only=False)
+   # Ignore errors from _get_repos(), we only want to know if the 
repo
+   # exists.
selected = self._match_repos(repos, available)
if not selected:
-   msgs = [red(" * ") + "The specified repos were not 
found: %s" %
-   (bold(", ".join(repos))) + "\n   ...returning"]
+   msgs.append(red(" * ") + "The specified repos are 
invalid or missing: %s" %
+   (bold(", ".join(repos))) + "\n   ...returning")
if return_messages:
return (False, msgs)
return (False, None)
-   return self._sync(selected, return_messages,
-   emaint_opts=options)
+   return self._sync(selected, return_messages, 
emaint_opts=options)
 
 
@staticmethod
@@ -148,10 +169,11 @@ class SyncRepos(object):
 
 
def _get_repos(self, auto_sync_only=True):
+   msgs = []
+   emerge_repos = []