tool: smarter systemd-boot install #76
No reviewers
Labels
No labels
bug
dependency
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
review-next
security
stub
tool
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: raito/lanzaboote#76
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "smart-systemd-boot-install"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The process of installing systemd-boot is "smarter" because it now
considers a a few conditions instead of doing nothing if there is a file
at the deistination path. systemd-boot is now forcibly installed (i.e.
overwriting any file at the destination) if (1) there is no file at the
destination, OR (2) a newer version of systemd-boot is available, OR (3)
the signature of the file at the destination could not be verified.
Fixes part of #39
Will produce a small and easy to fix merge conflict with #75
This still needs a test or two I've realised. ^^
nit: It is a bit of a hack though. ;)
@ -39,0 +55,4 @@
let v = kv
.get(1)
.map(|s| s.trim_matches('"'))
.with_context(|| format!("Failed to get second element from {kv:?}"))?;
This doesn't handle entries with
\"
correctly. (See also the spec.)Maybe something like this would help: https://crates.io/crates/os-release
Oh yes big time. Do you have a better solution? Or should I just make this clear in the comment as well?
But you don't provide a path as parameter. The comment seems stale.
This code was really easy to follow thanks to the useful comments. I love it.
My only concern here is the yolo parsing/printing of the os-release file. If we can use one of the existing parsing libraries that also handles the quoting correctly, I would sleep more calmly. :)
@ -39,0 +55,4 @@
let v = kv
.get(1)
.map(|s| s.trim_matches('"'))
.with_context(|| format!("Failed to get second element from {kv:?}"))?;
I looked at the os-release crate because I had the same instinct of avoiding yolo parsing, but sadly it's (1) unmaintained since 2018 and (2) actually performs the same hack (just slightly less elegantly): Compare mine with theirs
We actually never write out a file we have previously read. So I'm not too worried about yolo parsing from that perspective.
I should add a comment, however, that writing out a previously read file might not produce the same representation.
@ -39,0 +55,4 @@
let v = kv
.get(1)
.map(|s| s.trim_matches('"'))
.with_context(|| format!("Failed to get second element from {kv:?}"))?;
Fair point. I've opened #77 to fix this later.
If you make it clear in the comments this is fine for me. It does the job.
If someone wants to they can just add a small parser from
String
to(u32, u32)
.I'll do this in a separate PR.