summaryrefslogtreecommitdiffstats
path: root/meta/classes/package.bbclass
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2012-02-10 00:10:38 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-02-10 14:38:45 +0000
commit12306d01a091899178aca26b629bf14f6161dfb4 (patch)
tree945b49f09dd3b39acefd52b3ae525d2d9efe07b5 /meta/classes/package.bbclass
parentd60912993d8542883d2930101b5b9a21ecb6adc0 (diff)
downloadpoky-12306d01a091899178aca26b629bf14f6161dfb4.tar.gz
package.bbclass: Optimise the per file rpm handling
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%). (From OE-Core rev: 548037acd63bd4859f8de8d23a3d12f36ce9f97f) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package.bbclass')
-rw-r--r--meta/classes/package.bbclass52
1 files changed, 32 insertions, 20 deletions
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 348c13ce5e..f6d6e1acee 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1125,7 +1125,7 @@ if [ x"$D" = "x" ]; then
1125fi 1125fi
1126} 1126}
1127 1127
1128RPMDEPS = "${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" 1128RPMDEPS = "${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"
1129 1129
1130# Collect perfile run-time dependency metadata 1130# Collect perfile run-time dependency metadata
1131# Output: 1131# Output:
@@ -1136,7 +1136,7 @@ RPMDEPS = "${STAGING_LIBDIR_NATIVE}/rpm/bin/rpmdeps --macros ${STAGING_LIBDIR_NA
1136# FILERDEPENDS_filepath_pkg - per file dep 1136# FILERDEPENDS_filepath_pkg - per file dep
1137 1137
1138python package_do_filedeps() { 1138python package_do_filedeps() {
1139 import os, re 1139 import re
1140 1140
1141 pkgdest = d.getVar('PKGDEST', True) 1141 pkgdest = d.getVar('PKGDEST', True)
1142 packages = d.getVar('PACKAGES', True) 1142 packages = d.getVar('PACKAGES', True)
@@ -1145,39 +1145,49 @@ python package_do_filedeps() {
1145 r = re.compile(r'[<>=]+ +[^ ]*') 1145 r = re.compile(r'[<>=]+ +[^ ]*')
1146 1146
1147 # Quick routine to process the results of the rpmdeps call... 1147 # Quick routine to process the results of the rpmdeps call...
1148 def process_deps(pipe, pkg, f, provides_files, requires_files): 1148 def process_deps(pipe, pkg, provides_files, requires_files):
1149 provides = [] 1149 provides = {}
1150 requires = [] 1150 requires = {}
1151 file = f.replace(pkgdest + "/" + pkg, "")
1152 file = file.replace("@", "@at@")
1153 file = file.replace(" ", "@space@")
1154 file = file.replace("\t", "@tab@")
1155 file = file.replace("[", "@openbrace@")
1156 file = file.replace("]", "@closebrace@")
1157 file = file.replace("_", "@underscore@")
1158 1151
1159 for line in pipe: 1152 for line in pipe:
1153 f = line.split(" ", 1)[0].strip()
1154 line = line.split(" ", 1)[1].strip()
1155
1160 if line.startswith("Requires:"): 1156 if line.startswith("Requires:"):
1161 i = requires 1157 i = requires
1162 elif line.startswith("Provides:"): 1158 elif line.startswith("Provides:"):
1163 i = provides 1159 i = provides
1164 else: 1160 else:
1165 continue 1161 continue
1162
1163 file = f.replace(pkgdest + "/" + pkg, "")
1164 file = file.replace("@", "@at@")
1165 file = file.replace(" ", "@space@")
1166 file = file.replace("\t", "@tab@")
1167 file = file.replace("[", "@openbrace@")
1168 file = file.replace("]", "@closebrace@")
1169 file = file.replace("_", "@underscore@")
1166 value = line.split(":", 1)[1].strip() 1170 value = line.split(":", 1)[1].strip()
1167 value = r.sub(r'(\g<0>)', value) 1171 value = r.sub(r'(\g<0>)', value)
1172
1168 if value.startswith("rpmlib("): 1173 if value.startswith("rpmlib("):
1169 continue 1174 continue
1170 i.append(value) 1175 if file not in i:
1176 i[file] = []
1177 i[file].append(value)
1171 1178
1172 if len(provides) > 0: 1179 for file in provides:
1173 provides_files.append(file) 1180 provides_files.append(file)
1174 key = "FILERPROVIDES_" + file + "_" + pkg 1181 key = "FILERPROVIDES_" + file + "_" + pkg
1175 d.setVar(key, " ".join(provides)) 1182 d.setVar(key, " ".join(provides[file]))
1176 1183
1177 if len(requires) > 0: 1184 for file in requires:
1178 requires_files.append(file) 1185 requires_files.append(file)
1179 key = "FILERDEPENDS_" + file + "_" + pkg 1186 key = "FILERDEPENDS_" + file + "_" + pkg
1180 d.setVar(key, " ".join(requires)) 1187 d.setVar(key, " ".join(requires[file]))
1188
1189 def chunks(files, n):
1190 return [files[i:i+n] for i in range(0, len(files), n)]
1181 1191
1182 # Determine dependencies 1192 # Determine dependencies
1183 for pkg in packages.split(): 1193 for pkg in packages.split():
@@ -1186,13 +1196,15 @@ python package_do_filedeps() {
1186 1196
1187 provides_files = [] 1197 provides_files = []
1188 requires_files = [] 1198 requires_files = []
1199 rpfiles = []
1189 for root, dirs, files in os.walk(pkgdest + "/" + pkg): 1200 for root, dirs, files in os.walk(pkgdest + "/" + pkg):
1190 for file in files: 1201 for file in files:
1191 f = os.path.join(root, file) 1202 rpfiles.append(os.path.join(root, file))
1192 1203
1193 dep_pipe = os.popen(rpmdeps + " --provides --requires -v " + f) 1204 for files in chunks(rpfiles, 100):
1205 dep_pipe = os.popen(rpmdeps + " " + " ".join(files))
1194 1206
1195 process_deps(dep_pipe, pkg, f, provides_files, requires_files) 1207 process_deps(dep_pipe, pkg, provides_files, requires_files)
1196 1208
1197 d.setVar("FILERDEPENDSFLIST_" + pkg, " ".join(requires_files)) 1209 d.setVar("FILERDEPENDSFLIST_" + pkg, " ".join(requires_files))
1198 d.setVar("FILERPROVIDESFLIST_" + pkg, " ".join(provides_files)) 1210 d.setVar("FILERPROVIDESFLIST_" + pkg, " ".join(provides_files))