diff options
Diffstat (limited to 'scripts/find_packages.py')
-rwxr-xr-x | scripts/find_packages.py | 125 |
1 files changed, 0 insertions, 125 deletions
diff --git a/scripts/find_packages.py b/scripts/find_packages.py deleted file mode 100755 index 7a60a17..0000000 --- a/scripts/find_packages.py +++ /dev/null | |||
@@ -1,125 +0,0 @@ | |||
1 | #!/usr/bin/env python3 | ||
2 | |||
3 | import os.path | ||
4 | import sys | ||
5 | |||
6 | scripts_path = os.path.dirname(os.path.realpath(__file__)) | ||
7 | bb_lib_path = os.path.abspath(scripts_path + '/../../poky/bitbake/lib') | ||
8 | sys.path = sys.path + [bb_lib_path] | ||
9 | |||
10 | import bb.fetch2 | ||
11 | import bb.tinfoil | ||
12 | |||
13 | |||
14 | def print_deps(tinfoil, abcd_file, rn): | ||
15 | try: | ||
16 | info = tinfoil.get_recipe_info(rn) | ||
17 | except Exception: | ||
18 | print('Failed to get recipe info for: %s' % rn) | ||
19 | return [] | ||
20 | if not info: | ||
21 | print('No recipe info found for: %s' % rn) | ||
22 | return [] | ||
23 | append_files = tinfoil.get_file_appends(info.fn) | ||
24 | appends = True | ||
25 | data = tinfoil.parse_recipe_file(info.fn, appends, append_files) | ||
26 | src_uri = data.getVar('SRC_URI').split() | ||
27 | lic = data.getVar('LICENSE') | ||
28 | summary = data.getVar('SUMMARY') | ||
29 | description = data.getVar('DESCRIPTION') | ||
30 | homepage = data.getVar('HOMEPAGE') | ||
31 | srcrev = data.getVar('SRCREV') | ||
32 | branch = data.getVar('BRANCH') | ||
33 | depends = data.getVar('DEPENDS').split() | ||
34 | |||
35 | abcd_file.write('- id:\n') | ||
36 | abcd_file.write(' package_manager: "Yocto"\n') | ||
37 | abcd_file.write(' name: "%s"\n' % info.pn) | ||
38 | abcd_file.write(' version: "%s"\n' % info.pv) | ||
39 | abcd_file.write(' declared_lics:\n') | ||
40 | abcd_file.write(' - "%s"\n' % lic) | ||
41 | if summary: | ||
42 | abcd_file.write(' description: "%s"\n' % summary) | ||
43 | else: | ||
44 | abcd_file.write(' description: "%s"\n' % description) | ||
45 | abcd_file.write(' homepage_url: "%s"\n' % homepage) | ||
46 | abcd_file.write(' source_artifact:\n') | ||
47 | repos = [] | ||
48 | for src in src_uri: | ||
49 | # Strip options. | ||
50 | # TODO: ignore files with apply=false? | ||
51 | src = src.split(';', maxsplit=1)[0] | ||
52 | src_type = src.split('://', maxsplit=1)[0] | ||
53 | if src_type == 'file': | ||
54 | # TODO: Get full path of patches and other files within the source | ||
55 | # repo, not just the filesystem? | ||
56 | fetch = bb.fetch2.Fetch([], data) | ||
57 | local = fetch.localpath(src) | ||
58 | abcd_file.write(' - "%s"\n' % local) | ||
59 | else: | ||
60 | abcd_file.write(' - "%s"\n' % src) | ||
61 | if src_type != 'http' and src_type != 'https' and src_type != 'ftp' and src_type != 'ssh': | ||
62 | repos.append(src) | ||
63 | if len(repos) > 1: | ||
64 | print('Multiple repos not fully supported yet. Pacakge: %s' % info.pn) | ||
65 | for repo in repos: | ||
66 | vcs_type, url = repo.split('://', maxsplit=1) | ||
67 | abcd_file.write(' vcs:\n') | ||
68 | if vcs_type == 'gitsm': | ||
69 | vcs_type = 'git' | ||
70 | abcd_file.write(' type: "%s"\n' % vcs_type) | ||
71 | abcd_file.write(' url: "%s"\n' % url) | ||
72 | # TODO: Actually support multiple repos here: | ||
73 | abcd_file.write(' revision: "%s"\n' % srcrev) | ||
74 | abcd_file.write(' branch: "%s"\n' % branch) | ||
75 | |||
76 | abcd_file.write(' dependencies:\n') | ||
77 | for dep in depends: | ||
78 | abcd_file.write(' - "%s"\n' % dep) | ||
79 | # TODO: search for transitive dependencies here? Each dependency will | ||
80 | # get checked for its own dependencies sooner or later. | ||
81 | |||
82 | return depends | ||
83 | |||
84 | |||
85 | def main(): | ||
86 | abcd_manifest = 'manifest.abcd' | ||
87 | with open(abcd_manifest, "w") as abcd_file, bb.tinfoil.Tinfoil() as tinfoil: | ||
88 | tinfoil.prepare() | ||
89 | # These are the packages that bitbake assumes are provided by the host | ||
90 | # system. They do not have recipes, so searching tinfoil for them will | ||
91 | # not work. Anyway, by nature they are not included in code we release, | ||
92 | # only used by it. | ||
93 | assume_provided = tinfoil.config_data.getVar('ASSUME_PROVIDED').split() | ||
94 | abcd_file.write('packages:\n') | ||
95 | |||
96 | # Does NOT include garage-sign, anything used only for testing (i.e. | ||
97 | # strace and gtest), any of the git submodules, all of which are also | ||
98 | # only used for testing (tuf-test-vectors, isotp-c, ostreesysroot, | ||
99 | # and HdrHistogram_c), or any other third party modules included | ||
100 | # directly into the source tree (jsoncpp, open62541, picojson) | ||
101 | recipes_to_check = ['aktualizr', | ||
102 | 'aktualizr-native', | ||
103 | 'aktualizr-auto-prov', | ||
104 | 'aktualizr-implicit-prov', | ||
105 | 'aktualizr-ca-implicit-prov', | ||
106 | 'aktualizr-hsm-prov', | ||
107 | 'aktualizr-disable-send-ip', | ||
108 | 'aktualizr-example-interface', | ||
109 | 'aktualizr-log-debug', | ||
110 | 'libp11', # BUILD_P11 (HSM) only | ||
111 | 'dpkg', # BUILD_DEB only | ||
112 | 'systemd'] # BUILD_SYSTEMD only | ||
113 | |||
114 | # Iterate through the list of recipes to check. Append any dependencies | ||
115 | # found that aren't already in the list. As long as we only add to the | ||
116 | # list, it should be safe. | ||
117 | for recipe in recipes_to_check: | ||
118 | depends = print_deps(tinfoil, abcd_file, recipe) | ||
119 | for dep in depends: | ||
120 | if dep not in recipes_to_check and dep not in assume_provided: | ||
121 | recipes_to_check.append(dep) | ||
122 | |||
123 | |||
124 | if __name__ == "__main__": | ||
125 | main() | ||