Changeset 1922


Ignore:
Timestamp:
Jun 15, 2016, 3:50:12 PM (3 years ago)
Author:
kbut
Message:

update with upstream

File:
1 edited

Legend:

Unmodified
Added
Removed
  • germinate/trunk/fuentes/germinate/germinator.py

    r206 r1922  
    1 # -*- coding: UTF-8 -*-
     1# -*- coding: utf-8 -*-
    22"""Expand seeds into dependency-closed lists of packages."""
    33
     
    4040]
    4141
     42BUILD_DEPENDS = (
     43    "Build-Depends",
     44    "Build-Depends-Indep",
     45    "Build-Depends-Arch",
     46)
    4247
    4348_logger = logging.getLogger(__name__)
     
    446451        self._packages[pkg]["Essential"] = section.get("Essential", "")
    447452
    448         for field in "Pre-Depends", "Depends", "Recommends":
     453        for field in "Pre-Depends", "Depends", "Recommends", "Built-Using":
    449454            value = section.get(field, "")
    450             self._packages[pkg][field] = self._parse_depends(value)
     455            try:
     456                self._packages[pkg][field] = self._parse_depends(value)
     457            except ValueError:
     458                if field == "Built-Using":
     459                    _logger.error(
     460                        "Package %s has invalid Built-Using: %s", pkg, value)
     461                else:
     462                    raise
    451463
    452464        for field in "Size", "Installed-Size":
     
    570582        self._sources[src]["Version"] = ver
    571583
    572         for field in (
    573                 "Build-Depends", "Build-Depends-Indep", "Build-Depends-Arch"):
     584        for field in BUILD_DEPENDS:
    574585            value = section.get(field, "")
    575586            self._sources[src][field] = self._parse_src_depends(value)
     
    823834                        continue
    824835
    825             #pkg = pkg.split()[0]
    826             try:
    827                 pkg = pkg.split()[0]
    828             except Exception as e:
    829                 print(str(e))
    830                 pass
     836            pkg = pkg.split()[0]
     837
    831838            # a leading ! indicates a per-seed blacklist; never include this
    832839            # package in the given seed or any of its inner seeds, no matter
     
    11731180        return "follow-recommends" in structure.features
    11741181
     1182    def _follow_build_depends(self, structure, seed=None):
     1183        """
     1184        Test whether we should follow Build-Depends for this seed.
     1185        Defaults to True, if not explicitly specified.
     1186        """
     1187        if seed is not None:
     1188            if "follow-build-depends" in seed._features:
     1189                return True
     1190            if "no-follow-build-depends" in seed._features:
     1191                return False
     1192        return "no-follow-build-depends" not in structure.features
     1193
    11751194    def _add_reverse(self, pkg, field, rdep):
    11761195        """Add a reverse dependency entry."""
     
    11971216
    11981217        for src in output._all_srcs:
    1199             for field in (
    1200                     "Build-Depends", "Build-Depends-Indep",
    1201                     "Build-Depends-Arch"):
     1218            fields = ()
     1219            if self._follow_build_depends(structure):
     1220                fields = BUILD_DEPENDS
     1221            for field in fields:
    12021222                for deplist in self._sources[src][field]:
    12031223                    for dep in deplist:
     
    12151235                self._packages[pkg]["Section"] == "metapackages"):
    12161236                fields.append("Recommends")
    1217             fields.extend([
    1218                 "Build-Depends", "Build-Depends-Indep", "Build-Depends-Arch"])
     1237            fields.extend(BUILD_DEPENDS)
    12191238            for field in fields:
    12201239                if field not in self._packages[pkg]["Reverse-Depends"]:
     
    15421561
    15431562        src = self._packages[pkg]["Source"]
    1544         if src not in self._sources:
    1545             _logger.error("Missing source package: %s (for %s)", src, pkg)
    1546             return
     1563
     1564        # Built-Using field is in a form of apt_pkg.parse_depends For
     1565        # common-case "pkg (= 1)" it returns
     1566        #     [[('pkg', '1', '=')]]
     1567        # We thus unpack the first listed alternative pkg-name, for
     1568        # each built-using source.
     1569        built_using = [i[0][0] for i in self._packages[pkg]["Built-Using"]]
     1570        pkg_srcs = []
    15471571
    15481572        if second_class:
    1549             for innerseed in self._inner_seeds(seed):
    1550                 if src in innerseed._build_srcs:
    1551                     return
    1552         else:
    1553             for innerseed in self._inner_seeds(seed):
    1554                 if src in innerseed._not_build_srcs:
    1555                     return
    1556 
    1557         if build_tree:
    1558             seed._build_sourcepkgs.add(src)
    1559             if src in output._blacklist:
    1560                 seed._blacklisted.add(src)
    1561 
    1562         else:
    1563             seed._not_build_srcs.add(src)
    1564             seed._sourcepkgs.add(src)
    1565 
    1566         output._all_srcs.add(src)
    1567         seed._build_srcs.add(src)
    1568 
    1569         self._add_dependency_tree(seed, pkg,
    1570                                   self._sources[src]["Build-Depends"],
    1571                                   build_depend=True)
    1572         self._add_dependency_tree(seed, pkg,
    1573                                   self._sources[src]["Build-Depends-Indep"],
    1574                                   build_depend=True)
    1575         self._add_dependency_tree(seed, pkg,
    1576                                   self._sources[src]["Build-Depends-Arch"],
    1577                                   build_depend=True)
     1573            excluded_srcs = "_build_srcs"
     1574        else:
     1575            excluded_srcs = "_not_build_srcs"
     1576
     1577        # Create set of all sources needed for pkg: Source + Built-Using
     1578        for pkg_src in built_using + [src]:
     1579            if pkg_src in self._sources and pkg_src not in pkg_srcs:
     1580                # Consider this source unless it is already part of an inner
     1581                # seed
     1582                for innerseed in self._inner_seeds(seed):
     1583                    if pkg_src in getattr(innerseed, excluded_srcs):
     1584                        break
     1585                else:
     1586                    pkg_srcs.append(pkg_src)
     1587            else:
     1588                _logger.error("Missing source package: %s (for %s)", pkg_src, pkg)
     1589
     1590        # Use build_tree flag for src
     1591        # Treat all Built-Using as if it's part of build_tree
     1592        for pkg_src in pkg_srcs:
     1593            if build_tree or pkg_src in built_using:
     1594                seed._build_sourcepkgs.add(pkg_src)
     1595                if pkg_src in output._blacklist:
     1596                    seed._blacklisted.add(pkg_src)
     1597            else:
     1598                seed._not_build_srcs.add(pkg_src)
     1599                seed._sourcepkgs.add(pkg_src)
     1600
     1601            output._all_srcs.add(pkg_src)
     1602            seed._build_srcs.add(pkg_src)
     1603
     1604            if self._follow_build_depends(seed.structure, seed):
     1605                for build_depends in BUILD_DEPENDS:
     1606                    self._add_dependency_tree(seed, pkg,
     1607                                              self._sources[pkg_src][build_depends],
     1608                                              build_depend=True)
     1609
    15781610
    15791611    def _rescue_includes(self, structure, seedname, rescue_seedname,
     
    19671999            return
    19682000
    1969         for field in ("Pre-Depends", "Depends", "Recommends",
    1970                       "Build-Depends", "Build-Depends-Indep",
    1971                       "Build-Depends-Arch"):
     2001        for field in ("Pre-Depends", "Depends", "Recommends") + BUILD_DEPENDS:
    19722002            if field not in self._packages[pkg]["Reverse-Depends"]:
    19732003                continue
Note: See TracChangeset for help on using the changeset viewer.