| | |
| | | #!/usr/bin/python2.6 |
| | | #!/usr/bin/python3.9 |
| | | # |
| | | # CDDL HEADER START |
| | | # |
| | |
| | | import getopt |
| | | import re |
| | | import os.path |
| | | from pkg.version import Version |
| | | |
| | | Werror = False # set to true to exit with any warning |
| | | Werror = False # set to true to exit with any warning |
| | | |
| | | def warning(msg): |
| | | if Werror == True: |
| | | print >>sys.stderr, "ERROR: %s" % msg |
| | | print("ERROR: %s" % msg, file=sys.stderr) |
| | | sys.exit(1) |
| | | else: |
| | | print >>sys.stderr, "WARNING: %s" % msg |
| | | print("WARNING: %s" % msg, file=sys.stderr) |
| | | |
| | | class Incorporation(object): |
| | | name = None |
| | |
| | | |
| | | def __package_to_str(self, name, version): |
| | | # strip the :timestamp from the version string |
| | | # version = version.split(':', 1)[0] |
| | | version = version.split(':', 1)[0] |
| | | # strip the ,{build-release} from the version string |
| | | # version = re.sub(",[\d\.]+", "", version) |
| | | version = re.sub(",[\d\.]+", "", version) |
| | | |
| | | return "depend fmri=%s@%s facet.version-lock.%s=true type=incorporate" % (name, version, name) |
| | | |
| | |
| | | set name=pkg.description value="This incorporation constrains packages from the userland consolidation" |
| | | """ % (self.name, self.version, self.name) |
| | | |
| | | names = self.packages.keys() |
| | | names = list(self.packages.keys()) |
| | | names.sort() |
| | | for name in names: |
| | | result += (self.__package_to_str(name, self.packages[name]) + '\n') |
| | |
| | | tmp = subprocess.Popen(["/usr/bin/pkgrepo", "list", "-F", "json", |
| | | "-s", repository, |
| | | "-p", publisher], |
| | | stdout=subprocess.PIPE) |
| | | stdout=subprocess.PIPE, |
| | | universal_newlines=True) |
| | | incorporations = {} |
| | | packages = json.load(tmp.stdout) |
| | | inc_name='consolidation/userland/userland-incorporation' |
| | | |
| | | # Check for multiple versions of packages in the repo, but keep track of |
| | | # the latest one. |
| | |
| | | |
| | | if pkg_name in versions: |
| | | warning("%s is in the repo at multiple versions (%s, %s)" % (pkg_name, pkg_version, versions[pkg_name])) |
| | | pkg_version = max(pkg_version, versions[pkg_name]) |
| | | if(Version(package['version']) < Version(versions[pkg_name])): |
| | | pkg_version = versions[pkg_name] |
| | | versions[pkg_name] = pkg_version |
| | | |
| | | for package in packages: |
| | |
| | | pkg_version = package['version'] |
| | | |
| | | # skip older packages and those that explicitly don't want to be incorporated |
| | | if 'pkg.tmp.noincorporate' in package or pkg_version != versions[pkg_name]: |
| | | continue |
| | | # also skip the incorporation itself |
| | | if 'pkg.tmp.noincorporate' in package or pkg_version != versions[pkg_name] or pkg_name == inc_name: |
| | | continue |
| | | |
| | | # We don't want to support multiple incorporations for now |
| | | # We don't want to support multiple incorporations for now |
| | | # a dict inside a list inside a dict |
| | | # incorporate = package['pkg.tmp.incorporate'][0]['value'] |
| | | |
| | | inc_name='consolidation/userland/userland-incorporation' |
| | | # for inc_name in incorporate: |
| | | # if we haven't started to build this incorporation, create one. |
| | | if inc_name not in incorporations: |
| | |
| | | opts, pargs = getopt.getopt(sys.argv[1:], "c:s:p:v:d:w", |
| | | ["repository=", "publisher=", "version=", |
| | | "consolidation=", "destdir=", "Werror"]) |
| | | except getopt.GetoptError, e: |
| | | except getopt.GetoptError as e: |
| | | usage(_("illegal option: %s") % e.opt) |
| | | |
| | | repository = None |
| | |
| | | |
| | | incorporations = get_incorporations(repository, publisher, version) |
| | | |
| | | for incorporation_name in incorporations.keys(): |
| | | for incorporation_name in list(incorporations.keys()): |
| | | filename = '' |
| | | if destdir != None: |
| | | filename = destdir + '/' |