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