{"action":"closed","number":2857,"pull_request":{"url":"https://api.github.com/repos/rust-lang/cargo/pulls/2857","id":77057900,"html_url":"https://github.com/rust-lang/cargo/pull/2857","diff_url":"https://github.com/rust-lang/cargo/pull/2857.diff","patch_url":"https://github.com/rust-lang/cargo/pull/2857.patch","issue_url":"https://api.github.com/repos/rust-lang/cargo/issues/2857","number":2857,"state":"closed","locked":false,"title":"Add support local mirrors of registries, take 2","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"body":"This series of commits culminates in first class support in Cargo for local mirrors of registries. This is implemented through a number of other more generic mechanisms, and extra support was added along the way. The highlights of this PR, however, are:\r\n\r\n### Source redirection\r\n\r\nNew `.cargo/config` keys have been added to enable *replacing one source with another*. This functionality is intended to be used for mirrors of the main registry or otherwise one to one source correspondences. The support looks like:\r\n\r\n```toml\r\n# in .cargo/config\r\n[source.crates-io]\r\nreplace-with = 'my-awesome-registry'\r\n\r\n[source.my-awesome-registry]\r\nregistry = 'https://github.com/my-awesome/registry-index'\r\n```\r\n\r\nThis configuration means that instead of using `crates-io` (e.g. `https://github.com/rust-lang/crates.io-index`), Cargo will query the `my-awesome-registry` source instead (configured to a different index here). This alternate source **must be the exact same as the crates.io index**. Cargo assumes that replacement sources are exact 1:1 mirrors in this respect, and the following support is designed around that assumption.\r\n\r\nWhen generating a lock file for crate using a replacement registry, the *original registry* will be encoded into the lock file. For example in the configuration above, all lock files will still mention crates.io as the registry that packages originated from. This semantically represents how crates.io is the source of truth for all crates, and this is upheld because all replacements have a 1:1 correspondance.\r\n\r\nOverall, this means that no matter what replacement source you're working with, you can ship your lock file to anyone else and you'll all still have verifiably reproducible builds!\r\n\r\n### Adding sha256 checksums to the lock file\r\n\r\nWith the above support for custom registries, it's now possible for a project to be downloading crates from any number of sources. One of Cargo's core goals is reproducible builds, and with all these new sources of information it may be easy for a few situations to arise:\r\n\r\n1. A local replacement of crates.io could be corrupt\r\n2. A local replacement of crates.io could have made subtle changes to crates\r\n\r\nIn both of these cases, Cargo would today simply give non-reproducible builds. To help assuage these concerns, Cargo will now track the sha256 checksum of all crates from registries in the lock file. Whenever a `Cargo.lock` is generated from now on it will contain a `[metadata]` section which lists the sha256 checksum of all crates in the lock file (or `<none>` if the sha256 checksum isn't known).\r\n\r\nCargo already checks registry checksums against what's actually downloaded, and Cargo will now verify between iterations of the lock file that checksums remain the same as well. This means that if a local replacement registry is **not** in a 1:1 correspondance with crates.io, the lock file will prevent the build from progressing until the discrepancy is resolved.\r\n\r\n### Local Registries\r\n\r\nIn addition to the support above, there is now a new kind of source in Cargo, a \"local registry\", which is intended to be a subset of the crates.io ecosystem purposed for a local build for any particular project here or there. The way to enable this looks like:\r\n\r\n```toml\r\n# in .cargo/config\r\n[source.crates-io]\r\nreplace-with = 'my-awesome-registry'\r\n\r\n[source.my-awesome-registry]\r\nlocal-registry = 'path/to/my/local/registry'\r\n```\r\n\r\nThis local registry is expected to have two components:\r\n\r\n1. A directory called `index` which matches the same structure as the crates.io index. The `config.json` file is not required here.\r\n2. Inside the registry directory are any number of `.crate` files (downloaded from crates.io). Each crate file has the name `<package>-<version>.crate`.\r\n\r\nThis local registry must currently be managed manually, but I plan on publishing and maintaining a Cargo subcommand to manage a local registry. It will have options to do things like:\r\n\r\n1. Sync a local registry with a `Cargo.lock`\r\n2. Add a registry package to a local registry\r\n3. Remove a package from a local registry\r\n\r\n### Directory registries\r\n\r\nIn addition to local registries, Cargo also supports a \"directory source\" like so\r\n\r\n```toml\r\n# in .cargo/config\r\n[source.crates-io]\r\nreplace-with = 'my-awesome-registry'\r\n\r\n[source.my-awesome-registry]\r\ndirectory = 'path/to/some/sources'\r\n```\r\n\r\nA directory source is similar to a local registry above, except that all the crates are unpacked and visible as vendored source. This format is suitable for checking into source trees, like Gecko's.\r\n\r\nUnlike local registries above we don't have a tarball to verify the crates.io checksum with, but each vendored dependency has metadata containing what it *would* have been. To further prevent modifications by accident, the metadata contains the checksum of each file which should prevent accidental local modifications and steer towards `[replace]` as the mechanism to edit dependencies if necessary.\r\n\r\n### What's all this for?\r\n\r\nThis is quite a bit of new features! What's all this meant to do? Some example scenarios that this is envisioned to solve are:\r\n\r\n1. Supporting mirrors for crates.io in a first class fashion. Once we have the ability to spin up your own local registry, it should be easy to locally select a new mirror.\r\n2. Supporting round-robin mirrors, this provides an easy vector for configuration of \"instead of crates.io hit the first source in this list that works\"\r\n3. Build environments where network access is not an option. Preparing a local registry ahead-of-time (from a known good lock file) will be a vector to ensure that all Rust dependencies are locally available.\r\n   * Note this is intended to include use cases like Debian and Gecko\r\n\r\n### What's next?\r\n\r\nEven with the new goodies here, there's some more vectors through which this can be expanded:\r\n\r\n* Support for running your own mirror of crates.io needs to be implemented to be \"easy to do\". There should for example be a `cargo install foo` available to have everything \"Just Work\".\r\n* Replacing a source with a list of sources (attempted in round robin fashion) needs to be implemented\r\n* Eventually this support will be extended to the `Cargo.toml` file itself. For example:\r\n  * packages should be downloadable from multiple registries\r\n  * replacement sources should be encodable into `Cargo.toml` (note that these replacements, unlike the ones above, would be encoded into `Cargo.lock`)\r\n  * adding multiple mirrors to a `Cargo.toml` should be supported\r\n* Implementing the subcommand above to manage local registries needs to happen (I will attend to this shortly)","created_at":"2016-07-12T03:53:04Z","updated_at":"2016-08-02T00:55:13Z","closed_at":"2016-08-02T00:55:13Z","merged_at":"2016-08-02T00:55:13Z","merge_commit_sha":"63ac9e1b4d978302356bfd0aeeab4aeafb620b48","assignee":{"login":"brson","id":147214,"avatar_url":"https://avatars.githubusercontent.com/u/147214?v=3","gravatar_id":"","url":"https://api.github.com/users/brson","html_url":"https://github.com/brson","followers_url":"https://api.github.com/users/brson/followers","following_url":"https://api.github.com/users/brson/following{/other_user}","gists_url":"https://api.github.com/users/brson/gists{/gist_id}","starred_url":"https://api.github.com/users/brson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brson/subscriptions","organizations_url":"https://api.github.com/users/brson/orgs","repos_url":"https://api.github.com/users/brson/repos","events_url":"https://api.github.com/users/brson/events{/privacy}","received_events_url":"https://api.github.com/users/brson/received_events","type":"User","site_admin":false},"assignees":[{"login":"brson","id":147214,"avatar_url":"https://avatars.githubusercontent.com/u/147214?v=3","gravatar_id":"","url":"https://api.github.com/users/brson","html_url":"https://github.com/brson","followers_url":"https://api.github.com/users/brson/followers","following_url":"https://api.github.com/users/brson/following{/other_user}","gists_url":"https://api.github.com/users/brson/gists{/gist_id}","starred_url":"https://api.github.com/users/brson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brson/subscriptions","organizations_url":"https://api.github.com/users/brson/orgs","repos_url":"https://api.github.com/users/brson/repos","events_url":"https://api.github.com/users/brson/events{/privacy}","received_events_url":"https://api.github.com/users/brson/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/rust-lang/cargo/pulls/2857/commits","review_comments_url":"https://api.github.com/repos/rust-lang/cargo/pulls/2857/comments","review_comment_url":"https://api.github.com/repos/rust-lang/cargo/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rust-lang/cargo/issues/2857/comments","statuses_url":"https://api.github.com/repos/rust-lang/cargo/statuses/63ac9e1b4d978302356bfd0aeeab4aeafb620b48","head":{"label":"alexcrichton:redirect-sources","ref":"redirect-sources","sha":"63ac9e1b4d978302356bfd0aeeab4aeafb620b48","user":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"repo":{"id":20969258,"name":"cargo","full_name":"alexcrichton/cargo","owner":{"login":"alexcrichton","id":64996,"avatar_url":"https://avatars.githubusercontent.com/u/64996?v=3","gravatar_id":"","url":"https://api.github.com/users/alexcrichton","html_url":"https://github.com/alexcrichton","followers_url":"https://api.github.com/users/alexcrichton/followers","following_url":"https://api.github.com/users/alexcrichton/following{/other_user}","gists_url":"https://api.github.com/users/alexcrichton/gists{/gist_id}","starred_url":"https://api.github.com/users/alexcrichton/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alexcrichton/subscriptions","organizations_url":"https://api.github.com/users/alexcrichton/orgs","repos_url":"https://api.github.com/users/alexcrichton/repos","events_url":"https://api.github.com/users/alexcrichton/events{/privacy}","received_events_url":"https://api.github.com/users/alexcrichton/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/alexcrichton/cargo","description":"Cargo Experiments","fork":true,"url":"https://api.github.com/repos/alexcrichton/cargo","forks_url":"https://api.github.com/repos/alexcrichton/cargo/forks","keys_url":"https://api.github.com/repos/alexcrichton/cargo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alexcrichton/cargo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alexcrichton/cargo/teams","hooks_url":"https://api.github.com/repos/alexcrichton/cargo/hooks","issue_events_url":"https://api.github.com/repos/alexcrichton/cargo/issues/events{/number}","events_url":"https://api.github.com/repos/alexcrichton/cargo/events","assignees_url":"https://api.github.com/repos/alexcrichton/cargo/assignees{/user}","branches_url":"https://api.github.com/repos/alexcrichton/cargo/branches{/branch}","tags_url":"https://api.github.com/repos/alexcrichton/cargo/tags","blobs_url":"https://api.github.com/repos/alexcrichton/cargo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alexcrichton/cargo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alexcrichton/cargo/git/refs{/sha}","trees_url":"https://api.github.com/repos/alexcrichton/cargo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alexcrichton/cargo/statuses/{sha}","languages_url":"https://api.github.com/repos/alexcrichton/cargo/languages","stargazers_url":"https://api.github.com/repos/alexcrichton/cargo/stargazers","contributors_url":"https://api.github.com/repos/alexcrichton/cargo/contributors","subscribers_url":"https://api.github.com/repos/alexcrichton/cargo/subscribers","subscription_url":"https://api.github.com/repos/alexcrichton/cargo/subscription","commits_url":"https://api.github.com/repos/alexcrichton/cargo/commits{/sha}","git_commits_url":"https://api.github.com/repos/alexcrichton/cargo/git/commits{/sha}","comments_url":"https://api.github.com/repos/alexcrichton/cargo/comments{/number}","issue_comment_url":"https://api.github.com/repos/alexcrichton/cargo/issues/comments{/number}","contents_url":"https://api.github.com/repos/alexcrichton/cargo/contents/{+path}","compare_url":"https://api.github.com/repos/alexcrichton/cargo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alexcrichton/cargo/merges","archive_url":"https://api.github.com/repos/alexcrichton/cargo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alexcrichton/cargo/downloads","issues_url":"https://api.github.com/repos/alexcrichton/cargo/issues{/number}","pulls_url":"https://api.github.com/repos/alexcrichton/cargo/pulls{/number}","milestones_url":"https://api.github.com/repos/alexcrichton/cargo/milestones{/number}","notifications_url":"https://api.github.com/repos/alexcrichton/cargo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alexcrichton/cargo/labels{/name}","releases_url":"https://api.github.com/repos/alexcrichton/cargo/releases{/id}","deployments_url":"https://api.github.com/repos/alexcrichton/cargo/deployments","created_at":"2014-06-18T16:22:37Z","updated_at":"2014-06-25T22:54:56Z","pushed_at":"2016-08-01T18:40:24Z","git_url":"git://github.com/alexcrichton/cargo.git","ssh_url":"git@github.com:alexcrichton/cargo.git","clone_url":"https://github.com/alexcrichton/cargo.git","svn_url":"https://github.com/alexcrichton/cargo","homepage":null,"size":11727,"stargazers_count":0,"watchers_count":0,"language":"Rust","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rust-lang:master","ref":"master","sha":"34175981635cb6c827bc59a6ccf980e83fef57fb","user":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":17420913,"name":"cargo","full_name":"rust-lang/cargo","owner":{"login":"rust-lang","id":5430905,"avatar_url":"https://avatars.githubusercontent.com/u/5430905?v=3","gravatar_id":"","url":"https://api.github.com/users/rust-lang","html_url":"https://github.com/rust-lang","followers_url":"https://api.github.com/users/rust-lang/followers","following_url":"https://api.github.com/users/rust-lang/following{/other_user}","gists_url":"https://api.github.com/users/rust-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/rust-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rust-lang/subscriptions","organizations_url":"https://api.github.com/users/rust-lang/orgs","repos_url":"https://api.github.com/users/rust-lang/repos","events_url":"https://api.github.com/users/rust-lang/events{/privacy}","received_events_url":"https://api.github.com/users/rust-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rust-lang/cargo","description":"The Rust package manager","fork":false,"url":"https://api.github.com/repos/rust-lang/cargo","forks_url":"https://api.github.com/repos/rust-lang/cargo/forks","keys_url":"https://api.github.com/repos/rust-lang/cargo/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rust-lang/cargo/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rust-lang/cargo/teams","hooks_url":"https://api.github.com/repos/rust-lang/cargo/hooks","issue_events_url":"https://api.github.com/repos/rust-lang/cargo/issues/events{/number}","events_url":"https://api.github.com/repos/rust-lang/cargo/events","assignees_url":"https://api.github.com/repos/rust-lang/cargo/assignees{/user}","branches_url":"https://api.github.com/repos/rust-lang/cargo/branches{/branch}","tags_url":"https://api.github.com/repos/rust-lang/cargo/tags","blobs_url":"https://api.github.com/repos/rust-lang/cargo/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rust-lang/cargo/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rust-lang/cargo/git/refs{/sha}","trees_url":"https://api.github.com/repos/rust-lang/cargo/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rust-lang/cargo/statuses/{sha}","languages_url":"https://api.github.com/repos/rust-lang/cargo/languages","stargazers_url":"https://api.github.com/repos/rust-lang/cargo/stargazers","contributors_url":"https://api.github.com/repos/rust-lang/cargo/contributors","subscribers_url":"https://api.github.com/repos/rust-lang/cargo/subscribers","subscription_url":"https://api.github.com/repos/rust-lang/cargo/subscription","commits_url":"https://api.github.com/repos/rust-lang/cargo/commits{/sha}","git_commits_url":"https://api.github.com/repos/rust-lang/cargo/git/commits{/sha}","comments_url":"https://api.github.com/repos/rust-lang/cargo/comments{/number}","issue_comment_url":"https://api.github.com/repos/rust-lang/cargo/issues/comments{/number}","contents_url":"https://api.github.com/repos/rust-lang/cargo/contents/{+path}","compare_url":"https://api.github.com/repos/rust-lang/cargo/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rust-lang/cargo/merges","archive_url":"https://api.github.com/repos/rust-lang/cargo/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rust-lang/cargo/downloads","issues_url":"https://api.github.com/repos/rust-lang/cargo/issues{/number}","pulls_url":"https://api.github.com/repos/rust-lang/cargo/pulls{/number}","milestones_url":"https://api.github.com/repos/rust-lang/cargo/milestones{/number}","notifications_url":"https://api.github.com/repos/rust-lang/cargo/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rust-lang/cargo/labels{/name}","releases_url":"https://api.github.com/repos/rust-lang/cargo/releases{/id}","deployments_url":"https://api.github.com/repos/rust-lang/cargo/deployments","created_at":"2014-03-04T23:20:42Z","updated_at":"2016-07-31T13:12:37Z","pushed_at":"2016-08-02T00:55:12Z","git_url":"git://github.com/rust-lang/cargo.git","ssh_url":"git@github.com:rust-lang/cargo.git","clone_url":"https://github.com/rust-lang/cargo.git","svn_url":"https://github.com/rust-lang/cargo","homepage":"https://crates.io/","size":72724,"stargazers_count":1746,"watchers_count":1746,"language":"Rust","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":412,"mirror_url":null,"open_issues_count":330,"forks":412,"open_issues":330,"watchers":1746,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rust-lang/cargo/pulls/2857"},"html":{"href":"https://github.com/rust-lang/cargo/pull/2857"},"issue":{"href":"https://api.github.com/repos/rust-lang/cargo/issues/2857"},"comments":{"href":"https://api.github.com/repos/rust-lang/cargo/issues/2857/comments"},"review_comments":{"href":"https://api.github.com/repos/rust-lang/cargo/pulls/2857/comments"},"review_comment":{"href":"https://api.github.com/repos/rust-lang/cargo/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rust-lang/cargo/pulls/2857/commits"},"statuses":{"href":"https://api.github.com/repos/rust-lang/cargo/statuses/63ac9e1b4d978302356bfd0aeeab4aeafb620b48"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"bors","id":3372342,"avatar_url":"https://avatars.githubusercontent.com/u/3372342?v=3","gravatar_id":"","url":"https://api.github.com/users/bors","html_url":"https://github.com/bors","followers_url":"https://api.github.com/users/bors/followers","following_url":"https://api.github.com/users/bors/following{/other_user}","gists_url":"https://api.github.com/users/bors/gists{/gist_id}","starred_url":"https://api.github.com/users/bors/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bors/subscriptions","organizations_url":"https://api.github.com/users/bors/orgs","repos_url":"https://api.github.com/users/bors/repos","events_url":"https://api.github.com/users/bors/events{/privacy}","received_events_url":"https://api.github.com/users/bors/received_events","type":"User","site_admin":false},"comments":57,"review_comments":14,"commits":12,"additions":3242,"deletions":912,"changed_files":54}}
{"actor":{"display_login":"bors"}}