anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

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

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