]>
Commit | Line | Data |
---|---|---|
4b544ff3 | 1 | #!/usr/bin/env python3 |
72d1048a PE |
2 | |
3 | # OpenEmbedded opkg query helper utility | |
4 | # | |
5 | # Written by: Paul Eggleton <paul.eggleton@linux.intel.com> | |
6 | # | |
7 | # Copyright 2012 Intel Corporation | |
8 | # | |
f8c9c511 | 9 | # SPDX-License-Identifier: GPL-2.0-only |
72d1048a | 10 | # |
72d1048a PE |
11 | |
12 | import sys | |
13 | import fileinput | |
14 | import re | |
15 | ||
16 | archmode = False | |
17 | filemode = False | |
2978d1f2 | 18 | vermode = False |
72d1048a PE |
19 | |
20 | args = [] | |
21 | for arg in sys.argv[1:]: | |
22 | if arg == '-a': | |
23 | archmode = True | |
24 | elif arg == '-f': | |
25 | filemode = True | |
2978d1f2 PE |
26 | elif arg == '-v': |
27 | vermode = True | |
72d1048a PE |
28 | else: |
29 | args.append(arg) | |
30 | ||
31 | # Regex for removing version specs after dependency items | |
24b0ba00 | 32 | verregex = re.compile(r' \([=<>]* [^ )]*\)') |
72d1048a PE |
33 | |
34 | pkg = "" | |
35 | ver = "" | |
36 | for line in fileinput.input(args): | |
37 | line = line.rstrip() | |
38 | if ': ' in line: | |
39 | if line.startswith("Package:"): | |
40 | pkg = line.split(": ")[1] | |
41 | ver = "" | |
42 | else: | |
43 | if archmode: | |
44 | if line.startswith("Architecture:"): | |
45 | arch = line.split(": ")[1] | |
46 | print("%s %s" % (pkg,arch)) | |
47 | elif filemode: | |
48 | if line.startswith("Version:"): | |
49 | ver = line.split(": ")[1] | |
50 | elif line.startswith("Architecture:"): | |
51 | arch = line.split(": ")[1] | |
85e4a771 | 52 | print("%s %s_%s_%s.ipk %s" % (pkg,pkg,ver,arch,arch)) |
2978d1f2 PE |
53 | elif vermode: |
54 | if line.startswith("Version:"): | |
55 | ver = line.split(": ")[1] | |
56 | elif line.startswith("Architecture:"): | |
57 | arch = line.split(": ")[1] | |
58 | print("%s %s %s" % (pkg,arch,ver)) | |
72d1048a PE |
59 | else: |
60 | if line.startswith("Depends:"): | |
61 | depval = line.split(": ")[1] | |
62 | deps = depval.split(", ") | |
63 | for dep in deps: | |
64 | dep = verregex.sub('', dep) | |
65 | print("%s|%s" % (pkg,dep)) | |
66 | elif line.startswith("Recommends:"): | |
67 | recval = line.split(": ")[1] | |
68 | recs = recval.split(", ") | |
69 | for rec in recs: | |
70 | rec = verregex.sub('', rec) | |
71 | print("%s|%s [REC]" % (pkg, rec)) | |
72 |