tools/userland-incorporator
author Rich Burridge <rich.burridge@oracle.com>
Sat, 09 May 2015 12:45:23 -0700
changeset 4266 bcfdeff915c4
parent 2142 813e4817e573
child 5571 bd6c9b9b753f
permissions -rwxr-xr-x
21056705 libgsl needs to deliver both 32-bit and 64-bit gsl-config scripts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
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
#
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
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
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    28
import subprocess
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    29
import json
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    30
import sys
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    31
import getopt
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    32
import re
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
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
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
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
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    37
def warning(msg):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    38
    if Werror == True:
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    39
        print >>sys.stderr, "ERROR: %s" % msg
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    40
        sys.exit(1)
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    41
    else:
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
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
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    44
class Incorporation(object):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    45
    name = None
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    46
    version = '5.12'
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    47
    packages = {}
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    48
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    49
    def __init__(self, name, version):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    50
        self.name = name
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    51
        self.version = version
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    52
        self.packages = {}
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
    53
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    54
    def __package_to_str(self, name, version):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    55
        # strip the :timestamp from the version string
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    56
        version = version.split(':', 1)[0]
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    57
        # strip the ,{build-release} from the version string
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
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
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
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
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    62
    def add_package(self, name, version):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
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
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    65
    def __str__(self):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    66
        result = """
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    67
set name=pkg.fmri value=pkg:/%[email protected]%s
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    68
set name=info.classification value="org.opensolaris.category.2008:Meta Packages/Incorporations"
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    69
set name=org.opensolaris.consolidation value=userland
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    70
set name=pkg.depend.install-hold value=core-os.userland
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    71
set name=pkg.summary value="userland consolidation incorporation (%s)"
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    72
set name=pkg.description value="This incorporation constrains packages from the userland consolidation"
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
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
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    75
        names = self.packages.keys()
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    76
        names.sort()
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    77
        for name in names:
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
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
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
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
#
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    83
# This should probably use the pkg APIs at some point, but this appears to be
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    84
# a stable and less complicated interface to gathering information from the
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
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
#
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    87
def get_incorporations(repository, publisher, inc_version='5.12'):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    88
    tmp = subprocess.Popen(["/usr/bin/pkgrepo", "list", "-F", "json",
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    89
                                                        "-s", repository,
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    90
                                                        "-p", publisher],
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    91
                           stdout=subprocess.PIPE)
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    92
    incorporations = {}
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    93
    packages = json.load(tmp.stdout)
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    94
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    95
    # Check for multiple versions of packages in the repo, but keep track of
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    96
    # the latest one.
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    97
    versions = {}
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    98
    for package in packages:
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
    99
        pkg_name = package['name']
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   100
        pkg_version = package['version']
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   101
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   102
        if pkg_name in versions:
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   103
            warning("%s is in the repo at multiple versions (%s, %s)" % (pkg_name, pkg_version, versions[pkg_name]))
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   104
            pkg_version = max(pkg_version, versions[pkg_name])
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   105
        versions[pkg_name] = pkg_version
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   106
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   107
    for package in packages:
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   108
        pkg_name = package['name']
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   109
        pkg_version = package['version']
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   110
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   111
        # skip older packages and those that don't want to be incorporated
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   112
        if 'pkg.tmp.incorporate' not in package or pkg_version != versions[pkg_name]:
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   113
            continue
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   114
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   115
        # a dict inside a list inside a dict
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   116
        incorporate = package['pkg.tmp.incorporate'][0]['value']
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   117
        
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   118
        for inc_name in incorporate:
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   119
            # if we haven't started to build this incorporation, create one.
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   120
            if inc_name not in incorporations:
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   121
                incorporations[inc_name] = Incorporation(inc_name, inc_version)
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   122
            # find the incorporation and add the package
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   123
            tmp = incorporations[inc_name]
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   124
            tmp.add_package(pkg_name, pkg_version)
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   125
    return incorporations
500
3d451539794b 7064724 userland should deliver a consolidation incorporation
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents:
diff changeset
   126
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   127
def main_func():
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   128
    global Werror
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   129
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   130
    try: 
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   131
        opts, pargs = getopt.getopt(sys.argv[1:], "c:s:p:v:d:w",
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   132
                                    ["repository=", "publisher=", "version=",
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   133
                                     "consolidation=", "destdir=", "Werror"])
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   134
    except getopt.GetoptError, e:
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   135
        usage(_("illegal option: %s") % e.opt)
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   136
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   137
    repository = None
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   138
    publisher = None
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   139
    version = None
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   140
    destdir = None
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   141
    consolidation = None
1591
24aca88f3e99 17852021 userland-incorporator should detect duplicate packages
Mike Sullivan <Mike.Sullivan@Oracle.COM>
parents: 1517
diff changeset
   142
2142
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   143
    for opt, arg in opts:
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   144
        if opt in ("-s", "--repository"):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   145
            repository = arg
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   146
        elif opt in ("-p", "--publisher"):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   147
            publisher = arg
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   148
        elif opt in ("-v", "--version"):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   149
            version = arg
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   150
        elif opt in ("-d", "--destdir"):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   151
            destdir = arg
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   152
        elif opt in ("-c", "--consolidation"):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   153
            consolidation = arg
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   154
        elif opt in ("-w", "--Werror"):
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   155
            Werror = True
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   156
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   157
    incorporations = get_incorporations(repository, publisher, version)
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   158
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   159
    for incorporation_name in incorporations.keys():
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   160
        filename = ''
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   161
        if destdir != None:
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   162
            filename = destdir + '/'
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   163
        filename += os.path.basename(incorporation_name) + '.p5m'
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   164
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   165
        print("Writing %s manifest to %s" % (incorporation_name, filename))
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   166
        fd = open(filename, "w+")
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   167
        fd.write(str(incorporations[incorporation_name]))
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   168
        fd.close()
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   169
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   170
if __name__ == "__main__":
813e4817e573 18139749 userland-incorporator should allow generation of multiple incorporations
Norm Jacobs <Norm.Jacobs@Oracle.COM>
parents: 1591
diff changeset
   171
    main_func()