From 8f3879e81d29e7bec1ea55320df765491fd4565e Mon Sep 17 00:00:00 2001 From: Rex Dieter Date: Mon, 20 Feb 2017 10:17:02 -0600 Subject: [PATCH] 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. --- cmake.prov | 21 +++++++-------------- cmake.spec | 5 ++++- 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/cmake.prov b/cmake.prov index 182cd87..f569c23 100644 --- a/cmake.prov +++ b/cmake.prov @@ -2,6 +2,7 @@ # -*- 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 @@ -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) diff --git a/cmake.spec b/cmake.spec index d8a71c5..23847f6 100644 --- a/cmake.spec +++ b/cmake.spec @@ -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 - 3.7.2-3 +- Fix ambiguous file lookup in cmake.prov + * Thu Feb 9 2017 Orion Poplawski - 3.7.2-2 - Fix cmake.prov error