From 0d58ddd739c1d7f8c0e6e49b721dd3df965167c0 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sat, 8 Oct 2016 16:54:03 +0200 Subject: [PATCH 1/3] 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 --- data/macros.meson | 48 +++++++++++++++++++++++---------------- mesonbuild/modules/rpm.py | 22 ++++++------------ 2 files changed, 35 insertions(+), 35 deletions(-) diff --git a/data/macros.meson b/data/macros.meson index c89854bb2..05ff484d9 100644 --- a/data/macros.meson +++ b/data/macros.meson @@ -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:\ - export CFLAGS="%{optflags}" ; \ - export CXXFLAGS="%{optflags}" ; \ - export FFLAGS="%{optflags} -I%{_fmoddir}" ; \ - export FCFLAGS="%{optflags} -I%{_fmoddir}" ; \ - export LDFLAGS="%{__global_ldflags}" ; \ - %__meson %{?1} \\\ - --prefix=%{_prefix} \\\ - --libdir=%{_libdir} \\\ - --libexecdir=%{_libexecdir} \\\ - --bindir=%{_bindir} \\\ - --includedir=%{_includedir} \\\ - --datadir=%{_datadir} \\\ - --mandir=%{_mandir} \\\ - --localedir=%{_datadir}/locale \\\ - --sysconfdir=%{_sysconfdir} \\\ - --buildtype=plain \ - %{nil} \ -} +%meson \ + export CFLAGS="%{optflags}" \ + export CXXFLAGS="%{optflags}" \ + export FFLAGS="%{optflags} -I%{_fmoddir}" \ + export FCFLAGS="%{optflags} -I%{_fmoddir}" \ + export LDFLAGS="%{?__global_ldflags}" \ + mkdir -p %{__builddir} \ + pushd %{__builddir} \ + %{__meson} \\\ + --buildtype=plain \\\ + --prefix=%{_prefix} \\\ + --libdir=%{_libdir} \\\ + --libexecdir=%{_libexecdir} \\\ + --bindir=%{_bindir} \\\ + --includedir=%{_includedir} \\\ + --datadir=%{_datadir} \\\ + --mandir=%{_mandir} \\\ + --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} diff --git a/mesonbuild/modules/rpm.py b/mesonbuild/modules/rpm.py index 89194e95f..13aa20bf2 100644 --- a/mesonbuild/modules/rpm.py +++ b/mesonbuild/modules/rpm.py @@ -104,7 +104,7 @@ class RPMModule: mlog.bold('dnf provides %s' % lib.fullpath)) for prog in state.environment.coredata.ext_progs.values(): if not prog.found(): - fn.write('BuildRequires: /usr/bin/%s # FIXME\n' % + fn.write('BuildRequires: %{_bindir}/%s # FIXME\n' % prog.get_name()) else: fn.write('BuildRequires: %s\n' % ' '.join(prog.fullpath)) @@ -115,32 +115,25 @@ class RPMModule: if devel_subpkg: fn.write('%package devel\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('%description devel\n') fn.write('Development files for %{name}.\n') fn.write('\n') fn.write('%prep\n') fn.write('%autosetup\n') - fn.write('rm -rf rpmbuilddir && mkdir rpmbuilddir\n') fn.write('\n') fn.write('%build\n') - fn.write('pushd rpmbuilddir\n') - fn.write(' %meson ..\n') - fn.write(' ninja-build -v\n') - fn.write('popd\n') + fn.write('%meson\n') + fn.write('%meson_build\n') fn.write('\n') fn.write('%install\n') - fn.write('pushd rpmbuilddir\n') - fn.write(' DESTDIR=%{buildroot} ninja-build -v install\n') - fn.write('popd\n') + fn.write('%meson_install\n') 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('%check\n') - fn.write('pushd rpmbuilddir\n') - fn.write(' ninja-build -v test\n') - fn.write('popd\n') + fn.write('%meson_test\n') fn.write('\n') fn.write('%files\n') for f in files: @@ -153,7 +146,6 @@ class RPMModule: fn.write('\n') if so_installed: fn.write('%post -p /sbin/ldconfig\n') - fn.write('\n') fn.write('%postun -p /sbin/ldconfig\n') fn.write('\n') fn.write('%changelog\n') From b0fc370e727a9ad46516d13dac442c42801884b1 Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sat, 8 Oct 2016 17:13:37 +0200 Subject: [PATCH 2/3] fixup! rpm: couple of improvements and fixes --- data/macros.meson | 1 - 1 file changed, 1 deletion(-) diff --git a/data/macros.meson b/data/macros.meson index 05ff484d9..dd0e60c3a 100644 --- a/data/macros.meson +++ b/data/macros.meson @@ -1,7 +1,6 @@ %__meson %{_bindir}/meson %__sourcedir . %__builddir %{_target_platform} -%__meson_ninja_opts -v %{?_smp_mflags} -C %{__builddir} %meson \ export CFLAGS="%{optflags}" \ From 1e640955b6f7730e365f50d810e7031511b0473b Mon Sep 17 00:00:00 2001 From: Igor Gnatenko Date: Sat, 8 Oct 2016 17:15:02 +0200 Subject: [PATCH 3/3] fixup! fixup! rpm: couple of improvements and fixes --- data/macros.meson | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/data/macros.meson b/data/macros.meson index dd0e60c3a..4b91c70d3 100644 --- a/data/macros.meson +++ b/data/macros.meson @@ -23,6 +23,12 @@ --sysconfdir=%{_sysconfdir} \\\ $OLDPWD/%{__sourcedir} \ popd -%meson_build %ninja_build -C %{__builddir} -%meson_install %ninja_install -C %{__builddir} -%meson_test %ninja_test -C %{__builddir} + +%meson_build \ + %ninja_build -C %{__builddir} + +%meson_install \ + %ninja_install -C %{__builddir} + +%meson_test \ + %ninja_test -C %{__builddir}