diff --git a/__init__.py b/pv2/__init__.py similarity index 100% rename from __init__.py rename to pv2/__init__.py diff --git a/importer/__init__.py b/pv2/importer/__init__.py similarity index 100% rename from importer/__init__.py rename to pv2/importer/__init__.py diff --git a/importer/operation.py b/pv2/importer/operation.py similarity index 86% rename from importer/operation.py rename to pv2/importer/operation.py index 6ef1770..9f3602f 100644 --- a/importer/operation.py +++ b/pv2/importer/operation.py @@ -132,6 +132,9 @@ class Import: class SrpmImport(Import): """ Import class for importing rpms to a git service + + Note that this imports *as is*. This means you cannot control which branch + nor the release tag that shows up. """ # pylint: disable=too-many-arguments def __init__( @@ -140,6 +143,7 @@ class SrpmImport(Import): srpm_path: str, release: str = '', branch: str = '', + distprefix: str = 'el', git_user: str = 'git', org: str = 'rpms', verify_signature: bool = False @@ -155,6 +159,7 @@ class SrpmImport(Import): self.__srpm_metadata = self.get_srpm_metadata(srpm_path, verify_signature) self.__release = release + self.__dist_prefix = distprefix pkg_name = self.__srpm_metadata['name'] git_url = f'ssh://{git_user}@{git_url_path}/{org}/{pkg_name}.git' @@ -175,7 +180,7 @@ class SrpmImport(Import): """ Gets the release version from the srpm """ - regex = r'.el(\d+)' + regex = fr'.{self.distprefix}(\d+)' dist_tag = self.__srpm_metadata['release'] regex_search = re.search(regex, dist_tag) if regex_search: @@ -335,7 +340,54 @@ class SrpmImport(Import): new_name = self.__srpm_metadata['name'].replace('+', 'plus') return new_name + @property + def distprefix(self): + """ + Returns the distprefix value + """ + return self.__dist_prefix + class GitImport(Import): """ Import class for importing from git (e.g. pagure or gitlab) + + This attempts to look at a git repo that was cloned and check for either a + metadata file or a sources file. After that, it will make a best effort + guess on how to convert it and push it to your git forge with an expected + format. """ + # pylint: disable=too-many-arguments + def __init__( + self, + package: str, + source_git_url_path: str, + source_git_org_path: str, + git_url_path: str, + release: str, + branch: str, + distprefix: str = 'el', + git_user: str = 'git', + org: str = 'rpms', + verify_signature: bool = False + ): + """ + Init the class. + + Set the org to something else if needed. Note that if you are using + subgroups, do not start with a leading slash (e.g. some_group/rpms) + """ + self.__rpm = package + self.__release = release + source_git_url = f'https://{source_git_url_path}/{source_git_org_path}/{package}.git' + git_url = f'ssh://{git_user}@{git_url_path}/{org}/{package}.git' + self.__git_url = git_url + self.__dist_prefix = distprefix + self.__dist_tag = f'.{distprefix}{release}' + self.__branch = branch + + @property + def rpm_name(self): + """ + Returns the name of the RPM we're working with + """ + return self.__rpm diff --git a/mock/__init__.py b/pv2/mock/__init__.py similarity index 100% rename from mock/__init__.py rename to pv2/mock/__init__.py diff --git a/mock/config.py b/pv2/mock/config.py similarity index 100% rename from mock/config.py rename to pv2/mock/config.py diff --git a/mock/error.py b/pv2/mock/error.py similarity index 100% rename from mock/error.py rename to pv2/mock/error.py diff --git a/mock/runner.py b/pv2/mock/runner.py similarity index 100% rename from mock/runner.py rename to pv2/mock/runner.py diff --git a/modularity/__init__.py b/pv2/modularity/__init__.py similarity index 100% rename from modularity/__init__.py rename to pv2/modularity/__init__.py diff --git a/modularity/util.py b/pv2/modularity/util.py similarity index 100% rename from modularity/util.py rename to pv2/modularity/util.py diff --git a/util/README.md b/pv2/util/README.md similarity index 100% rename from util/README.md rename to pv2/util/README.md diff --git a/util/__init__.py b/pv2/util/__init__.py similarity index 100% rename from util/__init__.py rename to pv2/util/__init__.py diff --git a/util/color.py b/pv2/util/color.py similarity index 100% rename from util/color.py rename to pv2/util/color.py diff --git a/util/constants.py b/pv2/util/constants.py similarity index 100% rename from util/constants.py rename to pv2/util/constants.py diff --git a/util/cr.py b/pv2/util/cr.py similarity index 100% rename from util/cr.py rename to pv2/util/cr.py diff --git a/util/error.py b/pv2/util/error.py similarity index 100% rename from util/error.py rename to pv2/util/error.py diff --git a/util/fileutil.py b/pv2/util/fileutil.py similarity index 100% rename from util/fileutil.py rename to pv2/util/fileutil.py diff --git a/util/generic.py b/pv2/util/generic.py similarity index 100% rename from util/generic.py rename to pv2/util/generic.py diff --git a/util/gitutil.py b/pv2/util/gitutil.py similarity index 100% rename from util/gitutil.py rename to pv2/util/gitutil.py diff --git a/util/processor.py b/pv2/util/processor.py similarity index 100% rename from util/processor.py rename to pv2/util/processor.py diff --git a/util/rpmutil.py b/pv2/util/rpmutil.py similarity index 100% rename from util/rpmutil.py rename to pv2/util/rpmutil.py diff --git a/pyproject.toml b/pyproject.toml index 494e67a..c310815 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,18 +1,16 @@ [project] name = "pv2" version = "0.9.1" - +description = "PV2 backend framework module" +readme = "README.md" authors = [ - "Louis Abel " + { name = "Louis Abel", email = "label@rockylinux.org" } ] maintainers = [ - "Louis Abel " + { name = "Louis Abel", email = "label@rockylinux.org" } ] -description = "PV2 backend framework module" -readme = "README.md" -license = "MIT" requires-python = ">=3.6" dependencies = [ @@ -25,3 +23,9 @@ dependencies = [ [project.urls] "Homepage" = "https://github.com/peridotbuild/pv2" "Bug Tracker" = "https://github.com/peridotbuild/pv2/issues" + +[project.license] +file = "LICENSE" + +[tool.setuptools] +package-dir = { "pv2" = "pv2" }