Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support newer bootleby format #499

Merged
merged 1 commit into from
Jul 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ name = "humility"
#
# Be sure to check in and push all of the files that change. Happy versioning!
#
version = "0.11.9"
version = "0.11.10"
authors = ["Bryan Cantrill <[email protected]>"]
edition = "2018"
license = "MPL-2.0"
Expand Down
9 changes: 8 additions & 1 deletion cmd/rebootleby/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,13 +42,20 @@ fn rebootleby(context: &mut ExecutionContext) -> Result<()> {
let mut zip =
ZipArchive::new(bundle_reader).context("opening bundle file as ZIP")?;

let img_bootleby = {
let img_bootleby = if zip.file_names().any(|x| x == "bootleby.bin") {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could probably do something like this (untested)

let img_bootleby = {
    let mut entry = zip
        .by_name("bootleby.bin")
        .or_else("img/final.bin")
        .context("can't find bootleby.bin or img/final.bin in bundle")?;
     let mut data = vec![];
    entry.read_to_end(&mut data).context("reading bootleby binary")?;
    data
};

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah I wanted to do something like that but or_else requires a closure FnOnce(E) -> Result<T, F>. I gave up trying to figure out the correct combinator incantation.

let mut entry = zip
.by_name("bootleby.bin")
.context("can't find bootleby.bin in bundle")?;
let mut data = vec![];
entry.read_to_end(&mut data).context("reading bootleby.bin")?;
data
} else {
let mut entry = zip
.by_name("img/final.bin")
.context("can't find bootleby.bin or img/final.bin in bundle")?;
let mut data = vec![];
entry.read_to_end(&mut data).context("reading bootleby.bin")?;
data
};
let img_cmpa = {
let mut entry =
Expand Down
4 changes: 2 additions & 2 deletions tests/cli_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ fn make_tests(tests: &[Test], kind: Kind) -> Result<()> {

if let Some(f) = path.file_name() {
if let Some(s) = f.to_str() {
if let Some(name) = s.strip_prefix(&kind.prefix()) {
if let Some(name) = s.strip_prefix(kind.prefix()) {
input.push((name.to_string(), s.to_string()));
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ fn make_tests(tests: &[Test], kind: Kind) -> Result<()> {
let testcmd = if let Some(arg) = test.arg {
format!("{} {arg}", test.cmd)
} else {
format!("{}", test.cmd)
test.cmd.to_string()
};

writeln!(
Expand Down
4 changes: 2 additions & 2 deletions tests/cmd/chip.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ For more information try --help

```
$ humility --chip this-can-be-anything -V
humility 0.11.9
humility 0.11.10

```

Expand All @@ -28,7 +28,7 @@ For more information try --help

```
$ humility -c apx432 -V
humility 0.11.9
humility 0.11.10

```

4 changes: 2 additions & 2 deletions tests/cmd/version.trycmd
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ Long version flag:

```
$ humility --version
humility 0.11.9
humility 0.11.10

```

Short version flag:

```
$ humility -V
humility 0.11.9
humility 0.11.10

```
Loading