aboutsummaryrefslogtreecommitdiffstats
path: root/layerindex/update_layer.py
diff options
context:
space:
mode:
authorLiam R. Howlett <Liam.Howlett@WindRiver.com>2016-10-04 14:00:20 -0400
committerPaul Eggleton <paul.eggleton@linux.intel.com>2016-10-18 16:42:15 +1300
commit31c85196d05392726afaed622b46b13210e5912b (patch)
tree5cc4f950ff2f41f535f7eceef913765c1221c12c /layerindex/update_layer.py
parent4f0be8a7d03124aa834431e301a2f54abf05cd61 (diff)
downloadopenembedded-core-contrib-31c85196d05392726afaed622b46b13210e5912b.tar.gz
layerindex: Add distro to web interface and model
Add the distros to the index. This looks a lot like the machines and allows users to search for a particular distro. Signed-off-by: Liam R. Howlett <Liam.Howlett@WindRiver.com> Added associated migration. Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Diffstat (limited to 'layerindex/update_layer.py')
-rw-r--r--layerindex/update_layer.py46
1 files changed, 45 insertions, 1 deletions
diff --git a/layerindex/update_layer.py b/layerindex/update_layer.py
index 13b508f79d..f2a8b7e7f5 100644
--- a/layerindex/update_layer.py
+++ b/layerindex/update_layer.py
@@ -115,6 +115,19 @@ def update_machine_conf_file(path, machine):
break
machine.description = desc
+def update_distro_conf_file(path, distro):
+ logger.debug('Updating distro %s' % path)
+ desc = ""
+ with open(path, 'r') as f:
+ for line in f:
+ if line.startswith('#@NAME:'):
+ desc = line[7:].strip()
+ if line.startswith('#@DESCRIPTION:'):
+ desc = line[14:].strip()
+ desc = re.sub(r'Distribution configuration for( running)*( an)*( the)*', '', desc)
+ break
+ distro.description = desc
+
def main():
if LooseVersion(git.__version__) < '0.3.1':
logger.error("Version of GitPython is too old, please install GitPython (python-git) 0.3.1 or later in order to use this script")
@@ -161,7 +174,7 @@ def main():
utils.setup_django()
import settings
- from layerindex.models import LayerItem, LayerBranch, Recipe, RecipeFileDependency, Machine, BBAppend, BBClass
+ from layerindex.models import LayerItem, LayerBranch, Recipe, RecipeFileDependency, Machine, Distro, BBAppend, BBClass
from django.db import transaction
logger.setLevel(options.loglevel)
@@ -269,6 +282,7 @@ def main():
layerdir_start = os.path.normpath(layerdir) + os.sep
layerrecipes = Recipe.objects.filter(layerbranch=layerbranch)
layermachines = Machine.objects.filter(layerbranch=layerbranch)
+ layerdistros = Distro.objects.filter(layerbranch=layerbranch)
layerappends = BBAppend.objects.filter(layerbranch=layerbranch)
layerclasses = BBClass.objects.filter(layerbranch=layerbranch)
if layerbranch.vcs_last_rev != topcommit.hexsha or options.reload:
@@ -384,6 +398,15 @@ def main():
else:
logger.warn("Renamed machine %s could not be found" % oldpath)
other_adds.append(diffitem)
+ elif oldtypename == 'distro':
+ results = layerdistros.filter(name=oldfilename)
+ if len(results):
+ logger.debug("Rename distro %s to %s" % (results[0], newfilename))
+ results[0].name = newfilename
+ results[0].save()
+ else:
+ logger.warn("Renamed distro %s could not be found" % oldpath)
+ other_adds.append(diffitem)
elif oldtypename == 'bbclass':
results = layerclasses.filter(name=oldfilename)
if len(results):
@@ -422,6 +445,8 @@ def main():
layerappends.filter(filepath=filepath).filter(filename=filename).delete()
elif typename == 'machine':
layermachines.filter(name=filename).delete()
+ elif typename == 'distro':
+ layerdistros.filter(name=filename).delete()
elif typename == 'bbclass':
layerclasses.filter(name=filename).delete()
@@ -452,6 +477,12 @@ def main():
machine.name = filename
update_machine_conf_file(os.path.join(repodir, path), machine)
machine.save()
+ elif typename == 'distro':
+ distro = Distro()
+ distro.layerbranch = layerbranch
+ distro.name = filename
+ update_distro_conf_file(os.path.join(repodir, path), distro)
+ distro.save()
elif typename == 'bbclass':
bbclass = BBClass()
bbclass.layerbranch = layerbranch
@@ -483,6 +514,12 @@ def main():
machine = results[0]
update_machine_conf_file(os.path.join(repodir, path), machine)
machine.save()
+ elif typename == 'distro':
+ results = layerdistros.filter(name=filename)
+ if results:
+ distro = results[0]
+ update_distro_conf_file(os.path.join(repodir, path), distro)
+ distro.save()
deps = RecipeFileDependency.objects.filter(layerbranch=layerbranch).filter(path=path)
for dep in deps:
@@ -523,6 +560,7 @@ def main():
layerrecipe_fns.append(fullpath)
layermachines.delete()
+ layerdistros.delete()
layerappends.delete()
layerclasses.delete()
for root, dirs, files in os.walk(layerdir):
@@ -550,6 +588,12 @@ def main():
machine.name = filename
update_machine_conf_file(fullpath, machine)
machine.save()
+ elif typename == 'distro':
+ distro = Distro()
+ distro.layerbranch = layerbranch
+ distro.name = filename
+ update_distro_conf_file(fullpath, distro)
+ distro.save()
elif typename == 'bbclass':
bbclass = BBClass()
bbclass.layerbranch = layerbranch