From de493a3f7706deb7b5b914b579fb8966607bc8b6 Mon Sep 17 00:00:00 2001 From: Rex Dieter Date: Tue, 17 Mar 2015 17:41:11 -0500 Subject: [PATCH] RFE: CMake automatic RPM provides (#1202899) --- cmake.attr | 2 ++ cmake.prov | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ cmake.spec | 17 +++++++++++- 3 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 cmake.attr create mode 100644 cmake.prov diff --git a/cmake.attr b/cmake.attr new file mode 100644 index 0000000..ceee413 --- /dev/null +++ b/cmake.attr @@ -0,0 +1,2 @@ +%__cmake_provides %{_rpmconfigdir}/cmake.prov +%__cmake_path ^/usr/lib(64)/cmake/.*/.*(Config\.cmake|-config\.cmake)$ diff --git a/cmake.prov b/cmake.prov new file mode 100644 index 0000000..1d8d538 --- /dev/null +++ b/cmake.prov @@ -0,0 +1,78 @@ +#!/bin/python +# -*- coding:utf-8 -*- +# +# Copyright (C) 2015 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: + print("cmake(%s) = %s" % (cmakeModule, version)) + else: + print("cmake(%s)" % cmakeModule) + + + def parseCmakeModuleConfig(self, configFile): + paths = configFile.rsplit("/", 3) + + modulePath = "%s/cmake/%s" % (paths[0], paths[2]) + + lowercase = False + configFile = glob.glob("%s/*Config.cmake" % modulePath) + if not configFile: + configFile = glob.glob("%s/*-config.cmake" % modulePath) + lowercase = True + if not configFile: + return (None, None) + + if lowercase: + moduleName = configFile[0][len(modulePath) + 1:-len("-config.cmake")] + else: + moduleName = configFile[0][len(modulePath) + 1:-len("Config.cmake")] + + return (modulePath, moduleName, lowercase) + + def resolveCMakeModuleVersion(self, modulePath, cmakeModule, lowercase): + versionFile = ("%s/%s-config-version.cmake" if lowercase else "%s/%sConfigVersion.cmake") % (modulePath, cmakeModule) + f = open(versionFile, 'r') + 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.spec b/cmake.spec index 723dc18..9941ea6 100644 --- a/cmake.spec +++ b/cmake.spec @@ -13,7 +13,7 @@ Name: cmake Version: 3.2.1 -Release: 1%{?dist} +Release: 2%{?dist} Summary: Cross-platform make system Group: Development/Tools @@ -26,6 +26,9 @@ URL: http://www.cmake.org Source0: http://www.cmake.org/files/v3.2/cmake-%{version}%{?rcver}.tar.gz Source1: cmake-init.el Source2: macros.cmake +# See https://bugzilla.redhat.com/show_bug.cgi?id=1202899 +Source3: cmake.attr +Source4: cmake.prov # Patch to find DCMTK in Fedora (bug #720140) Patch0: cmake-dcmtk.patch # Patch to fix RindRuby vendor settings @@ -136,6 +139,11 @@ install -p -m 0644 %SOURCE1 %{buildroot}%{_emacs_sitestartdir}/ install -p -m0644 -D %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.cmake sed -i -e "s|@@CMAKE_VERSION@@|%{version}|" %{buildroot}%{rpm_macros_dir}/macros.cmake touch -r %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.cmake +%if 0%{?_rpmconfigdir:1} +# RPM auto provides +install -p -m0644 -D %{SOURCE3} %{buildroot}%{_prefix}/lib/rpm/fileattrs/cmake.attr +install -p -m0755 -D %{SOURCE4} %{buildroot}%{_prefix}/lib/rpm/cmake.prov +%endif mkdir -p %{buildroot}%{_libdir}/%{name} # Install copyright files for main package cp -p Copyright.txt %{buildroot}/%{_docdir}/%{name}/ @@ -191,6 +199,10 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || : %{_docdir}/%{name}/Copyright.txt* %{_docdir}/%{name}/COPYING* %{rpm_macros_dir}/macros.cmake +%if 0%{?_rpmconfigdir:1} +%{_prefix}/lib/rpm/fileattrs/cmake.attr +%{_prefix}/lib/rpm/cmake.prov +%endif %{_bindir}/ccmake %{_bindir}/cmake %{_bindir}/cpack @@ -221,6 +233,9 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || : %changelog +* Tue Mar 17 2015 Rex Dieter 3.2.1-2 +- RFE: CMake automatic RPM provides (#1202899) + * Wed Mar 11 2015 Orion Poplawski - 3.2.1-1 - Update to 3.2.1