Blame SOURCES/0083-build-Add-meson-rpmbuild-support.patch

26ccd9
From 8b5b941093521dd18fcc99659b3e3b1b9e9456b7 Mon Sep 17 00:00:00 2001
26ccd9
From: Dan Williams <dan.j.williams@intel.com>
26ccd9
Date: Wed, 5 Jan 2022 13:32:58 -0800
26ccd9
Subject: [PATCH 083/217] build: Add meson rpmbuild support
26ccd9
26ccd9
Beyond being a prerequisite for removing autotools support, this capability
26ccd9
served as validation that the meson conversion generated all the same files
26ccd9
as autotools and installed them to the same expected locations.
26ccd9
26ccd9
The procedure to use the rpmbuild.sh script is:
26ccd9
26ccd9
    meson setup build
26ccd9
    meson compile -C build rhel/ndctl.spec
26ccd9
    ./rpmbuild.sh build/rhel/ndctl.spec
26ccd9
26ccd9
Link: https://lore.kernel.org/r/164141837841.3990253.11379060834465142446.stgit@dwillia2-desk3.amr.corp.intel.com
26ccd9
Tested-by: Alison Schofield <alison.schofield@intel.com>
26ccd9
Tested-by: Vaibhav Jain <vaibhav@linux.ibm.com>
26ccd9
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
26ccd9
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
26ccd9
---
26ccd9
 .gitignore       |  2 +-
26ccd9
 Makefile.am      |  2 ++
26ccd9
 meson.build      |  6 ++++++
26ccd9
 ndctl.spec.in    | 23 +++++++++++++++++++++++
26ccd9
 rhel/meson.build | 23 +++++++++++++++++++++++
26ccd9
 rpmbuild.sh      |  5 ++++-
26ccd9
 sles/meson.build | 36 ++++++++++++++++++++++++++++++++++++
26ccd9
 7 files changed, 95 insertions(+), 2 deletions(-)
26ccd9
 create mode 100644 rhel/meson.build
26ccd9
 create mode 100644 sles/meson.build
26ccd9
26ccd9
diff -up ndctl-71.1/.gitignore.orig ndctl-71.1/.gitignore
26ccd9
--- ndctl-71.1/.gitignore.orig	2022-10-07 16:34:40.712445112 -0400
26ccd9
+++ ndctl-71.1/.gitignore	2022-10-07 16:34:52.832486377 -0400
26ccd9
@@ -35,7 +35,7 @@ daxctl/lib/libdaxctl.pc
26ccd9
 ndctl/config.h
26ccd9
 ndctl/lib/libndctl.pc
26ccd9
 ndctl/ndctl
26ccd9
-rhel/
26ccd9
+rhel/ndctl.spec
26ccd9
 sles/ndctl.spec
26ccd9
 version.m4
26ccd9
 *.swp
26ccd9
diff -up ndctl-71.1/Makefile.am.orig ndctl-71.1/Makefile.am
26ccd9
--- ndctl-71.1/Makefile.am.orig	2022-10-07 16:34:40.687445027 -0400
26ccd9
+++ ndctl-71.1/Makefile.am	2022-10-07 16:34:52.832486377 -0400
26ccd9
@@ -22,6 +22,7 @@ noinst_SCRIPTS = rhel/ndctl.spec sles/nd
26ccd9
 CLEANFILES += $(noinst_SCRIPTS)
26ccd9
 
26ccd9
 do_rhel_subst = sed -e 's,VERSION,$(VERSION),g' \
26ccd9
+            -e 's,MESON,0,g' \
26ccd9
             -e 's,DAX_DNAME,daxctl-devel,g' \
26ccd9
             -e 's,CXL_DNAME,cxl-devel,g' \
26ccd9
             -e 's,DNAME,ndctl-devel,g' \
26ccd9
@@ -31,6 +32,7 @@ do_rhel_subst = sed -e 's,VERSION,$(VERS
26ccd9
 	    -e 's,LNAME,ndctl-libs,g'
26ccd9
 
26ccd9
 do_sles_subst = sed -e 's,VERSION,$(VERSION),g' \
26ccd9
+            -e 's,MESON,0,g' \
26ccd9
             -e 's,DAX_DNAME,libdaxctl-devel,g' \
26ccd9
             -e 's,CXL_DNAME,libcxl-devel,g' \
26ccd9
             -e 's,DNAME,libndctl-devel,g' \
26ccd9
diff -up ndctl-71.1/meson.build.orig ndctl-71.1/meson.build
26ccd9
--- ndctl-71.1/meson.build.orig	2022-10-07 16:34:40.715445122 -0400
26ccd9
+++ ndctl-71.1/meson.build	2022-10-07 16:34:52.833486380 -0400
26ccd9
@@ -278,3 +278,9 @@ if get_option('docs').enabled()
26ccd9
 endif
