summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOla x Nilsson <ola.x.nilsson@axis.com>2016-12-12 17:19:29 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-14 09:56:32 +0000
commit6df99cda894033cba68bc6ab91e47f67e0d788a5 (patch)
tree2266b83f46f26a7b857ebd205df0d45dbaf89d07
parent4e412234c37efec42b3962c11d44903c0c58c92e (diff)
downloadopenembedded-core-6df99cda894033cba68bc6ab91e47f67e0d788a5.tar.gz
openembedded-core-6df99cda894033cba68bc6ab91e47f67e0d788a5.tar.bz2
openembedded-core-6df99cda894033cba68bc6ab91e47f67e0d788a5.zip
oe-pkgdata-util: Make read-value handle override variables
Some variables in pkgdata files have a package-name override. When the bare variable can not be found, try with the override-variant. PKGSIZE is one such variable, and already had special code to handle this. Test included. Signed-off-by: Ola x Nilsson <ola.x.nilsson@axis.com> Signed-off-by: Ross Burton <ross.burton@intel.com>
-rw-r--r--meta/lib/oeqa/selftest/pkgdata.py2
-rwxr-xr-xscripts/oe-pkgdata-util16
2 files changed, 10 insertions, 8 deletions
diff --git a/meta/lib/oeqa/selftest/pkgdata.py b/meta/lib/oeqa/selftest/pkgdata.py
index 5a63f89ff2..adfe346879 100644
--- a/meta/lib/oeqa/selftest/pkgdata.py
+++ b/meta/lib/oeqa/selftest/pkgdata.py
@@ -41,6 +41,8 @@ class OePkgdataUtilTests(oeSelfTest):
def test_read_value(self):
result = runCmd('oe-pkgdata-util read-value PN libz1')
self.assertEqual(result.output, 'zlib')
+ result = runCmd('oe-pkgdata-util read-value PKG libz1')
+ self.assertEqual(result.output, 'libz1')
result = runCmd('oe-pkgdata-util read-value PKGSIZE bash')
pkgsize = int(result.output.strip())
self.assertGreater(pkgsize, 1, "Size should be greater than 1. %s" % result.output)
diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index dbffd6a36b..fe41f41fa3 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -174,15 +174,16 @@ def read_value(args):
logger.error("No packages specified")
sys.exit(1)
- def readvar(pkgdata_file, valuename):
+ def readvar(pkgdata_file, valuename, mappedpkg):
val = ""
with open(pkgdata_file, 'r') as f:
for line in f:
- if line.startswith(valuename + ":"):
+ if (line.startswith(valuename + ":") or
+ line.startswith(valuename + "_" + mappedpkg + ":")):
val = line.split(': ', 1)[1].rstrip()
return val
- logger.debug("read-value('%s', '%s' '%s'" % (args.pkgdata_dir, args.valuename, packages))
+ logger.debug("read-value('%s', '%s' '%s')" % (args.pkgdata_dir, args.valuename, packages))
for package in packages:
pkg_split = package.split('_')
pkg_name = pkg_split[0]
@@ -192,18 +193,17 @@ def read_value(args):
if os.path.exists(revlink):
mappedpkg = os.path.basename(os.readlink(revlink))
qvar = args.valuename
+ value = readvar(revlink, qvar, mappedpkg)
if qvar == "PKGSIZE":
- # append packagename
- qvar = "%s_%s" % (args.valuename, mappedpkg)
# PKGSIZE is now in bytes, but we we want it in KB
- pkgsize = (int(readvar(revlink, qvar)) + 1024 // 2) // 1024
+ pkgsize = (int(value) + 1024 // 2) // 1024
value = "%d" % pkgsize
- else:
- value = readvar(revlink, qvar)
if args.prefix_name:
print('%s %s' % (pkg_name, value))
else:
print(value)
+ else:
+ logger.debug("revlink %s does not exist", revlink)
def lookup_pkglist(pkgs, pkgdata_dir, reverse):
if reverse: