Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements
@ 2020-01-05  9:23 Heiko Thiery
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 1/8] support/scripts/pkg-stats: store latest version in a dict Heiko Thiery
                   ` (8 more replies)
  0 siblings, 9 replies; 12+ messages in thread
From: Heiko Thiery @ 2020-01-05  9:23 UTC (permalink / raw)
  To: buildroot

This patches add several improvements for the json output of the
pkg-stats script.

- add developers information to the packages
- add supported defconfigs to json
- add license information to json
- add more generic status field to the packages

---
v1 -> v2:
- cleanup and recreation of patches
- remove pkg name from dumping to json
- use patch_files instead of combine count and files in dict
- include getdevelopers.py to reuse Developers class

---
Heiko Thiery (8):
  support/scripts/pkg-stats: store latest version in a dict
  support/scripts/pkg-stats: store patch files for the package
  support/scripts/pkg-stats: set developers info
  support/scripts/pkg-stats: store licences of package
  support/scripts/pkg-stats: add package status
  support/scripts/pkg-stats: add package count to stats
  support/scripts/pkg-stats: store pkg dir path
  support/scripts/pkg-stats: add defconfig support

 support/scripts/pkg-stats | 208 +++++++++++++++++++++++++++-----------
 1 file changed, 151 insertions(+), 57 deletions(-)

-- 
2.20.1

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH v2 1/8] support/scripts/pkg-stats: store latest version in a dict
  2020-01-05  9:23 [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Heiko Thiery
@ 2020-01-05  9:23 ` Heiko Thiery
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 2/8] support/scripts/pkg-stats: store patch files for the package Heiko Thiery
                   ` (7 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Heiko Thiery @ 2020-01-05  9:23 UTC (permalink / raw)
  To: buildroot

From: Heiko Thiery <heiko.thiery@kontron.com>

This patch changes the name and the variable from latest_verion of type list
to rm_status of type dict. This is for better readability/usability of the
data. With this the json output is more descriptive.

Signed-off-by: Heiko Thiery <heiko.thiery@kontron.com>
---
 support/scripts/pkg-stats | 35 ++++++++++++++++++-----------------
 1 file changed, 18 insertions(+), 17 deletions(-)

diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index e477828f7b..8c64993aaf 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -61,7 +61,7 @@ class Package:
         self.url = None
         self.url_status = None
         self.url_worker = None
-        self.latest_version = (RM_API_STATUS_ERROR, None, None)
+        self.rm_version = {'status': RM_API_STATUS_ERROR, 'version': None, 'id': None}
 
     def pkgvar(self):
         return self.name.upper().replace("-", "_")
@@ -331,11 +331,10 @@ def check_package_latest_version_worker(name):
 
 def check_package_latest_version(packages):
     """
-    Fills in the .latest_version field of all Package objects
+    Fills in the .rm_version field of all Package objects
+
+    This field is a dict and has the following keys:
 
-    This field has a special format:
-      (status, version, id)
-    with:
     - status: one of RM_API_STATUS_ERROR,
       RM_API_STATUS_FOUND_BY_DISTRO, RM_API_STATUS_FOUND_BY_PATTERN,
       RM_API_STATUS_NOT_FOUND
@@ -351,7 +350,9 @@ def check_package_latest_version(packages):
     worker_pool = Pool(processes=64)
     results = worker_pool.map(check_package_latest_version_worker, (pkg.name for pkg in packages))
     for pkg, r in zip(packages, results):
-        pkg.latest_version = r
+        pkg.rm_version['status'] = r[0]
+        pkg.rm_version['version'] = r[1]
+        pkg.rm_version['id'] = r[2]
     del http_pool
 
 
@@ -379,13 +380,13 @@ def calculate_stats(packages):
             stats["hash"] += 1
         else:
             stats["no-hash"] += 1
-        if pkg.latest_version[0] == RM_API_STATUS_FOUND_BY_DISTRO:
+        if pkg.rm_version['status'] == RM_API_STATUS_FOUND_BY_DISTRO:
             stats["rmo-mapping"] += 1
         else:
             stats["rmo-no-mapping"] += 1
-        if not pkg.latest_version[1]:
+        if not pkg.rm_version['version']:
             stats["version-unknown"] += 1
-        elif pkg.latest_version[1] == pkg.current_version:
+        elif pkg.rm_version['version'] == pkg.current_version:
             stats["version-uptodate"] += 1
         else:
             stats["version-not-uptodate"] += 1
@@ -548,29 +549,29 @@ def dump_html_pkg(f, pkg):
     f.write("  <td class=\"centered\">%s</td>\n" % current_version)
 
     # Latest version
-    if pkg.latest_version[0] == RM_API_STATUS_ERROR:
+    if pkg.rm_version['status'] == RM_API_STATUS_ERROR:
         td_class.append("version-error")
-    if pkg.latest_version[1] is None:
+    if pkg.rm_version['version'] is None:
         td_class.append("version-unknown")
-    elif pkg.latest_version[1] != pkg.current_version:
+    elif pkg.rm_version['version'] != pkg.current_version:
         td_class.append("version-needs-update")
     else:
         td_class.append("version-good")
 
-    if pkg.latest_version[0] == RM_API_STATUS_ERROR:
+    if pkg.rm_version['status'] == RM_API_STATUS_ERROR:
         latest_version_text = "<b>Error</b>"
-    elif pkg.latest_version[0] == RM_API_STATUS_NOT_FOUND:
+    elif pkg.rm_version['status'] == RM_API_STATUS_NOT_FOUND:
         latest_version_text = "<b>Not found</b>"
     else:
-        if pkg.latest_version[1] is None:
+        if pkg.rm_version['version'] is None:
             latest_version_text = "<b>Found, but no version</b>"
         else:
             latest_version_text = "<a href=\"https://release-monitoring.org/project/%s\"><b>%s</b></a>" % \
-                (pkg.latest_version[2], str(pkg.latest_version[1]))
+                (pkg.rm_version['id'], str(pkg.rm_version['version']))
 
         latest_version_text += "<br/>"
 
-        if pkg.latest_version[0] == RM_API_STATUS_FOUND_BY_DISTRO:
+        if pkg.rm_version['status'] == RM_API_STATUS_FOUND_BY_DISTRO:
             latest_version_text += "found by <a href=\"https://release-monitoring.org/distro/Buildroot/\">distro</a>"
         else:
             latest_version_text += "found by guess"
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH v2 2/8] support/scripts/pkg-stats: store patch files for the package
  2020-01-05  9:23 [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Heiko Thiery
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 1/8] support/scripts/pkg-stats: store latest version in a dict Heiko Thiery
@ 2020-01-05  9:23 ` Heiko Thiery
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 3/8] support/scripts/pkg-stats: set developers info Heiko Thiery
                   ` (6 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Heiko Thiery @ 2020-01-05  9:23 UTC (permalink / raw)
  To: buildroot

From: Heiko Thiery <heiko.thiery@kontron.com>

Signed-off-by: Heiko Thiery <heiko.thiery@kontron.com>
---
 support/scripts/pkg-stats | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index 8c64993aaf..6e250556e9 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -56,6 +56,7 @@ class Package:
         self.has_license_files = False
         self.has_hash = False
         self.patch_count = 0
+        self.patch_files = []
         self.warnings = 0
         self.current_version = None
         self.url = None
@@ -121,10 +122,10 @@ class Package:
         """
         Fills in the .patch_count field
         """
-        self.patch_count = 0
         pkgdir = os.path.dirname(self.path)
         for subdir, _, _ in os.walk(pkgdir):
-            self.patch_count += len(fnmatch.filter(os.listdir(subdir), '*.patch'))
+            self.patch_files = fnmatch.filter(os.listdir(subdir), '*.patch')
+            self.patch_count = len(self.patch_files)
 
     def set_current_version(self):
         """
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH v2 3/8] support/scripts/pkg-stats: set developers info
  2020-01-05  9:23 [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Heiko Thiery
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 1/8] support/scripts/pkg-stats: store latest version in a dict Heiko Thiery
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 2/8] support/scripts/pkg-stats: store patch files for the package Heiko Thiery
@ 2020-01-05  9:23 ` Heiko Thiery
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 4/8] support/scripts/pkg-stats: store licences of package Heiko Thiery
                   ` (5 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Heiko Thiery @ 2020-01-05  9:23 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
---
 support/scripts/pkg-stats | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index 6e250556e9..43d14785a1 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -26,10 +26,14 @@ import subprocess
 import requests  # URL checking
 import json
 import certifi
+import sys
 from urllib3 import HTTPSConnectionPool
 from urllib3.exceptions import HTTPError
 from multiprocessing import Pool
 
+sys.path.append('utils/')
+from getdeveloperlib import parse_developers
+
 INFRA_RE = re.compile(r"\$\(eval \$\(([a-z-]*)-package\)\)")
 URL_RE = re.compile(r"\s*https?://\S*\s*$")
 
@@ -153,6 +157,15 @@ class Package:
                 self.warnings = int(m.group(1))
                 return
 
+    def set_developers(self, developers):
+        """
+        Fills in the .developers field
+        """
+        self.developers = list()
+        for dev in developers:
+            if dev.hasfile(self.path):
+                self.developers.append((dev.name))
+
     def __eq__(self, other):
         return self.path == other.path
 
@@ -733,6 +746,8 @@ def __main__():
                                       'HEAD']).splitlines()[0]
     print("Build package list ...")
     packages = get_pkglist(args.npackages, package_list)
+    print("Getting developers ...")
+    developers = parse_developers()
     print("Getting package make info ...")
     package_init_make_info()
     print("Getting package details ...")
@@ -744,6 +759,7 @@ def __main__():
         pkg.set_check_package_warnings()
         pkg.set_current_version()
         pkg.set_url()
+        pkg.set_developers(developers)
     print("Checking URL status")
     check_package_urls(packages)
     print("Getting latest versions ...")
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH v2 4/8] support/scripts/pkg-stats: store licences of package
  2020-01-05  9:23 [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Heiko Thiery
                   ` (2 preceding siblings ...)
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 3/8] support/scripts/pkg-stats: set developers info Heiko Thiery
@ 2020-01-05  9:23 ` Heiko Thiery
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 5/8] support/scripts/pkg-stats: add package status Heiko Thiery
                   ` (4 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Heiko Thiery @ 2020-01-05  9:23 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
---
 support/scripts/pkg-stats | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index 43d14785a1..c10eb79a08 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -48,7 +48,7 @@ http_pool = None
 
 
 class Package:
-    all_licenses = list()
+    all_licenses = dict()
     all_license_files = list()
     all_versions = dict()
 
@@ -56,6 +56,7 @@ class Package:
         self.name = name
         self.path = path
         self.infras = None
+        self.license = None
         self.has_license = False
         self.has_license_files = False
         self.has_hash = False
@@ -112,6 +113,7 @@ class Package:
         var = self.pkgvar()
         if var in self.all_licenses:
             self.has_license = True
+            self.license = self.all_licenses[var]
         if var in self.all_license_files:
             self.has_license_files = True
 
@@ -261,7 +263,7 @@ def package_init_make_info():
             if value == "unknown":
                 continue
             pkgvar = pkgvar[:-8]
-            Package.all_licenses.append(pkgvar)
+            Package.all_licenses[pkgvar] = value
 
         elif pkgvar.endswith("_LICENSE_FILES"):
             if pkgvar.endswith("_MANIFEST_LICENSE_FILES"):
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH v2 5/8] support/scripts/pkg-stats: add package status
  2020-01-05  9:23 [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Heiko Thiery
                   ` (3 preceding siblings ...)
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 4/8] support/scripts/pkg-stats: store licences of package Heiko Thiery
@ 2020-01-05  9:23 ` Heiko Thiery
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 6/8] support/scripts/pkg-stats: add package count to stats Heiko Thiery
                   ` (3 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Heiko Thiery @ 2020-01-05  9:23 UTC (permalink / raw)
  To: buildroot

Unify the status check information. The status is stored in a tuple. The
first entry is the status that can be 'ok', 'warning' or 'error'. The
second entry is a verbose message.

With that status information the following variables are replaced:
has_license, has_license_files, has_hash, url_status

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
---
 support/scripts/pkg-stats | 104 +++++++++++++++++++++++++-------------
 1 file changed, 69 insertions(+), 35 deletions(-)

diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index c10eb79a08..ace092cf3b 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -57,17 +57,14 @@ class Package:
         self.path = path
         self.infras = None
         self.license = None
-        self.has_license = False
-        self.has_license_files = False
-        self.has_hash = False
         self.patch_count = 0
         self.patch_files = []
         self.warnings = 0
         self.current_version = None
         self.url = None
-        self.url_status = None
         self.url_worker = None
         self.rm_version = {'status': RM_API_STATUS_ERROR, 'version': None, 'id': None}
+        self.status = {}
 
     def pkgvar(self):
         return self.name.upper().replace("-", "_")
@@ -76,17 +73,17 @@ class Package:
         """
         Fills in the .url field
         """
-        self.url_status = "No Config.in"
+        self.status['url'] = ("warning", "no Config.in")
         for filename in os.listdir(os.path.dirname(self.path)):
             if fnmatch.fnmatch(filename, 'Config.*'):
                 fp = open(os.path.join(os.path.dirname(self.path), filename), "r")
                 for config_line in fp:
                     if URL_RE.match(config_line):
                         self.url = config_line.strip()
-                        self.url_status = "Found"
+                        self.status['url'] = ("ok", "found")
                         fp.close()
                         return
-                self.url_status = "Missing"
+                self.status['url'] = ("warning", "missing")
                 fp.close()
 
     def set_infra(self):
@@ -108,31 +105,43 @@ class Package:
 
     def set_license(self):
         """
-        Fills in the .has_license and .has_license_files fields
+        Fills in the .status['license'] and .status['license-files'] fields
         """
         var = self.pkgvar()
+        self.status['license'] = ("error", "missing")
+        self.status['license-files'] = ("ok", "missing")
         if var in self.all_licenses:
-            self.has_license = True
             self.license = self.all_licenses[var]
+            self.status['license'] = ("ok", "found")
         if var in self.all_license_files:
-            self.has_license_files = True
+            self.status['license-files'] = ("ok", "found")
 
     def set_hash_info(self):
         """
-        Fills in the .has_hash field
+        Fills in the .status['hash'] field
         """
         hashpath = self.path.replace(".mk", ".hash")
-        self.has_hash = os.path.exists(hashpath)
+        if os.path.exists(hashpath):
+            self.status['hash'] = ("ok", "found")
+        else:
+            self.status['hash'] = ("error", "missing")
 
     def set_patch_count(self):
         """
-        Fills in the .patch_count field
+        Fills in the .patch_count, .patch_files and .status['patches'] fields
         """
         pkgdir = os.path.dirname(self.path)
         for subdir, _, _ in os.walk(pkgdir):
             self.patch_files = fnmatch.filter(os.listdir(subdir), '*.patch')
             self.patch_count = len(self.patch_files)
 
+        if self.patch_count == 0:
+            self.status['patches'] = ("ok", "no patches")
+        elif self.patch_count < 5:
+            self.status['patches'] = ("warning", "some patches")
+        else:
+            self.status['patches'] = ("error", "lots of patches")
+
     def set_current_version(self):
         """
         Fills in the .current_version field
@@ -143,10 +152,11 @@ class Package:
 
     def set_check_package_warnings(self):
         """
-        Fills in the .warnings field
+        Fills in the .warnings and .status['pkg-check'] fields
         """
         cmd = ["./utils/check-package"]
         pkgdir = os.path.dirname(self.path)
+        self.status['pkg-check'] = ("error", "Missing")
         for root, dirs, files in os.walk(pkgdir):
             for f in files:
                 if f.endswith(".mk") or f.endswith(".hash") or f == "Config.in" or f == "Config.in.host":
@@ -157,17 +167,28 @@ class Package:
             m = re.match("^([0-9]*) warnings generated", line)
             if m:
                 self.warnings = int(m.group(1))
+                if self.warnings == 0:
+                    self.status['pkg-check'] = ("ok", "no warnings")
+                else:
+                    self.status['pkg-check'] = ("error", "{} warnings".format(self.warnings))
                 return
 
     def set_developers(self, developers):
         """
-        Fills in the .developers field
+        Fills in the .developers and .status['developers'] field
         """
         self.developers = list()
+        self.status['developers'] = ("warning", "no developers")
         for dev in developers:
             if dev.hasfile(self.path):
                 self.developers.append((dev.name))
 
+        if self.developers:
+            self.status['developers'] = ("ok", "{} developers".format(len(self.developers)))
+
+    def is_status_ok(self, name):
+        return self.status[name][0] == 'ok'
+
     def __eq__(self, other):
         return self.path == other.path
 
@@ -176,7 +197,7 @@ class Package:
 
     def __str__(self):
         return "%s (path='%s', license='%s', license_files='%s', hash='%s', patches=%d)" % \
-            (self.name, self.path, self.has_license, self.has_license_files, self.has_hash, self.patch_count)
+            (self.name, self.path, self.is_status_ok('license'), self.is_status_ok('license-files'), self.status['hash'], self.patch_count)
 
 
 def get_pkglist(npackages, package_list):
@@ -279,23 +300,23 @@ def package_init_make_info():
 
 
 def check_url_status_worker(url, url_status):
-    if url_status != "Missing" and url_status != "No Config.in":
+    if url_status[0] == 'ok':
         try:
             url_status_code = requests.head(url, timeout=30).status_code
             if url_status_code >= 400:
-                return "Invalid(%s)" % str(url_status_code)
+                return ("error", "invalid {}".format(url_status_code))
         except requests.exceptions.RequestException:
-            return "Invalid(Err)"
-        return "Ok"
+            return ("error", "invalid (err)")
+        return ("ok", "valid")
     return url_status
 
 
 def check_package_urls(packages):
     Package.pool = Pool(processes=64)
     for pkg in packages:
-        pkg.url_worker = pkg.pool.apply_async(check_url_status_worker, (pkg.url, pkg.url_status))
+        pkg.url_worker = pkg.pool.apply_async(check_url_status_worker, (pkg.url, pkg.status['url']))
     for pkg in packages:
-        pkg.url_status = pkg.url_worker.get(timeout=3600)
+        pkg.status['url'] = pkg.url_worker.get(timeout=3600)
 
 
 def release_monitoring_get_latest_version_by_distro(pool, name):
@@ -369,6 +390,18 @@ def check_package_latest_version(packages):
         pkg.rm_version['status'] = r[0]
         pkg.rm_version['version'] = r[1]
         pkg.rm_version['id'] = r[2]
+
+        if pkg.rm_version['status'] == RM_API_STATUS_ERROR:
+            pkg.status['version'] = ('warning', 'RM API error')
+        elif pkg.rm_version['status'] == RM_API_STATUS_NOT_FOUND:
+            pkg.status['version'] = ('warning', 'RM package not found')
+
+        if pkg.rm_version['version'] is None:
+            pkg.status['version'] = ('warning', 'no upstream version available')
+        elif pkg.rm_version['version'] != pkg.current_version:
+            pkg.status['version'] = ('error', 'package needs update')
+        else:
+            pkg.status['version'] = ('ok', 'up-to-date')
     del http_pool
 
 
@@ -384,15 +417,15 @@ def calculate_stats(packages):
             stats["infra-%s" % infra] += 1
         else:
             stats["infra-unknown"] += 1
-        if pkg.has_license:
+        if pkg.is_status_ok('license'):
             stats["license"] += 1
         else:
             stats["no-license"] += 1
-        if pkg.has_license_files:
+        if pkg.is_status_ok('license-files'):
             stats["license-files"] += 1
         else:
             stats["no-license-files"] += 1
-        if pkg.has_hash:
+        if pkg.is_status_ok('hash'):
             stats["hash"] += 1
         else:
             stats["no-hash"] += 1
@@ -532,30 +565,30 @@ def dump_html_pkg(f, pkg):
 
     # License
     td_class = ["centered"]
-    if pkg.has_license:
+    if pkg.is_status_ok('license'):
         td_class.append("correct")
     else:
         td_class.append("wrong")
     f.write("  <td class=\"%s\">%s</td>\n" %
-            (" ".join(td_class), boolean_str(pkg.has_license)))
+            (" ".join(td_class), boolean_str(pkg.is_status_ok('license'))))
 
     # License files
     td_class = ["centered"]
-    if pkg.has_license_files:
+    if pkg.is_status_ok('license-files'):
         td_class.append("correct")
     else:
         td_class.append("wrong")
     f.write("  <td class=\"%s\">%s</td>\n" %
-            (" ".join(td_class), boolean_str(pkg.has_license_files)))
+            (" ".join(td_class), boolean_str(pkg.is_status_ok('license-files'))))
 
     # Hash
     td_class = ["centered"]
-    if pkg.has_hash:
+    if pkg.is_status_ok('hash'):
         td_class.append("correct")
     else:
         td_class.append("wrong")
     f.write("  <td class=\"%s\">%s</td>\n" %
-            (" ".join(td_class), boolean_str(pkg.has_hash)))
+            (" ".join(td_class), boolean_str(pkg.is_status_ok('hash'))))
 
     # Current version
     if len(pkg.current_version) > 20:
@@ -606,12 +639,13 @@ def dump_html_pkg(f, pkg):
 
     # URL status
     td_class = ["centered"]
-    url_str = pkg.url_status
-    if pkg.url_status == "Missing" or pkg.url_status == "No Config.in":
+    url_str = pkg.status['url'][1]
+    if pkg.status['url'][0] == "warning":
+        td_class.append("missing_url")
+    elif pkg.status['url'][0] == "error":
         td_class.append("missing_url")
-    elif pkg.url_status.startswith("Invalid"):
         td_class.append("invalid_url")
-        url_str = "<a href=%s>%s</a>" % (pkg.url, pkg.url_status)
+        url_str = "<a href=%s>%s</a>" % (pkg.url, pkg.status['url'][1])
     else:
         td_class.append("good_url")
         url_str = "<a href=%s>Link</a>" % pkg.url
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH v2 6/8] support/scripts/pkg-stats: add package count to stats
  2020-01-05  9:23 [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Heiko Thiery
                   ` (4 preceding siblings ...)
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 5/8] support/scripts/pkg-stats: add package status Heiko Thiery
@ 2020-01-05  9:23 ` Heiko Thiery
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 7/8] support/scripts/pkg-stats: store pkg dir path Heiko Thiery
                   ` (2 subsequent siblings)
  8 siblings, 0 replies; 12+ messages in thread
From: Heiko Thiery @ 2020-01-05  9:23 UTC (permalink / raw)
  To: buildroot

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
---
 support/scripts/pkg-stats | 1 +
 1 file changed, 1 insertion(+)

diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index ace092cf3b..8ec3204d9a 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -407,6 +407,7 @@ def check_package_latest_version(packages):
 
 def calculate_stats(packages):
     stats = defaultdict(int)
+    stats['packages'] = len(packages)
     for pkg in packages:
         # If packages have multiple infra, take the first one. For the
         # vast majority of packages, the target and host infra are the
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH v2 7/8] support/scripts/pkg-stats: store pkg dir path
  2020-01-05  9:23 [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Heiko Thiery
                   ` (5 preceding siblings ...)
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 6/8] support/scripts/pkg-stats: add package count to stats Heiko Thiery
@ 2020-01-05  9:23 ` Heiko Thiery
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 8/8] support/scripts/pkg-stats: add defconfig support Heiko Thiery
  2020-01-05 19:45 ` [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Thomas Petazzoni
  8 siblings, 0 replies; 12+ messages in thread
From: Heiko Thiery @ 2020-01-05  9:23 UTC (permalink / raw)
  To: buildroot

This value can be used for later processing.

In the buildroot-stats application this is used to create links pointing
to the git repo of buildroot.

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
---
 support/scripts/pkg-stats | 1 +
 1 file changed, 1 insertion(+)

diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index 8ec3204d9a..5f61a095b6 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -55,6 +55,7 @@ class Package:
     def __init__(self, name, path):
         self.name = name
         self.path = path
+        self.pkg_path = os.path.dirname(path)
         self.infras = None
         self.license = None
         self.patch_count = 0
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH v2 8/8] support/scripts/pkg-stats: add defconfig support
  2020-01-05  9:23 [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Heiko Thiery
                   ` (6 preceding siblings ...)
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 7/8] support/scripts/pkg-stats: store pkg dir path Heiko Thiery
@ 2020-01-05  9:23 ` Heiko Thiery
  2020-01-05 19:45 ` [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Thomas Petazzoni
  8 siblings, 0 replies; 12+ messages in thread
From: Heiko Thiery @ 2020-01-05  9:23 UTC (permalink / raw)
  To: buildroot

Scan configs directory and create Defconfig objects.

Signed-off-by: Heiko Thiery <heiko.thiery@gmail.com>
---
 support/scripts/pkg-stats | 42 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 40 insertions(+), 2 deletions(-)

diff --git a/support/scripts/pkg-stats b/support/scripts/pkg-stats
index 5f61a095b6..cf5de784cd 100755
--- a/support/scripts/pkg-stats
+++ b/support/scripts/pkg-stats
@@ -46,6 +46,33 @@ RM_API_STATUS_NOT_FOUND = 4
 # because it's used by sub-processes.
 http_pool = None
 
+class Defconfig:
+    def __init__(self, name, path):
+        self.name = name
+        self.path = path
+        self.developers = None
+
+    def set_developers(self, developers):
+        """
+        Fills in the .developers field
+        """
+        self.developers = list()
+        for dev in developers:
+            if dev.hasfile(self.path):
+                self.developers.append(dev.name)
+
+def get_defconfig_list():
+     """
+     Builds the list of Buildroot defconfigs, returning a list of Defconfig
+     objects.
+     """
+     defconfigs = list()
+     files = [f for f in os.listdir('configs')]
+     for name in files:
+         d = Defconfig(name[:-10], os.path.join('configs', name))
+         defconfigs.append(d)
+     return defconfigs
+
 
 class Package:
     all_licenses = dict()
@@ -726,7 +753,7 @@ def dump_html(packages, stats, date, commit, output):
         f.write(html_footer)
 
 
-def dump_json(packages, stats, date, commit, output):
+def dump_json(packages, defconfigs, stats, date, commit, output):
     # Format packages as a dictionnary instead of a list
     # Exclude local field that does not contains real date
     excluded_fields = ['url_worker', 'name']
@@ -737,6 +764,12 @@ def dump_json(packages, stats, date, commit, output):
             if k not in excluded_fields
         } for pkg in packages
     }
+    defconfigs = {
+        d.name: {
+            k: v
+            for k, v in d.__dict__.items()
+        } for d in defconfigs
+    }
     # Aggregate infrastructures into a single dict entry
     statistics = {
         k: v
@@ -747,6 +780,7 @@ def dump_json(packages, stats, date, commit, output):
     # The actual structure to dump, add commit and date to it
     final = {'packages': pkgs,
              'stats': statistics,
+             'defconfigs': defconfigs,
              'commit': commit,
              'date': str(date)}
 
@@ -786,6 +820,10 @@ def __main__():
     packages = get_pkglist(args.npackages, package_list)
     print("Getting developers ...")
     developers = parse_developers()
+    print("Build defconfig list ...")
+    defconfigs = get_defconfig_list()
+    for d in defconfigs:
+        d.set_developers(developers)
     print("Getting package make info ...")
     package_init_make_info()
     print("Getting package details ...")
@@ -809,7 +847,7 @@ def __main__():
         dump_html(packages, stats, date, commit, args.html)
     if args.json:
         print("Write JSON")
-        dump_json(packages, stats, date, commit, args.json)
+        dump_json(packages, defconfigs, stats, date, commit, args.json)
 
 
 __main__()
-- 
2.20.1

^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements
  2020-01-05  9:23 [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Heiko Thiery
                   ` (7 preceding siblings ...)
  2020-01-05  9:23 ` [Buildroot] [PATCH v2 8/8] support/scripts/pkg-stats: add defconfig support Heiko Thiery
@ 2020-01-05 19:45 ` Thomas Petazzoni
  2020-01-05 21:40   ` Heiko Thiery
  8 siblings, 1 reply; 12+ messages in thread
From: Thomas Petazzoni @ 2020-01-05 19:45 UTC (permalink / raw)
  To: buildroot

Hello Heiko,

On Sun,  5 Jan 2020 10:23:22 +0100
Heiko Thiery <heiko.thiery@gmail.com> wrote:

> This patches add several improvements for the json output of the
> pkg-stats script.
> 
> - add developers information to the packages
> - add supported defconfigs to json
> - add license information to json
> - add more generic status field to the packages

Thanks for this new iteration. There is however one really important
thing that I missed in the review of v1: the JSON provided by pkg-stats
is then used by other tools. So if you change the layout/format of the
JSON file, those tools also need to be modified accordingly.

The tool consuming the JSON file today is the daily-mail script at
https://git.buildroot.org/buildroot-test/tree/utils/daily-mail. I think
the only function that needs to be modified is
https://git.buildroot.org/buildroot-test/tree/utils/daily-mail#n549.

Best regards,

Thomas
-- 
Thomas Petazzoni, CTO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements
  2020-01-05 19:45 ` [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Thomas Petazzoni
@ 2020-01-05 21:40   ` Heiko Thiery
  2020-01-06 18:08     ` Heiko Thiery
  0 siblings, 1 reply; 12+ messages in thread
From: Heiko Thiery @ 2020-01-05 21:40 UTC (permalink / raw)
  To: buildroot

Am So., 5. Jan. 2020 um 20:45 Uhr schrieb Thomas Petazzoni
<thomas.petazzoni@bootlin.com>:
>
> Hello Heiko,
>
> On Sun,  5 Jan 2020 10:23:22 +0100
> Heiko Thiery <heiko.thiery@gmail.com> wrote:
>
> > This patches add several improvements for the json output of the
> > pkg-stats script.
> >
> > - add developers information to the packages
> > - add supported defconfigs to json
> > - add license information to json
> > - add more generic status field to the packages
>
> Thanks for this new iteration. There is however one really important
> thing that I missed in the review of v1: the JSON provided by pkg-stats
> is then used by other tools. So if you change the layout/format of the
> JSON file, those tools also need to be modified accordingly.
>
> The tool consuming the JSON file today is the daily-mail script at
> https://git.buildroot.org/buildroot-test/tree/utils/daily-mail. I think
> the only function that needs to be modified is
> https://git.buildroot.org/buildroot-test/tree/utils/daily-mail#n549.

ok I see .. was not aware of this repo till now. I try to figure out
how it works. But when I'm correct this script is also used for the
other branches of maintained buildroot versions. So if we change the
layout of the JSON file we have to take care of the pkg-stats script
in the other maintained branches.

> Best regards,
>
> Thomas
> --
> Thomas Petazzoni, CTO, Bootlin
> Embedded Linux and Kernel engineering
> https://bootlin.com

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements
  2020-01-05 21:40   ` Heiko Thiery
@ 2020-01-06 18:08     ` Heiko Thiery
  0 siblings, 0 replies; 12+ messages in thread
From: Heiko Thiery @ 2020-01-06 18:08 UTC (permalink / raw)
  To: buildroot

Hi Thomas,

Am So., 5. Jan. 2020 um 22:40 Uhr schrieb Heiko Thiery <heiko.thiery@gmail.com>:
>
> Am So., 5. Jan. 2020 um 20:45 Uhr schrieb Thomas Petazzoni
> <thomas.petazzoni@bootlin.com>:
> >
> > Hello Heiko,
> >
> > On Sun,  5 Jan 2020 10:23:22 +0100
> > Heiko Thiery <heiko.thiery@gmail.com> wrote:
> >
> > > This patches add several improvements for the json output of the
> > > pkg-stats script.
> > >
> > > - add developers information to the packages
> > > - add supported defconfigs to json
> > > - add license information to json
> > > - add more generic status field to the packages
> >
> > Thanks for this new iteration. There is however one really important
> > thing that I missed in the review of v1: the JSON provided by pkg-stats
> > is then used by other tools. So if you change the layout/format of the
> > JSON file, those tools also need to be modified accordingly.
> >
> > The tool consuming the JSON file today is the daily-mail script at
> > https://git.buildroot.org/buildroot-test/tree/utils/daily-mail. I think
> > the only function that needs to be modified is
> > https://git.buildroot.org/buildroot-test/tree/utils/daily-mail#n549.
>
> ok I see .. was not aware of this repo till now. I try to figure out
> how it works. But when I'm correct this script is also used for the
> other branches of maintained buildroot versions. So if we change the
> layout of the JSON file we have to take care of the pkg-stats script
> in the other maintained branches.

if I see correct we only need to change this line
https://git.buildroot.org/buildroot-test/tree/utils/daily-mail#n554 to
get the 'status', 'latest_v' and 'id' from the dict 'rm_version'.
Should I send a patch to you? Or where to send?

> > Best regards,
> >
> > Thomas
> > --
> > Thomas Petazzoni, CTO, Bootlin
> > Embedded Linux and Kernel engineering
> > https://bootlin.com

--
Heiko

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2020-01-06 18:08 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-01-05  9:23 [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Heiko Thiery
2020-01-05  9:23 ` [Buildroot] [PATCH v2 1/8] support/scripts/pkg-stats: store latest version in a dict Heiko Thiery
2020-01-05  9:23 ` [Buildroot] [PATCH v2 2/8] support/scripts/pkg-stats: store patch files for the package Heiko Thiery
2020-01-05  9:23 ` [Buildroot] [PATCH v2 3/8] support/scripts/pkg-stats: set developers info Heiko Thiery
2020-01-05  9:23 ` [Buildroot] [PATCH v2 4/8] support/scripts/pkg-stats: store licences of package Heiko Thiery
2020-01-05  9:23 ` [Buildroot] [PATCH v2 5/8] support/scripts/pkg-stats: add package status Heiko Thiery
2020-01-05  9:23 ` [Buildroot] [PATCH v2 6/8] support/scripts/pkg-stats: add package count to stats Heiko Thiery
2020-01-05  9:23 ` [Buildroot] [PATCH v2 7/8] support/scripts/pkg-stats: store pkg dir path Heiko Thiery
2020-01-05  9:23 ` [Buildroot] [PATCH v2 8/8] support/scripts/pkg-stats: add defconfig support Heiko Thiery
2020-01-05 19:45 ` [Buildroot] [PATCH v2 0/8] pkg-stats json output improvements Thomas Petazzoni
2020-01-05 21:40   ` Heiko Thiery
2020-01-06 18:08     ` Heiko Thiery

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox