rpm: couple of improvements and fixes

* Don't hardcode /usr/bin, use %{_bindir}
* Implement %meson_build / %meson_install / %meson_test
* Automatic handling of out-of-tree builds

Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
pull/875/head
Igor Gnatenko 8 years ago
parent 6c50253645
commit 0d58ddd739
  1. 48
      data/macros.meson
  2. 22
      mesonbuild/modules/rpm.py

@ -1,21 +1,29 @@
%__meson /usr/bin/meson %__meson %{_bindir}/meson
%__sourcedir .
%__builddir %{_target_platform}
%__meson_ninja_opts -v %{?_smp_mflags} -C %{__builddir}
%meson() %{expand:\ %meson \
export CFLAGS="%{optflags}" ; \ export CFLAGS="%{optflags}" \
export CXXFLAGS="%{optflags}" ; \ export CXXFLAGS="%{optflags}" \
export FFLAGS="%{optflags} -I%{_fmoddir}" ; \ export FFLAGS="%{optflags} -I%{_fmoddir}" \
export FCFLAGS="%{optflags} -I%{_fmoddir}" ; \ export FCFLAGS="%{optflags} -I%{_fmoddir}" \
export LDFLAGS="%{__global_ldflags}" ; \ export LDFLAGS="%{?__global_ldflags}" \
%__meson %{?1} \\\ mkdir -p %{__builddir} \
--prefix=%{_prefix} \\\ pushd %{__builddir} \
--libdir=%{_libdir} \\\ %{__meson} \\\
--libexecdir=%{_libexecdir} \\\ --buildtype=plain \\\
--bindir=%{_bindir} \\\ --prefix=%{_prefix} \\\
--includedir=%{_includedir} \\\ --libdir=%{_libdir} \\\
--datadir=%{_datadir} \\\ --libexecdir=%{_libexecdir} \\\
--mandir=%{_mandir} \\\ --bindir=%{_bindir} \\\
--localedir=%{_datadir}/locale \\\ --includedir=%{_includedir} \\\
--sysconfdir=%{_sysconfdir} \\\ --datadir=%{_datadir} \\\
--buildtype=plain \ --mandir=%{_mandir} \\\
%{nil} \ --localedir=%{_datadir}/locale \\\
} --sysconfdir=%{_sysconfdir} \\\
$OLDPWD/%{__sourcedir} \
popd
%meson_build %ninja_build -C %{__builddir}
%meson_install %ninja_install -C %{__builddir}
%meson_test %ninja_test -C %{__builddir}

@ -104,7 +104,7 @@ class RPMModule:
mlog.bold('dnf provides %s' % lib.fullpath)) mlog.bold('dnf provides %s' % lib.fullpath))
for prog in state.environment.coredata.ext_progs.values(): for prog in state.environment.coredata.ext_progs.values():
if not prog.found(): if not prog.found():
fn.write('BuildRequires: /usr/bin/%s # FIXME\n' % fn.write('BuildRequires: %{_bindir}/%s # FIXME\n' %
prog.get_name()) prog.get_name())
else: else:
fn.write('BuildRequires: %s\n' % ' '.join(prog.fullpath)) fn.write('BuildRequires: %s\n' % ' '.join(prog.fullpath))
@ -115,32 +115,25 @@ class RPMModule:
if devel_subpkg: if devel_subpkg:
fn.write('%package devel\n') fn.write('%package devel\n')
fn.write('Summary: Development files for %{name}\n') fn.write('Summary: Development files for %{name}\n')
fn.write('Requires: %{name}%{?_isa} = %{version}-%{release}\n') fn.write('Requires: %{name}%{?_isa} = %{?epoch:%{epoch}:}{version}-%{release}\n')
fn.write('\n') fn.write('\n')
fn.write('%description devel\n') fn.write('%description devel\n')
fn.write('Development files for %{name}.\n') fn.write('Development files for %{name}.\n')
fn.write('\n') fn.write('\n')
fn.write('%prep\n') fn.write('%prep\n')
fn.write('%autosetup\n') fn.write('%autosetup\n')
fn.write('rm -rf rpmbuilddir && mkdir rpmbuilddir\n')
fn.write('\n') fn.write('\n')
fn.write('%build\n') fn.write('%build\n')
fn.write('pushd rpmbuilddir\n') fn.write('%meson\n')
fn.write(' %meson ..\n') fn.write('%meson_build\n')
fn.write(' ninja-build -v\n')
fn.write('popd\n')
fn.write('\n') fn.write('\n')
fn.write('%install\n') fn.write('%install\n')
fn.write('pushd rpmbuilddir\n') fn.write('%meson_install\n')
fn.write(' DESTDIR=%{buildroot} ninja-build -v install\n')
fn.write('popd\n')
if len(to_delete) > 0: if len(to_delete) > 0:
fn.write('rm -rf %s\n' % ' '.join(to_delete)) fn.write('rm -vf %s\n' % ' '.join(to_delete))
fn.write('\n') fn.write('\n')
fn.write('%check\n') fn.write('%check\n')
fn.write('pushd rpmbuilddir\n') fn.write('%meson_test\n')
fn.write(' ninja-build -v test\n')
fn.write('popd\n')
fn.write('\n') fn.write('\n')
fn.write('%files\n') fn.write('%files\n')
for f in files: for f in files:
@ -153,7 +146,6 @@ class RPMModule:
fn.write('\n') fn.write('\n')
if so_installed: if so_installed:
fn.write('%post -p /sbin/ldconfig\n') fn.write('%post -p /sbin/ldconfig\n')
fn.write('\n')
fn.write('%postun -p /sbin/ldconfig\n') fn.write('%postun -p /sbin/ldconfig\n')
fn.write('\n') fn.write('\n')
fn.write('%changelog\n') fn.write('%changelog\n')

Loading…
Cancel
Save