From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: openembedded-core <openembedded-core@lists.openembedded.org>
Subject: [PATCH] package.bbclass: Optimise the per file rpm handling
Date: Fri, 10 Feb 2012 00:10:38 +0000 [thread overview]
Message-ID: <1328832638.10451.52.camel@ted> (raw)
Currently a process was being forked off for each individual file
this class wanted to inspect with rpmdeps. This converts it to use
rpmdeps-oecore which allows batch processing of these dependencies.
For do_package for perl, this reduced the time by about 1 minute (33%).
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 348c13c..dfabcf8 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1125,7 +1125,7 @@ if [ x"$D" = "x" ]; then
fi
}
-RPMDEPS = "${STAGING_LIBDIR_NATIVE}/rpm/bin/rpmdeps --macros ${STAGING_LIBDIR_NATIVE}/rpm/macros --define '_rpmfc_magic_path ${STAGING_DIR_NATIVE}${datadir_native}/misc/magic.mgc' --rpmpopt ${STAGING_LIBDIR_NATIVE}/rpm/rpmpopt"
+RPMDEPS = "${STAGING_LIBDIR_NATIVE}/rpm/bin/rpmdeps-oecore --macros ${STAGING_LIBDIR_NATIVE}/rpm/macros --define '_rpmfc_magic_path ${STAGING_DIR_NATIVE}${datadir_native}/misc/magic.mgc' --rpmpopt ${STAGING_LIBDIR_NATIVE}/rpm/rpmpopt"
# Collect perfile run-time dependency metadata
# Output:
@@ -1136,7 +1136,7 @@ RPMDEPS = "${STAGING_LIBDIR_NATIVE}/rpm/bin/rpmdeps --macros ${STAGING_LIBDIR_NA
# FILERDEPENDS_filepath_pkg - per file dep
python package_do_filedeps() {
- import os, re
+ import re, subprocess
pkgdest = d.getVar('PKGDEST', True)
packages = d.getVar('PACKAGES', True)
@@ -1145,39 +1145,49 @@ python package_do_filedeps() {
r = re.compile(r'[<>=]+ +[^ ]*')
# Quick routine to process the results of the rpmdeps call...
- def process_deps(pipe, pkg, f, provides_files, requires_files):
- provides = []
- requires = []
- file = f.replace(pkgdest + "/" + pkg, "")
- file = file.replace("@", "@at@")
- file = file.replace(" ", "@space@")
- file = file.replace("\t", "@tab@")
- file = file.replace("[", "@openbrace@")
- file = file.replace("]", "@closebrace@")
- file = file.replace("_", "@underscore@")
+ def process_deps(pipe, pkg, provides_files, requires_files):
+ provides = {}
+ requires = {}
for line in pipe:
+ f = line.split(" ", 1)[0].strip()
+ line = line.split(" ", 1)[1].strip()
+
if line.startswith("Requires:"):
i = requires
elif line.startswith("Provides:"):
i = provides
else:
continue
+
+ file = f.replace(pkgdest + "/" + pkg, "")
+ file = file.replace("@", "@at@")
+ file = file.replace(" ", "@space@")
+ file = file.replace("\t", "@tab@")
+ file = file.replace("[", "@openbrace@")
+ file = file.replace("]", "@closebrace@")
+ file = file.replace("_", "@underscore@")
value = line.split(":", 1)[1].strip()
value = r.sub(r'(\g<0>)', value)
+
if value.startswith("rpmlib("):
continue
- i.append(value)
+ if file not in i:
+ i[file] = []
+ i[file].append(value)
- if len(provides) > 0:
+ for file in provides:
provides_files.append(file)
key = "FILERPROVIDES_" + file + "_" + pkg
- d.setVar(key, " ".join(provides))
+ d.setVar(key, " ".join(provides[file]))
- if len(requires) > 0:
+ for file in requires:
requires_files.append(file)
key = "FILERDEPENDS_" + file + "_" + pkg
- d.setVar(key, " ".join(requires))
+ d.setVar(key, " ".join(requires[file]))
+
+ def chunks(files, n):
+ return [files[i:i+n] for i in range(0, len(files), n)]
# Determine dependencies
for pkg in packages.split():
@@ -1186,13 +1196,15 @@ python package_do_filedeps() {
provides_files = []
requires_files = []
+ rpfiles = []
for root, dirs, files in os.walk(pkgdest + "/" + pkg):
for file in files:
- f = os.path.join(root, file)
+ rpfiles.append(os.path.join(root, file))
- dep_pipe = os.popen(rpmdeps + " --provides --requires -v " + f)
+ for files in chunks(rpfiles, 100):
+ dep_pipe = os.popen(rpmdeps + " " + " ".join(files))
- process_deps(dep_pipe, pkg, f, provides_files, requires_files)
+ process_deps(dep_pipe, pkg, provides_files, requires_files)
d.setVar("FILERDEPENDSFLIST_" + pkg, " ".join(requires_files))
d.setVar("FILERPROVIDESFLIST_" + pkg, " ".join(provides_files))
diff --git a/meta/recipes-core/busybox/busybox.inc b/meta/recipes-core/busybox/busybox.inc
index f35779d..5fb436e 100644
--- a/meta/recipes-core/busybox/busybox.inc
+++ b/meta/recipes-core/busybox/busybox.inc
@@ -216,9 +216,9 @@ python package_do_filedeps_append () {
# Load/backup original set
filerprovides = d.getVar('FILERPROVIDES_%s_%s' % (f_busybox, pkg), True) or ""
- dep_pipe = os.popen('sed -e "s,^,Provides: ," %s/%s%s' % (pkgdest, pkg, f_busybox_links))
+ dep_pipe = os.popen('sed -e "s,^,%s/%s%s Provides: ," %s/%s%s' % (pkgdest, pkg, f_busybox, pkgdest, pkg, f_busybox_links))
- process_deps(dep_pipe, pkg, "%s/%s%s" % (pkgdest, pkg, f_busybox), provides_files, requires_files)
+ process_deps(dep_pipe, pkg, provides_files, requires_files)
# Add the new set
filerprovides += d.getVar('FILERPROVIDES_%s_%s' % (f_busybox, pkg), True) or ""
next reply other threads:[~2012-02-10 0:18 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-10 0:10 Richard Purdie [this message]
2012-02-10 2:23 ` [PATCH] package.bbclass: Optimise the per file rpm handling Joshua Lock
2012-02-10 13:39 ` Richard Purdie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1328832638.10451.52.camel@ted \
--to=richard.purdie@linuxfoundation.org \
--cc=openembedded-core@lists.openembedded.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.