def main()

in pkg/make_rpm.py [0:0]


def main(argv):
  parser = argparse.ArgumentParser(
      description='Helper for building rpm packages',
      fromfile_prefix_chars='@')

  parser.add_argument('--name',
                      help='The name of the software being packaged.')
  parser.add_argument('--version',
                      help='The version of the software being packaged.')
  parser.add_argument('--release',
                      help='The release of the software being packaged.')
  parser.add_argument(
      '--arch',
      help='The CPU architecture of the software being packaged.')
  parser.add_argument('--spec_file', required=True,
                      help='The file containing the RPM specification.')
  parser.add_argument('--out_file', required=True,
                      help='The destination to save the resulting RPM file to.')
  parser.add_argument('--rpmbuild', help='Path to rpmbuild executable.')
  parser.add_argument('--source_date_epoch',
                      help='Value for the SOURCE_DATE_EPOCH rpmbuild '
                           'environment variable')
  parser.add_argument('--debug', action='store_true', default=False,
                      help='Print debug messages.')

  # Options currently used experimental/rpm.bzl:
  parser.add_argument('--install_script',
                      help='Installer script')
  parser.add_argument('--file_list',
                      help='File containing a list of files to include with rpm spec %files -f')
  parser.add_argument('--preamble',
                      help='File containing the RPM Preamble')
  parser.add_argument('--description',
                      help='File containing the RPM %description text')
  parser.add_argument('--pre_scriptlet',
                      help='File containing the RPM %pre scriptlet, if to be substituted')
  parser.add_argument('--post_scriptlet',
                      help='File containing the RPM %post scriptlet, if to be substituted')
  parser.add_argument('--preun_scriptlet',
                      help='File containing the RPM %preun scriptlet, if to be substituted')
  parser.add_argument('--postun_scriptlet',
                      help='File containing the RPM %postun scriptlet, if to be substituted')

  parser.add_argument('--rpmbuild_arg', dest='rpmbuild_args', action='append',
                      help='Any additional arguments to pass to rpmbuild')
  parser.add_argument('files', nargs='*')

  options = parser.parse_args(argv or ())

  try:
    builder = RpmBuilder(options.name,
                         options.version, options.release,
                         options.arch, options.rpmbuild,
                         source_date_epoch=options.source_date_epoch,
                         debug=options.debug)
    builder.AddFiles(options.files)
    return builder.Build(options.spec_file, options.out_file,
                         preamble_file=options.preamble,
                         description_file=options.description,
                         install_script_file=options.install_script,
                         file_list_path=options.file_list,
                         pre_scriptlet_path=options.pre_scriptlet,
                         post_scriptlet_path=options.post_scriptlet,
                         preun_scriptlet_path=options.preun_scriptlet,
                         postun_scriptlet_path=options.postun_scriptlet,
                         rpmbuild_args=options.rpmbuild_args)
  except NoRpmbuildFoundError:
    print('ERROR: rpmbuild is required but is not present in PATH')
    return 1