import_otherdistro: optionally store local path

We don't actually need this for anything at the moment, but it would be
useful if we get to the point where we need to access imported files
within the application after the import process (e.g. to compare
patches).

Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
This commit is contained in:
Paul Eggleton 2019-06-21 15:59:49 +12:00
parent a823789ab2
commit 19944b2281
3 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.11.16 on 2019-04-02 20:22
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('layerindex', '0034_source_sha256sum'),
]
operations = [
migrations.AddField(
model_name='layerbranch',
name='local_path',
field=models.CharField(blank=True, help_text='Local subdirectory where layer data can be found', max_length=255),
),
]

View File

@ -239,6 +239,7 @@ class LayerBranch(models.Model):
vcs_last_commit = models.DateTimeField('Last commit date', blank=True, null=True)
actual_branch = models.CharField('Actual Branch', max_length=80, blank=True, help_text='Name of the actual branch in the repository matching the core branch')
yp_compatible_version = models.ForeignKey(YPCompatibleVersion, verbose_name='Yocto Project Compatible version', null=True, blank=True, on_delete=models.SET_NULL, help_text='Which version of the Yocto Project Compatible program has this layer been approved for for?')
local_path = models.CharField(max_length=255, blank=True, help_text='Local subdirectory where layer data can be found')
updated = models.DateTimeField(auto_now=True)

View File

@ -448,6 +448,9 @@ def import_pkgspec(args):
logger.error('No spec files found in directory %s' % metapath)
return 1
if args.relative_path:
layerbranch.local_path = os.path.relpath(metapath, args.relative_path)
if existing:
fpaths = sorted(['%s/%s' % (pth, fn) for pth, fn in existing])
logger.info('Marking as deleted:\n %s' % '\n '.join(fpaths))
@ -628,6 +631,7 @@ def main():
parser_pkgspec.add_argument('layer', help='Layer to import into')
parser_pkgspec.add_argument('pkgdir', help='Top level directory containing package subdirectories')
parser_pkgspec.add_argument('--description', help='Set branch/layer description')
parser_pkgspec.add_argument('--relative-path', help='Top level directory to set layerbranch path relative to')
parser_pkgspec.add_argument('-u', '--update', help='Specify update record to link to')
parser_pkgspec.add_argument('-n', '--dry-run', help='Don\'t write any data back to the database', action='store_true')
parser_pkgspec.set_defaults(func=import_pkgspec)