diff options
-rw-r--r-- | doc/docsrc_common/pardoc-distro.xml | 3 | ||||
-rw-r--r-- | doc/gen_pkgdiff.py | 78 |
2 files changed, 66 insertions, 15 deletions
diff --git a/doc/docsrc_common/pardoc-distro.xml b/doc/docsrc_common/pardoc-distro.xml index 317a2a5..00711b5 100644 --- a/doc/docsrc_common/pardoc-distro.xml +++ b/doc/docsrc_common/pardoc-distro.xml | |||
@@ -34,4 +34,7 @@ | |||
34 | <para id="Yocto_VER"><phrase>&DISTRO;</phrase></para> | 34 | <para id="Yocto_VER"><phrase>&DISTRO;</phrase></para> |
35 | <para id="Yocto_NAME"><phrase>&DISTRO_NAME_NO_CAP;</phrase></para> | 35 | <para id="Yocto_NAME"><phrase>&DISTRO_NAME_NO_CAP;</phrase></para> |
36 | <para id="ULINK_YOCTO_RELEASE_NOTES"><ulink url='&YOCTO_RELEASE_NOTES;'>&YOCTO_RELEASE_NOTES;</ulink></para> | 36 | <para id="ULINK_YOCTO_RELEASE_NOTES"><ulink url='&YOCTO_RELEASE_NOTES;'>&YOCTO_RELEASE_NOTES;</ulink></para> |
37 | <para id="prev_baseline"><phrase>el5_baseline</phrase></para> | ||
38 | <para id="prev_lic_file"><phrase>doc/book-enea-linux-open-source/doc/licenses.xml</phrase></para> | ||
39 | <para id="new_lic_file"><phrase>doc/book-enea-linux-open-source/doc/licenses.xml</phrase></para> | ||
37 | </section> | 40 | </section> |
diff --git a/doc/gen_pkgdiff.py b/doc/gen_pkgdiff.py index 7dd8c73..5a13311 100644 --- a/doc/gen_pkgdiff.py +++ b/doc/gen_pkgdiff.py | |||
@@ -1,14 +1,30 @@ | |||
1 | ############################################################################### | 1 | ############################################################################### |
2 | # | 2 | # |
3 | # Diff two licenses.xml files. Splits the result in three sets: | 3 | # Diff two licenses.xml files. There are two cases: |
4 | # * Two arguments | ||
5 | # In this case, the two arguments are the two files to compare | ||
6 | # | ||
7 | # * No arguments | ||
8 | # In this casem the license files are specified by the following | ||
9 | # parameters in pardoc-distro.xml: | ||
10 | # - prev_baseline | ||
11 | # - prev_lic_file | ||
12 | # - new_lic_file | ||
13 | # | ||
14 | # The result is presented as three sets: | ||
4 | # 1) Removed | 15 | # 1) Removed |
5 | # Packages present in the old file, but not in the new. | 16 | # Packages present in the previous file, but not in the new. |
6 | # | 17 | # |
7 | # 2) Added | 18 | # 2) Added |
8 | # Packages present in the new file, but not in the old. | 19 | # Packages present in the new file, but not in the previous. |
9 | # | 20 | # |
10 | # 3) Changed | 21 | # 3) Changed |
11 | # Packages present in both files, but with different versions. | 22 | # Packages present in both files, but with different versions. If more than |
23 | # one version of a package is included, then all difference in the version | ||
24 | # set causes the package to be listed as changed. | ||
25 | # E.g. | ||
26 | # (v1) -> (v2) | ||
27 | # (v1, v2) -> (v2, v3) | ||
12 | # | 28 | # |
13 | # Note that packages with the unchanged version is not listed. | 29 | # Note that packages with the unchanged version is not listed. |
14 | # | 30 | # |
@@ -17,13 +33,30 @@ | |||
17 | # | 33 | # |
18 | ############################################################################### | 34 | ############################################################################### |
19 | 35 | ||
36 | import os | ||
20 | import sys | 37 | import sys |
21 | import subprocess | 38 | import subprocess as sp |
22 | import xml.etree.ElementTree as ET | 39 | import xml.etree.ElementTree as ET |
40 | import re | ||
41 | |||
42 | repo_root = sp.check_output(["git", "rev-parse", "--show-toplevel"]).rstrip() | ||
43 | script_root = os.path.dirname(os.path.realpath(__file__)) | ||
44 | param_file = os.path.join(script_root, "docsrc_common/pardoc-distro.xml") | ||
45 | |||
46 | def get_param(param_name): | ||
47 | pat = re.compile("%s.*>([^<>]+)</" % param_name) | ||
48 | |||
49 | with open(param_file) as f: | ||
50 | for line in f: | ||
51 | m = pat.search(line) | ||
52 | if m: | ||
53 | return m.group(1) | ||
54 | |||
55 | return None | ||
23 | 56 | ||
24 | def get_pkgs(file_spec): | 57 | def get_pkgs(file_spec): |
25 | if file_spec.find(":") >= 0: | 58 | if file_spec.find(":") >= 0: |
26 | s = subprocess.check_output(("git", "show", file_spec)) | 59 | s = sp.check_output(("git", "show", file_spec)) |
27 | else: | 60 | else: |
28 | f = open(file_spec) | 61 | f = open(file_spec) |
29 | s = f.read() | 62 | s = f.read() |
@@ -65,22 +98,37 @@ def get_pkgs(file_spec): | |||
65 | 98 | ||
66 | #---------------------------------------- | 99 | #---------------------------------------- |
67 | 100 | ||
68 | if len(sys.argv) != 3: | 101 | |
102 | if len(sys.argv) == 3: | ||
103 | new_file, prev_file = sys.argv[1:3] | ||
104 | |||
105 | elif len(sys.argv) == 1: | ||
106 | prev_baseline = get_param("prev_baseline") | ||
107 | prev_lic_file = get_param("prev_lic_file") | ||
108 | new_lic_file = get_param("new_lic_file") | ||
109 | |||
110 | new_file = os.path.relpath(os.path.join(repo_root, new_lic_file)) | ||
111 | prev_file = "%s:%s" % (prev_baseline, prev_lic_file) | ||
112 | print prev_file | ||
113 | print new_file | ||
114 | |||
115 | else: | ||
69 | sys.stderr.write("Usage:\n") | 116 | sys.stderr.write("Usage:\n") |
70 | sys.stderr.write(" %s " % sys.argv[0]) | 117 | sys.stderr.write(" 1) %s\n" % sys.argv[0]) |
118 | sys.stderr.write(" 2) %s " % sys.argv[0]) | ||
71 | sys.stderr.write("<new license file> <old license file>\n") | 119 | sys.stderr.write("<new license file> <old license file>\n") |
72 | sys.stderr.write("\n") | 120 | sys.stderr.write("\n") |
73 | sys.stderr.write(" E.g.:\n") | 121 | sys.stderr.write("In case 1, the files are specified using the following\n") |
74 | sys.stderr.write(" %s " % sys.argv[0]) | 122 | sys.stderr.write("parameters in pardoc-distro.xml:\n") |
75 | sys.stderr.write("licenses-5.0-ppc.xml licenses.xml\n") | 123 | sys.stderr.write(" - prev_baseline\n") |
124 | sys.stderr.write(" - prev_lic_file\n") | ||
125 | sys.stderr.write(" - new_lic_file\n") | ||
76 | exit() | 126 | exit() |
77 | 127 | ||
78 | new_file, old_file = sys.argv[1:3] | ||
79 | |||
80 | sys.stderr.write("New license file : %s\n" % new_file) | 128 | sys.stderr.write("New license file : %s\n" % new_file) |
81 | sys.stderr.write("Prev license file : %s\n" % old_file) | 129 | sys.stderr.write("Prev license file : %s\n" % prev_file) |
82 | 130 | ||
83 | old_pset, old_pdict = get_pkgs(old_file) | 131 | old_pset, old_pdict = get_pkgs(prev_file) |
84 | new_pset, new_pdict = get_pkgs(new_file) | 132 | new_pset, new_pdict = get_pkgs(new_file) |
85 | 133 | ||
86 | added = new_pset - old_pset # Set subtraction | 134 | added = new_pset - old_pset # Set subtraction |