diff options
author | Tan Shen Joon <shen.joon.tan@intel.com> | 2017-08-10 06:57:01 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-01-29 08:49:50 +0000 |
commit | 4984b60c76171f76237373b8fb37d8094004307c (patch) | |
tree | 275c6bc5a5c17d7749c0505ae8e27b0036290cd0 /scripts/distro/build-recipe-list.py | |
parent | 5442688efe20d1cb7f33fd02e47cfe3d89014df6 (diff) | |
download | poky-4984b60c76171f76237373b8fb37d8094004307c.tar.gz |
distrodata: add a utility script to compare list of recipes
distrocompare.sh is added to compare the added list of recipes
between two releases. The output of the script will share the
information of the licenses required and other distributions
that are using the package.
If a single input is provided, it will compare the current
branch with the provided branch/commit-ish package list.
To run : distrocompare.sh <older hash> <newer hash>
E.g. distrocompare.sh morty 92aa0e7
E.g. distrocompare.sh morty pyro
E.g. distrocompare.sh morty
output : The script will produce a file ending with
new_recipe_list.txt preceeded by the branch name from input
(From OE-Core rev: 32b363c2ba91fde4f10e5fe2c898b2fc2702aa85)
Signed-off-by: Tan Shen Joon <shen.joon.tan@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'scripts/distro/build-recipe-list.py')
-rwxr-xr-x | scripts/distro/build-recipe-list.py | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/scripts/distro/build-recipe-list.py b/scripts/distro/build-recipe-list.py new file mode 100755 index 0000000000..407debaa76 --- /dev/null +++ b/scripts/distro/build-recipe-list.py | |||
@@ -0,0 +1,117 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | # | ||
3 | # Copyright (c) 2017, Intel Corporation. | ||
4 | # | ||
5 | # This program is free software; you can redistribute it and/or modify it | ||
6 | # under the terms and conditions of the GNU General Public License, | ||
7 | # version 2, as published by the Free Software Foundation. | ||
8 | # | ||
9 | # This program is distributed in the hope it will be useful, but WITHOUT | ||
10 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
11 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
12 | # more details. | ||
13 | # | ||
14 | |||
15 | import os | ||
16 | import shutil | ||
17 | import csv | ||
18 | import sys | ||
19 | import argparse | ||
20 | |||
21 | __version__ = "0.1.0" | ||
22 | |||
23 | recipenames = [] | ||
24 | allrecipes = [] | ||
25 | |||
26 | def gather_recipes(rows): | ||
27 | # store the data into the array | ||
28 | for row in rows: | ||
29 | if row[0] not in recipenames: | ||
30 | recipenames.append(row[0]) | ||
31 | allrecipes.append(row) | ||
32 | |||
33 | def generate_recipe_list(): | ||
34 | # machine list | ||
35 | machine_list = ( "qemuarm64", "qemuarm", "qemumips64", "qemumips", "qemuppc", "qemux86-64", "qemux86" ) | ||
36 | # set filename format | ||
37 | fnformat = 'distrodata.%s.csv' | ||
38 | |||
39 | # store all data files in distrodata | ||
40 | datadir = 'distrodata' | ||
41 | |||
42 | # create the directory if it does not exists | ||
43 | if not os.path.exists(datadir): | ||
44 | os.mkdir(datadir) | ||
45 | |||
46 | # doing bitbake distrodata | ||
47 | for machine in machine_list: | ||
48 | os.system('MACHINE='+ machine + ' bitbake world -c distrodata') | ||
49 | shutil.copy('tmp/log/distrodata.csv', 'distrodata/' + fnformat % machine) | ||
50 | |||
51 | for machine in machine_list: | ||
52 | with open('distrodata/' + fnformat % machine) as f: | ||
53 | reader = csv.reader(f) | ||
54 | rows = reader.__iter__() | ||
55 | gather_recipes(rows) | ||
56 | |||
57 | with open('recipe-list.txt', 'w') as f: | ||
58 | for recipe in sorted(recipenames): | ||
59 | f.write("%s\n" % recipe) | ||
60 | print("file : recipe-list.txt is created with %d entries." % len(recipenames)) | ||
61 | |||
62 | with open('all-recipe-list.txt', 'w') as f: | ||
63 | for recipe in sorted(allrecipes): | ||
64 | f.write("%s\n" % ','.join([str(data) for data in recipe])) | ||
65 | |||
66 | |||
67 | def diff_for_new_recipes(recipe1, recipe2): | ||
68 | prev_recipe_path = recipe1 + '/' | ||
69 | curr_recipe_path = recipe2 + '/' | ||
70 | if not os.path.isfile(prev_recipe_path + 'recipe-list.txt') or not os.path.isfile(curr_recipe_path + 'recipe-list.txt'): | ||
71 | print("recipe files do not exists. please verify that the file exists.") | ||
72 | exit(1) | ||
73 | |||
74 | import csv | ||
75 | |||
76 | prev = [] | ||
77 | new = [] | ||
78 | |||
79 | with open(prev_recipe_path + 'recipe-list.txt') as f: | ||
80 | prev = f.readlines() | ||
81 | |||
82 | with open(curr_recipe_path + 'recipe-list.txt') as f: | ||
83 | new = f.readlines() | ||
84 | |||
85 | updates = [] | ||
86 | for pn in new: | ||
87 | if not pn in prev: | ||
88 | updates.append(pn.rstrip()) | ||
89 | |||
90 | allrecipe = [] | ||
91 | with open(recipe1 + '_' + recipe2 + '_new_recipe_list.txt','w') as dr: | ||
92 | with open(curr_recipe_path + 'all-recipe-list.txt') as f: | ||
93 | reader = csv.reader(f, delimiter=',') | ||
94 | for row in reader: | ||
95 | if row[0] in updates: | ||
96 | dr.write("%s,%s,%s" % (row[0], row[3], row[5])) | ||
97 | if len(row[9:]) > 0: | ||
98 | dr.write(",%s" % ','.join(row[9:])) | ||
99 | dr.write("\n") | ||
100 | |||
101 | def main(argv): | ||
102 | if argv[0] == "generate_recipe_list": | ||
103 | generate_recipe_list() | ||
104 | elif argv[0] == "compare_recipe": | ||
105 | diff_for_new_recipes(argv[1], argv[2]) | ||
106 | else: | ||
107 | print("no such option. choose either 'generate_recipe_list' or 'compare_recipe'") | ||
108 | |||
109 | exit(0) | ||
110 | |||
111 | if __name__ == "__main__": | ||
112 | try: | ||
113 | sys.exit(main(sys.argv[1:])) | ||
114 | except Exception as e: | ||
115 | print("Exception :", e) | ||
116 | sys.exit(1) | ||
117 | |||