From 0be4b09bc4504c41705c65b3dd8d3afd116718c4 Mon Sep 17 00:00:00 2001 From: Sebastien Merle Date: Thu, 3 Oct 2024 19:37:51 +0200 Subject: [PATCH] Renamed the --force-bundle and --force-firmware commands to --refresh --- CHANGELOG.md | 5 +++++ README.md | 6 +++--- src/rebar3_grisp_firmware.erl | 16 ++++++++-------- src/rebar3_grisp_pack.erl | 26 +++++++++++++------------- 4 files changed, 29 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1dcea8a..99fc0fd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed + +- Renamed the grisp firmware command argument --force-bundle/-F and the grisp + pack command argument --force-bundle/-F to --refresh/-r. [#91](https://github.com/grisp/rebar3_grisp/pull/91) + ### Removed - The utility function rebar3_grisp_util:rebar_command/4 has been removed as it diff --git a/README.md b/README.md index 1e04be2..c2180fb 100644 --- a/README.md +++ b/README.md @@ -228,7 +228,7 @@ Generate a system firmware for a specific release: Generate all firmwares, forcing existing files to be overwritten and forcing the generation of the software bundle even if one already exists in `_grisp/deploy`: - rebar3 grisp firmware --bootloader --image --force --force-bundle + rebar3 grisp firmware --bootloader --image --force --refresh ### Firmware Update @@ -386,9 +386,9 @@ Note that a toolchain is required for building the bootloader firmware, see the `deploy` command for more information on how to configure the toolchain. To force the recreation of the bundle and firmware(s) use the option -`-F/--force-firmware`: +`-r/--refresh`: - $ rebar3 grisp pack -F + $ rebar3 grisp pack -r To generate a signed package, use the `-k/--key` option: diff --git a/src/rebar3_grisp_firmware.erl b/src/rebar3_grisp_firmware.erl index 97875fa..b387b59 100644 --- a/src/rebar3_grisp_firmware.erl +++ b/src/rebar3_grisp_firmware.erl @@ -34,7 +34,7 @@ init(State) -> {relname, $n, "relname", string, "Specify the name for the release that will be deployed"}, {relvsn, $v, "relvsn", string, "Specify the version of the release"}, {bundle, undefined, "bundle", string, "The release bundle to use in the firmware"}, - {force_bundle, $F, "force-bundle", {boolean, false}, "Force bundle deploy even if it already exists"}, + {refresh, $r, "refresh", {boolean, false}, "Force bundle deploy even if it already exists"}, {force, $f, "force", {boolean, false}, "Replace existing files"}, {compress, $z, "compress", {boolean, true}, "Compress the output files"}, {system, $s, "system", {boolean, true}, "Generate a system firmware under _grisp/firmware"}, @@ -71,8 +71,8 @@ do(RState) -> = rebar3_grisp_util:select_release(RState, RelNameArg, RelVsnArg), case proplists:get_value(bundle, Args, undefined) of undefined -> - Force = proplists:get_value(force_bundle, Args, false), - case get_bundle(RState, Force, RelName, RelVsn, ExtraArgs) of + Refresh = proplists:get_value(refresh, Args, false), + case get_bundle(RState, Refresh, RelName, RelVsn, ExtraArgs) of {error, _Reason} = Error -> Error; {ok, BundleFile, RState2} -> grisp_tools_firmware(RState2, RelName, RelVsn, @@ -154,29 +154,29 @@ toolchain_root(RebarState) -> {error, docker_not_found} -> abort("Docker is not available") end. -get_bundle(RState, Force, RelName, RelVsn, ExtraRelArgs) -> +get_bundle(RState, Refresh, RelName, RelVsn, ExtraRelArgs) -> BundleFile = rebar3_grisp_util:bundle_file_path(RState, RelName, RelVsn), case filelib:is_file(BundleFile) of - true when Force =:= false -> + true when Refresh =:= false -> RelPath = grisp_tools_util:maybe_relative(BundleFile, ?MAX_DDOT), console("* Using existing bundle: ~s", [RelPath]), {ok, BundleFile, RState}; _ -> console("* Deploying bundle...", []), - case deploy_bundle(RState, Force, RelName, + case deploy_bundle(RState, Refresh, RelName, RelVsn, ExtraRelArgs) of {ok, RState2} -> {ok, BundleFile, RState2}; {error, _Reason} = Error -> Error end end. -deploy_bundle(RState, Force, RelName, RelVsn, ExtraRelArgs) -> +deploy_bundle(RState, Refresh, RelName, RelVsn, ExtraRelArgs) -> Args = [ "--tar", "--relname", atom_to_list(RelName), "--relvsn", RelVsn, "--destination", "" - ] ++ case Force =:= true of + ] ++ case Refresh =:= true of true -> ["--force"]; false -> [] end ++ case ExtraRelArgs of diff --git a/src/rebar3_grisp_pack.erl b/src/rebar3_grisp_pack.erl index ae9d945..c259001 100644 --- a/src/rebar3_grisp_pack.erl +++ b/src/rebar3_grisp_pack.erl @@ -38,7 +38,7 @@ init(State) -> {block_size, undefined, "block-size", integer, "The size of the blocks in bytes, before compression"}, {key, $k, "key", string, "Private key PEM file to use to sign the update package"}, {with_bootloader, $b, "with-bootloader", {boolean, false}, "Include a bootloader firmware in the software update package"}, - {force_firmware, $F, "force-firmware", {boolean, false}, "Force firmware building even if it already exists"}, + {refresh, $r, "refresh", {boolean, false}, "Force firmware building even if it already exists"}, {force, $f, "force", {boolean, false}, "Replace existing files"}, {quiet, $q, "quiet", {boolean, false}, "Do not show the instructions on how to update a GRiSP2 board"} ]}, @@ -67,8 +67,8 @@ do(RState) -> proplists:get_value(bootloader, Args, undefined), proplists:get_value(with_bootloader, Args)} of {undefined, undefined, true} -> - Force = proplists:get_value(force_firmware, Args, false), - case get_firmwares(RState, Force, RelName, RelVsn, ExtraArgs) of + Refresh = proplists:get_value(refresh, Args, false), + case get_firmwares(RState, Refresh, RelName, RelVsn, ExtraArgs) of {error, _Reason} = Error -> Error; {ok, SysFile, BootFile, RState2} -> grisp_tools_pack(RState2, RelName, RelVsn, @@ -76,7 +76,7 @@ do(RState) -> {bootloader, BootFile} | Args]) end; {undefined, undefined, false} -> - Force = proplists:get_value(force_firmware, Args, false), + Force = proplists:get_value(refresh, Args, false), case get_firmware(RState, Force, RelName, RelVsn, ExtraArgs) of {error, _Reason} = Error -> Error; {ok, SysFile, RState2} -> @@ -163,13 +163,13 @@ format_error(Reason) -> %--- Internal ------------------------------------------------------------------ -get_firmwares(RState, Force, RelName, RelVsn, ExtraRelArgs) -> +get_firmwares(RState, Refresh, RelName, RelVsn, ExtraRelArgs) -> SysFile = rebar3_grisp_util:firmware_file_path(RState, system, RelName, RelVsn), BootFile = rebar3_grisp_util:firmware_file_path(RState, boot, RelName, RelVsn), case {filelib:is_file(SysFile), filelib:is_file(BootFile)} of - {true, true} when Force =:= false -> + {true, true} when Refresh =:= false -> SysRelPath = grisp_tools_util:maybe_relative(SysFile, ?MAX_DDOT), BootRelPath = grisp_tools_util:maybe_relative(BootFile, ?MAX_DDOT), console("* Using existing system firmware: ~s", [SysRelPath]), @@ -177,31 +177,31 @@ get_firmwares(RState, Force, RelName, RelVsn, ExtraRelArgs) -> {ok, SysFile, BootFile, RState}; _ -> console("* Building firmwares...", []), - case build_firmwares(RState, true, Force, RelName, + case build_firmwares(RState, true, Refresh, RelName, RelVsn, ExtraRelArgs) of {ok, RState2} -> {ok, SysFile, BootFile, RState2}; {error, _Reason} = Error -> Error end end. -get_firmware(RState, Force, RelName, RelVsn, ExtraRelArgs) -> +get_firmware(RState, Refresh, RelName, RelVsn, ExtraRelArgs) -> SysFile = rebar3_grisp_util:firmware_file_path(RState, system, RelName, RelVsn), case filelib:is_file(SysFile) of - true when Force =:= false -> + true when Refresh =:= false -> SysRelPath = grisp_tools_util:maybe_relative(SysFile, ?MAX_DDOT), console("* Using existing system firmware: ~s", [SysRelPath]), {ok, SysFile, RState}; _ -> console("* Building system firmware...", []), - case build_firmwares(RState, false, Force, RelName, + case build_firmwares(RState, false, Refresh, RelName, RelVsn, ExtraRelArgs) of {ok, RState2} -> {ok, SysFile, RState2}; {error, _Reason} = Error -> Error end end. -build_firmwares(RState, WithBoot, Force, RelName, RelVsn, ExtraRelArgs) -> +build_firmwares(RState, WithBoot, Refresh, RelName, RelVsn, ExtraRelArgs) -> Args = [ "--relname", atom_to_list(RelName), "--relvsn", RelVsn, @@ -210,8 +210,8 @@ build_firmwares(RState, WithBoot, Force, RelName, RelVsn, ExtraRelArgs) -> ] ++ case WithBoot of true -> ["--bootloader"]; false -> [] - end ++ case Force =:= true of - true -> ["--force-bundle"]; + end ++ case Refresh =:= true of + true -> ["--refresh"]; false -> [] end ++ case ExtraRelArgs of [_|_] -> ["--" | ExtraRelArgs];