RFE: CMake automatic RPM provides (#1202899)

This commit is contained in:
Rex Dieter 2015-03-17 17:41:11 -05:00
parent ca739f559d
commit de493a3f77
3 changed files with 96 additions and 1 deletions

2
cmake.attr Normal file
View File

@ -0,0 +1,2 @@
%__cmake_provides %{_rpmconfigdir}/cmake.prov
%__cmake_path ^/usr/lib(64)/cmake/.*/.*(Config\.cmake|-config\.cmake)$

78
cmake.prov Normal file
View File

@ -0,0 +1,78 @@
#!/bin/python
# -*- coding:utf-8 -*-
#
# Copyright (C) 2015 Daniel Vrátil <dvratil@redhat.com>
#
#
# 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>)
version = re.match(r"^set[\ ]*\([\ ]*PACKAGE_VERSION[\ ]+[\"]*([0-9\.]+)[\"]*[\ ]*[.]*\)", line)
if version:
return version.groups(1)[0]
return None
if __name__ == "__main__":
parser = CMakeParser()

View File

@ -13,7 +13,7 @@
Name: cmake Name: cmake
Version: 3.2.1 Version: 3.2.1
Release: 1%{?dist} Release: 2%{?dist}
Summary: Cross-platform make system Summary: Cross-platform make system
Group: Development/Tools 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 Source0: http://www.cmake.org/files/v3.2/cmake-%{version}%{?rcver}.tar.gz
Source1: cmake-init.el Source1: cmake-init.el
Source2: macros.cmake 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) # Patch to find DCMTK in Fedora (bug #720140)
Patch0: cmake-dcmtk.patch Patch0: cmake-dcmtk.patch
# Patch to fix RindRuby vendor settings # 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 install -p -m0644 -D %{SOURCE2} %{buildroot}%{rpm_macros_dir}/macros.cmake
sed -i -e "s|@@CMAKE_VERSION@@|%{version}|" %{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 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} mkdir -p %{buildroot}%{_libdir}/%{name}
# Install copyright files for main package # Install copyright files for main package
cp -p Copyright.txt %{buildroot}/%{_docdir}/%{name}/ 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}/Copyright.txt*
%{_docdir}/%{name}/COPYING* %{_docdir}/%{name}/COPYING*
%{rpm_macros_dir}/macros.cmake %{rpm_macros_dir}/macros.cmake
%if 0%{?_rpmconfigdir:1}
%{_prefix}/lib/rpm/fileattrs/cmake.attr
%{_prefix}/lib/rpm/cmake.prov
%endif
%{_bindir}/ccmake %{_bindir}/ccmake
%{_bindir}/cmake %{_bindir}/cmake
%{_bindir}/cpack %{_bindir}/cpack
@ -221,6 +233,9 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
%changelog %changelog
* Tue Mar 17 2015 Rex Dieter <rdieter@fedoraproject.org> 3.2.1-2
- RFE: CMake automatic RPM provides (#1202899)
* Wed Mar 11 2015 Orion Poplawski <orion@cora.nwra.com> - 3.2.1-1 * Wed Mar 11 2015 Orion Poplawski <orion@cora.nwra.com> - 3.2.1-1
- Update to 3.2.1 - Update to 3.2.1