Skip to content

Commit

Permalink
Try #884: --target x86_64-unknown-linux-gnu
Browse files Browse the repository at this point in the history
  • Loading branch information
bors[bot] authored Jun 30, 2022
2 parents e583132 + b8eb391 commit ecc64ce
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/docker/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub fn run(
docker_in_docker,
cwd,
)
.wrap_err("could not complete remote run")
} else {
local::run(
engine,
Expand Down
42 changes: 29 additions & 13 deletions src/docker/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ use std::path::{Path, PathBuf};
use std::process::ExitStatus;
use std::{env, fs, time};

use eyre::Context;

use super::engine::Engine;
use super::shared::*;
use crate::cargo::CargoMetadata;
Expand Down Expand Up @@ -130,7 +132,7 @@ fn copy_volume_files(
.arg(src.to_utf8()?)
.arg(format!("{container}:{}", dst.as_posix()?))
.run_and_get_status(msg_info, false)
.map_err(Into::into)
.map(Into::into)
}

fn is_cachedir_tag(path: &Path) -> Result<bool> {
Expand Down Expand Up @@ -221,9 +223,15 @@ pub fn copy_volume_container_cargo(
} else {
// can copy a limit subset of files: the rest is present.
create_volume_dir(engine, container, &dst, msg_info)?;
for entry in fs::read_dir(cargo_dir)? {
for entry in fs::read_dir(cargo_dir)
.wrap_err_with(|| format!("when reading directory {cargo_dir:?}"))?
{
let file = entry?;
let basename = file.file_name().to_utf8()?.to_string();
let basename = file
.file_name()
.to_utf8()
.wrap_err_with(|| format!("when reading file {file:?}"))?
.to_string();
if !basename.starts_with('.') && !matches!(basename.as_ref(), "git" | "registry") {
copy_volume_files(engine, container, &file.path(), &dst, msg_info)?;
}
Expand All @@ -238,7 +246,7 @@ fn copy_dir<Skip>(src: &Path, dst: &Path, depth: u32, skip: Skip) -> Result<()>
where
Skip: Copy + Fn(&fs::DirEntry, u32) -> bool,
{
for entry in fs::read_dir(src)? {
for entry in fs::read_dir(src).wrap_err_with(|| format!("when reading directory {src:?}"))? {
let file = entry?;
if skip(&file, depth) {
continue;
Expand All @@ -247,7 +255,8 @@ where
let src_path = file.path();
let dst_path = dst.join(file.file_name());
if file.file_type()?.is_file() {
fs::copy(&src_path, &dst_path)?;
fs::copy(&src_path, &dst_path)
.wrap_err_with(|| format!("when copying file {src_path:?} -> {dst_path:?}"))?;
} else {
fs::create_dir(&dst_path).ok();
copy_dir(&src_path, &dst_path, depth + 1, skip)?;
Expand Down Expand Up @@ -755,7 +764,7 @@ pub(crate) fn run(

// 2. create our volume to copy all our data over to
if let VolumeId::Discard(ref id) = volume {
volume_create(engine, id, msg_info)?;
volume_create(engine, id, msg_info).wrap_err("when creating volume")?;
}
let _volume_deletter = DeleteVolume(engine, &volume, msg_info);

Expand All @@ -775,9 +784,11 @@ pub(crate) fn run(
cwd,
|_, val| mount_path(val),
|(src, dst)| volumes.push((src, dst)),
)?;
)
.wrap_err("could not determine mount points")?;

docker_seccomp(&mut docker, engine.kind, target, metadata)?;
docker_seccomp(&mut docker, engine.kind, target, metadata)
.wrap_err("when copying seccomp profile")?;

// Prevent `bin` from being mounted inside the Docker container.
docker.args(&["-v", &format!("{mount_prefix}/cargo/bin")]);
Expand Down Expand Up @@ -821,15 +832,17 @@ pub(crate) fn run(
target,
mount_prefix_path,
msg_info,
)?;
)
.wrap_err("when copying xargo")?;
copy_volume_container_cargo(
engine,
&container,
&dirs.cargo,
mount_prefix_path,
false,
msg_info,
)?;
)
.wrap_err("when copying cargo")?;
copy_volume_container_rust(
engine,
&container,
Expand All @@ -838,7 +851,8 @@ pub(crate) fn run(
mount_prefix_path,
false,
msg_info,
)?;
)
.wrap_err("when copying rust")?;
} else {
// need to copy over the target triple if it hasn't been previously copied
copy_volume_container_rust_triple(
Expand All @@ -849,14 +863,16 @@ pub(crate) fn run(
mount_prefix_path,
true,
msg_info,
)?;
)
.wrap_err("when copying rust target files")?;
}
let mount_root = if mount_volumes {
// cannot panic: absolute unix path, must have root
let rel_mount_root = dirs.mount_root.strip_prefix('/').unwrap();
let mount_root = mount_prefix_path.join(rel_mount_root);
if !rel_mount_root.is_empty() {
create_volume_dir(engine, &container, mount_root.parent().unwrap(), msg_info)?;
create_volume_dir(engine, &container, mount_root.parent().unwrap(), msg_info)
.wrap_err("when creating mount root")?;
}
mount_root
} else {
Expand Down
3 changes: 2 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@ pub fn run() -> Result<ExitStatus> {
args.msg_info,
args.docker_in_docker,
&cwd,
)?;
)
.wrap_err("when running docker")?;
let needs_host = args
.subcommand
.map(|sc| sc.needs_host(is_remote))
Expand Down

0 comments on commit ecc64ce

Please sign in to comment.