From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: openembedded-core <openembedded-core@lists.openembedded.org>
Subject: package_rpm.bbclass: Replace shell provides/requires script with python version
Date: Thu, 26 Apr 2012 20:54:23 +0100 [thread overview]
Message-ID: <1335470063.20130.32.camel@ted> (raw)
The existing shell script is a fork bomb and forks off hundreds of
grep/cur/wc calls as it reads from its input stream and iterates over
the file data table for each line of input. This patch replaces the
shell code with python code which doesn't exec anything and hence runs
much faster without the exec() overhead. This speeds up rpm packaging
considerably, as can be measured simply by timing it, or watching the
processor utilisation.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/meta/classes/package_rpm.bbclass b/meta/classes/package_rpm.bbclass
index ffe3b31..d90976b 100644
--- a/meta/classes/package_rpm.bbclass
+++ b/meta/classes/package_rpm.bbclass
@@ -1004,8 +1004,9 @@ python do_package_rpm () {
# Construct per file dependencies file
def dump_filerdeps(varname, outfile, d):
- outfile.write("#!/bin/sh\n")
- outfile.write("\n# Dependency table\n")
+ outfile.write("#!/usr/bin/env python\n\n")
+ outfile.write("# Dependency table\n")
+ outfile.write('deps = {\n')
for pkg in packages.split():
dependsflist_key = 'FILE' + varname + 'FLIST' + "_" + pkg
dependsflist = (d.getVar(dependsflist_key, True) or "")
@@ -1018,7 +1019,7 @@ python do_package_rpm () {
file = file.replace("@tab@", "\t")
file = file.replace("@space@", " ")
file = file.replace("@at@", "@")
- outfile.write("#" + pkgd + file + "\t")
+ outfile.write('"' + pkgd + file + '" : "')
for dep in depends_dict:
ver = depends_dict[dep]
if dep and ver:
@@ -1027,12 +1028,15 @@ python do_package_rpm () {
outfile.write(dep + " " + ver + " ")
else:
outfile.write(dep + " ")
- outfile.write("\n")
- outfile.write("\n\nwhile read file_name ; do\n")
- outfile.write("\tlength=$(echo \"#${file_name}\t\" | wc -c )\n")
- outfile.write("\tline=$(grep \"^#${file_name}\t\" $0 | cut -c ${length}- )\n")
- outfile.write("\tprintf \"%s\\n\" ${line}\n")
- outfile.write("done\n")
+ outfile.write('",\n')
+ outfile.write('}\n\n')
+ outfile.write("import sys\n")
+ outfile.write("while 1:\n")
+ outfile.write("\tline = sys.stdin.readline().strip()\n")
+ outfile.write("\tif not line:\n")
+ outfile.write("\t\tsys.exit(0)\n")
+ outfile.write("\tif line in deps:\n")
+ outfile.write("\t\tprint(deps[line] + '\\n')\n")
# OE-core dependencies a.k.a. RPM requires
outdepends = workdir + "/" + srcname + ".requires"
next reply other threads:[~2012-04-26 20:04 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-04-26 19:54 Richard Purdie [this message]
2012-04-26 20:34 ` package_rpm.bbclass: Replace shell provides/requires script with python version Mark Hatle
2012-04-27 17:09 ` Richard Purdie
2012-04-27 17:37 ` Mark Hatle
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=1335470063.20130.32.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox