-
-
Notifications
You must be signed in to change notification settings - Fork 1
refactor(cli): rewrite cli in rust - WIP #14
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
base: main
Are you sure you want to change the base?
Conversation
59c1206 to
c505243
Compare
c505243 to
75ab1bb
Compare
8ce1e79 to
9dabf66
Compare
TheJJ
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
awsum! added some ideas and small nits.
i think we should already separate between the rust-only cli entry point (which doesn't need pyo3/maturin) and potentially stuff being called from debmagic-pkg or others via python.
| "PATH": f"/usr/share/cargo/bin:{os.environ['PATH']}", | ||
| "CARGO": "/usr/share/cargo/bin/cargo", | ||
| "CARGO_HOME": f"{Path.cwd()}/debian/cargo_home", | ||
| "CARGO_REGISTRY": f"{Path.cwd()}/debian/cargo_registry", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pkg.base_dir
|
|
||
| os.environ.update({ | ||
| "PATH": f"/usr/share/cargo/bin:{os.environ['PATH']}", | ||
| "CARGO": "/usr/share/cargo/bin/cargo", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls add a todo to move this to our not-yet-existing rust module.
|
|
||
| # Added by cargo | ||
|
|
||
| /target |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to 'building' section above.
| @@ -0,0 +1,3 @@ | |||
| [workspace] | |||
| resolver = "3" | |||
| members = ["packages/debmagic"] | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rust edition, version and dependencies can be moved here ([workspace.package], [workspace.dependencies]
| manifest-path = "Cargo.toml" | ||
| module-name = "debmagic.cli" | ||
| strip = true | ||
| exclude = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the debmagic cli still needed as a python package?
if we need a python-api for it, we should have a separate crate. debmagic_api as lib with pyo3 python api, debmagic (=cli) using the api crate.
| let current_dir = env::current_dir()?; | ||
| match &cli.command { | ||
| Commands::Build(args) => { | ||
| let source_dir = args.source_dir.as_deref().unwrap_or(¤t_dir); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of current_dir, should be package_base_dir (detected by debian directory?)
|
|
||
| fn cleanup(&self); | ||
|
|
||
| fn drop_into_shell(&self) -> std::io::Result<()>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
name it just shell?
also, maybe have a difference between builddrivers and machine providers - the former are "how to build" and the latter are "how to launch and control machines (containers/vms...)"
| let mut full_cmd: Vec<String> = Vec::new(); | ||
|
|
||
| // Handle sudo logic | ||
| let is_root = unsafe { libc::getuid() == 0 }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
geteuid
|
|
||
| command.current_dir(cwd); | ||
|
|
||
| // Inherit stdout/stderr to match Python behavior |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leftover?
|
|
||
| fn drop_into_shell(&self) -> std::io::Result<()> { | ||
| let mut shell = Command::new("/usr/bin/env"); | ||
| shell.arg("bash"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
todo: configurable. maybe default shell of build user, maybe just run login -f $user?
No description provided.