userland-incorporator revision 5569
71bd43eebd9d6e42dbcae62b730f5b6508d5acd8Automatic Updater# CDDL HEADER START
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater# The contents of this file are subject to the terms of the
2bb3422dc683c013db7042f5736240de6b86f182Automatic Updater# Common Development and Distribution License (the "License").
0bddff542cf2ae1b6595020f2f72ca482c6b438fAutomatic Updater# You may not use this file except in compliance with the License.
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
bb93c8542756719b53096b9939e4041d0966026fAutomatic Updater# or http://www.opensolaris.org/os/licensing.
c89d02f2fb4c06168236d600e86831cff324f763Mark Andrews# See the License for the specific language governing permissions
90ff38a0d8deaf5f9c2aa5916d99b2e572d28738Automatic Updater# and limitations under the License.
ac4e70ff8955669341f435bc0a734a17c01af124Mark Andrews# When distributing Covered Code, include this CDDL HEADER in each
6c6a121295b30772cbf3dd75a51fb9d883051a0eAutomatic Updater# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
9e3a7b0faf417a10f5f689edf288807b2d5eedc5Brian Wellington# If applicable, add the following below this CDDL HEADER, with the
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater# fields enclosed by brackets "[]" replaced with your own identifying
bc0a53583d92309bebcf93c408e2f3247ebd3d3cAutomatic Updater# information: Portions Copyright [yyyy] [name of copyright owner]
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews# CDDL HEADER END
4b2cb1422c7c600fbc13b1cb06a8b4693bc11af8Mark Andrews# Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved.
96713299d08c0735c18ebe8772dd2cc1ecd4356aAutomatic Updater# incorporator - an utility to incorporate packages in a repo
aa1d397c4736cd86540555193d71e55fa3b37b2aMark AndrewsWerror = False # set to true to exit with any warning
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic Updater def __package_to_str(self, name, version):
cdfc81e048bd34c1d628380247bda6b80a89e20eAutomatic Updater # strip the :timestamp from the version string
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater # strip the ,{build-release} from the version string
eabc9c3c07cd956d3c436bd7614cb162dabdda76Mark Andrews return "depend fmri=%s@%s facet.version-lock.%s=true type=incorporate" % (name, version, name)
80faf1588895fd26490f82f95a7a1b771df1c324Automatic Updaterset name=pkg.fmri value=pkg:/%s@%s
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsset name=info.classification value="org.opensolaris.category.2008:Meta Packages/Incorporations"
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updaterset name=org.opensolaris.consolidation value=userland
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrewsset name=pkg.depend.install-hold value=core-os.userland
db5b7e2cdf150c46e8242d3e2e3ad3f5c7300258Automatic Updaterset name=pkg.summary value="userland consolidation incorporation (%s)"
80faf1588895fd26490f82f95a7a1b771df1c324Automatic Updaterset name=pkg.description value="This incorporation constrains packages from the userland consolidation"
c651f15b30f1dae5cc2f00878fb5da5b3a35a468Mark Andrews result += (self.__package_to_str(name, self.packages[name]) + '\n')
efb0e886f18894a1d2489f1ad74ad14b579e11c7Mark Andrews# This should probably use the pkg APIs at some point, but this appears to be
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrews# a stable and less complicated interface to gathering information from the
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson# manifests in the package repo.
aa1d397c4736cd86540555193d71e55fa3b37b2aMark Andrewsdef get_incorporations(repository, publisher, inc_version='5.12',
9174e44c14b1cb91a651fa1dc29470438c246ab9Automatic Updater # if a static file was provided, prime the cache with the contents of
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater (incorporation, package, version) = re.split(':|@', line)
885f47576842cf3c569315b9a48bd9f0ca03f203Automatic Updater incorporations[incorporation] = Incorporation(incorporation, inc_version)
ae7e54b14c946e0984c191554db9abb4893f9349Automatic Updater # find the incorporation and add the package
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updater # Load the repository for packages to incorporate.
fe80a4909bf62b602feaf246866e9d29f7654194Automatic Updater tmp = subprocess.Popen(["/usr/bin/pkgrepo", "list", "-F", "json",
91216cff91b34c9ff6e846dc23f248219cafe660Andreas Gustafsson # Check for multiple versions of packages in the repo, but keep track of
dd65eb1efb40b1c47d57963192bfc54873b219beAutomatic Updater # the latest one.
0df8ead472f207020f8da22a185fe4b945248ab8Automatic Updater warning("%s is in the repo at multiple versions (%s, %s)" % (pkg_name, pkg_version, versions[pkg_name]))
e8c7dc2a5ce48f11c07a67c9923eeb8f419ff19fEvan Hunt pkg_version = max(pkg_version, versions[pkg_name])
2bb3422dc683c013db7042f5736240de6b86f182Automatic Updater # Add published packages to the incorporation lists
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater # skip older packages and those that don't want to be incorporated
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater if 'pkg.tmp.incorporate' not in package or pkg_version != versions[pkg_name]:
0df8ead472f207020f8da22a185fe4b945248ab8Automatic Updater # a dict inside a list inside a dict
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater incorporate = package['pkg.tmp.incorporate'][0]['value']
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater # if we haven't started to build this incorporation, create one.
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater incorporations[inc_name] = Incorporation(inc_name, inc_version)
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater # find the incorporation and add the package
9513a2a6670951f5cf5477fcfec9f933fcaff628Automatic Updater opts, pargs = getopt.getopt(sys.argv[1:], "S:c:s:p:v:d:w",
4cda4fd158d6ded5586bacea8c388445d99611eaAutomatic Updater if opt in ("-S", "--static-content-file"):
7f94d9a8162c9a96b56e66176702b66e79d8e1a2Automatic Updater incorporations = get_incorporations(repository, publisher, version,
ce9cad6bb04869c5e94d9dc721032b25117f9210Automatic Updater for incorporation_name in incorporations.keys():
7eda3642eea03f1181e41540c7c8791a57759383Automatic Updater filename += os.path.basename(incorporation_name) + '.p5m'
59528addd704f8d5757b54e540520f74e588a7c7Automatic Updater print("Writing %s manifest to %s" % (incorporation_name, filename))