aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pym/repoman/_xml.py16
-rw-r--r--pym/repoman/metadata.py39
-rw-r--r--pym/repoman/modules/scan/metadata/__init__.py2
-rw-r--r--pym/repoman/modules/scan/metadata/pkgmetadata.py6
-rw-r--r--pym/repoman/scanner.py8
5 files changed, 36 insertions, 35 deletions
diff --git a/pym/repoman/_xml.py b/pym/repoman/_xml.py
index f7ff9fbe5..2291755a5 100644
--- a/pym/repoman/_xml.py
+++ b/pym/repoman/_xml.py
@@ -12,7 +12,7 @@ from portage import os
from portage.output import red
from portage.process import find_binary
-from repoman.metadata import fetch_metadata_dtd
+from repoman.metadata import fetch_metadata_xsd
from repoman._subprocess import repoman_getstatusoutput
@@ -53,12 +53,12 @@ class _MetadataTreeBuilder(xml.etree.ElementTree.TreeBuilder):
class XmlLint(object):
- def __init__(self, options, repoman_settings, metadata_dtd=None):
- self.metadata_dtd = (metadata_dtd or
- os.path.join(repoman_settings["DISTDIR"], 'metadata.dtd'))
+ def __init__(self, options, repoman_settings, metadata_xsd=None):
+ self.metadata_xsd = (metadata_xsd or
+ os.path.join(repoman_settings["DISTDIR"], 'metadata.xsd'))
self.options = options
self.repoman_settings = repoman_settings
- self._is_capable = metadata_dtd is not None
+ self._is_capable = metadata_xsd is not None
self.binary = None
self._is_capable = False
self._check_capable()
@@ -70,7 +70,7 @@ class XmlLint(object):
if not self.binary:
print(red("!!! xmllint not found. Can't check metadata.xml.\n"))
elif not self._is_capable:
- if not fetch_metadata_dtd(self.metadata_dtd, self.repoman_settings):
+ if not fetch_metadata_xsd(self.metadata_xsd, self.repoman_settings):
sys.exit(1)
# this can be problematic if xmllint changes their output
self._is_capable = True
@@ -94,8 +94,8 @@ class XmlLint(object):
# xmlint can produce garbage output even on success, so only dump
# the ouput when it fails.
st, out = repoman_getstatusoutput(
- self.binary + " --nonet --noout --dtdvalid %s %s" % (
- portage._shell_quote(self.metadata_dtd),
+ self.binary + " --nonet --noout --schema %s %s" % (
+ portage._shell_quote(self.metadata_xsd),
portage._shell_quote(
os.path.join(checkdir, "metadata.xml"))))
if st != os.EX_OK:
diff --git a/pym/repoman/metadata.py b/pym/repoman/metadata.py
index e95ad4144..7a514dc51 100644
--- a/pym/repoman/metadata.py
+++ b/pym/repoman/metadata.py
@@ -33,8 +33,9 @@ metadata_xml_declaration = '<?xml version="1.0" encoding="%s"?>' \
% (metadata_xml_encoding,)
metadata_doctype_name = 'pkgmetadata'
metadata_dtd_uri = 'http://www.gentoo.org/dtd/metadata.dtd'
+metadata_xsd_uri = 'http://www.gentoo.org/xml-schema/metadata.xsd'
# force refetch if the local copy creation time is older than this
-metadata_dtd_ctime_interval = 60 * 60 * 24 * 7 # 7 days
+metadata_xsd_ctime_interval = 60 * 60 * 24 * 7 # 7 days
def parse_metadata_use(xml_tree):
@@ -86,36 +87,36 @@ def parse_metadata_use(xml_tree):
return uselist
-def fetch_metadata_dtd(metadata_dtd, repoman_settings):
+def fetch_metadata_xsd(metadata_xsd, repoman_settings):
"""
- Fetch metadata.dtd if it doesn't exist or the ctime is older than
- metadata_dtd_ctime_interval.
+ Fetch metadata.xsd if it doesn't exist or the ctime is older than
+ metadata_xsd_ctime_interval.
@rtype: bool
@return: True if successful, otherwise False
"""
must_fetch = True
- metadata_dtd_st = None
+ metadata_xsd_st = None
current_time = int(time.time())
try:
- metadata_dtd_st = os.stat(metadata_dtd)
+ metadata_xsd_st = os.stat(metadata_xsd)
except EnvironmentError as e:
if e.errno not in (errno.ENOENT, errno.ESTALE):
raise
del e
else:
- # Trigger fetch if metadata.dtd mtime is old or clock is wrong.
- if abs(current_time - metadata_dtd_st.st_ctime) \
- < metadata_dtd_ctime_interval:
+ # Trigger fetch if metadata.xsd mtime is old or clock is wrong.
+ if abs(current_time - metadata_xsd_st.st_ctime) \
+ < metadata_xsd_ctime_interval:
must_fetch = False
if must_fetch:
print()
print(
- "%s the local copy of metadata.dtd "
+ "%s the local copy of metadata.xsd "
"needs to be refetched, doing that now" % green("***"))
print()
- parsed_url = urlparse(metadata_dtd_uri)
+ parsed_url = urlparse(metadata_xsd_uri)
setting = 'FETCHCOMMAND_' + parsed_url.scheme.upper()
fcmd = repoman_settings.get(setting)
if not fcmd:
@@ -125,29 +126,29 @@ def fetch_metadata_dtd(metadata_dtd, repoman_settings):
return False
destdir = repoman_settings["DISTDIR"]
- fd, metadata_dtd_tmp = tempfile.mkstemp(
- prefix='metadata.dtd.', dir=destdir)
+ fd, metadata_xsd_tmp = tempfile.mkstemp(
+ prefix='metadata.xsd.', dir=destdir)
os.close(fd)
try:
if not portage.getbinpkg.file_get(
- metadata_dtd_uri, destdir, fcmd=fcmd,
- filename=os.path.basename(metadata_dtd_tmp)):
+ metadata_xsd_uri, destdir, fcmd=fcmd,
+ filename=os.path.basename(metadata_xsd_tmp)):
logging.error(
- "failed to fetch metadata.dtd from '%s'" % metadata_dtd_uri)
+ "failed to fetch metadata.xsd from '%s'" % metadata_xsd_uri)
return False
try:
portage.util.apply_secpass_permissions(
- metadata_dtd_tmp,
+ metadata_xsd_tmp,
gid=portage.data.portage_gid, mode=0o664, mask=0o2)
except portage.exception.PortageException:
pass
- shutil.move(metadata_dtd_tmp, metadata_dtd)
+ shutil.move(metadata_xsd_tmp, metadata_xsd)
finally:
try:
- os.unlink(metadata_dtd_tmp)
+ os.unlink(metadata_xsd_tmp)
except OSError:
pass
diff --git a/pym/repoman/modules/scan/metadata/__init__.py b/pym/repoman/modules/scan/metadata/__init__.py
index 90981d876..b2463fc72 100644
--- a/pym/repoman/modules/scan/metadata/__init__.py
+++ b/pym/repoman/modules/scan/metadata/__init__.py
@@ -18,7 +18,7 @@ module_spec = {
'functions': ['check'],
'func_desc': {
},
- 'mod_kwargs': ['repo_settings', 'qatracker', 'options', 'metadata_dtd',
+ 'mod_kwargs': ['repo_settings', 'qatracker', 'options', 'metadata_xsd',
],
'func_kwargs': {
},
diff --git a/pym/repoman/modules/scan/metadata/pkgmetadata.py b/pym/repoman/modules/scan/metadata/pkgmetadata.py
index 030cbcaad..fa73bb53b 100644
--- a/pym/repoman/modules/scan/metadata/pkgmetadata.py
+++ b/pym/repoman/modules/scan/metadata/pkgmetadata.py
@@ -46,17 +46,17 @@ class PkgMetadata(ScanBase):
@param repo_settings: settings instance
@param qatracker: QATracker instance
@param options: argparse options instance
- @param metadata_dtd: path of metadata.dtd
+ @param metadata_xsd: path of metadata.xsd
'''
super(PkgMetadata, self).__init__(**kwargs)
repo_settings = kwargs.get('repo_settings')
self.qatracker = kwargs.get('qatracker')
self.options = kwargs.get('options')
- metadata_dtd = kwargs.get('metadata_dtd')
+ metadata_xsd = kwargs.get('metadata_xsd')
self.repoman_settings = repo_settings.repoman_settings
self.musedict = {}
self.xmllint = XmlLint(self.options, self.repoman_settings,
- metadata_dtd=metadata_dtd)
+ metadata_xsd=metadata_xsd)
def check(self, **kwargs):
'''Performs the checks on the metadata.xml for the package
diff --git a/pym/repoman/scanner.py b/pym/repoman/scanner.py
index a9f56e9c5..3bd9684df 100644
--- a/pym/repoman/scanner.py
+++ b/pym/repoman/scanner.py
@@ -54,11 +54,11 @@ class Scanner(object):
portage.util.stack_lists([self.categories], incremental=1))
self.categories = self.repo_settings.repoman_settings.categories
- metadata_dtd = None
+ metadata_xsd = None
for path in reversed(self.repo_settings.repo_config.eclass_db.porttrees):
- path = os.path.join(path, 'metadata/dtd/metadata.dtd')
+ path = os.path.join(path, 'metadata/xml-schema/metadata.xsd')
if os.path.exists(path):
- metadata_dtd = path
+ metadata_xsd = path
break
self.portdb = repo_settings.portdb
@@ -184,7 +184,7 @@ class Scanner(object):
"qatracker": self.qatracker,
"vcs_settings": self.vcs_settings,
"options": self.options,
- "metadata_dtd": metadata_dtd,
+ "metadata_xsd": metadata_xsd,
"uselist": uselist,
"checks": self.checks,
"repo_metadata": self.repo_metadata,