From patchwork Sun Oct 25 08:15:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Prado X-Patchwork-Id: 1387135 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.137; helo=fraxinus.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=e-labworks.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=e-labworks-com.20150623.gappssmtp.com header.i=@e-labworks-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=Nmotg4wF; dkim-atps=neutral Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CJrZp45g2z9sSs for ; Sun, 25 Oct 2020 19:23:30 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id EFE9B86B18; Sun, 25 Oct 2020 08:23:26 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LHnLPA_uqHkz; Sun, 25 Oct 2020 08:23:26 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by fraxinus.osuosl.org (Postfix) with ESMTP id 03AC286AB7; Sun, 25 Oct 2020 08:23:26 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id A34571BF3ED for ; Sun, 25 Oct 2020 08:23:24 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 9CF72272E3 for ; Sun, 25 Oct 2020 08:23:24 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 6BV6aho2zjGm for ; Sun, 25 Oct 2020 08:23:23 +0000 (UTC) X-Greylist: delayed 00:07:55 by SQLgrey-1.7.6 Received: from mail-qt1-f181.google.com (mail-qt1-f181.google.com [209.85.160.181]) by silver.osuosl.org (Postfix) with ESMTPS id 5C0952305A for ; Sun, 25 Oct 2020 08:23:23 +0000 (UTC) Received: by mail-qt1-f181.google.com with SMTP id e6so4600513qtw.10 for ; Sun, 25 Oct 2020 01:23:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=e-labworks-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=wDjwhOa7Jl4g78dKzieaZe4nXlW0hy3V9z6B/TMWKks=; b=Nmotg4wFERVimeQOfjtiXQ2T+pNTEwGhNfe+roFsurKP4PViet/Cn8tJtcFKyKpQNs 5D59VlBmNUvi/QRpVLI5WdVVewAO4WqU6GcUAAnfH1LTezCeVOtM0nrC1wBs2iM0I8Uy dkuxQuuAmz0q7QAw4+T9edi8IksVJrQmgu8rwPtHsRAXHj+rbkiHOSVu7wQNkBqmSqzs h+Tkg2EsIoSGbVOfXSZmT/yrgsbPEduPoulIis8n02RLZZhzH5rzblWAqoOZlttphJ2U clL8h20eul/HvqV7NI+3nPNpL6mrip9jjev+OS4AU3mHNQyFNNrKs71Pix9Yo7u5pLsb DQTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=wDjwhOa7Jl4g78dKzieaZe4nXlW0hy3V9z6B/TMWKks=; b=tx8rirJ7nKpvhUnqzrtwKLXhMhhucuOlLWcVPVrrv1F+CXa+KxNJp7aSS880BCXx3a E1RTLFCgOVZgni0vPLJpgAXTfB/1G6fucAgENhWNJsRjYiLKOlYsxTzPKt7datdY58LI npN+xqylQqtVWJ4iNyNeQu0olioZlWKAUytAmp+zOwnFcJOXY7zOlKDkkN5Sj00wgghl kZSfmpe3VIVOClFb0ZAtg2v3LEBdh3bjnr5ceABFrLyMeJctRStTNMCcrlC5Wam1Qu8i A/X8yAqCO0Q7znfUK4nxc7nNHx3FQhyIfsGhXG13zRnQiHe57z9dbnb0XzWaxg2kcod4 37JA== X-Gm-Message-State: AOAM530fHU/g6sdF9Vf8bWR1vUB9kaLTCiFaZXOFcyE51bjZ06gS8EIF L817zYrTCmmIE38evzxDz2ebC7READICwABX X-Google-Smtp-Source: ABdhPJxpXIiX09lcguQexXmkM4++spaPiUjT0uelnqA0oYpuAcnvMjOdOj6VGkwbWlUurfB9B3N5Cw== X-Received: by 2002:ac8:5387:: with SMTP id x7mr10567143qtp.130.1603613726755; Sun, 25 Oct 2020 01:15:26 -0700 (PDT) Received: from localhost.localdomain ([189.62.45.160]) by smtp.gmail.com with ESMTPSA id m15sm4692755qtc.90.2020.10.25.01.15.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2020 01:15:26 -0700 (PDT) From: Sergio Prado X-Google-Original-From: Sergio Prado To: buildroot@buildroot.org Date: Sun, 25 Oct 2020 05:15:17 -0300 Message-Id: <20201025081518.22309-2-sergio.prado@toradex.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201025081518.22309-1-sergio.prado@toradex.com> References: <20201025081518.22309-1-sergio.prado@toradex.com> Subject: [Buildroot] [PATCH v1 1/2] package/sloci-image: new host package X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Prado MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Sergio Prado sloci-image is a simple CLI tool for packing rootfs into a single-layer OCI image. The patch fixes a escaping issue and a PR was sent upstream: https://github.com/jirutka/sloci-image/pull/2 Signed-off-by: Sergio Prado --- DEVELOPERS | 1 + package/Config.in.host | 1 + ...ues-when-generating-the-OCI-image-co.patch | 55 +++++++++++++++++++ package/sloci-image/Config.in.host | 7 +++ package/sloci-image/sloci-image.hash | 5 ++ package/sloci-image/sloci-image.mk | 19 +++++++ 6 files changed, 88 insertions(+) create mode 100644 package/sloci-image/0001-Fix-escaping-issues-when-generating-the-OCI-image-co.patch create mode 100644 package/sloci-image/Config.in.host create mode 100644 package/sloci-image/sloci-image.hash create mode 100644 package/sloci-image/sloci-image.mk diff --git a/DEVELOPERS b/DEVELOPERS index b245c1cd7eee..a0bfde2391a6 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -2383,6 +2383,7 @@ F: package/curlpp/ F: package/daq/ F: package/libgdiplus/ F: package/pimd/ +F: package/sloci-image/ F: package/snort/ F: package/stella/ F: package/tio/ diff --git a/package/Config.in.host b/package/Config.in.host index 546f1c226dec..26ed8480cc21 100644 --- a/package/Config.in.host +++ b/package/Config.in.host @@ -76,6 +76,7 @@ menu "Host utilities" source "package/sam-ba/Config.in.host" source "package/sdbusplus/Config.in.host" source "package/sentry-cli/Config.in.host" + source "package/sloci-image/Config.in.host" source "package/squashfs/Config.in.host" source "package/sunxi-tools/Config.in.host" source "package/swig/Config.in.host" diff --git a/package/sloci-image/0001-Fix-escaping-issues-when-generating-the-OCI-image-co.patch b/package/sloci-image/0001-Fix-escaping-issues-when-generating-the-OCI-image-co.patch new file mode 100644 index 000000000000..de95cda38717 --- /dev/null +++ b/package/sloci-image/0001-Fix-escaping-issues-when-generating-the-OCI-image-co.patch @@ -0,0 +1,55 @@ +From f2ebd0aaff7c519fd3d1c64bdfbedb49b6c60c11 Mon Sep 17 00:00:00 2001 +From: Sergio Prado +Date: Sat, 24 Oct 2020 12:43:46 -0300 +Subject: [PATCH] Fix escaping issues when generating the OCI image config + files + +Some parameters are not escaping correctly the double quotes +when generating the OCI image config files. + +This is easily reproducible: + +$ mkdir rootfs +$ ./sloci-image --arch arm --user 0 rootfs oci-image:latest +$ grep -R "User" oci-image/ +oci-image/blobs/sha256/e574ac66b91453b00beb37717ed0e604249fa695ec772e17a56ff208357ec72a: \"User\": "0", + +Fix that by escaping the double quotes with an echo command. + +Signed-off-by: Sergio Prado +--- + sloci-image | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/sloci-image b/sloci-image +index be8e79a824e0..2c7ab5047271 100755 +--- a/sloci-image ++++ b/sloci-image +@@ -269,13 +269,13 @@ oci_image_config() { + "architecture": "$(oci_arch $CFG_ARCH)", + "os": "$CFG_OS", + "config": { +- ${CFG_USER:+"\"User\": $(json_string "$CFG_USER"),"} ++ ${CFG_USER:+"$(echo \"User\"): $(json_string "$CFG_USER"),"} + "ExposedPorts": $(json_pseudoarray "$CFG_PORTS"), + "Env": $(json_string_array "$CFG_ENV"), + "Entrypoint": $(json_string_array "$CFG_ENTRYPOINT"), + "Cmd": $(json_string_array "$CFG_CMD"), + "Volumes": $(json_pseudoarray "$CFG_VOLUMES"), +- ${CFG_WORKING_DIR:+"\"WorkingDir\": $(json_string "$CFG_WORKING_DIR"),"} ++ ${CFG_WORKING_DIR:+"$(echo \"WorkingDir\"): $(json_string "$CFG_WORKING_DIR"),"} + "Labels": $(json_string_map "$CFG_LABELS") + }, + "rootfs": { +@@ -309,7 +309,7 @@ oci_image_index() { + "digest": "$manifest_digest", + "platform": { + "architecture": "$(oci_arch $CFG_ARCH)", +- ${CFG_ARCH_VARIANT:+"\"variant\": $(json_string "$CFG_ARCH_VARIANT"),"} ++ ${CFG_ARCH_VARIANT:+"$(echo \"variant\"): $(json_string "$CFG_ARCH_VARIANT"),"} + "os": "$CFG_OS" + }, + "annotations": { +-- +2.17.1 + diff --git a/package/sloci-image/Config.in.host b/package/sloci-image/Config.in.host new file mode 100644 index 000000000000..d809f1f3c786 --- /dev/null +++ b/package/sloci-image/Config.in.host @@ -0,0 +1,7 @@ +config BR2_PACKAGE_HOST_SLOCI_IMAGE + bool "host sloci-image" + help + A simple CLI tool for packing rootfs into a single-layer OCI + image. + + https://github.com/jirutka/sloci-image diff --git a/package/sloci-image/sloci-image.hash b/package/sloci-image/sloci-image.hash new file mode 100644 index 000000000000..2476b2340823 --- /dev/null +++ b/package/sloci-image/sloci-image.hash @@ -0,0 +1,5 @@ +# Locally computed +sha256 2c154e355aea65089921058c8ba96cc90e6c22753b4e7956221403b6183ac775 sloci-image-4015e49763e5a738026a5bbfcf32b38b5a4fa650.tar.gz + +# Hash for license files: +sha256 8ea53673b084576813fc40cd63817c5a1619438942b5e6c30dac1d10707c27e4 LICENSE diff --git a/package/sloci-image/sloci-image.mk b/package/sloci-image/sloci-image.mk new file mode 100644 index 000000000000..ab716a074342 --- /dev/null +++ b/package/sloci-image/sloci-image.mk @@ -0,0 +1,19 @@ +################################################################################ +# +# sloci-image +# +################################################################################ + +SLOCI_IMAGE_VERSION = 4015e49763e5a738026a5bbfcf32b38b5a4fa650 +SLOCI_IMAGE_SITE = $(call github,jirutka,sloci-image,$(SLOCI_IMAGE_VERSION)) + +SLOCI_IMAGE_LICENSE = MIT +SLOCI_IMAGE_LICENSE_FILES = LICENSE + +HOST_SLOCI_IMAGE_DEPENDENCIES = host-gawk + +define HOST_SLOCI_IMAGE_INSTALL_CMDS + $(HOST_MAKE_ENV) $(MAKE) DESTDIR=$(HOST_DIR) PREFIX=/usr -C $(@D) install +endef + +$(eval $(host-generic-package)) From patchwork Sun Oct 25 08:15:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sergio Prado X-Patchwork-Id: 1387133 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=busybox.net (client-ip=140.211.166.133; helo=hemlock.osuosl.org; envelope-from=buildroot-bounces@busybox.net; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=e-labworks.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=e-labworks-com.20150623.gappssmtp.com header.i=@e-labworks-com.20150623.gappssmtp.com header.a=rsa-sha256 header.s=20150623 header.b=WjL4a9GU; dkim-atps=neutral Received: from hemlock.osuosl.org (smtp2.osuosl.org [140.211.166.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4CJrYD3dv3z9sSs for ; Sun, 25 Oct 2020 19:22:05 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by hemlock.osuosl.org (Postfix) with ESMTP id C29968753D; Sun, 25 Oct 2020 08:22:01 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from hemlock.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id qNXlBRawifUD; Sun, 25 Oct 2020 08:21:59 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by hemlock.osuosl.org (Postfix) with ESMTP id 7648187485; Sun, 25 Oct 2020 08:21:59 +0000 (UTC) X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from fraxinus.osuosl.org (smtp4.osuosl.org [140.211.166.137]) by ash.osuosl.org (Postfix) with ESMTP id 38BDD1BF3ED for ; Sun, 25 Oct 2020 08:21:58 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by fraxinus.osuosl.org (Postfix) with ESMTP id 3558486AB7 for ; Sun, 25 Oct 2020 08:21:58 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from fraxinus.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S8JAu4MQT-UL for ; Sun, 25 Oct 2020 08:21:57 +0000 (UTC) X-Greylist: delayed 00:06:30 by SQLgrey-1.7.6 Received: from mail-qk1-f174.google.com (mail-qk1-f174.google.com [209.85.222.174]) by fraxinus.osuosl.org (Postfix) with ESMTPS id D788F864F4 for ; Sun, 25 Oct 2020 08:21:56 +0000 (UTC) Received: by mail-qk1-f174.google.com with SMTP id k9so5666170qki.6 for ; Sun, 25 Oct 2020 01:21:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=e-labworks-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=7+R1xoVnev4q6mh/XPgcg1ulwItTEBrX0uMwlDjEAfY=; b=WjL4a9GU8qs13N3ZY5GiLm1yPhOKpY0UvMOtvuUnoq74Yqw5BXXnt/ARF6FGOH64zf IIoKZRSSZpnqLhjEi4hnpQTMryFg20oCrBV01p3AfmvfXBHUXqRxBcP6N99j6fsAjjzs V6FJ3pWq3n/0v/wJO26hseZz46rDDNI6d+R/M6jXFmVFrUf3y9ntdKLKFCaC9OVeH/qN 2/53B6wLkQ8NibiutseKyibC9y8eJAUq6cLMXupYKgC+PDFrS4cPQbfLh6xV1caQ4g9E 19c/TkkrOfbewYhd91BxMuuxDpzZq7kEkexmCC836iG45cl06GBqrsEALEbeLTbzZGZ9 Jwow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=7+R1xoVnev4q6mh/XPgcg1ulwItTEBrX0uMwlDjEAfY=; b=PQk5tGtX0KHb8cj2qLb376+L+vr6SvPeqXWUrMRs+vGOdGHIYOO+rKSm4z4H/1xpCE ll6zLEmWGEDYj/hXnAHkn4/yVsy5yqzrO0yRpT8eq++c2JOlqMoxoADYehCsPF6TDnXG M3WHZYmtu4SRnTV8Invr/hBrcbier/vqN1zAhqMWgPMoPxXr4+PAHAIxRAByfa211Rgk sDSuRL7lmsi+8zCINDKr0191CrDTAkXEXfrVPZpTO40wmkKhuBOkadh/AdlFskGrMqB4 US/nUA1I0HTGsR/FK3lOtNoGhnMnMW1Zbap/SjI21GldOXtv87ccZzhPtFgtuMLAgWUP 0Y6w== X-Gm-Message-State: AOAM530QYIY0FrN3+Y0AkKGuIRFSj7QVSIhJ6spTRvJ8G906pk54pjIJ IwHbK4FYuvj+mKctVlzK/a5Jx49o7NyK21dp X-Google-Smtp-Source: ABdhPJz1BzmYwz5oY/VnHxKhkCTyh+fqACjpBpFPFah6CnWfBy0oK8bosuwogz14OXdvV2vxkZV0lA== X-Received: by 2002:a05:620a:311:: with SMTP id s17mr11647282qkm.482.1603613728167; Sun, 25 Oct 2020 01:15:28 -0700 (PDT) Received: from localhost.localdomain ([189.62.45.160]) by smtp.gmail.com with ESMTPSA id m15sm4692755qtc.90.2020.10.25.01.15.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Oct 2020 01:15:27 -0700 (PDT) From: Sergio Prado X-Google-Original-From: Sergio Prado To: buildroot@buildroot.org Date: Sun, 25 Oct 2020 05:15:18 -0300 Message-Id: <20201025081518.22309-3-sergio.prado@toradex.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20201025081518.22309-1-sergio.prado@toradex.com> References: <20201025081518.22309-1-sergio.prado@toradex.com> Subject: [Buildroot] [PATCH v1 2/2] oci: add new filesystem type X-BeenThere: buildroot@busybox.net X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sergio Prado MIME-Version: 1.0 Errors-To: buildroot-bounces@busybox.net Sender: "buildroot" From: Sergio Prado Add support to generate OCI (Open Container Initiative) images. An OCI image consists of a manifest, an image index (optional), a set of filesystem layers, and a configuration. The complete specification is available in the link below: https://github.com/opencontainers/image-spec/blob/master/spec.md The image is generated with the host tool sloci-image, and config options can be used to configure image parameters. By default, the image is generated in a directory called rootfs-oci: $ cd output/images $ ls rootfs-oci/ blobs index.json oci-layout Optionally, the image can be packed into a tar archive. The image can be pushed to a registry using containers tools like skopeo: $ skopeo copy --dest-creds : oci:rootfs-oci: \ docker:/// And then we can pull/run the container image with tools like docker: $ docker run -it /: Signed-off-by: Sergio Prado --- fs/Config.in | 1 + fs/oci/Config.in | 88 +++++++++++++++++++++++++++++++++++++++++++ fs/oci/oci.mk | 97 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 186 insertions(+) create mode 100644 fs/oci/Config.in create mode 100644 fs/oci/oci.mk diff --git a/fs/Config.in b/fs/Config.in index 37a2aa21f8ac..eee5e26bb2b3 100644 --- a/fs/Config.in +++ b/fs/Config.in @@ -11,6 +11,7 @@ source "fs/f2fs/Config.in" source "fs/initramfs/Config.in" source "fs/iso9660/Config.in" source "fs/jffs2/Config.in" +source "fs/oci/Config.in" source "fs/romfs/Config.in" source "fs/squashfs/Config.in" source "fs/tar/Config.in" diff --git a/fs/oci/Config.in b/fs/oci/Config.in new file mode 100644 index 000000000000..b17e7009e9e5 --- /dev/null +++ b/fs/oci/Config.in @@ -0,0 +1,88 @@ +config BR2_TARGET_ROOTFS_OCI + bool "oci image" + help + Build an OCI (Open Container Initiative) image. + + By default, the image is generated in a directory called + rootfs-oci: + + $ cd output/images + $ ls rootfs-oci/ + blobs index.json oci-layout + + You can push the image to a registry. Example using skopeo: + + $ skopeo copy --dest-creds : \ + oci:rootfs-oci: docker:/// + + And pull/run it with docker: + + $ docker run -it /: + +if BR2_TARGET_ROOTFS_OCI + +config BR2_TARGET_ROOTFS_OCI_AUTHOR + string "author name and/or email address" + default "Buildroot" + help + Name and/or email address of the person which created the + image. + +config BR2_TARGET_ROOTFS_OCI_TAG + string "image tag" + default "latest" + help + Tag to be used in the container image. If empty, 'latest' will + be used by default. + +config BR2_TARGET_ROOTFS_OCI_ENTRYPOINT + string "entrypoint" + default "sh" + help + Command to execute when the container starts. + +config BR2_TARGET_ROOTFS_OCI_ENTRYPOINT_ARGS + string "entrypoint arguments" + help + Default arguments to the entrypoint of the container. + +config BR2_TARGET_ROOTFS_OCI_WORKDIR + string "working directory" + help + Working directory of the entrypoint process in the + container. + +config BR2_TARGET_ROOTFS_OCI_UID + string "username or UID" + default "0" + help + The username or UID of user the process run as. + +config BR2_TARGET_ROOTFS_OCI_ENV_VARS + string "environment variables" + help + Default environment variables for the container. + +config BR2_TARGET_ROOTFS_OCI_PORTS + string "ports" + help + Default set of ports to expose from a container running + this image in the following format: + + /tcp, /udp, (same as /tcp). + +config BR2_TARGET_ROOTFS_OCI_LABELS + string "labels" + help + Metadata in the format KEY=VALUE for the container compliant + with OCI annotation rules. If KEY starts with a dot, it will + be prefixed with "org.opencontainers.image" + (e.g. .url -> org.opencontainers.image.url). + +config BR2_TARGET_ROOTFS_OCI_ARCHIVE + bool "pack oci image into a tar archive" + default n + help + Select whether the image should be packed into a TAR archive. + +endif diff --git a/fs/oci/oci.mk b/fs/oci/oci.mk new file mode 100644 index 000000000000..9656ad3c0312 --- /dev/null +++ b/fs/oci/oci.mk @@ -0,0 +1,97 @@ +################################################################################ +# +# Build the oci image +# +################################################################################ + +ROOTFS_OCI_IMAGE_NAME = rootfs-oci + +ROOTFS_OCI_DEPENDENCIES = host-sloci-image + +# architecture +SLOCI_IMAGE_OPTS = --arch $(BR2_ARCH) + +# architecture variant (typically used only for arm) +ifeq ($(BR2_ARM_CPU_HAS_ARM),y) +ifeq ($(BR2_ARM_CPU_ARMV5),y) +SLOCI_IMAGE_OPTS += --arch-variant v5 +else ifeq ($(BR2_ARM_CPU_ARMV6),y) +SLOCI_IMAGE_OPTS += --arch-variant v6 +else ifeq ($(BR2_ARM_CPU_ARMV7A),y) +SLOCI_IMAGE_OPTS += --arch-variant v7 +else ifeq ($(BR2_ARM_CPU_ARMV8A),y) +SLOCI_IMAGE_OPTS += --arch-variant v8 +endif +endif + +# entrypoint +OCI_ENTRYPOINT = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_ENTRYPOINT)) +ifneq ($(OCI_ENTRYPOINT),) +SLOCI_IMAGE_OPTS += --entrypoint $(OCI_ENTRYPOINT) +endif + +# entrypoint arguments +OCI_ENTRYPOINT_ARGS = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_ENTRYPOINT_ARGS)) +ifneq ($(OCI_ENTRYPOINT_ARGS),) +SLOCI_IMAGE_OPTS += --cmd "$(OCI_ENTRYPOINT_ARGS)" +endif + +# author +OCI_AUTHOR = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_AUTHOR)) +ifneq ($(OCI_AUTHOR),) +SLOCI_IMAGE_OPTS += --author "$(OCI_AUTHOR)" +endif + +# username or UID +OCI_UID = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_UID)) +ifneq ($(OCI_UID),) +SLOCI_IMAGE_OPTS += --user $(OCI_UID) +endif + +# labels +OCI_LABELS = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_LABELS)) +ifneq ($(OCI_LABELS),) +SLOCI_IMAGE_OPTS += \ + $(foreach label,$(OCI_LABELS),--label $(label)) +endif + +# environment variables +OCI_ENV_VARS = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_ENV_VARS)) +ifneq ($(OCI_ENV_VARS),) +SLOCI_IMAGE_OPTS += \ + $(foreach var,$(OCI_ENV_VARS),--env $(var)) +endif + +# working directory +OCI_WORKDIR = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_WORKDIR)) +ifneq ($(OCI_WORKDIR),) +SLOCI_IMAGE_OPTS += --working-dir $(OCI_WORKDIR) +endif + +# ports +OCI_PORTS = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_PORTS)) +ifneq ($(OCI_PORTS),) +SLOCI_IMAGE_OPTS += \ + $(foreach port,$(OCI_PORTS),--port $(port)) +endif + +# tag +OCI_TAG = $(call qstrip,$(BR2_TARGET_ROOTFS_OCI_TAG)) +ifeq ($(OCI_TAG),) +OCI_TAG = latest +endif + +# enable tar archive +ifeq ($(BR2_TARGET_ROOTFS_OCI_ARCHIVE),y) +SLOCI_IMAGE_OPTS += --tar +endif + +define ROOTFS_OCI_CMD + (cd $(BINARIES_DIR); \ + rm -rf $(ROOTFS_OCI_IMAGE_NAME)* + $(HOST_DIR)/bin/sloci-image $(SLOCI_IMAGE_OPTS) $(TARGET_DIR) \ + $(ROOTFS_OCI_IMAGE_NAME):$(OCI_TAG) + ) +endef + +$(eval $(rootfs))