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