Skip to content

Commit

Permalink
avoid name clash in cargo crates downloaded from git repositories
Browse files Browse the repository at this point in the history
Crates referenced by their git revision have a version but might have
different revisions.
The source filename ignored the revision such that sources from
different revisions were considered the same file which either fails the
checksum verification or the build.
Append the revision if specified to disambiguate them.
  • Loading branch information
Flamefire committed Oct 14, 2024
1 parent 3cd59c8 commit 6bd93b5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions easybuild/easyblocks/generic/cargo.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,15 @@ def extra_options(extra_vars=None):
return extra_vars

@staticmethod
def crate_src_filename(pkg_name, pkg_version, *args):
"""Crate tarball filename based on package name and version"""
return "{0}-{1}.tar.gz".format(pkg_name, pkg_version)
def crate_src_filename(pkg_name, pkg_version, _=None, rev=None):
"""Crate tarball filename based on package name, version and optionally git revision"""
parts = [pkg_name, pkg_version]
if rev is not None:
parts.append(rev)
return '-'.join(parts) + ".tar.gz"

@staticmethod
def crate_download_filename(pkg_name, pkg_version, *args):
def crate_download_filename(pkg_name, pkg_version):
"""Crate download filename based on package name and version"""
return "{0}/{1}/download".format(pkg_name, pkg_version)

Expand Down Expand Up @@ -148,7 +151,7 @@ def __init__(self, *args, **kwargs):
repo_name = repo_name[:-4]
sources.append({
'git_config': {'url': url, 'repo_name': repo_name, 'commit': rev},
'filename': self.crate_src_filename(crate, version),
'filename': self.crate_src_filename(crate, version, rev=rev),
})

# copy EasyConfig instance before we make changes to it
Expand Down

0 comments on commit 6bd93b5

Please sign in to comment.