Blame 0004-rpm-couple-of-improvements-and-fixes.patch

Igor Gnatenko 511817
From 12501846ca7f5ce3b33bb9f58839d392952e8c78 Mon Sep 17 00:00:00 2001
Igor Gnatenko 57d01a
From: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Igor Gnatenko 57d01a
Date: Sat, 8 Oct 2016 16:54:03 +0200
Igor Gnatenko 511817
Subject: [PATCH 04/10] rpm: couple of improvements and fixes
Igor Gnatenko 57d01a
Igor Gnatenko 57d01a
* Don't hardcode /usr/bin, use %{_bindir}
Igor Gnatenko 57d01a
* Implement %meson_build / %meson_install / %meson_test
Igor Gnatenko 57d01a
* Automatic handling of out-of-tree builds
Igor Gnatenko 57d01a
Igor Gnatenko 57d01a
Signed-off-by: Igor Gnatenko <i.gnatenko.brain@gmail.com>
Igor Gnatenko 57d01a
(cherry picked from commit 0d58ddd739c1d7f8c0e6e49b721dd3df965167c0)
Igor Gnatenko 57d01a
---
Igor Gnatenko 57d01a
 data/macros.meson         | 48 +++++++++++++++++++++++++++--------------------
Igor Gnatenko 57d01a
 mesonbuild/modules/rpm.py | 22 +++++++---------------
Igor Gnatenko 57d01a
 2 files changed, 35 insertions(+), 35 deletions(-)
Igor Gnatenko 57d01a
Igor Gnatenko 57d01a
diff --git a/data/macros.meson b/data/macros.meson
Igor Gnatenko 57d01a
index c89854b..05ff484 100644
Igor Gnatenko 57d01a
--- a/data/macros.meson
Igor Gnatenko 57d01a
+++ b/data/macros.meson
Igor Gnatenko 57d01a
@@ -1,21 +1,29 @@
Igor Gnatenko 57d01a
-%__meson /usr/bin/meson
Igor Gnatenko 57d01a
+%__meson %{_bindir}/meson
Igor Gnatenko 57d01a
+%__sourcedir .
Igor Gnatenko 57d01a
+%__builddir %{_target_platform}
Igor Gnatenko 57d01a
+%__meson_ninja_opts -v %{?_smp_mflags} -C %{__builddir}
Igor Gnatenko 57d01a
 
Igor Gnatenko 57d01a
-%meson() %{expand:\
Igor Gnatenko 57d01a
-  export CFLAGS="%{optflags}" ; \
Igor Gnatenko 57d01a
-  export CXXFLAGS="%{optflags}" ; \
Igor Gnatenko 57d01a
-  export FFLAGS="%{optflags} -I%{_fmoddir}" ; \
Igor Gnatenko 57d01a
-  export FCFLAGS="%{optflags} -I%{_fmoddir}" ; \
Igor Gnatenko 57d01a
-  export LDFLAGS="%{__global_ldflags}" ; \
Igor Gnatenko 57d01a
-  %__meson %{?1} \\\
Igor Gnatenko 57d01a
-        --prefix=%{_prefix}            \\\
Igor Gnatenko 57d01a
-        --libdir=%{_libdir}            \\\
Igor Gnatenko 57d01a
-        --libexecdir=%{_libexecdir}    \\\
Igor Gnatenko 57d01a
-        --bindir=%{_bindir}            \\\
Igor Gnatenko 57d01a
-        --includedir=%{_includedir}    \\\
Igor Gnatenko 57d01a
-        --datadir=%{_datadir}          \\\
Igor Gnatenko 57d01a
-        --mandir=%{_mandir}            \\\
Igor Gnatenko 57d01a
-        --localedir=%{_datadir}/locale \\\
Igor Gnatenko 57d01a
-        --sysconfdir=%{_sysconfdir}    \\\
Igor Gnatenko 57d01a
-        --buildtype=plain \
Igor Gnatenko 57d01a
-        %{nil} \
Igor Gnatenko 57d01a
-}
Igor Gnatenko 57d01a
+%meson \
Igor Gnatenko 57d01a
+    export CFLAGS="%{optflags}"                \
Igor Gnatenko 57d01a
+    export CXXFLAGS="%{optflags}"              \
Igor Gnatenko 57d01a
+    export FFLAGS="%{optflags} -I%{_fmoddir}"  \
Igor Gnatenko 57d01a
+    export FCFLAGS="%{optflags} -I%{_fmoddir}" \
Igor Gnatenko 57d01a
+    export LDFLAGS="%{?__global_ldflags}"      \
Igor Gnatenko 57d01a
+    mkdir -p %{__builddir}                     \
Igor Gnatenko 57d01a
+    pushd %{__builddir}                        \
Igor Gnatenko 57d01a
+        %{__meson}                         \\\
Igor Gnatenko 57d01a
+            --buildtype=plain              \\\
Igor Gnatenko 57d01a
+            --prefix=%{_prefix}            \\\
Igor Gnatenko 57d01a
+            --libdir=%{_libdir}            \\\
Igor Gnatenko 57d01a
+            --libexecdir=%{_libexecdir}    \\\
Igor Gnatenko 57d01a
+            --bindir=%{_bindir}            \\\
Igor Gnatenko 57d01a
+            --includedir=%{_includedir}    \\\
Igor Gnatenko 57d01a
+            --datadir=%{_datadir}          \\\
Igor Gnatenko 57d01a
+            --mandir=%{_mandir}            \\\
Igor Gnatenko 57d01a
+            --localedir=%{_datadir}/locale \\\
Igor Gnatenko 57d01a
+            --sysconfdir=%{_sysconfdir}    \\\
Igor Gnatenko 57d01a
+            $OLDPWD/%{__sourcedir}             \
Igor Gnatenko 57d01a
+    popd
Igor Gnatenko 57d01a
+%meson_build %ninja_build -C %{__builddir}
Igor Gnatenko 57d01a
+%meson_install %ninja_install -C %{__builddir}
Igor Gnatenko 57d01a
+%meson_test %ninja_test -C %{__builddir}
Igor Gnatenko 57d01a
diff --git a/mesonbuild/modules/rpm.py b/mesonbuild/modules/rpm.py
Igor Gnatenko 57d01a
index 89194e9..13aa20b 100644
Igor Gnatenko 57d01a
--- a/mesonbuild/modules/rpm.py
Igor Gnatenko 57d01a
+++ b/mesonbuild/modules/rpm.py
Igor Gnatenko 57d01a
@@ -104,7 +104,7 @@ class RPMModule:
Igor Gnatenko 57d01a
                          mlog.bold('dnf provides %s' % lib.fullpath))
