@@ -58,6 +58,8 @@ def add_common_args(parser):
5858 help = "Directory where the build-dependency RPMs will be taken from." )
5959 group .add_argument ('--no-update' , action = 'store_true' ,
6060 help = 'do not run "yum update" on container start, use it as it was at build time' )
61+ group .add_argument ('--no-network' , action = 'store_true' ,
62+ help = 'disable all networking support in the build environment' )
6163
6264def add_container_args (parser ):
6365 group = parser .add_argument_group ("container arguments" )
@@ -213,6 +215,11 @@ def container(args):
213215 docker_args += ["-e" , "DISABLEREPO=%s" % args .disablerepo ]
214216 if args .no_update :
215217 docker_args += ["-e" , "NOUPDATE=1" ]
218+ if args .no_network :
219+ docker_args += ["--network" , "none" ]
220+
221+ if args .no_network and not args .no_update :
222+ print ("WARNING: network disabled but --no-update not passed" , file = sys .stderr )
216223
217224 # container args
218225 if args .volume :
@@ -249,6 +256,9 @@ def container(args):
249256 # action-specific
250257 match args .action :
251258 case 'build' :
259+ if args .no_network and not args .local_repo :
260+ print ("WARNING: network disabled but --local-repo not passed" , file = sys .stderr )
261+
252262 build_dir = os .path .abspath (args .source_dir )
253263 if args .define :
254264 docker_args += ["-e" , "RPMBUILD_DEFINE=%s" % args .define ]
0 commit comments