mirror of
https://github.com/devvmhq/devvm.git
synced 2026-12-01 06:23:17 -10:00
What a build VM downloads failed on a network's first hiccup: curl's --retry 3 skips a connection cut mid-transfer (exit 18) and waits for ever on a stall, apt's retries were off, and oh-my-bash's clone had none. - devvm-fetch: each try has --connect-timeout 20 and a stall limit (--speed-limit 1024 --speed-time 30), and any failure is tried again, five tries in all, from where it stopped (-C -): curl's own --retry, --retry-all-errors included, starts again from nothing (measured on curl 8.7). A server that can't resume (33, 36) starts it again; a file that came whole and checks out ends the loop; a file that doesn't check out is fetched again from nothing once, as a resume may have joined two versions. A redirect goes only to https (--proto-redir =https), so no try or resume moves to plain http. TestDevvmFetchTries runs it against a server that cuts, ignores ranges, changes the file, fails and redirects to http. - apt.sh: package lists still fail fast (exit 75 when no source answers), and once they're in, the build's installs get Acquire::Retries "3", with apt's own backoff. - crane (oci/build.sh, the --from conversion, which has no devvm-fetch): --retry 5 --retry-all-errors --retry-delay 2 and the same timeouts. - oh-my-bash: the clone is tried five times in all, with git's low-speed limit. Docs: images.md's Building and Base's packages, customizing.md's devvm-fetch; the CHANGELOG's second highlight, which says which downloads resume, and What to do 1, which names the layers and --from bases that rebuild and pull again; the release page's A first run on a bad network. Image keys change: base's (base.sh, apt.sh, omb.sh), every layer's (apt.sh is in each), and a --from conversion's (oci/build.sh). Tool images' keys don't (shared-tools/build.sh is unchanged). Co-Authored-By: Claude Opus 5.5 <[email protected]>
27 lines
1.4 KiB
Bash
Executable File
27 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# oh-my-bash: themed prompt, completions, aliases
|
|
set -euxo pipefail
|
|
# Pinned commit (scripts/bump.sh updates it); git checks the content against it.
|
|
omb_commit=94c2977eda06f230aafa9628fcd869123f01896b
|
|
|
|
# Its own installer, from the pinned commit and cloning from it (OSH_REPOSITORY), so nothing comes
|
|
# from master. Replaces ~/.bashrc (backed up first); re-add the ~/.bashrc.d loader afterwards.
|
|
# A clone that fails, or stays slower than 1 KB/s for 30 s, is tried again, five tries in all.
|
|
tmp=$(mktemp -d)
|
|
for try in 1 2 3 4 5; do
|
|
GIT_HTTP_LOW_SPEED_LIMIT=1024 GIT_HTTP_LOW_SPEED_TIME=30 \
|
|
git clone -q https://github.com/ohmybash/oh-my-bash "$tmp/omb" && break
|
|
rm -rf "$tmp/omb"
|
|
(( try < 5 )) || { echo "omb.sh: cloning oh-my-bash failed $try times" >&2; exit 1; }
|
|
sleep $(( try * 2 ))
|
|
done
|
|
git -C "$tmp/omb" checkout -q -B pinned "$omb_commit"
|
|
OSH_REPOSITORY="$tmp/omb" bash "$tmp/omb/tools/install.sh" --unattended
|
|
rm -rf "$tmp"
|
|
git -C ~/.oh-my-bash rev-parse HEAD | grep -x "$omb_commit"
|
|
git -C ~/.oh-my-bash remote set-url origin https://github.com/ohmybash/oh-my-bash
|
|
grep -qs bashrc.d ~/.bashrc || echo 'for f in ~/.bashrc.d/*.sh; do [ -r "$f" ] && . "$f"; done' >> ~/.bashrc
|
|
# No background update checks; the image is rebuilt to update.
|
|
sed -i 's/^# *DISABLE_AUTO_UPDATE="true"/DISABLE_AUTO_UPDATE="true"/' ~/.bashrc
|
|
grep -q '^DISABLE_AUTO_UPDATE="true"' ~/.bashrc
|