@@ -178,6 +178,15 @@ class RpmBuilder(object):
178178 RPMS_DIR = 'RPMS'
179179 DIRS = [SOURCE_DIR , BUILD_DIR , RPMS_DIR , TEMP_DIR ]
180180
181+ # `debuginfo` RPM types as defined in `toolchains/rpm/rpmbuild_configure.bzl`
182+ DEBUGINFO_TYPE_NONE = "none"
183+ DEBUGINFO_TYPE_CENTOS = "centos"
184+ DEBUGINFO_TYPE_FEDORA = "fedora"
185+ SUPPORTED_DEBUGINFO_TYPES = {
186+ DEBUGINFO_TYPE_CENTOS ,
187+ DEBUGINFO_TYPE_FEDORA ,
188+ }
189+
181190 def __init__ (self , name , version , release , arch , rpmbuild_path ,
182191 source_date_epoch = None ,
183192 debug = False ):
@@ -362,7 +371,7 @@ def CallRpmBuild(self, dirname, rpmbuild_args, debuginfo_type):
362371 if self .debug :
363372 args .append ('-vv' )
364373
365- if debuginfo_type == "fedora40" :
374+ if debuginfo_type == RpmBuilder . DEBUGINFO_TYPE_FEDORA :
366375 os .makedirs (f'{ dirname } /{ RpmBuilder .BUILD_DIR } /{ RpmBuilder .BUILD_SUBDIR } ' )
367376
368377 # Common options
@@ -375,13 +384,13 @@ def CallRpmBuild(self, dirname, rpmbuild_args, debuginfo_type):
375384 '--define' , '_builddir %s/BUILD' % dirname ,
376385 ]
377386
378- if debuginfo_type in [ "fedora40" , "centos7" , "centos9" , "almalinux9.3" ] :
387+ if debuginfo_type in RpmBuilder . SUPPORTED_DEBUGINFO_TYPES :
379388 args += ['--undefine' , '_debugsource_packages' ]
380389
381- if debuginfo_type in [ "centos7" , "centos9" , "almalinux9.3" ] :
390+ if debuginfo_type == RpmBuilder . DEBUGINFO_TYPE_CENTOS :
382391 args += ['--define' , 'buildsubdir .' ]
383392
384- if debuginfo_type == "fedora40" :
393+ if debuginfo_type == RpmBuilder . DEBUGINFO_TYPE_FEDORA :
385394 args += ['--define' , f'buildsubdir { RpmBuilder .BUILD_SUBDIR } ' ]
386395
387396 args += [
@@ -399,7 +408,7 @@ def CallRpmBuild(self, dirname, rpmbuild_args, debuginfo_type):
399408 if self .file_list_path :
400409 # %files -f is taken relative to the package root
401410 base_path = os .path .basename (self .file_list_path )
402- if debuginfo_type == "fedora40" :
411+ if debuginfo_type == RpmBuilder . DEBUGINFO_TYPE_FEDORA :
403412 base_path = os .path .join (".." , base_path )
404413
405414 args += ['--define' , 'build_rpm_files %s' % base_path ]
@@ -556,30 +565,31 @@ def main(argv):
556565 parser .add_argument ('--install_script' ,
557566 help = 'Installer script' )
558567 parser .add_argument ('--file_list' ,
559- help = 'File containing a list of files to include with rpm spec %files -f' )
568+ help = 'File containing a list of files to include with rpm spec %% files -f' )
560569 parser .add_argument ('--preamble' ,
561570 help = 'File containing the RPM Preamble' )
562571 parser .add_argument ('--description' ,
563- help = 'File containing the RPM %description text' )
572+ help = 'File containing the RPM %% description text' )
564573 parser .add_argument ('--subrpms' ,
565574 help = 'File containing the RPM subrpm details' )
566575 parser .add_argument ('--pre_scriptlet' ,
567- help = 'File containing the RPM %pre scriptlet, if to be substituted' )
576+ help = 'File containing the RPM %% pre scriptlet, if to be substituted' )
568577 parser .add_argument ('--post_scriptlet' ,
569- help = 'File containing the RPM %post scriptlet, if to be substituted' )
578+ help = 'File containing the RPM %% post scriptlet, if to be substituted' )
570579 parser .add_argument ('--preun_scriptlet' ,
571- help = 'File containing the RPM %preun scriptlet, if to be substituted' )
580+ help = 'File containing the RPM %% preun scriptlet, if to be substituted' )
572581 parser .add_argument ('--postun_scriptlet' ,
573- help = 'File containing the RPM %postun scriptlet, if to be substituted' )
582+ help = 'File containing the RPM %% postun scriptlet, if to be substituted' )
574583 parser .add_argument ('--posttrans_scriptlet' ,
575- help = 'File containing the RPM %posttrans scriptlet, if to be substituted' )
584+ help = 'File containing the RPM %% posttrans scriptlet, if to be substituted' )
576585 parser .add_argument ('--changelog' ,
577586 help = 'File containing the RPM changelog text' )
578587
579588 parser .add_argument ('--rpmbuild_arg' , dest = 'rpmbuild_args' , action = 'append' ,
580589 help = 'Any additional arguments to pass to rpmbuild' )
581- parser .add_argument ('--debuginfo_type' , dest = 'debuginfo_type' , default = 'none' ,
582- help = 'debuginfo type to use (centos7, fedora40, or none)' )
590+ parser .add_argument ('--debuginfo_type' , default = RpmBuilder .DEBUGINFO_TYPE_NONE ,
591+ choices = sorted (RpmBuilder .SUPPORTED_DEBUGINFO_TYPES ) + [RpmBuilder .DEBUGINFO_TYPE_NONE ],
592+ help = 'debuginfo type to use' )
583593 parser .add_argument ('files' , nargs = '*' )
584594
585595 options = parser .parse_args (argv or ())
0 commit comments