diff --git a/pisi/api.py b/pisi/api.py index 97b8d468..6b3f9b4b 100644 --- a/pisi/api.py +++ b/pisi/api.py @@ -838,6 +838,8 @@ def __update_repo(repo, force=False): else: return + repodb.check_distribution(repo) + try: index.check_signature(repouri, repo) except pisi.file.NoSignatureFound, e: diff --git a/pisi/cli/addrepo.py b/pisi/cli/addrepo.py index e921af79..0c41d72a 100644 --- a/pisi/cli/addrepo.py +++ b/pisi/cli/addrepo.py @@ -89,8 +89,6 @@ NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment if not ctx.get_option('no_fetch'): try: pisi.api.update_repo(name) - if not ctx.get_option('ignore_check'): - self.check_distro(name) except (pisi.fetcher.FetchError, IOError): warning = _("%s repository could not be reached. Removing %s from system.") % (name, name) self.warn_and_remove(warning, name) diff --git a/pisi/db/repodb.py b/pisi/db/repodb.py index 51729f3d..8b47b767 100644 --- a/pisi/db/repodb.py +++ b/pisi/db/repodb.py @@ -27,6 +27,9 @@ import pisi.db.lazydb as lazydb class RepoError(pisi.Error): pass +class IncompatibleRepoError(RepoError): + pass + class Repo: def __init__(self, indexuri): self.indexuri = indexuri @@ -225,19 +228,22 @@ class RepoDB(lazydb.LazyDB): def get_distribution(self, name): doc = self.get_repo_doc(name) - return doc.getTag("Distribution").getTagData("DistributionName") + return doc.getTag("Distribution").getTagData("SourceName") def get_distribution_release(self, name): doc = self.get_repo_doc(name) return doc.getTag("Distribution").getTagData("Version") def check_distribution(self, name): + if ctx.get_option('ignore_check'): + return + dist_name = self.get_distribution(name) dist_release = self.get_distribution_release(name) - if not dist_name: - # If distribution info is not available, ignore for now. - return True - - return dist_name == ctx.config.values.general.distribution and \ - dist_release == ctx.config.values.general.distribution_release + if dist_name != ctx.config.values.general.distribution or \ + dist_release != ctx.config.values.general.distribution_release: + self.deactivate_repo(name) + raise IncompatibleRepoError( + _("Repository '%s' is not compatible with your " + "distribution. Repository is disabled.") % name)