@@ -120,6 +120,22 @@ def buildparser():
120120 add_container_args (parser_build )
121121 add_common_args (parser_build )
122122
123+ # builddep -- fetch/cache builddep of an rpm using a container
124+ parser_builddep = subparsers_container .add_parser (
125+ 'builddep' ,
126+ help = "Fetch dependencies for the spec file(s) found in the SPECS/ subdirectory "
127+ "of the directory passed as parameter." )
128+ parser_builddep .add_argument (
129+ 'source_dir' , nargs = '?' , default = '.' ,
130+ help = "Root path where SPECS/ and SOURCES are available. "
131+ "The default is the working directory" )
132+ add_container_args (parser_builddep )
133+ add_common_args (parser_builddep )
134+ parser_builddep .add_argument (
135+ 'builddep_dir' ,
136+ help = "Directory where the build-dependency RPMs will be cached. "
137+ "The directory is created if it doesn't exist" )
138+
123139 # run -- execute commands inside a container
124140 parser_run = subparsers_container .add_parser (
125141 'run' ,
@@ -156,11 +172,18 @@ def container(args):
156172
157173 if hasattr (args , 'command' ) and args .command != []:
158174 docker_args += ["-e" , "COMMAND=%s" % ' ' .join (args .command )]
159- if args .action == 'build' :
175+ if args .action in ( 'build' , 'builddep' ) :
160176 build_dir = os .path .abspath (args .source_dir )
161- docker_args += ["-v" , f"{ build_dir } :/home/builder/rpmbuild" ]
162- docker_args += ["-e" , "BUILD_LOCAL=1" ]
163177 print (f"Building directory { build_dir } " , file = sys .stderr )
178+ docker_args += ["-v" , f"{ build_dir } :/home/builder/rpmbuild" ]
179+ match args .action :
180+ case 'build' :
181+ docker_args += ["-e" , "BUILD_LOCAL=1" ]
182+ case 'builddep' :
183+ docker_args += ["-e" , "BUILD_DEPS=1" ]
184+ case _:
185+ print (f"unhandled action { args .action } " , file = sys .stderr )
186+ sys .exit (1 )
164187 if hasattr (args , 'define' ) and args .define :
165188 docker_args += ["-e" , "RPMBUILD_DEFINE=%s" % args .define ]
166189 if hasattr (args , 'rpmbuild_opts' ) and args .rpmbuild_opts :
@@ -174,6 +197,10 @@ def container(args):
174197 os .makedirs (args .output_dir , exist_ok = True )
175198 docker_args += ["-v" , "%s:/home/builder/output" %
176199 os .path .abspath (args .output_dir )]
200+ if hasattr (args , 'builddep_dir' ) and args .builddep_dir :
201+ os .makedirs (args .builddep_dir , exist_ok = True )
202+ docker_args += ["-v" , "%s:/home/builder/builddep" %
203+ os .path .abspath (args .builddep_dir )]
177204 if args .no_exit :
178205 docker_args += ["-e" , "NO_EXIT=1" ]
179206 if args .fail_on_error :
0 commit comments