From 4c58e609fe8d1d4fc54d8142b80cb5c6e91fc654 Mon Sep 17 00:00:00 2001 From: Silvan Calarco Date: Fri, 5 Jan 2024 21:26:42 +0100 Subject: [PATCH] fix for lost major_version definition in a previous specfile release [release 3.27.3-4mamba;Mon Aug 21 2023] --- cmake-rpmmacro | 20 ------------ cmake.attr | 3 ++ cmake.prov | 82 +++++++++++++++++++++++++++++++++++++++++++++++++ cmake.req | 70 +++++++++++++++++++++++++++++++++++++++++ cmake.spec | 36 +++++++++++++++++++--- macros.cmake.in | 77 ++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 263 insertions(+), 25 deletions(-) delete mode 100644 cmake-rpmmacro create mode 100644 cmake.attr create mode 100644 cmake.prov create mode 100644 cmake.req create mode 100644 macros.cmake.in diff --git a/cmake-rpmmacro b/cmake-rpmmacro deleted file mode 100644 index 0395598..0000000 --- a/cmake-rpmmacro +++ /dev/null @@ -1,20 +0,0 @@ -%_cmake_lib_suffix64 -DLIB_SUFFIX=64 -%__cmake %{_bindir}/cmake - -%cmake(d:) \ - CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \ - CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \ - FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \ - bdir=. \ - %{-d:dir=%{-d*} ; mkdir -p $dir ; cd $dir ; bdir=.. } \ - %__cmake \\\ - -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\ - -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \\\ - -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \\\ - -DLIB_INSTALL_DIR:PATH=%{_libdir} \\\ - -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\ - -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\ -%if "%{?_lib}" == "lib64" \ - %{?_cmake_lib_suffix64} \\\ -%endif \ - -DBUILD_SHARED_LIBS:BOOL=ON $bdir diff --git a/cmake.attr b/cmake.attr new file mode 100644 index 0000000..87f1ed9 --- /dev/null +++ b/cmake.attr @@ -0,0 +1,3 @@ +%__cmake_provides %{_rpmconfigdir}/cmake.prov +#% __cmake_requires %{_rpmconfigdir}/cmake.req +%__cmake_path ^(%{_libdir}|%{_datadir})/cmake/.*/.*(Config\.cmake|-config\.cmake)$ diff --git a/cmake.prov b/cmake.prov new file mode 100644 index 0000000..58d3522 --- /dev/null +++ b/cmake.prov @@ -0,0 +1,82 @@ +#!/usr/bin/python3 +# -*- coding:utf-8 -*- +# +# Copyright (C) 2015 Daniel Vrátil +# Copyright (C) 2017 Daniel Vrátil +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +import sys +import re +import glob + +class CMakeParser: + def __init__(self, filelist = None): + if filelist == None: + filelist = sys.stdin + + paths = map(lambda x: x.rstrip(), filelist.readlines()) + for path in paths: + modulePath, cmakeModule, lowercase = self.parseCmakeModuleConfig(path) + if modulePath and cmakeModule: + version = self.resolveCMakeModuleVersion(modulePath, cmakeModule, lowercase) + + if version: + string = "cmake(" + cmakeModule + ") = " + version + else: + string = "cmake(" + cmakeModule + ")" + if string == string.lower(): + print(string) + else: + # Temporarily print both variants to satisfy requires + # by the old version of this generator which made mistakes + print(string) + print(string.lower()) + + + def parseCmakeModuleConfig(self, configFile): + paths = configFile.rsplit("/", 3) + + modulePath = "%s/cmake/%s" % (paths[0], paths[2]) + cfgFile = paths[3] + if cfgFile.endswith("Config.cmake"): + return (modulePath, cfgFile[0:-len("Config.cmake")], False) + elif cfgFile.endswith("-config.cmake"): + return (modulePath, cfgFile[0:-len("-config.cmake")], True) + else: + return (None, None, False) + + def resolveCMakeModuleVersion(self, modulePath, cmakeModule, lowercase): + versionFile = ("%s/%s-config-version.cmake" if lowercase else "%s/%sConfigVersion.cmake") % (modulePath, cmakeModule) + try: + f = open(versionFile, 'r') + except: + return None + + for line in f: + line = line.strip() + + # set(PACKAGE_VERSION ) + version = re.match(r"^set[\ ]*\([\ ]*PACKAGE_VERSION[\ ]+[\"]*([0-9\.]+)[\"]*[\ ]*[.]*\)", line) + if version: + return version.groups(1)[0] + + return None + +if __name__ == "__main__": + parser = CMakeParser() diff --git a/cmake.req b/cmake.req new file mode 100644 index 0000000..9af5c44 --- /dev/null +++ b/cmake.req @@ -0,0 +1,70 @@ +#!/usr/bin/python3 +# -*- coding:utf-8 -*- +# +# Copyright (C) 2017 Björn Esser +# +# based on cmake.prov, which is +# Copyright (C) 2015 Daniel Vrátil +# Copyright (C) 2017 Daniel Vrátil +# +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU Library General Public License as +# published by the Free Software Foundation; either version 2 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Library General Public +# License along with this program; if not, write to the +# Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +import sys +import re +import subprocess + +class CMakeParser: + def __init__(self, filelist = None): + if filelist == None: + filelist = sys.stdin + + has_module = False + is_arched = False + + isa_suf = subprocess.check_output(["/usr/bin/rpm", "-E %{?_isa}"]).decode().strip() + + paths = map(lambda x: x.rstrip(), filelist.readlines()) + for path in paths: + modulePath, cmakeModule, lowercase = self.parseCmakeModuleConfig(path) + if modulePath and cmakeModule: + has_module = True + if re.match(".*/usr/lib(64)?/cmake/.*", modulePath): + is_arched = True + + if has_module: + if is_arched: + print("cmake-filesystem%s" % isa_suf) + else: + print("cmake-filesystem") + + + def parseCmakeModuleConfig(self, configFile): + paths = configFile.rsplit("/", 3) + + modulePath = "%s/cmake/%s" % (paths[0], paths[2]) + cfgFile = paths[3] + if cfgFile.endswith("Config.cmake"): + return (modulePath, cfgFile[0:-len("Config.cmake")], False) + elif cfgFile.endswith("-config.cmake"): + return (modulePath, cfgFile[0:-len("-config.cmake")], True) + else: + return (None, None, False) + + +if __name__ == "__main__": + parser = CMakeParser() diff --git a/cmake.spec b/cmake.spec index 1df9c15..84d1812 100644 --- a/cmake.spec +++ b/cmake.spec @@ -1,8 +1,9 @@ %define majorminor %(echo %version | cut -d. -f 1-2) +%define major_version %(echo %version | cut -d. -f 1) Name: cmake Version: 3.27.3 -Release: 1mamba +Release: 4mamba Summary: A cross-platform, open-source make system Group: Development/Tools Vendor: openmamba @@ -10,7 +11,10 @@ Distribution: openmamba Packager: Silvan Calarco URL: https://cmake.org/ Source0: http://www.cmake.org/files/v%{majorminor}/cmake-%{version}.tar.gz -Source1: cmake-rpmmacro +Source1: macros.cmake.in +Source2: cmake.attr +Source3: cmake.req +Source4: cmake.prov Patch: %{name}-2.4.5_use_intree_xmlrpc.patch Patch1: cmake-2.8.11.2-ImageMagick-6.8.patch Patch2: cmake-2.8.12.1-freetype-2.5.1.patch @@ -48,10 +52,12 @@ Other sponsors include the Insight, VTK, and VXL open source software communitie %prep %setup -q +#-D -T #%patch1 -p1 #%patch2 -p1 %build +#:<< _EOF export CFLAGS="%{optflags}" export CXXFLAGS="%{optflags} -std=gnu++14" ./configure \ @@ -71,21 +77,32 @@ export CXXFLAGS="%{optflags} -std=gnu++14" #install -D -m 0644 Docs/cmake-mode.el \ # %{buildroot}%{_datadir}/emacs/site-lisp/cmake-mode.el -install -D -m 0644 %{S:1} \ - %{buildroot}%{_sysconfdir}/rpm/macros.cmake +# RPM macros (from Fedora) +install -p -m0644 -D %{SOURCE1} %{buildroot}%{_prefix}/lib/rpm/macros.d/macros.%{name} +sed -i -e "s|@@CMAKE_VERSION@@|%{version}|" -e "s|@@CMAKE_MAJOR_VERSION@@|%{major_version}|" \ + %{buildroot}%{_prefix}/lib/rpm/macros.d/macros.%{name} +touch -r %{SOURCE1} %{buildroot}%{_prefix}/lib/rpm/macros.d/macros.%{name} + +# RPM auto provides +install -p -m0644 -D %{SOURCE2} %{buildroot}%{_prefix}/lib/rpm/fileattrs/%{name}.attr +install -p -m0755 -D %{SOURCE3} %{buildroot}%{_prefix}/lib/rpm/%{name}.prov +install -p -m0755 -D %{SOURCE4} %{buildroot}%{_prefix}/lib/rpm/%{name}.req %clean [ "%{buildroot}" != / ] && rm -rf "%{buildroot}" %files %defattr(-,root,root) -%{_sysconfdir}/rpm/macros.cmake %{_bindir}/ccmake %{_bindir}/cmake %{_bindir}/cpack %{_bindir}/ctest %dir %{_datadir}/%{name} %{_datadir}/%{name}/* +%{_prefix}/lib/rpm/macros.d/macros.%{name} +%{_prefix}/lib/rpm/fileattrs/%{name}.attr +%{_prefix}/lib/rpm/%{name}.prov +%{_prefix}/lib/rpm/%{name}.req %{_datadir}/bash-completion/completions/* %{_datadir}/emacs/site-lisp/cmake-mode.el %{_datadir}/vim/vimfiles/indent/cmake.vim @@ -94,6 +111,15 @@ install -D -m 0644 %{S:1} \ %{_datadir}/doc/%{name}-%{version}/ %changelog +* Mon Aug 21 2023 Silvan Calarco 3.27.3-4mamba +- fix for lost major_version definition in a previous specfile release + +* Sun Aug 20 2023 Silvan Calarco 3.27.3-3mamba +- disable cmake requires + +* Sun Aug 20 2023 Silvan Calarco 3.27.3-2mamba +- update rpm macros file and add auto req/prov from Fedora + * Thu Aug 17 2023 Automatic Build System 3.27.3-1mamba - automatic version update by autodist diff --git a/macros.cmake.in b/macros.cmake.in new file mode 100644 index 0000000..e539d5d --- /dev/null +++ b/macros.cmake.in @@ -0,0 +1,77 @@ +# +# Macros for cmake +# +%_cmake_lib_suffix64 -DLIB_SUFFIX=64 +%_cmake_shared_libs -DBUILD_SHARED_LIBS:BOOL=ON +%_cmake_skip_rpath -DCMAKE_SKIP_RPATH:BOOL=ON +%_cmake_version @@CMAKE_VERSION@@ +%__cmake /usr/bin/cmake +%__ctest /usr/bin/ctest +%_vpath_srcdir . +%_vpath_builddir build +%__cmake_builddir %{!?__cmake_in_source_build:%{_vpath_builddir}}%{?__cmake_in_source_build:.} + + +# - Set default compile flags +# - CMAKE_*_FLAGS_RELEASE are added *after* the *FLAGS environment variables +# and default to -O3 -DNDEBUG. Strip the -O3 so we can override with *FLAGS +# - Turn on verbose makefiles so we can see and verify compile flags +# - Turn off stripping by default so RPM can do it separately +# - Set default install prefixes and library install directories +# - Turn on shared libraries by default +# openmamba: support -d option and keep old legacy behaviour if not empty +%cmake(d:) \ + CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \ + CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \ + FFLAGS="${FFLAGS:-%optflags}" ; export FFLAGS ; \ +%if "%{-d*}" != "" \ + bdir=. \ + %{-d:dir=%{-d*} ; mkdir -p $dir ; cd $dir ; bdir=.. } \ + %__cmake \\\ + -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\ + -DCMAKE_INSTALL_LIBDIR:PATH=%{_libdir} \\\ + -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \\\ + -DLIB_INSTALL_DIR:PATH=%{_libdir} \\\ + -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\ + -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\ +%if "%{?_lib}" == "lib64" \ + %{?_cmake_lib_suffix64} \\\ +%endif \ + -DBUILD_SHARED_LIBS:BOOL=ON $bdir \\\ +%else \ + %{set_build_flags} \ + %__cmake \\\ + %{!?__cmake_in_source_build:-S "%{_vpath_srcdir}"} \\\ + %{!?__cmake_in_source_build:-B "%{__cmake_builddir}"} \\\ + -DCMAKE_C_FLAGS_RELEASE:STRING="-DNDEBUG" \\\ + -DCMAKE_CXX_FLAGS_RELEASE:STRING="-DNDEBUG" \\\ + -DCMAKE_Fortran_FLAGS_RELEASE:STRING="-DNDEBUG" \\\ + -DCMAKE_VERBOSE_MAKEFILE:BOOL=ON \\\ + -DCMAKE_INSTALL_DO_STRIP:BOOL=OFF \\\ + -DCMAKE_INSTALL_PREFIX:PATH=%{_prefix} \\\ + -DINCLUDE_INSTALL_DIR:PATH=%{_includedir} \\\ + -DLIB_INSTALL_DIR:PATH=%{_libdir} \\\ + -DSYSCONF_INSTALL_DIR:PATH=%{_sysconfdir} \\\ + -DSHARE_INSTALL_PREFIX:PATH=%{_datadir} \\\ +%if "%{?_lib}" == "lib64" \ + %{?_cmake_lib_suffix64} \\\ +%endif \ + %{?_cmake_shared_libs} \\\ +%endif \ +%{nil} + +%cmake_build \ + %__cmake --build "%{__cmake_builddir}" %{?_smp_mflags} --verbose + +%cmake_install \ + DESTDIR="%{buildroot}" %__cmake --install "%{__cmake_builddir}" + +%ctest(:-:h:j:u:v:A:C:D:E:F:H:I:L:M:N:O:Q:R:S:T:U:V:) \ + %__ctest --test-dir "%{__cmake_builddir}" --output-on-failure --force-new-ctest-process %{?_smp_mflags} %{**} + + +%cmake@@CMAKE_MAJOR_VERSION@@ %cmake +%cmake@@CMAKE_MAJOR_VERSION@@_build %cmake_build +%cmake@@CMAKE_MAJOR_VERSION@@_install %cmake_install +%ctest@@CMAKE_MAJOR_VERSION@@(:-:h:j:u:v:A:C:D:E:F:H:I:L:M:N:O:Q:R:S:T:U:V:) \ + %ctest %{**}