@@ -16,7 +16,7 @@ use crate::{
1616 config, error, info,
1717 machine:: { self , get_container_ns_name, inspect_instance, spawn_container} ,
1818 network:: download_file_progress,
19- overlayfs, warn,
19+ overlayfs, repo , warn,
2020} ;
2121
2222use super :: { for_each_instance, APT_UPDATE_SCRIPT } ;
@@ -298,6 +298,28 @@ pub fn start_container(instance: &str) -> Result<String> {
298298 Ok ( ns_name)
299299}
300300
301+ /// Prepare the local repository for the container
302+ pub fn prepare_local_repo ( instance : & str ) -> Result < ( ) > {
303+ let conf = config:: read_config ( ) ;
304+ if conf. is_err ( ) {
305+ return Err ( anyhow ! ( "Please configure this workspace first!" ) ) ;
306+ }
307+ let conf = conf. unwrap ( ) ;
308+ if !conf. local_repo {
309+ return Err ( anyhow ! ( "Please enable local packages repository first!" ) ) ;
310+ }
311+ let ns_name = get_instance_ns_name ( instance) ?;
312+ let inst = inspect_instance ( instance, & ns_name) ?;
313+ let output_dir = get_output_directory ( conf. sep_mount ) ;
314+ let root = std:: env:: current_dir ( ) ?. join ( output_dir) ;
315+ if !inst. mounted {
316+ mount_fs ( instance) ?;
317+ }
318+ info ! ( "Refreshing local repository..." ) ;
319+ repo:: init_repo ( root. as_ref ( ) , Path :: new ( & instance) ) ?;
320+ Ok ( ( ) )
321+ }
322+
301323/// Execute the specified command in the container
302324pub fn run_in_container < S : AsRef < OsStr > > ( instance : & str , args : & [ S ] ) -> Result < i32 > {
303325 let ns_name = start_container ( instance) ?;
0 commit comments