rpm: Bring RPM module back in to a working state

pull/4765/head
Alistair Thomas 6 years ago committed by Jussi Pakkanen
parent 913c87b327
commit b204a74917
  1. 104
      mesonbuild/modules/rpm.py

@ -29,39 +29,16 @@ import os
class RPMModule(ExtensionModule): class RPMModule(ExtensionModule):
@noKwargs @noKwargs
def generate_spec_template(self, state, args, kwargs): def generate_spec_template(self, coredata, args, kwargs):
compiler_deps = set() self.coredata = coredata
for compiler in state.compilers.values(): required_compilers = self.__get_required_compilers()
# Elbrus has one 'lcc' package for every compiler proj = coredata.project_name.replace(' ', '_').replace('\t', '_')
if isinstance(compiler, compilers.GnuCCompiler):
compiler_deps.add('gcc')
elif isinstance(compiler, compilers.GnuCPPCompiler):
compiler_deps.add('gcc-c++')
elif isinstance(compiler, compilers.ElbrusCCompiler):
compiler_deps.add('lcc')
elif isinstance(compiler, compilers.ElbrusCPPCompiler):
compiler_deps.add('lcc')
elif isinstance(compiler, compilers.ElbrusFortranCompiler):
compiler_deps.add('lcc')
elif isinstance(compiler, compilers.ValaCompiler):
compiler_deps.add('vala')
elif isinstance(compiler, compilers.GnuFortranCompiler):
compiler_deps.add('gcc-gfortran')
elif isinstance(compiler, compilers.GnuObjCCompiler):
compiler_deps.add('gcc-objc')
elif compiler == compilers.GnuObjCPPCompiler:
compiler_deps.add('gcc-objc++')
else:
mlog.log('RPM spec file will not created, generating not allowed for:',
mlog.bold(compiler.get_id()))
return
proj = state.project_name.replace(' ', '_').replace('\t', '_')
so_installed = False so_installed = False
devel_subpkg = False devel_subpkg = False
files = set() files = set()
files_devel = set() files_devel = set()
to_delete = set() to_delete = set()
for target in state.targets.values(): for target in coredata.targets.values():
if isinstance(target, build.Executable) and target.need_install: if isinstance(target, build.Executable) and target.need_install:
files.add('%%{_bindir}/%s' % target.get_filename()) files.add('%%{_bindir}/%s' % target.get_filename())
elif isinstance(target, build.SharedLibrary) and target.need_install: elif isinstance(target, build.SharedLibrary) and target.need_install:
@ -80,18 +57,19 @@ class RPMModule(ExtensionModule):
files_devel.add('%%{_datadir}/gir-1.0/%s' % target.get_filename()[0]) files_devel.add('%%{_datadir}/gir-1.0/%s' % target.get_filename()[0])
elif isinstance(target, TypelibTarget) and target.should_install(): elif isinstance(target, TypelibTarget) and target.should_install():
files.add('%%{_libdir}/girepository-1.0/%s' % target.get_filename()[0]) files.add('%%{_libdir}/girepository-1.0/%s' % target.get_filename()[0])
for header in state.headers: for header in coredata.headers:
if len(header.get_install_subdir()) > 0: if len(header.get_install_subdir()) > 0:
files_devel.add('%%{_includedir}/%s/' % header.get_install_subdir()) files_devel.add('%%{_includedir}/%s/' % header.get_install_subdir())
else: else:
for hdr_src in header.get_sources(): for hdr_src in header.get_sources():
files_devel.add('%%{_includedir}/%s' % hdr_src) files_devel.add('%%{_includedir}/%s' % hdr_src)
for man in state.man: for man in coredata.man:
for man_file in man.get_sources(): for man_file in man.get_sources():
files.add('%%{_mandir}/man%u/%s.*' % (int(man_file.split('.')[-1]), man_file)) files.add('%%{_mandir}/man%u/%s.*' % (int(man_file.split('.')[-1]), man_file))
if len(files_devel) > 0: if len(files_devel) > 0:
devel_subpkg = True devel_subpkg = True
filename = os.path.join(state.environment.get_build_dir(),
filename = os.path.join(coredata.environment.get_build_dir(),
'%s.spec' % proj) '%s.spec' % proj)
with open(filename, 'w+') as fn: with open(filename, 'w+') as fn:
fn.write('Name: %s\n' % proj) fn.write('Name: %s\n' % proj)
@ -102,24 +80,28 @@ class RPMModule(ExtensionModule):
fn.write('\n') fn.write('\n')
fn.write('Source0: %{name}-%{version}.tar.xz # FIXME\n') fn.write('Source0: %{name}-%{version}.tar.xz # FIXME\n')
fn.write('\n') fn.write('\n')
for compiler in compiler_deps: fn.write('BuildRequires: meson\n')
for compiler in required_compilers:
fn.write('BuildRequires: %s\n' % compiler) fn.write('BuildRequires: %s\n' % compiler)
for dep in state.environment.coredata.deps: for dep in coredata.environment.coredata.deps:
fn.write('BuildRequires: pkgconfig(%s)\n' % dep[0]) fn.write('BuildRequires: pkgconfig(%s)\n' % dep[0])
for lib in state.environment.coredata.ext_libs.values(): # ext_libs and ext_progs have been removed from coredata so the following code
name = lib.get_name() # no longer works. It is kept as a reminder of the idea should anyone wish
fn.write('BuildRequires: {} # FIXME\n'.format(name)) # to re-implement it.
mlog.warning('replace', mlog.bold(name), 'with the real package.', #
'You can use following command to find package which ' # for lib in state.environment.coredata.ext_libs.values():
'contains this lib:', # name = lib.get_name()
mlog.bold("dnf provides '*/lib{}.so'".format(name))) # fn.write('BuildRequires: {} # FIXME\n'.format(name))
for prog in state.environment.coredata.ext_progs.values(): # mlog.warning('replace', mlog.bold(name), 'with the real package.',
if not prog.found(): # 'You can use following command to find package which '
fn.write('BuildRequires: %%{_bindir}/%s # FIXME\n' % # 'contains this lib:',
prog.get_name()) # mlog.bold("dnf provides '*/lib{}.so'".format(name)))
else: # for prog in state.environment.coredata.ext_progs.values():
fn.write('BuildRequires: {}\n'.format(prog.get_path())) # if not prog.found():
fn.write('BuildRequires: meson\n') # fn.write('BuildRequires: %%{_bindir}/%s # FIXME\n' %
# prog.get_name())
# else:
# fn.write('BuildRequires: {}\n'.format(prog.get_path()))
fn.write('\n') fn.write('\n')
fn.write('%description\n') fn.write('%description\n')
fn.write('\n') fn.write('\n')
@ -167,5 +149,33 @@ class RPMModule(ExtensionModule):
mlog.log('RPM spec template written to %s.spec.\n' % proj) mlog.log('RPM spec template written to %s.spec.\n' % proj)
return ModuleReturnValue(None, []) return ModuleReturnValue(None, [])
def __get_required_compilers(self):
required_compilers = set()
for compiler in self.coredata.compilers.values():
# Elbrus has one 'lcc' package for every compiler
if isinstance(compiler, compilers.GnuCCompiler):
required_compilers.add('gcc')
elif isinstance(compiler, compilers.GnuCPPCompiler):
required_compilers.add('gcc-c++')
elif isinstance(compiler, compilers.ElbrusCCompiler):
required_compilers.add('lcc')
elif isinstance(compiler, compilers.ElbrusCPPCompiler):
required_compilers.add('lcc')
elif isinstance(compiler, compilers.ElbrusFortranCompiler):
required_compilers.add('lcc')
elif isinstance(compiler, compilers.ValaCompiler):
required_compilers.add('vala')
elif isinstance(compiler, compilers.GnuFortranCompiler):
required_compilers.add('gcc-gfortran')
elif isinstance(compiler, compilers.GnuObjCCompiler):
required_compilers.add('gcc-objc')
elif compiler == compilers.GnuObjCPPCompiler:
required_compilers.add('gcc-objc++')
else:
mlog.log('RPM spec file not created, generation not allowed for:',
mlog.bold(compiler.get_id()))
return required_compilers
def initialize(*args, **kwargs): def initialize(*args, **kwargs):
return RPMModule(*args, **kwargs) return RPMModule(*args, **kwargs)

Loading…
Cancel
Save