mod source_fetch

module source_fetch

Fill the source checksum a version bump invalidates, the way eb --inject-checksums does: download each sources entry from the recipe’s own source_urls, in order, and hash the bytes.

A bump that changes the version clears the old digest because it is not a claim about the new tarball. EasyBuild’s answer is --inject-checksums, which fetches the artifact the recipe names and writes its SHA-256. This module does the same before emission, so the bumped recipe carries a real digest and the SBOM’s source component carries the same hash. Nothing here invents a URL. An entry with no URL, a git checkout, or a failed download stays unresolved and is reported as a residual with the reason, never filled. The one URL EasyBuild itself supplies is kept: PythonPackage (and an easyblock that takes its extra_options, such as CargoPythonPackage or PythonBundle) defaults source_urls to [PYPI_SOURCE] when the recipe leaves the list unset. That default is used only for the download. It is not written back into the recipe.

Functions

fn bump_release_commits(bundle: &mut PackageBundle, client: &dyn RegistryClient, old_version: &str, new_version: &str)

Move a local_* variable that pins the old release’s commit to the new release’s commit.

RStudio-Server writes the commit of its release tag into the build (local_git_rev, passed as RSTUDIO_GIT_REVISION_HASH); a version bump that keeps it names the old release’s commit in the new build. A 40-hex local_* value is moved only when it is the commit of the old release’s tag, the tag being the first source’s archive name (as the GitHub archive/ URL names it) with the new version replaced by the old one. Anything else is reported, never guessed.

fn bump_secondary_sources(bundle: &mut PackageBundle, client: &dyn RegistryClient, overrides: &std::collections::BTreeMap<String, crate::upstream::Override>, fetched: &mut Vec<SourceFetch>)

Move each later source whose version a local_* variable holds to its newest stable upstream release.

A source after the first counts when its file name holds the value of a version-valued local_* assignment and the sources list names that variable: gc’s 'libatomic_ops-%s.tar.gz' % local_libatomic_version. The component is the file name before the version (libatomic_ops), and its releases are read with the backends of crate::upstream from the source_urls that carry the version, keyed by the component in overrides. A newer release rewrites the variable, downloads the new file, and writes its digest where the old one was. Each source gets a secondary-source record: the move, that it is current, or why no version could be decided.

fn fetch_sources(recipe: &ResolvedEasyconfig, client: &dyn RegistryClient) -> Vec<SourceFetch>

Download and hash every sources entry of recipe.

fn plan_package_bump_fetching(request: &BumpPackageRequest, options: &PackageEmitOptions, client: &dyn RegistryClient) -> Result<(PackageBundle, Vec<SourceFetch>), PackageWorkflowError>

Plan a bump, then fill the source checksum the version change cleared.

The first pass emits the recipe at the new version, so its sources and source_urls resolve with the new templates. The first source’s digest is then passed as source_checksum and the bump is planned again, which is the existing, tested path for a stated checksum. Entries that could not be fetched, and sources after the first, become source:fetch residuals; the bump never invents a digest. A request that already states a checksum, or keeps the version, is planned once and unchanged.

With the new source in hand, every patch the tree could not decide is tried against it (see crate::patch_apply): a patch that applies is carried, one the release already contains or whose files are gone is dropped from the recipe, and only a patch that does neither stays undecided. strict_patches fails on those that remain.

fn plan_package_bump_fetching_with(request: &BumpPackageRequest, options: &PackageEmitOptions, client: &dyn RegistryClient, decisions: &BumpDecisions) -> Result<(PackageBundle, Vec<SourceFetch>), PackageWorkflowError>

plan_package_bump_fetching with the operator’s decisions.

A patch the source leaves undecided is replaced by a rebased file named for the new release (<Name>-<version>_<description>.patch, or the old name with its version replaced) when one sits beside the source recipe or under <letter>/<Name> of an easyconfigs root and applies to the new source. decisions.drop_patches then drop what the operator decided, with the reason in the plan, and decisions.latest_secondary moves version-pinned later sources (see bump_secondary_sources).

fn source_download_urls(recipe: &ResolvedEasyconfig, file: &SourceFile) -> Vec<String>

The URLs EasyBuild would try for file, in order: the entry’s own source_urls when the dict sets them, else the recipe’s, else the easyblock default from pypi_default_bases.

Structs and Unions

struct BumpDecisions

What a fetching bump takes from its operator rather than from evidence.

drop_patches: Vec<(String, String)>

Patches to drop, by file name, each with the reason the plan records. A name the recipe does not list fails the bump.

latest_secondary: bool

Move every later source whose version a local_* variable holds to its newest stable upstream release, read the way package latest reads the package’s own.

overrides: std::collections::BTreeMap<String, crate::upstream::Override>

Upstream overrides for those sources, keyed by the component name that precedes the version in the file name (libatomic_ops).

struct Respelling

A source download name the archive host served under the other spelling of the release tag.

from: String

Name the recipe asked for, which the host does not serve.

to: String

Name that served the archive.

struct SourceFetch

What happened to one sources entry.

filename: String

Name the artifact is saved under.

url: Option<String>

URL that served it, when one did.

sha256: Option<String>

SHA-256 of the downloaded bytes, when the download succeeded.

errors: Vec<String>

Every URL tried and why it failed, or why none could be tried.

bytes: Option<Vec<u8>>

Body of a successful download. Not part of sources.fetch.json; the index rewrite reads Cargo.lock out of it and then drops it.

respelled: Option<Respelling>

The recipe’s download name and the one that served the archive, when the release tag is spelled the other way: a project that moved from 1.0.8 to v1.0.10 tags serves /archive/v1.0.10.tar.gz and 404s on /archive/1.0.10.tar.gz. The recipe’s sources entry is rewritten to the name that served it.