From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) by finch.gentoo.org (Postfix) with ESMTP id 90C65138CED for ; Thu, 18 Jun 2015 21:36:52 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 73F4A14024; Thu, 18 Jun 2015 21:36:51 +0000 (UTC) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id D1F3314024 for ; Thu, 18 Jun 2015 21:36:50 +0000 (UTC) Received: by wgez8 with SMTP id z8so74360090wge.0 for ; Thu, 18 Jun 2015 14:36:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=TwHfndsopKOBkKWGaa1/GsqcgMCRTBcmk8sgCluId44=; b=mbPMqPknv1Ev7r5QnGw8VeildDe1CrJKf4Ul5H4wnkLVB4eEVjlLmv8NOF1VnAbAAZ iSVUbQ2dfYWc/txvxuG2E7yTLvTeTNBSHG72CVQ1QuUSqELAaTuaLZrXU10+UmN22AEg EEMv4X2JfoXzjyc7EUIizR1cCDhpuJZq9+uPd2vZUV6x23GBTUZ5ovl7lApKKqrywTAE pId8MKfGa5pSbD+x3MX6R34cjm1ZktacToS4IJM0WIMK4NHQJjhWMsy5kP/8jHq+zOaI UrK49lGOnePpI4/JZVm6youhDIqKmt8dj/fPZjliBxwhEVDail971tg9yduVLEt9V/8u gdcg== X-Received: by 10.180.149.243 with SMTP id ud19mr228948wib.11.1434663409614; Thu, 18 Jun 2015 14:36:49 -0700 (PDT) Received: from localhost.localdomain (sbr22-2-88-185-151-243.fbx.proxad.net. [88.185.151.243]) by mx.google.com with ESMTPSA id s10sm14017473wjy.35.2015.06.18.14.36.48 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 18 Jun 2015 14:36:48 -0700 (PDT) From: =?UTF-8?q?=C3=89tienne=20Buira?= To: gentoo-portage-dev@lists.gentoo.org Cc: =?UTF-8?q?=C3=89tienne=20Buira?= Subject: [gentoo-portage-dev] [PATCH v2 1/2] sync: allow sync modules to have specific options Date: Thu, 18 Jun 2015 23:36:23 +0200 Message-Id: X-Mailer: git-send-email 2.3.6 In-Reply-To: <20150617133217.303b3b68.dolsen@gentoo.org> References: <20150617133217.303b3b68.dolsen@gentoo.org> Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-portage-dev@lists.gentoo.org Reply-to: gentoo-portage-dev@lists.gentoo.org X-Archives-Salt: 3f12d40d-761e-4933-908e-8faced9735b8 X-Archives-Hash: ceecd1fd85571954421fe629da371f33 --- pym/portage/repository/config.py | 34 +++++++++++++++++++++------------- pym/portage/sync/__init__.py | 10 ++++++++++ pym/portage/sync/modules/cvs/cvs.py | 5 +++++ pym/portage/sync/syncbase.py | 5 +++++ 4 files changed, 41 insertions(+), 13 deletions(-) diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index b7c969d..60eb1f2 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -86,11 +86,12 @@ class RepoConfig(object): 'find_invalid_path_char', 'force', 'format', 'local_config', 'location', 'main_repo', 'manifest_hashes', 'masters', 'missing_repo_name', 'name', 'portage1_profiles', 'portage1_profiles_compat', 'priority', - 'profile_formats', 'sign_commit', 'sign_manifest', 'sync_cvs_repo', + 'profile_formats', 'sign_commit', 'sign_manifest', 'sync_depth', 'sync_type', 'sync_umask', 'sync_uri', 'sync_user', 'thin_manifest', 'update_changelog', 'user_location', '_eapis_banned', - '_eapis_deprecated', '_masters_orig') + '_eapis_deprecated', '_masters_orig') + \ + tuple(portage.sync.module_specific_options) def __init__(self, name, repo_opts, local_config=True): """Build a RepoConfig with options in repo_opts @@ -148,11 +149,6 @@ class RepoConfig(object): priority = None self.priority = priority - sync_cvs_repo = repo_opts.get('sync-cvs-repo') - if sync_cvs_repo is not None: - sync_cvs_repo = sync_cvs_repo.strip() - self.sync_cvs_repo = sync_cvs_repo or None - sync_type = repo_opts.get('sync-type') if sync_type is not None: sync_type = sync_type.strip() @@ -180,6 +176,11 @@ class RepoConfig(object): self.sync_depth = repo_opts.get('sync-depth') + for o in portage.sync.module_specific_options: + odash = o.replace('_', '-') + if odash in repo_opts: + setattr(self, o, repo_opts[odash]) + # Not implemented. format = repo_opts.get('format') if format is not None: @@ -407,8 +408,6 @@ class RepoConfig(object): repo_msg.append(indent + "format: " + self.format) if self.user_location: repo_msg.append(indent + "location: " + self.user_location) - if self.sync_cvs_repo: - repo_msg.append(indent + "sync-cvs-repo: " + self.sync_cvs_repo) if self.sync_type: repo_msg.append(indent + "sync-type: " + self.sync_type) if self.sync_umask: @@ -426,6 +425,11 @@ class RepoConfig(object): if self.eclass_overrides: repo_msg.append(indent + "eclass-overrides: " + \ " ".join(self.eclass_overrides)) + if self.sync_type is not None: + prefix = "sync_" + self.sync_type + "_" + for o in portage.sync.module_specific_options: + if hasattr(self, o) and o.startswith(prefix) and getattr(self, o): + repo_msg.append(indent + o.replace('_', '-') + ": " + getattr(self, o)) repo_msg.append("") return "\n".join(repo_msg) @@ -477,6 +481,9 @@ class RepoConfigLoader(object): if prepos['DEFAULT'].masters is not None: default_repo_opts['masters'] = \ ' '.join(prepos['DEFAULT'].masters) + for o in portage.sync.module_specific_options: + if hasattr(prepos['DEFAULT'], o): + default_repo_opts[o.replace('_', '-')] = getattr(prepos['DEFAULT'], o) if overlays: # We need a copy of the original repos.conf data, since we're @@ -503,10 +510,10 @@ class RepoConfigLoader(object): # Selectively copy only the attributes which # repos.conf is allowed to override. for k in ('aliases', 'auto_sync', 'eclass_overrides', - 'force', 'masters', 'priority', 'sync_cvs_repo', + 'force', 'masters', 'priority', 'sync_depth', 'sync_type', 'sync_umask', 'sync_uri', 'sync_user', - ): + ) + tuple(portage.sync.module_specific_options): v = getattr(repos_conf_opts, k, None) if v is not None: setattr(repo, k, v) @@ -961,8 +968,9 @@ class RepoConfigLoader(object): def config_string(self): str_or_int_keys = ("auto_sync", "format", "location", - "main_repo", "priority", "sync_cvs_repo", + "main_repo", "priority", "sync_type", "sync_umask", "sync_uri", 'sync_user') + str_or_int_keys += tuple(portage.sync.module_specific_options) str_tuple_keys = ("aliases", "eclass_overrides", "force") repo_config_tuple_keys = ("masters",) keys = str_or_int_keys + str_tuple_keys + repo_config_tuple_keys @@ -972,7 +980,7 @@ class RepoConfigLoader(object): for key in sorted(keys): if key == "main_repo" and repo_name != "DEFAULT": continue - if getattr(repo, key) is not None: + if hasattr(repo, key) and getattr(repo, key) is not None: if key in str_or_int_keys: config_string += "%s = %s\n" % (key.replace("_", "-"), getattr(repo, key)) elif key in str_tuple_keys: diff --git a/pym/portage/sync/__init__.py b/pym/portage/sync/__init__.py index 51bf051..11059eb 100644 --- a/pym/portage/sync/__init__.py +++ b/pym/portage/sync/__init__.py @@ -25,6 +25,16 @@ module_controller = Modules(path=path, namepath="portage.sync.modules") module_names = module_controller.module_names[:] +def _build_module_specific_options_list(): + modules = set() + for (mn, m) in [(mn, module_controller.get_class(mn)) for mn in module_names]: + modules.update(["sync_" + mn + "_" + opt.replace('-', '_') for opt in m.specific_options()]) + return modules + + +module_specific_options = frozenset(_build_module_specific_options_list()) + + def validate_config(repo, logger): '''Validate the repos.conf settings for the repo''' global module_names, module_controller diff --git a/pym/portage/sync/modules/cvs/cvs.py b/pym/portage/sync/modules/cvs/cvs.py index 9b382ab..90e256b 100644 --- a/pym/portage/sync/modules/cvs/cvs.py +++ b/pym/portage/sync/modules/cvs/cvs.py @@ -19,6 +19,11 @@ class CVSSync(NewBase): return "CVSSync" + @staticmethod + def specific_options(): + return ("repo",) + + def __init__(self): NewBase.__init__(self, "cvs", portage.const.CVS_PACKAGE_ATOM) diff --git a/pym/portage/sync/syncbase.py b/pym/portage/sync/syncbase.py index d30d69d..4d75f69 100644 --- a/pym/portage/sync/syncbase.py +++ b/pym/portage/sync/syncbase.py @@ -24,6 +24,11 @@ class SyncBase(object): return "BlankSync" + @staticmethod + def specific_options(): + return () + + def can_progressbar(self, func): return False -- 2.0.5