From 8082a75b7be712c3b2fcec5fad014c279aef5520 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kl=C3=B6tzke?= Date: Sun, 13 Oct 2024 15:20:10 +0200 Subject: [PATCH] cmds: add new sandbox modes to remaining commands This does not actually add any new behaviour. But it makes the remaining commands consistent with the build/dev/jenkins commands by accepting the same options. --- pym/bob/cmds/build/project.py | 27 +++++++++++++++++++++------ pym/bob/cmds/build/query.py | 12 ++++++++++-- pym/bob/cmds/graph.py | 6 ++++++ pym/bob/cmds/misc.py | 24 ++++++++++++++++++++++++ pym/bob/cmds/show.py | 6 ++++++ 5 files changed, 67 insertions(+), 8 deletions(-) diff --git a/pym/bob/cmds/build/project.py b/pym/bob/cmds/build/project.py index 284b71a0e..f774ec3fb 100644 --- a/pym/bob/cmds/build/project.py +++ b/pym/bob/cmds/build/project.py @@ -8,7 +8,7 @@ from ...generators import generators as defaultGenerators from ...input import RecipeSet from ...tty import colorize -from ...utils import processDefines +from ...utils import processDefines, SandboxMode import argparse import os @@ -48,9 +48,15 @@ def _downloadArg(arg): parser.add_argument('-j', '--jobs', default=None, type=int, nargs='?', const=..., help="Specifies the number of jobs to run simultaneously.") group = parser.add_mutually_exclusive_group() - group.add_argument('--sandbox', action='store_true', default=False, - help="Enable sandboxing") - group.add_argument('--no-sandbox', action='store_false', dest='sandbox', + group.add_argument('--sandbox', action='store_const', const="yes", default=None, + help="Enable partial sandboxing") + group.add_argument('--slim-sandbox', action='store_const', const="slim", dest='sandbox', + help="Enable slim sandboxing") + group.add_argument('--dev-sandbox', action='store_const', const="dev", dest='sandbox', + help="Enable development sandboxing") + group.add_argument('--strict-sandbox', action='store_const', const="strict", dest='sandbox', + help="Enable strict sandboxing") + group.add_argument('--no-sandbox', action='store_const', const="no", dest='sandbox', help="Disable sandboxing") args = parser.parse_args(argv) @@ -68,7 +74,9 @@ def _downloadArg(arg): nameFormatter = recipes.getHook('developNameFormatter') developPersister = DevelopDirOracle(nameFormatter, recipes.getHook('developNamePersister')) nameFormatter = LocalBuilder.makeRunnable(developPersister.getFormatter()) - packages = recipes.generatePackages(nameFormatter, args.sandbox) + sandboxMode = SandboxMode(args.sandbox) + packages = recipes.generatePackages(nameFormatter, sandboxMode.sandboxEnabled, + sandboxMode.stablePaths) developPersister.prime(packages) generators = defaultGenerators.copy() @@ -98,7 +106,14 @@ def _downloadArg(arg): extra.append('-e') extra.append(e) if args.preserve_env: extra.append('-E') - if args.sandbox: extra.append('--sandbox') + if args.sandbox == "yes": + extra.append('--sandbox') + elif args.sandbox == "slim": + extra.append('--slim-sandbox') + elif args.sandbox == "dev": + extra.append('--dev-sandbox') + elif args.sandbox == "strict": + extra.append('--strict-sandbox') if args.jobs is ...: # expand because we cannot control the argument order in the generator args.jobs = os.cpu_count() diff --git a/pym/bob/cmds/build/query.py b/pym/bob/cmds/build/query.py index ab85069b4..b6d9108d0 100644 --- a/pym/bob/cmds/build/query.py +++ b/pym/bob/cmds/build/query.py @@ -45,8 +45,16 @@ def doQueryPath(argv, bobRoot): help="Return a non-zero error code in case of errors") group = parser.add_mutually_exclusive_group() - group.add_argument('--sandbox', action='store_true', help="Enable sandboxing") - group.add_argument('--no-sandbox', action='store_false', dest='sandbox', help="Disable sandboxing") + group.add_argument('--sandbox', action='store_true', default=False, + help="Enable sandboxing") + group.add_argument('--slim-sandbox', action='store_false', dest='sandbox', + help="Enable slim sandboxing") + group.add_argument('--dev-sandbox', action='store_true', dest='sandbox', + help="Enable development sandboxing") + group.add_argument('--strict-sandbox', action='store_true', dest='sandbox', + help="Enable strict sandboxing") + group.add_argument('--no-sandbox', action='store_false', dest='sandbox', + help="Disable sandboxing") parser.set_defaults(sandbox=None) group = parser.add_mutually_exclusive_group() diff --git a/pym/bob/cmds/graph.py b/pym/bob/cmds/graph.py index 19edc05a1..b75cfc5ec 100644 --- a/pym/bob/cmds/graph.py +++ b/pym/bob/cmds/graph.py @@ -513,6 +513,12 @@ def doGraph(argv, bobRoot): group = parser.add_mutually_exclusive_group() group.add_argument('--sandbox', action='store_true', default=False, help="Enable sandboxing") + group.add_argument('--slim-sandbox', action='store_false', dest='sandbox', + help="Enable slim sandboxing") + group.add_argument('--dev-sandbox', action='store_true', dest='sandbox', + help="Enable development sandboxing") + group.add_argument('--strict-sandbox', action='store_true', dest='sandbox', + help="Enable strict sandboxing") group.add_argument('--no-sandbox', action='store_false', dest='sandbox', help="Disable sandboxing") parser.add_argument('--destination', metavar="DEST", diff --git a/pym/bob/cmds/misc.py b/pym/bob/cmds/misc.py index 5428a9584..fe0bfa219 100644 --- a/pym/bob/cmds/misc.py +++ b/pym/bob/cmds/misc.py @@ -90,6 +90,12 @@ def doLS(argv, bobRoot): group = parser.add_mutually_exclusive_group() group.add_argument('--sandbox', action='store_true', default=False, help="Enable sandboxing") + group.add_argument('--slim-sandbox', action='store_false', dest='sandbox', + help="Enable slim sandboxing") + group.add_argument('--dev-sandbox', action='store_true', dest='sandbox', + help="Enable development sandboxing") + group.add_argument('--strict-sandbox', action='store_true', dest='sandbox', + help="Enable strict sandboxing") group.add_argument('--no-sandbox', action='store_false', dest='sandbox', help="Disable sandboxing") args = parser.parse_args(argv) @@ -138,6 +144,12 @@ def doQueryMeta(argv, bobRoot): group = parser.add_mutually_exclusive_group() group.add_argument('--sandbox', action='store_true', default=False, help="Enable sandboxing") + group.add_argument('--slim-sandbox', action='store_false', dest='sandbox', + help="Enable slim sandboxing") + group.add_argument('--dev-sandbox', action='store_true', dest='sandbox', + help="Enable development sandboxing") + group.add_argument('--strict-sandbox', action='store_true', dest='sandbox', + help="Enable strict sandboxing") group.add_argument('--no-sandbox', action='store_false', dest='sandbox', help="Disable sandboxing") args = parser.parse_args(argv) @@ -196,6 +208,12 @@ def doQuerySCM(argv, bobRoot): group = parser.add_mutually_exclusive_group() group.add_argument('--sandbox', action='store_true', default=False, help="Enable sandboxing") + group.add_argument('--slim-sandbox', action='store_false', dest='sandbox', + help="Enable slim sandboxing") + group.add_argument('--dev-sandbox', action='store_true', dest='sandbox', + help="Enable development sandboxing") + group.add_argument('--strict-sandbox', action='store_true', dest='sandbox', + help="Enable strict sandboxing") group.add_argument('--no-sandbox', action='store_false', dest='sandbox', help="Disable sandboxing") @@ -258,6 +276,12 @@ def doQueryRecipe(argv, bobRoot): group = parser.add_mutually_exclusive_group() group.add_argument('--sandbox', action='store_true', default=False, help="Enable sandboxing") + group.add_argument('--slim-sandbox', action='store_false', dest='sandbox', + help="Enable slim sandboxing") + group.add_argument('--dev-sandbox', action='store_true', dest='sandbox', + help="Enable development sandboxing") + group.add_argument('--strict-sandbox', action='store_true', dest='sandbox', + help="Enable strict sandboxing") group.add_argument('--no-sandbox', action='store_false', dest='sandbox', help="Disable sandboxing") diff --git a/pym/bob/cmds/show.py b/pym/bob/cmds/show.py index e68429c72..8cd9d0e05 100644 --- a/pym/bob/cmds/show.py +++ b/pym/bob/cmds/show.py @@ -252,6 +252,12 @@ def doShow(argv, bobRoot): group = parser.add_mutually_exclusive_group() group.add_argument('--sandbox', action='store_true', default=False, help="Enable sandboxing") + group.add_argument('--slim-sandbox', action='store_false', dest='sandbox', + help="Enable slim sandboxing") + group.add_argument('--dev-sandbox', action='store_true', dest='sandbox', + help="Enable development sandboxing") + group.add_argument('--strict-sandbox', action='store_true', dest='sandbox', + help="Enable strict sandboxing") group.add_argument('--no-sandbox', action='store_false', dest='sandbox', help="Disable sandboxing")