aboutsummaryrefslogtreecommitdiffstats
path: root/MgaRepo
diff options
context:
space:
mode:
authorPer Øyvind Karlsen <proyvind@moondrake.org>2016-08-18 17:54:49 +0200
committerPer Øyvind Karlsen <proyvind@moondrake.org>2016-08-18 17:54:49 +0200
commit14d5c0398fa649f03b6e0f43ab811594890a9a91 (patch)
tree5832bda72bf1f163f6c31ffb93cdfa431b292adf /MgaRepo
parentcd6cad27819e2e1a16a1a17a9b3cb80dd921ed3f (diff)
downloadmgarepo-14d5c0398fa649f03b6e0f43ab811594890a9a91.tar
mgarepo-14d5c0398fa649f03b6e0f43ab811594890a9a91.tar.gz
mgarepo-14d5c0398fa649f03b6e0f43ab811594890a9a91.tar.bz2
mgarepo-14d5c0398fa649f03b6e0f43ab811594890a9a91.tar.xz
mgarepo-14d5c0398fa649f03b6e0f43ab811594890a9a91.zip
auomatically fallback to non-ssh when authentication fails
Diffstat (limited to 'MgaRepo')
-rw-r--r--MgaRepo/VCS.py9
-rw-r--r--MgaRepo/layout.py4
-rw-r--r--MgaRepo/log.py4
-rw-r--r--MgaRepo/svn.py11
4 files changed, 23 insertions, 5 deletions
diff --git a/MgaRepo/VCS.py b/MgaRepo/VCS.py
index ee419f4..4edbd7f 100644
--- a/MgaRepo/VCS.py
+++ b/MgaRepo/VCS.py
@@ -36,7 +36,9 @@ class VCS(object):
self._path = layout.package_name(layout.remove_current(url))
else:
self._path = path
- self._url = url
+ # FIXME
+ self._url = None
+ self.__url = url
def _execVcs(self, *args, **kwargs):
localcmds = ("add", "revert", "cleanup", "mv")
@@ -400,6 +402,9 @@ class VCS(object):
else:
return None
+ def drop_ssh_if_no_auth(self, url):
+ return url
+
@property
def path(self):
return self._path
@@ -407,7 +412,7 @@ class VCS(object):
@property
def url(self):
if not self._url:
- self._url = self.info2(self._path)["URL"]
+ self._url = self.drop_ssh_if_no_auth(self.__url or self.info2(self._path)["URL"])
return self._url
class VCSLook(object):
diff --git a/MgaRepo/layout.py b/MgaRepo/layout.py
index 97f634d..ce39eac 100644
--- a/MgaRepo/layout.py
+++ b/MgaRepo/layout.py
@@ -5,6 +5,7 @@ import urllib.parse
from MgaRepo import Error, config
from MgaRepo.svn import SVN
+from MgaRepo.rpmutil import detectVCS
__all__ = ["package_url", "checkout_url", "repository_url", "get_url_revision"]
@@ -132,7 +133,8 @@ def repository_url(mirrored=False):
raise Error("you need to set the 'repository' " \
"configuration option on mgarepo.conf")
url = convert_default_parent(default_parent)
- return url
+ vcs = detectVCS(url)
+ return vcs.url
def package_url(name_or_url, version=None, release=None, distro=None, backports=None,
mirrored=True, obsolete=None):
diff --git a/MgaRepo/log.py b/MgaRepo/log.py
index 818a876..8e062ad 100644
--- a/MgaRepo/log.py
+++ b/MgaRepo/log.py
@@ -570,14 +570,14 @@ def get_old_log(pkgdirurl):
chlog = StringIO()
oldurl = config.get("log", "oldurl")
if oldurl:
- svn = SVN()
+ svn = SVN(url=oldurl)
tmpdir = tempfile.mktemp()
try:
if oldurl == '.' or oldurl.startswith('./'):
pkgoldurl = os.path.join(pkgdirurl, oldurl)
else:
pkgname = layout.package_name(pkgdirurl)
- pkgoldurl = os.path.join(oldurl, pkgname)
+ pkgoldurl = os.path.join(svn.url, pkgname)
try:
# we're using HEAD here because fixes in misc/ (oldurl) may
# be newer than packages' last changed revision.
diff --git a/MgaRepo/svn.py b/MgaRepo/svn.py
index 5f8851c..cc1ed1b 100644
--- a/MgaRepo/svn.py
+++ b/MgaRepo/svn.py
@@ -19,6 +19,17 @@ class SVN(VCS):
self.vcs_command = config.get("global", "svn-command", ["svn"])
self.env_defaults = {"SVN_SSH": self.vcs_wrapper}
+ def drop_ssh_if_no_auth(self, url):
+ if url and url.startswith("svn+ssh://"):
+ cmd = ["info", "--non-interactive", "--no-newline", "--show-item", "url", url]
+ status, output = self._execVcs(*cmd, local=True, noerror=True, show=False)
+ if status == 1 and (("E170013" in output) or ("E210002" in output)):
+ url = url.replace("svn+ssh://", "svn://")
+ status, output = self._execVcs(*cmd, local=True, noerror=True, show=False)
+ if status == 0 and output == url:
+ pass
+ return url
+
class SVNLook(VCSLook):
def __init__(self, repospath, txn=None, rev=None):
VCSLook.__init__(self, repospath, txn, rev)