26ccd9
 subdir('test')
26ccd9
 subdir('contrib')
26ccd9
+
26ccd9
+# only support spec file generation from git builds
26ccd9
+if version_tag == ''
26ccd9
+  subdir('rhel')
26ccd9
+  subdir('sles')
26ccd9
+endif
26ccd9
diff -up ndctl-71.1/ndctl.spec.in.orig ndctl-71.1/ndctl.spec.in
26ccd9
--- ndctl-71.1/ndctl.spec.in.orig	2022-10-07 16:34:40.645444884 -0400
26ccd9
+++ ndctl-71.1/ndctl.spec.in	2022-10-07 16:34:52.833486380 -0400
26ccd9
@@ -6,14 +6,20 @@ License:	GPLv2
26ccd9
 Url:		https://github.com/pmem/ndctl
26ccd9
 Source0:	https://github.com/pmem/%{name}/archive/v%{version}.tar.gz#/%{name}-%{version}.tar.gz
26ccd9
 
26ccd9
+%define with_meson MESON
26ccd9
 Requires:	LNAME%{?_isa} = %{version}-%{release}
26ccd9
 Requires:	DAX_LNAME%{?_isa} = %{version}-%{release}
26ccd9
 Requires:	CXL_LNAME%{?_isa} = %{version}-%{release}
26ccd9
 BuildRequires:	autoconf
26ccd9
 %if 0%{?rhel} < 9
26ccd9
 BuildRequires:	asciidoc
26ccd9
+%if !%{with_meson}
26ccd9
 %define asciidoc --disable-asciidoctor
26ccd9
+%endif
26ccd9
 %else
26ccd9
+%if %{with_meson}
26ccd9
+%define asciidoctor -Dasciidoctor=enabled
26ccd9
+%endif
26ccd9
 BuildRequires:	rubygem-asciidoctor
26ccd9
 %endif
26ccd9
 BuildRequires:	xmlto
26ccd9
@@ -28,6 +34,10 @@ BuildRequires:	pkgconfig(bash-completion
26ccd9
 BuildRequires:	pkgconfig(systemd)
26ccd9
 BuildRequires:	keyutils-libs-devel
26ccd9
 
26ccd9
+%if %{with_meson}
26ccd9
+BuildRequires:	meson
26ccd9
+%endif
26ccd9
+
26ccd9
 %description
26ccd9
 Utility library for managing the "libnvdimm" subsystem.  The "libnvdimm"
26ccd9
 subsystem defines a kernel device model and control message interface for
26ccd9
@@ -115,17 +125,30 @@ libcxl is a library for enumerating and
26ccd9
 %setup -q ndctl-%{version}
26ccd9
 
26ccd9
 %build
26ccd9
+%if %{with_meson}
26ccd9
+%meson %{?asciidoctor} -Dversion-tag=%{version}
26ccd9
+%meson_build
26ccd9
+%else
26ccd9
 echo %{version} > version
26ccd9
 ./autogen.sh
26ccd9
 %configure --disable-static --disable-silent-rules %{?asciidoc}
26ccd9
 make %{?_smp_mflags}
26ccd9
+%endif
26ccd9
 
26ccd9
 %install
26ccd9
+%if %{with_meson}
26ccd9
+%meson_install
26ccd9
+%else
26ccd9
 %make_install
26ccd9
 find $RPM_BUILD_ROOT -name '*.la' -exec rm -f {} ';'
26ccd9
+%endif
26ccd9
 
26ccd9
 %check
26ccd9
+%if %{with_meson}
26ccd9
+%meson_test
26ccd9
+%else
26ccd9
 make check
26ccd9
+%endif
26ccd9
 
26ccd9
 %ldconfig_scriptlets -n LNAME
26ccd9
 
26ccd9
diff -up ndctl-71.1/rhel/meson.build.orig ndctl-71.1/rhel/meson.build
26ccd9
--- ndctl-71.1/rhel/meson.build.orig	2022-10-07 16:34:52.834486384 -0400
26ccd9
+++ ndctl-71.1/rhel/meson.build	2022-10-07 16:34:52.834486384 -0400
26ccd9
@@ -0,0 +1,23 @@
26ccd9
+rhel_spec1 = vcs_tag(
26ccd9
+    input : '../ndctl.spec.in',
26ccd9
+    output : 'ndctl.spec.in',
26ccd9
+    command: vcs_tagger,
26ccd9
+    replace_string : 'VERSION',
26ccd9
+)
26ccd9
+
26ccd9
+rhel_spec2 = custom_target('ndctl.spec',
26ccd9
+  command : [
26ccd9
+    'sed', '-e', 's,MESON,1,g',
26ccd9
+	   '-e', 's,DAX_DNAME,daxctl-devel,g',
26ccd9
+	   '-e', 's,CXL_DNAME,cxl-devel,g',
26ccd9
+	   '-e', 's,DNAME,ndctl-devel,g',
26ccd9
+	   '-e', '/^%defattr.*/d',
26ccd9
+	   '-e', 's,DAX_LNAME,daxctl-libs,g',
26ccd9
+	   '-e', 's,CXL_LNAME,cxl-libs,g',
26ccd9
+	   '-e', 's,LNAME,ndctl-libs,g',
26ccd9
+	   '@INPUT@'
26ccd9
+  ],
26ccd9
+  input : rhel_spec1,
26ccd9
+  output : 'ndctl.spec',
26ccd9
+  capture : true,
26ccd9
+)
26ccd9
diff -up ndctl-71.1/rpmbuild.sh.orig ndctl-71.1/rpmbuild.sh
26ccd9
--- ndctl-71.1/rpmbuild.sh.orig	2020-12-22 16:44:57.000000000 -0500
26ccd9
+++ ndctl-71.1/rpmbuild.sh	2022-10-07 16:34:52.834486384 -0400
26ccd9
@@ -1,6 +1,9 @@
26ccd9
 #!/bin/bash
26ccd9
+
26ccd9
+spec=${1:-$(dirname $0)/rhel/ndctl.spec)}
26ccd9
+
26ccd9
 pushd $(dirname $0) >/dev/null
