diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-01-29 14:10:30 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2013-02-01 15:54:02 +0000 |
commit | 244f107c1f11bb74b5a489e4f24eac93706aa584 (patch) | |
tree | 1a7a619fe6ece0268ebc3b9f8dda0351b1b20429 /meta/classes/package.bbclass | |
parent | ed931d0314e4d1bb5230b266d2ec6d55dcb63df6 (diff) | |
download | poky-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/package.bbclass')
-rw-r--r-- | meta/classes/package.bbclass | 78 |
1 files changed, 41 insertions, 37 deletions
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 | ||
1846 | PACKAGE_PREPROCESS_FUNCS ?= "" | 1833 | PACKAGE_PREPROCESS_FUNCS ?= "" |
1847 | PACKAGEFUNCS ?= " \ | 1834 | # Functions for setting up PKGD |
1835 | PACKAGEBUILDPKGD ?= " \ | ||
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 | ||
1843 | PACKAGEFUNCS ?= " \ | ||
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 | } |