mirror of
https://github.com/peridotbuild/pv2.git
synced 2024-12-22 10:48:31 +00:00
importer fixes, remove submodules, cleanup util
importer/operation.py: Added a skip_lookaside option to pkg_import(). This will remove the source files outright and not attempt to move them. Removed models and peridotpb. These will be something outside of this core module. util/generic.py: reordered __all__ util/rpmutil.py: ordered __all__ and added metadata logic to NEVRA splitter.
This commit is contained in:
parent
60e197c9e1
commit
843380bd98
@ -116,6 +116,17 @@ class Import:
|
||||
if os.path.exists('/usr/sbin/restorecon'):
|
||||
processor.run_proc_foreground_shell(f'/usr/sbin/restorecon {dest_path}')
|
||||
|
||||
@staticmethod
|
||||
def skip_import_lookaside(repo_path: str, file_dict: dict):
|
||||
"""
|
||||
Removes all files that are supposed to go to the lookaside. This is for
|
||||
cases where you may have sources in another location, you just want the
|
||||
metadata filled out appropriately.
|
||||
"""
|
||||
for name, _ in file_dict.items():
|
||||
source_path = f'{repo_path}/{name}'
|
||||
os.remove(source_path)
|
||||
|
||||
class SrpmImport(Import):
|
||||
"""
|
||||
Import class for importing rpms to a git service
|
||||
@ -170,9 +181,12 @@ class SrpmImport(Import):
|
||||
|
||||
return None
|
||||
|
||||
def pkg_import(self):
|
||||
def pkg_import(self, skip_lookaside: bool = False):
|
||||
"""
|
||||
Actually perform the import
|
||||
|
||||
If skip_lookaside is True, source files will just be deleted rather
|
||||
than uploaded to lookaside.
|
||||
"""
|
||||
check_repo = gitutil.lsremote(self.git_url)
|
||||
git_repo_path = f'/var/tmp/{self.rpm_name}'
|
||||
@ -234,7 +248,12 @@ class SrpmImport(Import):
|
||||
sources = self.get_dict_of_lookaside_files(git_repo_path)
|
||||
self.generate_metadata(git_repo_path, self.rpm_name, sources)
|
||||
self.generate_filesum(git_repo_path, self.rpm_name, self.srpm_hash)
|
||||
self.import_lookaside(git_repo_path, self.rpm_name, branch, sources)
|
||||
|
||||
if skip_lookaside:
|
||||
self.skip_import_lookaside(git_repo_path, sources)
|
||||
else:
|
||||
self.import_lookaside(git_repo_path, self.rpm_name, branch, sources)
|
||||
|
||||
gitutil.add_all(repo)
|
||||
|
||||
verify = repo.is_dirty()
|
||||
|
@ -1,5 +0,0 @@
|
||||
# -*-:python; coding:utf-8; -*-
|
||||
# author: Louis Abel <label@rockylinux.org>
|
||||
"""
|
||||
Useful models. These may not be used and may be put elsewhere.
|
||||
"""
|
@ -1,5 +0,0 @@
|
||||
# -*-:python; coding:utf-8; -*-
|
||||
# author: Louis Abel <label@rockylinux.org>
|
||||
"""
|
||||
The peridotpb part of everything I suppose.
|
||||
"""
|
@ -8,13 +8,13 @@ from pv2.util import error as err
|
||||
|
||||
# General utilities
|
||||
__all__ = [
|
||||
'ordered',
|
||||
'conv_multibyte',
|
||||
'to_unicode',
|
||||
'convert_from_unix_time',
|
||||
'trim_non_empty_string',
|
||||
'gen_bool_option',
|
||||
'generate_password_hash'
|
||||
'generate_password_hash',
|
||||
'ordered',
|
||||
'to_unicode',
|
||||
'trim_non_empty_string'
|
||||
]
|
||||
|
||||
def to_unicode(string: str) -> str:
|
||||
|
@ -19,18 +19,18 @@ except ImportError:
|
||||
rpm = None
|
||||
|
||||
__all__ = [
|
||||
'is_debug_package',
|
||||
'add_rpm_key',
|
||||
'compare_rpms',
|
||||
'get_all_rpm_header_keys',
|
||||
'get_exclu_from_package',
|
||||
'get_files_from_package',
|
||||
'get_rpm_hdr_size',
|
||||
'get_rpm_header',
|
||||
'get_rpm_metadata_from_hdr',
|
||||
'compare_rpms',
|
||||
'is_debug_package',
|
||||
'is_rpm',
|
||||
'get_files_from_package',
|
||||
'get_exclu_from_package',
|
||||
'get_rpm_hdr_size',
|
||||
'split_rpm_by_header',
|
||||
'get_all_rpm_header_keys',
|
||||
'verify_rpm_signature',
|
||||
'add_rpm_key'
|
||||
'verify_rpm_signature'
|
||||
]
|
||||
|
||||
# NOTES TO THOSE RUNNING PYLINT OR ANOTHER TOOL
|
||||
@ -336,13 +336,19 @@ def split_rpm_by_header(hdr) -> tuple:
|
||||
|
||||
Note: Splitting a source package will result in an erroneous "arch" field.
|
||||
"""
|
||||
|
||||
# pylint: disable=no-member
|
||||
source_files = hdr[rpm.RPMTAG_SOURCE]
|
||||
source_pkg = hdr[rpm.RPMTAG_SOURCERPM]
|
||||
pkg_arch = generic.to_unicode(hdr[rpm.RPMTAG_ARCH])
|
||||
|
||||
if len(source_files) != 0 or not source_pkg:
|
||||
pkg_arch = 'src'
|
||||
|
||||
name = hdr[rpm.RPMTAG_NAME]
|
||||
version = hdr[rpm.RPMTAG_VERSION]
|
||||
release = hdr[rpm.RPMTAG_RELEASE]
|
||||
epoch = hdr[rpm.RPMTAG_EPOCH]
|
||||
arch = hdr[rpm.RPMTAG_ARCH]
|
||||
arch = pkg_arch
|
||||
|
||||
if not epoch:
|
||||
epoch = ''
|
||||
|
Loading…
Reference in New Issue
Block a user