[pve-devel] [PATCH v1 installer 14/18] auto-installer: add fetch answer binary
Christoph Heiss
c.heiss at proxmox.com
Tue Feb 6 12:33:35 CET 2024
On Tue, Jan 23, 2024 at 06:00:49PM +0100, Aaron Lauterer wrote:
>
[..]
> diff --git a/proxmox-auto-installer/src/bin/proxmox-fetch-answer.rs b/proxmox-auto-installer/src/bin/proxmox-fetch-answer.rs
> new file mode 100644
> index 0000000..baf2bd2
> --- /dev/null
> +++ b/proxmox-auto-installer/src/bin/proxmox-fetch-answer.rs
> @@ -0,0 +1,73 @@
[..]
> +fn main() -> ExitCode {
> + if let Err(err) = init_log() {
> + panic!("could not initilize logging: {err}");
> + }
> +
> + info!("Fetching answer file");
> + let answer = match fetch_answer() {
> + Ok(answer) => answer,
> + Err(err) => {
> + error!("Aborting: {}", err);
> + return ExitCode::FAILURE;
> + }
> + };
> +
> + let mut child = match Command::new("/usr/bin/proxmox-auto-installer")
Is relaying on hard-coded paths necessary here? Just using
"proxmox-auto-installer" should work fine too, as `Command` searches in
$PATH anyway for relative paths.
[..]
> diff --git a/proxmox-auto-installer/src/fetch_plugins/partition.rs b/proxmox-auto-installer/src/fetch_plugins/partition.rs
> new file mode 100644
> index 0000000..0552ddd
> --- /dev/null
> +++ b/proxmox-auto-installer/src/fetch_plugins/partition.rs
> @@ -0,0 +1,102 @@
[..]
> + /// Will mount source path to ANSWER_MP
> + ///
> + /// # Arguments
> + ///
> + /// * `source` - `PathBuf` of the source location
> + fn mount_part(source: PathBuf) -> Result<()> {
> + info!("Mounting partition at {ANSWER_MP}");
> + // create dir for mountpoint
> + match Command::new("/usr/bin/mkdir")
> + .arg(ANSWER_MP)
> + .arg("-p")
> + .output()
> + {
> + Ok(output) => {
> + if !output.status.success() {
> + warn!(
> + "Error creating mount path: {}",
> + String::from_utf8(output.stderr)?
> + )
> + }
> + }
> + Err(err) => bail!("Error creating mount path: {}", err),
> + }
This can replaced with a `std::fs::create_dir_all(ANSWER_MP)?`.
But if nothing else major turns up, cleaning it (both) up as a follow-up
patch is fine too I'd say - since it is a rather big series.
> + match Command::new("/usr/bin/mount")
^ Same as proxmox-auto-installer
[..]
> _______________________________________________
> pve-devel mailing list
> pve-devel at lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
>
>
More information about the pve-devel
mailing list