commit: 367ab0c2e5c2cf06b142979dbd97ad6a79dbf69a Author: Michał Górny <mgorny <AT> gentoo <DOT> org> AuthorDate: Wed Dec 9 17:10:09 2015 +0000 Commit: Michał Górny <mgorny <AT> gentoo <DOT> org> CommitDate: Wed Dec 9 17:13:51 2015 +0000 URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=367ab0c2
Revert unreviewed and breaking changes done by Arfrever Reverts: e7d95cb ("Support location with trailing whitespace [...]") Reverts: 7853950 ("Delete support for PORTDIR and PORTDIR_OVERLAY [...]") Reverts: 31923f4 ("Skip some warnings for Portage Python [...]") bin/ebuild | 2 +- bin/isolated-functions.sh | 20 +-- man/make.conf.5 | 61 +++++++- man/portage.5 | 1 - pym/_emerge/actions.py | 33 +++++ pym/portage/dbapi/porttree.py | 4 +- .../package/ebuild/_config/special_env_vars.py | 1 + pym/portage/package/ebuild/config.py | 46 ++++-- pym/portage/repository/config.py | 163 +++++++++++++++++++-- pym/portage/tests/dbapi/test_fakedbapi.py | 2 +- pym/portage/tests/resolver/ResolverPlayground.py | 2 +- pym/portage/tests/sync/test_sync_local.py | 2 +- pym/repoman/repos.py | 2 +- 13 files changed, 284 insertions(+), 55 deletions(-) diff --git a/bin/ebuild b/bin/ebuild index a696adf..1afad25 100755 --- a/bin/ebuild +++ b/bin/ebuild @@ -158,7 +158,7 @@ if repo_location != vdb_path: print("Appending repository '%s' located in '%s' to configuration of repositories" % (repo_name, repo_location)) tmp_conf_file = io.StringIO(textwrap.dedent(""" [%s] - location = "%s" + location = %s """ % (repo_name, repo_location))) repositories = portage.repository.config.load_repository_config(portage.settings, extra_files=[tmp_conf_file]) os.environ["PORTAGE_REPOSITORIES"] = repositories.config_string() diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index a55d4a3..5766921 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright 1999-2015 Gentoo Foundation +# Copyright 1999-2014 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 source "${PORTAGE_BIN_PATH}/eapi.sh" || exit 1 @@ -473,23 +473,17 @@ has() { } __repo_attr() { - local appropriate_section=0 attribute=$2 exit_status=1 line repo_name=$1 saved_extglob_shopt=$(shopt -p extglob) value + local appropriate_section=0 exit_status=1 line saved_extglob_shopt=$(shopt -p extglob) shopt -s extglob while read line; do - [[ ${appropriate_section} == 0 && ${line} == "[${repo_name}]" ]] && appropriate_section=1 && continue + [[ ${appropriate_section} == 0 && ${line} == "[$1]" ]] && appropriate_section=1 && continue [[ ${appropriate_section} == 1 && ${line} == "["*"]" ]] && appropriate_section=0 && continue - # If a conditional expression like [[ ${line} == ${attribute}*( )=* ]] is used - # then bash <4.1 produces an error like the following when the file is + # If a conditional expression like [[ ${line} == $2*( )=* ]] is used + # then bash-3.2 produces an error like the following when the file is # sourced: syntax error in conditional expression: unexpected token `(' # Therefore, use a regular expression for compatibility. - if [[ ${appropriate_section} == 1 && ${line} =~ ^${attribute}[[:space:]]*= ]]; then - value="${line##${attribute}*( )=*( )}" - if [[ ${attribute} =~ ^(location)$ && (${value} == "'"*"'" || ${value} == '"'*'"') ]]; then - # bash >=4.2: - # value=${value:1:-1} - value=${value:1:$((${#value} - 2))} - fi - echo "${value}" + if [[ ${appropriate_section} == 1 && ${line} =~ ^${2}[[:space:]]*= ]]; then + echo "${line##$2*( )=*( )}" exit_status=0 break fi diff --git a/man/make.conf.5 b/man/make.conf.5 index f155c8e..1d1cfeb 100644 --- a/man/make.conf.5 +++ b/man/make.conf.5 @@ -1,4 +1,4 @@ -.TH "MAKE.CONF" "5" "Dec 2015" "Portage VERSION" "Portage" +.TH "MAKE.CONF" "5" "Jan 2015" "Portage VERSION" "Portage" .SH "NAME" make.conf \- custom settings for Portage .SH "SYNOPSIS" @@ -195,8 +195,9 @@ like to selectively prune obsolete files from this directory, see Use the \fBPORTAGE_RO_DISTDIRS\fR variable to specify one or more read-only directories containing distfiles. -Note that locations under locations of repositories are not necessarily safe -for data storage. +Note +that locations under /usr/portage are not necessarily safe for data storage. +See the \fBPORTDIR\fR documentation for more information. .br Defaults to /usr/portage/distfiles. .TP @@ -772,8 +773,8 @@ to it's category. However, for backward compatibility with the layout used by older versions of portage, if the \fI${PKGDIR}/All\fR directory exists then all packages will be stored inside of it and symlinks to the packages will be created in the category subdirectories. Note -that locations under locations of repositories are not necessarily safe -for data storage. +that locations under /usr/portage are not necessarily safe for data storage. +See the \fBPORTDIR\fR documentation for more information. .br Defaults to /usr/portage/packages. .TP @@ -1000,6 +1001,30 @@ when \fBxattr\fR is in \fBFEATURES\fR. .br Defaults to "security.*" (security labels are special, see bug #461868). .TP +\fBPORTDIR\fR = \fI[path]\fR +Defines the location of main repository. This variable is deprecated in favor of +settings in \fBrepos.conf\fR. If you change this, you must update +your /etc/portage/make.profile symlink accordingly. +.br +Defaults to /usr/portage. +.br +\fB***Warning***\fR +.br +Data stored inside \fBPORTDIR\fR is in peril of being overwritten or deleted by +the emerge \-\-sync command. The default value of +\fBPORTAGE_RSYNC_OPTS\fR will protect the default locations of +\fBDISTDIR\fR and \fBPKGDIR\fR, but users are warned that any other locations +inside \fBPORTDIR\fR are not necessarily safe for data storage. You should not +put other data (such as overlays) in your \fBPORTDIR\fB. Portage will walk +directory structures and may arbitrarily add invalid categories as packages. +.TP +\fBPORTDIR_OVERLAY\fR = \fI"[path] [different\-path] [etc...]"\fR +Defines the locations of other repositories. This variable is deprecated in +favor of settings in \fBrepos.conf\fR. This variable is a space\-delimited list of +directories. +.br +Defaults to no value. +.TP \fBQA_STRICT_EXECSTACK = \fI"set"\fR Set this to cause portage to ignore any \fIQA_EXECSTACK\fR override settings from ebuilds. See also \fBebuild\fR(5). @@ -1047,6 +1072,32 @@ Defines the location where created RPM packages will be stored. .br Defaults to /usr/portage/rpm. .TP +\fBSYNC\fR = \fI[RSYNC]\fR +Insert your preferred rsync mirror here. This rsync server +is used to sync the local portage tree when `emerge \-\-sync` is run. + +Note that the \fBSYNC\fR variable is now deprecated, and instead the +sync\-type and sync\-uri attributes in repos.conf should be used. See +\fBportage\fR(5) for more information. + +Defaults to rsync://rsync.gentoo.org/gentoo\-portage +.RS +.TP +.B Usage: +(rsync|ssh)://[username@]hostname[:port]/(module|path) +.TP +.B Examples: +rsync://private\-mirror.com/portage\-module +.br +rsync://rsync\-user@private\-mirror.com:873/gentoo\-portage +.br +ssh://ssh\-user@192.168.0.1:22/usr/portage +.br +ssh://ssh\-user@192.168.0.1:22/\\${HOME}/portage\-storage +.TP +Note: For the ssh:// scheme, key\-based authentication might be of interest. +.RE +.TP \fBUNINSTALL_IGNORE\fR = \fI[space delimited list of fnmatch patterns]\fR This variable prevents uninstallation of files that match specific \fBfnmatch\fR(3) patterns. In order to ignore file diff --git a/man/portage.5 b/man/portage.5 index aa87e8f..6c41332 100644 --- a/man/portage.5 +++ b/man/portage.5 @@ -956,7 +956,6 @@ Valid values: aliases, eclass\-overrides, masters .TP .B location Specifies location of given repository. -If location of repository ends with whitespace, then value of this attribute must be quoted. .TP .B masters Specifies master repositories of given repository. diff --git a/pym/_emerge/actions.py b/pym/_emerge/actions.py index da7d90f..a080ba4 100644 --- a/pym/_emerge/actions.py +++ b/pym/_emerge/actions.py @@ -2693,6 +2693,38 @@ def expand_set_arguments(myfiles, myaction, root_config): newargs.append(a) return (newargs, retval) +def repo_name_duplicate_check(trees): + ignored_repos = {} + for root, root_trees in trees.items(): + if 'porttree' in root_trees: + portdb = root_trees['porttree'].dbapi + if portdb.settings.get('PORTAGE_REPO_DUPLICATE_WARN') != '0': + for repo_name, paths in portdb.getIgnoredRepos(): + k = (root, repo_name, portdb.getRepositoryPath(repo_name)) + ignored_repos.setdefault(k, []).extend(paths) + + if ignored_repos: + msg = [] + msg.append('WARNING: One or more repositories ' + \ + 'have been ignored due to duplicate') + msg.append(' profiles/repo_name entries:') + msg.append('') + for k in sorted(ignored_repos): + msg.append(' %s overrides' % ", ".join(k)) + for path in ignored_repos[k]: + msg.append(' %s' % (path,)) + msg.append('') + msg.extend(' ' + x for x in textwrap.wrap( + "All profiles/repo_name entries must be unique in order " + \ + "to avoid having duplicates ignored. " + \ + "Set PORTAGE_REPO_DUPLICATE_WARN=\"0\" in " + \ + "/etc/portage/make.conf if you would like to disable this warning.")) + msg.append("\n") + writemsg_level(''.join('%s\n' % l for l in msg), + level=logging.WARNING, noiselevel=-1) + + return bool(ignored_repos) + def run_action(emerge_config): # skip global updates prior to sync, since it's called after sync @@ -2778,6 +2810,7 @@ def run_action(emerge_config): if "--quiet" not in emerge_config.opts: portage.deprecated_profile_check( settings=emerge_config.target_config.settings) + repo_name_duplicate_check(emerge_config.trees) config_protect_check(emerge_config.trees) check_procfs() diff --git a/pym/portage/dbapi/porttree.py b/pym/portage/dbapi/porttree.py index fd489d8..0b8034e 100644 --- a/pym/portage/dbapi/porttree.py +++ b/pym/portage/dbapi/porttree.py @@ -363,9 +363,7 @@ class portdbapi(dbapi): Returns a list of repository paths that have been ignored, because another repo with the same name exists. """ - warnings.warn("portage.dbapi.porttree.portdbapi.getIgnoredRepos() is deprecated", - DeprecationWarning, stacklevel=2) - return () + return self.settings.repositories.ignored_repos def findname2(self, mycpv, mytree=None, myrepo = None): """ diff --git a/pym/portage/package/ebuild/_config/special_env_vars.py b/pym/portage/package/ebuild/_config/special_env_vars.py index d69c010..9ae53c1 100644 --- a/pym/portage/package/ebuild/_config/special_env_vars.py +++ b/pym/portage/package/ebuild/_config/special_env_vars.py @@ -174,6 +174,7 @@ environ_filter += [ "PORTAGE_GPG_KEY", "PORTAGE_GPG_SIGNING_COMMAND", "PORTAGE_IONICE_COMMAND", "PORTAGE_PACKAGE_EMPTY_ABORT", + "PORTAGE_REPO_DUPLICATE_WARN", "PORTAGE_RO_DISTDIRS", "PORTAGE_RSYNC_EXTRA_OPTS", "PORTAGE_RSYNC_OPTS", "PORTAGE_RSYNC_RETRIES", "PORTAGE_SSH_OPTS", "PORTAGE_SYNC_STALE", diff --git a/pym/portage/package/ebuild/config.py b/pym/portage/package/ebuild/config.py index f75a0e7..975fe88 100644 --- a/pym/portage/package/ebuild/config.py +++ b/pym/portage/package/ebuild/config.py @@ -502,24 +502,28 @@ class config(object): self["EPREFIX"] = eprefix self["EROOT"] = eroot known_repos = [] + portdir = "" + portdir_overlay = "" + portdir_sync = None for confs in [make_globals, make_conf, self.configdict["env"]]: + v = confs.get("PORTDIR") + if v is not None: + portdir = v + known_repos.append(v) + v = confs.get("PORTDIR_OVERLAY") + if v is not None: + portdir_overlay = v + known_repos.extend(shlex_split(v)) + v = confs.get("SYNC") + if v is not None: + portdir_sync = v if 'PORTAGE_RSYNC_EXTRA_OPTS' in confs: self['PORTAGE_RSYNC_EXTRA_OPTS'] = confs['PORTAGE_RSYNC_EXTRA_OPTS'] - for var in ("PORTDIR", "PORTDIR_OVERLAY", "SYNC"): - if make_conf.get(var) is not None: - writemsg_level("!!! %s\n" % _("%s variable is set in make.conf but is no longer used. " - "Use repos.conf instead.") % var, level=logging.WARNING, noiselevel=-1) - # Skip warnings for Portage Python scripts called in ebuild environment. - # PORTDIR is exported in ebuild environment in some EAPIs. - if self.configdict["env"].get("EBUILD") is None: - for var in ("PORTDIR", "PORTDIR_OVERLAY", "SYNC"): - if self.configdict["env"].get(var) is not None: - writemsg_level("!!! %s\n" % _("%s environmental variable is set but is no longer used. " - "Use new environmental variables instead:") % var, level=logging.WARNING, noiselevel=-1) - writemsg_level(" PORTAGE_REPOSITORIES, PORTAGE_REPOSITORY:${repository_name}:${attribute}, " - "PORTAGE_ADDED_REPOSITORIES, PORTAGE_DELETED_REPOSITORIES\n", level=logging.WARNING, noiselevel=-1) - + self["PORTDIR"] = portdir + self["PORTDIR_OVERLAY"] = portdir_overlay + if portdir_sync: + self["SYNC"] = portdir_sync self.lookuplist = [self.configdict["env"]] if repositories is None: self.repositories = load_repository_config(self) @@ -539,11 +543,23 @@ class config(object): self.backup_changes("PORTDIR") expand_map["PORTDIR"] = self["PORTDIR"] + # repoman controls PORTDIR_OVERLAY via the environment, so no + # special cases are needed here. portdir_overlay = list(self.repositories.repoLocationList()) if portdir_overlay and portdir_overlay[0] == self["PORTDIR"]: portdir_overlay = portdir_overlay[1:] - self["PORTDIR_OVERLAY"] = " ".join(portdir_overlay) + new_ov = [] + if portdir_overlay: + for ov in portdir_overlay: + ov = normalize_path(ov) + if isdir_raise_eaccess(ov) or portage._sync_mode: + new_ov.append(portage._shell_quote(ov)) + else: + writemsg(_("!!! Invalid PORTDIR_OVERLAY" + " (not a dir): '%s'\n") % ov, noiselevel=-1) + + self["PORTDIR_OVERLAY"] = " ".join(new_ov) self.backup_changes("PORTDIR_OVERLAY") expand_map["PORTDIR_OVERLAY"] = self["PORTDIR_OVERLAY"] diff --git a/pym/portage/repository/config.py b/pym/portage/repository/config.py index e1d5761..fff619f 100644 --- a/pym/portage/repository/config.py +++ b/pym/portage/repository/config.py @@ -143,8 +143,6 @@ class RepoConfig(object): name, level=logging.ERROR, noiselevel=-1) self._invalid_config = True else: - if (location.startswith("'") and location.endswith("'")) or (location.startswith('"') and location.endswith('"')): - location = location[1:-1] if not os.path.isabs(location): writemsg_level("!!! %s\n" % _("Section %r in repos.conf has 'location' attribute set to " "relative path: %r") % (name, location), level=logging.ERROR, noiselevel=-1) @@ -422,7 +420,7 @@ class RepoConfig(object): if self.format: repo_msg.append(indent + "format: " + self.format) if self.location: - repo_msg.append(indent + "location: \"" + self.location + "\"") + repo_msg.append(indent + "location: " + self.location) if self.sync_type: repo_msg.append(indent + "sync-type: " + self.sync_type) if self.sync_umask: @@ -463,7 +461,102 @@ class RepoConfig(object): return _unicode_encode(self.__unicode__()) class RepoConfigLoader(object): - """Loads and store config of several repositories, loaded from repos.conf""" + """Loads and store config of several repositories, loaded from PORTDIR_OVERLAY or repos.conf""" + + @staticmethod + def _add_repositories(portdir, portdir_overlay, prepos, + ignored_map, local_config, default_portdir): + """Add overlays in PORTDIR_OVERLAY as repositories""" + overlays = [] + portdir_orig = None + if portdir: + portdir = normalize_path(portdir) + portdir_orig = portdir + overlays.append(portdir) + try: + port_ov = [normalize_path(i) for i in shlex_split(portdir_overlay)] + except ValueError as e: + #File "/usr/lib/python3.2/shlex.py", line 168, in read_token + # raise ValueError("No closing quotation") + writemsg(_("!!! Invalid PORTDIR_OVERLAY:" + " %s: %s\n") % (e, portdir_overlay), noiselevel=-1) + port_ov = [] + overlays.extend(port_ov) + default_repo_opts = {} + if prepos['DEFAULT'].aliases is not None: + default_repo_opts['aliases'] = \ + ' '.join(prepos['DEFAULT'].aliases) + if prepos['DEFAULT'].eclass_overrides is not None: + default_repo_opts['eclass-overrides'] = \ + ' '.join(prepos['DEFAULT'].eclass_overrides) + if prepos['DEFAULT'].masters is not None: + default_repo_opts['masters'] = \ + ' '.join(prepos['DEFAULT'].masters) + + if overlays: + # We need a copy of the original repos.conf data, since we're + # going to modify the prepos dict and some of the RepoConfig + # objects that we put in prepos may have to be discarded if + # they get overridden by a repository with the same name but + # a different location. This is common with repoman, for example, + # when temporarily overriding an rsync repo with another copy + # of the same repo from CVS. + repos_conf = prepos.copy() + #overlay priority is negative because we want them to be looked before any other repo + base_priority = 0 + for ov in overlays: + # Ignore missing directory for 'gentoo' so that + # first sync with emerge-webrsync is possible. + if isdir_raise_eaccess(ov) or \ + (base_priority == 0 and ov is portdir): + repo_opts = default_repo_opts.copy() + repo_opts['location'] = ov + repo = RepoConfig(None, repo_opts, local_config=local_config) + if repo._invalid_config: + continue + # repos_conf_opts contains options from repos.conf + repos_conf_opts = repos_conf.get(repo.name) + if repos_conf_opts is not None: + # Selectively copy only the attributes which + # repos.conf is allowed to override. + for k in ('aliases', 'auto_sync', 'eclass_overrides', + 'force', 'masters', 'priority', + 'sync_depth', 'sync_hooks_only_on_change', + 'sync_type', 'sync_umask', 'sync_uri', 'sync_user', + 'module_specific_options'): + v = getattr(repos_conf_opts, k, None) + if v is not None: + setattr(repo, k, v) + + if repo.name in prepos: + # Silently ignore when PORTDIR overrides the location + # setting from the default repos.conf (bug #478544). + old_location = prepos[repo.name].location + if old_location is not None and \ + old_location != repo.location and \ + not (base_priority == 0 and + old_location == default_portdir): + ignored_map.setdefault(repo.name, []).append(old_location) + if old_location == portdir: + portdir = repo.location + + if repo.priority is None: + if base_priority == 0 and ov == portdir_orig: + # If it's the original PORTDIR setting and it's not + # in PORTDIR_OVERLAY, then it will be assigned a + # special priority setting later. + pass + else: + repo.priority = base_priority + base_priority += 1 + + prepos[repo.name] = repo + else: + + if not portage._sync_mode: + writemsg(_("!!! Invalid PORTDIR_OVERLAY (not a dir): '%s'\n") % ov, noiselevel=-1) + + return portdir @staticmethod def _parse(paths, prepos, local_config, default_opts, added_repos, deleted_repos, attrs_overrides): @@ -555,6 +648,7 @@ class RepoConfigLoader(object): prepos = {} location_map = {} treemap = {} + ignored_map = {} default_opts = { "EPREFIX" : settings["EPREFIX"], "EROOT" : settings["EROOT"], @@ -566,10 +660,18 @@ class RepoConfigLoader(object): added_repos = [] deleted_repos = [] attrs_overrides = {} + portdir = "" + portdir_overlay = "" + # deprecated portdir_sync + portdir_sync = "" else: added_repos = settings.get("PORTAGE_ADDED_REPOSITORIES", "").split() deleted_repos = settings.get("PORTAGE_DELETED_REPOSITORIES", "").split() attrs_overrides = {x: settings[x] for x in settings if _repo_attr_override_var_re.match(x) is not None} + portdir = settings.get("PORTDIR", "") + portdir_overlay = settings.get("PORTDIR_OVERLAY", "") + # deprecated portdir_sync + portdir_sync = settings.get("SYNC", "") default_opts['sync-rsync-extra-opts'] = \ settings.get("PORTAGE_RSYNC_EXTRA_OPTS", None) @@ -580,11 +682,28 @@ class RepoConfigLoader(object): writemsg( _("!!! Error while reading repo config file: %s\n") % e, noiselevel=-1) - # The configparser state is unreliable (prone to quirky exceptions) - # after it has thrown an error, so use empty config. + # The configparser state is unreliable (prone to quirky + # exceptions) after it has thrown an error, so use empty + # config and try to fall back to PORTDIR{,_OVERLAY}. prepos.clear() prepos['DEFAULT'] = RepoConfig('DEFAULT', {}, local_config=settings.local_config) + location_map.clear() + treemap.clear() + + default_portdir = os.path.join(os.sep, + settings['EPREFIX'].lstrip(os.sep), 'usr', 'portage') + + # If PORTDIR_OVERLAY contains a repo with the same repo_name as + # PORTDIR, then PORTDIR is overridden. + portdir = self._add_repositories(portdir, portdir_overlay, prepos, + ignored_map, settings.local_config, + default_portdir) + if portdir and portdir.strip(): + portdir = os.path.realpath(portdir) + + ignored_repos = tuple((repo_name, tuple(paths)) \ + for repo_name, paths in ignored_map.items()) # Do this before expanding aliases, so that location_map and # treemap consistently map unaliased names whenever available. @@ -621,11 +740,30 @@ class RepoConfigLoader(object): treemap[name] = repo.location main_repo = prepos['DEFAULT'].main_repo + if main_repo is None or main_repo not in prepos: + #setting main_repo if it was not set in repos.conf + main_repo = location_map.get(portdir) + if main_repo is not None: + prepos['DEFAULT'].main_repo = main_repo + else: + prepos['DEFAULT'].main_repo = None + if portdir and not portage._sync_mode: + writemsg(_("!!! main-repo not set in DEFAULT and PORTDIR is empty.\n"), noiselevel=-1) if main_repo is not None and prepos[main_repo].priority is None: # This happens if main-repo has been set in repos.conf. prepos[main_repo].priority = -1000 + # DEPRECATED Backward compatible SYNC support for old mirrorselect. + # Feb. 2, 2015. Version 2.2.16 + if portdir_sync and main_repo is not None: + writemsg(_("!!! SYNC setting found in make.conf.\n " + "This setting is Deprecated and no longer used. " + "Please ensure your 'sync-type' and 'sync-uri' are set correctly" + " in /etc/portage/repos.conf/gentoo.conf\n"), + noiselevel=-1) + + # Include repo.name in sort key, for predictable sorting # even when priorities are equal. prepos_order = sorted(prepos.items(), @@ -639,6 +777,7 @@ class RepoConfigLoader(object): self.prepos = prepos self.prepos_order = prepos_order + self.ignored_repos = ignored_repos self.location_map = location_map self.treemap = treemap self._prepos_changed = True @@ -731,7 +870,7 @@ class RepoConfigLoader(object): self._check_locations() def repoLocationList(self): - """Get list of locations of repositories.""" + """Get a list of repositories location. Replaces PORTDIR_OVERLAY""" if self._prepos_changed: _repo_location_list = [] for repo in self.prepos_order: @@ -818,12 +957,12 @@ class RepoConfigLoader(object): return repo_name in self.prepos def config_string(self): - quoted_str_keys = ("location",) - str_or_int_keys = ("auto_sync", "format", "main_repo", "priority", + str_or_int_keys = ("auto_sync", "format", "location", + "main_repo", "priority", "sync_type", "sync_umask", "sync_uri", 'sync_user') str_tuple_keys = ("aliases", "eclass_overrides", "force") repo_config_tuple_keys = ("masters",) - keys = quoted_str_keys + str_or_int_keys + str_tuple_keys + repo_config_tuple_keys + keys = str_or_int_keys + str_tuple_keys + repo_config_tuple_keys config_string = "" for repo_name, repo in sorted(self.prepos.items(), key=lambda x: (x[0] != "DEFAULT", x[0])): config_string += "\n[%s]\n" % repo_name @@ -831,9 +970,7 @@ class RepoConfigLoader(object): if key == "main_repo" and repo_name != "DEFAULT": continue if getattr(repo, key) is not None: - if key in quoted_str_keys: - config_string += "%s = \"%s\"\n" % (key.replace("_", "-"), getattr(repo, key)) - elif key in str_or_int_keys: + if key in str_or_int_keys: config_string += "%s = %s\n" % (key.replace("_", "-"), getattr(repo, key)) elif key in str_tuple_keys: config_string += "%s = %s\n" % (key.replace("_", "-"), " ".join(getattr(repo, key))) diff --git a/pym/portage/tests/dbapi/test_fakedbapi.py b/pym/portage/tests/dbapi/test_fakedbapi.py index 1a1e4b3..e4f5dd7 100644 --- a/pym/portage/tests/dbapi/test_fakedbapi.py +++ b/pym/portage/tests/dbapi/test_fakedbapi.py @@ -48,7 +48,7 @@ class TestFakedbapi(TestCase): with open(os.path.join(test_repo, "profiles", "repo_name"), "w") as f: f.write("test_repo") env = { - "PORTAGE_REPOSITORIES": "[DEFAULT]\nmain-repo = test_repo\n[test_repo]\nlocation = '%s'" % test_repo + "PORTAGE_REPOSITORIES": "[DEFAULT]\nmain-repo = test_repo\n[test_repo]\nlocation = %s" % test_repo } # Tests may override portage.const.EPREFIX in order to diff --git a/pym/portage/tests/resolver/ResolverPlayground.py b/pym/portage/tests/resolver/ResolverPlayground.py index 6622685..6bdf2c7 100644 --- a/pym/portage/tests/resolver/ResolverPlayground.py +++ b/pym/portage/tests/resolver/ResolverPlayground.py @@ -502,7 +502,7 @@ class ResolverPlayground(object): create_trees_kwargs["target_root"] = self.target_root env = { - "PORTAGE_REPOSITORIES": "\n".join("[%s]\n%s" % (repo_name, "\n".join("%s = %s" % ((k, "'%s'" % v) if k == "location" else (k, v)) for k, v in repo_config.items())) for repo_name, repo_config in self._repositories.items()) + "PORTAGE_REPOSITORIES": "\n".join("[%s]\n%s" % (repo_name, "\n".join("%s = %s" % (k, v) for k, v in repo_config.items())) for repo_name, repo_config in self._repositories.items()) } trees = portage.create_trees(env=env, eprefix=self.eprefix, diff --git a/pym/portage/tests/sync/test_sync_local.py b/pym/portage/tests/sync/test_sync_local.py index 6911898..b57bdba 100644 --- a/pym/portage/tests/sync/test_sync_local.py +++ b/pym/portage/tests/sync/test_sync_local.py @@ -39,7 +39,7 @@ class SyncLocalTestCase(TestCase): [DEFAULT] %(default_keys)s [test_repo] - location = "%(EPREFIX)s/var/repositories/test_repo" + location = %(EPREFIX)s/var/repositories/test_repo sync-type = %(sync-type)s sync-uri = file:/%(EPREFIX)s/var/repositories/test_repo_sync auto-sync = yes diff --git a/pym/repoman/repos.py b/pym/repoman/repos.py index dd50663..e7b8463 100644 --- a/pym/repoman/repos.py +++ b/pym/repoman/repos.py @@ -133,7 +133,7 @@ class RepoSettings(object): self.repo_name = self.repo_conf._read_repo_name(portdir_overlay, quiet=True) tmp_conf_file = io.StringIO(textwrap.dedent(""" [%s] - location = "%s" + location = %s """) % (self.repo_name, portdir_overlay)) # Ensure that the repository corresponding to $PWD overrides a # repository of the same name referenced by the existing PORTDIR