|
| 1 | +From 36198274dcb4332f1acd445d2a80854232b1d236 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Dallas Delaney <dadelan@microsoft.com> |
| 3 | +Date: Thu, 26 Jan 2023 14:58:55 -0800 |
| 4 | +Subject: [PATCH] osbuilder: Add support for CBL-Mariner |
| 5 | + |
| 6 | +Add osbuilder support to build a rootfs and image |
| 7 | +based on the CBL-Mariner Linux distro |
| 8 | + |
| 9 | +Fixes: #6462 |
| 10 | + |
| 11 | +Signed-off-by: Dallas Delaney <dadelan@microsoft.com> |
| 12 | +--- |
| 13 | + tools/osbuilder/README.md | 14 +++++----- |
| 14 | + .../rootfs-builder/cbl-mariner/Dockerfile.in | 15 +++++++++++ |
| 15 | + .../rootfs-builder/cbl-mariner/config.sh | 10 +++++++ |
| 16 | + .../rootfs-builder/cbl-mariner/rootfs_lib.sh | 26 +++++++++++++++++++ |
| 17 | + 4 files changed, 58 insertions(+), 7 deletions(-) |
| 18 | + create mode 100644 tools/osbuilder/rootfs-builder/cbl-mariner/Dockerfile.in |
| 19 | + create mode 100644 tools/osbuilder/rootfs-builder/cbl-mariner/config.sh |
| 20 | + create mode 100644 tools/osbuilder/rootfs-builder/cbl-mariner/rootfs_lib.sh |
| 21 | + |
| 22 | +diff --git a/tools/osbuilder/README.md b/tools/osbuilder/README.md |
| 23 | +index 343d2bf60..9415de74e 100644 |
| 24 | +--- a/tools/osbuilder/README.md |
| 25 | ++++ b/tools/osbuilder/README.md |
| 26 | +@@ -80,7 +80,7 @@ filesystem components to generate an initrd. |
| 27 | + 3. When generating an image, the initrd is extracted to obtain the base rootfs for |
| 28 | + the image. |
| 29 | + |
| 30 | +-Ubuntu is the default distro for building the rootfs, to use a different one, you can set `DISTRO=alpine|clearlinux|debian|ubuntu`. |
| 31 | ++Ubuntu is the default distro for building the rootfs, to use a different one, you can set `DISTRO=alpine|clearlinux|debian|ubuntu|cbl-mariner`. |
| 32 | + For example `make USE_DOCKER=true DISTRO=alpine rootfs` will make an Alpine rootfs using Docker. |
| 33 | + |
| 34 | + ### Rootfs creation |
| 35 | +@@ -209,9 +209,9 @@ of the the osbuilder distributions. |
| 36 | + > Note: this table is not relevant for the dracut build method, since it supports |
| 37 | + any Linux distribution and architecture where dracut is available. |
| 38 | + |
| 39 | +-| |Alpine |CentOS Stream |Clear Linux |Debian/Ubuntu | |
| 40 | +-|-- |-- |-- |-- |-- | |
| 41 | +-|**ARM64** |:heavy_check_mark:|:heavy_check_mark:| | | |
| 42 | +-|**PPC64le**| |:heavy_check_mark:| |:heavy_check_mark:| |
| 43 | +-|**s390x** | |:heavy_check_mark:| |:heavy_check_mark:| |
| 44 | +-|**x86_64** |:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| |
| 45 | ++| |Alpine |CentOS Stream |Clear Linux |Debian/Ubuntu |CBL-Mariner | |
| 46 | ++|-- |-- |-- |-- |-- |-- | |
| 47 | ++|**ARM64** |:heavy_check_mark:|:heavy_check_mark:| | | | |
| 48 | ++|**PPC64le**| |:heavy_check_mark:| |:heavy_check_mark:| | |
| 49 | ++|**s390x** | |:heavy_check_mark:| |:heavy_check_mark:| | |
| 50 | ++|**x86_64** |:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:|:heavy_check_mark:| |
| 51 | +diff --git a/tools/osbuilder/rootfs-builder/cbl-mariner/Dockerfile.in b/tools/osbuilder/rootfs-builder/cbl-mariner/Dockerfile.in |
| 52 | +new file mode 100644 |
| 53 | +index 000000000..6fa29807d |
| 54 | +--- /dev/null |
| 55 | ++++ b/tools/osbuilder/rootfs-builder/cbl-mariner/Dockerfile.in |
| 56 | +@@ -0,0 +1,15 @@ |
| 57 | ++# Copyright (c) 2023 Microsoft Corporation |
| 58 | ++# |
| 59 | ++# SPDX-License-Identifier: Apache-2.0 |
| 60 | ++ |
| 61 | ++ARG IMAGE_REGISTRY=mcr.microsoft.com |
| 62 | ++FROM ${IMAGE_REGISTRY}/cbl-mariner/base/core:@OS_VERSION@ |
| 63 | ++ |
| 64 | ++RUN tdnf -y install \ |
| 65 | ++ ca-certificates \ |
| 66 | ++ build-essential \ |
| 67 | ++ dnf \ |
| 68 | ++ git \ |
| 69 | ++ tar |
| 70 | ++ |
| 71 | ++@INSTALL_RUST@ |
| 72 | +diff --git a/tools/osbuilder/rootfs-builder/cbl-mariner/config.sh b/tools/osbuilder/rootfs-builder/cbl-mariner/config.sh |
| 73 | +new file mode 100644 |
| 74 | +index 000000000..694124acd |
| 75 | +--- /dev/null |
| 76 | ++++ b/tools/osbuilder/rootfs-builder/cbl-mariner/config.sh |
| 77 | +@@ -0,0 +1,10 @@ |
| 78 | ++# Copyright (c) 2023 Microsoft Corporation |
| 79 | ++# |
| 80 | ++# SPDX-License-Identifier: Apache-2.0 |
| 81 | ++ |
| 82 | ++OS_NAME=cbl-mariner |
| 83 | ++OS_VERSION=${OS_VERSION:-2.0} |
| 84 | ++LIBC="gnu" |
| 85 | ++PACKAGES="core-packages-base-image ca-certificates" |
| 86 | ++[ "$AGENT_INIT" = no ] && PACKAGES+=" systemd" |
| 87 | ++[ "$SECCOMP" = yes ] && PACKAGES+=" libseccomp" |
| 88 | +diff --git a/tools/osbuilder/rootfs-builder/cbl-mariner/rootfs_lib.sh b/tools/osbuilder/rootfs-builder/cbl-mariner/rootfs_lib.sh |
| 89 | +new file mode 100644 |
| 90 | +index 000000000..0288d4d77 |
| 91 | +--- /dev/null |
| 92 | ++++ b/tools/osbuilder/rootfs-builder/cbl-mariner/rootfs_lib.sh |
| 93 | +@@ -0,0 +1,26 @@ |
| 94 | ++# Copyright (c) 2023 Microsoft Corporation |
| 95 | ++# |
| 96 | ++# SPDX-License-Identifier: Apache-2.0 |
| 97 | ++ |
| 98 | ++build_rootfs() |
| 99 | ++{ |
| 100 | ++ # Mandatory |
| 101 | ++ local ROOTFS_DIR="$1" |
| 102 | ++ |
| 103 | ++ [ -z "$ROOTFS_DIR" ] && die "need rootfs" |
| 104 | ++ |
| 105 | ++ # In case of support EXTRA packages, use it to allow |
| 106 | ++ # users add more packages to the base rootfs |
| 107 | ++ local EXTRA_PKGS=${EXTRA_PKGS:-""} |
| 108 | ++ |
| 109 | ++ check_root |
| 110 | ++ mkdir -p "${ROOTFS_DIR}" |
| 111 | ++ PKG_MANAGER="tdnf" |
| 112 | ++ |
| 113 | ++ DNF="${PKG_MANAGER} -y --installroot=${ROOTFS_DIR} --noplugins --releasever=${OS_VERSION}" |
| 114 | ++ |
| 115 | ++ info "install packages for rootfs" |
| 116 | ++ $DNF install ${EXTRA_PKGS} ${PACKAGES} |
| 117 | ++ |
| 118 | ++ rm -rf ${ROOTFS_DIR}/usr/share/{bash-completion,cracklib,doc,info,locale,man,misc,pixmaps,terminfo,zoneinfo,zsh} |
| 119 | ++} |
| 120 | +-- |
| 121 | +2.33.8 |
| 122 | + |
0 commit comments