Skip to content

Commit

Permalink
Remove gen_bundled_provides.py
Browse files Browse the repository at this point in the history
With automatic generation of bundled provides in Rust vendor tarfile via
macros, this script is no longer needed.

Signed-off-by: mulhern <[email protected]>
  • Loading branch information
mulkieran committed Oct 24, 2024
1 parent 611a6ba commit 2295837
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 122 deletions.
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.

0 comments on commit 2295837

Please sign in to comment.