* [PATCH V2 0/2]
@ 2018-01-18 23:18 Amanda Brindle
2018-01-18 23:18 ` [PATCH V2 1/2] oe-pkgdata-util: Refactor functions for consistency Amanda Brindle
2018-01-18 23:18 ` [PATCH V2 2/2] oe-pkgdata-util: Add support for RPROVIDES Amanda Brindle
0 siblings, 2 replies; 4+ messages in thread
From: Amanda Brindle @ 2018-01-18 23:18 UTC (permalink / raw)
To: openembedded-core; +Cc: paul.eggleton, Amanda Brindle
In V2, fixed an error that did not list all packages if multiple packages were specified
on the command line.
The following changes since commit cf75fd5ae07355951b1f90d13842552a99e61063:
contrib/yocto-bsp-kernel-update.sh: remove this script (2018-01-18 13:05:56 +0000)
are available in the git repository at:
git://git.yoctoproject.org/poky-contrib abrindle/rprovides
http://git.yoctoproject.org/cgit.cgi/poky-contrib/log/?h=abrindle/rprovides
Amanda Brindle (2):
oe-pkgdata-util: Refactor functions for consistency
oe-pkgdata-util: Add support for RPROVIDES
scripts/oe-pkgdata-util | 173 +++++++++++++++++++++++++++---------------------
1 file changed, 97 insertions(+), 76 deletions(-)
--
2.7.4
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH V2 1/2] oe-pkgdata-util: Refactor functions for consistency
2018-01-18 23:18 [PATCH V2 0/2] Amanda Brindle
@ 2018-01-18 23:18 ` Amanda Brindle
2018-01-22 20:12 ` Paul Eggleton
2018-01-18 23:18 ` [PATCH V2 2/2] oe-pkgdata-util: Add support for RPROVIDES Amanda Brindle
1 sibling, 1 reply; 4+ messages in thread
From: Amanda Brindle @ 2018-01-18 23:18 UTC (permalink / raw)
To: openembedded-core; +Cc: paul.eggleton, Amanda Brindle
Refactor functions lookup_recipe and package_info to be consistent with
list_pkg_files. Print the appropriate information as soon as it's found,
rather than storing it in a mappings variable and wait to print after
searching all packages.
Signed-off-by: Amanda Brindle <amanda.r.brindle@intel.com>
---
scripts/oe-pkgdata-util | 107 ++++++++++++++++++++++--------------------------
1 file changed, 48 insertions(+), 59 deletions(-)
diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index c6fba56..e4ccf30 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -257,25 +257,22 @@ def lookup_recipe(args):
for pkgitem in args.pkg:
pkgs.extend(pkgitem.split())
- mappings = defaultdict(list)
for pkg in pkgs:
- pkgfile = os.path.join(args.pkgdata_dir, 'runtime-reverse', pkg)
- if os.path.exists(pkgfile):
- with open(pkgfile, 'r') as f:
+ pkgdatafile = os.path.join(args.pkgdata_dir, 'runtime-reverse', pkg)
+ if os.path.exists(pkgdatafile):
+ with open(pkgdatafile, 'r') as f:
+ found = False
for line in f:
- fields = line.rstrip().split(': ')
- if fields[0] == 'PN':
- mappings[pkg].append(fields[1])
+ if line.startswith('PN'):
+ print("\t%s" % line.split(':', 1)[1].strip())
+ found = True
break
- if len(mappings) < len(pkgs):
- missing = list(set(pkgs) - set(mappings.keys()))
- logger.error("The following packages could not be found: %s" % ', '.join(missing))
- sys.exit(1)
-
- items = []
- for pkg in pkgs:
- items.extend(mappings.get(pkg, []))
- print('\n'.join(items))
+ if not found:
+ logger.error("Unable to find PN entry in %s" % pkgdatafile)
+ sys.exit(1)
+ else:
+ logger.error("Unable to find any built runtime package named %s" % pkg)
+ sys.exit(1)
def package_info(args):
# Handle both multiple arguments and multiple values within an arg (old syntax)
@@ -293,51 +290,43 @@ def package_info(args):
logger.error("No packages specified")
sys.exit(1)
- mappings = defaultdict(lambda: defaultdict(str))
for pkg in packages:
- pkgfile = os.path.join(args.pkgdata_dir, 'runtime-reverse', pkg)
- if os.path.exists(pkgfile):
- with open(pkgfile, 'r') as f:
+ pkgdatafile = os.path.join(args.pkgdata_dir, 'runtime-reverse', pkg)
+ if os.path.exists(pkgdatafile):
+ with open(pkgdatafile, 'r') as f:
+ pkge = ''
+ pkgr = ''
+ pe = ''
+ pr = ''
for line in f:
- fields = line.rstrip().split(': ')
- if fields[0].endswith("_" + pkg):
- k = fields[0][:len(fields[0]) - len(pkg) - 1]
- else:
- k = fields[0]
- v = fields[1] if len(fields) == 2 else ""
- mappings[pkg][k] = v
-
- if len(mappings) < len(packages):
- missing = list(set(packages) - set(mappings.keys()))
- logger.error("The following packages could not be found: %s" %
- ', '.join(missing))
- sys.exit(1)
-
- items = []
- for pkg in packages:
- pkg_version = mappings[pkg]['PKGV']
- if mappings[pkg]['PKGE']:
- pkg_version = mappings[pkg]['PKGE'] + ":" + pkg_version
- if mappings[pkg]['PKGR']:
- pkg_version = pkg_version + "-" + mappings[pkg]['PKGR']
- recipe = mappings[pkg]['PN']
- recipe_version = mappings[pkg]['PV']
- if mappings[pkg]['PE']:
- recipe_version = mappings[pkg]['PE'] + ":" + recipe_version
- if mappings[pkg]['PR']:
- recipe_version = recipe_version + "-" + mappings[pkg]['PR']
- pkg_size = mappings[pkg]['PKGSIZE']
-
- line = "%s %s %s %s %s" % (pkg, pkg_version, recipe, recipe_version, pkg_size)
-
- if args.extra:
- for var in args.extra:
- val = mappings[pkg][var].strip()
- val = re.sub(r'\s+', ' ', val)
- line += ' "%s"' % val
-
- items.append(line)
- print('\n'.join(items))
+ if line.startswith('PKGV'):
+ pkg_version = line.split(':', 1)[1].strip()
+ elif line.startswith('PKGE'):
+ pkge = line.split(':', 1)[1].strip()
+ elif line.startswith('PKGR'):
+ pkgr = line.split(':', 1)[1].strip()
+ elif line.startswith('PN'):
+ recipe = line.split(':', 1)[1].strip()
+ elif line.startswith('PV'):
+ recipe_version = line.split(':', 1)[1].strip()
+ elif line.startswith('PE'):
+ pe = line.split(':', 1)[1].strip()
+ elif line.startswith('PR'):
+ pr = line.split(':', 1)[1].strip()
+ elif line.startswith('PKGSIZE'):
+ pkg_size = line.split(':', 1)[1].strip()
+ if pkge:
+ pkg_version = pkge + ":" + pkg_version
+ if pkgr:
+ pkg_version = pkg_version + "-" + pkgr
+ if pe:
+ recipe_version = pe + ":" + recipe_version
+ if pr:
+ recipe_version = recipe_version + "-" + pr
+ print("%s %s %s %s %s" % (pkg, pkg_version, recipe, recipe_version, pkg_size))
+ else:
+ logger.error("Unable to find any built runtime package named %s" % pkg)
+ sys.exit(1)
def get_recipe_pkgs(pkgdata_dir, recipe, unpackaged):
recipedatafile = os.path.join(pkgdata_dir, recipe)
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH V2 2/2] oe-pkgdata-util: Add support for RPROVIDES
2018-01-18 23:18 [PATCH V2 0/2] Amanda Brindle
2018-01-18 23:18 ` [PATCH V2 1/2] oe-pkgdata-util: Refactor functions for consistency Amanda Brindle
@ 2018-01-18 23:18 ` Amanda Brindle
1 sibling, 0 replies; 4+ messages in thread
From: Amanda Brindle @ 2018-01-18 23:18 UTC (permalink / raw)
To: openembedded-core; +Cc: paul.eggleton, Amanda Brindle
In lookup_recipe, package_info, and list_pkg_files, check if the package
name exists in runtime-rprovides. If so, and the provider package has a
different name than the inputted package, print a note that says the
specified package is in another package's RPROVIDES. If the provider
package has the same name as the inputted package, continue as before.
Fixes [YOCTO 11943]
Signed-off-by: Amanda Brindle <amanda.r.brindle@intel.com>
---
scripts/oe-pkgdata-util | 154 +++++++++++++++++++++++++++++-------------------
1 file changed, 93 insertions(+), 61 deletions(-)
diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
index e4ccf30..040854f 100755
--- a/scripts/oe-pkgdata-util
+++ b/scripts/oe-pkgdata-util
@@ -252,29 +252,72 @@ def lookup_pkg(args):
print('\n'.join(items))
def lookup_recipe(args):
+ def parse_pkgdatafile(pkgdatafile):
+ with open(pkgdatafile, 'r') as f:
+ found = False
+ for line in f:
+ if line.startswith('PN'):
+ print("%s" % line.split(':', 1)[1].strip())
+ found = True
+ break
+ if not found:
+ logger.error("Unable to find PN entry in %s" % pkgdatafile)
+ sys.exit(1)
+
# Handle both multiple arguments and multiple values within an arg (old syntax)
pkgs = []
for pkgitem in args.pkg:
pkgs.extend(pkgitem.split())
for pkg in pkgs:
+ providepkgpath = os.path.join(args.pkgdata_dir, "runtime-rprovides", pkg)
+ if os.path.exists(providepkgpath):
+ for f in os.listdir(providepkgpath):
+ if f != pkg:
+ print("%s is in the RPROVIDES of %s:" % (pkg, f))
+ pkgdatafile = os.path.join(args.pkgdata_dir, "runtime", f)
+ parse_pkgdatafile(pkgdatafile)
+ break
pkgdatafile = os.path.join(args.pkgdata_dir, 'runtime-reverse', pkg)
- if os.path.exists(pkgdatafile):
- with open(pkgdatafile, 'r') as f:
- found = False
- for line in f:
- if line.startswith('PN'):
- print("\t%s" % line.split(':', 1)[1].strip())
- found = True
- break
- if not found:
- logger.error("Unable to find PN entry in %s" % pkgdatafile)
- sys.exit(1)
- else:
- logger.error("Unable to find any built runtime package named %s" % pkg)
+ if not os.path.exists(pkgdatafile):
+ logger.error("The following packages could not be found: %s" % pkg)
sys.exit(1)
+ parse_pkgdatafile(pkgdatafile)
def package_info(args):
+ def parse_pkgdatafile(pkgdatafile):
+ with open(pkgdatafile, 'r') as f:
+ pkge = ''
+ pkgr = ''
+ pe = ''
+ pr = ''
+ for line in f:
+ if line.startswith('PKGV'):
+ pkg_version = line.split(':', 1)[1].strip()
+ elif line.startswith('PKGE'):
+ pkge = line.split(':', 1)[1].strip()
+ elif line.startswith('PKGR'):
+ pkgr = line.split(':', 1)[1].strip()
+ elif line.startswith('PN'):
+ recipe = line.split(':', 1)[1].strip()
+ elif line.startswith('PV'):
+ recipe_version = line.split(':', 1)[1].strip()
+ elif line.startswith('PE'):
+ pe = line.split(':', 1)[1].strip()
+ elif line.startswith('PR'):
+ pr = line.split(':', 1)[1].strip()
+ elif line.startswith('PKGSIZE'):
+ pkg_size = line.split(':', 1)[1].strip()
+ if pkge:
+ pkg_version = pkge + ":" + pkg_version
+ if pkgr:
+ pkg_version = pkg_version + "-" + pkgr
+ if pe:
+ recipe_version = pe + ":" + recipe_version
+ if pr:
+ recipe_version = recipe_version + "-" + pr
+ print("%s %s %s %s %s" % (pkg, pkg_version, recipe, recipe_version, pkg_size))
+
# Handle both multiple arguments and multiple values within an arg (old syntax)
packages = []
if args.file:
@@ -291,42 +334,19 @@ def package_info(args):
sys.exit(1)
for pkg in packages:
- pkgdatafile = os.path.join(args.pkgdata_dir, 'runtime-reverse', pkg)
- if os.path.exists(pkgdatafile):
- with open(pkgdatafile, 'r') as f:
- pkge = ''
- pkgr = ''
- pe = ''
- pr = ''
- for line in f:
- if line.startswith('PKGV'):
- pkg_version = line.split(':', 1)[1].strip()
- elif line.startswith('PKGE'):
- pkge = line.split(':', 1)[1].strip()
- elif line.startswith('PKGR'):
- pkgr = line.split(':', 1)[1].strip()
- elif line.startswith('PN'):
- recipe = line.split(':', 1)[1].strip()
- elif line.startswith('PV'):
- recipe_version = line.split(':', 1)[1].strip()
- elif line.startswith('PE'):
- pe = line.split(':', 1)[1].strip()
- elif line.startswith('PR'):
- pr = line.split(':', 1)[1].strip()
- elif line.startswith('PKGSIZE'):
- pkg_size = line.split(':', 1)[1].strip()
- if pkge:
- pkg_version = pkge + ":" + pkg_version
- if pkgr:
- pkg_version = pkg_version + "-" + pkgr
- if pe:
- recipe_version = pe + ":" + recipe_version
- if pr:
- recipe_version = recipe_version + "-" + pr
- print("%s %s %s %s %s" % (pkg, pkg_version, recipe, recipe_version, pkg_size))
- else:
+ providepkgpath = os.path.join(args.pkgdata_dir, "runtime-rprovides", pkg)
+ if os.path.exists(providepkgpath):
+ for f in os.listdir(providepkgpath):
+ if f != pkg:
+ print("%s is in the RPROVIDES of %s:" % (pkg, f))
+ pkgdatafile = os.path.join(args.pkgdata_dir, "runtime", f)
+ parse_pkgdatafile(pkgdatafile)
+ break
+ pkgdatafile = os.path.join(args.pkgdata_dir, "runtime-reverse", pkg)
+ if not os.path.exists(pkgdatafile):
logger.error("Unable to find any built runtime package named %s" % pkg)
sys.exit(1)
+ parse_pkgdatafile(pkgdatafile)
def get_recipe_pkgs(pkgdata_dir, recipe, unpackaged):
recipedatafile = os.path.join(pkgdata_dir, recipe)
@@ -415,6 +435,21 @@ def list_pkgs(args):
def list_pkg_files(args):
import json
+ def parse_pkgdatafile(pkgdatafile):
+ with open(pkgdatafile, 'r') as f:
+ found = False
+ for line in f:
+ if line.startswith('FILES_INFO:'):
+ found = True
+ val = line.split(':', 1)[1].strip()
+ dictval = json.loads(val)
+ for fullpth in sorted(dictval):
+ print("\t%s" % fullpth)
+ break
+ if not found:
+ logger.error("Unable to find FILES_INFO entry in %s" % pkgdatafile)
+ sys.exit(1)
+
if args.recipe:
if args.pkg:
@@ -444,25 +479,22 @@ def list_pkg_files(args):
continue
logger.error("Unable to find any built runtime package named %s" % pkg)
sys.exit(1)
+ parse_pkgdatafile(pkgdatafile)
+
else:
+ providepkgpath = os.path.join(args.pkgdata_dir, "runtime-rprovides", pkg)
+ if os.path.exists(providepkgpath):
+ for f in os.listdir(providepkgpath):
+ if f != pkg:
+ print("%s is in the RPROVIDES of %s:" % (pkg, f))
+ pkgdatafile = os.path.join(args.pkgdata_dir, "runtime", f)
+ parse_pkgdatafile(pkgdatafile)
+ continue
pkgdatafile = os.path.join(args.pkgdata_dir, "runtime", pkg)
if not os.path.exists(pkgdatafile):
logger.error("Unable to find any built recipe-space package named %s" % pkg)
sys.exit(1)
-
- with open(pkgdatafile, 'r') as f:
- found = False
- for line in f:
- if line.startswith('FILES_INFO:'):
- found = True
- val = line.split(':', 1)[1].strip()
- dictval = json.loads(val)
- for fullpth in sorted(dictval):
- print("\t%s" % fullpth)
- break
- if not found:
- logger.error("Unable to find FILES_INFO entry in %s" % pkgdatafile)
- sys.exit(1)
+ parse_pkgdatafile(pkgdatafile)
def find_path(args):
import json
--
2.7.4
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH V2 1/2] oe-pkgdata-util: Refactor functions for consistency
2018-01-18 23:18 ` [PATCH V2 1/2] oe-pkgdata-util: Refactor functions for consistency Amanda Brindle
@ 2018-01-22 20:12 ` Paul Eggleton
0 siblings, 0 replies; 4+ messages in thread
From: Paul Eggleton @ 2018-01-22 20:12 UTC (permalink / raw)
To: Amanda Brindle; +Cc: openembedded-core
Hi Amanda,
On Friday, 19 January 2018 12:18:27 PM NZDT Amanda Brindle wrote:
> Refactor functions lookup_recipe and package_info to be consistent with
> list_pkg_files. Print the appropriate information as soon as it's found,
> rather than storing it in a mappings variable and wait to print after
> searching all packages.
>
> Signed-off-by: Amanda Brindle <amanda.r.brindle@intel.com>
> ---
> scripts/oe-pkgdata-util | 107 ++++++++++++++++++++++--------------------------
> 1 file changed, 48 insertions(+), 59 deletions(-)
>
> diff --git a/scripts/oe-pkgdata-util b/scripts/oe-pkgdata-util
> index c6fba56..e4ccf30 100755
> --- a/scripts/oe-pkgdata-util
> +++ b/scripts/oe-pkgdata-util
> @@ -257,25 +257,22 @@ def lookup_recipe(args):
> for pkgitem in args.pkg:
> pkgs.extend(pkgitem.split())
>
> - mappings = defaultdict(list)
> for pkg in pkgs:
> - pkgfile = os.path.join(args.pkgdata_dir, 'runtime-reverse', pkg)
> - if os.path.exists(pkgfile):
> - with open(pkgfile, 'r') as f:
> + pkgdatafile = os.path.join(args.pkgdata_dir, 'runtime-reverse', pkg)
> + if os.path.exists(pkgdatafile):
> + with open(pkgdatafile, 'r') as f:
> + found = False
> for line in f:
> - fields = line.rstrip().split(': ')
> - if fields[0] == 'PN':
> - mappings[pkg].append(fields[1])
> + if line.startswith('PN'):
> + print("\t%s" % line.split(':', 1)[1].strip())
> + found = True
I don't think we want to do this. What if we started writing out some PN<something>
variable to the file? This will erroneously match it. We should split by : as the
previous code did and compare the actual field name, or at minimum add ':' to the
end of each check string. The same goes for the similar changes later on in the
patch.
Cheers,
Paul
--
Paul Eggleton
Intel Open Source Technology Centre
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2018-01-22 20:12 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-18 23:18 [PATCH V2 0/2] Amanda Brindle
2018-01-18 23:18 ` [PATCH V2 1/2] oe-pkgdata-util: Refactor functions for consistency Amanda Brindle
2018-01-22 20:12 ` Paul Eggleton
2018-01-18 23:18 ` [PATCH V2 2/2] oe-pkgdata-util: Add support for RPROVIDES Amanda Brindle
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox