Fix ambiguous file lookup in cmake.prov

Don't use glob to lookup cmake config file, because there can
be multiple matches and we might accidentally pick the wrong one.
Instead just work with the filepath passed to us via stdin.
This commit is contained in:
Rex Dieter 2017-02-20 10:17:02 -06:00
parent 72646fef46
commit 8f3879e81d
2 changed files with 11 additions and 15 deletions

View File

@ -2,6 +2,7 @@
# -*- coding:utf-8 -*-
#
# Copyright (C) 2015 Daniel Vrátil <dvratil@redhat.com>
# Copyright (C) 2017 Daniel Vrátil <dvratil@fedoraproject.org>
#
#
# This program is free software; you can redistribute it and/or modify
@ -45,21 +46,13 @@ class CMakeParser:
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, None)
if lowercase:
moduleName = configFile[0][len(modulePath) + 1:-len("-config.cmake")]
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:
moduleName = configFile[0][len(modulePath) + 1:-len("Config.cmake")]
return (modulePath, moduleName, lowercase)
return (None, None, False)
def resolveCMakeModuleVersion(self, modulePath, cmakeModule, lowercase):
versionFile = ("%s/%s-config-version.cmake" if lowercase else "%s/%sConfigVersion.cmake") % (modulePath, cmakeModule)

View File

@ -43,7 +43,7 @@
Name: %{orig_name}%{?name_suffix}
Version: %{major_version}.%{minor_version}.2
Release: 2%{?dist}
Release: 3%{?dist}
Summary: Cross-platform make system
# most sources are BSD
@ -399,6 +399,9 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
%changelog
* Mon Feb 20 2017 Rex Dieter <rdieter@fedoraproject.org> - 3.7.2-3
- Fix ambiguous file lookup in cmake.prov
* Thu Feb 9 2017 Orion Poplawski <orion@cora.nwra.com> - 3.7.2-2
- Fix cmake.prov error