Ship the corrected bundled SQLite in device components and pinned builds
This commit is contained in:
+34
-4
@@ -61,15 +61,41 @@ def prepare(target, jobs, windows_updater=False):
|
||||
return platform, triple, image, binaries, cargo
|
||||
|
||||
|
||||
def crate_registry(work, docker, image, triple):
|
||||
# Old revisions can build entirely from the registry embedded in the image.
|
||||
# New lockfiles get a persistent package cache. Only Cargo fetch needs the
|
||||
# network; build scripts and the compiler always run without it.
|
||||
registry = work / "cargo-registry"
|
||||
mount = ["-v", f"{registry}:/packages", "-e", "CARGO_HOME=/packages"]
|
||||
fetch = ["--entrypoint", "cargo", image, "fetch", "--locked", "--target", triple]
|
||||
offline = [*docker, "--network=none"]
|
||||
cache = mount if registry.exists() else []
|
||||
probe = subprocess.run([*offline, *cache, *fetch, "--offline"], capture_output=True)
|
||||
if probe.returncode == 0:
|
||||
return cache
|
||||
|
||||
if not registry.exists():
|
||||
with tempfile.TemporaryDirectory(dir=work) as temporary:
|
||||
staging = Path(temporary) / "packages"
|
||||
staging.mkdir()
|
||||
subprocess.run([
|
||||
*offline, "-v", f"{staging}:/packages", "--entrypoint", "sh", image, "-c",
|
||||
"mkdir /packages/registry && cp -R /usr/local/cargo/registry/cache "
|
||||
"/usr/local/cargo/registry/index /packages/registry/",
|
||||
], check=True)
|
||||
staging.rename(registry)
|
||||
print("Fetching locked Cargo dependencies for " + triple, flush=True)
|
||||
subprocess.run([*docker, *mount, *fetch], check=True)
|
||||
return mount
|
||||
|
||||
|
||||
def build_archive(work, archive, revision, plan):
|
||||
platform, triple, image, binaries, cargo = plan
|
||||
source, cache = work / "src", work / "cargo"
|
||||
command = ["docker", "run", "--rm", "--pull=never", "--platform", platform, "--network=none",
|
||||
docker = ["docker", "run", "--rm", "--pull=never", "--platform", platform,
|
||||
"--read-only", "--cap-drop=ALL", "--security-opt=no-new-privileges",
|
||||
"--tmpfs", "/tmp:rw,exec", "--user", f"{os.getuid()}:{os.getgid()}",
|
||||
"-v", f"{source}:/src:ro", "-v", f"{cache}:/target", "-w", "/src",
|
||||
"-e", "CARGO_TARGET_DIR=/target", "--entrypoint", cargo[0], image, *cargo[1:]]
|
||||
print(shlex.join(command), flush=True)
|
||||
"-v", f"{source}:/src:ro", "-w", "/src"]
|
||||
os.umask(0o077)
|
||||
subprocess.run(["docker", "image", "inspect", image], check=True, stdout=subprocess.DEVNULL)
|
||||
work.mkdir(parents=True, exist_ok=True)
|
||||
@@ -85,6 +111,10 @@ def build_archive(work, archive, revision, plan):
|
||||
# Preserve unchanged inputs for Cargo. Changed inputs receive a fresh mtime
|
||||
# even when switching back to an older commit with an older Git timestamp.
|
||||
subprocess.run(["rsync", "-rlcp", "--delete", str(unpacked) + "/", source], check=True)
|
||||
registry = crate_registry(work, docker, image, triple)
|
||||
command = [*docker, "--network=none", *registry, "-v", f"{cache}:/target",
|
||||
"-e", "CARGO_TARGET_DIR=/target", "--entrypoint", cargo[0], image, *cargo[1:]]
|
||||
print(shlex.join(command), flush=True)
|
||||
subprocess.run(command, check=True)
|
||||
artifacts = staging / "artifacts"
|
||||
artifacts.mkdir()
|
||||
|
||||
Reference in New Issue
Block a user