diff --git a/release_management/_utils.py b/release_management/_utils.py index 5e61474..f97f434 100755 --- a/release_management/_utils.py +++ b/release_management/_utils.py @@ -20,7 +20,6 @@ # isort: STDLIB import os import subprocess -import tarfile import tomllib from datetime import datetime from getpass import getpass @@ -77,52 +76,6 @@ def calc_pre_release_suffix(): return f"{datetime.today():%Y%m%d%H%M}git{commit_hash}" -def get_bundled_provides(vendor_tarfile): - """ - Given absolute path of vendor tarfile generate bundled provides. - """ - with tarfile.open(vendor_tarfile, "r") as tar: - for member in tar.getmembers(): - components = member.name.split("/") - - if ( - len(components) == 3 - and components[0] == "vendor" - and components[2] == "Cargo.toml" - ): - manifest = tar.extractfile(member) - metadata = tomllib.load(manifest) - directory_name = components[1] - package = metadata["package"] - package_version = package["version"] - package_name = package["name"] - if directory_name != package_name and ( - not directory_name.startswith(package_name) - and directory_name[-len(package_version) :] != package_version - ): - raise RuntimeError( - "Unexpected disagreement between directory name " - f"{directory_name} and package name in Cargo.toml, " - f"{package_name}" - ) - continue - - if ( - len(components) == 4 - and components[0] == "vendor" - and components[2] == "src" - and components[3] == "lib.rs" - ): - size = member.size - if size != 0: - if components[1] == directory_name: - yield f"Provides: bundled(crate({package_name})) = {package_version}" - else: - raise RuntimeError( - "Found an entry for bundled provides, but no version information" - ) - - def edit_specfile(specfile_path, *, release_version=None, sources=None, arbitrary=None): """ Edit the specfile in place diff --git a/release_management/create_artifacts.py b/release_management/create_artifacts.py index 612aee0..d1fbc87 100755 --- a/release_management/create_artifacts.py +++ b/release_management/create_artifacts.py @@ -28,7 +28,6 @@ ReleaseVersion, calc_pre_release_suffix, edit_specfile, - get_bundled_provides, get_package_info, get_python_package_info, make_source_tarball, @@ -139,17 +138,6 @@ def _stratisd_artifacts(namespace): os.rename(vendor_tarfile_name, vendor_tarfile_path) - def insert_bundled_provides(spec): - """ - Insert bundled provides in the spec file. - """ - with spec.sections() as sections: - preamble = sections.package - preamble.append("%if 0%{?rhel}") - preamble.extend(get_bundled_provides(vendor_tarfile_path)) - preamble.append("%endif") - preamble.append("") - edit_specfile( specfile_path, release_version=release_version, @@ -157,7 +145,6 @@ def insert_bundled_provides(spec): os.path.basename(path) for path in [source_tarfile_path, vendor_tarfile_path] ], - arbitrary=insert_bundled_provides, ) diff --git a/release_management/gen_bundled_provides.py b/release_management/gen_bundled_provides.py deleted file mode 100755 index 5dc015d..0000000 --- a/release_management/gen_bundled_provides.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/python3 -# -# Copyright 2023 Red Hat, Inc. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -""" -Generate vendored provides list from vendor tarfile. -""" - -# isort: STDLIB -import argparse -import os -import sys - -# isort: LOCAL -from _utils import get_bundled_provides - - -def main(): - """ - Main function - """ - - parser = argparse.ArgumentParser( - description=( - "Generate a list of bundled provides suitable for including in an " - "rpm spec file. Include in the list only those dependencies which " - "have source code in the vendor tarfile. Prints list to stdout." - ) - ) - - parser.add_argument( - "vendor_tarfile", - action="store", - help="path to vendor tarfile", - type=os.path.abspath, - ) - - namespace = parser.parse_args() - - for line in get_bundled_provides(namespace.vendor_tarfile): - print(line) - - return 0 - - -if __name__ == "__main__": - try: - main() - except Exception as err: # pylint: disable=broad-except - print(err) - sys.exit(1)