Skip to contentSkip to conversation

update: allow preserving temp directory

PATCH New Paul Eggleton 1 participant 3 messages Oct 4, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 update: allow preserving temp directory

If you're diagnosing problems with the bitbake server when running the update script, then you need to be able to look at bitbake-cookerdaemon.log, but you couldn't do that after the fact because the temporary directory it gets written out to was being unconditionally deleted. Add a --keep-temp option which preserves it and some debug messages to tell you where it is.

---
 layerindex/update.py       |  5 +++++
 layerindex/update_layer.py | 10 +++++++++-
 2 files changed, 14 insertions(+), 1 deletion(-)
layerindex/update.py +5 -0
index 2d578df..d1e67a0 100755
@@ -85,6 +85,8 @@ def prepare_update_layer_command(options, branch, layer, initial=False):
         cmd += ' -d'
     elif options.loglevel == logging.ERROR:
         cmd += ' -q'
+    if options.keep_temp:
+        cmd += ' --keep-temp'
     return cmd
 
 def update_actual_branch(layerquery, fetchdir, branch, options, update_bitbake, bitbakepath):
@@ -165,6 +167,9 @@ def main():
     parser.add_option("-q", "--quiet",
             help = "Hide all output except error messages",
             action="store_const", const=logging.ERROR, dest="loglevel")
+    parser.add_option("", "--keep-temp",
+            help = "Preserve temporary directory at the end instead of deleting it",
+            action="store_true")
 
     options, args = parser.parse_args(sys.argv)
     if len(args) > 1:
layerindex/update_layer.py +9 -1
index 7f0c08f..d91c00e 100644
@@ -194,6 +194,9 @@ def main():
     parser.add_option("-q", "--quiet",
             help = "Hide all output except error messages",
             action="store_const", const=logging.ERROR, dest="loglevel")
+    parser.add_option("", "--keep-temp",
+            help = "Preserve temporary directory at the end instead of deleting it",
+            action="store_true")
 
     options, args = parser.parse_args(sys.argv)
     if len(args) > 1:
@@ -258,6 +261,7 @@ def main():
     except recipeparse.RecipeParseError as e:
         logger.error(str(e))
         sys.exit(1)
+    logger.debug('Using temp directory %s' % tempdir)
     # Clear the default value of SUMMARY so that we can use DESCRIPTION instead if it hasn't been set
     tinfoil.config_data.setVar('SUMMARY', '')
     # Clear the default value of DESCRIPTION so that we can see where it's not set
@@ -702,7 +706,11 @@ def main():
         if LooseVersion(bb.__version__) > LooseVersion("1.27"):
             tinfoil.shutdown()
 
-    shutil.rmtree(tempdir)
+    if options.keep_temp:
+        logger.debug('Preserving temp directory %s' % tempdir)
+    else:
+        logger.debug('Deleting temp directory')
+        shutil.rmtree(tempdir)
     sys.exit(0)
 
 
Signature · 1 line
2.9.5
#1 lore raw

PATCH 2/3 models: allow LayerBranch.collection to be blank

It's really irritating to be forced to specify a value for this field especially as it'll get auto-populated by the update script. Set blank=True to allow that. While we're at it, touch up the description a bit to make more sense.

---
 layerindex/migrations/0009_layerbranch_collection.py | 19 +++++++++++++++++++
 layerindex/models.py                                 |  2 +-
 2 files changed, 20 insertions(+), 1 deletion(-)
 create mode 100644 layerindex/migrations/0009_layerbranch_collection.py
layerindex/migrations/0009_layerbranch_collection.py new file +19 -0
new file mode 100644
index 0000000..bf6276f
@@ -0,0 +1,19 @@
+# -*- coding: utf-8 -*-
+from __future__ import unicode_literals
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('layerindex', '0008_yp_compatible'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='layerbranch',
+            name='collection',
+            field=models.CharField(help_text='Name of the collection that the layer provides for the purpose of expressing dependencies (as specified in BBFILE_COLLECTIONS). Can only contain letters, numbers and dashes.', max_length=40, blank=True, null=True, verbose_name='Layer Collection'),
+        ),
+    ]
layerindex/models.py +1 -1
index e99f0b8..b39518a 100644
@@ -157,7 +157,7 @@ class YPCompatibleVersion(models.Model):
 class LayerBranch(models.Model):
     layer = models.ForeignKey(LayerItem)
     branch = models.ForeignKey(Branch)
-    collection = models.CharField('Layer Collection', max_length=40, null=True, help_text='Name of the layer that could be used in the list of dependencies - can only contain letters, numbers and dashes')
+    collection = models.CharField('Layer Collection', max_length=40, null=True, blank=True, help_text='Name of the collection that the layer provides for the purpose of expressing dependencies (as specified in BBFILE_COLLECTIONS). Can only contain letters, numbers and dashes.')
     version = models.CharField('Layer Version', max_length=10, null=True, blank=True, help_text='The layer version for this particular branch.')
     vcs_subdir = models.CharField('Repository subdirectory', max_length=40, blank=True, help_text='Subdirectory within the repository where the layer is located, if not in the root (usually only used if the repository contains more than one layer)')
     vcs_last_fetch = models.DateTimeField('Last successful fetch', blank=True, null=True)
Signature · 1 line
2.9.5
#2 lore raw

PATCH 3/3 Show note if layer branch hasn't been indexed

In reply to Paul Eggleton

For newly added layers it may not be immediately obvious that you have to wait for it to be indexed (since the update script is usually run on a scheduled basis). If the layer branch hasn't been indexed, add a note mentioning this.

---
 templates/layerindex/detail.html | 5 +++++
 1 file changed, 5 insertions(+)
templates/layerindex/detail.html +5 -0
index 144d5e8..0747421 100644
@@ -167,6 +167,11 @@
             </div>  <!-- end of row-fluid -->
         </div> <!-- end of container-fluid -->
 
+        {% if not layerbranch.vcs_last_commit %}
+        <div class="alert alert-info">
+            <b>Note:</b> The content of this layer on branch {{ url_branch }} has not yet been indexed. Indexing should take place within a few hours.
+        </div>
+        {% endif %}
 
         <ul class="nav nav-tabs" id="layertabbar">
             {% if layerbranch.recipe_set.count > 0 %}
Signature · 1 line
2.9.5