From a1f4d97bf8322461baa04145d235c20344655600 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 25 Oct 2021 22:15:52 +0800 Subject: [PATCH] bitbake: bitbake-worker: Allow shutdown/database flush of pseudo server at task exit We have a problem where pseudo server processes exist after bitbake exits and hold the pseudo database in memory. In a docker container, the processes will be killed as the container is destroyed with no warning and no opportunity to write the data to disk. This leads to permissions/inode corruptions and data loss. Send a shutdown message to pseudo which in new versions of pseudo will flush the database, thereby fixing some of the issues people using docker containers see. (Bitbake rev: 7752c2c00245e91aeb17e22de484535190b18e5d) Signed-off-by: Richard Purdie (cherry picked from commit a07a971b40acd3eee12e203d2cfa3e49f56109f6) Signed-off-by: Anuj Mittal Signed-off-by: Richard Purdie --- bitbake/bin/bitbake-worker | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker index 3ca8c1853b..b3877b15c0 100755 --- a/bitbake/bin/bitbake-worker +++ b/bitbake/bin/bitbake-worker @@ -16,6 +16,8 @@ import signal import pickle import traceback import queue +import shlex +import subprocess from multiprocessing import Lock from threading import Thread @@ -145,6 +147,7 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha # a fork() or exec*() activates PSEUDO... envbackup = {} + fakeroot = False fakeenv = {} umask = None @@ -164,6 +167,7 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha # We can't use the fakeroot environment in a dry run as it possibly hasn't been built if 'fakeroot' in taskdep and taskname in taskdep['fakeroot'] and not dry_run: + fakeroot = True envvars = (workerdata["fakerootenv"][fn] or "").split() for key, value in (var.split('=') for var in envvars): envbackup[key] = os.environ.get(key) @@ -282,7 +286,11 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, taskha try: if dry_run: return 0 - return bb.build.exec_task(fn, taskname, the_data, cfg.profile) + ret = bb.build.exec_task(fn, taskname, the_data, cfg.profile) + if fakeroot: + fakerootcmd = shlex.split(the_data.getVar("FAKEROOTCMD")) + subprocess.run(fakerootcmd + ['-S'], check=True, stdout=subprocess.PIPE) + return ret except: os._exit(1) if not profiling: