summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/toaster/orm
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-01 09:38:23 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-01 09:38:35 +0100
commitaa2d94542336f359a1205520e844c1bcff53712b (patch)
tree0e09d8049ec4e2e486026764173d6ea6ee4ccfac /bitbake/lib/toaster/orm
parent5b61fa04a335a4fdefd435dc25d4bac41ee21e39 (diff)
downloadpoky-aa2d94542336f359a1205520e844c1bcff53712b.tar.gz
bitbake: lib/toaster: Fix missing new files from previous commits
(Bitbake rev: f77e6f21a2cc57a3fcb5970437e55cfae39849a3) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/toaster/orm')
-rw-r--r--bitbake/lib/toaster/orm/migrations/0010_delete_layer_source_references.py118
-rw-r--r--bitbake/lib/toaster/orm/migrations/0011_delete_layersource.py17
-rw-r--r--bitbake/lib/toaster/orm/migrations/0012_use_release_instead_of_up_branch.py62
3 files changed, 197 insertions, 0 deletions
diff --git a/bitbake/lib/toaster/orm/migrations/0010_delete_layer_source_references.py b/bitbake/lib/toaster/orm/migrations/0010_delete_layer_source_references.py
new file mode 100644
index 0000000000..f67388e990
--- /dev/null
+++ b/bitbake/lib/toaster/orm/migrations/0010_delete_layer_source_references.py
@@ -0,0 +1,118 @@
1# -*- coding: utf-8 -*-
2from __future__ import unicode_literals
3
4from django.db import migrations, models
5import django.utils.timezone
6
7
8class Migration(migrations.Migration):
9
10 dependencies = [
11 ('orm', '0009_target_package_manifest_path'),
12 ]
13
14 operations = [
15 migrations.AlterUniqueTogether(
16 name='releaselayersourcepriority',
17 unique_together=set([]),
18 ),
19 migrations.RemoveField(
20 model_name='releaselayersourcepriority',
21 name='layer_source',
22 ),
23 migrations.RemoveField(
24 model_name='releaselayersourcepriority',
25 name='release',
26 ),
27 migrations.DeleteModel(
28 name='ImportedLayerSource',
29 ),
30 migrations.DeleteModel(
31 name='LayerIndexLayerSource',
32 ),
33 migrations.DeleteModel(
34 name='LocalLayerSource',
35 ),
36 migrations.RemoveField(
37 model_name='recipe',
38 name='layer_source',
39 ),
40 migrations.RemoveField(
41 model_name='recipe',
42 name='up_id',
43 ),
44 migrations.AlterField(
45 model_name='layer',
46 name='up_date',
47 field=models.DateTimeField(default=django.utils.timezone.now, null=True),
48 ),
49 migrations.AlterField(
50 model_name='layer_version',
51 name='layer_source',
52 field=models.IntegerField(default=0, choices=[(0, 'local'), (1, 'layerindex'), (2, 'imported'), (3, 'build')]),
53 ),
54 migrations.AlterField(
55 model_name='layer_version',
56 name='up_date',
57 field=models.DateTimeField(default=django.utils.timezone.now, null=True),
58 ),
59 migrations.AlterUniqueTogether(
60 name='branch',
61 unique_together=set([]),
62 ),
63 migrations.AlterUniqueTogether(
64 name='layer',
65 unique_together=set([]),
66 ),
67 migrations.AlterUniqueTogether(
68 name='layer_version',
69 unique_together=set([]),
70 ),
71 migrations.AlterUniqueTogether(
72 name='layerversiondependency',
73 unique_together=set([]),
74 ),
75 migrations.AlterUniqueTogether(
76 name='machine',
77 unique_together=set([]),
78 ),
79 migrations.DeleteModel(
80 name='ReleaseLayerSourcePriority',
81 ),
82 migrations.RemoveField(
83 model_name='branch',
84 name='layer_source',
85 ),
86 migrations.RemoveField(
87 model_name='branch',
88 name='up_id',
89 ),
90 migrations.RemoveField(
91 model_name='layer',
92 name='layer_source',
93 ),
94 migrations.RemoveField(
95 model_name='layer',
96 name='up_id',
97 ),
98 migrations.RemoveField(
99 model_name='layer_version',
100 name='up_id',
101 ),
102 migrations.RemoveField(
103 model_name='layerversiondependency',
104 name='layer_source',
105 ),
106 migrations.RemoveField(
107 model_name='layerversiondependency',
108 name='up_id',
109 ),
110 migrations.RemoveField(
111 model_name='machine',
112 name='layer_source',
113 ),
114 migrations.RemoveField(
115 model_name='machine',
116 name='up_id',
117 ),
118 ]
diff --git a/bitbake/lib/toaster/orm/migrations/0011_delete_layersource.py b/bitbake/lib/toaster/orm/migrations/0011_delete_layersource.py
new file mode 100644
index 0000000000..75506961a9
--- /dev/null
+++ b/bitbake/lib/toaster/orm/migrations/0011_delete_layersource.py
@@ -0,0 +1,17 @@
1# -*- coding: utf-8 -*-
2from __future__ import unicode_literals
3
4from django.db import migrations, models
5
6
7class Migration(migrations.Migration):
8
9 dependencies = [
10 ('orm', '0010_delete_layer_source_references'),
11 ]
12
13 operations = [
14 migrations.DeleteModel(
15 name='LayerSource',
16 ),
17 ]
diff --git a/bitbake/lib/toaster/orm/migrations/0012_use_release_instead_of_up_branch.py b/bitbake/lib/toaster/orm/migrations/0012_use_release_instead_of_up_branch.py
new file mode 100644
index 0000000000..0e6bb83311
--- /dev/null
+++ b/bitbake/lib/toaster/orm/migrations/0012_use_release_instead_of_up_branch.py
@@ -0,0 +1,62 @@
1# -*- coding: utf-8 -*-
2from __future__ import unicode_literals
3
4from django.db import migrations, models
5from django.db.models import Q
6
7
8def branch_to_release(apps, schema_editor):
9 Layer_Version = apps.get_model('orm', 'Layer_Version')
10 Release = apps.get_model('orm', 'Release')
11
12 print("Converting all layer version up_branches to releases")
13 # Find all the layer versions which have an upbranch and convert them to
14 # the release that they're for.
15 for layer_version in Layer_Version.objects.filter(
16 Q(release=None) & ~Q(up_branch=None)):
17 try:
18 # HEAD and local are equivalent
19 if "HEAD" in layer_version.up_branch.name:
20 release = Release.objects.get(name="local")
21 layer_version.commit = "HEAD"
22 layer_version.branch = "HEAD"
23 else:
24 release = Release.objects.get(
25 name=layer_version.up_branch.name)
26
27 layer_version.release = release
28 layer_version.save()
29 except Exception as e:
30 print("Couldn't work out an appropriate release for %s "
31 "the up_branch was %s "
32 "user the django admin interface to correct it" %
33 (layer_version.layer.name, layer_version.up_branch.name))
34 print(e)
35
36 continue
37
38
39class Migration(migrations.Migration):
40
41 dependencies = [
42 ('orm', '0011_delete_layersource'),
43 ]
44
45 operations = [
46 migrations.AddField(
47 model_name='layer_version',
48 name='release',
49 field=models.ForeignKey(to='orm.Release', default=None, null=True),
50 ),
51 migrations.RunPython(branch_to_release,
52 reverse_code=migrations.RunPython.noop),
53
54 migrations.RemoveField(
55 model_name='layer_version',
56 name='up_branch',
57 ),
58
59 migrations.DeleteModel(
60 name='Branch',
61 ),
62 ]