Exemplo n.º 1
0
    def add(cls,
            user,
            name,
            selected_chroots,
            repos=None,
            description=None,
            instructions=None,
            check_for_duplicates=False,
            group=None,
            **kwargs):
        copr = models.Copr(name=name,
                           repos=repos or u"",
                           owner_id=user.id,
                           description=description or u"",
                           instructions=instructions or u"",
                           created_on=int(time.time()),
                           **kwargs)

        if group is not None:
            UsersLogic.raise_if_not_in_group(user, group)
            copr.group = group

        # form validation checks for duplicates
        CoprsLogic.new(user, copr, check_for_duplicates=check_for_duplicates)
        CoprChrootsLogic.new_from_names(copr, selected_chroots)

        db.session.flush()
        ActionsLogic.send_create_gpg_key(copr)

        return copr
Exemplo n.º 2
0
    def add(cls,
            user,
            name,
            selected_chroots,
            repos=None,
            description=None,
            instructions=None,
            check_for_duplicates=False,
            group=None,
            persistent=False,
            auto_prune=True,
            use_bootstrap_container=False,
            follow_fedora_branching=False,
            **kwargs):

        if not user.admin and persistent:
            raise exceptions.NonAdminCannotCreatePersistentProject()

        if not user.admin and not auto_prune:
            raise exceptions.NonAdminCannotDisableAutoPrunning()

        # form validation checks for duplicates
        cls.new(user, name, group, check_for_duplicates=check_for_duplicates)

        copr = models.Copr(name=name,
                           repos=repos or u"",
                           user=user,
                           description=description or u"",
                           instructions=instructions or u"",
                           created_on=int(time.time()),
                           persistent=persistent,
                           auto_prune=auto_prune,
                           use_bootstrap_container=use_bootstrap_container,
                           follow_fedora_branching=follow_fedora_branching,
                           **kwargs)

        if group is not None:
            UsersLogic.raise_if_not_in_group(user, group)
            copr.group = group

        copr_dir = models.CoprDir(main=True, name=name, copr=copr)

        db.session.add(copr_dir)
        db.session.add(copr)

        CoprChrootsLogic.new_from_names(copr, selected_chroots)

        db.session.flush()
        ActionsLogic.send_create_gpg_key(copr)

        return copr
Exemplo n.º 3
0
    def fork_copr(cls, copr, user, dstname, dstgroup=None):
        forking = ProjectForking(user, dstgroup)
        fcopr = forking.fork_copr(copr, dstname)
        created = fcopr in db.session.new

        if fcopr.full_name == copr.full_name:
            raise exceptions.DuplicateException("Source project should not be same as destination")

        builds_map = {}
        for package in copr.packages:
            fpackage = forking.fork_package(package, fcopr)
            build = package.last_build()
            if not build:
                continue

            fbuild = forking.fork_build(build, fcopr, fpackage)
            builds_map[fbuild.id] = build.result_dir_name

        ActionsLogic.send_create_gpg_key(fcopr)
        ActionsLogic.send_fork_copr(copr, fcopr, builds_map)
        return fcopr, created
Exemplo n.º 4
0
    def fork_copr(cls, copr, user, dstname, dstgroup=None):
        forking = ProjectForking(user, dstgroup)
        created = (not bool(forking.get(copr, dstname)))
        fcopr = forking.fork_copr(copr, dstname)

        if fcopr.full_name == copr.full_name:
            raise exceptions.DuplicateException(
                "Source project should not be same as destination")

        builds_map = {}
        for package in copr.packages:
            fpackage = forking.fork_package(package, fcopr)
            build = package.last_build()
            if not build:
                continue

            fbuild = forking.fork_build(build, fcopr, fpackage)
            builds_map[fbuild.id] = build.result_dir_name

        ActionsLogic.send_create_gpg_key(fcopr)
        ActionsLogic.send_fork_copr(copr, fcopr, builds_map)
        return fcopr, created
Exemplo n.º 5
0
    def add(cls, user, name, selected_chroots, repos=None, description=None,
            instructions=None, check_for_duplicates=False, group=None, **kwargs):
        copr = models.Copr(name=name,
                           repos=repos or u"",
                           user_id=user.id,
                           description=description or u"",
                           instructions=instructions or u"",
                           created_on=int(time.time()),
                           **kwargs)

        if group is not None:
            UsersLogic.raise_if_not_in_group(user, group)
            copr.group = group

        # form validation checks for duplicates
        cls.new(user, copr, check_for_duplicates=check_for_duplicates)
        CoprChrootsLogic.new_from_names(copr, selected_chroots)

        db.session.flush()
        ActionsLogic.send_create_gpg_key(copr)

        return copr
Exemplo n.º 6
0
#!/usr/bin/python
import sys
sys.path.append("/usr/share/copr/coprs_frontend")
from coprs.logic.actions_logic import ActionsLogic
from coprs.logic.coprs_logic import CoprsLogic
from coprs import db

USER = "******"
PROJECT = "someproject"
fcopr = CoprsLogic.get(USER, PROJECT).first()
ActionsLogic.send_create_gpg_key(fcopr)
db.session.commit()
print("Done")