* Linux packages install beside Docker's own Compose and buildx
The full kiri .deb/.rpm put docker-compose and docker-buildx straight into
/usr/lib/docker/cli-plugins, which docker-desktop, docker-compose-plugin and
docker-buildx-plugin own, so dpkg refused the install ("trying to overwrite
'/usr/lib/docker/cli-plugins/docker-buildx', which is also in package
docker-desktop").
The plugins now live in /usr/libexec/kiri/cli-plugins and are linked into
/usr/lib/docker/cli-plugins through update-alternatives only where the slot
is free, as /usr/bin/docker already was; otherwise Docker's plugins stay and
Kiri's docker uses them. The rpm does it in %posttrans, since an upgrade
erases the old package's real files there only after %post.
* Leave Docker's plugins in /usr/libexec alone, and re-check when they change
Docker's apt/dnf packages (docker-compose-plugin, docker-buildx-plugin) put
their plugins in /usr/libexec/docker/cli-plugins. The CLI searches
/usr/lib/docker/cli-plugins first, so a Kiri link there replaced Docker's
Compose and buildx. A plugin's slot now counts as taken when Docker's copy is
in any of the CLI's plugin folders (/usr/lib, /usr/libexec, /usr/local/lib,
/usr/local/libexec), and Kiri's link is removed if Docker's copy turns up.
A dpkg trigger (interest-noawait on those folders) and rpm
%filetriggerin/%filetriggerpostun run the check again when another package
adds or removes plugins there, so Docker's packages installed or removed
after Kiri are handled too.
23 lines
1.2 KiB
Bash
23 lines
1.2 KiB
Bash
#!/bin/sh
|
|
# Kiri's `docker` (the full kiri package): the bundled docker CLI, talking to
|
|
# Kiri's engine unless you chose otherwise. DOCKER_HOST, DOCKER_CONTEXT or a
|
|
# `docker context use` of your own always win; Compose and buildx are found in
|
|
# /usr/lib/docker/cli-plugins, one of the CLI's standard plugin directories:
|
|
# Kiri's (alternatives links to /usr/libexec/kiri/cli-plugins) or, where
|
|
# Docker's packages already put theirs there, those.
|
|
if [ -z "${DOCKER_HOST:-}" ] && [ -z "${DOCKER_CONTEXT:-}" ]; then
|
|
cfg=${DOCKER_CONFIG:-$HOME/.docker}/config.json
|
|
if [ ! -f "$cfg" ] || ! grep -q '"currentContext"' "$cfg" 2>/dev/null; then
|
|
DOCKER_HOST=unix:///run/kiri/docker.sock
|
|
export DOCKER_HOST
|
|
# With DOCKER_HOST, `docker build` would ask for the "default" context's
|
|
# builder, the engine's own BuildKit, which Kiri doesn't have: Kiri's
|
|
# builder instead, once it is made (crates/kiri/src/buildwith.rs).
|
|
if [ -z "${BUILDX_BUILDER:-}" ] && [ -f "${BUILDX_CONFIG:-${DOCKER_CONFIG:-$HOME/.docker}/buildx}/instances/kiri-build" ]; then
|
|
BUILDX_BUILDER=kiri-build
|
|
export BUILDX_BUILDER
|
|
fi
|
|
fi
|
|
fi
|
|
exec /usr/libexec/kiri/bin/docker "$@"
|