2017-10-10 13:18:19 +02:00
|
|
|
From 33b3aab641f6f71f33fd87f1e1b41ea2e74f48e3 Mon Sep 17 00:00:00 2001
|
|
|
|
From: Dirk Mueller <dirk@dmllr.de>
|
|
|
|
Date: Sun, 1 Oct 2017 14:36:40 +0200
|
2017-10-10 13:21:54 +02:00
|
|
|
Subject: [PATCH] Validate Appdata also when appstream-util is unavailable
|
2017-10-10 13:18:19 +02:00
|
|
|
|
|
|
|
When the dependency isn't installed, we can at least still
|
|
|
|
validate whether the input is valid XML or not. As we're
|
|
|
|
not printing any validation results anyway this is good
|
|
|
|
enough.
|
|
|
|
---
|
|
|
|
AppDataCheck.py | 14 ++++++++++----
|
|
|
|
1 file changed, 10 insertions(+), 4 deletions(-)
|
|
|
|
|
2017-10-10 13:21:54 +02:00
|
|
|
Index: rpmlint-rpmlint-1.10/AppDataCheck.py
|
|
|
|
===================================================================
|
|
|
|
--- rpmlint-rpmlint-1.10.orig/AppDataCheck.py
|
|
|
|
+++ rpmlint-rpmlint-1.10/AppDataCheck.py
|
2017-10-10 13:18:19 +02:00
|
|
|
@@ -10,6 +10,7 @@ import AbstractCheck
|
|
|
|
import Config
|
|
|
|
from Filter import addDetails, printError
|
|
|
|
from Pkg import getstatusoutput
|
|
|
|
+import xml.etree.ElementTree as ET
|
|
|
|
|
|
|
|
STANDARD_BIN_DIRS = ['/bin/', '/sbin/', '/usr/bin/', '/usr/sbin/']
|
|
|
|
DEFAULT_APPDATA_CHECKER = ('appstream-util', 'validate-relax')
|
2017-10-10 13:21:54 +02:00
|
|
|
@@ -28,12 +29,18 @@ class AppDataCheck(AbstractCheck.Abstrac
|
|
|
|
def check_file(self, pkg, filename):
|
|
|
|
root = pkg.dirName()
|
|
|
|
f = root + filename
|
2017-10-10 13:18:19 +02:00
|
|
|
+ validation_failed = False
|
|
|
|
try:
|
2017-10-10 13:21:54 +02:00
|
|
|
st = getstatusoutput(appdata_checker + (f,))
|
2017-10-10 13:18:19 +02:00
|
|
|
+ # Return code nonzero?
|
|
|
|
+ validation_failed = (st[0] != 0)
|
|
|
|
except OSError:
|
|
|
|
- # ignore if the checker is not installed
|
|
|
|
- return
|
|
|
|
- if st[0]:
|
|
|
|
+ # checker is not installed, do a validation manually
|
|
|
|
+ try:
|
|
|
|
+ ET.parse(pkg.dirName() + filename)
|
|
|
|
+ except ET.ParseError:
|
|
|
|
+ validation_failed = True
|
|
|
|
+ if validation_failed:
|
|
|
|
printError(pkg, 'invalid-appdata-file', filename)
|
|
|
|
|
|
|
|
|