From df1c781cf9f69ab68cb38dd026ece22610ddd662 Mon Sep 17 00:00:00 2001 From: Alex Huszagh Date: Wed, 29 Jun 2022 16:19:54 -0500 Subject: [PATCH] Minor bug fixes. --- src/bin/commands/containers.rs | 10 +++++----- xtask/src/util.rs | 14 ++++++-------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/bin/commands/containers.rs b/src/bin/commands/containers.rs index fc0582e68..ffa3e863a 100644 --- a/src/bin/commands/containers.rs +++ b/src/bin/commands/containers.rs @@ -109,9 +109,9 @@ impl CreateVolume { #[derive(Args, Debug)] pub struct RemoveVolume { - /// Triple for the target platform. - #[clap(long)] - pub target: String, + /// FIXME: remove in 0.3.0, remains since it's a breaking change. + #[clap(long, hide = true)] + pub target: Option, /// If cross is running inside a container. #[clap(short, long)] pub docker_in_docker: bool, @@ -473,7 +473,6 @@ pub fn create_persistent_volume( pub fn remove_persistent_volume( RemoveVolume { - target, docker_in_docker, verbose, quiet, @@ -484,8 +483,9 @@ pub fn remove_persistent_volume( channel: Option<&str>, ) -> cross::Result<()> { let msg_info = MessageInfo::create(verbose, quiet, color.as_deref())?; + let triple = cross::Host::X86_64UnknownLinuxGnu.triple(); let (_, _, dirs) = - docker::get_package_info(engine, &target, channel, docker_in_docker, msg_info)?; + docker::get_package_info(engine, triple, channel, docker_in_docker, msg_info)?; let volume = docker::remote::unique_toolchain_identifier(&dirs.sysroot)?; if !docker::remote::volume_exists(engine, &volume, msg_info)? { diff --git a/xtask/src/util.rs b/xtask/src/util.rs index 4ec5ddb7e..8eafeb3a0 100644 --- a/xtask/src/util.rs +++ b/xtask/src/util.rs @@ -216,7 +216,7 @@ pub fn gha_output(tag: &str, content: &str) { println!("::set-output name={tag}::{}", content) } -pub fn read_dockerfiles(msg_info: MessageInfo) -> cross::Result> { +pub fn read_dockerfiles(msg_info: MessageInfo) -> cross::Result> { let root = project_dir(msg_info)?; let docker = root.join("docker"); let mut dockerfiles = vec![]; @@ -225,18 +225,18 @@ pub fn read_dockerfiles(msg_info: MessageInfo) -> cross::Result> { let file_type = entry.file_type()?; let file_name = entry.file_name(); if file_type.is_file() && file_name.to_utf8()?.starts_with("Dockerfile") { - dockerfiles.push(fs::read_to_string(entry.path())?); + let contents = fs::read_to_string(entry.path())?; + dockerfiles.push((entry.path().to_path_buf(), contents)); } } Ok(dockerfiles) } -#[cfg(tests)] +#[cfg(test)] mod tests { use super::*; - use crate::util::read_dockerfiles; use cross::shell::Verbosity; use std::collections::BTreeMap; @@ -245,15 +245,13 @@ mod tests { // count all the entries of FROM for our images let mut counts = BTreeMap::new(); let dockerfiles = read_dockerfiles(Verbosity::Verbose.into())?; - for dockerfile in dockerfiles { + for (path, dockerfile) in dockerfiles { let lines: Vec<&str> = dockerfile.lines().collect(); let index = lines .iter() .map(|x| x.trim()) .position(|x| x.to_lowercase().starts_with("from")) - .ok_or_else(|| { - eyre::eyre!("unable to find FROM instruction for {:?}", entry.path()) - })?; + .ok_or_else(|| eyre::eyre!("unable to find FROM instruction for {:?}", path))?; let tag = lines[index] .split_whitespace() .nth(1)