[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

[PATCH] Fix dep11 validation and enable it again



Hi!
The patch below will fix the dep11 validation in dak, so it's safe to
enable that again (also done in this patch).
We had no occasions of the appstream-generator running out of memory
in the past weeks, but just in case the data for ftpmasters is now
rsynced into a dedicated directory on mekeel.d.o
(/srv/appstream.debian.org/ftpmaster/) so this should never break dak
even if things go bad at mekeel (with the exception of mekeel going
offline completely).
Patch is attached as well, because GMail likes to insert linebreaks in
mail occasionally.

Cheers,
    Matthias

>From 3d7e2cc265348bcf023adc93dbcf8832870c6a65 Mon Sep 17 00:00:00 2001
From: Matthias Klumpp <mak@debian.org>
Date: Tue, 5 Dec 2017 21:19:58 +0100
Subject: [PATCH] Fix dep11 validation and enable it again

Web-applications don't need to have a package defined.
---
 config/debian/dinstall.tasks           |  2 +-
 scripts/debian/dep11-basic-validate.py | 22 +++++++++++++---------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/config/debian/dinstall.tasks b/config/debian/dinstall.tasks
index bd1b421a3..adf9183bd 100644
--- a/config/debian/dinstall.tasks
+++ b/config/debian/dinstall.tasks
@@ -8,7 +8,7 @@ bugdoctxt              none
External\ Updates          fal
 mailingliststxt        none                       none
       false   true
 pseudopackages         none                       none
       false   true
 i18n1                  none                       i18n\ 1
       false   false
-#dep11                  none                       dep11\ 1
        false   true
+dep11                  none                       dep11\ 1
       false   true
 NOSTAGE                lockaccepted               none
       false   false
 punew                  stable-new                 p-u-new
       false   false
 opunew                 oldstable-new              o-p-u-new
       false   false
diff --git a/scripts/debian/dep11-basic-validate.py
b/scripts/debian/dep11-basic-validate.py
index 40935da0d..17b125d0f 100755
--- a/scripts/debian/dep11-basic-validate.py
+++ b/scripts/debian/dep11-basic-validate.py
@@ -42,7 +42,7 @@ schema_component = Schema({
     Required('Type'): All(str, Length(min=1)),
     Required('ID'): All(str, Length(min=1)),
     Required('Name'): All(dict, Length(min=1), schema_translated),
-    Required('Package'): All(str, Length(min=1)),
+    Required('Summary'): All(dict, Length(min=1)),
 }, extra = True)

 def add_issue(msg):
@@ -99,35 +99,39 @@ def validate_data(data):
             ret = False

         for doc in docs:
-            docid = doc.get('ID')
+            cptid = doc.get('ID')
             pkgname = doc.get('Package')
-            if not pkgname:
-                pkgname = "?unknown?"
+            cpttype = doc.get('Type')
             if not doc:
                 add_issue("FATAL: Empty document found.")
                 ret = False
                 continue
-            if not docid:
+            if not cptid:
                 add_issue("FATAL: Component without ID found.")
                 ret = False
                 continue
+            if not pkgname:
+                if cpttype != "web-application":
+                    add_issue("[%s]: %s" % (cptid, "Component is
missing a 'Package' key."))
+                    ret = False
+                    continue

             try:
                 schema_component(doc)
             except Exception as e:
-                add_issue("[%s]: %s" % (docid, str(e)))
+                add_issue("[%s]: %s" % (cptid, str(e)))
                 ret = False
                 continue

             # more tests for the icon key
             icon = doc.get('Icon')
-            if (doc['Type'] == "desktop-app") or (doc['Type'] == "web-app"):
+            if (cpttype == "desktop-application") or (cpttype ==
"web-application"):
                 if not doc.get('Icon'):
-                    add_issue("[%s]: %s" % (docid, "Components
containing an application must have an 'Icon' key."))
+                    add_issue("[%s]: %s" % (cptid, "Components
containing an application must have an 'Icon' key."))
                     ret = False
             if icon:
                 if (not icon.get('stock')) and (not
icon.get('cached')) and (not icon.get('local')):
-                    add_issue("[%s]: %s" % (docid, "A 'stock',
'cached' or 'local' icon must at least be provided. @ data['Icon']"))
+                    add_issue("[%s]: %s" % (cptid, "A 'stock',
'cached' or 'local' icon must at least be provided. @ data['Icon']"))
                     ret = False

             if not test_localized(doc, 'Name'):
-- 
2.15.0
From 3d7e2cc265348bcf023adc93dbcf8832870c6a65 Mon Sep 17 00:00:00 2001
From: Matthias Klumpp <matthias@tenstral.net>
Date: Tue, 5 Dec 2017 21:19:58 +0100
Subject: [PATCH] Fix dep11 validation and enable it again

Web-applications don't need to have a package defined.
---
 config/debian/dinstall.tasks           |  2 +-
 scripts/debian/dep11-basic-validate.py | 22 +++++++++++++---------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/config/debian/dinstall.tasks b/config/debian/dinstall.tasks
index bd1b421a3..adf9183bd 100644
--- a/config/debian/dinstall.tasks
+++ b/config/debian/dinstall.tasks
@@ -8,7 +8,7 @@ bugdoctxt              none                       External\ Updates          fal
 mailingliststxt        none                       none                       false   true
 pseudopackages         none                       none                       false   true
 i18n1                  none                       i18n\ 1                    false   false
-#dep11                  none                       dep11\ 1                   false   true
+dep11                  none                       dep11\ 1                   false   true
 NOSTAGE                lockaccepted               none                       false   false
 punew                  stable-new                 p-u-new                    false   false
 opunew                 oldstable-new              o-p-u-new                  false   false
diff --git a/scripts/debian/dep11-basic-validate.py b/scripts/debian/dep11-basic-validate.py
index 40935da0d..17b125d0f 100755
--- a/scripts/debian/dep11-basic-validate.py
+++ b/scripts/debian/dep11-basic-validate.py
@@ -42,7 +42,7 @@ schema_component = Schema({
     Required('Type'): All(str, Length(min=1)),
     Required('ID'): All(str, Length(min=1)),
     Required('Name'): All(dict, Length(min=1), schema_translated),
-    Required('Package'): All(str, Length(min=1)),
+    Required('Summary'): All(dict, Length(min=1)),
 }, extra = True)
 
 def add_issue(msg):
@@ -99,35 +99,39 @@ def validate_data(data):
             ret = False
 
         for doc in docs:
-            docid = doc.get('ID')
+            cptid = doc.get('ID')
             pkgname = doc.get('Package')
-            if not pkgname:
-                pkgname = "?unknown?"
+            cpttype = doc.get('Type')
             if not doc:
                 add_issue("FATAL: Empty document found.")
                 ret = False
                 continue
-            if not docid:
+            if not cptid:
                 add_issue("FATAL: Component without ID found.")
                 ret = False
                 continue
+            if not pkgname:
+                if cpttype != "web-application":
+                    add_issue("[%s]: %s" % (cptid, "Component is missing a 'Package' key."))
+                    ret = False
+                    continue
 
             try:
                 schema_component(doc)
             except Exception as e:
-                add_issue("[%s]: %s" % (docid, str(e)))
+                add_issue("[%s]: %s" % (cptid, str(e)))
                 ret = False
                 continue
 
             # more tests for the icon key
             icon = doc.get('Icon')
-            if (doc['Type'] == "desktop-app") or (doc['Type'] == "web-app"):
+            if (cpttype == "desktop-application") or (cpttype == "web-application"):
                 if not doc.get('Icon'):
-                    add_issue("[%s]: %s" % (docid, "Components containing an application must have an 'Icon' key."))
+                    add_issue("[%s]: %s" % (cptid, "Components containing an application must have an 'Icon' key."))
                     ret = False
             if icon:
                 if (not icon.get('stock')) and (not icon.get('cached')) and (not icon.get('local')):
-                    add_issue("[%s]: %s" % (docid, "A 'stock', 'cached' or 'local' icon must at least be provided. @ data['Icon']"))
+                    add_issue("[%s]: %s" % (cptid, "A 'stock', 'cached' or 'local' icon must at least be provided. @ data['Icon']"))
                     ret = False
 
             if not test_localized(doc, 'Name'):
-- 
2.15.0


Reply to: