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