meta-virtualization.lists.yoctoproject.org archive mirror
 help / color / mirror / Atom feed
From: liu.ming50@gmail.com
To: meta-virtualization@lists.yoctoproject.org
Cc: Ming Liu <liu.ming50@gmail.com>
Subject: [meta-virtualization][PATCH] podman: support bash completions for podman/docker
Date: Mon,  8 Jan 2024 19:09:33 +0100	[thread overview]
Message-ID: <20240108180933.2362963-1-liu.ming50@gmail.com> (raw)

From: Ming Liu <liu.ming50@gmail.com>

Generate podman bash completion script with qemu wrapper.

When docker pkgconfig is enabled, also generate bash completion script
for docker.

Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
 recipes-containers/podman/podman_git.bb | 29 +++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/recipes-containers/podman/podman_git.bb b/recipes-containers/podman/podman_git.bb
index 33d437a3..1c64272a 100644
--- a/recipes-containers/podman/podman_git.bb
+++ b/recipes-containers/podman/podman_git.bb
@@ -68,6 +68,18 @@ EXTRA_OEMAKE = " \
 # packageconfig, the podman package will rconfict with docker.
 PACKAGECONFIG ?= "docker"
 
+# podman builds bash completion with the help of podman binary, only the machines
+# that support qemu usermode can enable this pkgconfig.
+PACKAGECONFIG:append = " ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'completion', '', d)}"
+DEPENDS:append = " ${@bb.utils.contains('MACHINE_FEATURES', 'qemu-usermode', 'qemu-native', '', d)}"
+
+inherit qemu bash-completion
+
+# To avoid breaking the recipes without 'completion' enabled.
+ALLOW_EMPTY:${PN}-bash-completion = "1"
+
+QEMU_OPTIONS = ""
+
 do_compile() {
 	cd ${S}/src
 	rm -rf .gopath
@@ -116,6 +128,23 @@ do_install() {
 		install -d "${D}${sysconfdir}/sysctl.d"
 		install -m 0644 "${WORKDIR}/50-podman-rootless.conf" "${D}${sysconfdir}/sysctl.d"
 	fi
+
+	if ${@bb.utils.contains('PACKAGECONFIG', 'completion', 'true', 'false', d)}; then
+		qemu_binary="${@qemu_wrapper_cmdline(d, '${STAGING_DIR_TARGET}', ['${B}', '${STAGING_DIR_TARGET}/${base_libdir}'])}"
+		cat > ${WORKDIR}/podman-qemuwrapper << EOF
+#!/bin/sh
+
+$qemu_binary "\$@"
+EOF
+		chmod +x ${WORKDIR}/podman-qemuwrapper
+		${WORKDIR}/podman-qemuwrapper ./bin/podman completion bash > ${B}/podman-bash-completion
+		install -d ${D}${datadir}/bash-completion/completions
+		install -m 0644 ${B}/podman-bash-completion ${D}${datadir}/bash-completion/completions/podman
+		if ${@bb.utils.contains('PACKAGECONFIG', 'docker', 'true', 'false', d)}; then
+			sed "s/podman/docker/g" ${B}/podman-bash-completion > ${B}/docker-bash-completion
+			install -m 0644 ${B}/docker-bash-completion ${D}${datadir}/bash-completion/completions/docker
+		fi
+	fi
 }
 
 do_install_ptest () {
-- 
2.34.1



             reply	other threads:[~2024-01-08 18:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-08 18:09 liu.ming50 [this message]
2024-01-08 18:22 ` [meta-virtualization][PATCH] podman: support bash completions for podman/docker Bruce Ashfield
2024-01-09  9:19   ` Ming Liu
2024-01-09 13:23     ` Bruce Ashfield
2024-01-10  8:50       ` Ming Liu
2024-01-10 14:08         ` Bruce Ashfield

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240108180933.2362963-1-liu.ming50@gmail.com \
    --to=liu.ming50@gmail.com \
    --cc=meta-virtualization@lists.yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).