commit aef358286d7eb402b16b2f1051cf2a25927f06cb Author: Mustafa Gezen Date: Sun May 8 16:46:13 2022 +0200 Initial commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..6c676b9 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,19 @@ +root = true + +[*] +charset = utf-8 +indent_style = space +indent_size = 2 +insert_final_newline = true +trim_trailing_whitespace = true +end_of_line = lf + +[*.md] +max_line_length = off +trim_trailing_whitespace = false + +[*.go] +indent_size = 4 + +[*.py] +indent_size = 4 \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..985a63e --- /dev/null +++ b/.gitignore @@ -0,0 +1,204 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# C extensions +*.so + +# Distribution / packaging +.Python +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +wheels/ +pip-wheel-metadata/ +share/python-wheels/ +*.egg-info/ +.installed.cfg +*.egg +MANIFEST + +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + +# Installer logs +pip-log.txt +pip-delete-this-directory.txt + +# Unit test / coverage reports +htmlcov/ +.tox/ +.nox/ +.coverage +.coverage.* +.cache +nosetests.xml +coverage.xml +*.cover +*.py,cover +.hypothesis/ +.pytest_cache/ + +# Translations +*.mo +*.pot + +# Django stuff: +*.log +local_settings.py +db.sqlite3 +db.sqlite3-journal + +# Flask stuff: +instance/ +.webassets-cache + +# Scrapy stuff: +.scrapy + +# Sphinx documentation +docs/_build/ + +# PyBuilder +target/ + +# Jupyter Notebook +.ipynb_checkpoints + +# IPython +profile_default/ +ipython_config.py + +# pyenv +.python-version + +# pipenv +# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. +# However, in case of collaboration, if having platform-specific dependencies or dependencies +# having no cross-platform support, pipenv may install dependencies that don't work, or not +# install all needed dependencies. +#Pipfile.lock + +# PEP 582; used by e.g. github.com/David-OConnor/pyflow +__pypackages__/ + +# Celery stuff +celerybeat-schedule +celerybeat.pid + +# SageMath parsed files +*.sage.py + +# Environments +.env +.venv +env/ +venv/ +ENV/ +env.bak/ +venv.bak/ + +# Spyder project settings +.spyderproject +.spyproject + +# Rope project settings +.ropeproject + +# mkdocs documentation +/site + +# mypy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pyre type checker +.pyre/ + +# User-specific stuff +.idea/**/workspace.xml +.idea/**/tasks.xml +.idea/**/usage.statistics.xml +.idea/**/dictionaries +.idea/**/shelf + +# AWS User-specific +.idea/**/aws.xml + +# Generated files +.idea/**/contentModel.xml + +# Sensitive or high-churn files +.idea/**/dataSources/ +.idea/**/dataSources.ids +.idea/**/dataSources.local.xml +.idea/**/sqlDataSources.xml +.idea/**/dynamic.xml +.idea/**/uiDesigner.xml +.idea/**/dbnavigator.xml + +# Gradle +.idea/**/gradle.xml +.idea/**/libraries + +# Gradle and Maven with auto-import +# When using Gradle or Maven with auto-import, you should exclude module files, +# since they will be recreated, and may cause churn. Uncomment if using +# auto-import. +# .idea/artifacts +# .idea/compiler.xml +# .idea/jarRepositories.xml +# .idea/modules.xml +# .idea/*.iml +# .idea/modules +# *.iml +# *.ipr + +# CMake +cmake-build-*/ + +# Mongo Explorer plugin +.idea/**/mongoSettings.xml + +# File-based project format +*.iws + +# IntelliJ +out/ + +# mpeltonen/sbt-idea plugin +.idea_modules/ + +# JIRA plugin +atlassian-ide-plugin.xml + +# Cursive Clojure plugin +.idea/replstate.xml + +# SonarLint plugin +.idea/sonarlint/ + +# Crashlytics plugin (for Android Studio and IntelliJ) +com_crashlytics_export_strings.xml +crashlytics.properties +crashlytics-build.properties +fabric.properties + +# Editor-based Rest Client +.idea/httpRequests + +# Android studio 3.1+ serialized cache file +.idea/caches/build_file_checksums.ser diff --git a/.idea/.gitignore b/.idea/.gitignore new file mode 100644 index 0000000..73f69e0 --- /dev/null +++ b/.idea/.gitignore @@ -0,0 +1,8 @@ +# Default ignored files +/shelf/ +/workspace.xml +# Datasource local storage ignored files +/dataSources/ +/dataSources.local.xml +# Editor-based HTTP Client requests +/httpRequests/ diff --git a/.idea/copyright/Python.xml b/.idea/copyright/Python.xml new file mode 100644 index 0000000..682ecc6 --- /dev/null +++ b/.idea/copyright/Python.xml @@ -0,0 +1,6 @@ + + + + \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml new file mode 100644 index 0000000..0550ad8 --- /dev/null +++ b/.idea/copyright/profiles_settings.xml @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/.idea/google-java-format.xml b/.idea/google-java-format.xml new file mode 100644 index 0000000..2aa056d --- /dev/null +++ b/.idea/google-java-format.xml @@ -0,0 +1,6 @@ + + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..ca05baf --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,11 @@ + + + + diff --git a/.idea/misc.xml b/.idea/misc.xml new file mode 100644 index 0000000..bf5218c --- /dev/null +++ b/.idea/misc.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml new file mode 100644 index 0000000..26ca63b --- /dev/null +++ b/.idea/modules.xml @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/.idea/peridot-releng.iml b/.idea/peridot-releng.iml new file mode 100644 index 0000000..586a970 --- /dev/null +++ b/.idea/peridot-releng.iml @@ -0,0 +1,16 @@ + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml new file mode 100644 index 0000000..797acea --- /dev/null +++ b/.idea/runConfigurations.xml @@ -0,0 +1,10 @@ + + + + + + \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml new file mode 100644 index 0000000..94a25f7 --- /dev/null +++ b/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/AUTHORS b/AUTHORS new file mode 100644 index 0000000..e0dd6ad --- /dev/null +++ b/AUTHORS @@ -0,0 +1 @@ +Ctrl IQ, Inc. \ No newline at end of file diff --git a/CONTRIBUTORS b/CONTRIBUTORS new file mode 100644 index 0000000..c4f0323 --- /dev/null +++ b/CONTRIBUTORS @@ -0,0 +1 @@ +Mustafa Gezen \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..415e574 --- /dev/null +++ b/LICENSE @@ -0,0 +1,27 @@ +Copyright (c) Peridot-Releng Authors. All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, +this list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, +this list of conditions and the following disclaimer in the documentation +and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors +may be used to endorse or promote products derived from this software without +specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..2029209 --- /dev/null +++ b/README.md @@ -0,0 +1,2 @@ +# peridot-releng +Scripts/tools engineers uses to build and release Rocky Linux diff --git a/pungicatalog/README.md b/pungicatalog/README.md new file mode 100644 index 0000000..af7094c --- /dev/null +++ b/pungicatalog/README.md @@ -0,0 +1,10 @@ +# pungicatalog +Convert Pungi configuration to Peridot compatible catalogs. + +A catalog includes package list and repository placement of these packages as well as other +configuration related to a distribution. + +### Usage +``` +python3 pungicatalog/pungicatalog.py --pungi-conf-path /tmp/pungi-rocky/rocky.conf --output-path /tmp/catalog.cfg +``` diff --git a/pungicatalog/catalog.py b/pungicatalog/catalog.py new file mode 100644 index 0000000..95c8e6e --- /dev/null +++ b/pungicatalog/catalog.py @@ -0,0 +1,151 @@ +# -- peridot-releng-header-v0.1 -- +# Copyright (c) Peridot-Releng Authors. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +from dataclasses import dataclass +from enum import Enum + + +class PeridotCatalogSyncPackageType(str, Enum): + PACKAGE_TYPE_NORMAL = "PACKAGE_TYPE_NORMAL" + PACKAGE_TYPE_NORMAL_FORK = "PACKAGE_TYPE_NORMAL_FORK" + PACKAGE_TYPE_NORMAL_SRC = "PACKAGE_TYPE_NORMAL_SRC" + PACKAGE_TYPE_MODULE_FORK = "PACKAGE_TYPE_MODULE_FORK" + PACKAGE_TYPE_MODULE_FORK_COMPONENT = "PACKAGE_TYPE_MODULE_FORK_COMPONENT" + PACKAGE_TYPE_NORMAL_FORK_MODULE = "PACKAGE_TYPE_NORMAL_FORK_MODULE" + PACKAGE_TYPE_NORMAL_FORK_MODULE_COMPONENT = "PACKAGE_TYPE_NORMAL_FORK_MODULE_COMPONENT" + PACKAGE_TYPE_MODULE_FORK_MODULE_COMPONENT = "PACKAGE_TYPE_MODULE_FORK_MODULE_COMPONENT" + + +@dataclass +class PeridotCatalogSyncRepository: + name: str + include_filter: list[str] + multilib: list[str] + + def include_filter_to_prototxt(self): + return '\n' + '\n'.join( + [f" include_filter: \"{f}\"" for f in self.include_filter]) + + def multilib_to_prototxt(self): + return '\n' + '\n'.join( + [f" multilib: \"{f}\"" for f in self.multilib]) + + +@dataclass +class PeridotCatalogSyncPackage: + name: str + type: PeridotCatalogSyncPackageType + module_components: list[str] + repositories: list[PeridotCatalogSyncRepository] + + def mc_to_prototxt(self): + return '\n' + '\n'.join( + [f" module_component: \"{component}\"" for component in + self.module_components]) + + def repos_to_prototxt(self): + return '\n'.join( + [f""" repository {{ + name: \"{repo.name}\"{ + repo.include_filter_to_prototxt() if repo.include_filter else "" + }{ + repo.multilib_to_prototxt() if repo.multilib else "" + } + }}""" for repo in self.repositories]) + + +class PeridotCatalogSync: + additional_multilib: list[str] = [] + exclude_multilib_filter: list[str] = [] + exclude_filter: list[tuple[str, dict]] = [] + include_filter: list[tuple[str, dict]] = [] + packages: list[PeridotCatalogSyncPackage] = [] + + def add_package(self, package: PeridotCatalogSyncPackage): + self.packages.append(package) + + def additional_multilib_to_prototxt(self): + return '\n'.join( + [f"additional_multilib: \"{f}\"" for f in + self.additional_multilib]) + + def exclude_multilib_filter_to_prototxt(self): + return '\n' + '\n'.join( + [f"exclude_multilib_filter: \"{f}\"" for f in + self.exclude_multilib_filter]) + + def filter_arch_to_prototxt(self, arch: dict): + nl = '\n' + glob_match = {} + for k, v in arch.items(): + glob_match[k] = [f" glob_match: \"{f}\"" for f in v] + for k in glob_match.keys(): + if len(glob_match[k]) > 0: + glob_match[k][0] = '\n' + glob_match[k][0] + return '\n'.join([f""" arch {{ + key: \"{f}\"{nl.join(glob_match[f])} + }}""" for f in arch.keys()]) + + def exclude_filter_to_prototxt(self): + return '\n' + '\n'.join( + [f"""exclude_filter {{ + repo_match: \"{f[0]}\" +{self.filter_arch_to_prototxt(f[1])} +}}""" for f in + self.exclude_filter]) + + def include_filter_to_prototxt(self): + return '\n' + '\n'.join( + [f"""include_filter {{ + repo_match: \"{f[0]}\" +{self.filter_arch_to_prototxt(f[1])} +}}""" for f in + self.include_filter]) + + def to_prototxt(self): + ret = f"""# kind: resf.peridot.v1.CatalogSync +{self.additional_multilib_to_prototxt()}{ + self.exclude_multilib_filter_to_prototxt() + }{ + self.exclude_filter_to_prototxt() + }{ + self.include_filter_to_prototxt() + } +""" + for pkg in self.packages: + ret += f"""package {{ + name: "{pkg.name}" + type: {pkg.type}{ + pkg.mc_to_prototxt() if pkg.module_components else "" + } +{pkg.repos_to_prototxt()} +}} +""" + + return ret diff --git a/pungicatalog/pungicatalog.py b/pungicatalog/pungicatalog.py new file mode 100644 index 0000000..2169b69 --- /dev/null +++ b/pungicatalog/pungicatalog.py @@ -0,0 +1,114 @@ +# -- peridot-releng-header-v0.1 -- +# Copyright (c) Peridot-Releng Authors. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +import argparse +import os + +import kobo.conf + +from catalog import PeridotCatalogSync, PeridotCatalogSyncPackage, \ + PeridotCatalogSyncPackageType, PeridotCatalogSyncRepository +from scm import SCM + + +def main(pungi_conf_path: str, output_path: str): + pungi_base = os.path.dirname(pungi_conf_path) + + conf = kobo.conf.PyConfigParser() + conf.load_from_file(pungi_conf_path) + + gather_prepopulate_scm_dict = conf.get("gather_prepopulate") + gpscm = SCM(pungi_base, gather_prepopulate_scm_dict) + gpjson = gpscm.json() + + # Create a catalog + catalog = PeridotCatalogSync() + + # Set multilib filters + catalog.additional_multilib.extend( + list(conf.get("multilib_whitelist").values())[0]) + catalog.exclude_multilib_filter.extend( + list(conf.get("multilib_blacklist").values())[0]) + + # Set additional packages/filters + catalog.exclude_filter.extend(conf.get("filter_packages")) + catalog.include_filter.extend(conf.get("additional_packages")) + + # Create indexes + package_index = {} + + # Read prepopulate json and create package objects + for repo in gpjson.keys(): + for arch in gpjson[repo].keys(): + for package in gpjson[repo][arch].keys(): + if package not in package_index: + package_index[package] = {} + if repo not in package_index[package]: + package_index[package][repo] = {"include_filter": [], + "multilib": []} + na_list = gpjson[repo][arch][package] + for na in na_list: + splitted = na.split(".") + arch_package = splitted[len(splitted) - 1] + if arch != arch_package and arch_package != "noarch": + if arch not in package_index[package][repo]["multilib"]: + package_index[package][repo]["multilib"].append( + arch) + if na not in package_index[package][repo]["include_filter"]: + package_index[package][repo]["include_filter"].append( + na) + + for package in package_index.keys(): + catalog.add_package( + PeridotCatalogSyncPackage( + package, + PeridotCatalogSyncPackageType.PACKAGE_TYPE_NORMAL_FORK if not package.startswith("rocky-") else PeridotCatalogSyncPackageType.PACKAGE_TYPE_NORMAL_SRC, + [], + [PeridotCatalogSyncRepository(x, package_index[package][x][ + "include_filter"], package_index[package][x]["multilib"]) + for + x in package_index[package].keys()] + ) + ) + + f = open(output_path, "w") + f.write(catalog.to_prototxt()) + f.close() + + pass + + +if __name__ == "__main__": + parser = argparse.ArgumentParser( + description='Convert Pungi configuration to Peridot compatible ' + 'catalogs.') + parser.add_argument('--pungi-conf-path', type=str, required=True) + parser.add_argument('--output-path', type=str, default="catalog.cfg") + args = parser.parse_args() + main(args.pungi_conf_path, args.output_path) diff --git a/pungicatalog/scm.py b/pungicatalog/scm.py new file mode 100644 index 0000000..f31ce02 --- /dev/null +++ b/pungicatalog/scm.py @@ -0,0 +1,52 @@ +# -- peridot-releng-header-v0.1 -- +# Copyright (c) Peridot-Releng Authors. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +import json +import os + + +class SCM: + def __init__(self, pungi_base, scm_dict): + if scm_dict["scm"] == "file": + file_path = os.path.join(pungi_base, scm_dict["file"]) + f = open(file_path, "r") + file_contents = f.read() + + if file_path.endswith(".json"): + self.json_value = json.loads(file_contents) + else: + self.text_value = file_contents + + f.close() + + def json(self): + return self.json_value + + def text(self): + return self.text_value diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..7ddeeb5 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +kobo==0.23.0 +GitPython==3.1.27 +requests==2.27.1 diff --git a/scripts/create-batch-task-list.py b/scripts/create-batch-task-list.py new file mode 100644 index 0000000..39cb5dc --- /dev/null +++ b/scripts/create-batch-task-list.py @@ -0,0 +1,69 @@ +#!/usr/bin/env python3 + +# -- peridot-releng-header-v0.1 -- +# Copyright (c) Peridot-Releng Authors. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +import sys +import requests +import json + + +def get_batch(batch_type, task_id, status, page): + r = requests.get( + f'https://peridot.pdot-dev.rockylinux.org/api/v1/projects/c4fa14a2-5af6-4634-bfea-847a9fd639c7/{batch_type}_batches/{task_id}?page={page}&limit=100&filter.status={status}') + return r.json()[f'{batch_type}s'] + + +def process_batch(batch_type, task_id, status): + ret = [] + page = 0 + while True: + res = get_batch(batch_type, task_id, status, page) + if len(res) == 0: + return ret + ret.extend(res) + page = page + 1 + + +if __name__ == '__main__': + batch_type = sys.argv[1] + task_id = sys.argv[2] + + batch_items = process_batch(batch_type, task_id, 4) + # batch_items.extend(process_batch(batch_type, task_id, 5)) + + req = {} + key = f'{batch_type}s' + req[key] = [] + for item in batch_items: + req[key].append({ + 'package_name': item['name'] + }) + + print(json.dumps(req)) diff --git a/scripts/stdin-to-batch-req.py b/scripts/stdin-to-batch-req.py new file mode 100644 index 0000000..ae58204 --- /dev/null +++ b/scripts/stdin-to-batch-req.py @@ -0,0 +1,44 @@ +# -- peridot-releng-header-v0.1 -- +# Copyright (c) Peridot-Releng Authors. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are met: +# +# 1. Redistributions of source code must retain the above copyright notice, +# this list of conditions and the following disclaimer. +# +# 2. Redistributions in binary form must reproduce the above copyright notice, +# this list of conditions and the following disclaimer in the documentation +# and/or other materials provided with the distribution. +# +# 3. Neither the name of the copyright holder nor the names of its contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. + +import sys +import json + +if __name__ == '__main__': + build_type = sys.argv[1] + key = f'{build_type}s' + + req = {} + req[key] = [] + for line in sys.stdin: + req[key].append({ + 'package_name': line.strip() + }) + + print(json.dumps(req))