diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-31 15:06:39 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-22 09:16:00 +0100 |
commit | d28f9b0c8636f27065c3261caa7a9c48a503460d (patch) | |
tree | 6a20336b41edd99ea45e9b4cf420f08a744e0284 /meta/classes | |
parent | 8cbdc270c9663bcdc314fec19de51e85a6461a94 (diff) | |
download | poky-d28f9b0c8636f27065c3261caa7a9c48a503460d.tar.gz |
package_deb: Enable multithreaded package creation
Allow the creation of debs to happen in parallel, making best use of resources
on multiprocessor systems.
(From OE-Core rev: dd540fba6c65fb74df014f5d9d2965078314a790)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/package_deb.bbclass | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/meta/classes/package_deb.bbclass b/meta/classes/package_deb.bbclass index 04b91970c7..23b449cbe0 100644 --- a/meta/classes/package_deb.bbclass +++ b/meta/classes/package_deb.bbclass | |||
@@ -51,6 +51,8 @@ def debian_arch_map(arch, tune): | |||
51 | # INSTALL_TASK_DEB - task name | 51 | # INSTALL_TASK_DEB - task name |
52 | 52 | ||
53 | python do_package_deb () { | 53 | python do_package_deb () { |
54 | from multiprocessing import Process | ||
55 | |||
54 | oldcwd = os.getcwd() | 56 | oldcwd = os.getcwd() |
55 | 57 | ||
56 | packages = d.getVar('PACKAGES') | 58 | packages = d.getVar('PACKAGES') |
@@ -62,11 +64,25 @@ python do_package_deb () { | |||
62 | if os.access(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"),os.R_OK): | 64 | if os.access(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN"),os.R_OK): |
63 | os.unlink(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN")) | 65 | os.unlink(os.path.join(tmpdir, "stamps", "DEB_PACKAGE_INDEX_CLEAN")) |
64 | 66 | ||
65 | for pkg in packages.split(): | 67 | max_process = int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1) |
66 | deb_write_pkg(pkg, d) | 68 | launched = [] |
69 | pkgs = packages.split() | ||
70 | while pkgs: | ||
71 | if len(launched) < max_process: | ||
72 | p = Process(target=deb_write_pkg, args=(pkgs.pop(), d)) | ||
73 | p.start() | ||
74 | launched.append(p) | ||
75 | for q in launched: | ||
76 | # The finished processes are joined when calling is_alive() | ||
77 | if not q.is_alive(): | ||
78 | launched.remove(q) | ||
79 | for p in launched: | ||
80 | p.join() | ||
67 | 81 | ||
68 | os.chdir(oldcwd) | 82 | os.chdir(oldcwd) |
69 | } | 83 | } |
84 | do_package_deb[vardeps] += "deb_write_pkg" | ||
85 | do_package_deb[vardepsexclude] = "BB_NUMBER_THREADS" | ||
70 | 86 | ||
71 | def deb_write_pkg(pkg, d): | 87 | def deb_write_pkg(pkg, d): |
72 | import re, copy | 88 | import re, copy |