Mini Shell
Direktori : /lib/rpm/ |
|
Current File : //lib/rpm/osgi.req |
#!/usr/libexec/platform-python
# Copyright (c) 2014, Red Hat, Inc.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the
# distribution.
# 3. Neither the name of Red Hat nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#
# Authors: Alexander Kurtakov <akurtako@redhat.com>
# Michal Srb <msrb@redhat.com>
import sys
import os
import traceback
from javapackages.cache.osgi import OSGiCache
from javapackages.common.util import kill_parent_process, init_rpmgen, get_logger
_log = get_logger("osgi.req")
class TagBuilder(object):
def __init__(self, filelist=None):
if filelist is None:
filelist = sys.stdin
paths = [x.rstrip() for x in filelist.readlines()]
_log.info("input: {fl}".format(fl=paths))
cache = OSGiCache(rpmconf)
requires = []
for path in paths:
# symlinks are not interesting, skip them
if os.path.islink(path):
continue
# check if OSGi requires for this path were handled by metadata
# if so, move on
if cache.check_path_in_metadata(path):
continue
bundle = cache.get_bundle_for_path(path)
if not bundle:
continue
for req in bundle.requires:
prov = cache.get_bundle(req.bundle)
if prov:
requires.append(req.get_rpm_str(version=prov.version))
else:
requires.append(req.get_rpm_str())
if requires:
_log.info(", ".join(requires))
print("\n".join(requires))
if __name__ == "__main__":
rpmconf = None
try:
rpmconf = init_rpmgen(sys.argv)
# this dependency generator should never run in SCL environment.
# but check it, just in case...
if rpmconf.scl:
raise Exception("{name} dependency generator doesn't support SCLs"
.format(name=os.path.basename(__file__)))
builder = TagBuilder()
except Exception:
traceback.print_exc(file=sys.stderr)
kill_parent_process(rpmconf)
# Local Variables:
# mode: Python
# End:
# vi: ft=python
Zerion Mini Shell 1.0