@@ -83,13 +83,15 @@ clone(#{repo_state := _State, otp_version := {_,_,_,Ver}} = S0) ->
8383 Branch = [" OTP-" , Ver ],
8484 % See https://github.com/erlang/rebar3/pull/2660
8585 S2 = mapz :deep_put ([shell , env , " GIT_TERMINAL_PROMPT" ], " 0" , S1 ),
86- {{ok , Output }, S3 } = shell (S2 ,
87- " git clone "
88- " -b " ++ Branch ++ " "
89- " --depth 1 " ++
90- " --single-branch " ++
91- URL ++ " \" " ++ binary_to_list (BuildPath ) ++ " \" "
92- ),
86+ Cmd = [
87+ " git clone " ,
88+ " -b " , Branch , " " ,
89+ " --depth 1 " ,
90+ " --single-branch " ,
91+ URL , " " ,
92+ grisp_tools_util :shell_quote (BuildPath )
93+ ],
94+ {{ok , Output }, S3 } = shell (S2 , Cmd ),
9395 event (mapz :deep_put ([build , download ], true , S3 ), [{output , Output }]).
9496
9597prepare (S0 ) ->
@@ -208,10 +210,12 @@ install(S0) ->
208210 grisp_tools_util :ensure_dir (filename :join (InstallPath , " ." )),
209211 S1 = grisp_tools_util :pipe (S0 , [
210212 fun (S ) -> shell_ok (S ,
211- [" rm -rf " , filename :join (InstallPath , " *" )],
213+ [" rm -rf " ,
214+ grisp_tools_util :shell_quote (InstallPath ), " /*" ],
212215 [{cd , InstallPath }]) end ,
213216 fun (S ) -> shell_ok (S ,
214- [" make install DESTDIR=" , $" , InstallPath , $" ],
217+ [" make install DESTDIR=" ,
218+ grisp_tools_util :shell_quote (InstallPath )],
215219 [{cd , BuildPath }]) end
216220 ]),
217221
@@ -254,7 +258,8 @@ tar(#{build := #{flags := #{tar := true}}} = S0) ->
254258 Name = grisp_tools_util :package_name (S0 ),
255259 Package = filename :join (PackagePath , Name ),
256260 grisp_tools_util :ensure_dir (Package ),
257- shell_ok (S0 , [" tar -zcf " , Package , " ." ], [{cd , InstallPath }]),
261+ shell_ok (S0 , [" tar -zcf " , grisp_tools_util :shell_quote (Package ), " ." ],
262+ [{cd , InstallPath }]),
258263 event (S0 , [{file , relative (Package )}]);
259264tar (S0 ) ->
260265 event (S0 , ['_skip' ]).
@@ -276,30 +281,40 @@ dockerize_command(Cmd, S0) ->
276281 BuidPath = binary_to_list (mapz :deep_get ([paths , build ], S0 )),
277282 {docker , Image } = mapz :deep_get ([paths , toolchain ], S0 ),
278283 BuildSubdir = string :prefix (BuidPath , Cwd ),
279- [" docker run" ,
280- " --rm " ,
281- [" -e " ++ K ++ " =" ++ io_lib :format (" ~s " ,[V ])|| {K ,V } <- maps :to_list (Env )],
282- " --volume " ++ Cwd ++ " :" ++ Cwd ,
283- " " ++ Image ++ " sh -c \" cd " ++ Cwd ++ BuildSubdir ,
284- " && " , Cmd , " \" " ].
284+ VolumeArg = grisp_tools_util :shell_quote ([Cwd , " :" , Cwd ]),
285+ EnvArgs = [
286+ [" -e " , grisp_tools_util :shell_quote ([K , " =" , V ])]
287+ || {K , V } <- maps :to_list (Env )
288+ ],
289+ Script = [" cd " , grisp_tools_util :shell_quote ([Cwd , BuildSubdir ]), " && " , Cmd ],
290+ [
291+ " docker run --rm" ,
292+ EnvArgs ,
293+ " --volume " , VolumeArg ,
294+ " " , grisp_tools_util :shell_quote (Image ),
295+ " sh -c " , grisp_tools_util :shell_quote (Script )
296+ ].
285297
286298apply_patch ({Name , Patch }, State0 ) ->
287299 Dir = mapz :deep_get ([paths , build ], State0 ),
288300 Context = mapz :deep_get ([build , context ], State0 ),
289301 grisp_tools_util :copy_file (Dir , Patch , Context ),
290302 State4 = case shell (State0 ,
291- [" git apply " , Name , " --ignore-whitespace --reverse --check" ],
303+ [" git apply " , grisp_tools_util :shell_quote (Name ),
304+ " --ignore-whitespace --reverse --check" ],
292305 [{cd , Dir }, return_on_error ]) of
293306 {{ok , _Output }, State1 } ->
294307 event (State1 , [{skip , Patch }]);
295308 {{error , {1 , _ }}, State1 } ->
296309 State2 = event (State1 , [{apply , Patch }]),
297310 {{ok , _ }, State3 } = shell (State2 ,
298- " git apply --ignore-whitespace " ++ Name ,
311+ [" git apply --ignore-whitespace " ,
312+ grisp_tools_util :shell_quote (Name )],
299313 [{cd , Dir }]),
300314 State3
301315 end ,
302- {{ok , _ }, State5 } = shell (State4 , " rm " ++ Name , [{cd , Dir }]),
316+ {{ok , _ }, State5 } = shell (State4 , [" rm " , grisp_tools_util :shell_quote (Name )],
317+ [{cd , Dir }]),
303318 State5 .
304319
305320sort_files (Apps , Files ) ->
@@ -337,7 +352,7 @@ run_hooks(#{paths := #{toolchain := {ToolchainType, _}}} = S0, Type, Opts) ->
337352
338353delete_directory (BuildPath , S0 ) ->
339354 case filelib :is_dir (BuildPath ) of
340- true -> shell_ok (S0 , " rm -rf \" " ++ binary_to_list (BuildPath ) ++ " \" " , []);
355+ true -> shell_ok (S0 , [ " rm -rf " , grisp_tools_util : shell_quote (BuildPath )] , []);
341356 false -> S0
342357 end .
343358
@@ -362,11 +377,13 @@ check_git_repository(BuildPath, S0) ->
362377repo_sanity_check (Repo , S0 ) ->
363378 PlumbingTests = [
364379 {
365- " git --git-dir " ++ Repo ++ " fetch --dry-run" ,
380+ [" git --git-dir " , grisp_tools_util :shell_quote (Repo ),
381+ " fetch --dry-run" ],
366382 fun (" " ) -> true ; (_ ) -> false end
367383 },
368384 {
369- " git --git-dir " ++ Repo ++ " describe --tags" ,
385+ [" git --git-dir " , grisp_tools_util :shell_quote (Repo ),
386+ " describe --tags" ],
370387 fun (Out ) ->
371388 {_ ,_ ,_ ,V } = maps :get (otp_version , S0 ),
372389 VersionTag = " OTP-" ++ binary_to_list (V )++ " \n " ,
0 commit comments