コード例 #1
0
    def add(cls,
            user,
            pkgs,
            copr,
            repos=None,
            chroots=None,
            memory_reqs=None,
            timeout=None,
            enable_net=True):
        if chroots is None:
            chroots = []
        coprs_logic.CoprsLogic.raise_if_unfinished_blocking_action(
            user, copr,
            "Can't build while there is an operation in progress: {action}")
        users_logic.UsersLogic.raise_if_cant_build_in_copr(
            user, copr, "You don't have permissions to build in this copr.")

        if not repos:
            repos = copr.repos

        if " " in pkgs or "\n" in pkgs or "\t" in pkgs or pkgs.strip() != pkgs:
            raise exceptions.MalformedArgumentException(
                "Trying to create a build using src_pkg "
                "with bad characters. Forgot to split?")

        build = models.Build(
            user=user,
            pkgs=pkgs,
            copr=copr,
            repos=repos,
            submitted_on=int(time.time()),
            enable_net=bool(enable_net),
        )

        if memory_reqs:
            build.memory_reqs = memory_reqs

        if timeout:
            build.timeout = timeout or DEFAULT_BUILD_TIMEOUT

        db.session.add(build)

        # add BuildChroot object for each active (or selected) chroot
        # this copr is assigned to
        if not chroots:
            chroots = copr.active_chroots

        for chroot in chroots:
            buildchroot = models.BuildChroot(build=build, mock_chroot=chroot)

            db.session.add(buildchroot)

        return build
コード例 #2
0
    def tuple_from_name(cls, user, name, noarch=False):
        """
        input should be os-version-architecture, e.g. fedora-rawhide-x86_64

        the architecture could be optional with noarch=True

        returns ("os", "version", "arch") or ("os", "version", None)
        """
        split_name = name.split("-")
        valid = False
        if noarch and len(split_name) in [2, 3]:
            valid = True
        if not noarch and len(split_name) == 3:
            valid = True

        if not valid:
            raise exceptions.MalformedArgumentException(
                "Chroot name is not valid")

        if noarch and len(split_name) == 2:
            split_name.append(None)

        return tuple(split_name)
コード例 #3
0
ファイル: builds_logic.py プロジェクト: nos1609/copr
    def add(cls,
            user,
            pkgs,
            copr,
            source_type=None,
            source_json=None,
            repos=None,
            chroots=None,
            timeout=None,
            enable_net=True,
            git_hashes=None,
            skip_import=False):
        if chroots is None:
            chroots = []

        coprs_logic.CoprsLogic.raise_if_unfinished_blocking_action(
            copr,
            "Can't build while there is an operation in progress: {action}")
        users_logic.UsersLogic.raise_if_cant_build_in_copr(
            user, copr, "You don't have permissions to build in this copr.")

        if not repos:
            repos = copr.repos

        # todo: eliminate pkgs and this check
        if " " in pkgs or "\n" in pkgs or "\t" in pkgs or pkgs.strip() != pkgs:
            raise exceptions.MalformedArgumentException(
                "Trying to create a build using src_pkg "
                "with bad characters. Forgot to split?")

        # just temporary to keep compatibility
        if not source_type or not source_json:
            source_type = helpers.BuildSourceEnum("srpm_link")
            source_json = json.dumps({"url": pkgs})

        build = models.Build(
            user=user,
            pkgs=pkgs,
            copr=copr,
            repos=repos,
            source_type=source_type,
            source_json=source_json,
            submitted_on=int(time.time()),
            enable_net=bool(enable_net),
        )

        if timeout:
            build.timeout = timeout or DEFAULT_BUILD_TIMEOUT

        db.session.add(build)

        # add BuildChroot object for each active (or selected) chroot
        # this copr is assigned to
        if not chroots:
            chroots = copr.active_chroots

        status = helpers.StatusEnum("importing")

        if skip_import:
            status = StatusEnum("pending")

        for chroot in chroots:
            git_hash = None
            if git_hashes:
                git_hash = git_hashes.get(chroot.name)
            buildchroot = models.BuildChroot(build=build,
                                             status=status,
                                             mock_chroot=chroot,
                                             git_hash=git_hash)

            db.session.add(buildchroot)

        return build