From 1c41823d4c7cab2bca18c9694a7bfe3094e07960 Mon Sep 17 00:00:00 2001 From: Ryan Roberts Date: Wed, 20 Mar 2024 10:33:53 +0000 Subject: [PATCH] build: Fix --no-sync with no arguments Previously --no-sync would allow 0 or 1 arguments. For the 0 args case, that meant "do not sync any of the components' repos". However, this usage causes incorrect parsing if the config is immediately following --no-sync on the command line; in this case, the config would be interpretted as the argument. Let's fix this by separating the 0 arg use into a separate option, --no-sync-all. Now --no-sync always requires an argument. Signed-off-by: Ryan Roberts --- documentation/userguide/configmodel.rst | 2 +- documentation/userguide/quickstart.rst | 2 +- shrinkwrap/commands/build.py | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/documentation/userguide/configmodel.rst b/documentation/userguide/configmodel.rst index 588a62c..12c057d 100644 --- a/documentation/userguide/configmodel.rst +++ b/documentation/userguide/configmodel.rst @@ -190,7 +190,7 @@ component section =========== =========== =========== key type description =========== =========== =========== -repo dictionary Specifies information about the git repo(s) that must be cloned and checked out. By default, Shrinkwrap syncs the git repo to the specified revision when building. ``--no-sync`` can be used to tell Shrinkwrap to build it in whatever state the user left it in. Not required if ``sourcedir`` is provided. +repo dictionary Specifies information about the git repo(s) that must be cloned and checked out. By default, Shrinkwrap syncs the git repo to the specified revision when building. ``--no-sync`` or ``--no-sync-all`` can be used to tell Shrinkwrap to build it in whatever state the user left it in. Not required if ``sourcedir`` is provided. sourcedir string If specified, points to the path on disk where the source repo can be found. Useful for developer use cases where a local repo already exists. builddir string If specified, the location where the component will be built. If not specified, shrinkwrap allocates its own location based on SHRINKWRAP_BUILD. toolchain string Defines the toolchain to be used for compilation. Value is set as CROSS_COMPILE environment variable before invoking any prebuild/build/postbuild commands. When using the standard image with a container runtime, the options are: ``aarch64-none-elf-``, ``arm-none-eabi-``, ``aarch64-linux-gnu-``, or ``arm-linux-gnueabihf-``. diff --git a/documentation/userguide/quickstart.rst b/documentation/userguide/quickstart.rst index 87f012f..3d0da12 100644 --- a/documentation/userguide/quickstart.rst +++ b/documentation/userguide/quickstart.rst @@ -317,7 +317,7 @@ artifacts. in the config on every build invocation. If you have made changes in the working directory, your CHANGES WILL BE LOST! You can override this behaviour so that Shrinkwrap just builds whatever is in the working directory by adding - ``--no-sync []`` to the command line. + ``--no-sync `` or ``--no-sync-all`` to the command line. Alternatively, pass ``--dry-run`` to view the shell script that would have been run: diff --git a/shrinkwrap/commands/build.py b/shrinkwrap/commands/build.py index 39180b4..564a8d2 100644 --- a/shrinkwrap/commands/build.py +++ b/shrinkwrap/commands/build.py @@ -48,12 +48,15 @@ def add_parser(parser, formatter): cmdp.add_argument('-s', '--no-sync', metavar='component', required=False, default=[], - action='append', const=True, nargs='?', + action='append', help="""Optionally specify any components whose git repos should not be synced. For all other components, Shrinkwrap ensures that all repos are clean and checked out at the correct - revision. Option can be specified multiple times. If - specified without an argument, behaves as if --no-sync was + revision. Option can be specified multiple times.""") + + cmdp.add_argument('--no-sync-all', + required=False, default=False, action='store_true', + help="""Do not sync repos for any component, as if --no-sync was specified for every component in the config.""") buildall.add_common_args(cmdp) @@ -68,6 +71,6 @@ def dispatch(args): command line. The arguments comply with those requested in add_parser(). """ btvars = vars.parse(args.btvar, type='bt') - if any([c == True for c in args.no_sync]): + if args.no_sync_all: args.no_sync = True buildall.build([args.config], [btvars], args.no_sync, args) -- GitLab