@@ -79,7 +79,7 @@ impl Cargo {
7979 // let status = command
8080 // .arg("pepsi")
8181 // .arg("sdk")
82- // .adownload_and_installrg ("install")
82+ // .arg ("install")
8383 // .arg("--version")
8484 // .arg(version)
8585 // .status()
@@ -127,27 +127,12 @@ impl Cargo {
127127 let pwd = Path :: new ( "/hulk" ) . join ( & repository. root_to_current_dir ( ) ?) ;
128128 let root = repository. current_dir_to_root ( ) ?;
129129 let tagged_image_name = sdk_image. name_tagged ( ) ;
130- let mut command = OsString :: from ( format ! (
131- "\
132- mkdir -p {cargo_home}/git && \
133- mkdir -p {cargo_home}/registry && \
134- podman run \
135- --volume={root}:/hulk:z \
136- --volume={cargo_home}/git:/root/.cargo/git:z \
137- --volume={cargo_home}/registry:/root/.cargo/registry:z \
138- --net=host \
139- --rm \
140- --interactive \
141- --pull=never \
142- --tty \
143- {tagged_image_name} \
144- /bin/sh -c '\
145- cd {pwd} && \
146- echo $PATH && \
147- /root/.cargo/bin/cargo \
148- ",
149- root = root. display( ) ,
150- pwd = pwd. display( ) ,
130+ let mut command = OsString :: from ( build_command_string (
131+ "podman" ,
132+ cargo_home,
133+ root. display ( ) . to_string ( ) ,
134+ tagged_image_name,
135+ pwd. display ( ) . to_string ( ) ,
151136 ) ) ;
152137 command. push ( arguments) ;
153138 command. push ( OsStr :: new ( "'" ) ) ;
@@ -159,26 +144,12 @@ impl Cargo {
159144 let pwd = Path :: new ( "/hulk" ) . join ( & repository. root_to_current_dir ( ) ?) ;
160145 let root = repository. current_dir_to_root ( ) ?;
161146 let tagged_image_name = sdk_image. name_tagged ( ) ;
162- let mut command = OsString :: from ( format ! (
163- "\
164- mkdir -p {cargo_home}/git && \
165- mkdir -p {cargo_home}/registry && \
166- docker run \
167- --volume={root}:/hulk:z \
168- --volume={cargo_home}/git:/root/.cargo/git:z \
169- --volume={cargo_home}/registry:/root/.cargo/registry:z \
170- --rm \
171- --interactive \
172- --pull=never \
173- --tty \
174- {tagged_image_name} \
175- /bin/sh -c '\
176- cd {pwd} && \
177- echo $PATH && \
178- cargo \
179- ",
180- root = root. display( ) ,
181- pwd = pwd. display( ) ,
147+ let mut command = OsString :: from ( build_command_string (
148+ "docker" ,
149+ cargo_home,
150+ root. display ( ) . to_string ( ) ,
151+ tagged_image_name,
152+ pwd. display ( ) . to_string ( ) ,
182153 ) ) ;
183154 command. push ( arguments) ;
184155 command. push ( OsStr :: new ( "'" ) ) ;
@@ -208,3 +179,31 @@ impl Cargo {
208179 Ok ( command)
209180 }
210181}
182+
183+ fn build_command_string (
184+ container_runtime : & str ,
185+ cargo_home : String ,
186+ root : String ,
187+ tagged_image_name : String ,
188+ pwd : String ,
189+ ) -> String {
190+ format ! (
191+ "\
192+ mkdir -p {cargo_home}/git && \
193+ mkdir -p {cargo_home}/registry && \
194+ {container_runtime} run \
195+ --volume={root}:/hulk:z \
196+ --volume={cargo_home}/git:/root/.cargo/git:z \
197+ --volume={cargo_home}/registry:/root/.cargo/registry:z \
198+ --rm \
199+ --interactive \
200+ --pull=never \
201+ --tty \
202+ {tagged_image_name} \
203+ /bin/sh -c '\
204+ cd {pwd} && \
205+ echo $PATH && \
206+ cargo \
207+ "
208+ )
209+ }
0 commit comments