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 -*- # -*- coding:utf-8 -*-
# #
# Copyright (C) 2015 Daniel Vrátil <dvratil@redhat.com> # 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 # This program is free software; you can redistribute it and/or modify
@ -45,21 +46,13 @@ class CMakeParser:
paths = configFile.rsplit("/", 3) paths = configFile.rsplit("/", 3)
modulePath = "%s/cmake/%s" % (paths[0], paths[2]) modulePath = "%s/cmake/%s" % (paths[0], paths[2])
cfgFile = paths[3]
lowercase = False if cfgFile.endswith("Config.cmake"):
configFile = glob.glob("%s/*Config.cmake" % modulePath) return (modulePath, cfgFile[0:-len("Config.cmake")], False)
if not configFile: elif cfgFile.endswith("-config.cmake"):
configFile = glob.glob("%s/*-config.cmake" % modulePath) return (modulePath, cfgFile[0:-len("-config.cmake")], True)
lowercase = True
if not configFile:
return (None, None, None)
if lowercase:
moduleName = configFile[0][len(modulePath) + 1:-len("-config.cmake")]
else: else:
moduleName = configFile[0][len(modulePath) + 1:-len("Config.cmake")] return (None, None, False)
return (modulePath, moduleName, lowercase)
def resolveCMakeModuleVersion(self, modulePath, cmakeModule, lowercase): def resolveCMakeModuleVersion(self, modulePath, cmakeModule, lowercase):
versionFile = ("%s/%s-config-version.cmake" if lowercase else "%s/%sConfigVersion.cmake") % (modulePath, cmakeModule) 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} Name: %{orig_name}%{?name_suffix}
Version: %{major_version}.%{minor_version}.2 Version: %{major_version}.%{minor_version}.2
Release: 2%{?dist} Release: 3%{?dist}
Summary: Cross-platform make system Summary: Cross-platform make system
# most sources are BSD # most sources are BSD
@ -399,6 +399,9 @@ update-mime-database %{?fedora:-n} %{_datadir}/mime &> /dev/null || :
%changelog %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 * Thu Feb 9 2017 Orion Poplawski <orion@cora.nwra.com> - 3.7.2-2
- Fix cmake.prov error - Fix cmake.prov error