Skip to content

Commit

Permalink
Renamed the --force-bundle and --force-firmware commands to --refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
sylane committed Oct 3, 2024
1 parent 2154609 commit 0be4b09
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 24 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:

Expand Down
16 changes: 8 additions & 8 deletions src/rebar3_grisp_firmware.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
26 changes: 13 additions & 13 deletions src/rebar3_grisp_pack.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
]},
Expand Down Expand Up @@ -67,16 +67,16 @@ 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,
[{system, SysFile},
{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} ->
Expand Down Expand Up @@ -163,45 +163,45 @@ 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]),
console("* Using existing bootloader firmware: ~s", [BootRelPath]),
{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,
Expand All @@ -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];
Expand Down

0 comments on commit 0be4b09

Please sign in to comment.