From d814052aac7a19841bc1cdf29b15af88240c2a9f Mon Sep 17 00:00:00 2001 From: Jan Lindemann Date: Thu, 19 Feb 2026 08:14:34 +0100 Subject: [PATCH] jw.pkg.cmds.projects.CmdBuild: --source-profile -> --env-reinit Replace --source-profile by --env-reinit and --env-keep to allow more fine-grained control over environment manipulation. Signed-off-by: Jan Lindemann --- src/python/jw/pkg/cmds/projects/CmdBuild.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/python/jw/pkg/cmds/projects/CmdBuild.py b/src/python/jw/pkg/cmds/projects/CmdBuild.py index 048b4655..7f0f0514 100644 --- a/src/python/jw/pkg/cmds/projects/CmdBuild.py +++ b/src/python/jw/pkg/cmds/projects/CmdBuild.py @@ -24,8 +24,10 @@ class CmdBuild(Cmd): # export default=False, help='Don\'t build anything, just print the build order.') parser.add_argument('-I', '--ignore-deps', action='store_true', default=False, help='Don\'t build dependencies, i.e. build only modules specified on the command line') - parser.add_argument('--source-profile', choices=['no', 'add', 'replace'], - default='no', help='Source /etc/profile before each build step') + parser.add_argument('--env-reinit', action='store_true', + default=False, help='Source /etc/profile before each build step. Discard environment unless --env-keep is specified') + parser.add_argument('--env-keep', default='none', help='Comma seperated list of environment variables to keep, ' + + '"all" or "none", only meaningful if --env-reinit is specified') parser.add_argument('target', default='all', help='Build target') parser.add_argument('modules', nargs='+', default='', help='Modules to be built') @@ -100,8 +102,17 @@ class CmdBuild(Cmd): # export title = '---- [%d/%d]: Running "%s" in %s -' % (cur_project, num_projects, ' '.join(make_cmd), wd) env = None - if args.source_profile != 'no': - env = await get_profile_env(add=True if args.source_profile == 'add' else False) + if args.env_reinit: + keep: bool|list[str] = False + if args.env_keep is not None: + match args.env_keep: + case 'all': + keep=True + case 'none': + keep=False + case _: + keep = args.env_keep.split(',') + env = await get_profile_env(keep=keep) try: stdout, stderr = await run_cmd(