From 4d275b32c16370a82a486098855fc7c40544c6b3 Mon Sep 17 00:00:00 2001 From: mulhern Date: Mon, 11 Mar 2024 14:07:54 -0400 Subject: [PATCH] No longer unpack crate on top of GitHub release This means it is no longer necessary to generate the crate as a source artifact or ensure that the vendor tar file is built from the packaged source. Signed-off-by: mulhern --- mockbuild_test/stratisd.spec | 7 ------- release_management/_utils.py | 27 +++++--------------------- release_management/create_artifacts.py | 10 ++-------- release_management/create_release.py | 2 +- 4 files changed, 8 insertions(+), 38 deletions(-) diff --git a/mockbuild_test/stratisd.spec b/mockbuild_test/stratisd.spec index e2a4ff4..8cfb17e 100644 --- a/mockbuild_test/stratisd.spec +++ b/mockbuild_test/stratisd.spec @@ -12,7 +12,6 @@ License: MPL-2.0 URL: https://github.com/stratis-storage/stratisd Source0: %{url}/archive/stratisd-v%{version}/%{name}-%{version}.tar.gz Source1: %{url}/releases/download/stratisd-v%{version}/%{name}-%{version}-vendor.tar.gz -Source2: %{crates_source} ExclusiveArch: %{rust_arches} @@ -84,13 +83,7 @@ Requires: stratisd %{summary}. This package should not be used in production. %prep -# Extract the upstream crate on top of the extracted GitHub release, overwriting -# changed files. The primary purpose of this step is to ensure that the -# Cargo.toml that is used in building is the one that is generated by -# cargo-publish and cargo-package, not the file with path dependencies that -# GitHub packs up. %autosetup -n stratisd-stratisd-v%{version} -tar --strip-components=1 --extract --overwrite --file %{SOURCE2} %if 0%{?rhel} %cargo_prep -V 1 diff --git a/release_management/_utils.py b/release_management/_utils.py index 68fdf07..5e61474 100755 --- a/release_management/_utils.py +++ b/release_management/_utils.py @@ -276,35 +276,18 @@ def vendor(manifest_abs_path, release_version, *, filterer=False): :param str manifest_abs_path: manifest path (absolute) :param ReleaseVersion release_version: the release version :param bool filterer: filter dependencies in vendor tarfile - :return: name of vendored tarfile and path of crate relative to manifest - :rtype: str * str + :return: name of vendored tarfile + :rtype: str """ vendor_dir = "vendor" - subprocess.run( - ["cargo", "package", "--no-verify", f"--manifest-path={manifest_abs_path}"], - check=True, - ) - - stratis_package_name = f"stratisd-{release_version.base_only()}" - - crate_path = os.path.join("target", "package", f"{stratis_package_name}.crate") - - subprocess.run(["tar", "--extract", f"--file={crate_path}"], check=True) - - package_manifest = os.path.join( - os.path.dirname(manifest_abs_path), - stratis_package_name, - "Cargo.toml", - ) - if filterer: subprocess.run( [ "cargo", "vendor-filterer", - f"--manifest-path={package_manifest}", + f"--manifest-path={manifest_abs_path}", vendor_dir, ], check=True, @@ -316,7 +299,7 @@ def vendor(manifest_abs_path, release_version, *, filterer=False): "cargo", "vendor", "--quiet", - f"--manifest-path={package_manifest}", + f"--manifest-path={manifest_abs_path}", vendor_dir, ], check=True, @@ -339,7 +322,7 @@ def vendor(manifest_abs_path, release_version, *, filterer=False): check=True, ) - return (vendor_tarfile_name, crate_path) + return vendor_tarfile_name def make_source_tarball(package_name, release_version, output_dir): diff --git a/release_management/create_artifacts.py b/release_management/create_artifacts.py index 3211469..612aee0 100755 --- a/release_management/create_artifacts.py +++ b/release_management/create_artifacts.py @@ -129,18 +129,12 @@ def _stratisd_artifacts(namespace): ) print(os.path.relpath(source_tarfile_path)) - (vendor_tarfile_name, cargo_crate_path) = vendor( + vendor_tarfile_name = vendor( manifest_abs_path, release_version, filterer=filtered, ) - crate_path = os.path.join( - output_path, f"stratisd-{release_version.to_crate_str()}.crate" - ) - - os.rename(cargo_crate_path, crate_path) - vendor_tarfile_path = os.path.join(output_path, vendor_tarfile_name) os.rename(vendor_tarfile_name, vendor_tarfile_path) @@ -161,7 +155,7 @@ def insert_bundled_provides(spec): release_version=release_version, sources=[ os.path.basename(path) - for path in [source_tarfile_path, vendor_tarfile_path, crate_path] + for path in [source_tarfile_path, vendor_tarfile_path] ], arbitrary=insert_bundled_provides, ) diff --git a/release_management/create_release.py b/release_management/create_release.py index 64c2f33..f762ef2 100755 --- a/release_management/create_release.py +++ b/release_management/create_release.py @@ -203,7 +203,7 @@ def tag_rust_library(namespace, name): additional_assets = [] if not namespace.no_vendor: filtered = namespace.vendor_method == "filtered" - (vendor_tarfile_name, _) = vendor( + vendor_tarfile_name = vendor( manifest_abs_path, ReleaseVersion(release_version), filterer=filtered,