@@ -102,9 +102,9 @@ DEVBUILDS = "devbuilds"
102
102
PACKAGE_SOURCES = [DEFAULT , NIGHTLY , DEVBUILDS ]
103
103
104
104
PACKAGES_FROM = {
105
- DEFAULT : '' ,
106
- NIGHTLY : ' samba-nightly' ,
107
- DEVBUILDS : ' devbuilds' ,
105
+ DEFAULT : "" ,
106
+ NIGHTLY : " samba-nightly" ,
107
+ DEVBUILDS : " devbuilds" ,
108
108
}
109
109
110
110
# SOURCE_DIRS - image source paths
@@ -121,7 +121,7 @@ DEFAULT_DISTRO_BASES = [FEDORA]
121
121
LATEST = "latest"
122
122
QUAL_NONE = "unqualified"
123
123
QUAL_DISTRO = "distro-qualified"
124
- QUAL_FQIN = ' fqin'
124
+ QUAL_FQIN = " fqin"
125
125
126
126
127
127
_DISCOVERED_CONTAINER_ENGINES = []
@@ -207,45 +207,71 @@ def container_build(cli, target):
207
207
tasks = []
208
208
209
209
# For docker cross-builds we need to use buildx
210
- if "docker" in eng and target .arch != host_arch ():
210
+ if "docker" in eng and target .arch != host_arch ():
211
211
args = [eng , "buildx" ]
212
212
213
213
# Docker's default builder only supports the host architecture.
214
214
# Therefore, we need to create a new builder to support other
215
215
# architectures, and we must ensure we start with a fresh builder
216
216
# that does not contain any images from previous builds.
217
- tasks .append (lambda : run (cli , args + ["rm" , target .flat_name ()], check = False ))
218
- tasks .append (lambda : run (cli , args + ["create" , f"--name={ target .flat_name ()} " ], check = True ))
217
+ tasks .append (
218
+ lambda : run (cli , args + ["rm" , target .flat_name ()], check = False )
219
+ )
220
+ tasks .append (
221
+ lambda : run (
222
+ cli ,
223
+ args + ["create" , f"--name={ target .flat_name ()} " ],
224
+ check = True ,
225
+ )
226
+ )
219
227
220
- tasks .append (lambda : run (cli , args + [
221
- "build" ,
222
- f"--builder={ target .flat_name ()} " ,
223
- f"--platform=linux/{ target .arch } " ,
224
- "--load" ] + create_common_container_engine_args (cli , target ), check = True ))
228
+ tasks .append (
229
+ lambda : run (
230
+ cli ,
231
+ args
232
+ + [
233
+ "build" ,
234
+ f"--builder={ target .flat_name ()} " ,
235
+ f"--platform=linux/{ target .arch } " ,
236
+ "--load" ,
237
+ ]
238
+ + create_common_container_engine_args (cli , target ),
239
+ check = True ,
240
+ )
241
+ )
225
242
226
- tasks .append (lambda : run (cli , args + ["rm" , target .flat_name ()], check = True ))
243
+ tasks .append (
244
+ lambda : run (cli , args + ["rm" , target .flat_name ()], check = True )
245
+ )
227
246
else :
228
247
args = [eng , "build" ]
229
248
if target .arch != host_arch () or FORCE_ARCH_FLAG :
230
- # We've noticed a few small quirks when using podman with the --arch
231
- # option. The main issue is that building the client image works
232
- # but then the toolbox image fails because it somehow doesn't see
233
- # the image we just built as usable. This doesn't happen when
249
+ # We've noticed a few small quirks when using podman with the
250
+ # --arch option. The main issue is that building the client image
251
+ # works but then the toolbox image fails because it somehow doesn't
252
+ # see the image we just built as usable. This doesn't happen when
234
253
# --arch is not provided. So if the target arch and the host_arch
235
254
# are the same, skip passing the extra argument.
236
255
args += [f"--arch={ target .arch } " ]
237
256
238
- tasks .append (lambda : run (cli , args + create_common_container_engine_args (cli , target ), check = True ))
257
+ tasks .append (
258
+ lambda : run (
259
+ cli ,
260
+ args + create_common_container_engine_args (cli , target ),
261
+ check = True ,
262
+ )
263
+ )
239
264
240
265
for task in tasks :
241
266
task ()
242
267
268
+
243
269
def create_common_container_engine_args (cli , target ):
244
270
args = []
245
271
pkgs_from = PACKAGES_FROM [target .pkg_source ]
246
272
if pkgs_from :
247
273
args .append (f"--build-arg=INSTALL_PACKAGES_FROM={ pkgs_from } " )
248
-
274
+
249
275
if cli .extra_build_arg :
250
276
args .extend (cli .extra_build_arg )
251
277
@@ -258,6 +284,7 @@ def create_common_container_engine_args(cli, target):
258
284
args .append (kind_source_dir (target .name ))
259
285
return [str (a ) for a in args ]
260
286
287
+
261
288
def container_push (cli , push_name ):
262
289
"""Construct and execute a command to push a container image."""
263
290
args = [container_engine (cli ), "push" , push_name ]
@@ -306,7 +333,9 @@ def kind_source_dir(kind):
306
333
307
334
def target_containerfile (target ):
308
335
"""Return the path to a containerfile given an image target."""
309
- return str (kind_source_dir (target .name ) / f"Containerfile.{ target .distro } " )
336
+ return str (
337
+ kind_source_dir (target .name ) / f"Containerfile.{ target .distro } "
338
+ )
310
339
311
340
312
341
def host_arch ():
@@ -659,7 +688,7 @@ def main():
659
688
parser .add_argument (
660
689
"--push-selected-tags" ,
661
690
type = QMatcher ,
662
- help = QMatcher .__doc__
691
+ help = QMatcher .__doc__ ,
663
692
)
664
693
parser .add_argument (
665
694
"--buildfile-prefix" ,
@@ -724,8 +753,10 @@ def main():
724
753
action = "store_const" ,
725
754
dest = "main_action" ,
726
755
const = retag ,
727
- help = ("Regenerate any short (unqualified) tags expected to exist"
728
- " for a given FQIN. Requires FQIN to already exist locally." ),
756
+ help = (
757
+ "Regenerate any short (unqualified) tags expected to exist"
758
+ " for a given FQIN. Requires FQIN to already exist locally."
759
+ ),
729
760
)
730
761
cli = parser .parse_args ()
731
762
0 commit comments