mirror of
https://git.yoctoproject.org/poky
synced 2026-06-01 00:59:48 +00:00
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>
This commit is contained in:
@@ -17,6 +17,8 @@ OPKG_ARGS += "${@['', '--add-exclude ' + ' --add-exclude '.join((d.getVar('PACKA
|
|||||||
OPKGLIBDIR = "${localstatedir}/lib"
|
OPKGLIBDIR = "${localstatedir}/lib"
|
||||||
|
|
||||||
python do_package_ipk () {
|
python do_package_ipk () {
|
||||||
|
from multiprocessing import Process
|
||||||
|
|
||||||
oldcwd = os.getcwd()
|
oldcwd = os.getcwd()
|
||||||
|
|
||||||
workdir = d.getVar('WORKDIR')
|
workdir = d.getVar('WORKDIR')
|
||||||
@@ -37,11 +39,25 @@ python do_package_ipk () {
|
|||||||
if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK):
|
if os.access(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"), os.R_OK):
|
||||||
os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"))
|
os.unlink(os.path.join(tmpdir, "stamps", "IPK_PACKAGE_INDEX_CLEAN"))
|
||||||
|
|
||||||
for pkg in packages.split():
|
max_process = int(d.getVar("BB_NUMBER_THREADS") or os.cpu_count() or 1)
|
||||||
ipk_write_pkg(pkg, d)
|
launched = []
|
||||||
|
pkgs = packages.split()
|
||||||
|
while pkgs:
|
||||||
|
if len(launched) < max_process:
|
||||||
|
p = Process(target=ipk_write_pkg, args=(pkgs.pop(), d))
|
||||||
|
p.start()
|
||||||
|
launched.append(p)
|
||||||
|
for q in launched:
|
||||||
|
# The finished processes are joined when calling is_alive()
|
||||||
|
if not q.is_alive():
|
||||||
|
launched.remove(q)
|
||||||
|
for p in launched:
|
||||||
|
p.join()
|
||||||
|
|
||||||
os.chdir(oldcwd)
|
os.chdir(oldcwd)
|
||||||
}
|
}
|
||||||
|
do_package_ipk[vardeps] += "ipk_write_pkg"
|
||||||
|
do_package_ipk[vardepsexclude] = "BB_NUMBER_THREADS"
|
||||||
|
|
||||||
def ipk_write_pkg(pkg, d):
|
def ipk_write_pkg(pkg, d):
|
||||||
import re, copy
|
import re, copy
|
||||||
|
|||||||
Reference in New Issue
Block a user