|
|
626dd7 |
#!/usr/bin/python3
|
|
|
411bbd |
# -*- coding:utf-8 -*-
|
|
|
411bbd |
#
|
|
|
411bbd |
# Copyright (C) 2017 Björn Esser <besser82@fedoraproject.org>
|
|
|
411bbd |
#
|
|
|
411bbd |
# based on cmake.prov, which is
|
|
|
411bbd |
# Copyright (C) 2015 Daniel Vrátil <dvratil@redhat.com>
|
|
|
411bbd |
# Copyright (C) 2017 Daniel Vrátil <dvratil@fedoraproject.org>
|
|
|
411bbd |
#
|
|
|
411bbd |
#
|
|
|
411bbd |
# This program is free software; you can redistribute it and/or modify
|
|
|
411bbd |
# it under the terms of the GNU Library General Public License as
|
|
|
411bbd |
# published by the Free Software Foundation; either version 2 of the
|
|
|
411bbd |
# License, or (at your option) any later version.
|
|
|
411bbd |
#
|
|
|
411bbd |
# This program is distributed in the hope that it will be useful,
|
|
|
411bbd |
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
411bbd |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
411bbd |
# GNU General Public License for more details.
|
|
|
411bbd |
#
|
|
|
411bbd |
# You should have received a copy of the GNU Library General Public
|
|
|
411bbd |
# License along with this program; if not, write to the
|
|
|
411bbd |
# Free Software Foundation, Inc.,
|
|
|
411bbd |
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
411bbd |
#
|
|
|
411bbd |
|
|
|
411bbd |
import sys
|
|
|
411bbd |
import re
|
|
|
411bbd |
import subprocess
|
|
|
411bbd |
|
|
|
411bbd |
class CMakeParser:
|
|
|
411bbd |
def __init__(self, filelist = None):
|
|
|
411bbd |
if filelist == None:
|
|
|
411bbd |
filelist = sys.stdin
|
|
|
411bbd |
|
|
|
411bbd |
has_module = False
|
|
|
411bbd |
is_arched = False
|
|
|
411bbd |
|
|
|
411bbd |
isa_suf = subprocess.check_output(["/usr/bin/rpm", "-E %{?_isa}"]).decode().strip()
|
|
|
411bbd |
|
|
|
411bbd |
paths = map(lambda x: x.rstrip(), filelist.readlines())
|
|
|
411bbd |
for path in paths:
|
|
|
411bbd |
modulePath, cmakeModule, lowercase = self.parseCmakeModuleConfig(path)
|
|
|
411bbd |
if modulePath and cmakeModule:
|
|
|
411bbd |
has_module = True
|
|
|
411bbd |
if re.match(".*/usr/lib(64)?/cmake/.*", modulePath):
|
|
|
411bbd |
is_arched = True
|
|
|
411bbd |
|
|
|
411bbd |
if has_module:
|
|
|
411bbd |
if is_arched:
|
|
|
411bbd |
print("cmake-filesystem%s" % isa_suf)
|
|
|
411bbd |
else:
|
|
|
411bbd |
print("cmake-filesystem")
|
|
|
411bbd |
|
|
|
411bbd |
|
|
|
411bbd |
def parseCmakeModuleConfig(self, configFile):
|
|
|
411bbd |
paths = configFile.rsplit("/", 3)
|
|
|
411bbd |
|
|
|
411bbd |
modulePath = "%s/cmake/%s" % (paths[0], paths[2])
|
|
|
411bbd |
cfgFile = paths[3]
|
|
|
411bbd |
if cfgFile.endswith("Config.cmake"):
|
|
|
411bbd |
return (modulePath, cfgFile[0:-len("Config.cmake")], False)
|
|
|
411bbd |
elif cfgFile.endswith("-config.cmake"):
|
|
|
411bbd |
return (modulePath, cfgFile[0:-len("-config.cmake")], True)
|
|
|
411bbd |
else:
|
|
|
411bbd |
return (None, None, False)
|
|
|
411bbd |
|
|
|
411bbd |
|
|
|
411bbd |
if __name__ == "__main__":
|
|
|
411bbd |
parser = CMakeParser()
|