From 22e98e4555a9ecc55c365c7f5b4331356c860264 Mon Sep 17 00:00:00 2001 From: ZSchoen Date: Thu, 8 Apr 2021 17:30:20 +0200 Subject: [PATCH] fixed ssh-port & rsync address + added env to Remote --- src/config.rs | 6 ++++++ src/main.rs | 33 +++++++++++++++++---------------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/src/config.rs b/src/config.rs index a9eefd2..2f87bcf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -6,6 +6,7 @@ pub struct Remote { pub host: String, pub ssh_port: u16, pub temp_dir: String, + pub env: String, } #[derive(Debug, Deserialize)] @@ -14,6 +15,7 @@ struct PartialRemote { pub host: String, pub ssh_port: Option, pub temp_dir: Option, + pub env: Option, } impl Default for Remote { @@ -23,6 +25,7 @@ impl Default for Remote { host: String::new(), ssh_port: 22, temp_dir: "~/remote-builds".to_string(), + env: "/etc/profile".to_string(), } } } @@ -33,11 +36,13 @@ impl From for Remote { let name = minimal_remote.name.unwrap_or(default.name); let ssh_port = minimal_remote.ssh_port.unwrap_or(default.ssh_port); let temp_dir = minimal_remote.temp_dir.unwrap_or(default.temp_dir); + let env = minimal_remote.env.unwrap_or(default.env); Remote { name, host: minimal_remote.host, ssh_port, temp_dir, + env, } } } @@ -96,6 +101,7 @@ impl Config { host: opts.host.clone().unwrap_or(blueprint_remote.host), ssh_port: opts.ssh_port.clone().unwrap_or(blueprint_remote.ssh_port), temp_dir: opts.temp_dir.clone().unwrap_or(blueprint_remote.temp_dir), + env: opts.env.clone().unwrap_or(blueprint_remote.env), }) } } diff --git a/src/main.rs b/src/main.rs index 7f6dcc4..2d68ad2 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,6 +27,13 @@ pub struct RemoteOpts { /// The directory where cargo builds the project #[structopt(short, long = "remote-temp-dir")] temp_dir: Option, + + #[structopt( + short = "e", + long = "env", + help = "Environment profile. default_value = /etc/profile" + )] + env: Option, } #[derive(StructOpt, Debug)] @@ -53,14 +60,6 @@ enum Opts { )] rustup_default: String, - #[structopt( - short = "e", - long = "env", - help = "Environment profile. default_value = /etc/profile", - default_value = "/etc/profile" - )] - env: String, - #[structopt( short = "c", long = "copy-back", @@ -107,7 +106,6 @@ fn main() { remote_opts, build_env, rustup_default, - env, copy_back, no_copy_lock, manifest_path, @@ -153,7 +151,8 @@ fn main() { .arg("-a".to_owned()) .arg("--delete") .arg("--compress") - .args(&["-e", "ssh", "-p", &remote.ssh_port.to_string()]) + .arg("-e") + .arg(format!("ssh -p {}", remote.ssh_port)) .arg("--info=progress2") .arg("--exclude") .arg("target"); @@ -176,11 +175,11 @@ fn main() { exit(-4); }); info!("Build ENV: {:?}", build_env); - info!("Environment profile: {:?}", env); + info!("Environment profile: {:?}", remote.env); info!("Build path: {:?}", build_path); let build_command = format!( "source {}; rustup default {}; cd {}; {} cargo {} {}", - env, + remote.env, rustup_default, build_path, build_env, @@ -210,11 +209,12 @@ fn main() { .arg("-a") .arg("--delete") .arg("--compress") - .args(&["-e", "ssh", "-p", &remote.ssh_port.to_string()]) + .arg("-e") + .arg(format!("ssh -p {}", remote.ssh_port)) .arg("--info=progress2") .arg("--info=progress2") .arg(format!( - "{}:{}/target/{}", + "{}:{}target/{}", build_server, build_path, file_name )) .arg(format!( @@ -241,10 +241,11 @@ fn main() { .arg("-a") .arg("--delete") .arg("--compress") - .args(&["-e", "ssh", "-p", &remote.ssh_port.to_string()]) + .arg("-e") + .arg(format!("ssh -p {}", remote.ssh_port)) .arg("--info=progress2") .arg("--info=progress2") - .arg(format!("{}:{}/Cargo.lock", build_server, build_path)) + .arg(format!("{}:{}Cargo.lock", build_server, build_path)) .arg(format!("{}/Cargo.lock", project_dir.to_string_lossy())) .stdout(Stdio::inherit()) .stderr(Stdio::inherit())