summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Vacek <patrickvacek@gmail.com>2018-05-22 17:56:35 +0200
committerPatrick Vacek <patrickvacek@gmail.com>2018-05-28 13:19:43 +0200
commitc3d3a0d42416867d92c77e9b5e3e8879b64b3409 (patch)
treee7e7b28f60a18b944754e8037292e2f2db976cdb
parentb799d9c4a83de82bc4e0664ed63c788955b33a68 (diff)
downloadmeta-updater-c3d3a0d42416867d92c77e9b5e3e8879b64b3409.tar.gz
find_packages.py: Initial version.
Finds aktualizr package information for OSS Review Toolkit.
-rwxr-xr-xscripts/find_packages.py87
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
3import os.path
4import sys
5
6scripts_path = os.path.dirname(os.path.realpath(__file__))
7lib_path = os.path.abspath(scripts_path + '/../../poky/bitbake/lib')
8sys.path = sys.path + [lib_path]
9
10import bb.tinfoil
11
12
13def 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
63def 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
86if __name__ == "__main__":
87 main()