diff options
author | Patrick Vacek <patrickvacek@gmail.com> | 2018-05-22 17:56:35 +0200 |
---|---|---|
committer | Patrick Vacek <patrickvacek@gmail.com> | 2018-05-28 13:19:43 +0200 |
commit | c3d3a0d42416867d92c77e9b5e3e8879b64b3409 (patch) | |
tree | e7e7b28f60a18b944754e8037292e2f2db976cdb | |
parent | b799d9c4a83de82bc4e0664ed63c788955b33a68 (diff) | |
download | meta-updater-c3d3a0d42416867d92c77e9b5e3e8879b64b3409.tar.gz |
find_packages.py: Initial version.
Finds aktualizr package information for OSS Review Toolkit.
-rwxr-xr-x | scripts/find_packages.py | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/scripts/find_packages.py b/scripts/find_packages.py new file mode 100755 index 0000000..4b1680b --- /dev/null +++ b/scripts/find_packages.py | |||
@@ -0,0 +1,87 @@ | |||
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 | lib_path = os.path.abspath(scripts_path + '/../../poky/bitbake/lib') | ||
8 | sys.path = sys.path + [lib_path] | ||
9 | |||
10 | import bb.tinfoil | ||
11 | |||
12 | |||
13 | def print_deps(tinfoil, abcd_file, rn): | ||
14 | try: | ||
15 | info = tinfoil.get_recipe_info(rn) | ||
16 | except: | ||
17 | # fails on hostperl-runtime-native, virtual/libintl-native, grep-native, virtual/libiconv-native | ||
18 | print('failing on: %s' % rn) | ||
19 | return [] | ||
20 | append_files = tinfoil.get_file_appends(info.fn) | ||
21 | appends = True | ||
22 | data = tinfoil.parse_recipe_file(info.fn, appends, append_files) | ||
23 | src_uri = data.getVar('SRC_URI').split() | ||
24 | lic = data.getVar('LICENSE') | ||
25 | summary = data.getVar('SUMMARY') | ||
26 | description = data.getVar('DESCRIPTION') | ||
27 | homepage = data.getVar('HOMEPAGE') | ||
28 | srcrev = data.getVar('SRCREV') | ||
29 | branch = data.getVar('BRANCH') | ||
30 | depends = data.getVar('DEPENDS').split() | ||
31 | |||
32 | abcd_file.write('- id:\n') | ||
33 | abcd_file.write(' package_manager: "Yocto"\n') | ||
34 | abcd_file.write(' name: "%s"\n' % info.pn) | ||
35 | abcd_file.write(' version: "%s"\n' % info.pv) | ||
36 | abcd_file.write(' declared_lics:\n') | ||
37 | abcd_file.write(' - "%s"\n' % lic) | ||
38 | if summary: | ||
39 | abcd_file.write(' description: "%s"\n' % summary) | ||
40 | else: | ||
41 | abcd_file.write(' description: "%s"\n' % description) | ||
42 | abcd_file.write(' homepage_url: "%s"\n' % homepage) | ||
43 | abcd_file.write(' source_artifact:\n') | ||
44 | for src in src_uri: | ||
45 | # TODO: Get full path of patches? | ||
46 | abcd_file.write(' - "%s"\n' % src) | ||
47 | # TODO: Check more than the first and not just git | ||
48 | if src_uri and 'git' in src_uri[0]: | ||
49 | abcd_file.write(' vcs:\n') | ||
50 | abcd_file.write(' type: "git"\n') | ||
51 | abcd_file.write(' url: "%s"\n' % src_uri[0]) | ||
52 | abcd_file.write(' revision: "%s"\n' % srcrev) | ||
53 | abcd_file.write(' branch: "%s"\n' % branch) | ||
54 | |||
55 | abcd_file.write(' dependencies:\n') | ||
56 | for dep in depends: | ||
57 | abcd_file.write(' - "%s"\n' % dep) | ||
58 | # TODO: continue nesting here? | ||
59 | |||
60 | return depends | ||
61 | |||
62 | |||
63 | def main(): | ||
64 | abcd_manifest = 'manifest.abcd' | ||
65 | with open(abcd_manifest, "w") as abcd_file, bb.tinfoil.Tinfoil() as tinfoil: | ||
66 | tinfoil.prepare() | ||
67 | abcd_file.write('packages:\n') | ||
68 | |||
69 | recipes_to_check = ['aktualizr', | ||
70 | 'aktualizr-native', | ||
71 | 'aktualizr-auto-prov', | ||
72 | 'aktualizr-implicit-prov', | ||
73 | 'aktualizr-ca-implicit-prov', | ||
74 | 'aktualizr-hsm-prov', | ||
75 | 'aktualizr-disable-send-ip', | ||
76 | 'aktualizr-example-interface', | ||
77 | 'aktualizr-log-debug'] | ||
78 | |||
79 | for recipe in recipes_to_check: | ||
80 | depends = print_deps(tinfoil, abcd_file, recipe) | ||
81 | for dep in depends: | ||
82 | if dep not in recipes_to_check: | ||
83 | recipes_to_check.append(dep) | ||
84 | |||
85 | |||
86 | if __name__ == "__main__": | ||
87 | main() | ||