Add new option to pisi ar : --ignore-check

Now, pisi checks distribution release and architecture types of pisi-index.xml files when adding the repository.
To skip this feature, use --ignore-check parameter.

To use this feature effectively for architectures; while creating distribution.xml files, Architecture tag should be added.
Otherwise, Architecture check is skipped.
This commit is contained in:
Serdar Dalgıç
2009-12-14 11:55:00 +00:00
parent 89f509fbff
commit 5649b03ea7
4 changed files with 40 additions and 4 deletions
+8
View File
@@ -805,6 +805,14 @@ def __update_repo(repo, force=False):
index.read_uri_of_repo(repouri, repo, force = force)
else:
return
except pisi.index.NotCompatibleDistroException, e:
ctx.ui.warning(e)
remove_repo(repo)
return
except pisi.index.NotCompatibleArchException, e:
ctx.ui.warning(e)
remove_repo(repo)
return
try:
index.check_signature(repouri, repo)
+3
View File
@@ -45,6 +45,9 @@ NB: We support only local files (e.g., /a/b/c) and http:// URIs at the moment
group.add_option("--at", action="store",
type="int", default=None,
help=_("Add repository at given position (0 is first)"))
group.add_option("--ignore-check", action="store_true",
default=False,
help=_("Ignore distribution release and architecture checks"))
self.parser.add_option_group(group)
def run(self):
+27 -2
View File
@@ -34,6 +34,16 @@ import pisi.group as group
class Error(pisi.Error):
pass
class NotCompatibleDistroException(pisi.Exception):
def __init__(self, repoVersion, curDistro, curDistVersion):
pisi.Exception.__init__(self, "Opps, sorry, this repository for %s is not compatible with your distribution release %s %s." \
% (repoVersion, curDistro, curDistVersion))
class NotCompatibleArchException(pisi.Exception):
def __init__(self, repoArch, curArch):
pisi.Exception.__init__(self, "Opps, sorry, repo architecture %s is not compatible with your %s architecture." \
% (repoArch, curArch))
class Index(xmlfile.XmlFile):
__metaclass__ = autoxml.autoxml
@@ -50,7 +60,7 @@ class Index(xmlfile.XmlFile):
return self.distribution.name + self.distribution.repositoryname
def read_uri(self, uri, tmpdir, force = False):
self.read(uri, tmpDir=tmpdir, sha1sum=not force,
return self.read(uri, tmpDir=tmpdir, sha1sum=not force,
compress=pisi.file.File.auto, sign=pisi.file.File.detached, copylocal = True, nodecode = True)
# read index for a given repo, force means download even if remote not updated
@@ -68,7 +78,11 @@ class Index(xmlfile.XmlFile):
urlfile.write(uri) # uri
urlfile.close()
self.read_uri(uri, tmpdir, force)
doc = self.read_uri(uri, tmpdir, force)
# check packages' DistributionReleases and Architecture
if not ctx.get_option('ignore_check'):
self.check_distro_and_arch(doc)
if not repo:
repo = self.distribution.name()
@@ -81,6 +95,17 @@ class Index(xmlfile.XmlFile):
tmpdir = os.path.join(ctx.config.index_dir(), repo)
pisi.file.File.check_signature(filename, tmpdir)
def check_distro_and_arch(self, doc):
config = pisi.configfile.ConfigurationFile("/etc/pisi/pisi.conf")
if doc.getTag("Distribution").getTagData("Version") != config.get("general", "distribution_release"):
raise NotCompatibleDistroException(doc.getTag("Distribution").getTagData("Version"), \
config.get("general", "distribution"), config.get("general", "distribution_release"))
if doc.getTag("Distribution").getTagData("Architecture"):
# First check if Architecture tag exists in index.xml; if not, directly skip it ;)
if doc.getTag("Distribution").getTagData("Architecture") != config.get("general", "architecture"):
raise NotCompatibleArchException(doc.getTag("Distribution").getTagData("Architecture"), \
config.get("general", "architecture"))
def index(self, repo_uri, skip_sources=False):
self.repo_dir = repo_uri
+2 -2
View File
@@ -440,11 +440,11 @@ class autoxml(oo.autosuper, oo.autoprop):
def read(self, uri, keepDoc = False, tmpDir = '/tmp',
sha1sum = False, compress = None, sign = None, copylocal = False, nodecode = False):
"read XML file and decode it into a python object"
self.readxml(uri, tmpDir, sha1sum=sha1sum,
read_xml = self.readxml(uri, tmpDir, sha1sum=sha1sum,
compress=compress, sign=sign, copylocal=copylocal)
if nodecode:
return
return read_xml
errs = []
self.decode(self.rootNode(), errs)