blob: ce89491f60bdc5107dbac44fcc09efced052bbf0 [file] [log] [blame]
Patrick Williamsc0f7c042017-02-23 20:41:17 -06001#!/usr/bin/env python3
Patrick Williamsc124f4f2015-09-15 14:41:29 -05002
3# OpenEmbedded opkg query helper utility
4#
5# Written by: Paul Eggleton <paul.eggleton@linux.intel.com>
6#
7# Copyright 2012 Intel Corporation
8#
9# This program is free software; you can redistribute it and/or modify
10# it under the terms of the GNU General Public License version 2 as
11# published by the Free Software Foundation.
12#
13# This program is distributed in the hope that it will be useful,
14# but WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16# GNU General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License along
19# with this program; if not, write to the Free Software Foundation, Inc.,
20# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21#
22#
23
24
25import sys
26import fileinput
27import re
28
29archmode = False
30filemode = False
31vermode = False
32
33args = []
34for arg in sys.argv[1:]:
35 if arg == '-a':
36 archmode = True
37 elif arg == '-f':
38 filemode = True
39 elif arg == '-v':
40 vermode = True
41 else:
42 args.append(arg)
43
44# Regex for removing version specs after dependency items
45verregex = re.compile(' \([=<>]* [^ )]*\)')
46
47pkg = ""
48ver = ""
49for line in fileinput.input(args):
50 line = line.rstrip()
51 if ': ' in line:
52 if line.startswith("Package:"):
53 pkg = line.split(": ")[1]
54 ver = ""
55 else:
56 if archmode:
57 if line.startswith("Architecture:"):
58 arch = line.split(": ")[1]
59 print("%s %s" % (pkg,arch))
60 elif filemode:
61 if line.startswith("Version:"):
62 ver = line.split(": ")[1]
63 elif line.startswith("Architecture:"):
64 arch = line.split(": ")[1]
65 print("%s %s_%s_%s.ipk %s" % (pkg,pkg,ver,arch,arch))
66 elif vermode:
67 if line.startswith("Version:"):
68 ver = line.split(": ")[1]
69 elif line.startswith("Architecture:"):
70 arch = line.split(": ")[1]
71 print("%s %s %s" % (pkg,arch,ver))
72 else:
73 if line.startswith("Depends:"):
74 depval = line.split(": ")[1]
75 deps = depval.split(", ")
76 for dep in deps:
77 dep = verregex.sub('', dep)
78 print("%s|%s" % (pkg,dep))
79 elif line.startswith("Recommends:"):
80 recval = line.split(": ")[1]
81 recs = recval.split(", ")
82 for rec in recs:
83 rec = verregex.sub('', rec)
84 print("%s|%s [REC]" % (pkg, rec))
85