Skip to contentSkip to conversation

buildah: add recipe for buildah v1.26

PATCH In review Andrei Gherzan 2 participants 5 messages Sep 5, 2022 – Sep 7, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/3 buildah: add recipe for buildah v1.26

From: "[email protected]" <[email protected]>

buildah is a command line tool, to be installed and run on target, that can be used to:
- create a working container, either from scratch or using an image as a starting point
- create an image, either from a working container or via the instructions in a Dockerfile
- images can be built in either the OCI image format or the traditional upstream docker image format
- mount a working container's root filesystem for manipulation
- unmount a working container's root filesystem
- use the updated contents of a container's root filesystem as a filesystem layer to create a new image
- delete a working container or an image
- rename a local container

Testing:
Setup the build directory:

   $ . oe-init-build-env <build_dir>

Add to local.conf:
IMAGE_INSTALL:append = " buildah kernel-modules"

   KERNEL_FEATURES += "features/overlayfs/overlayfs.cfgi \
                       features/netfilter/netfilter.scc  \
                       features/lxc/lxc-enable.scc"

IMAGE_ROOTFS_EXTRA_SPACE = "5242880"

Build image:

   $ bitbake core-image-minimal

Run the image:

   $ runqemu nographic kvm qemuparams="-m 4096"

On target:
Pull an image:

Quoted 1 line

cnt=$(buildah from fedora)

Or build from Dockerfile

Quoted 1 line

buildah bud -t <image_name>:<tag> .

Mount the image:

Quoted 1 line

mnt=$(buildah mount ${cnt})

Install packages on the container rootfs:

Quoted 1 line

dnf install --installroot $mnt <packages_to_install> -y

Copy local files to the container:

Quoted 1 line

buildah copy $cnt <local_file> <dest_on_container>

Save the changes to an image

Quoted 1 line

buildah commit --format docker $cnt <name>:<tag>

Run the image using buildah:

Quoted 1 line

buildah run $cnt /bin/sh

Or using docker:

Quoted 1 line

docker run -it <name>:<tag>

---
 recipes-containers/buildah/buildah_git.bb | 57 +++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 recipes-containers/buildah/buildah_git.bb
recipes-containers/buildah/buildah_git.bb new file +57 -0
new file mode 100644
index 0000000..024e82c
@@ -0,0 +1,57 @@
+HOMEPAGE = "https://buildah.io"
+SUMMARY = "A tool that facilitates building OCI container images."
+DESCRIPTION = "A tool that facilitates building OCI container images."
+
+# Apache-2.0 for containerd
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://src/github.com/containers/buildah/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
+
+S = "${WORKDIR}/git"
+
+BUILDAH_VERSION = "1.26"
+SRCREV_buildah = "0a9d6e6eaef2e2e7936313d449a4e226022eb865"
+
+PV = "${BUILDAH_VERSION}"
+
+inherit go
+inherit goarch
+inherit pkgconfig
+
+GO_IMPORT = "github.com/containers/buildah"
+GO_INSTALL = "${GO_IMPORT}"
+GO_WORKDIR = "${GO_INSTALL}"
+GOBUILDFLAGS += "-mod vendor"
+
+SRC_URI = " \
+    git://github.com/containers/buildah;branch=release-${BUILDAH_VERSION};name=buildah;protocol=https \
+    "
+
+DEPENDS = "libdevmapper btrfs-tools gpgme"
+RDEPENDS:${PN} = "cgroup-lite fuse-overlayfs libdevmapper podman"
+RDEPENDS:${PN}-dev = "bash perl"
+
+do_compile:prepend() {
+    cd ${S}/src/github.com/containers/buildah
+}
+
+go_do_compile() {
+        export TMPDIR="${GOTMPDIR}"
+        if [ -n "${GO_INSTALL}" ]; then
+                if [ -n "${GO_LINKSHARED}" ]; then
+                        ${GO} install ${GOBUILDFLAGS} ./cmd/buildah
+                        ${GO} install ${GOBUILDFLAGS} ./tests/imgtype/imgtype.go
+                        ${GO} install ${GOBUILDFLAGS} ./tests/copy/copy.go
+                        rm -rf ${B}/bin
+                fi
+                ${GO} install ${GO_LINKSHARED} ${GOBUILDFLAGS} ./cmd/buildah
+                ${GO} install ${GO_LINKSHARED} ${GOBUILDFLAGS} ./tests/imgtype/imgtype.go
+                ${GO} install ${GO_LINKSHARED} ${GOBUILDFLAGS} ./tests/copy/copy.go
+        fi
+}
+
+do_install:append() {
+    dest_dir=${D}/${sysconfdir}/containers
+    mkdir -p ${dest_dir}
+    install -m 666 ${S}/src/github.com/containers/buildah/docs/samples/registries.conf ${dest_dir}/buildah.registries.conf.sample
+    install -m 666 ${S}/src/github.com/containers/buildah/tests/policy.json ${dest_dir}/buildah.policy.json.sample
+}
Signature · 1 line
2.25.1
#1 lore raw

