@@ -45,6 +45,7 @@ ERROR() {
4545# constants
4646CONTAINERD_ROOTLESS_SH=" containerd-rootless.sh"
4747SYSTEMD_CONTAINERD_UNIT=" containerd.service"
48+ SYSTEMD_BUILDKIT_UNIT=" buildkit.service"
4849SYSTEMD_FUSE_OVERLAYFS_UNIT=" containerd-fuse-overlayfs.service"
4950
5051# global vars
@@ -238,17 +239,51 @@ cmd_entrypoint_install() {
238239 INFO " You do NOT need to specify \$ CONTAINERD_ADDRESS explicitly."
239240}
240241
242+ # CLI subcommand: "install-buildkit"
243+ cmd_entrypoint_install_buildkit () {
244+ init
245+ if ! command -v " buildkitd" > /dev/null 2>&1 ; then
246+ ERROR " buildkitd (https://github.com/moby/buildkit) needs to be present under \$ PATH"
247+ exit 1
248+ fi
249+ if ! systemctl --user --no-pager status " ${SYSTEMD_CONTAINERD_UNIT} " > /dev/null 2>&1 ; then
250+ ERROR " Install containerd first (\` $ARG0 install\` )"
251+ exit 1
252+ fi
253+ cat << -EOT | install_systemd_unit "${SYSTEMD_BUILDKIT_UNIT} "
254+ [Unit]
255+ Description=BuildKit (Rootless)
256+ PartOf=${SYSTEMD_CONTAINERD_UNIT}
257+
258+ [Service]
259+ Environment=PATH=$BIN :/sbin:/usr/sbin:$PATH
260+ ExecStart="$REALPATH0 " nsenter buildkitd
261+ ExecReload=/bin/kill -s HUP \$ MAINPID
262+ RestartSec=2
263+ Restart=always
264+ Type=simple
265+ KillMode=mixed
266+
267+ [Install]
268+ WantedBy=default.target
269+ EOT
270+ }
271+
241272# CLI subcommand: "install-fuse-overlayfs"
242273cmd_entrypoint_install_fuse_overlayfs () {
243274 init
244- if ! command -v " containerd-fuse-overlayfs-grpc" 2 > /dev/null; then
275+ if ! command -v " containerd-fuse-overlayfs-grpc" > /dev/null 2>&1 ; then
245276 ERROR " containerd-fuse-overlayfs-grpc (https://github.com/AkihiroSuda/containerd-fuse-overlayfs) needs to be present under \$ PATH"
246277 exit 1
247278 fi
248- if ! command -v " containerd-fuse-overlayfs-grpc" 2 > /dev/null; then
279+ if ! command -v " containerd-fuse-overlayfs-grpc" > /dev/null 2>&1 ; then
249280 ERROR " fuse-overlayfs (https://github.com/containers/fuse-overlayfs) needs to be present under \$ PATH"
250281 exit 1
251282 fi
283+ if ! systemctl --user --no-pager status " ${SYSTEMD_CONTAINERD_UNIT} " > /dev/null 2>&1 ; then
284+ ERROR " Install containerd first (\` $ARG0 install\` )"
285+ exit 1
286+ fi
252287 cat << -EOT | install_systemd_unit "${SYSTEMD_FUSE_OVERLAYFS_UNIT} "
253288 [Unit]
254289 Description=containerd-fuse-overlayfs (Rootless)
@@ -281,13 +316,22 @@ cmd_entrypoint_install_fuse_overlayfs() {
281316# CLI subcommand: "uninstall"
282317cmd_entrypoint_uninstall () {
283318 init
319+ uninstall_systemd_unit " ${SYSTEMD_BUILDKIT_UNIT} "
284320 uninstall_systemd_unit " ${SYSTEMD_FUSE_OVERLAYFS_UNIT} "
285321 uninstall_systemd_unit " ${SYSTEMD_CONTAINERD_UNIT} "
286322
287323 INFO " This uninstallation tool does NOT remove containerd binaries and data."
288324 INFO " To remove data, run: \` $BIN /rootlesskit rm -rf ${XDG_DATA_HOME} /containerd\` "
289325}
290326
327+ # CLI subcommand: "uninstall-buildkit"
328+ cmd_entrypoint_uninstall_buildkit () {
329+ init
330+ uninstall_systemd_unit " ${SYSTEMD_BUILDKIT_UNIT} "
331+ INFO " This uninstallation tool does NOT remove data."
332+ INFO " To remove data, run: \` $BIN /rootlesskit rm -rf ${XDG_DATA_HOME} /buildkit"
333+ }
334+
291335# CLI subcommand: "uninstall-fuse-overlayfs"
292336cmd_entrypoint_uninstall_fuse_overlayfs () {
293337 init
@@ -308,7 +352,11 @@ usage() {
308352 echo " install Install systemd unit and show how to manage the service"
309353 echo " uninstall Uninstall systemd unit"
310354 echo
311- echo " Add-on commands:"
355+ echo " Add-on commands (BuildKit):"
356+ echo " install-buildkit Install the systemd unit for BuildKit"
357+ echo " uninstall-buildkit Uninstall the systemd unit for BuildKit"
358+ echo
359+ echo " Add-on commands (fuse-overlayfs):"
312360 echo " install-fuse-overlayfs Install the systemd unit for fuse-overlayfs snapshotter"
313361 echo " uninstall-fuse-overlayfs Uninstall the systemd unit for fuse-overlayfs snapshotter"
314362}
0 commit comments