Igor Gnatenko 57d01a
             for prog in state.environment.coredata.ext_progs.values():
Igor Gnatenko 57d01a
                 if not prog.found():
Igor Gnatenko 57d01a
-                    fn.write('BuildRequires: /usr/bin/%s # FIXME\n' %
Igor Gnatenko 57d01a
+                    fn.write('BuildRequires: %{_bindir}/%s # FIXME\n' %
Igor Gnatenko 57d01a
                              prog.get_name())
Igor Gnatenko 57d01a
                 else:
Igor Gnatenko 57d01a
                     fn.write('BuildRequires: %s\n' % ' '.join(prog.fullpath))
Igor Gnatenko 57d01a
@@ -115,32 +115,25 @@ class RPMModule:
Igor Gnatenko 57d01a
             if devel_subpkg:
Igor Gnatenko 57d01a
                 fn.write('%package devel\n')
Igor Gnatenko 57d01a
                 fn.write('Summary: Development files for %{name}\n')
Igor Gnatenko 57d01a
-                fn.write('Requires: %{name}%{?_isa} = %{version}-%{release}\n')
Igor Gnatenko 57d01a
+                fn.write('Requires: %{name}%{?_isa} = %{?epoch:%{epoch}:}{version}-%{release}\n')
Igor Gnatenko 57d01a
                 fn.write('\n')
Igor Gnatenko 57d01a
                 fn.write('%description devel\n')
Igor Gnatenko 57d01a
                 fn.write('Development files for %{name}.\n')
Igor Gnatenko 57d01a
                 fn.write('\n')
Igor Gnatenko 57d01a
             fn.write('%prep\n')
Igor Gnatenko 57d01a
             fn.write('%autosetup\n')
Igor Gnatenko 57d01a
-            fn.write('rm -rf rpmbuilddir && mkdir rpmbuilddir\n')
Igor Gnatenko 57d01a
             fn.write('\n')
Igor Gnatenko 57d01a
             fn.write('%build\n')
Igor Gnatenko 57d01a
-            fn.write('pushd rpmbuilddir\n')
Igor Gnatenko 57d01a
-            fn.write('  %meson ..\n')
Igor Gnatenko 57d01a
-            fn.write('  ninja-build -v\n')
Igor Gnatenko 57d01a
-            fn.write('popd\n')
Igor Gnatenko 57d01a
+            fn.write('%meson\n')
Igor Gnatenko 57d01a
+            fn.write('%meson_build\n')
Igor Gnatenko 57d01a
             fn.write('\n')
Igor Gnatenko 57d01a
             fn.write('%install\n')
Igor Gnatenko 57d01a
-            fn.write('pushd rpmbuilddir\n')
Igor Gnatenko 57d01a
-            fn.write('  DESTDIR=%{buildroot} ninja-build -v install\n')
Igor Gnatenko 57d01a
-            fn.write('popd\n')
Igor Gnatenko 57d01a
+            fn.write('%meson_install\n')
Igor Gnatenko 57d01a
             if len(to_delete) > 0:
Igor Gnatenko 57d01a
-                fn.write('rm -rf %s\n' % ' '.join(to_delete))
Igor Gnatenko 57d01a
+                fn.write('rm -vf %s\n' % ' '.join(to_delete))
Igor Gnatenko 57d01a
             fn.write('\n')
Igor Gnatenko 57d01a
             fn.write('%check\n')
Igor Gnatenko 57d01a
-            fn.write('pushd rpmbuilddir\n')
Igor Gnatenko 57d01a
-            fn.write('  ninja-build -v test\n')
Igor Gnatenko 57d01a
-            fn.write('popd\n')
Igor Gnatenko 57d01a
+            fn.write('%meson_test\n')
Igor Gnatenko 57d01a
             fn.write('\n')
Igor Gnatenko 57d01a
             fn.write('%files\n')
Igor Gnatenko 57d01a
             for f in files:
Igor Gnatenko 57d01a
@@ -153,7 +146,6 @@ class RPMModule:
Igor Gnatenko 57d01a
                 fn.write('\n')
Igor Gnatenko 57d01a
             if so_installed:
Igor Gnatenko 57d01a
                 fn.write('%post -p /sbin/ldconfig\n')
Igor Gnatenko 57d01a
-                fn.write('\n')
Igor Gnatenko 57d01a
                 fn.write('%postun -p /sbin/ldconfig\n')
Igor Gnatenko 57d01a
             fn.write('\n')
Igor Gnatenko 57d01a
             fn.write('%changelog\n')
Igor Gnatenko 57d01a
-- 
Igor Gnatenko 57d01a
2.10.1
Igor Gnatenko 57d01a