PATCH 2/3 catatonit: Integrate version 0.1.7

From: Andrei Gherzan <[email protected]>

This is useful for podman system tests.

---
 recipes-containers/catatonit/catatonit_0.1.7.bb | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 recipes-containers/catatonit/catatonit_0.1.7.bb
recipes-containers/catatonit/catatonit_0.1.7.bb new file +16 -0
new file mode 100644
index 0000000..da3973d
@@ -0,0 +1,16 @@
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: MIT
+
+SUMMARY = "A container init that is so simple it's effectively brain-dead."
+HOMEPAGE = "https://github.com/openSUSE/catatonit"
+DESCRIPTION = "${SUMMARY}"
+SECTION = "base"
+LICENSE = "GPL-3.0-or-later"
+LIC_FILES_CHKSUM = "file://COPYING;md5=1ebbd3e34237af26da5dc08a4e440464"
+
+SRC_URI = "git://github.com/openSUSE/${BPN};protocol=https;branch=main"
+SRCREV = "d8d72fea155c144ed3bf298a35a1aba5625a5656"
+S = "${WORKDIR}/git"
+
+inherit autotools
Signature · 1 line
2.25.1
#2 lore raw

PATCH 3/3 podman: Add ptest support for system tests

In reply to Andrei Gherzan

From: Andrei Gherzan <[email protected]>

---
 recipes-containers/podman/podman/run-ptest | 13 +++++++++++
 recipes-containers/podman/podman_git.bb    | 27 +++++++++++++++++++++-
 2 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100644 recipes-containers/podman/podman/run-ptest
recipes-containers/podman/podman/run-ptest new file +13 -0
new file mode 100644
index 0000000..108ff45
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+# SPDX-FileCopyrightText: Huawei Inc.
+#
+# SPDX-License-Identifier: MIT
+
+#
+# Podman system tests
+#
+
+# The system tests don't need any go related variables. Dummy-define them to
+# avoid useless warnings/errors.
+GOOS=undefined GO=true BUILDTAGS= make localsystem
recipes-containers/podman/podman_git.bb +26 -1
index 09bf827..9dd40d4 100644
@@ -24,6 +24,7 @@ SRC_URI = " \
     file://0002-Define-ActKillThread-equal-to-ActKill.patch;patchdir=src/import/vendor/github.com/seccomp/libseccomp-golang \
     file://CVE-2022-27649.patch;patchdir=src/import \
     ${@bb.utils.contains('PACKAGECONFIG', 'rootless', 'file://50-podman-rootless.conf', '', d)} \
+    file://run-ptest \
 "
 
 LICENSE = "Apache-2.0"
@@ -49,7 +50,7 @@ export LDFLAGS=""
 TOOLCHAIN = "gcc"
 
 inherit go goarch
-inherit systemd pkgconfig
+inherit systemd pkgconfig ptest
 
 do_configure[noexec] = "1"
 
@@ -110,6 +111,17 @@ do_install() {
 	fi
 }
 
+do_install_ptest () {
+	cp ${S}/src/import/Makefile ${D}${PTEST_PATH}
+	install -d ${D}${PTEST_PATH}/test
+	cp -r ${S}/src/import/test/system ${D}${PTEST_PATH}/test
+
+	# Some compatibility links for the Makefile assumptions.
+	install -d ${D}${PTEST_PATH}/bin
+	ln -s ${bindir}/podman ${D}${PTEST_PATH}/bin/podman
+	ln -s ${bindir}/podman-remote ${D}${PTEST_PATH}/bin/podman-remote
+}
+
 FILES:${PN} += " \
     ${systemd_unitdir}/system/* \
     ${systemd_unitdir}/user/* \
@@ -129,3 +141,16 @@ RDEPENDS:${PN} += "\
 "
 RRECOMMENDS:${PN} += "slirp4netns kernel-module-xt-masquerade kernel-module-xt-comment"
 RCONFLICTS:${PN} = "${@bb.utils.contains('PACKAGECONFIG', 'docker', 'docker', '', d)}"
+
+RDEPENDS:${PN}-ptest += " \
+	bash \
+	bats \
+	buildah \
+	catatonit \
+	coreutils \
+	file \
+	gnupg \
+	jq \
+	make \
+	tar \
+"
Signature · 1 line
2.25.1
#3 lore raw
In reply to Andrei Gherzan

Technically we don't add new packages to old branches, without a very good reason.

Sure, this can't break anything that already exists in kirkstone, but it is a new feature when you consider supported hosts, etc.

The changes to master look fine, but I need to consider this a bit longer.

Bruce

Quoted 133 lines · Andrei Gherzan

From: "[email protected]" <[email protected]>

buildah is a command line tool, to be installed and run on target, that can be used to:
- create a working container, either from scratch or using an image as a starting point
- create an image, either from a working container or via the instructions in a Dockerfile
- images can be built in either the OCI image format or the traditional upstream docker image format
- mount a working container's root filesystem for manipulation
- unmount a working container's root filesystem
- use the updated contents of a container's root filesystem as a filesystem layer to create a new image
- delete a working container or an image
- rename a local container

