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:
@@ -805,6 +805,14 @@ def __update_repo(repo, force=False):
|
|||||||
index.read_uri_of_repo(repouri, repo, force = force)
|
index.read_uri_of_repo(repouri, repo, force = force)
|
||||||
else:
|
else:
|
||||||
return
|
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:
|
try:
|
||||||
index.check_signature(repouri, repo)
|
index.check_signature(repouri, repo)
|
||||||
|
|||||||
@@ -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",
|
group.add_option("--at", action="store",
|
||||||
type="int", default=None,
|
type="int", default=None,
|
||||||
help=_("Add repository at given position (0 is first)"))
|
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)
|
self.parser.add_option_group(group)
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
|
|||||||
+27
-2
@@ -34,6 +34,16 @@ import pisi.group as group
|
|||||||
class Error(pisi.Error):
|
class Error(pisi.Error):
|
||||||
pass
|
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):
|
class Index(xmlfile.XmlFile):
|
||||||
__metaclass__ = autoxml.autoxml
|
__metaclass__ = autoxml.autoxml
|
||||||
|
|
||||||
@@ -50,7 +60,7 @@ class Index(xmlfile.XmlFile):
|
|||||||
return self.distribution.name + self.distribution.repositoryname
|
return self.distribution.name + self.distribution.repositoryname
|
||||||
|
|
||||||
def read_uri(self, uri, tmpdir, force = False):
|
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)
|
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
|
# 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.write(uri) # uri
|
||||||
urlfile.close()
|
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:
|
if not repo:
|
||||||
repo = self.distribution.name()
|
repo = self.distribution.name()
|
||||||
@@ -81,6 +95,17 @@ class Index(xmlfile.XmlFile):
|
|||||||
tmpdir = os.path.join(ctx.config.index_dir(), repo)
|
tmpdir = os.path.join(ctx.config.index_dir(), repo)
|
||||||
pisi.file.File.check_signature(filename, tmpdir)
|
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):
|
def index(self, repo_uri, skip_sources=False):
|
||||||
self.repo_dir = repo_uri
|
self.repo_dir = repo_uri
|
||||||
|
|
||||||
|
|||||||
@@ -440,11 +440,11 @@ class autoxml(oo.autosuper, oo.autoprop):
|
|||||||
def read(self, uri, keepDoc = False, tmpDir = '/tmp',
|
def read(self, uri, keepDoc = False, tmpDir = '/tmp',
|
||||||
sha1sum = False, compress = None, sign = None, copylocal = False, nodecode = False):
|
sha1sum = False, compress = None, sign = None, copylocal = False, nodecode = False):
|
||||||
"read XML file and decode it into a python object"
|
"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)
|
compress=compress, sign=sign, copylocal=copylocal)
|
||||||
|
|
||||||
if nodecode:
|
if nodecode:
|
||||||
return
|
return read_xml
|
||||||
|
|
||||||
errs = []
|
errs = []
|
||||||
self.decode(self.rootNode(), errs)
|
self.decode(self.rootNode(), errs)
|
||||||
|
|||||||
Reference in New Issue
Block a user