Skip to content

Commit e583132

Browse files
Merge #882
882: Minor bug fixes. r=Emilgardis a=Alexhuszagh Removes the requirement of an unused target from `cross-util volumes remove` and fixes the Ubuntu base testing. Co-authored-by: Alex Huszagh <[email protected]>
2 parents e594054 + df1c781 commit e583132

File tree

2 files changed

+11
-13
lines changed

2 files changed

+11
-13
lines changed

src/bin/commands/containers.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -109,9 +109,9 @@ impl CreateVolume {
109109

110110
#[derive(Args, Debug)]
111111
pub struct RemoveVolume {
112-
/// Triple for the target platform.
113-
#[clap(long)]
114-
pub target: String,
112+
/// FIXME: remove in 0.3.0, remains since it's a breaking change.
113+
#[clap(long, hide = true)]
114+
pub target: Option<String>,
115115
/// If cross is running inside a container.
116116
#[clap(short, long)]
117117
pub docker_in_docker: bool,
@@ -473,7 +473,6 @@ pub fn create_persistent_volume(
473473

474474
pub fn remove_persistent_volume(
475475
RemoveVolume {
476-
target,
477476
docker_in_docker,
478477
verbose,
479478
quiet,
@@ -484,8 +483,9 @@ pub fn remove_persistent_volume(
484483
channel: Option<&str>,
485484
) -> cross::Result<()> {
486485
let msg_info = MessageInfo::create(verbose, quiet, color.as_deref())?;
486+
let triple = cross::Host::X86_64UnknownLinuxGnu.triple();
487487
let (_, _, dirs) =
488-
docker::get_package_info(engine, &target, channel, docker_in_docker, msg_info)?;
488+
docker::get_package_info(engine, triple, channel, docker_in_docker, msg_info)?;
489489
let volume = docker::remote::unique_toolchain_identifier(&dirs.sysroot)?;
490490

491491
if !docker::remote::volume_exists(engine, &volume, msg_info)? {

xtask/src/util.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ pub fn gha_output(tag: &str, content: &str) {
216216
println!("::set-output name={tag}::{}", content)
217217
}
218218

219-
pub fn read_dockerfiles(msg_info: MessageInfo) -> cross::Result<Vec<String>> {
219+
pub fn read_dockerfiles(msg_info: MessageInfo) -> cross::Result<Vec<(PathBuf, String)>> {
220220
let root = project_dir(msg_info)?;
221221
let docker = root.join("docker");
222222
let mut dockerfiles = vec![];
@@ -225,18 +225,18 @@ pub fn read_dockerfiles(msg_info: MessageInfo) -> cross::Result<Vec<String>> {
225225
let file_type = entry.file_type()?;
226226
let file_name = entry.file_name();
227227
if file_type.is_file() && file_name.to_utf8()?.starts_with("Dockerfile") {
228-
dockerfiles.push(fs::read_to_string(entry.path())?);
228+
let contents = fs::read_to_string(entry.path())?;
229+
dockerfiles.push((entry.path().to_path_buf(), contents));
229230
}
230231
}
231232

232233
Ok(dockerfiles)
233234
}
234235

235-
#[cfg(tests)]
236+
#[cfg(test)]
236237
mod tests {
237238
use super::*;
238239

239-
use crate::util::read_dockerfiles;
240240
use cross::shell::Verbosity;
241241
use std::collections::BTreeMap;
242242

@@ -245,15 +245,13 @@ mod tests {
245245
// count all the entries of FROM for our images
246246
let mut counts = BTreeMap::new();
247247
let dockerfiles = read_dockerfiles(Verbosity::Verbose.into())?;
248-
for dockerfile in dockerfiles {
248+
for (path, dockerfile) in dockerfiles {
249249
let lines: Vec<&str> = dockerfile.lines().collect();
250250
let index = lines
251251
.iter()
252252
.map(|x| x.trim())
253253
.position(|x| x.to_lowercase().starts_with("from"))
254-
.ok_or_else(|| {
255-
eyre::eyre!("unable to find FROM instruction for {:?}", entry.path())
256-
})?;
254+
.ok_or_else(|| eyre::eyre!("unable to find FROM instruction for {:?}", path))?;
257255
let tag = lines[index]
258256
.split_whitespace()
259257
.nth(1)

0 commit comments

Comments
 (0)