From 8982407c4d2f70054db5b4caeed0e12a41c8a8b8088f4ff485dc9084ebda6568 Mon Sep 17 00:00:00 2001 From: Dirk Mueller Date: Tue, 10 Oct 2017 11:18:19 +0000 Subject: [PATCH] add 0007-Validate-Appdata-also-when-appstream-util-is-unavail.patch OBS-URL: https://build.opensuse.org/package/show/devel:openSUSE:Factory:rpmlint/rpmlint?expand=0&rev=521 --- ...-also-when-appstream-util-is-unavail.patch | 51 +++++++++++++++++++ rpmlint.changes | 1 + rpmlint.spec | 1 + 3 files changed, 53 insertions(+) create mode 100644 0007-Validate-Appdata-also-when-appstream-util-is-unavail.patch diff --git a/0007-Validate-Appdata-also-when-appstream-util-is-unavail.patch b/0007-Validate-Appdata-also-when-appstream-util-is-unavail.patch new file mode 100644 index 0000000..1dd74c7 --- /dev/null +++ b/0007-Validate-Appdata-also-when-appstream-util-is-unavail.patch @@ -0,0 +1,51 @@ +From 33b3aab641f6f71f33fd87f1e1b41ea2e74f48e3 Mon Sep 17 00:00:00 2001 +From: Dirk Mueller +Date: Sun, 1 Oct 2017 14:36:40 +0200 +Subject: [PATCH 7/7] Validate Appdata also when appstream-util is unavailable + +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(-) + +diff --git a/AppDataCheck.py b/AppDataCheck.py +index 20302d8..b714f31 100644 +--- a/AppDataCheck.py ++++ b/AppDataCheck.py +@@ -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') +@@ -32,13 +33,18 @@ class AppDataCheck(AbstractCheck.AbstractFilesCheck): + checker = appdata_checker + if checker[0] == "appstream-util" and not self.network_enabled: + checker += ("--nonet",) +- print(checker) ++ validation_failed = False + try: + st = getstatusoutput(checker + (f,)) ++ # 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) + + +-- +2.14.1 + diff --git a/rpmlint.changes b/rpmlint.changes index e932e7f..96e789b 100644 --- a/rpmlint.changes +++ b/rpmlint.changes @@ -2,6 +2,7 @@ Tue Oct 10 09:06:23 UTC 2017 - dmueller@suse.com - add 0001-Avoid-false-positives-on-is_elf-check.patch (bsc#1057216) + add 0007-Validate-Appdata-also-when-appstream-util-is-unavail.patch - Update rpmlint-checks to version master: * Fix false positives for -theme- -> -branding- rename * Stop leaking filedescriptors diff --git a/rpmlint.spec b/rpmlint.spec index 68f997e..83f13ad 100644 --- a/rpmlint.spec +++ b/rpmlint.spec @@ -84,6 +84,7 @@ Patch65: 0001-split-wrong-script-interpreter-into-env-script-inter.patch Patch66: 0001-Handle-post-scripts-that-contain-non-ascii-character.patch Patch67: omit_BUILDROOT_from_pyo_files.patch Patch68: 0001-Avoid-false-positives-on-is_elf-check.patch +Patch69: 0007-Validate-Appdata-also-when-appstream-util-is-unavail.patch Patch70: rpmlint-all-pie.patch BuildRequires: obs-service-format_spec_file BuildRequires: python3-flake8