Fix sync script for mismatched target string in URL

In nightly 2022-02-02, aarch64-apple-darwin's rust-docs actually points
to x86_64-apple-darwin's artifact URL. Most tier 2 targets'
rust-docs also forward to -unknown-linux-gnu with the same arch.

Not sure why they do so, but URL forwarding is implemented now.
main
oxalica 2 years ago
parent 9fb49daf1b
commit 264468bbc3
  1. 4
      flake.nix
  2. 23
      manifest.nix
  3. 25
      scripts/fetch.py

@ -147,6 +147,10 @@
extensions = [ "rustfmt" "rustc-dev" ];
targets = [ "aarch64-unknown-linux-gnu" ];
});
} // optionalAttrs (system == "aarch64-darwin") {
url-forward = assertUrl
nightly."2022-02-02".rust-docs
"https://static.rust-lang.org/dist/2022-02-02/rust-docs-nightly-x86_64-apple-darwin.tar.xz";
};
checkDrvs = optionalAttrs (elem system [ "aarch64-linux" "x86_64-linux" ]) {

@ -1,6 +1,6 @@
final: prev:
let
inherit (builtins) match;
inherit (builtins) match isString toString;
inherit (final.lib)
attrNames concatMap elemAt filter hasAttr mapAttrs mapAttrs' removeSuffix;
@ -67,8 +67,8 @@ let
# We use rustc version for all components to reduce manifest size.
# This version is just used for component derivation name.
version = "${v} (000000000 ${d})"; # "<version> (<commit-hash> yyyy-mm-dd)"
target =
mapAttrs' (targetIdx: hash: let
target = let
results = mapAttrs' (targetIdx: hash: let
target = targets.${targetIdx};
pkgNameStripped = removeSuffix "-preview" pkgName;
targetTail = if targetIdx == "_" then "" else "-" + target;
@ -78,11 +78,20 @@ let
else channel; # Otherwise, for beta/nightly channel, default to be "beta"/"nightly".
in {
name = target;
value = {
xz_url = "${distRoot}/${date}/${pkgNameStripped}-${urlVersion}${targetTail}.tar.xz";
xz_hash = hash;
} // (if pkgName == "rust" then rustPkgExtra pkg target else {});
value =
# Normally, hash is just the hash.
if isString hash then
{
xz_url = "${distRoot}/${date}/${pkgNameStripped}-${urlVersion}${targetTail}.tar.xz";
xz_hash = hash;
} // (if pkgName == "rust" then rustPkgExtra pkg target else {})
# But hash can be an integer to forward to another URL.
# This occurs in aarch64-apple-darwin rust-docs on 2022-02-02.
else
results.${targets."_${toString hash}"};
}) (removeAttrs hashes ["u"]);
in
results;
}) (removeAttrs manifest ["v" "d" "r" "p"]);
profiles = if p == null

@ -14,7 +14,7 @@ import requests
MAX_TRIES = 3
RETRY_DELAY = 3.0
SYNC_MAX_UPDATE = 8
SYNC_MAX_UPDATE = 32
MIN_STABLE_VERSION = '1.29.0'
MIN_BETA_DATE = MIN_NIGHTLY_DATE = datetime.date.fromisoformat('2018-09-13')
@ -145,6 +145,7 @@ def translate_dump_manifest(channel: str, manifest: str, f):
pkg_targets = sorted(pkg['target'].keys())
url_version = rustc_version
url_target_map = {}
for target_name in pkg_targets:
target = pkg['target'][target_name]
if not target['available']:
@ -153,9 +154,21 @@ def translate_dump_manifest(channel: str, manifest: str, f):
target_tail = '' if target_name == '*' else '-' + target_name
start = f'{DIST_ROOT}/{date}/{pkg_name_stripped}-'
end = f'{target_tail}.tar.xz'
# Occurs in nightly-2019-01-10. Maybe broken or hirarerchy change?
if url.startswith('nightly/'):
url = DIST_ROOT + url[7:]
# The target part may not be the same as current one.
# This occurs in `pkg.rust-std.target.aarch64-apple-darwin` of nightly-2022-02-02,
# which points to the URL of x86_64-apple-darwin rust-docs.
if not url.endswith(end):
assert url.startswith(start + default_url_version + '-') and url.endswith('.tar.xz')
url_target = url[len(start + default_url_version + '-'):-len('.tar.xz')]
assert url_target in pkg_targets
url_target_map[target_name] = url_target
continue
assert url.startswith(start) and url.endswith(end), f'Unexpected url: {url}'
url_version = url[len(start):-len(end)]
@ -163,6 +176,15 @@ def translate_dump_manifest(channel: str, manifest: str, f):
if url_version != default_url_version:
f.write(f'u={escape_nix_string(url_version)};')
for target_name in pkg_targets:
# Forward to another URL.
if target_name in url_target_map:
url_target = url_target_map[target_name]
assert pkg['target'][url_target] == pkg['target'][target_name]
url_target_id = compress_target(url_target)[1:]
assert url_target_id
f.write(f'{compress_target(target_name)}={url_target_id};')
continue
target = pkg['target'][target_name]
if not target['available']:
continue
@ -175,6 +197,7 @@ def translate_dump_manifest(channel: str, manifest: str, f):
expect_url = f'https://static.rust-lang.org/dist/{date}/{pkg_name_stripped}-{url_version}{target_tail}.tar.xz'
assert url == expect_url, f'Unexpected url: {url}, expecting: {expect_url}'
f.write(f'{compress_target(target_name)}="{hash}";')
f.write('};')
f.write('}\n')

Loading…
Cancel
Save