Exemple #1
0
def generate_triggers(domain):
    domain_settings = domain.settings
    yield env_update()

    d = {}
    for x in ("CONFIG_PROTECT", "CONFIG_PROTECT_MASK", "COLLISION_IGNORE",
              "INSTALL_MASK", "UNINSTALL_IGNORE"):
        d[x] = domain_settings.get(x, [])
        if isinstance(d[x], basestring):
            d[x] = d[x].split()

    yield ConfigProtectInstall(d["CONFIG_PROTECT"], d["CONFIG_PROTECT_MASK"])
    yield ConfigProtectUninstall()

    features = domain_settings.get("FEATURES", ())

    if "collision-protect" in features:
        yield CollisionProtect(d["CONFIG_PROTECT"], d["CONFIG_PROTECT_MASK"],
                               d["COLLISION_IGNORE"])

    if "protect-owned" in features and "collision-protect" not in features:
        yield ProtectOwned(domain.vdb, d["CONFIG_PROTECT"],
                           d["CONFIG_PROTECT_MASK"], d["COLLISION_IGNORE"])

    if "multilib-strict" in features:
        yield register_multilib_strict_trigger(domain_settings)

    if "sfperms" in features:
        yield SFPerms()

    yield install_into_symdir_protect(d["CONFIG_PROTECT"],
                                      d["CONFIG_PROTECT_MASK"])

    for x in ("man", "info", "doc"):
        if "no%s" % x in features:
            d["INSTALL_MASK"].append("/usr/share/%s" % x)
    l = []
    for x in d["INSTALL_MASK"]:
        x = x.rstrip("/")
        l.append(values.StrRegex(fnmatch.translate(x)))
        l.append(values.StrRegex(fnmatch.translate("%s/*" % x)))
    install_mask = l

    if install_mask:
        if len(install_mask) == 1:
            install_mask = install_mask[0]
        else:
            install_mask = values.OrRestriction(*install_mask)
        yield triggers.PruneFiles(install_mask.match)
        # note that if this wipes all /usr/share/ entries, should
        # wipe the empty dir.

    yield UninstallIgnore(d["UNINSTALL_IGNORE"])
    yield InfoRegen()
Exemple #2
0
    def __iter__(self):
        yield env_update()

        yield ConfigProtectInstall(
            self.opts["CONFIG_PROTECT"], self.opts["CONFIG_PROTECT_MASK"])
        yield ConfigProtectUninstall()

        if "collision-protect" in self.domain.features:
            yield CollisionProtect(
                self.opts["CONFIG_PROTECT"], self.opts["CONFIG_PROTECT_MASK"],
                self.opts["COLLISION_IGNORE"])

        if "protect-owned" in self.domain.features and "collision-protect" not in self.domain.features:
            yield ProtectOwned(
                self.domain.installed_repos, self.opts["CONFIG_PROTECT"],
                self.opts["CONFIG_PROTECT_MASK"], self.opts["COLLISION_IGNORE"])

        if "multilib-strict" in self.domain.features:
            yield register_multilib_strict_trigger(self.opts)

        if "sfperms" in self.domain.features:
            yield SFPerms()

        yield install_into_symdir_protect(
            self.opts["CONFIG_PROTECT"], self.opts["CONFIG_PROTECT_MASK"])

        # TODO: support multiple binpkg repo targets?
        pkgdir = self.opts.get("PKGDIR", None)
        if pkgdir:
            target_repo = self.domain.binary_repos_raw.get(pkgdir, None)
        else:
            # get the highest priority binpkg repo
            try:
                target_repo = self.domain.binary_repos_raw[0]
            except IndexError:
                target_repo = None
        if target_repo is not None:
            if 'buildpkg' in self.domain.features:
                yield triggers.SavePkg(pristine='no', target_repo=target_repo)
            elif 'pristine-buildpkg' in self.domain.features:
                yield triggers.SavePkg(pristine='yes', target_repo=target_repo)
            elif 'buildsyspkg' in self.domain.features:
                yield triggers.SavePkgIfInPkgset(
                    pristine='yes', target_repo=target_repo, pkgset=self.domain.profile.system)
            elif 'unmerge-backup' in self.domain.features:
                yield triggers.SavePkgUnmerging(target_repo=target_repo)

        if 'save-deb' in self.domain.features:
            path = self.opts.get("DEB_REPO_ROOT", None)
            if path is None:
                logger.warning("disabling save-deb; DEB_REPO_ROOT is unset")
            else:
                yield ospkg.triggers.SaveDeb(
                    basepath=normpath(path), maintainer=self.opts.get("DEB_MAINAINER", ''),
                    platform=self.opts.get("DEB_ARCHITECTURE", ""))

        if 'splitdebug' in self.domain.features:
            yield triggers.BinaryDebug(mode='split', compress=('compressdebug' in self.domain.features))
        elif 'strip' in self.domain.features or 'nostrip' not in self.domain.features:
            yield triggers.BinaryDebug(mode='strip')

        if '-fixlafiles' not in self.domain.features:
            yield libtool.FixLibtoolArchivesTrigger()

        for x in ("man", "info", "doc"):
            if f"no{x}" in self.domain.features:
                self.opts["INSTALL_MASK"].append(f"/usr/share/{x}")
        l = []
        for x in self.opts["INSTALL_MASK"]:
            x = x.rstrip("/")
            l.append(values.StrRegex(fnmatch.translate(x)))
            l.append(values.StrRegex(fnmatch.translate(f"{x}/*")))
        install_mask = l

        if install_mask:
            if len(install_mask) == 1:
                install_mask = install_mask[0]
            else:
                install_mask = values.OrRestriction(*install_mask)
            yield triggers.PruneFiles(install_mask.match)
            # note that if this wipes all /usr/share/ entries, should
            # wipe the empty dir.

        yield UninstallIgnore(self.opts["UNINSTALL_IGNORE"])
        yield InfoRegen()