diff --git a/.tests/fakebin/_curl b/.tests/fakebin/_curl index 9905ef4..3b00f1d 100644 --- a/.tests/fakebin/_curl +++ b/.tests/fakebin/_curl @@ -8,7 +8,8 @@ # FAKE_BOOT_PW the password that gets a 200; anything else gets a 401 # FAKE_BOOT_CODE force a code (404, 000, 500 ...) whatever the password # FAKE_BWS_SUMS match (default) | mismatch | absent -# FAKE_FAIL=curl:deb | curl:chezmoi | curl:fzf fail just that one download +# FAKE_FAIL=curl:deb | curl:chezmoi | curl:fzf | curl:docker +# fail just that one download _fb=$(dirname "$0") # the fakebin directory url=; out=; prev=; readcfg=0 @@ -46,6 +47,16 @@ case $url in installer chezmoi "\$HOME/.local/bin"; exit 0 ;; *astral.sh/uv/install.sh*) installer uv "\$HOME/.local/bin"; exit 0 ;; +*get.docker.com*) + # The vendor's convenience script. It installs the engine and both plugins + # in one pass, so the stand-in drops a single `docker` fake -- `docker + # buildx` and `docker compose` are subcommands of that binary, not separate + # ones. Through emit, because the caller downloads this to a file and runs + # the file rather than feeding it to a shell through a pipe: POSIX sh has no + # pipefail, so the pipe form cannot tell a failed download from a good one. + # FAKE_FAIL=curl:docker is that download failing. + [ "$mode" = docker ] && exit 22 + installer docker "\$HOME/.local/bin" | emit; exit 0 ;; *go.dev/VERSION*) echo go1.99.0; exit 0 ;; *api.github.com*) diff --git a/.tests/fakebin/_fake b/.tests/fakebin/_fake index a544c93..4211c6f 100755 --- a/.tests/fakebin/_fake +++ b/.tests/fakebin/_fake @@ -31,6 +31,10 @@ # saves the other thirty. # FAKE_FAIL=npm:batch the same shape for npm. # FAKE_FAIL=curl:deb curl fails only for the .deb download. +# FAKE_FAIL=curl:docker curl fails only for the get.docker.com script. +# That is how the docker group's failure path is +# reached: one note_fail, nothing executed, and +# the other two rows reported as not attempted. # # Several may be combined: FAKE_FAIL=brew,apt-get:batch set -u @@ -79,15 +83,19 @@ apt-cache) # # gh genuinely absent -- `apt-cache policy` prints nothing. The # manifest's real example of a name that falls through to brew. - # docker-ce present in the cache but with `Candidate: (none)`, because - # something else Conflicts/Replaces it. `apt-cache show` exits - # 0 for this, which is why the old probe kept it in the batch - # and let apt refuse all thirty packages at once. + # nvidia-container-toolkit + # present in the cache but with `Candidate: (none)`: it is + # published from NVIDIA's own repository, which nothing here + # configures. `apt-cache show` exits 0 for this, which is why + # the old probe kept it in the batch and let apt refuse all + # thirty packages at once. (docker-ce used to be this example; + # the docker rows install from get.docker.com now and never + # reach apt at all, so the live case is NVIDIA's.) case ${1:-} in policy) case ${2:-} in gh) exit 0 ;; - docker-ce) printf '%s:\n Installed: (none)\n Candidate: (none)\n' "$2"; exit 0 ;; + nvidia-container-toolkit) printf '%s:\n Installed: (none)\n Candidate: (none)\n' "$2"; exit 0 ;; esac printf '%s:\n Installed: (none)\n Candidate: 1.0-fake\n' "$2"; exit 0 ;; esac diff --git a/.tests/seal.sh b/.tests/seal.sh index 646220d..7c77625 100755 --- a/.tests/seal.sh +++ b/.tests/seal.sh @@ -38,7 +38,9 @@ REAL='sh awk grep sed sort cut tr head tail id uname mkdir cp mv rm cat # bws absent is what makes the private tier actually install it. FAKE='curl apt-get apt-cache brew npm uv snap flatpak xcode-select git dpkg unzip chezmoi' -OPTIONAL='sudo fzf bws nvim go node' +# docker absent is what makes the docker rows actually run get.docker.com; +# the fake the script drops behaves like every other one here. +OPTIONAL='sudo fzf bws nvim go node docker' dir=${1:?usage: seal.sh [--with name ...] [--without name ...]}; shift # Everything the seal KNOWS about, fixed before --without takes anything out: a diff --git a/.tests/test.sh b/.tests/test.sh index 5caf7d9..dc85093 100755 --- a/.tests/test.sh +++ b/.tests/test.sh @@ -401,6 +401,18 @@ is "…and the scoped mermaid name" "npm @mermaid-js/mermaid-cli" "$ is "deb channel carries a source" "deb gh:mkasberg/ghostty-ubuntu:_%a_%v.deb" "$(rs apps/ghostty)" is "snap channel renames to the binary" "snap bw" "$(rs core/bitwarden-cli)" is "tarball is dispatched, not named" "tarball neovim" "$(rs core/neovim)" +# The docker group. `docker-ce`, `docker-buildx-plugin` and +# `docker-compose-plugin` exist only in Docker's OWN apt repository, which +# nothing here configures — so as apt names they had no installation candidate, +# fell through to the brew column, and a system daemon went looking at Homebrew. +# They are a script row on both platforms now and never a formula. +is "docker is a script row, not an apt name" "script docker-ce" "$(rs docker/docker-ce)" +is "…the buildx plugin with it" "script docker-buildx" "$(rs docker/docker-buildx)" +is "…and compose, which is the plugin" "script docker-compose" "$(rs docker/docker-compose)" +# Guest tools for when this box is the VM, not the host. Ubuntu main, so these +# stay plain apt rows — the docker/nvidia vendor-repo trap does not apply. +is "the qemu guest agent is an apt row" "apt qemu-guest-agent" "$(rs virt/guest-agent)" +is "…and the spice agent beside it" "apt spice-vdagent" "$(rs virt/spice-vdagent)" is "an unknown key says so" "missing" "$(rs nope/nope | tr -d ' ')" # The macOS half of the manifest is exercised nowhere else. Resolution is pure # data, so a fake `uname` is enough to check it — and it caught a real bug: the @@ -412,6 +424,9 @@ is "darwin: tap-only pkg is a brew tap" "brew can1357/tap/omp" "$(drs agents/ is "darwin: zsh is built in" "builtin zsh" "$(drs core/zsh)" is "darwin: no apt package is not a reason to try apt" "unavailable" \ "$(drs networking/davfs2 | tr -d ' ')" +# Docker Desktop's own CLI installer, off the .dmg. There is no brew cask in +# this story on either platform. +is "darwin: docker is a script row too" "script docker-ce" "$(drs docker/docker-ce)" # Nothing in the default set may be unresolvable — that is a manifest bug, and # it is silent until someone runs the installer on a fresh machine. @@ -456,7 +471,7 @@ hasnt "--print never reaches the private stage" "Bootstrap URL:" "$out" # handlers write outside $HOME, and a test suite has no business doing that. newbox; BOXPATH=$SEALSUDO pick agents/omp agents/specify-cli apps/obsidian core/bitwarden-cli \ - core/gh core/lazygit core/mermaid-cli core/ripgrep docker/docker-ce + core/gh core/lazygit core/mermaid-cli core/ripgrep gpu/container-toolkit box install >/dev/null 2>&1 || true log=$(cat "$LOG") has "apt batches its packages in one call" "apt-get install -y ripgrep" "$log" @@ -472,13 +487,27 @@ has "…with the real obsidian app id" "md.obsidian.Obsidian" # no installation candidate. The probe asks for the candidate now, so the # assertion follows it. has "apt probes before it batches" "apt-cache policy gh" "$log" -# docker-ce is here for one reason: it is in the apt cache but has no -# installation candidate, and `apt-cache show` exits 0 for exactly that shape. -# Under the old probe it stayed in the batch and apt refused all of them at -# once -- one unavailable name taking thirty installable ones down with it. -has "…and rejects a name with no candidate" "apt-cache policy docker-ce" "$log" -hasnt "…leaving it out of the apt batch" "apt-get install -y ripgrep docker-ce" "$log" -has "…while the rest of the batch survives" "apt-get install -y ripgrep" "$log" +# nvidia-container-toolkit is here for one reason: it is in the apt cache but +# has no installation candidate -- it ships from NVIDIA's own repository -- and +# `apt-cache show` exits 0 for exactly that shape. Under the old probe it stayed +# in the batch and apt refused all of them at once: one unavailable name taking +# thirty installable ones down with it. (docker-ce was this test's example until +# the docker rows moved to get.docker.com and stopped reaching apt at all.) +has "…and rejects a name with no candidate" "apt-cache policy nvidia-container-toolkit" "$log" +hasnt "…leaving it out of the apt batch" "apt-get install -y nvidia-container-toolkit" "$log" +# Asserted as the WHOLE line, not as a prefix. `has "apt-get install -y ripgrep"` +# passed for any batch that merely began with ripgrep, so a rejected name +# reappearing after it -- the exact regression this section exists to catch -- +# would have gone unseen, and the assertion was pinned to sort order rather than +# to content. The brew prerequisite call is excluded by name because it is a +# second, deliberate apt line rather than a batch that split apart. +# The two leading words are stripped rather than asserted: $SUDO is empty for a +# run that is already root (the suite's own container is), so pinning them would +# make this pass on a laptop and fail in CI for a reason that is not the batch. +is "…while the rest of the batch survives, and only it" \ + "apt-get install -y ripgrep" \ + "$(grep 'apt-get install' "$LOG" | grep -v 'build-essential procps curl file git$' \ + | sed 's/^sudo //; s/^DEBIAN_FRONTEND=noninteractive //')" has "an apt name apt rejects moves to brew" "brew install gh" "$log" hasnt "…and is not left in the apt batch" "apt-get install -y gh" "$log" # npm cannot run before node, uv cannot run before uv. The pipeline is fixed @@ -490,6 +519,92 @@ is "apt runs before npm" "yes" \ # Nothing runs as root that does not have to. hasnt "brew is never run through sudo" "sudo brew" "$log" +printf '\n\033[1mdocker comes from Docker — never brew, never compose v1\033[0m\n' +# The group named docker-ce, docker-buildx-plugin and docker-compose-plugin as +# apt packages. All three live in download.docker.com/linux/, which +# nothing here configures, so on a fresh box apt had no candidate for any of +# them, install_apt's unknown-name path fired, and the brew column was consulted +# for a system daemon. Docker's convenience script is the vendor's supported +# route and lays down the engine and BOTH plugins in one pass. +newbox; BOXPATH=$SEALSUDO +pick docker/docker-ce docker/docker-buildx docker/docker-compose +out=$(box install --print 2>&1 | plain || true) +has "the group resolves to the official script" "get.docker.com" "$out" +is "…run once for three rows, not three times" "1" \ + "$(printf '%s\n' "$out" | grep -c 'get.docker.com' || true)" +has "…and the rows it covers say so rather than going quiet" \ + "docker/docker-compose: covered by the docker group's single install" "$out" +hasnt "no docker row reaches apt at all" "apt-get install -y docker" "$out" +# The line-by-line form of "never via brew": not one line of a full docker +# selection may name both. +is "no line of the docker plan pairs brew with docker" "" \ + "$(printf '%s\n' "$out" | grep -i brew | grep -i docker || true)" +# v1 is a different program from the plugin, deprecated, and reachable from pip, +# apt and brew under the same hyphenated name. What lands is `docker compose`. +is "the deprecated standalone docker-compose is never fetched" "" \ + "$(printf '%s\n' "$out" | grep -E 'install[^|]*docker-compose' || true)" +is "…nor named in either package-manager column" "" \ + "$(awk -F'\t' '!/^[#@]/ && NF>=3 && ($4 ~ /docker-compose/ || $5 ~ /docker-compose/) {print}' "$M")" + +# The real engine, against the seal. Two things about the setup are load-bearing. +# +# holed docker find_tool probes /usr/local/bin and /opt/homebrew/bin by +# ABSOLUTE path, which no PATH can seal. On a machine with +# Docker Desktop installed, the first run below would take the +# "already present" branch and every assertion here would pass +# or fail for a reason that has nothing to do with the code. +# `holed` refuses instead of pretending. +# no sudo SUDO='' means the vendor script is run directly, so the +# stand-in installer actually executes and drops a `docker` +# where find_tool will find it -- which is what makes the +# idempotence assertion below about something. +newbox +if holed docker; then +pick docker/docker-ce docker/docker-buildx docker/docker-compose +box install >/dev/null 2>&1 || true +has "the real run fetches the vendor script" "curl -fsSL https://get.docker.com" "$(cat "$LOG")" +is "…exactly once" "1" "$(grep -c 'get.docker.com' "$LOG" || true)" +is "…and never invokes brew for it" "" "$(grep -i brew "$LOG" || true)" +is "…nor a package manager for a docker name" "" \ + "$(grep -E '^(apt-get|apt-cache|snap|flatpak|npm) .*docker' "$LOG" || true)" +# Idempotence. The script's stand-in installed to ~/.local/bin, one of +# find_tool's probes, so the second run sees it the way a real one would -- and +# what it asks is `docker buildx version` and `docker compose version`, not the +# mere existence of a `docker`: docker.io, podman-docker and a hand-dropped +# binary all satisfy that while shipping neither plugin, which would have made +# the two plugin rows silently do nothing. +out=$(box install 2>&1 | plain || true) +has "a second run leaves an installed docker alone" "already present — leaving it" "$out" +is "…and downloads nothing the second time" "1" "$(grep -c 'get.docker.com' "$LOG" || true)" +else + printf ' \033[33mskip\033[0m docker sits at an absolute path find_tool probes\n' +fi + +# The failure path, and it is the one the pipe form could not reach: with no +# pipefail a failed download exited 0, note_fail was unreachable, and whatever +# fragment arrived had already run as root. Downloading to a file and checking +# it arrived is what makes any of this observable. +newbox +if holed docker; then +BOXENV='FAKE_FAIL=curl:docker' +pick docker/docker-ce docker/docker-buildx docker/docker-compose +out=$(box install 2>&1 | plain || true) +has "a failed download is reported, not swallowed" \ + "the Docker install script download failed or arrived empty" "$out" +has "…against the key you can type at the picker" "docker/docker-ce" "$out" +is "…and the file that never arrived is never run" "" \ + "$(printf '%s\n' "$out" | grep " sh '" || true)" +has "…and the other two rows say they were not attempted" \ + "not attempted — the docker install failed" "$out" +is "…rather than claiming the install covered them" "" \ + "$(printf '%s\n' "$out" | grep 'covered by the docker' || true)" +is "…having tried the download once, not once per row" "1" \ + "$(grep -c 'get.docker.com' "$LOG" || true)" +is "…and the run exits non-zero" "1" "$(boxrc install)" +else + printf ' \033[33mskip\033[0m docker sits at an absolute path find_tool probes\n' +fi + printf '\n\033[1munattended — the boundary holds because of what is missing\033[0m\n' # A stale state file is the adversary here: it ticks the two things an # unattended run must never act on, and the run has to refuse both anyway. @@ -563,10 +678,40 @@ is "…with brew's prerequisites as their own call" "1" \ "$(printf '%s\n' "$minprint" | grep -c 'build-essential procps curl file git$')" unset minprint rm -rf "$MIN" -# `sudo` must not be glued onto anything that is not a system package manager. -is "sudo is only ever used for apt, snap and dpkg" "" \ - "$(grep -oE '\$\{SUDO:\+\$SUDO \}[a-z-]+' $D | sed 's/.*}//' | sort -u \ - | grep -vE '^(apt-get|snap|rm|mkdir|tar|ln)$' || true)" +# `sudo` must not be glued onto anything that is not a system package manager or +# a file operation under a system prefix. Two vendor installers do have to run as +# root, and WHICH FILE each of them runs is the entire question -- so they are +# pinned below by name rather than allowlisted by shape. +# +# The old pattern stopped at `[a-z-]+`, which could not see an invocation +# beginning with a quote or a slash AT ALL: the macOS installer path was +# invisible to it, and so was any future one written that way. `[^ ]+` sees +# every one, and every one has to appear on this list. +sudoers() { grep -oE '\$\{SUDO:\+\$SUDO \}[^ ]+' $D | sed "s/.*}//; s/'//g" | sort -u; } +is "every root invocation is one of the ones we meant" "" \ + "$(sudoers | grep -vxF -e apt-get -e rm -e mkdir -e tar -e ln -e sh \ + -e DEBIAN_FRONTEND=noninteractive -e '$SNAP' \ + -e '$WORKDIR/mnt/Docker.app/Contents/MacOS/install' || true)" +# `sh` is on that list for exactly one caller, and it must stay exactly one. +is "…exactly one root shell in the whole script" "1" \ + "$(grep -cE '\$\{SUDO:\+\$SUDO \}sh ' $D || true)" +is "…and it runs this run's own copy of the vendor script" "1" \ + "$(grep -cE '\$\{SUDO:\+\$SUDO \}sh .\$WORKDIR/get-docker\.sh.' $D || true)" +is "…which was downloaded to that file first" "1" \ + "$(grep -cF 'curl -fsSL https://get.docker.com -o ' $D || true)" +# POSIX sh has no pipefail: a download fed straight to a root shell reports the +# SHELL's status, so a truncated body gets executed AND called a success. +# Nothing in this script may have that shape. +is "nothing is ever piped into a root shell" "" \ + "$(grep -nE 'curl[^|]*\|[^|]*\$\{SUDO' $D || true)" +# The macOS root invocation, named. It runs out of this run's own 700 directory +# rather than /Volumes/Docker -- a fixed path anyone able to mount an image can +# occupy, and which hdiutil silently sidesteps to "/Volumes/Docker 1" while +# still exiting 0. +is "…and Docker Desktop's installer runs from this run's mount" "1" \ + "$(grep -cE '\$\{SUDO:\+\$SUDO \}.\$WORKDIR/mnt/Docker\.app/Contents/MacOS/install.' $D || true)" +is "…which was mounted read-only at a path this run chose" "1" \ + "$(grep -cE 'hdiutil attach .*-readonly .*-mountpoint .\$WORKDIR/mnt.' $D || true)" printf '\n\033[1mthe seal itself — a missing fake is an error, not the host tool\033[0m\n' SB1=${TMPDIR:-/tmp}/dotup-sealtest.$$; rm -rf "$SB1"; mkdir -p "$SB1" @@ -627,13 +772,13 @@ newbox; pick core/ripgrep docker/docker-ce networking/openssh-server out=$(box --unattended install 2>&1 | plain || true) log=$(cat "$LOG") has "it names what it refused" "refusing invasive packages" "$out" -hasnt "the daemon never reaches a package manager" "docker-ce" "$log" +hasnt "the daemon never reaches a package manager" "get.docker.com" "$log" hasnt "…nor does the listening ssh port" "openssh-server" "$log" has "…and the safe package still installs" "ripgrep" "$log" # Conditional on the flag, or it is a broken installer rather than a boundary. newbox; pick core/ripgrep docker/docker-ce box install >/dev/null 2>&1 || true -has "with a human present the same tick does install" "docker-ce" "$(cat "$LOG")" +has "with a human present the same tick does install" "get.docker.com" "$(cat "$LOG")" printf '\n\033[1mflags are read wherever they sit — DU-H1\033[0m\n' # The production incident. The old parser stopped at the first bare word and @@ -650,7 +795,7 @@ pick core/ripgrep docker/docker-ce networking/openssh-server out=$(box install --unattended 2>&1 | plain || true) log=$(cat "$LOG") has "install --unattended refuses invasive too" "refusing invasive packages" "$out" -hasnt "…so the daemon never reaches a package manager" "docker-ce" "$log" +hasnt "…so the daemon never reaches a package manager" "get.docker.com" "$log" hasnt "…nor does the listening ssh port" "openssh-server" "$log" has "…and the safe package still installs" "ripgrep" "$log" # A box where no selection has EVER existed: `install --unattended` must mean @@ -661,7 +806,7 @@ newbox; BOXPATH=$SEALSUDO; rm -f "$SB/.config/dotfiles/selected" out=$(box install --unattended 2>&1 | plain || true) log=$(cat "$LOG") has "no state file ever -> unattended install seeds the defaults" "ripgrep" "$log" -hasnt "…and the seeded defaults never include an invasive row" "docker-ce" "$log" +hasnt "…and the seeded defaults never include an invasive row" "get.docker.com" "$log" newbox; BOXPATH=$SEALSUDO; : > "$SB/.config/dotfiles/picked" out=$(box install --unattended 2>&1 | plain || true) is "an accepted chose-none is a decision — nothing installs" "" "$(grep -E ' (install|remove|upgrade) ' "$LOG" || true)" diff --git a/README.md b/README.md index f328a9d..8f77934 100644 --- a/README.md +++ b/README.md @@ -166,12 +166,37 @@ otherwise brew would still be missing when the rows needing it are attempted. The installer probes `apt-cache policy` before it batches, and asks for the installation *candidate* rather than merely whether the name is known: on stock -Ubuntu `apt-cache show docker-ce` prints nothing and **exits 0**, so an -existence test kept it in the batch, apt refused all thirty packages at once, -and the brew fallback was never reached. One unavailable name took thirty +Ubuntu `apt-cache show nvidia-container-toolkit` prints nothing and **exits 0**, +so an existence test kept it in the batch, apt refused all thirty packages at +once, and the brew fallback was never reached. One unavailable name took thirty installable ones down with it. A name with no candidate now moves to the brew column instead. +**Docker is the case where that fallback was the wrong answer.** `docker-ce`, +`docker-buildx-plugin` and `docker-compose-plugin` exist only in Docker's own +apt repository, which nothing here configures — so all three had no candidate, +and the apt-then-brew rule sent a system daemon looking at Homebrew. The three +rows are a `script` channel now: on Linux Docker's own `get.docker.com`, the +vendor's supported route, which adds the repository and installs the engine +*and both plugins* in one pass; on macOS the Docker Desktop `.dmg` and its own +`Contents/MacOS/install`. The group still shows three members and still carries +its invasive warning, but `docker/docker-ce` is the row that does the work and +the other two report **its** outcome — "covered by" when it succeeded, "not +attempted" when it did not. What lands is the compose **plugin** — +`docker compose`. The deprecated standalone `docker-compose` v1 is never +fetched from anywhere. + +Neither installer is piped into a shell. POSIX `sh` has no `pipefail`, so +`curl … | sh` exits with the *shell's* status: a download that 404s or is cut +off half way through reports success, the error path is unreachable, and +whatever fragment did arrive has already run as root. Both are downloaded into +the run's own `mktemp -d` directory, checked non-empty, and then executed from +there — and the `.dmg` is mounted read-only at a path inside that directory +rather than at `/Volumes/Docker`, which is a fixed name anyone able to mount an +image can occupy first. The presence check asks `docker buildx version` and +`docker compose version`, not merely whether a `docker` exists: `docker.io` and +`podman-docker` satisfy the latter while shipping neither plugin. + `@spec` carries the argument a channel needs but the package name cannot supply — the scoped npm name, the flatpak app id, the `.deb` source. It defaults to the package name. diff --git a/dot_local/bin/executable_dotup b/dot_local/bin/executable_dotup index b135d5a..2d4d102 100755 --- a/dot_local/bin/executable_dotup +++ b/dot_local/bin/executable_dotup @@ -423,6 +423,14 @@ SUDO= if [ "$(id -u)" != 0 ] && command -v sudo >/dev/null 2>&1; then SUDO=sudo; fi FAILED=$STATE/.failed.$$ APT_UPDATED=0 +# The docker group is three manifest rows and ONE install: get.docker.com lays +# down the engine and both plugins together. docker/docker-ce does the work (see +# install_bespoke, which puts it in front of its own plugins) and records the +# OUTCOME here -- empty, `ok` or `fail` -- so the two rows behind it can say what +# actually happened rather than claiming a success that never occurred. A +# recorded outcome rather than a re-probe, so a dry run prints the commands once +# instead of three times, and a broken network is not retried three times. +DOCKER_SCRIPTED= # One private directory per run, for everything this script downloads. # @@ -615,8 +623,10 @@ apt_update_once() { # That is what "apt-then-brew" has to mean in practice, and it is the difference # between 34 packages installed and 0. # `apt-cache show` is not an existence test. A name that exists only because -# something else Conflicts/Replaces it -- docker-ce on a stock Ubuntu is the -# live example -- prints nothing and exits 0, so the batch kept it, apt refused +# something else Conflicts/Replaces it, or that is published from a vendor +# repository nothing here configures -- nvidia-container-toolkit on a stock +# Ubuntu is the live example, and docker-ce was until the docker rows moved to +# get.docker.com -- prints nothing and exits 0, so the batch kept it, apt refused # the whole batch with "has no installation candidate", and the brew column was # never consulted. Ask for the installation candidate instead, which is the # thing `apt-get install` will actually go looking for. @@ -799,6 +809,15 @@ install_deb() { install_bespoke() { bsp=$(norm "$2") [ -n "$bsp" ] || return 0 + # The docker group is three rows and one install, and the row that performs + # it is the row the log should name. `keys` hands this list over sorted, so + # docker-buildx led and the engine appeared to be a consequence of its own + # plugin. Put the engine back in front of them. + # shellcheck disable=SC2086 + case " $bsp " in + *" docker/docker-ce "*) + bsp="docker/docker-ce $(printf '%s\n' $bsp | grep -vx docker/docker-ce | tr '\n' ' ')" ;; + esac head_ "$1" for key in $bsp; do case $key in @@ -913,6 +932,118 @@ install_bespoke() { # a failure invented by the dry run itself. [ "$DRYRUN" -eq 1 ] || have brew \ || note_fail "$key" "brew still not found after installing it" ;; + docker/docker-ce|docker/docker-buildx|docker/docker-compose) + # Docker publishes its own apt repository and ships nothing to + # Ubuntu's. `apt-cache policy docker-ce` on a stock box reports + # `Candidate: (none)`, so install_apt's unknown-name path fired and + # consulted the brew column — for a system daemon, on Linux. That is + # how brew got into the docker story at all, and it is why these + # rows are a script channel now: the vendor's own installer is the + # supported route, it configures the repository first, and it + # installs docker-ce, docker-ce-cli, containerd.io, + # docker-buildx-plugin AND docker-compose-plugin in a single pass. + # + # So the three rows are one install. The picker still shows three + # members and still carries the group's invasive warning, and + # `@needs gpu/container-toolkit docker` still pulls all three in — + # but docker/docker-ce is the row that runs it and the other two + # report ITS outcome. Saying "covered by" after a failed install + # would turn one honest failure into two invented successes. + # + # The compose that lands is the PLUGIN (`docker compose`). The + # standalone docker-compose v1 binary is deprecated and is never + # fetched, from apt, brew or anywhere else. + if [ -n "$DOCKER_SCRIPTED" ]; then + if [ "$DOCKER_SCRIPTED" = ok ]; then + say " $key: covered by the docker group's single install" + else + note_fail "$key" "not attempted — the docker install failed" + fi + continue + fi + # `have docker` on its own is a false proxy for this group. docker.io, + # podman-docker and a hand-dropped binary all satisfy it while + # shipping NEITHER plugin, so ticking the buildx or compose row would + # have quietly installed nothing. Ask for what the three rows between + # them deliver. A partial match is a reason to run the installer, not + # to skip it: the script upgrades and completes an existing install. + # Resolved through find_tool, like everything else here, because a + # docker installed a moment ago is not on this process's PATH. + if [ "$DRYRUN" -eq 0 ] && dk=$(find_tool docker) \ + && "$dk" buildx version >/dev/null 2>&1 \ + && "$dk" compose version >/dev/null 2>&1; then + say " docker with buildx and compose already present — leaving it" + DOCKER_SCRIPTED=ok; continue + fi + case $(uname -s) in + Darwin) + # No brew cask either. Docker Desktop's disk image carries an + # official CLI installer -- Contents/MacOS/install -- which is + # the documented unattended route and the only one that sets up + # the privileged helper without a human dragging an icon. + case $(uname -m) in + aarch64|arm64) a=arm64 ;; + x86_64|amd64) a=amd64 ;; + *) note_fail "$key" "no Docker Desktop build for $(uname -m)" + DOCKER_SCRIPTED=fail; continue ;; + esac + workdir || { note_fail "$key" "no private working directory" + DOCKER_SCRIPTED=fail; continue; } + # Same `[ -s ]` as the tarball handlers, and for the same + # reason: nothing reaches hdiutil that was not verified to have + # arrived. A truncated proxy error page mounts as garbage. + run_sh "curl -fsSL 'https://desktop.docker.com/mac/main/$a/Docker.dmg' -o '$WORKDIR/Docker.dmg' && [ -s '$WORKDIR/Docker.dmg' ]" \ + || { note_fail "$key" "Docker Desktop download failed or arrived empty" + DOCKER_SCRIPTED=fail; continue; } + # -mountpoint is the security-relevant flag here, not a tidiness + # one. Without it hdiutil mounts at /Volumes/Docker -- or at + # "/Volumes/Docker 1" when that name is already taken, and STILL + # exits 0. The installer line would then run whatever happens to + # be sitting at the fixed /Volumes/Docker, AS ROOT, and anyone + # able to mount an image gets to choose what that is. Mounting + # read-only inside this run's own 700 directory makes the thing + # that runs as root exactly the image just downloaded. + run_sh "hdiutil attach -nobrowse -readonly -quiet -mountpoint '$WORKDIR/mnt' '$WORKDIR/Docker.dmg'" \ + || { note_fail "$key" "could not mount Docker.dmg" + DOCKER_SCRIPTED=fail; continue; } + dk_rc=0 + run_sh "${SUDO:+$SUDO }'$WORKDIR/mnt/Docker.app/Contents/MacOS/install' --accept-license" || dk_rc=1 + # Detach whatever happened above, or the next run inherits a + # mount it did not make. + run_sh "hdiutil detach -quiet '$WORKDIR/mnt'" || warn "could not unmount $WORKDIR/mnt" + [ "$dk_rc" -eq 0 ] || { note_fail "$key" "the Docker Desktop installer failed" + DOCKER_SCRIPTED=fail; continue; } + DOCKER_SCRIPTED=ok ;; + *) + # NOT fetched straight into a shell through a pipe. POSIX sh has + # no pipefail, so that form exits with the SHELL's status: a + # download that 404s or dies half way through is a 0, note_fail + # is unreachable, and whatever fragment did arrive has already + # been executed as root. Download to a file this run owns, check + # it arrived non-empty, then run that file -- the same shape, and + # the same reason, as the three tarball handlers above. + workdir || { note_fail "$key" "no private working directory" + DOCKER_SCRIPTED=fail; continue; } + run_sh "curl -fsSL https://get.docker.com -o '$WORKDIR/get-docker.sh' && [ -s '$WORKDIR/get-docker.sh' ]" \ + || { note_fail "$key" "the Docker install script download failed or arrived empty" + DOCKER_SCRIPTED=fail; continue; } + # get.docker.com escalates on its own when it is not run as root, + # but this box may have no sudo at all and dotup already knows + # which -- so pass it explicitly and keep the command that is + # printed identical to the one that runs. + run_sh "${SUDO:+$SUDO }sh '$WORKDIR/get-docker.sh'" \ + || { note_fail "$key" "the official Docker install script failed" + DOCKER_SCRIPTED=fail; continue; } + DOCKER_SCRIPTED=ok ;; + esac + # core/brew's post-condition, for the same reason: an installer that + # exits 0 without leaving the binary behind is a failure THIS run + # should name, not one the next command stumbles into. Only after + # something actually ran -- under --print nothing did. + if [ "$DRYRUN" -eq 0 ] && [ "$DOCKER_SCRIPTED" = ok ] && ! have docker; then + note_fail "$key" "docker still not found after the installer ran" + DOCKER_SCRIPTED=fail + fi ;; core/uv) if have uv && [ "$DRYRUN" -eq 0 ]; then say " uv already present — leaving it"; continue; fi run_sh "curl -LsSf https://astral.sh/uv/install.sh | sh" || note_fail "$key" "installer failed" ;; diff --git a/dot_local/share/dotup/packages.tsv b/dot_local/share/dotup/packages.tsv index 2c3bae4..dc6bf5b 100644 --- a/dot_local/share/dotup/packages.tsv +++ b/dot_local/share/dotup/packages.tsv @@ -113,9 +113,17 @@ networking nfs-common invasive nfs-common - setuid mount helper networking cifs-utils invasive cifs-utils - setuid mount helper networking davfs2 invasive davfs2 - setuid mount helper @docker daemon; membership in the docker group is root-equivalent -docker docker-ce invasive docker-ce - daemon; docker group is root-equivalent -docker docker-buildx invasive docker-buildx-plugin - -docker docker-compose invasive docker-compose-plugin - +# Docker's own apt repository, not Ubuntu's. `docker-ce`, `docker-buildx-plugin` +# and `docker-compose-plugin` live in download.docker.com/linux/, which +# nothing here configures — so on a stock box every one of these names had no +# installation candidate, install_apt's unknown-name path fired, and a Linux +# daemon went looking in the brew column. get.docker.com adds the repository and +# installs the engine and BOTH plugins in one pass, so all three rows are one +# install: see install_bespoke's docker branch. Never brew, and never the +# deprecated standalone docker-compose v1 — `docker compose` is the plugin. +docker docker-ce invasive -script -script daemon; docker group is root-equivalent · installs from get.docker.com, never brew +docker docker-buildx invasive -script -script buildx plugin — get.docker.com installs it alongside docker-ce +docker docker-compose invasive -script -script the compose plugin, run as `docker compose` — from get.docker.com, never the deprecated v1 binary @desktop changes the display manager — can leave you at a black screen desktop xfce4 invasive xfce4 - changes the display manager desktop lightdm invasive lightdm - CAN LEAVE YOU AT A BLACK SCREEN @@ -127,6 +135,10 @@ gpu container-toolkit invasive nvidia-container-toolkit - requires docker virt qemu invasive qemu-kvm - virt libvirt invasive libvirt-daemon-system - daemon + group membership virt virt-manager invasive virt-manager - +# The rows above host guests; these two ARE the guest. Both ship in +# Ubuntu main — plain apt names, no vendor repository involved. +virt guest-agent invasive qemu-guest-agent - daemon the qemu HOST can command (shutdown, fsfreeze) — for when this box is the guest +virt spice-vdagent invasive spice-vdagent - guest clipboard/resolution under SPICE graphics · useless outside a VM @private one password, typed after the install finishes private private-repo private - - ~/.local/share/dotfiles-private — agent config, ssh config private bws-secrets private - - bws + 7 API keys into ~/.config/zsh/secrets.zsh; the tier installs bws itself