Skip to content

Commit

Permalink
Merge pull request #511 from mulkieran/issue_project_694
Browse files Browse the repository at this point in the history
No longer unpack crate on top of GitHub release
  • Loading branch information
mulkieran authored Mar 12, 2024
2 parents 3caee8a + 4d275b3 commit e2898db
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 38 deletions.
7 changes: 0 additions & 7 deletions mockbuild_test/stratisd.spec
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down
27 changes: 5 additions & 22 deletions release_management/_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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):
Expand Down
10 changes: 2 additions & 8 deletions release_management/create_artifacts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion release_management/create_release.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit e2898db

Please sign in to comment.