summaryrefslogtreecommitdiffstats
path: root/scripts/oe-pkgdata-util
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/oe-pkgdata-util')
-rwxr-xr-xscripts/oe-pkgdata-util47
1 files changed, 28 insertions, 19 deletions
diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index 75dd23efa3..44ae40549a 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -96,7 +96,7 @@ def glob(args):
96 pn = os.path.basename(pkgdata_file) 96 pn = os.path.basename(pkgdata_file)
97 with open(pkgdata_file, 'r') as f: 97 with open(pkgdata_file, 'r') as f:
98 for line in f: 98 for line in f:
99 if line.startswith("PKG_%s:" % pn): 99 if line.startswith("PKG:%s:" % pn):
100 renamed = line.split(': ')[1].rstrip() 100 renamed = line.split(': ')[1].rstrip()
101 return renamed 101 return renamed
102 102
@@ -171,7 +171,7 @@ def read_value(args):
171 val = line.split(': ', 1)[1].rstrip() 171 val = line.split(': ', 1)[1].rstrip()
172 return val 172 return val
173 173
174 logger.debug("read-value('%s', '%s' '%s')" % (args.pkgdata_dir, args.valuename, packages)) 174 logger.debug("read-value('%s', '%s' '%s')" % (args.pkgdata_dir, args.valuenames, packages))
175 for package in packages: 175 for package in packages:
176 pkg_split = package.split('_') 176 pkg_split = package.split('_')
177 pkg_name = pkg_split[0] 177 pkg_name = pkg_split[0]
@@ -180,20 +180,29 @@ def read_value(args):
180 logger.debug(revlink) 180 logger.debug(revlink)
181 if os.path.exists(revlink): 181 if os.path.exists(revlink):
182 mappedpkg = os.path.basename(os.readlink(revlink)) 182 mappedpkg = os.path.basename(os.readlink(revlink))
183 qvar = args.valuename 183 qvars = args.valuenames
184 value = readvar(revlink, qvar, mappedpkg) 184 val_names = qvars.split(',')
185 if qvar == "PKGSIZE": 185 values = []
186 # PKGSIZE is now in bytes, but we we want it in KB 186 for qvar in val_names:
187 pkgsize = (int(value) + 1024 // 2) // 1024 187 if qvar == "PACKAGE":
188 value = "%d" % pkgsize 188 value = mappedpkg
189 if args.unescape: 189 else:
190 import codecs 190 value = readvar(revlink, qvar, mappedpkg)
191 # escape_decode() unescapes backslash encodings in byte streams 191 if qvar == "PKGSIZE":
192 value = codecs.escape_decode(bytes(value, "utf-8"))[0].decode("utf-8") 192 # PKGSIZE is now in bytes, but we we want it in KB
193 pkgsize = (int(value) + 1024 // 2) // 1024
194 value = "%d" % pkgsize
195 if args.unescape:
196 import codecs
197 # escape_decode() unescapes backslash encodings in byte streams
198 value = codecs.escape_decode(bytes(value, "utf-8"))[0].decode("utf-8")
199 values.append(value)
200
201 values_str = ' '.join(values)
193 if args.prefix_name: 202 if args.prefix_name:
194 print('%s %s' % (pkg_name, value)) 203 print('%s %s' % (pkg_name, values_str))
195 else: 204 else:
196 print(value) 205 print(values_str)
197 else: 206 else:
198 logger.debug("revlink %s does not exist", revlink) 207 logger.debug("revlink %s does not exist", revlink)
199 208
@@ -213,7 +222,7 @@ def lookup_pkglist(pkgs, pkgdata_dir, reverse):
213 with open(pkgfile, 'r') as f: 222 with open(pkgfile, 'r') as f:
214 for line in f: 223 for line in f:
215 fields = line.rstrip().split(': ') 224 fields = line.rstrip().split(': ')
216 if fields[0] == 'PKG_%s' % pkg: 225 if fields[0] == 'PKG:%s' % pkg:
217 mappings[pkg].append(fields[1]) 226 mappings[pkg].append(fields[1])
218 break 227 break
219 return mappings 228 return mappings
@@ -287,7 +296,7 @@ def package_info(args):
287 extra = '' 296 extra = ''
288 for line in f: 297 for line in f:
289 for var in vars: 298 for var in vars:
290 m = re.match(var + '(?:_\S+)?:\s*(.+?)\s*$', line) 299 m = re.match(var + r'(?::\S+)?:\s*(.+?)\s*$', line)
291 if m: 300 if m:
292 vals[var] = m.group(1) 301 vals[var] = m.group(1)
293 pkg_version = vals['PKGV'] or '' 302 pkg_version = vals['PKGV'] or ''
@@ -431,7 +440,7 @@ def list_pkg_files(args):
431 for line in f: 440 for line in f:
432 if line.startswith('FILES_INFO:'): 441 if line.startswith('FILES_INFO:'):
433 found = True 442 found = True
434 val = line.split(':', 1)[1].strip() 443 val = line.split(': ', 1)[1].strip()
435 dictval = json.loads(val) 444 dictval = json.loads(val)
436 if long: 445 if long:
437 width = max(map(len, dictval), default=0) 446 width = max(map(len, dictval), default=0)
@@ -500,7 +509,7 @@ def find_path(args):
500 with open(os.path.join(root,fn)) as f: 509 with open(os.path.join(root,fn)) as f:
501 for line in f: 510 for line in f:
502 if line.startswith('FILES_INFO:'): 511 if line.startswith('FILES_INFO:'):
503 val = line.split(':', 1)[1].strip() 512 val = line.split(': ', 1)[1].strip()
504 dictval = json.loads(val) 513 dictval = json.loads(val)
505 for fullpth in dictval.keys(): 514 for fullpth in dictval.keys():
506 if fnmatch.fnmatchcase(fullpth, args.targetpath): 515 if fnmatch.fnmatchcase(fullpth, args.targetpath):
@@ -570,7 +579,7 @@ def main():
570 parser_read_value = subparsers.add_parser('read-value', 579 parser_read_value = subparsers.add_parser('read-value',
571 help='Read any pkgdata value for one or more packages', 580 help='Read any pkgdata value for one or more packages',
572 description='Reads the named value from the pkgdata files for the specified packages') 581 description='Reads the named value from the pkgdata files for the specified packages')
573 parser_read_value.add_argument('valuename', help='Name of the value to look up') 582 parser_read_value.add_argument('valuenames', help='Name of the value/s to look up (separated by commas, no spaces)')
574 parser_read_value.add_argument('pkg', nargs='*', help='Runtime package name to look up') 583 parser_read_value.add_argument('pkg', nargs='*', help='Runtime package name to look up')
575 parser_read_value.add_argument('-f', '--file', help='Read package names from the specified file (one per line, first field only)') 584 parser_read_value.add_argument('-f', '--file', help='Read package names from the specified file (one per line, first field only)')
576 parser_read_value.add_argument('-n', '--prefix-name', help='Prefix output with package name', action='store_true') 585 parser_read_value.add_argument('-n', '--prefix-name', help='Prefix output with package name', action='store_true')