diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-03-30 22:02:45 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-06-22 09:16:00 +0100 |
commit | 1b489073dcf1e0836f7f2db8cb171debeb7a02e7 (patch) | |
tree | a0f4d93315d65bca27ed89271796d4581199aef6 /meta/classes/package_ipk.bbclass | |
parent | d28f9b0c8636f27065c3261caa7a9c48a503460d (diff) | |
download | poky-1b489073dcf1e0836f7f2db8cb171debeb7a02e7.tar.gz |
package_ipk: Parallelise ipk creation
Allow the creation of ipks to happen in parallel, making best use of resources
on multiprocessor systems.
(From OE-Core rev: 07f6c0b464f0671bc39116317138e4ddf27bdae9)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes/package_ipk.bbclass')
-rw-r--r-- | meta/classes/package_ipk.bbclass | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/meta/classes/package_ipk.bbclass b/meta/classes/package_ipk.bbclass index 8e69b5da36..d58b824d3a 100644 --- a/meta/classes/package_ipk.bbclass +++ b/meta/classes/package_ipk.bbclass | |||
@@ -17,6 +17,8 @@ OPKG_ARGS += "${@['', '--add-exclude ' + ' --add-exclude '.join((d.getVar('PACKA | |||
17 | OPKGLIBDIR = "${localstatedir}/lib" | 17 | OPKGLIBDIR = "${localstatedir}/lib" |
18 | 18 | ||
19 | python do_package_ipk () { | 19 | python do_package_ipk () { |
20 | from multiprocessing import Process | ||
21 | |||
20 | oldcwd = os.getcwd() | 22 | oldcwd = os.getcwd() |
21 | 23 | ||
22 | workdir = d.getVar('WORKDIR') | 24 | workdir = d.getVar('WORKDIR') |
@@ -37,11 +39,25 @@ python do_package_ipk () { | |||
37 | if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK): | 39 | if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK): |
38 | os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN")) | 40 | os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN")) |
39 | 41 | ||
40 | for pkg in packages.split(): | 42 | max_process = int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1) |
41 | ipk_write_pkg(pkg, d) | 43 | launched = [] |
44 | pkgs = packages.split() | ||
45 | while pkgs: | ||
46 | if len(launched) < max_process: | ||
47 | p = Process(target=ipk_write_pkg, args=(pkgs.pop(), d)) | ||
48 | p.start() | ||
49 | launched.append(p) | ||
50 | for q in launched: | ||
51 | # The finished processes are joined when calling is_alive() | ||
52 | if not q.is_alive(): | ||
53 | launched.remove(q) | ||
54 | for p in launched: | ||
55 | p.join() | ||
42 | 56 | ||
43 | os.chdir(oldcwd) | 57 | os.chdir(oldcwd) |
44 | } | 58 | } |
59 | do_package_ipk[vardeps] += "ipk_write_pkg" | ||
60 | do_package_ipk[vardepsexclude] = "BB_NUMBER_THREADS" | ||
45 | 61 | ||
46 | def ipk_write_pkg(pkg, d): | 62 | def ipk_write_pkg(pkg, d): |
47 | import re, copy | 63 | import re, copy |