26ccd9
 [ ! -d ~/rpmbuild/SOURCES ] && echo "rpmdev tree not found" && exit 1
26ccd9
 ./make-git-snapshot.sh
26ccd9
 popd > /dev/null
26ccd9
-rpmbuild -ba $(dirname $0)/rhel/ndctl.spec
26ccd9
+rpmbuild --nocheck -ba $spec
26ccd9
diff -up ndctl-71.1/sles/meson.build.orig ndctl-71.1/sles/meson.build
26ccd9
--- ndctl-71.1/sles/meson.build.orig	2022-10-07 16:34:52.836486391 -0400
26ccd9
+++ ndctl-71.1/sles/meson.build	2022-10-07 16:34:52.835486387 -0400
26ccd9
@@ -0,0 +1,36 @@
26ccd9
+sles_spec1 = vcs_tag(
26ccd9
+    input : '../ndctl.spec.in',
26ccd9
+    output : 'ndctl.spec.sles.in',
26ccd9
+    command: vcs_tagger,
26ccd9
+    replace_string : 'VERSION',
26ccd9
+)
26ccd9
+
26ccd9
+header = files('header')
26ccd9
+
26ccd9
+sles_spec2 = custom_target('ndctl.spec.in',
26ccd9
+  command : [
26ccd9
+    'cat', header, '@INPUT@',
26ccd9
+  ],
26ccd9
+  input : sles_spec1,
26ccd9
+  output : 'ndctl.spec.in',
26ccd9
+  capture : true,
26ccd9
+)
26ccd9
+
26ccd9
+sles_spec3 = custom_target('ndctl.spec',
26ccd9
+  command : [
26ccd9
+    'sed', '-e', 's,MESON,1,g',
26ccd9
+           '-e', 's,DAX_DNAME,libdaxctl-devel,g',
26ccd9
+           '-e', 's,CXL_DNAME,libcxl-devel,g',
26ccd9
+           '-e', 's,DNAME,libndctl-devel,g',
26ccd9
+           '-e', 's,%license,%doc,g',
26ccd9
+           '-e', 's,\(^License:.*GPL\)v2,\1-2.0,g',
26ccd9
+           '-e', 's,DAX_LNAME,libdaxctl@0@,g'.format(LIBDAXCTL_CURRENT - LIBDAXCTL_AGE),
26ccd9
+           '-e', 's,CXL_LNAME,libcxl@0@,g'.format(LIBCXL_CURRENT - LIBCXL_AGE),
26ccd9
+           '-e', 's,LNAME,libndctl@0@,g'.format(LIBNDCTL_CURRENT - LIBNDCTL_AGE),
26ccd9
+	   '@INPUT@'
26ccd9
+  ],
26ccd9
+
26ccd9
+  input : sles_spec2,
26ccd9
+  output : 'ndctl.spec',
26ccd9
+  capture : true,
26ccd9
+)