@@ -4,6 +4,8 @@ use std::path::{Path, PathBuf};
4
4
use std:: process:: ExitStatus ;
5
5
use std:: { env, fs, time} ;
6
6
7
+ use eyre:: Context ;
8
+
7
9
use super :: engine:: Engine ;
8
10
use super :: shared:: * ;
9
11
use crate :: cargo:: CargoMetadata ;
@@ -130,7 +132,7 @@ fn copy_volume_files(
130
132
. arg ( src. to_utf8 ( ) ?)
131
133
. arg ( format ! ( "{container}:{}" , dst. as_posix( ) ?) )
132
134
. run_and_get_status ( msg_info, false )
133
- . map_err ( Into :: into)
135
+ . map ( Into :: into)
134
136
}
135
137
136
138
fn is_cachedir_tag ( path : & Path ) -> Result < bool > {
@@ -221,9 +223,15 @@ pub fn copy_volume_container_cargo(
221
223
} else {
222
224
// can copy a limit subset of files: the rest is present.
223
225
create_volume_dir ( engine, container, & dst, msg_info) ?;
224
- for entry in fs:: read_dir ( cargo_dir) ? {
226
+ for entry in fs:: read_dir ( cargo_dir)
227
+ . wrap_err_with ( || format ! ( "when reading directory {cargo_dir:?}" ) ) ?
228
+ {
225
229
let file = entry?;
226
- let basename = file. file_name ( ) . to_utf8 ( ) ?. to_string ( ) ;
230
+ let basename = file
231
+ . file_name ( )
232
+ . to_utf8 ( )
233
+ . wrap_err_with ( || format ! ( "when reading file {file:?}" ) ) ?
234
+ . to_string ( ) ;
227
235
if !basename. starts_with ( '.' ) && !matches ! ( basename. as_ref( ) , "git" | "registry" ) {
228
236
copy_volume_files ( engine, container, & file. path ( ) , & dst, msg_info) ?;
229
237
}
@@ -238,7 +246,7 @@ fn copy_dir<Skip>(src: &Path, dst: &Path, depth: u32, skip: Skip) -> Result<()>
238
246
where
239
247
Skip : Copy + Fn ( & fs:: DirEntry , u32 ) -> bool ,
240
248
{
241
- for entry in fs:: read_dir ( src) ? {
249
+ for entry in fs:: read_dir ( src) . wrap_err_with ( || format ! ( "when reading directory {src:?}" ) ) ? {
242
250
let file = entry?;
243
251
if skip ( & file, depth) {
244
252
continue ;
@@ -247,7 +255,8 @@ where
247
255
let src_path = file. path ( ) ;
248
256
let dst_path = dst. join ( file. file_name ( ) ) ;
249
257
if file. file_type ( ) ?. is_file ( ) {
250
- fs:: copy ( & src_path, & dst_path) ?;
258
+ fs:: copy ( & src_path, & dst_path)
259
+ . wrap_err_with ( || format ! ( "when copying file {src_path:?} -> {dst_path:?}" ) ) ?;
251
260
} else {
252
261
fs:: create_dir ( & dst_path) . ok ( ) ;
253
262
copy_dir ( & src_path, & dst_path, depth + 1 , skip) ?;
@@ -755,7 +764,7 @@ pub(crate) fn run(
755
764
756
765
// 2. create our volume to copy all our data over to
757
766
if let VolumeId :: Discard ( ref id) = volume {
758
- volume_create ( engine, id, msg_info) ?;
767
+ volume_create ( engine, id, msg_info) . wrap_err ( "when creating volume" ) ?;
759
768
}
760
769
let _volume_deletter = DeleteVolume ( engine, & volume, msg_info) ;
761
770
@@ -775,9 +784,11 @@ pub(crate) fn run(
775
784
cwd,
776
785
|_, val| mount_path ( val) ,
777
786
|( src, dst) | volumes. push ( ( src, dst) ) ,
778
- ) ?;
787
+ )
788
+ . wrap_err ( "could not determine mount points" ) ?;
779
789
780
- docker_seccomp ( & mut docker, engine. kind , target, metadata) ?;
790
+ docker_seccomp ( & mut docker, engine. kind , target, metadata)
791
+ . wrap_err ( "when copying seccomp profile" ) ?;
781
792
782
793
// Prevent `bin` from being mounted inside the Docker container.
783
794
docker. args ( & [ "-v" , & format ! ( "{mount_prefix}/cargo/bin" ) ] ) ;
@@ -821,15 +832,17 @@ pub(crate) fn run(
821
832
target,
822
833
mount_prefix_path,
823
834
msg_info,
824
- ) ?;
835
+ )
836
+ . wrap_err ( "when copying xargo" ) ?;
825
837
copy_volume_container_cargo (
826
838
engine,
827
839
& container,
828
840
& dirs. cargo ,
829
841
mount_prefix_path,
830
842
false ,
831
843
msg_info,
832
- ) ?;
844
+ )
845
+ . wrap_err ( "when copying cargo" ) ?;
833
846
copy_volume_container_rust (
834
847
engine,
835
848
& container,
@@ -838,7 +851,8 @@ pub(crate) fn run(
838
851
mount_prefix_path,
839
852
false ,
840
853
msg_info,
841
- ) ?;
854
+ )
855
+ . wrap_err ( "when copying rust" ) ?;
842
856
} else {
843
857
// need to copy over the target triple if it hasn't been previously copied
844
858
copy_volume_container_rust_triple (
@@ -849,14 +863,16 @@ pub(crate) fn run(
849
863
mount_prefix_path,
850
864
true ,
851
865
msg_info,
852
- ) ?;
866
+ )
867
+ . wrap_err ( "when copying rust target files" ) ?;
853
868
}
854
869
let mount_root = if mount_volumes {
855
870
// cannot panic: absolute unix path, must have root
856
871
let rel_mount_root = dirs. mount_root . strip_prefix ( '/' ) . unwrap ( ) ;
857
872
let mount_root = mount_prefix_path. join ( rel_mount_root) ;
858
873
if !rel_mount_root. is_empty ( ) {
859
- create_volume_dir ( engine, & container, mount_root. parent ( ) . unwrap ( ) , msg_info) ?;
874
+ create_volume_dir ( engine, & container, mount_root. parent ( ) . unwrap ( ) , msg_info)
875
+ . wrap_err ( "when creating mount root" ) ?;
860
876
}
861
877
mount_root
862
878
} else {
0 commit comments