summaryrefslogtreecommitdiffstats
path: root/meta/classes
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-01-29 14:10:30 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-02-01 15:54:02 +0000
commit244f107c1f11bb74b5a489e4f24eac93706aa584 (patch)
tree1a7a619fe6ece0268ebc3b9f8dda0351b1b20429 /meta/classes
parented931d0314e4d1bb5230b266d2ec6d55dcb63df6 (diff)
downloadpoky-244f107c1f11bb74b5a489e4f24eac93706aa584.tar.gz
package: Create global package file list and use throughout PACKAGEFUNCS
Currently we do a signficant amount of tree traversal in many different places which in inefficient. We can assume that the files don't change and cache the file list which gives an efficiency improvement which this patch does using a global variable. (From OE-Core rev: 2d7608842d2dab07065e60aab729a5c8fd6b7907) (From OE-Core rev: 5c7c8347eb1bc25d194be6f4be142ba0924e2600) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r--meta/classes/buildhistory.bbclass11
-rw-r--r--meta/classes/debian.bbclass28
-rw-r--r--meta/classes/insane.bbclass4
-rw-r--r--meta/classes/package.bbclass78
4 files changed, 60 insertions, 61 deletions
diff --git a/meta/classes/buildhistory.bbclass b/meta/classes/buildhistory.bbclass
index 4b80f07b45..a6fbd68333 100644
--- a/meta/classes/buildhistory.bbclass
+++ b/meta/classes/buildhistory.bbclass
@@ -199,12 +199,11 @@ python buildhistory_emit_pkghistory() {
199 pkgdestpkg = os.path.join(pkgdest, pkg) 199 pkgdestpkg = os.path.join(pkgdest, pkg)
200 filelist = [] 200 filelist = []
201 pkginfo.size = 0 201 pkginfo.size = 0
202 for root, dirs, files in os.walk(pkgdestpkg): 202 for f in pkgfiles[pkg]:
203 relpth = os.path.relpath(root, pkgdestpkg) 203 relpth = os.path.relpath(f, pkgdestpkg)
204 for f in files: 204 fstat = os.lstat(f)
205 fstat = os.lstat(os.path.join(root, f)) 205 pkginfo.size += fstat.st_size
206 pkginfo.size += fstat.st_size 206 filelist.append(os.sep + relpth)
207 filelist.append(os.sep + os.path.join(relpth, f))
208 filelist.sort() 207 filelist.sort()
209 pkginfo.filelist = " ".join(filelist) 208 pkginfo.filelist = " ".join(filelist)
210 209
diff --git a/meta/classes/debian.bbclass b/meta/classes/debian.bbclass
index 45f01e43cd..d7ea151a5d 100644
--- a/meta/classes/debian.bbclass
+++ b/meta/classes/debian.bbclass
@@ -51,23 +51,21 @@ python debian_package_name_hook () {
51 sonames = [] 51 sonames = []
52 has_bins = 0 52 has_bins = 0
53 has_libs = 0 53 has_libs = 0
54 pkg_dir = os.path.join(pkgdest, orig_pkg) 54 for file in pkgfiles[orig_pkg]:
55 for root, dirs, files in os.walk(pkg_dir): 55 root = os.path.dirname(file)
56 if bin_re.match(root) and files: 56 if bin_re.match(root):
57 has_bins = 1 57 has_bins = 1
58 if lib_re.match(root) and files: 58 if lib_re.match(root):
59 has_libs = 1 59 has_libs = 1
60 for f in files: 60 if so_re.match(os.path.basename(file)):
61 if so_re.match(f): 61 cmd = (d.getVar('TARGET_PREFIX', True) or "") + "objdump -p " + file + " 2>/dev/null"
62 fp = os.path.join(root, f) 62 fd = os.popen(cmd)
63 cmd = (d.getVar('TARGET_PREFIX', True) or "") + "objdump -p " + fp + " 2>/dev/null" 63 lines = fd.readlines()
64 fd = os.popen(cmd) 64 fd.close()
65 lines = fd.readlines() 65 for l in lines:
66 fd.close() 66 m = re.match("\s+SONAME\s+([^\s]*)", l)
67 for l in lines: 67 if m and not m.group(1) in sonames:
68 m = re.match("\s+SONAME\s+([^\s]*)", l) 68 sonames.append(m.group(1))
69 if m and not m.group(1) in sonames:
70 sonames.append(m.group(1))
71 69
72 bb.debug(1, 'LIBNAMES: pkg %s libs %d bins %d sonames %s' % (orig_pkg, has_libs, has_bins, sonames)) 70 bb.debug(1, 'LIBNAMES: pkg %s libs %d bins %d sonames %s' % (orig_pkg, has_libs, has_bins, sonames))
73 soname = None 71 soname = None
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass
index 3693d42f4c..5dfa5aaec4 100644
--- a/meta/classes/insane.bbclass
+++ b/meta/classes/insane.bbclass
@@ -658,9 +658,7 @@ def package_qa_walk(path, warnfuncs, errorfuncs, skip, package, d):
658 658
659 warnings = [] 659 warnings = []
660 errors = [] 660 errors = []
661 for root, dirs, files in os.walk(path): 661 for path in pkgfiles[package]:
662 for file in files:
663 path = os.path.join(root,file)
664 elf = oe.qa.ELFFile(path) 662 elf = oe.qa.ELFFile(path)
665 try: 663 try:
666 elf.open() 664 elf.open()
diff --git a/meta/classes/package.bbclass b/meta/classes/package.bbclass
index 1ccac9cdb8..5f6cf802c2 100644
--- a/meta/classes/package.bbclass
+++ b/meta/classes/package.bbclass
@@ -1049,9 +1049,7 @@ python package_fixsymlinks () {
1049 dangling_links[pkg] = [] 1049 dangling_links[pkg] = []
1050 pkg_files[pkg] = [] 1050 pkg_files[pkg] = []
1051 inst_root = os.path.join(pkgdest, pkg) 1051 inst_root = os.path.join(pkgdest, pkg)
1052 for root, dirs, files in os.walk(inst_root): 1052 for path in pkgfiles[pkg]:
1053 for f in files:
1054 path = os.path.join(root, f)
1055 rpath = path[len(inst_root):] 1053 rpath = path[len(inst_root):]
1056 pkg_files[pkg].append(rpath) 1054 pkg_files[pkg].append(rpath)
1057 try: 1055 try:
@@ -1061,7 +1059,7 @@ python package_fixsymlinks () {
1061 raise 1059 raise
1062 target = os.readlink(path) 1060 target = os.readlink(path)
1063 if target[0] != '/': 1061 if target[0] != '/':
1064 target = os.path.join(root[len(inst_root):], target) 1062 target = os.path.join(os.path.dirname(path)[len(inst_root):], target)
1065 dangling_links[pkg].append(os.path.normpath(target)) 1063 dangling_links[pkg].append(os.path.normpath(target))
1066 1064
1067 newrdepends = {} 1065 newrdepends = {}
@@ -1307,12 +1305,8 @@ python package_do_filedeps() {
1307 1305
1308 provides_files = [] 1306 provides_files = []
1309 requires_files = [] 1307 requires_files = []
1310 rpfiles = []
1311 for root, dirs, files in os.walk(pkgdest + "/" + pkg):
1312 for file in files:
1313 rpfiles.append(os.path.join(root, file))
1314 1308
1315 for files in chunks(rpfiles, 100): 1309 for files in chunks(pkgfiles[pkg], 100):
1316 dep_pipe = os.popen(rpmdeps + " " + " ".join(files)) 1310 dep_pipe = os.popen(rpmdeps + " " + " ".join(files))
1317 1311
1318 process_deps(dep_pipe, pkg, provides_files, requires_files) 1312 process_deps(dep_pipe, pkg, provides_files, requires_files)
@@ -1362,9 +1356,9 @@ python package_do_shlibs() {
1362 # Take shared lock since we're only reading, not writing 1356 # Take shared lock since we're only reading, not writing
1363 lf = bb.utils.lockfile(d.expand("${PACKAGELOCK}")) 1357 lf = bb.utils.lockfile(d.expand("${PACKAGELOCK}"))
1364 1358
1365 def linux_so(root, path, file): 1359 def linux_so(file):
1366 needs_ldconfig = False 1360 needs_ldconfig = False
1367 cmd = d.getVar('OBJDUMP', True) + " -p " + pipes.quote(os.path.join(root, file)) + " 2>/dev/null" 1361 cmd = d.getVar('OBJDUMP', True) + " -p " + pipes.quote(file) + " 2>/dev/null"
1368 cmd = "PATH=\"%s\" %s" % (d.getVar('PATH', True), cmd) 1362 cmd = "PATH=\"%s\" %s" % (d.getVar('PATH', True), cmd)
1369 fd = os.popen(cmd) 1363 fd = os.popen(cmd)
1370 lines = fd.readlines() 1364 lines = fd.readlines()
@@ -1381,15 +1375,14 @@ python package_do_shlibs() {
1381 # if library is private (only used by package) then do not build shlib for it 1375 # if library is private (only used by package) then do not build shlib for it
1382 if not private_libs or -1 == private_libs.find(this_soname): 1376 if not private_libs or -1 == private_libs.find(this_soname):
1383 sonames.append(this_soname) 1377 sonames.append(this_soname)
1384 if libdir_re.match(root): 1378 if libdir_re.match(os.path.dirname(file)):
1385 needs_ldconfig = True 1379 needs_ldconfig = True
1386 if snap_symlinks and (file != this_soname): 1380 if snap_symlinks and (os.path.basename(file) != this_soname):
1387 renames.append((os.path.join(root, file), os.path.join(root, this_soname))) 1381 renames.append((file, os.path.join(os.path.dirname(file), this_soname)))
1388 return needs_ldconfig 1382 return needs_ldconfig
1389 1383
1390 def darwin_so(root, path, file): 1384 def darwin_so(file):
1391 fullpath = os.path.join(root, file) 1385 if not os.path.exists(file):
1392 if not os.path.exists(fullpath):
1393 return 1386 return
1394 1387
1395 def get_combinations(base): 1388 def get_combinations(base):
@@ -1414,7 +1407,7 @@ python package_do_shlibs() {
1414 if not combo in sonames: 1407 if not combo in sonames:
1415 sonames.append(combo) 1408 sonames.append(combo)
1416 if file.endswith('.dylib') or file.endswith('.so'): 1409 if file.endswith('.dylib') or file.endswith('.so'):
1417 lafile = fullpath.replace(os.path.join(pkgdest, pkg), d.getVar('PKGD', True)) 1410 lafile = file.replace(os.path.join(pkgdest, pkg), d.getVar('PKGD', True))
1418 # Drop suffix 1411 # Drop suffix
1419 lafile = lafile.rsplit(".",1)[0] 1412 lafile = lafile.rsplit(".",1)[0]
1420 lapath = os.path.dirname(lafile) 1413 lapath = os.path.dirname(lafile)
@@ -1427,7 +1420,7 @@ python package_do_shlibs() {
1427 lafile = lapath + '/' + combo + '.la' 1420 lafile = lapath + '/' + combo + '.la'
1428 1421
1429 #bb.note("Foo2: %s" % lafile) 1422 #bb.note("Foo2: %s" % lafile)
1430 #bb.note("Foo %s %s" % (file, fullpath)) 1423 #bb.note("Foo %s" % file)
1431 if os.path.exists(lafile): 1424 if os.path.exists(lafile):
1432 fd = open(lafile, 'r') 1425 fd = open(lafile, 'r')
1433 lines = fd.readlines() 1426 lines = fd.readlines()
@@ -1475,17 +1468,14 @@ python package_do_shlibs() {
1475 needed[pkg] = [] 1468 needed[pkg] = []
1476 sonames = list() 1469 sonames = list()
1477 renames = list() 1470 renames = list()
1478 top = os.path.join(pkgdest, pkg) 1471 for file in pkgfiles[pkg]:
1479 for root, dirs, files in os.walk(top):
1480 for file in files:
1481 soname = None 1472 soname = None
1482 path = os.path.join(root, file) 1473 if os.path.islink(file):
1483 if os.path.islink(path):
1484 continue 1474 continue
1485 if targetos == "darwin" or targetos == "darwin8": 1475 if targetos == "darwin" or targetos == "darwin8":
1486 darwin_so(root, dirs, file) 1476 darwin_so(file)
1487 elif os.access(path, os.X_OK) or lib_re.match(file): 1477 elif os.access(file, os.X_OK) or lib_re.match(file):
1488 ldconfig = linux_so(root, dirs, file) 1478 ldconfig = linux_so(file)
1489 needs_ldconfig = needs_ldconfig or ldconfig 1479 needs_ldconfig = needs_ldconfig or ldconfig
1490 for (old, new) in renames: 1480 for (old, new) in renames:
1491 bb.note("Renaming %s to %s" % (old, new)) 1481 bb.note("Renaming %s to %s" % (old, new))
@@ -1594,18 +1584,15 @@ python package_do_pkgconfig () {
1594 for pkg in packages.split(): 1584 for pkg in packages.split():
1595 pkgconfig_provided[pkg] = [] 1585 pkgconfig_provided[pkg] = []
1596 pkgconfig_needed[pkg] = [] 1586 pkgconfig_needed[pkg] = []
1597 top = os.path.join(pkgdest, pkg) 1587 for file in pkgfiles[pkg]:
1598 for root, dirs, files in os.walk(top):
1599 for file in files:
1600 m = pc_re.match(file) 1588 m = pc_re.match(file)
1601 if m: 1589 if m:
1602 pd = bb.data.init() 1590 pd = bb.data.init()
1603 name = m.group(1) 1591 name = m.group(1)
1604 pkgconfig_provided[pkg].append(name) 1592 pkgconfig_provided[pkg].append(name)
1605 path = os.path.join(root, file) 1593 if not os.access(file, os.R_OK):
1606 if not os.access(path, os.R_OK):
1607 continue 1594 continue
1608 f = open(path, 'r') 1595 f = open(file, 'r')
1609 lines = f.readlines() 1596 lines = f.readlines()
1610 f.close() 1597 f.close()
1611 for l in lines: 1598 for l in lines:
@@ -1844,16 +1831,19 @@ def gen_packagevar(d):
1844 return " ".join(ret) 1831 return " ".join(ret)
1845 1832
1846PACKAGE_PREPROCESS_FUNCS ?= "" 1833PACKAGE_PREPROCESS_FUNCS ?= ""
1847PACKAGEFUNCS ?= " \ 1834# Functions for setting up PKGD
1835PACKAGEBUILDPKGD ?= " \
1848 perform_packagecopy \ 1836 perform_packagecopy \
1849 ${PACKAGE_PREPROCESS_FUNCS} \ 1837 ${PACKAGE_PREPROCESS_FUNCS} \
1850 package_do_split_locales \
1851 split_and_strip_files \ 1838 split_and_strip_files \
1852 fixup_perms \ 1839 fixup_perms \
1853 populate_packages \ 1840 package_do_split_locales \
1841 populate_packages"
1842# Functions which process metadata based on split packages
1843PACKAGEFUNCS ?= " \
1844 package_fixsymlinks \
1854 package_name_hook \ 1845 package_name_hook \
1855 package_get_auto_pr \ 1846 package_get_auto_pr \
1856 package_fixsymlinks \
1857 package_do_filedeps \ 1847 package_do_filedeps \
1858 package_do_shlibs \ 1848 package_do_shlibs \
1859 package_do_pkgconfig \ 1849 package_do_pkgconfig \
@@ -1883,6 +1873,20 @@ python do_package () {
1883 bb.error("WORKDIR, DEPLOY_DIR, D, PN and PKGD all must be defined, unable to package") 1873 bb.error("WORKDIR, DEPLOY_DIR, D, PN and PKGD all must be defined, unable to package")
1884 return 1874 return
1885 1875
1876 for f in (d.getVar('PACKAGEBUILDPKGD', True) or '').split():
1877 bb.build.exec_func(f, d)
1878
1879 # Build global list of files in each split package
1880 global pkgfiles
1881 pkgfiles = {}
1882 packages = d.getVar('PACKAGES', True).split()
1883 pkgdest = d.getVar('PKGDEST', True)
1884 for pkg in packages:
1885 pkgfiles[pkg] = []
1886 for walkroot, dirs, files in os.walk(pkgdest + "/" + pkg):
1887 for file in files:
1888 pkgfiles[pkg].append(walkroot + os.sep + file)
1889
1886 for f in (d.getVar('PACKAGEFUNCS', True) or '').split(): 1890 for f in (d.getVar('PACKAGEFUNCS', True) or '').split():
1887 bb.build.exec_func(f, d) 1891 bb.build.exec_func(f, d)
1888} 1892}