This repository has been archived by the owner on Jan 9, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
As a user I can migrate modules and modules-defaults.
closes #6321
- Loading branch information
Showing
6 changed files
with
474 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
As a user I can migrate modules and modules-defaults |
55 changes: 55 additions & 0 deletions
55
pulp_2to3_migration/app/migrations/0005_pulp2modulemd_pulp2modulemddefaults.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Generated by Django 2.2.10 on 2020-03-13 19:28 | ||
|
||
import django.contrib.postgres.fields.jsonb | ||
from django.db import migrations, models | ||
import django.db.models.deletion | ||
import uuid | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('pulp_2to3_migration', '0004_pulp2yumrepometadatafile'), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name='Pulp2ModulemdDefaults', | ||
fields=[ | ||
('pulp_id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), | ||
('pulp_created', models.DateTimeField(auto_now_add=True)), | ||
('pulp_last_updated', models.DateTimeField(auto_now=True, null=True)), | ||
('module', models.TextField()), | ||
('stream', models.TextField()), | ||
('profiles', django.contrib.postgres.fields.jsonb.JSONField(verbose_name=dict)), | ||
('digest', models.TextField()), | ||
('repo_id', models.TextField()), | ||
('pulp2content', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='modulemd_defaults_detail_model', to='pulp_2to3_migration.Pulp2Content')), | ||
], | ||
options={ | ||
'default_related_name': 'modulemd_defaults_detail_model', | ||
'unique_together': {('digest', 'repo_id', 'pulp2content')}, | ||
}, | ||
), | ||
migrations.CreateModel( | ||
name='Pulp2Modulemd', | ||
fields=[ | ||
('pulp_id', models.UUIDField(default=uuid.uuid4, editable=False, primary_key=True, serialize=False)), | ||
('pulp_created', models.DateTimeField(auto_now_add=True)), | ||
('pulp_last_updated', models.DateTimeField(auto_now=True, null=True)), | ||
('name', models.TextField()), | ||
('stream', models.TextField()), | ||
('version', models.BigIntegerField()), | ||
('context', models.TextField()), | ||
('arch', models.TextField()), | ||
('artifacts', django.contrib.postgres.fields.jsonb.JSONField()), | ||
('checksum', models.TextField()), | ||
('dependencies', django.contrib.postgres.fields.jsonb.JSONField()), | ||
('pulp2content', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='modulemd_detail_model', to='pulp_2to3_migration.Pulp2Content')), | ||
], | ||
options={ | ||
'default_related_name': 'modulemd_detail_model', | ||
'unique_together': {('name', 'stream', 'version', 'context', 'arch', 'pulp2content')}, | ||
}, | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import logging | ||
|
||
from gettext import gettext as _ | ||
|
||
|
||
_LOGGER = logging.getLogger(__name__) | ||
|
||
|
||
def nevra(name): | ||
""" | ||
Parse NEVRA. | ||
Inspired by: | ||
https://github.com/rpm-software-management/hawkey/blob/d61bf52871fcc8e41c92921c8cd92abaa4dfaed5/src/util.c#L157. # NOQA | ||
We don't use hawkey because it is not available on all platforms we support. | ||
Args: | ||
name(string): NEVRA (jay-3:3.10-4.fc3.x86_64) | ||
Returns: | ||
tuple: parsed NEVRA (name, epoch, version, release, architecture) | ||
""" | ||
if name.count(".") < 1: | ||
msg = _("failed to parse nevra '%s' not a valid nevra") % name | ||
_LOGGER.exception(msg) | ||
raise ValueError(msg) | ||
|
||
arch_dot_pos = name.rfind(".") | ||
arch = name[arch_dot_pos + 1:] | ||
|
||
return nevr(name[:arch_dot_pos]) + (arch, ) | ||
|
||
|
||
def nevr(name): | ||
""" | ||
Parse NEVR. | ||
Inspired by: | ||
https://github.com/rpm-software-management/hawkey/blob/d61bf52871fcc8e41c92921c8cd92abaa4dfaed5/src/util.c#L157. # NOQA | ||
Args: | ||
name(string): NEVR "jay-test-3:3.10-4.fc3" | ||
Returns: | ||
tuple: parsed NEVR (name, epoch, version, release) | ||
""" | ||
if name.count("-") < 2: # release or name is missing | ||
msg = _("failed to parse nevr '%s' not a valid nevr") % name | ||
_LOGGER.exception(msg) | ||
raise ValueError(msg) | ||
|
||
release_dash_pos = name.rfind("-") | ||
release = name[release_dash_pos + 1:] | ||
name_epoch_version = name[:release_dash_pos] | ||
name_dash_pos = name_epoch_version.rfind("-") | ||
package_name = name_epoch_version[:name_dash_pos] | ||
|
||
epoch_version = name_epoch_version[name_dash_pos + 1:].split(":") | ||
if len(epoch_version) == 1: | ||
epoch = 0 | ||
version = epoch_version[0] | ||
elif len(epoch_version) == 2: | ||
epoch = int(epoch_version[0]) | ||
version = epoch_version[1] | ||
else: | ||
# more than one ':' | ||
msg = _("failed to parse nevr '%s' not a valid nevr") % name | ||
_LOGGER.exception(msg) | ||
raise ValueError(msg) | ||
|
||
return package_name, epoch, version, release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.