tools/userland-incorporator
author Petr Nyc <Petr.Nyc@Oracle.COM>
Fri, 27 Mar 2015 13:24:00 +0100
branchs11u2-sru
changeset 4027 a2e597105018
parent 3496 b38b125547c2
child 7036 9bdfcd8747ba
permissions -rwxr-xr-x
Removed tag 0.175.2..0..0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
     1
#!/usr/bin/python2.7
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     2
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     3
# CDDL HEADER START
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     4
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     5
# The contents of this file are subject to the terms of the
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     6
# Common Development and Distribution License (the "License").
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     7
# You may not use this file except in compliance with the License.
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     8
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
     9
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    10
# or http://www.opensolaris.org/os/licensing.
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    11
# See the License for the specific language governing permissions
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    12
# and limitations under the License.
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    13
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    14
# When distributing Covered Code, include this CDDL HEADER in each
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    15
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    16
# If applicable, add the following below this CDDL HEADER, with the
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    17
# fields enclosed by brackets "[]" replaced with your own identifying
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    18
# information: Portions Copyright [yyyy] [name of copyright owner]
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    19
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    20
# CDDL HEADER END
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    21
#
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    22
# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved.
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    23
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    24
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    25
# incorporator - an utility to incorporate packages in a repo
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    26
#
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    27
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    28
import subprocess
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    29
import json
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    30
import sys
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    31
import getopt
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    32
import re
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    33
import os.path
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    34
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    35
Werror = False	# set to true to exit with any warning
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    36
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    37
def warning(msg):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    38
    if Werror == True:
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    39
        print >>sys.stderr, "ERROR: %s" % msg
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    40
        sys.exit(1)
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    41
    else:
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    42
        print >>sys.stderr, "WARNING: %s" % msg
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    43
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    44
class Incorporation(object):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    45
    name = None
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    46
    version = '5.12'
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    47
    packages = {}
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    48
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    49
    def __init__(self, name, version):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    50
        self.name = name
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    51
        self.version = version
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    52
        self.packages = {}
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    53
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    54
    def __package_to_str(self, name, version):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    55
        # strip the :timestamp from the version string
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    56
        version = version.split(':', 1)[0]
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    57
        # strip the ,{build-release} from the version string
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    58
        version = re.sub(",[\d\.]+", "", version) 
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    59
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    60
        return "depend fmri=%[email protected]%s facet.version-lock.%s=true type=incorporate" % (name, version, name)
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    61
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    62
    def add_package(self, name, version):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    63
        self.packages[name] = version
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    64
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    65
    def __str__(self):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    66
        result = """
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    67
set name=pkg.fmri value=pkg:/%[email protected]%s
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    68
set name=info.classification value="org.opensolaris.category.2008:Meta Packages/Incorporations"
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    69
set name=org.opensolaris.consolidation value=userland
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    70
set name=pkg.depend.install-hold value=core-os.userland
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    71
set name=pkg.summary value="userland consolidation incorporation (%s)"
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    72
set name=pkg.description value="This incorporation constrains packages from the userland consolidation"
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    73
""" % (self.name, self.version, self.name)
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    74
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    75
        names = self.packages.keys()
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    76
        names.sort()
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    77
        for name in names:
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    78
            result += (self.__package_to_str(name, self.packages[name]) + '\n')
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    79
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    80
        return result
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    81
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    82
#
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    83
# This should probably use the pkg APIs at some point, but this appears to be
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    84
# a stable and less complicated interface to gathering information from the
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    85
# manifests in the package repo.
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    86
#
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    87
def get_incorporations(repository, publisher, inc_version='5.12'):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    88
    tmp = subprocess.Popen(["/usr/bin/pkgrepo", "list", "-F", "json",
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    89
                                                        "-s", repository,
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    90
                                                        "-p", publisher],
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    91
                           stdout=subprocess.PIPE)
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    92
    incorporations = {}
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    93
    packages = json.load(tmp.stdout)
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    94
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    95
    # Check for multiple versions of packages in the repo, but keep track of
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    96
    # the latest one.
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    97
    versions = {}
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    98
    for package in packages:
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
    99
        pkg_name = package['name']
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   100
        pkg_version = package['version']
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   101
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   102
        if pkg_name in versions:
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   103
            warning("%s is in the repo at multiple versions (%s, %s)" % (pkg_name, pkg_version, versions[pkg_name]))
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   104
            pkg_version = max(pkg_version, versions[pkg_name])
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   105
        versions[pkg_name] = pkg_version
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   106
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   107
    for package in packages:
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   108
        pkg_name = package['name']
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   109
        pkg_version = package['version']
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   110
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   111
        # skip older packages and those that don't want to be incorporated
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   112
        if 'pkg.tmp.incorporate' not in package or pkg_version != versions[pkg_name]:
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   113
            continue
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   114
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   115
        # a dict inside a list inside a dict
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   116
        incorporate = package['pkg.tmp.incorporate'][0]['value']
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   117
        
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   118
        for inc_name in incorporate:
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   119
            # if we haven't started to build this incorporation, create one.
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   120
            if inc_name not in incorporations:
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   121
                incorporations[inc_name] = Incorporation(inc_name, inc_version)
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   122
            # find the incorporation and add the package
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   123
            tmp = incorporations[inc_name]
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   124
            tmp.add_package(pkg_name, pkg_version)
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   125
    return incorporations
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   126
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   127
def main_func():
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   128
    global Werror
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   129
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   130
    try: 
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   131
        opts, pargs = getopt.getopt(sys.argv[1:], "c:s:p:v:d:w",
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   132
                                    ["repository=", "publisher=", "version=",
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   133
                                     "consolidation=", "destdir=", "Werror"])
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   134
    except getopt.GetoptError, e:
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   135
        usage(_("illegal option: %s") % e.opt)
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   136
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   137
    repository = None
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   138
    publisher = None
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   139
    version = None
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   140
    destdir = None
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   141
    consolidation = None
2855
576d5a7857b7 16404201 serialize pkglinting of components
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 830
diff changeset
   142
3496
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   143
    for opt, arg in opts:
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   144
        if opt in ("-s", "--repository"):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   145
            repository = arg
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   146
        elif opt in ("-p", "--publisher"):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   147
            publisher = arg
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   148
        elif opt in ("-v", "--version"):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   149
            version = arg
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   150
        elif opt in ("-d", "--destdir"):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   151
            destdir = arg
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   152
        elif opt in ("-c", "--consolidation"):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   153
            consolidation = arg
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   154
        elif opt in ("-w", "--Werror"):
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   155
            Werror = True
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   156
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   157
    incorporations = get_incorporations(repository, publisher, version)
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   158
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   159
    for incorporation_name in incorporations.keys():
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   160
        filename = ''
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   161
        if destdir != None:
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   162
            filename = destdir + '/'
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   163
        filename += os.path.basename(incorporation_name) + '.p5m'
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   164
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   165
        print("Writing %s manifest to %s" % (incorporation_name, filename))
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   166
        fd = open(filename, "w+")
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   167
        fd.write(str(incorporations[incorporation_name]))
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   168
        fd.close()
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   169
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   170
if __name__ == "__main__":
b38b125547c2 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 2855
diff changeset
   171
    main_func()