Skip to content

Commit

Permalink
Add cargo vendor drop in style file
Browse files Browse the repository at this point in the history
Add support for cargo_vendors which should be pretty much the output
of a 'cargo vendor' run. This will be appended to any existing
.cargo/config.toml file in the sources. It is intended to mostly come
from the vendor.py in common but useful for other builds as well which
don't need to enable cargo_vendor in options.conf.

Signed-off-by: William Douglas <[email protected]>
  • Loading branch information
bryteise committed Jul 8, 2024
1 parent 43d564b commit 1f90fb5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
6 changes: 6 additions & 0 deletions autospec/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class Config(object):

def __init__(self, download_path):
"""Initialize Default configuration settings."""
self.cargo_vendors = ""
self.content = None # hack to avoid circular init dependency
self.extra_configure = ""
self.extra_configure32 = ""
Expand Down Expand Up @@ -991,6 +992,11 @@ def parse_config_files(self, bump, filemanager, version, requirements):
if not license.add_license(word, self.license_translations, self.license_blacklist):
print_warning("{}: blacklisted license {} ignored.".format(self.content.name + ".license", word))

# cargo_vendors is the output of 'cargo vendor' and should be read as is
content = self.read_file(os.path.join(self.download_path, "cargo_vendors"), track=True)
if content:
self.cargo_vendors = "".join(content)

if self.config_opts['use_clang']:
self.config_opts['funroll-loops'] = False
requirements.add_buildreq("llvm")
Expand Down
7 changes: 2 additions & 5 deletions autospec/specfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,14 +509,11 @@ def write_prep(self):
self.apply_patches()

# setup cargo.toml vendoring if needed
if self.config.config_opts['cargo_vendor']:
if self.config.cargo_vendors:
if self.config.subdir:
self._write_strip("pushd " + self.config.subdir)
self._write_strip("mkdir -p .cargo")
self._write_strip("echo '[source.crates-io]' >> .cargo/config.toml")
self._write_strip("""echo 'replace-with = "vendored-sources"' >> .cargo/config.toml""")
self._write_strip("echo '[source.vendored-sources]' >> .cargo/config.toml")
self._write_strip("""echo 'directory = "vendor"' >> .cargo/config.toml""")
self._write_strip(f"echo '{self.config.cargo_vendors}' >> .cargo/config.toml")
if self.config.subdir:
self._write_strip("popd")

Expand Down

0 comments on commit 1f90fb5

Please sign in to comment.