@@ -56,6 +56,8 @@ def add_common_args(parser):
5656 'If both --enablerepo and --disablerepo are set, --disablerepo will be applied first' )
5757 group .add_argument ('--no-update' , action = 'store_true' ,
5858 help = 'do not run "yum update" on container start, use it as it was at build time' )
59+ group .add_argument ('--no-network' , action = 'store_true' ,
60+ help = 'disable all networking support in the build environment' )
5961
6062def add_container_args (parser ):
6163 group = parser .add_argument_group ("container arguments" )
@@ -196,6 +198,11 @@ def container(args):
196198 docker_args += ["-e" , "DISABLEREPO=%s" % args .disablerepo ]
197199 if args .no_update :
198200 docker_args += ["-e" , "NOUPDATE=1" ]
201+ if args .no_network :
202+ docker_args += ["--network" , "none" ]
203+
204+ if args .no_network and not args .no_update :
205+ print ("WARNING: network disabled but --no-update not passed" , file = sys .stderr )
199206
200207 # container args
201208 if args .volume :
@@ -228,6 +235,9 @@ def container(args):
228235 # action-specific
229236 match args .action :
230237 case 'build' :
238+ if args .no_network and not args .builddep_dir :
239+ print ("WARNING: network disabled but --builddep-dir not passed" , file = sys .stderr )
240+
231241 build_dir = os .path .abspath (args .source_dir )
232242 if args .define :
233243 docker_args += ["-e" , "RPMBUILD_DEFINE=%s" % args .define ]
0 commit comments