Skip to content

Commit 7968172

Browse files
committed
Drop the separate Alpine bootstrap, install.func already covers it
Alpine had its own in-container bootstrap, lxc/alpine-install.func: 266 lines holding thinner copies of eleven functions install.func also defines. Both backends picked between them on var_os, so install.func's own Alpine support -- detect_os setting apk and openrc, seven apk branches, the OpenRC service and inittab handling -- was written, maintained and never executed for LXC. Two copies of the same eight functions is not free. The hostname -I failure on BusyBox came out of it, and the /dev/tty prompt fix earlier today had to be written twice into two copies of network_check. Deleting the thin one means Alpine now gets what everything else gets: the conditional testing banner instead of a hardcoded "DEV Repository (ProxmoxVED)" that every Alpine container on ProxmoxVE was shown, the IPv6 leg of network_check, the proxy and telemetry handling, and mirror fallback that shuffles. Two things really were only in the Alpine copy and are ported rather than lost: - util-linux. Alpine ships BusyBox getty, not agetty, and the inittab rewrite names /sbin/agetty explicitly. The host installs bash, curl and friends into Alpine containers but not util-linux, so without this the new inittab line would point at a binary that does not exist and the console would not come back. The rewrite is now skipped entirely if agetty is still missing. - The bootstrap probe. alpine-install.func checked each download before sourcing it; install.func used `source <(...)`, which hides the exit code, so a failed fetch sourced an empty script and surfaced as "command not found" somewhere later. _bootstrap_source now names the file that could not be fetched, and catches a truncated response that parses but is missing what we asked for. The apk mirror loop also shuffles with shuf, which BusyBox may not provide. It now falls back to the fixed order -- an empty list there would have reported "all mirrors failed" without trying a single one. Not ported: the /etc/local.d/autologin.start boot hook. install.func writes the same change directly to /etc/inittab, which persists, and reloads it more thoroughly (telinit q plus a targeted pkill) than the kill -HUP 1 it replaces. Checked locally: every engine file parses, both prefetch lists still cover the tree, and the three loader API snapshots are unchanged. The inittab regexes were run against real Alpine and Gentoo inittab formats -- both rewrite tty1 and console and leave tty2 alone. What this cannot cover is a real Alpine container; those code paths go from dead to load-bearing here.
1 parent 259d326 commit 7968172

7 files changed

Lines changed: 62 additions & 298 deletions

File tree

‎core/build.func‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ _cs_source_func() {
245245
# so a new .func cannot be forgotten here. A file missing from it would still
246246
# work — _cs_local_path falls through to the network — just slower.
247247
_CS_ENGINE_FILES=(
248-
lxc/alpine-install.func lib/alpine.func api/api.func
248+
lib/alpine.func api/api.func
249249
api/errorlog.func api/exitcodes.func api/sysinfo.func
250250
api/telemetry.func
251251
ui/build-ui.func ui/advanced.func ui/defaults.func

‎docs/README.md‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ engine and ProxmoxVE, which has not moved over yet.
6767
| [`lib/db.func`](../lib/db.func) | Databases and search engines |
6868
| [`lib/hwaccel.func`](../lib/hwaccel.func) | GPU detection and hardware acceleration |
6969
| [`lib/alpine.func`](../lib/alpine.func) | The Alpine helper library, loaded instead of the above |
70-
| [`lxc/install.func`](../lxc/install.func) | In-container bootstrap, multi-distro |
71-
| [`lxc/alpine-install.func`](../lxc/alpine-install.func) | In-container bootstrap for Alpine |
70+
| [`lxc/install.func`](../lxc/install.func) | In-container bootstrap, every distro including Alpine |
7271
| [`lxc/platform.func`](../lxc/platform.func) | Proxmox VE / Incus / in-container detection |
7372
| [`host/preflight.func`](../host/preflight.func) | Optional host readiness checks, off by default |
7473
| [`host/validate.func`](../host/validate.func) | MAC, VLAN and MTU checks shared by both platforms |

‎docs/lxc.md‎

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,10 @@ folder-qualified paths, the same as on the host.
2020
Which helper library gets loaded is decided here: `lib/alpine.func` for Alpine,
2121
`lib/tools.func` otherwise.
2222

23-
## [`alpine-install.func`](../lxc/alpine-install.func)
24-
25-
The Alpine bootstrap. Separate because Alpine uses `apk` and `ash`, and because
26-
a freshly booted Alpine container may not have `curl` yet — the first thing this
27-
file does is install it if missing.
28-
29-
It also sets `TELEMETRY_CONTEXT=container`, so the error handler writes failure
30-
artifacts instead of calling the API, and it checks each download before
31-
sourcing it rather than sourcing an empty stream on a failed fetch.
23+
Alpine used to get its own bootstrap, `alpine-install.func`. It was a second,
24+
thinner copy of the same eight functions, so every fix had to be made twice and
25+
`install.func`'s own apk and OpenRC branches never ran. Both backends now hand
26+
`install.func` to every container and `detect_os` decides the rest.
3227

3328
## [`platform.func`](../lxc/platform.func)
3429

‎incus/backend.func‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -198,11 +198,9 @@ validate_storage_space() {
198198
}
199199

200200
_incus_prepare_install_exports() {
201-
if [[ "${var_os:-debian}" == "alpine" ]]; then
202-
export FUNCTIONS_FILE_PATH="$(_cs_fetch_text "lxc/alpine-install.func")"
203-
else
204-
export FUNCTIONS_FILE_PATH="$(_cs_fetch_text "lxc/install.func")"
205-
fi
201+
# One bootstrap for every OS — see pve/backend.func for why the Alpine split
202+
# went away.
203+
export FUNCTIONS_FILE_PATH="$(_cs_fetch_text "lxc/install.func")"
206204

207205
export DIAGNOSTICS="${DIAGNOSTICS:-yes}"
208206
export RANDOM_UUID="${RANDOM_UUID}"

‎lxc/alpine-install.func‎

Lines changed: 0 additions & 266 deletions
This file was deleted.

0 commit comments

Comments
 (0)