Testing:
Setup the build directory:

   $ . oe-init-build-env <build_dir>

Add to local.conf:

   IMAGE_INSTALL:append = " buildah kernel-modules"
   KERNEL_FEATURES += "features/overlayfs/overlayfs.cfgi \
                       features/netfilter/netfilter.scc  \
                       features/lxc/lxc-enable.scc"
   IMAGE_ROOTFS_EXTRA_SPACE = "5242880"

Build image:

   $ bitbake core-image-minimal

Run the image:

   $ runqemu nographic kvm qemuparams="-m 4096"

On target:
Pull an image:

Quoted 1 line

cnt=$(buildah from fedora)

Or build from Dockerfile

Quoted 1 line

buildah bud -t <image_name>:<tag> .

Mount the image:

Quoted 1 line

mnt=$(buildah mount ${cnt})

Install packages on the container rootfs:

Quoted 1 line

dnf install --installroot $mnt <packages_to_install> -y

Copy local files to the container:

Quoted 1 line

buildah copy $cnt <local_file> <dest_on_container>

Save the changes to an image

Quoted 1 line

buildah commit --format docker $cnt <name>:<tag>

Run the image using buildah:

Quoted 1 line

buildah run $cnt /bin/sh

Or using docker:

Quoted 1 line

docker run -it <name>:<tag>

---
 recipes-containers/buildah/buildah_git.bb | 57 +++++++++++++++++++++++
 1 file changed, 57 insertions(+)
 create mode 100644 recipes-containers/buildah/buildah_git.bb
recipes-containers/buildah/buildah_git.bb new file +57 -1
new file mode 100644
index 0000000..024e82c
@@ -0,0 +1,57 @@
+HOMEPAGE = "https://buildah.io"
+SUMMARY = "A tool that facilitates building OCI container images."
+DESCRIPTION = "A tool that facilitates building OCI container images."
+
+# Apache-2.0 for containerd
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://src/github.com/containers/buildah/LICENSE;md5=e3fc50a88d0a364313df4b21ef20c29e"
+
+S = "${WORKDIR}/git"
+
+BUILDAH_VERSION = "1.26"
+SRCREV_buildah = "0a9d6e6eaef2e2e7936313d449a4e226022eb865"
+
+PV = "${BUILDAH_VERSION}"
+
+inherit go
+inherit goarch
+inherit pkgconfig
+
+GO_IMPORT = "github.com/containers/buildah"
+GO_INSTALL = "${GO_IMPORT}"
+GO_WORKDIR = "${GO_INSTALL}"
+GOBUILDFLAGS += "-mod vendor"
+
+SRC_URI = " \
+    git://github.com/containers/buildah;branch=release-${BUILDAH_VERSION};name=buildah;protocol=https \
+    "
+
+DEPENDS = "libdevmapper btrfs-tools gpgme"
+RDEPENDS:${PN} = "cgroup-lite fuse-overlayfs libdevmapper podman"
+RDEPENDS:${PN}-dev = "bash perl"
+
+do_compile:prepend() {
+    cd ${S}/src/github.com/containers/buildah
+}
+
+go_do_compile() {
+        export TMPDIR="${GOTMPDIR}"
+        if [ -n "${GO_INSTALL}" ]; then
+                if [ -n "${GO_LINKSHARED}" ]; then
+                        ${GO} install ${GOBUILDFLAGS} ./cmd/buildah
+                        ${GO} install ${GOBUILDFLAGS} ./tests/imgtype/imgtype.go
+                        ${GO} install ${GOBUILDFLAGS} ./tests/copy/copy.go
+                        rm -rf ${B}/bin
+                fi
+                ${GO} install ${GO_LINKSHARED} ${GOBUILDFLAGS} ./cmd/buildah
+                ${GO} install ${GO_LINKSHARED} ${GOBUILDFLAGS} ./tests/imgtype/imgtype.go
+                ${GO} install ${GO_LINKSHARED} ${GOBUILDFLAGS} ./tests/copy/copy.go
+        fi
+}
+
+do_install:append() {
+    dest_dir=${D}/${sysconfdir}/containers
+    mkdir -p ${dest_dir}
+    install -m 666 ${S}/src/github.com/containers/buildah/docs/samples/registries.conf ${dest_dir}/buildah.registries.conf.sample
+    install -m 666 ${S}/src/github.com/containers/buildah/tests/policy.json ${dest_dir}/buildah.policy.json.sample
+}
--

2.25.1

Signature · 3 lines
- Thou shalt not follow the NULL pointer, for chaos and madness await
thee at its end
- "Use the force Harry" - Gandalf, Star Trek II
#4 lore raw
Quoted 7 lines · Bruce Ashfield

Technically we don't add new packages to old branches, without a very good reason.

Sure, this can't break anything that already exists in kirkstone, but it is a new feature when you consider supported hosts, etc.

The changes to master look fine, but I need to consider this a bit longer.

That is absolutely fine and understandable. I will import them in local layers if they don't reach kirkstone.

Regards,
Andrei