15922912 Auto-generation of Userland gate list - Phase 4
authorRich Burridge <rich.burridge@oracle.com>
Tue, 27 Nov 2012 08:25:14 -0800
changeset 1061 757624619bb3
parent 1060 57ffa0ff918c
child 1062 3e8044c3a700
15922912 Auto-generation of Userland gate list - Phase 4
make-rules/component-report
tools/gen-components
--- a/make-rules/component-report	Mon Nov 26 23:00:58 2012 -0800
+++ b/make-rules/component-report	Tue Nov 27 08:25:14 2012 -0800
@@ -24,6 +24,7 @@
 	@echo "<td>" >>$@ ; for license in $(LICENSE) ; do \
 	     echo "$$license<br>" >>$@ ; \
 	 done ; echo "</td>" >>$@
+	@echo "<td>$(TPNO)</td>" >>$@
 	@echo "<td>" >>$@ ; for bugdb in $(COMPONENT_BUGDB) ; do \
 	     echo "$$bugdb<br>" >>$@ ; \
 	 done ; echo "</td>" >>$@
@@ -40,6 +41,7 @@
 	@echo "COMPONENT_PROJECT_URL=\"$(COMPONENT_PROJECT_URL)\"" >>$@
 	@echo "COMPONENT_ARCHIVE_URL=\"$(COMPONENT_ARCHIVE_URL)\"" >>$@
 	@echo "COMPONENT_DIR=\"$(CDIR)\"" >>$@
+	@echo "TPNO=\"$(TPNO)\"" >>$@
 	@echo "COMPONENT_BUGDB=\"$(COMPONENT_BUGDB)\"" >>$@
 	@echo "RESPONSIBLE_ENGINEER=\"$(RESPONSIBLE_ENGINEER)\"" >>$@
 	@echo "RESPONSIBLE_MANAGER=\"$(RESPONSIBLE_MANAGER)\"" >>$@
--- a/tools/gen-components	Mon Nov 26 23:00:58 2012 -0800
+++ b/tools/gen-components	Tue Nov 27 08:25:14 2012 -0800
@@ -22,8 +22,8 @@
 # Copyright (c) 2012, Oracle and/or it's affiliates.  All rights reserved.
 #
 #
-# gen_components.py
-# A simple program to generate (on stdout) the component.html web page 
+# gen_components
+# A simple script to generate (on stdout), the component.html web page 
 # found at: http://userland.us.oracle.com/components.html
 #
 
@@ -33,6 +33,9 @@
 
 debug = False
 
+# Hashtable of components with TPNOs keyed by component name.
+comp_TPNOs = {}
+
 # Hashtable of RE's / RM's keyed by component path.
 owners = {}
 
@@ -82,6 +85,7 @@
     <th>Package(s)</th>
     <th>ARC Case(s)</th>
     <th>License(s)</th>
+    <th>TPNO</th>
     <th>BugDB</th>
     <th>RE</th>
     <th>RM</th>
@@ -119,6 +123,34 @@
 
     return owners
 
+# Return a hashtable of components with TPNOs keyed by component name.
+def find_TPNOs(workspace):
+    comp_TPNOs = {}
+    for directory, _, files in os.walk(workspace + "/components"):
+        for filename in files:
+            if filename.endswith(".license") or filename.endswith(".copyright"):
+                pathname = os.path.join(directory, filename)
+                fin = open(pathname, 'r')
+                lines = fin.readlines()
+                fin.close()
+
+                for line in lines:
+                    line = line.replace("\n", "")
+                    if line.startswith("Oracle Internal Tracking Number"):
+                        tpno_str = line.split()[-1]
+                        try:
+                            # Check that the TPNO is a valid number.
+                            tpno = int(tpno_str)
+                            if debug:
+                                print >> sys.stderr, "TPNO: %s: %s" % \
+                                    (directory, tpno_str)
+                            comp_TPNOs[directory] = tpno_str
+                        except:
+                            print >> sys.stderr, "Unable to read TPNO: %s" % \
+                                pathname
+
+    return(comp_TPNOs)
+
 # Return a sorted list of the directories containing one or more .p5m files.
 def find_p5m_dirs(workspace):
     p5m_dirs = []
@@ -160,11 +192,16 @@
     if debug:
         print >> sys.stderr, "Processing %s" % component_dir
 
+    try:
+        tpno = comp_TPNOs[component_dir]
+    except:
+        tpno = ""
+
     re, rm = get_re_and_rm(component_dir)
     makefiles = "-f Makefile -f %s/make-rules/component-report" % workspace
     targets = "clean component-hook"
-    cmd = "cd %s; RESPONSIBLE_ENGINEER='%s' RESPONSIBLE_MANAGER='%s' gmake COMPONENT_HOOK='gmake %s component-report' %s" % \
-        (component_dir, re, rm, makefiles, targets)
+    cmd = "cd %s; TPNO='%s' RESPONSIBLE_ENGINEER='%s' RESPONSIBLE_MANAGER='%s' gmake COMPONENT_HOOK='gmake %s component-report' %s" % \
+        (component_dir, tpno, re, rm, makefiles, targets)
 
     if debug:
         print >> sys.stderr, "gen_reports: command: `%s`" % cmd
@@ -232,6 +269,7 @@
  
     owners = read_owners(owners_file)
     write_preamble()
+    comp_TPNOs = find_TPNOs(workspace)
     p5m_dirs = find_p5m_dirs(workspace)
     for p5m_dir in p5m_dirs:
         gen_reports(workspace, p5m_dir)