Specify basename, build directory
parent
1e4c33c6d6
commit
f3dda40180
|
@ -59,6 +59,10 @@ enum Commands {
|
||||||
/// Optional cargo flag
|
/// Optional cargo flag
|
||||||
#[arg(long, require_equals = true, num_args = 0..=1, default_value_t = Tag::Debug, default_missing_value = "debug")]
|
#[arg(long, require_equals = true, num_args = 0..=1, default_value_t = Tag::Debug, default_missing_value = "debug")]
|
||||||
tag: Tag,
|
tag: Tag,
|
||||||
|
|
||||||
|
/// Basename of the repository
|
||||||
|
#[arg(long, value_name = "NAME")]
|
||||||
|
basename: String,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -140,6 +144,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
subcommand,
|
subcommand,
|
||||||
features,
|
features,
|
||||||
tag,
|
tag,
|
||||||
|
basename,
|
||||||
} => {
|
} => {
|
||||||
// Connect to a peer
|
// Connect to a peer
|
||||||
let remote = format!("{}:{}", args.host, args.port);
|
let remote = format!("{}:{}", args.host, args.port);
|
||||||
|
@ -165,7 +170,7 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
profile,
|
profile,
|
||||||
command: test_command,
|
command: test_command,
|
||||||
repository: Url::parse(&repo).unwrap(),
|
repository: Url::parse(&repo).unwrap(),
|
||||||
basename: "serde_json".to_string(),
|
basename,
|
||||||
};
|
};
|
||||||
|
|
||||||
info!("Message UUID: <magenta>{}<//>", &test_message.uuid);
|
info!("Message UUID: <magenta>{}<//>", &test_message.uuid);
|
||||||
|
|
|
@ -16,6 +16,7 @@ use uuid_simd::UuidExt;
|
||||||
struct HostConfig {
|
struct HostConfig {
|
||||||
ip: String,
|
ip: String,
|
||||||
port: u16,
|
port: u16,
|
||||||
|
build_directory: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone)]
|
#[derive(Serialize, Deserialize, Clone)]
|
||||||
|
@ -100,7 +101,7 @@ struct Message {
|
||||||
basename: String,
|
basename: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn build(msg: Message, address: SocketAddr) {
|
async fn build(msg: Message, address: SocketAddr, dir: String) {
|
||||||
let mut features = String::new();
|
let mut features = String::new();
|
||||||
match msg.command.features {
|
match msg.command.features {
|
||||||
Some(f) => {
|
Some(f) => {
|
||||||
|
@ -115,14 +116,16 @@ async fn build(msg: Message, address: SocketAddr) {
|
||||||
}
|
}
|
||||||
|
|
||||||
success!(
|
success!(
|
||||||
"Received message from <green>{:?}<//>: <magenta>{}<//>\n<bright-white>git clone {}\n{} {} {} {}\n<//>",
|
"Received message from <green>{:?}<//>: <magenta>{}<//>\n<bright-white>cd {}\ngit clone {}\ncd {}\n{} {} {} {}\n<//>",
|
||||||
address,
|
address,
|
||||||
msg.uuid.format_hyphenated(),
|
msg.uuid.format_hyphenated(),
|
||||||
|
dir,
|
||||||
msg.repository,
|
msg.repository,
|
||||||
|
msg.basename,
|
||||||
msg.command.build_system,
|
msg.command.build_system,
|
||||||
msg.command.subcommand,
|
msg.command.subcommand,
|
||||||
msg.command.tag,
|
msg.command.tag,
|
||||||
features
|
features,
|
||||||
);
|
);
|
||||||
|
|
||||||
match msg.pre_exec {
|
match msg.pre_exec {
|
||||||
|
@ -162,6 +165,7 @@ async fn process_socket(
|
||||||
mut socket: TcpStream,
|
mut socket: TcpStream,
|
||||||
address: SocketAddr,
|
address: SocketAddr,
|
||||||
auth: AuthConfig,
|
auth: AuthConfig,
|
||||||
|
dir: String,
|
||||||
salt: SaltString,
|
salt: SaltString,
|
||||||
argon2: Argon2<'_>,
|
argon2: Argon2<'_>,
|
||||||
) {
|
) {
|
||||||
|
@ -187,12 +191,13 @@ async fn process_socket(
|
||||||
if auth.authenticate {
|
if auth.authenticate {
|
||||||
match &auth.password {
|
match &auth.password {
|
||||||
Some(pass) => {
|
Some(pass) => {
|
||||||
|
let directory = dir.clone();
|
||||||
if json
|
if json
|
||||||
.authenticate(pass.clone(), salt.clone(), argon2.clone())
|
.authenticate(pass.clone(), salt.clone(), argon2.clone())
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
build(json, address).await;
|
build(json, address, directory).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -201,7 +206,10 @@ async fn process_socket(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
build(json, address).await;
|
let directory = dir.clone();
|
||||||
|
tokio::spawn(async move {
|
||||||
|
build(json, address, directory).await;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -220,10 +228,11 @@ async fn main() -> io::Result<()> {
|
||||||
match listener.accept().await {
|
match listener.accept().await {
|
||||||
Ok((socket, addr)) => {
|
Ok((socket, addr)) => {
|
||||||
let auth = config.auth.clone();
|
let auth = config.auth.clone();
|
||||||
|
let dir = config.host.build_directory.clone().unwrap();
|
||||||
let m_salt = salt.clone();
|
let m_salt = salt.clone();
|
||||||
let m_argon2 = argon2.clone();
|
let m_argon2 = argon2.clone();
|
||||||
tokio::spawn(async move {
|
tokio::spawn(async move {
|
||||||
process_socket(socket, addr, auth, m_salt, m_argon2).await;
|
process_socket(socket, addr, auth, dir, m_salt, m_argon2).await;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
Err(e) => error!("couldn't get client: {:?}", e),
|
Err(e) => error!("couldn't get client: {:?}", e),
|
||||||
|
@ -236,6 +245,9 @@ async fn configure() -> Config {
|
||||||
default_config.push("forge");
|
default_config.push("forge");
|
||||||
default_config.push("config.toml");
|
default_config.push("config.toml");
|
||||||
|
|
||||||
|
let mut default_build_dir = dirs::home_dir().unwrap();
|
||||||
|
default_build_dir.push("src");
|
||||||
|
|
||||||
let config_contents = match fs::read_to_string(&default_config) {
|
let config_contents = match fs::read_to_string(&default_config) {
|
||||||
Ok(f) => f,
|
Ok(f) => f,
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
|
@ -244,6 +256,7 @@ async fn configure() -> Config {
|
||||||
host: HostConfig {
|
host: HostConfig {
|
||||||
ip: "127.0.0.1".to_string(),
|
ip: "127.0.0.1".to_string(),
|
||||||
port: 9134,
|
port: 9134,
|
||||||
|
build_directory: Some(default_build_dir.to_str().unwrap().to_string()),
|
||||||
},
|
},
|
||||||
auth: AuthConfig {
|
auth: AuthConfig {
|
||||||
authenticate: false,
|
authenticate: false,
|
||||||
|
|
Loading…
Reference in New Issue