Replace _module_build condition with specific macros

The _module_build condition disables all the features when building
any Modularity module. This is wrong because there are modules that want to
enable some features. Like using system libraries or enabling Qt GUI
or Spinx-generated documentation or RPM dependency generators for
cmake files.

This patch breaks the _module_build condition into various specific
bcond_with conditions defined and documented at the beginning of the
spec file.
This commit is contained in:
Petr Písař 2017-09-05 13:38:07 +02:00
parent 7b73d7e32a
commit 7ad9a9f7bc

View File

@ -1,27 +1,46 @@
# Do we add appdata-files?
%if 0%{?fedora} || 0%{?rhel} > 7
%bcond_without cmake_enables_appdata
%else
%bcond_with cmake_enables_appdata
%endif
# Set to bcond_without or use --with bootstrap if bootstrapping a new release
# or architecture
%bcond_with bootstrap
# Build with Emacs support
%bcond_without cmake_enables_emacs
# Set to bcond_with or use --without gui to disable qt4 gui build # Set to bcond_with or use --without gui to disable qt4 gui build
%bcond_without gui %bcond_without cmake_enables_gui
# Use ncurses for colorful output
%bcond_without cmake_enables_ncurses
# Setting the Python-version used by default # Setting the Python-version used by default
%if 0%{?rhel} && 0%{?rhel} < 8 %if 0%{?rhel} && 0%{?rhel} < 8
%bcond_with python3 %bcond_with cmake_enables_python3
%else %else
%bcond_without python3 %bcond_without cmake_enables_python3
%endif %endif
# Do we add appdata-files? # Enable RPM dependency generators for cmake files written in Python
%if 0%{?fedora} || 0%{?rhel} > 7 %bcond_without cmake_enables_rpm
%bcond_without appdata
%else
%bcond_with appdata
%endif
# Sphinx-build cannot import CMakeLexer on EPEL <= 6 # Sphinx-build cannot import CMakeLexer on EPEL <= 6
%if 0%{?fedora} || 0%{?rhel} >= 7 %if 0%{?fedora} || 0%{?rhel} >= 7
%bcond_without sphinx %bcond_without cmake_enables_sphinx
%else %else
%bcond_with sphinx %bcond_with cmake_enables_sphinx
%endif %endif
# Run tests
%bcond_without cmake_enables_test
# Enable X11 tests
%bcond_without cmake_enables_X11_test
# Place rpm-macros into proper location # Place rpm-macros into proper location
%global rpm_macros_dir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d) %global rpm_macros_dir %(d=%{_rpmconfigdir}/macros.d; [ -d $d ] || d=%{_sysconfdir}/rpm; echo $d)
@ -86,15 +105,22 @@ BuildRequires: findutils
BuildRequires: gcc-c++ BuildRequires: gcc-c++
BuildRequires: gcc-gfortran BuildRequires: gcc-gfortran
BuildRequires: sed BuildRequires: sed
%if ! 0%{?_module_build} %if %{with cmake_enables_X11_test}
BuildRequires: ncurses-devel, libX11-devel BuildRequires: libX11-devel
%endif
%if %{with cmake_enables_ncurses}
BuildRequires: ncurses-devel
%endif
%if %{without bootstrap}
BuildRequires: bzip2-devel BuildRequires: bzip2-devel
BuildRequires: curl-devel BuildRequires: curl-devel
BuildRequires: expat-devel BuildRequires: expat-devel
BuildRequires: jsoncpp-devel BuildRequires: jsoncpp-devel
%if 0%{?fedora} || 0%{?rhel} >= 7 %if 0%{?fedora} || 0%{?rhel} >= 7
BuildRequires: libarchive-devel BuildRequires: libarchive-devel
%if %{with cmake_enables_sphinx}
BuildRequires: /usr/bin/sphinx-build BuildRequires: /usr/bin/sphinx-build
%endif
%else %else
BuildRequires: libarchive3-devel BuildRequires: libarchive3-devel
%endif %endif
@ -102,25 +128,26 @@ BuildRequires: libuv-devel
BuildRequires: rhash-devel BuildRequires: rhash-devel
BuildRequires: xz-devel BuildRequires: xz-devel
BuildRequires: zlib-devel BuildRequires: zlib-devel
%endif
%if %{with cmake_enables_emacs}
BuildRequires: emacs BuildRequires: emacs
%endif %endif
%if ! 0%{?_module_build} %if %{with cmake_enables_rpm}
%if %{with python3} %if %{with cmake_enables_python3}
%{!?python3_pkgversion: %global python3_pkgversion 3} %{!?python3_pkgversion: %global python3_pkgversion 3}
BuildRequires: python%{python3_pkgversion}-devel BuildRequires: python%{python3_pkgversion}-devel
%else %else
BuildRequires: python2-devel BuildRequires: python2-devel
%endif %endif
%endif
#BuildRequires: xmlrpc-c-devel #BuildRequires: xmlrpc-c-devel
%if %{with gui} %if %{with cmake_enables_gui}
%if 0%{?fedora} || 0%{?rhel} > 7 %if 0%{?fedora} || 0%{?rhel} > 7
BuildRequires: pkgconfig(Qt5) BuildRequires: pkgconfig(Qt5)
%else %else
BuildRequires: qt-devel BuildRequires: qt-devel
%endif %endif
BuildRequires: desktop-file-utils BuildRequires: desktop-file-utils
%global qt_gui --qt-gui
%endif
%endif %endif
Requires: %{name}-data = %{version}-%{release} Requires: %{name}-data = %{version}-%{release}
@ -150,7 +177,7 @@ generation, code generation, and template instantiation.
Summary: Common data-files for %{name} Summary: Common data-files for %{name}
Requires: %{name} = %{version}-%{release} Requires: %{name} = %{version}-%{release}
Requires: %{name}-filesystem = %{version}-%{release} Requires: %{name}-filesystem = %{version}-%{release}
%if ! 0%{?_module_build} %if %{with cmake_enables_emacs}
%if 0%{?fedora} || 0%{?rhel} >= 7 %if 0%{?fedora} || 0%{?rhel} >= 7
Requires: emacs-filesystem >= %{_emacs_version} Requires: emacs-filesystem >= %{_emacs_version}
%endif %endif
@ -177,6 +204,7 @@ Summary: Directories used by CMake modules
This package owns all directories used by CMake modules. This package owns all directories used by CMake modules.
%if %{with cmake_enables_gui}
%package gui %package gui
Summary: Qt GUI for %{name} Summary: Qt GUI for %{name}
@ -186,12 +214,14 @@ Requires: shared-mime-info%{?_isa}
%description gui %description gui
The %{name}-gui package contains the Qt based GUI for %{name}. The %{name}-gui package contains the Qt based GUI for %{name}.
%endif
%prep %prep
%autosetup -n %{orig_name}-%{version}%{?versuf} -p 1 %autosetup -n %{orig_name}-%{version}%{?versuf} -p 1
%if %{with python3} %if %{with cmake_enables_rpm}
%if %{with cmake_enables_python3}
echo '#!%{__python3}' > %{name}.prov echo '#!%{__python3}' > %{name}.prov
echo '#!%{__python3}' > %{name}.req echo '#!%{__python3}' > %{name}.req
%else %else
@ -200,6 +230,7 @@ echo '#!%{__python2}' > %{name}.req
%endif %endif
tail -n +2 %{SOURCE4} >> %{name}.prov tail -n +2 %{SOURCE4} >> %{name}.prov
tail -n +2 %{SOURCE5} >> %{name}.req tail -n +2 %{SOURCE5} >> %{name}.req
%endif
%build %build
@ -208,18 +239,17 @@ export CXXFLAGS="%{optflags}"
export LDFLAGS="%{?__global_ldflags}" export LDFLAGS="%{?__global_ldflags}"
mkdir build mkdir build
pushd build pushd build
%if ! 0%{?_module_build}
../bootstrap --prefix=%{_prefix} --datadir=/share/%{name} \ ../bootstrap --prefix=%{_prefix} --datadir=/share/%{name} \
--docdir=/share/doc/%{name} --mandir=/share/man \ --docdir=/share/doc/%{name} --mandir=/share/man \
--%{?with_bootstrap:no-}system-libs \ --%{?with_bootstrap:no-}system-libs \
--parallel=`/usr/bin/getconf _NPROCESSORS_ONLN` \ --parallel=`/usr/bin/getconf _NPROCESSORS_ONLN` \
%{?with_sphinx:--sphinx-man --sphinx-html} \ %if %{with cmake_enables_sphinx}
%{?qt_gui}; --sphinx-man --sphinx-html \
%else %else
../bootstrap --prefix=%{_prefix} --datadir=/share/%{name} \ --sphinx-build=%{_bindir}false \
--docdir=/share/doc/%{name} --mandir=/share/man \
--parallel=`/usr/bin/getconf _NPROCESSORS_ONLN`
%endif %endif
--%{!?with_cmake_enables_gui:no-}qt-gui \
;
%make_build VERBOSE=1 %make_build VERBOSE=1
@ -238,7 +268,7 @@ for f in %{buildroot}%{_datadir}/%{name}/completions/*
do do
ln -s ../../%{name}/completions/$(basename $f) %{buildroot}%{_datadir}/bash-completion/completions ln -s ../../%{name}/completions/$(basename $f) %{buildroot}%{_datadir}/bash-completion/completions
done done
%if ! 0%{?_module_build} %if %{with cmake_enables_emacs}
# Install emacs cmake mode # Install emacs cmake mode
mkdir -p %{buildroot}%{_emacs_sitelispdir}/%{name} mkdir -p %{buildroot}%{_emacs_sitelispdir}/%{name}
install -p -m 0644 Auxiliary/cmake-mode.el %{buildroot}%{_emacs_sitelispdir}/%{name}/%{name}-mode.el install -p -m 0644 Auxiliary/cmake-mode.el %{buildroot}%{_emacs_sitelispdir}/%{name}/%{name}-mode.el
@ -250,7 +280,7 @@ install -p -m 0644 %SOURCE1 %{buildroot}%{_emacs_sitestartdir}
install -p -m0644 -D %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.%{name} install -p -m0644 -D %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.%{name}
sed -i -e "s|@@CMAKE_VERSION@@|%{version}|" -e "s|@@CMAKE_MAJOR_VERSION@@|%{major_version}|" %{buildroot}%{rpm_macros_dir}/macros.%{name} sed -i -e "s|@@CMAKE_VERSION@@|%{version}|" -e "s|@@CMAKE_MAJOR_VERSION@@|%{major_version}|" %{buildroot}%{rpm_macros_dir}/macros.%{name}
touch -r %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.%{name} touch -r %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.%{name}
%if 0%{?_rpmconfigdir:1} %if %{with cmake_enables_rpm} && 0%{?_rpmconfigdir:1}
# RPM auto provides # RPM auto provides
install -p -m0644 -D %{SOURCE3} %{buildroot}%{_prefix}/lib/rpm/fileattrs/%{name}.attr install -p -m0644 -D %{SOURCE3} %{buildroot}%{_prefix}/lib/rpm/fileattrs/%{name}.attr
install -p -m0755 -D %{name}.prov %{buildroot}%{_prefix}/lib/rpm/%{name}.prov install -p -m0755 -D %{name}.prov %{buildroot}%{_prefix}/lib/rpm/%{name}.prov
@ -266,30 +296,25 @@ do
cp -p $f ./${fname}_${dname} cp -p $f ./${fname}_${dname}
done done
# Cleanup pre-installed documentation # Cleanup pre-installed documentation
%if ! 0%{?_module_build} %if %{with cmake_enables_sphinx}
%if 0%{?with_sphinx:1}
mv %{buildroot}%{_docdir}/%{name}/html . mv %{buildroot}%{_docdir}/%{name}/html .
%endif %endif
%endif
rm -rf %{buildroot}%{_docdir}/%{name} rm -rf %{buildroot}%{_docdir}/%{name}
# Install documentation to _pkgdocdir # Install documentation to _pkgdocdir
mkdir -p %{buildroot}%{_pkgdocdir} mkdir -p %{buildroot}%{_pkgdocdir}
cp -pr %{buildroot}%{_datadir}/%{name}/Help %{buildroot}%{_pkgdocdir} cp -pr %{buildroot}%{_datadir}/%{name}/Help %{buildroot}%{_pkgdocdir}
mv %{buildroot}%{_pkgdocdir}/Help %{buildroot}%{_pkgdocdir}/rst mv %{buildroot}%{_pkgdocdir}/Help %{buildroot}%{_pkgdocdir}/rst
%if ! 0%{?_module_build} %if %{with cmake_enables_sphinx}
%if 0%{?with_sphinx:1}
mv html %{buildroot}%{_pkgdocdir} mv html %{buildroot}%{_pkgdocdir}
%endif %endif
%endif
%if ! 0%{?_module_build} %if %{with cmake_enables_gui}
%if %{with gui}
# Desktop file # Desktop file
desktop-file-install --delete-original \ desktop-file-install --delete-original \
--dir=%{buildroot}%{_datadir}/applications \ --dir=%{buildroot}%{_datadir}/applications \
%{buildroot}%{_datadir}/applications/%{name}-gui.desktop %{buildroot}%{_datadir}/applications/%{name}-gui.desktop
%if %{with appdata} %if %{with cmake_enables_appdata}
# Register as an application to be visible in the software center # Register as an application to be visible in the software center
# #
# NOTE: It would be *awesome* if this file was maintained by the upstream # NOTE: It would be *awesome* if this file was maintained by the upstream
@ -328,7 +353,6 @@ SentUpstream: 2014-09-17
EOF EOF
%endif %endif
%endif %endif
%endif
# create manifests for splitting files and directories for filesystem-package # create manifests for splitting files and directories for filesystem-package
find %{buildroot}%{_datadir}/%{name} -type d | \ find %{buildroot}%{_datadir}/%{name} -type d | \
@ -343,7 +367,7 @@ find %{buildroot}%{_bindir} -type f -or -type l -or -xtype l | \
sed -e '/.*-gui$/d' -e '/^$/d' -e 's!^%{buildroot}!"!g' -e 's!$!"!g' >> lib_files.mf sed -e '/.*-gui$/d' -e '/^$/d' -e 's!^%{buildroot}!"!g' -e 's!$!"!g' >> lib_files.mf
%if ! 0%{?_module_build} %if %{with cmake_enables_test}
%check %check
%if 0%{?rhel} && 0%{?rhel} <= 6 %if 0%{?rhel} && 0%{?rhel} <= 6
mv -f Modules/FindLibArchive.cmake Modules/FindLibArchive.disabled mv -f Modules/FindLibArchive.cmake Modules/FindLibArchive.disabled
@ -364,7 +388,7 @@ mv -f Modules/FindLibArchive.disabled Modules/FindLibArchive.cmake
%endif %endif
%if %{with gui} %if %{with cmake_enables_gui}
%post gui %post gui
update-desktop-database &> /dev/null || : update-desktop-database &> /dev/null || :
/bin/touch --no-create %{_datadir}/mime || : /bin/touch --no-create %{_datadir}/mime || :
@ -389,21 +413,19 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
%doc %dir %{_pkgdocdir} %doc %dir %{_pkgdocdir}
%license Copyright.txt* %license Copyright.txt*
%license COPYING* %license COPYING*
%if ! 0%{?_module_build} %if %{with cmake_enables_sphinx}
%if 0%{?with_sphinx:1}
%{_mandir}/man1/c%{name}.1.* %{_mandir}/man1/c%{name}.1.*
%{_mandir}/man1/%{name}.1.* %{_mandir}/man1/%{name}.1.*
%{_mandir}/man1/cpack%{?name_suffix}.1.* %{_mandir}/man1/cpack%{?name_suffix}.1.*
%{_mandir}/man1/ctest%{?name_suffix}.1.* %{_mandir}/man1/ctest%{?name_suffix}.1.*
%{_mandir}/man7/*.7.* %{_mandir}/man7/*.7.*
%endif %endif
%endif
%files data -f data_files.mf %files data -f data_files.mf
%{_datadir}/aclocal/%{name}.m4 %{_datadir}/aclocal/%{name}.m4
%{_datadir}/bash-completion %{_datadir}/bash-completion
%if ! 0%{?_module_build} %if %{with cmake_enables_emacs}
%if 0%{?fedora} || 0%{?rhel} >= 7 %if 0%{?fedora} || 0%{?rhel} >= 7
%{_emacs_sitelispdir}/%{name} %{_emacs_sitelispdir}/%{name}
%{_emacs_sitestartdir}/%{name}-init.el %{_emacs_sitestartdir}/%{name}-init.el
@ -413,7 +435,7 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
%endif %endif
%endif %endif
%{rpm_macros_dir}/macros.%{name} %{rpm_macros_dir}/macros.%{name}
%if 0%{?_rpmconfigdir:1} %if %{with cmake_enables_rpm} && 0%{?_rpmconfigdir:1}
%{_rpmconfigdir}/fileattrs/%{name}.attr %{_rpmconfigdir}/fileattrs/%{name}.attr
%{_rpmconfigdir}/%{name}.prov %{_rpmconfigdir}/%{name}.prov
%{_rpmconfigdir}/%{name}.req %{_rpmconfigdir}/%{name}.req
@ -430,21 +452,19 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
%files filesystem -f data_dirs.mf -f lib_dirs.mf %files filesystem -f data_dirs.mf -f lib_dirs.mf
%if ! 0%{?_module_build} %if %{with cmake_enables_gui}
%if %{with gui}
%files gui %files gui
%{_bindir}/%{name}-gui %{_bindir}/%{name}-gui
%if %{with appdata} %if %{with cmake_enables_appdata}
%{_datadir}/appdata/*.appdata.xml %{_datadir}/appdata/*.appdata.xml
%endif %endif
%{_datadir}/applications/%{name}-gui.desktop %{_datadir}/applications/%{name}-gui.desktop
%{_datadir}/mime/packages %{_datadir}/mime/packages
%{_datadir}/icons/hicolor/*/apps/CMake%{?name_suffix}Setup.png %{_datadir}/icons/hicolor/*/apps/CMake%{?name_suffix}Setup.png
%if 0%{?with_sphinx:1} %if %{with cmake_enables_sphinx}
%{_mandir}/man1/%{name}-gui.1.* %{_mandir}/man1/%{name}-gui.1.*
%endif %endif
%endif %endif
%endif
%changelog %changelog