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

Building quark #10

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

Building quark #10

wants to merge 2 commits into from

Conversation

JeremyLARDENOIS
Copy link

Signed-off-by: JeremyLARDENOIS [email protected]

@sameo Can I have a review? 🙂

Signed-off-by: JeremyLARDENOIS <[email protected]>
Copy link
Contributor

@sameo sameo left a comment

Choose a reason for hiding this comment

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

Thanks for the PR @JeremyLARDENOIS . I have a few comments on the code and an additional one on the PR/commit: Your single commit should explain what it's doing and why it's doing it. Building quarkwont allow anyone going through future git logs to understand what this commit is about.

.gitignore Outdated Show resolved Hide resolved
src/cli/build.rs Outdated Show resolved Hide resolved
src/cli/build.rs Show resolved Hide resolved

if !self.offline {
println!("Online mode is not supported yet.");
return Ok(());
Copy link
Contributor

Choose a reason for hiding this comment

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

If it's not supported, you should return an error.

.arg(src)
.arg(workdir)
.status()
.unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

No unwrap, please propagate the error instead.
Also, you should consider using the https://docs.rs/fs_extra/1.2.0/fs_extra/index.html crate. It's only based on the std crate.

Copy link
Author

Choose a reason for hiding this comment

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

I wanted to use it, but I didn't achieve it. I will try again I think

} else {
// If the rootfs doesn't exist, display error message
println!("Rootfs doesn't exist.");
return Ok(());
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto.

src/cli/build.rs Outdated Show resolved Hide resolved

// Change the init script to use the kaps bundle
println!("Changing init script to use the kaps bundle");
let init_script = format!("{}/{}/init", workdir, rootfs_filename);
Copy link
Contributor

Choose a reason for hiding this comment

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

A cleaner way to build an actual path is to use the std::path::Pathcrate.

let mut init_script_file = std::fs::File::create(init_script.clone())?;
println!("Writing new init script");
let kaps_name = self.kaps.split('/').last().unwrap();
let bundle_name = self.bundle.split('/').last().unwrap();
Copy link
Contributor

Choose a reason for hiding this comment

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

Lots of unwraps, lots of potential panics. Return an error (through e.g.map_err).

// Create initramfs ------------------------------------------------------------
println!("Creating initramfs");
let rootfs_workdir = format!("{}/{}", workdir, rootfs_filename);
(subprocess::Exec::shell(format!("find {} -print0", rootfs_workdir))
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not Commandinstead?

Copy link
Author

Choose a reason for hiding this comment

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

Because there is a bash pipe, and I don't know how to do it without make a bash script

Signed-off-by: JeremyLARDENOIS <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants