summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/toastermain/management/commands/builddelete.py
blob: 5cec436714b1ca533df3e47be43fec22534ddf85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
from django.core.management.base import BaseCommand, CommandError
from orm.models import Build
import os



class Command(BaseCommand):
    args    = "buildId"
    help    = "Deletes selected build"

    def handle(self, buildId, *args, **options):
        b = Build.objects.get(pk = buildId)
        # theoretically, just b.delete() would suffice
        # however SQLite runs into problems when you try to
        # delete too many rows at once, so we delete some direct
        # relationships from Build manually.

        for t in b.target_set.all():
            t.delete()
        for t in b.task_build.all():
            t.delete()
        for p in b.package_set.all():
            p.delete()
        for lv in b.layer_version_build.all():
            lv.delete()
        for v in b.variable_build.all():
            v.delete()
        for l in b.logmessage_set.all():
            l.delete()

        # this should take care of the rest
        b.delete()