Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove gen_bundled_provides.py #516

Merged
merged 1 commit into from
Oct 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 0 additions & 47 deletions release_management/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
# isort: STDLIB
import os
import subprocess
import tarfile
import tomllib
from datetime import datetime
from getpass import getpass
Expand Down Expand Up @@ -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
Expand Down
13 changes: 0 additions & 13 deletions release_management/create_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
ReleaseVersion,
calc_pre_release_suffix,
edit_specfile,
get_bundled_provides,
get_package_info,
get_python_package_info,
make_source_tarball,
Expand Down Expand Up @@ -139,25 +138,13 @@ 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,
sources=[
os.path.basename(path)
for path in [source_tarfile_path, vendor_tarfile_path]
],
arbitrary=insert_bundled_provides,
)


Expand Down
62 changes: 0 additions & 62 deletions release_management/gen_bundled_provides.py

This file was deleted.