@@ -78,25 +78,20 @@ fn ruby_build(args: &RubyArgs) -> Result<(), Box<dyn std::error::Error>> {
7878 let dockerfile = ruby_dockerfile_contents ( base_image) ;
7979 let dockerfile_path = temp_dir. path ( ) . join ( "Dockerfile" ) ;
8080
81- _ = {
82- print:: bullet ( "Dockerfile" ) ;
83- print:: sub_stream_with ( "Writing contents to tmpdir" , |mut stream, _| {
84- write ! ( stream, "{dockerfile}" )
85- . and_then ( |_| fs_err:: write ( & dockerfile_path, & dockerfile) )
86- } ) ?;
87- } ;
88-
89- _ = {
90- print:: bullet ( format ! ( "Docker image {image_name}" ) ) ;
91- let mut docker_build = Command :: new ( "docker" ) ;
92- docker_build. arg ( "build" ) ;
93- docker_build. args ( [ "--platform" , & format ! ( "linux/{arch}" ) ] ) ;
94- docker_build. args ( [ "--progress" , "plain" ] ) ;
95- docker_build. args ( [ "--tag" , & image_name] ) ;
96- docker_build. args ( [ "--file" , & dockerfile_path. display ( ) . to_string ( ) ] ) ;
97- docker_build. arg ( source_dir ( ) ) ;
98- print:: sub_stream_cmd ( docker_build) ?;
99- } ;
81+ print:: bullet ( "Dockerfile" ) ;
82+ print:: sub_stream_with ( "Writing contents to tmpdir" , |mut stream, _| {
83+ write ! ( stream, "{dockerfile}" ) . and_then ( |_| fs_err:: write ( & dockerfile_path, & dockerfile) )
84+ } ) ?;
85+
86+ print:: bullet ( format ! ( "Docker image {image_name}" ) ) ;
87+ let mut docker_build = Command :: new ( "docker" ) ;
88+ docker_build. arg ( "build" ) ;
89+ docker_build. args ( [ "--platform" , & format ! ( "linux/{arch}" ) ] ) ;
90+ docker_build. args ( [ "--progress" , "plain" ] ) ;
91+ docker_build. args ( [ "--tag" , & image_name] ) ;
92+ docker_build. args ( [ "--file" , & dockerfile_path. display ( ) . to_string ( ) ] ) ;
93+ docker_build. arg ( source_dir ( ) ) ;
94+ print:: sub_stream_cmd ( docker_build) ?;
10095
10196 let download_tar_path =
10297 TarDownloadPath ( volume_cache_dir. join ( format ! ( "ruby-source-{version}.tgz" ) ) ) ;
@@ -114,85 +109,81 @@ fn ruby_build(args: &RubyArgs) -> Result<(), Box<dyn std::error::Error>> {
114109 download_tar ( & version. download_url ( ) , & download_tar_path) ?;
115110 } ;
116111
117- _ = {
118- print:: bullet ( "Make Ruby" ) ;
119- let input_tar = PathBuf :: from ( INNER_CACHE ) . join ( format ! ( "ruby-source-{version}.tgz" ) ) ;
120- let output_tar = output_tar_path ( Path :: new ( INNER_OUTPUT ) , version, base_image, arch) ;
121- let volume_cache = volume_cache_dir. display ( ) ;
122- let volume_output = volume_output_dir. display ( ) ;
123-
124- let mut docker_run = Command :: new ( "docker" ) ;
125- docker_run. arg ( "run" ) ;
126- docker_run. arg ( "--rm" ) ;
127- docker_run. args ( [ "--platform" , & format ! ( "linux/{arch}" ) ] ) ;
128- docker_run. args ( [ "--volume" , & format ! ( "{volume_output}:{INNER_OUTPUT}" ) ] ) ;
129- docker_run. args ( [ "--volume" , & format ! ( "{volume_cache}:{INNER_CACHE}" ) ] ) ;
130-
131- docker_run. arg ( & image_name) ;
132- docker_run. args ( [ "bash" , "-c" ] ) ;
133- docker_run. arg ( format ! (
134- "./make_ruby.sh {} {}" ,
135- input_tar. display( ) ,
136- output_tar. display( )
137- ) ) ;
138-
139- print:: sub_stream_cmd ( docker_run) ?;
112+ print:: bullet ( "Make Ruby" ) ;
113+ let input_tar = PathBuf :: from ( INNER_CACHE ) . join ( format ! ( "ruby-source-{version}.tgz" ) ) ;
114+ let output_tar = output_tar_path ( Path :: new ( INNER_OUTPUT ) , version, base_image, arch) ;
115+ let volume_cache = volume_cache_dir. display ( ) ;
116+ let volume_output = volume_output_dir. display ( ) ;
117+
118+ let mut docker_run = Command :: new ( "docker" ) ;
119+ docker_run. arg ( "run" ) ;
120+ docker_run. arg ( "--rm" ) ;
121+ docker_run. args ( [ "--platform" , & format ! ( "linux/{arch}" ) ] ) ;
122+ docker_run. args ( [ "--volume" , & format ! ( "{volume_output}:{INNER_OUTPUT}" ) ] ) ;
123+ docker_run. args ( [ "--volume" , & format ! ( "{volume_cache}:{INNER_CACHE}" ) ] ) ;
124+
125+ docker_run. arg ( & image_name) ;
126+ docker_run. args ( [ "bash" , "-c" ] ) ;
127+ docker_run. arg ( format ! (
128+ "./make_ruby.sh {} {}" ,
129+ input_tar. display( ) ,
130+ output_tar. display( )
131+ ) ) ;
132+
133+ print:: sub_stream_cmd ( docker_run) ?;
134+
135+ print:: bullet ( format ! (
136+ "Updating manifest {}" ,
137+ style:: value( inventory. to_string_lossy( ) )
138+ ) ) ;
139+
140+ let output_tar = output_tar_path ( & volume_output_dir, version, base_image, arch) ;
141+
142+ let sha = sha256_from_path ( & output_tar) ?;
143+ let sha_seven = sha. chars ( ) . take ( 7 ) . collect :: < String > ( ) ;
144+ let sha_seven_path = append_filename_with ( & output_tar, & format ! ( "-{sha_seven}" ) , ".tgz" ) ?;
145+ let url = format ! (
146+ "{S3_BASE_URL}/{}" ,
147+ sha_seven_path. strip_prefix( & volume_output_dir) ?. display( )
148+ ) ;
149+
150+ print:: sub_bullet ( format ! ( "Copying SHA tgz {}" , sha_seven_path. display( ) , ) ) ;
151+ fs_err:: copy ( output_tar, & sha_seven_path) ?;
152+
153+ let artifact = Artifact {
154+ version : GemVersion :: from_str ( & version. bundler_format ( ) ) ?,
155+ os : inventory:: artifact:: Os :: Linux ,
156+ arch : * arch,
157+ url,
158+ checksum : format ! ( "sha256:{sha}" ) . parse ( ) ?,
159+ metadata : ArtifactMetadata {
160+ distro_version : base_image. distro_version ( ) ,
161+ timestamp : chrono:: Utc :: now ( ) ,
162+ } ,
140163 } ;
141164
142- _ = {
143- print:: bullet ( format ! (
144- "Updating manifest {}" ,
145- style:: value( inventory. to_string_lossy( ) )
146- ) ) ;
165+ atomic_inventory_update ( & inventory, |inventory| {
166+ for prior in & inventory. artifacts {
167+ if let Err ( error) = artifact_same_url_different_checksum ( prior, & artifact) {
168+ // TODO: Investigate bullet stream ownership
169+ println ! (
170+ "{}" ,
171+ style:: important( format!( "!!!!!!!!!! Error updating inventory: {error}" ) )
172+ ) ;
147173
148- let output_tar = output_tar_path ( & volume_output_dir, version, base_image, arch) ;
149-
150- let sha = sha256_from_path ( & output_tar) ?;
151- let sha_seven = sha. chars ( ) . take ( 7 ) . collect :: < String > ( ) ;
152- let sha_seven_path = append_filename_with ( & output_tar, & format ! ( "-{sha_seven}" ) , ".tgz" ) ?;
153- let url = format ! (
154- "{S3_BASE_URL}/{}" ,
155- sha_seven_path. strip_prefix( & volume_output_dir) ?. display( )
156- ) ;
157-
158- print:: sub_bullet ( format ! ( "Copying SHA tgz {}" , sha_seven_path. display( ) , ) ) ;
159- fs_err:: copy ( output_tar, & sha_seven_path) ?;
160-
161- let artifact = Artifact {
162- version : GemVersion :: from_str ( & version. bundler_format ( ) ) ?,
163- os : inventory:: artifact:: Os :: Linux ,
164- arch : * arch,
165- url,
166- checksum : format ! ( "sha256:{sha}" ) . parse ( ) ?,
167- metadata : ArtifactMetadata {
168- distro_version : base_image. distro_version ( ) ,
169- timestamp : chrono:: Utc :: now ( ) ,
170- } ,
171- } ;
172-
173- atomic_inventory_update ( & inventory, |inventory| {
174- for prior in & inventory. artifacts {
175- if let Err ( error) = artifact_same_url_different_checksum ( prior, & artifact) {
176- // TODO: Investigate bullet stream ownership
177- println ! (
178- "{}" ,
179- style:: important( format!( "!!!!!!!!!! Error updating inventory: {error}" ) )
180- ) ;
181-
182- fs_err:: remove_file ( & sha_seven_path) ?;
183- return Err ( error) ;
184- } ;
185- }
186-
187- inventory
188- . artifacts
189- . retain ( |a| artifact_is_different ( a, & artifact) ) ;
190-
191- inventory. push ( artifact) ;
192-
193- Ok ( ( ) )
194- } ) ?;
195- } ;
174+ fs_err:: remove_file ( & sha_seven_path) ?;
175+ return Err ( error) ;
176+ } ;
177+ }
178+
179+ inventory
180+ . artifacts
181+ . retain ( |a| artifact_is_different ( a, & artifact) ) ;
182+
183+ inventory. push ( artifact) ;
184+
185+ Ok ( ( ) )
186+ } ) ?;
196187
197188 print:: all_done ( & Some ( start) ) ;
198189
0 commit comments