* [gentoo-commits] proj/portage:master commit in: man/, pym/portage/repository/, pym/repoman/, pym/portage/tests/sync/, ...
@ 2015-12-09 8:44 Arfrever Frehtes Taifersar Arahesis
0 siblings, 0 replies; only message in thread
From: Arfrever Frehtes Taifersar Arahesis @ 2015-12-09 8:44 UTC (permalink / raw
To: gentoo-commits
commit: e7d95cbf1e0f8a209ac1417ae2ae89ef331becfc
Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Apache <DOT> Org>
AuthorDate: Wed Dec 9 08:34:26 2015 +0000
Commit: Arfrever Frehtes Taifersar Arahesis <arfrever <AT> apache <DOT> org>
CommitDate: Wed Dec 9 08:34:26 2015 +0000
URL: https://gitweb.gentoo.org/proj/portage.git/commit/?id=e7d95cbf
portage.repository.config.RepoConfig: Support location with trailing whitespace by using quoting.
configparser.ConfigParser strips initial and trailing whitespace.
bin/ebuild | 2 +-
bin/isolated-functions.sh | 20 +++++++++++++-------
man/portage.5 | 1 +
pym/portage/repository/config.py | 14 +++++++++-----
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 +-
8 files changed, 28 insertions(+), 17 deletions(-)
diff --git a/bin/ebuild b/bin/ebuild
index 1afad25..a696adf 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 5766921..a55d4a3 100644
--- a/bin/isolated-functions.sh
+++ b/bin/isolated-functions.sh
@@ -1,5 +1,5 @@
#!/bin/bash
-# Copyright 1999-2014 Gentoo Foundation
+# Copyright 1999-2015 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
source "${PORTAGE_BIN_PATH}/eapi.sh" || exit 1
@@ -473,17 +473,23 @@ has() {
}
__repo_attr() {
- local appropriate_section=0 exit_status=1 line saved_extglob_shopt=$(shopt -p extglob)
+ local appropriate_section=0 attribute=$2 exit_status=1 line repo_name=$1 saved_extglob_shopt=$(shopt -p extglob) value
shopt -s extglob
while read line; do
- [[ ${appropriate_section} == 0 && ${line} == "[$1]" ]] && appropriate_section=1 && continue
+ [[ ${appropriate_section} == 0 && ${line} == "[${repo_name}]" ]] && appropriate_section=1 && continue
[[ ${appropriate_section} == 1 && ${line} == "["*"]" ]] && appropriate_section=0 && continue
- # If a conditional expression like [[ ${line} == $2*( )=* ]] is used
- # then bash-3.2 produces an error like the following when the file is
+ # If a conditional expression like [[ ${line} == ${attribute}*( )=* ]] is used
+ # then bash <4.1 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} =~ ^${2}[[:space:]]*= ]]; then
- echo "${line##$2*( )=*( )}"
+ 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}"
exit_status=0
break
fi
diff --git a/man/portage.5 b/man/portage.5
index 6c41332..aa87e8f 100644
--- a/man/portage.5
+++ b/man/portage.5
@@ -956,6 +956,7 @@ 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/portage/repository/config.py b/pym/portage/repository/config.py
index fff619f..54d7688 100644
--- a/pym/portage/repository/config.py
+++ b/pym/portage/repository/config.py
@@ -143,6 +143,8 @@ 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)
@@ -420,7 +422,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:
@@ -957,12 +959,12 @@ class RepoConfigLoader(object):
return repo_name in self.prepos
def config_string(self):
- str_or_int_keys = ("auto_sync", "format", "location",
- "main_repo", "priority",
+ quoted_str_keys = ("location",)
+ str_or_int_keys = ("auto_sync", "format", "main_repo", "priority",
"sync_type", "sync_umask", "sync_uri", 'sync_user')
str_tuple_keys = ("aliases", "eclass_overrides", "force")
repo_config_tuple_keys = ("masters",)
- keys = str_or_int_keys + str_tuple_keys + repo_config_tuple_keys
+ keys = quoted_str_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
@@ -970,7 +972,9 @@ class RepoConfigLoader(object):
if key == "main_repo" and repo_name != "DEFAULT":
continue
if getattr(repo, key) is not None:
- if key in str_or_int_keys:
+ if key in quoted_str_keys:
+ config_string += "%s = \"%s\"\n" % (key.replace("_", "-"), getattr(repo, key))
+ elif 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 e4f5dd7..1a1e4b3 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 6bdf2c7..6622685 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, 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, "'%s'" % v) if k == "location" else (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 b57bdba..6911898 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 e7b8463..dd50663 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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2015-12-09 8:44 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-09 8:44 [gentoo-commits] proj/portage:master commit in: man/, pym/portage/repository/, pym/repoman/, pym/portage/tests/sync/, Arfrever Frehtes Taifersar Arahesis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox