[Buildroot] [PATCH 3/6] manual: add deprecated-list.txt generation support

Samuel Martin s.martin49 at gmail.com
Wed Nov 28 21:40:29 UTC 2012


The whole deprecated-list.txt file is generated by the deprecated.py
script by searching for symbols depending on BR2_DEPRECATED in the
Buildroot code base.

Signed-off-by: Samuel Martin <s.martin49 at gmail.com>
---
 docs/manual/manual.mk         |   3 +
 support/scripts/deprecated.py | 144 ++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 147 insertions(+)
 create mode 100755 support/scripts/deprecated.py

diff --git a/docs/manual/manual.mk b/docs/manual/manual.mk
index c4a21b2..a344efe 100644
--- a/docs/manual/manual.mk
+++ b/docs/manual/manual.mk
@@ -44,6 +44,9 @@ $(TOPDIR)/docs/manual/package-list.txt:
 		sed -e 's;.*\?/\(.*\?\).mk;* \1;' | \
 		sort >> $@
 
+$(TOPDIR)/docs/manual/deprecated-list.txt:
+	python2 $(TOPDIR)/support/scripts/deprecated.py > $@
+
 ################################################################################
 # GENDOC -- generates the make targets needed to build asciidoc documentation.
 #
diff --git a/support/scripts/deprecated.py b/support/scripts/deprecated.py
new file mode 100755
index 0000000..cd8c288
--- /dev/null
+++ b/support/scripts/deprecated.py
@@ -0,0 +1,144 @@
+#!/usr/bin/env python
+##
+## deprecated-packages.py
+##
+## Author(s):
+##  - Samuel MARTIN <s.martin49 at gmail.com>
+##
+## Copyright (C) 2012 Samuel MARTIN
+##
+
+# Python 2.7 script searching for kconfig symbols depending on 'BR2_DEPRECATED'
+# and generating (printing to the standard output) the manual file in asciidoc.
+
+import os
+import re
+import sys
+
+
+ASCIIDOC_HEADER = """\
+//
+// Autogenerated file
+//
+
+[[deprecated]]
+Deprecated list
+---------------
+
+The following stuff are marked as _deprecated_ in Buildroot due to
+their status either too old or unmaintained.
+
+// Please check and sort by grepping the source running:
+//
+// $ git grep -EB4 'depends on BR2_DEPRECATED'
+//
+// and:
+//
+// $ git grep -EB4 'depends on BR2_DEPRECATED' | \\
+//     grep -Eo '(:|-).*?(config|comment) BR2_.*'
+"""
+
+NOT_SEARCHED = (".git", "board", "configs", "docs", "output", "support")
+
+# Relative path to category data map
+#   key:   relative path from buildroot topdir to the search location
+#   value: (rank_in_menuconfig, category_name, recursive_search)
+#       rank_in_menuconfig is used for ordering the diplaying
+#       category_name is used in the diplaying
+#       recursive_search when searching for deprecated stuff
+CAT_DIR2DATA = {
+    'arch'      : (0, "target architecture",  True),
+    '.'         : (1, "build options",        False),
+    'toolchain' : (2, "toolchain",            True),
+    'system'    : (3, "system configuration", True),
+    'package'   : (4, "package selection",    True),
+    'fs'        : (5, "filesystem images",    True),
+    'boot'      : (6, "bootloaders",          True),
+    'linux'     : (7, "kernel",               True),
+    }
+
+DEPR_SYMBOL = "BR2_DEPRECATED"
+
+_REGEX = r"config BR2_(.*?)\n" + \
+    "((.*?(?!config)(prompt|bool|string|int) \"(.*?)\".*?|[^\n]+)\n)*" + \
+    "(.*?(?!config )" + DEPR_SYMBOL + ".*?)\n" + \
+    "((.*?(?!config)(prompt|bool|string|int) \"(.*?)\".*?|[^\n]+)\n)*"
+
+REGEX = re.compile(_REGEX, flags=re.MULTILINE)
+
+
+def _get_buildroot_topdir():
+    topdir = os.path.join(os.path.dirname(__file__), "..", "..")
+    topdir = os.path.abspath(topdir)
+    return topdir
+
+def get_dir_list():
+    root = _get_buildroot_topdir()
+    dirs = ['.']
+    for dir_ in os.listdir(root):
+        if dir_ in NOT_SEARCHED:
+            continue
+        dir__ = os.path.join(root, dir_)
+        if not os.path.isdir(dir__):
+            continue
+        dirs += [dir_]
+    return dirs
+
+def find_deprecated(root, recursive):
+    deprecated = list()
+    for root_, _, files_ in os.walk(root):
+        if not recursive and root_ != root:
+            break
+        for file_ in files_:
+            if not file_.startswith("Config.in"):
+                continue
+            with open(os.path.join(root_, file_), "r") as f:
+                content = f.read()
+            if not DEPR_SYMBOL in content:
+                continue
+            found = REGEX.findall(content)
+            if found:
+                deprecated += found
+    return deprecated
+
+
+class Category():
+
+    def __init__(self, directory):
+        self.path = os.path.join(_get_buildroot_topdir(), directory)
+        rank, name, rec = CAT_DIR2DATA.get(directory, (99, directory, True))
+        self.name = name
+        self.rank = rank
+        self.depr_items = find_deprecated(self.path, rec)
+
+    def __str__(self):
+        items_ = list()
+        for item in self.depr_items:
+            name_ = item[0].lower().replace("_", " ")
+            name_ = re.sub("^package ", "", name_)
+            vers = re.sub(".*?(version )?([0-9].*)", r'\2', name_)
+            if vers:
+                vers = re.sub(" ", ".", vers)
+                name_ = re.sub("(version )?([0-9].*)", vers, name_)
+            symbol = item[4]
+            if not symbol:
+                symbol = item[9]
+            items_ += ["** %-25s +[%s]+" % (name_, symbol)]
+        items_.sort()
+        output = "\n* %s:\n\n" % self.name.capitalize()
+        output += "\n".join(items_)
+        output += "\n"
+        return output
+
+def main():
+    categories = [Category(directory) for directory in get_dir_list()]
+    categories = [category for category in categories if category.depr_items]
+    categories.sort(cmp=lambda x, y: x.rank - y.rank if x.rank != y.rank \
+                        else cmp(x.name, y.name))
+    output = ASCIIDOC_HEADER
+    for category in categories:
+        output += str(category)
+    print output
+
+if __name__ == "__main__":
+    main()
-- 
1.8.0.1




More information about the buildroot mailing list