From patchwork Tue Feb 9 04:10:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Silvano Cirujano Cuesta X-Patchwork-Id: 309 Return-Path: Delivered-To: ilbers.mnt@gmail.com Received: by 2002:a4a:c583:0:0:0:0:0 with SMTP id x3csp529217oop; Tue, 9 Feb 2021 06:10:13 -0800 (PST) X-Received: by 2002:a05:6000:f:: with SMTP id h15mr12202013wrx.148.1612879813434; Tue, 09 Feb 2021 06:10:13 -0800 (PST) ARC-Seal: i=3; a=rsa-sha256; t=1612879813; cv=pass; d=google.com; s=arc-20160816; b=AidL8b5+hiedsRxXkBq1dpbuMAzbkIwUuKyyoVDmugjFSIxjxLI8gP2vsebzS7/C5H HXzyod9N9v7LYSNzwrnGm1TPJBpyiVE+7hVBUlL5vkUNBN+MuVSyJAK8NVz0s95Goo7r goucA8zhK4FhUQpTB8Ed+0AQz1WwEuQICeWY57yttnJH3/aPu1Ddd42DZO0VbwIvpPa8 Whp1Zq3l8VQCiviOJQpEDhLY/kH+XgBBzqY1QCqGsLTc6yC+BTcoH+0MwjoIanLLjSFo CnFvLE6UmZtP6vv5BSaEEkGMFdMQx5x6dCa4RXRxvo8k8o2hzsCm1Pz+tQY9HW+xy32e 5jug== ARC-Message-Signature: i=3; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :sender:dkim-signature; bh=BcJZgon21JjQZveXvYTiexadOAKSP1PCzA91/s805Qc=; b=HsqEjbhsOmqPzDX6MoGX8lxyrRVzPjUCkmhozHHQ7doAroMpsBIWcnTssb1iO+sHSY jI8EfbHD5FmJcjHhIukvkfv9TvGQsg6mJFWNWUG36zZnncla9dnjoRTsvcxlNbbq0CAD fN1l9siwE8ddurqBoYULGhJSaHL49cSIeojzJqifuDgPT93kXf9DLgAR2LOHfMPYZrcy eE/z3dy2h7yZXSzFftZO2UtD+gh7Hhw/t7B5vnK6ne+uQmDvzMcqCHEHaB1XeUqDgCGB 0cBQXOLZYZFE+RDEkplqWv/AAbem+eFcqFo4/pg6B/VkdQPctgHks7uufHk+wa35/Nm3 vzdw== ARC-Authentication-Results: i=3; mx.google.com; dkim=pass header.i=@googlegroups.com header.s=20161025 header.b="ih/HJJJ6"; arc=pass (i=2 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of isar-users+bncbcd6jj6cqqfrbrfprkaqmgqee6l5pha@googlegroups.com designates 209.85.220.55 as permitted sender) smtp.mailfrom=isar-users+bncBCD6JJ6CQQFRBRFPRKAQMGQEE6L5PHA@googlegroups.com; dmarc=fail (p=NONE sp=NONE dis=NONE arc=pass) header.from=siemens.com Received: from mail-sor-f55.google.com (mail-sor-f55.google.com. [209.85.220.55]) by mx.google.com with SMTPS id n5sor10871515wrw.60.2021.02.09.06.10.13 (Google Transport Security); Tue, 09 Feb 2021 06:10:13 -0800 (PST) Received-SPF: pass (google.com: domain of isar-users+bncbcd6jj6cqqfrbrfprkaqmgqee6l5pha@googlegroups.com designates 209.85.220.55 as permitted sender) client-ip=209.85.220.55; Authentication-Results: mx.google.com; dkim=pass header.i=@googlegroups.com header.s=20161025 header.b="ih/HJJJ6"; arc=pass (i=2 spf=pass spfdomain=siemens.com dmarc=pass fromdomain=siemens.com); spf=pass (google.com: domain of isar-users+bncbcd6jj6cqqfrbrfprkaqmgqee6l5pha@googlegroups.com designates 209.85.220.55 as permitted sender) smtp.mailfrom=isar-users+bncBCD6JJ6CQQFRBRFPRKAQMGQEE6L5PHA@googlegroups.com; dmarc=fail (p=NONE sp=NONE dis=NONE arc=pass) header.from=siemens.com ARC-Seal: i=2; a=rsa-sha256; t=1612879813; cv=pass; d=google.com; s=arc-20160816; b=UGzBMenjO4sXo0N5opwTYazMjNZbU4WyxnRv5j/VTESFecX+J5HTtAgsPixhNzAhJn iDkKl7eIJyFPs0ZfsydmiXg+lYjuvqS10XZItJIk8LDskLm6fInuysTJLAdORyNzMdxx CJWWjb5tGE8p4Y7Ia2yoN80BeA9hFYlSHQWtKX5O845+cN9o9lAq6nj4Au6iE+Tnh67I rlaOob+jXXSd64CoLv9DmD48HsScITqgSATkPpU3xsgfc5MZ2rnBtwISS6iWQvd+/+WO 1W1ROGKSY3hWSCGubwIIQPCDdowFZRGxmcxD++RnP9cbpRaeggthdY7O9r3iMCgrBkZ5 5f9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :sender:dkim-signature; bh=BcJZgon21JjQZveXvYTiexadOAKSP1PCzA91/s805Qc=; b=mLu2JfurYmZTtyFDVVgTfECp0wvLvm0DayG7q1/3lChBHfXWX6A/ahJKMyI2HfesXH di1f8I/+j+l0WQk4TZ6hjEcUwpbY6i5kyfTQ4VkpTLkhqGTUmOlTlDpS6VSqSk085oiK l5phnhAvJNFcv0H2l/EwhpyaX35NvVpk2hoJJwh8nzqLm+xIGunBgC8/leG9i3gupzcD N/tOLIfVDFFBZDRnSJpSgbrs2iCQjoskYey7gJOK3VImEIheYKwOFDzR7U8HozEawUq+ ak0cEMsUrut8bfswMGIcAfpscYjGmd1e0wVC24hpNz8y9y62sY9OIFZ7TCASTtev3On2 TVhQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; spf=pass (google.com: domain of silvano.cirujano-cuesta@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=silvano.cirujano-cuesta@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=BcJZgon21JjQZveXvYTiexadOAKSP1PCzA91/s805Qc=; b=ih/HJJJ6XAumFtU1zbnPSnArAOqqFoslUpyRCgk1oUefQ9rAuAIu3Fl3G4ks2p7COC gtEPCYl0cdVMQ6IyF6HWXi4x2eF45KkGrAhrUhaXbO+aZmtPTZvPuovoazGlq9qQkuhN YEQCBrPSHWu9VW6zofVxUTKTGuNoHid20b51LDSPc63PQhhUyq9H9a9L1VOkJOSCVq6h VzxOkPtrRmdSc2Levv7ALE1ps+wqXyDDbhwtcNPnujiw8MHZDaGPftme84lxMKaHa7sZ D4+8V1rGHC+d5cvnMO9LkUQXeIJyLci07vdhJ3n0rrVdkWXPI1UQaaIxZttnXQiW6fnx EroA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:x-spam-checked-in-group:list-post:list-help :list-archive:list-subscribe:list-unsubscribe; bh=BcJZgon21JjQZveXvYTiexadOAKSP1PCzA91/s805Qc=; b=ra6K3iyW2CXU/5tqU7bYS8fJc41HNLcf9T9RTiJNUWd/C/5slENvTplDyKrzYyL12Y HOgsJOipGyXpIEMyIwBFYgWkCR/6FTlSEJmQyuyFpEa/MH4cR24AQh5+k59tQTP9ok3l Jf+mb4uVFgVk3/LQff2bsLcV0hdDTEEsIDLrGEmXH2kfpl/GmE4Wgrv1iytTzVnDWRfs twJaQvt4Q3S+luVAJbbSmQ0TEfqLUmRvp+hrSwbsKLI3SvpDRDryOFMVU9y086FSuujb J8F6gGTgOQCBHBTITZqSEY0T2aoBHaVvZxAp5E2uHJ3AAPClocfQAt20kWcM5Tu2/Ur0 Iw2g== Sender: isar-users@googlegroups.com X-Gm-Message-State: AOAM532Ujem+7IU3rhJujSIGc7zROUUpWLVHsaBMEjEyLgpRSb2QZ6E0 9AAMDZjTl5RdwYkZfvj3Q3U= X-Google-Smtp-Source: ABdhPJwPuhaSp50Qmh+XPIq5PBbKx6beVWqhD0lpCqI5194CC3Eu/1oz+4Q7ruHXaQKMJW+QXS+fHA== X-Received: by 2002:a5d:6089:: with SMTP id w9mr17658105wrt.412.1612879813106; Tue, 09 Feb 2021 06:10:13 -0800 (PST) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a5d:4485:: with SMTP id j5ls4829503wrq.1.gmail; Tue, 09 Feb 2021 06:10:12 -0800 (PST) X-Received: by 2002:a05:6000:1547:: with SMTP id 7mr25962087wry.301.1612879812350; Tue, 09 Feb 2021 06:10:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612879812; cv=none; d=google.com; s=arc-20160816; b=CzyfKOFVNKTaPZwktG77UoBcYVqW0c0tNHsTDTDHHc74GjMmihsYxmacYbWITu2llo v41hnpX0r/uYwaOYauG2L1iPjR8NrsEp/i4uyPZsI5kAJlWKgb39ch+i7ZQwvQxQTLKG SDxmEOBWl5NBOu9IXDInLl65w4nfypVFRca5N2pU2/4r883QLplvYWVZ7vXLykXCWA3t PPWvJKTHjvy0OP41ixHghUd48890vwZJBD6JCxqpAngCDrdOLvnyq6EkmJ8Zgc+vn2mB UAO1wVi2ROUz3UgLUtO3rqxnS31oxMelEPYA35TQKv38i09ATvYeCqxxkQ3q68dA6v+g OD2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from; bh=rQku5cSldo3H+DaZshM57TRkeJcfcYsIvX9nS34LAUo=; b=oXnvHc72L85F962WmQGN23e1PKqkCIwi7vxbSttk2NaSAI6foSPU+83RFehVtbe9YZ tiV0RW9tfjVuP1/3nOMhbrbXDqwsDitpxRO82HceG8gnoWGStQn+63xO/fkNJckuTCbI x3ffwxf3WYj5l0+Aa3wvD1L9pN0d4ix9uMMdlEpGWd2h2zkoyoaDvmh9qkquxgxctgCj 7YsjNzuXW8YOplv4yhRwnYKfKcyVXWHs3wKXMdhrLC7XmYGCTdzgTUwR9fpQh6dV4/XZ GmemHUAkOG1HCi1zeVXToj2QOYeZ0q9ZDWQEJ3fk8a5a/KJILWlFAV434OmqNU/UWrOy S1dQ== ARC-Authentication-Results: i=1; gmr-mx.google.com; spf=pass (google.com: domain of silvano.cirujano-cuesta@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=silvano.cirujano-cuesta@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Received: from gecko.sbs.de (gecko.sbs.de. [194.138.37.40]) by gmr-mx.google.com with ESMTPS id m3si216693wme.0.2021.02.09.06.10.12 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Feb 2021 06:10:12 -0800 (PST) Received-SPF: pass (google.com: domain of silvano.cirujano-cuesta@siemens.com designates 194.138.37.40 as permitted sender) client-ip=194.138.37.40; Received: from mail1.sbs.de (mail1.sbs.de [192.129.41.35]) by gecko.sbs.de (8.15.2/8.15.2) with ESMTPS id 119EAB2L022716 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 9 Feb 2021 15:10:12 +0100 Received: from md1sf36c.ad001.siemens.net ([167.87.10.176]) by mail1.sbs.de (8.15.2/8.15.2) with ESMTP id 119EA6tj018204 for ; Tue, 9 Feb 2021 15:10:09 +0100 From: Silvano Cirujano Cuesta To: isar-users@googlegroups.com Subject: [PATCH V2 2/2] docs: document creation of container images Date: Tue, 9 Feb 2021 15:10:05 +0100 Message-Id: <20210209141005.45491-3-silvano.cirujano-cuesta@siemens.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210209141005.45491-1-silvano.cirujano-cuesta@siemens.com> References: <20210209141005.45491-1-silvano.cirujano-cuesta@siemens.com> MIME-Version: 1.0 X-Original-Sender: silvano.cirujano-cuesta@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; spf=pass (google.com: domain of silvano.cirujano-cuesta@siemens.com designates 194.138.37.40 as permitted sender) smtp.mailfrom=silvano.cirujano-cuesta@siemens.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=siemens.com Precedence: list Mailing-list: list isar-users@googlegroups.com; contact isar-users+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: isar-users@googlegroups.com X-Google-Group-Id: 914930254986 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1691227063052543644?= X-GMAIL-MSGID: =?utf-8?q?1691227063052543644?= Signed-off-by: Silvano Cirujano Cuesta --- doc/user_manual.md | 127 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) diff --git a/doc/user_manual.md b/doc/user_manual.md index a4f3d1d..6b72a16 100644 --- a/doc/user_manual.md +++ b/doc/user_manual.md @@ -19,6 +19,7 @@ Copyright (C) 2016-2019, ilbers GmbH - [Add a Custom Application](#add-a-custom-application) - [Enabling Cross-compilation](#isar-cross-compilation) - [Create an ISAR SDK root filesystem](#create-an-isar-sdk-root-filesystem) + - [Create a containerized ISAR SDK root filesystem](#create-a-containerized-isar-sdk-root-filesystem) - [Creation of local apt repo caching upstream Debian packages](#creation-of-local-apt-repo-caching-upstream-debian-packages) @@ -84,6 +85,9 @@ If your host is >= buster, also install the following package. apt install python3-distutils ``` +If you want to generate containerized SDKs, also install the following packages: `umoci` and `skopeo`. +Umoci is provided by Debian Buster and can be installed with `apt install umoci`, Skopeo is provided by Debian Bullseye/Unstable and has to be installed either manually downloading the DEB and installing it (no other packages required) or with `apt install -t bullseye skopeo` (if unstable/bullseye included in `/etc/apt/sources.list[.d]`). + Notes: * BitBake requires Python 3.4+. @@ -223,6 +227,54 @@ qemu-system-x86_64 -m 256M -nographic -bios edk2/Build/OvmfX64/RELEASE_*/FV/OVMF qemu-system-i386 -m 256M -nographic -hda tmp/deploy/images/qemui386/isar-image-base-debian-buster-qemui386.wic.img ``` +### Generate container image with root-filesystem + +A runnable container image is generated if you set IMAGE_TYPE to 'container-img'. +Getting a container image can be the main purpose of an ISAR configuration, but not only. +A container image created from an ISAR configuration meant for bare-metal or virtual machines can be helpfull to test certain applications which requirements (e.g. libraries) can be easily resolved in a containerized environment. + +Container images can be generated in different formats, selected with the variable `CONTAINER_FORMAT`. One or more (whitespace separated) of following options can be given: + - `docker-archive`: (default) an archive containing a Docker image that can be imported with [`docker import`](https://docs.docker.com/engine/reference/commandline/import/) + - `docker-daemon`: resulting container image is made available on the local Docker Daemon + - `containers-storage`: resulting container image is made available to tools using containers/storage back-end (e.g. Podman, CRIO, buildah,...) + - `oci-archive`: an archive containing an OCI image, mostly for archiving as seed for any of the above formats + +Following formats don't work if running `bitbake ...` (to build the image) from inside of a container (e.g. using `kas-container`): `docker-daemon` and `containers-storage`. +It's technically possible, but requires making host resources (e.g. the Docker Daemon socket) accessible in the container. +What can endanger the stability and security of the host. + +The resulting container image archives (only for `docker-archive` and `oci-archive`) are made available as `tmp/deploy/images/${MACHINE}/${DISTRO}-${DISTRO_ARCH}-${container_format}.tar.xz` (being `container_format` each one of the formats specified in `CONTAINER_FORMAT`). + +### Example + + - Make the relevant environment variables available to the task + +For one-shot builds (use `local.conf` otherwise): + +``` +export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE IMAGE_TYPE CONTAINER_FORMAT" +export IMAGE_TYPE="container-img" +export CONTAINER_FORMAT="docker-archive" +``` + + - Trigger creation of container image from root filesystem + +``` +bitbake mc:qemuarm-buster:isar-image-base +``` + + - Load the container image into the Docker Daemon + +``` +xzcat build/tmp/deploy/images/qemuarm/debian-buster-armhf-docker-archive.tar.xz | docker load +``` + + - Run a container using the container image (following commands starting with `#~:` are to be run in the container) + +``` +docker run --rm -ti --volume "$(pwd):/build" isar-buster-armhf:latest +``` + --- ## Terms and Definitions @@ -834,6 +886,81 @@ ii crossbuild-essential-armhf 12.3 all Inf ~# ``` +## Create a containerized ISAR SDK root filesystem + +### Motivation + +Distributing and using the SDK root filesystem created following the instructions in "[Create an ISAR SDK root filesystem](#create-an-isar-sdk-root-filesystem)" becomes easier using container images (at least for those using containers anyway) +A "containerized" SDK adds to those advantages of a normal SDK root filesystem the comfort of container images. + +### Approach + +Create container image with SDK root filesystem with installed cross-toolchain for target architecture and ability to install already prebuilt target binary artifacts. +Developer: + - runs a container based on the resulting container image mounting the source code to be built, + - develops applications for target platform on the container and + - leaves the container getting the results on the mounted directory. + +### Solution + +A container image containing the SDK is generated if you set IMAGE_TYPE to 'container-img'. + +Container images can be generated in different formats, selected with the variable `CONTAINER_FORMAT`. One or more (space separated) of following options can be given: + - `docker-archive`: (default) an archive containing a Docker image that can be imported with [`docker import`](https://docs.docker.com/engine/reference/commandline/import/) + - `docker-daemon`: resulting container image is made available on the local Docker Daemon + - `containers-storage`: resulting container image is made available to tools using containers/storage back-end (e.g. Podman, CRIO, buildah,...) + - `oci-archive`: an archive containing an OCI image, mostly for archiving as seed for any of the above formats + +User manually triggers creation of SDK formats for his target platform by launching the task `do_populate_sdk` for target image, f.e. +`bitbake -c do_populate_sdk mc:${MACHINE}-${DISTRO}:isar-image-base`. +Packages that should be additionally installed into the SDK can be appended to `SDK_PREINSTALL` (external repositories) and `SDK_INSTALL` (self-built). + +Following formats don't work if running `bitbake -c do_populate_sdk ...` (to generate the containerized SDK) from inside of a container (e.g. using `kas-container`): `docker-daemon` and `containers-storage`. +It's technically possible, but requires making host resources (e.g. the Docker Daemon socket) accessible in the container. +What can endanger the stability and security of the host. + +The resulting SDK formats are archived into `tmp/deploy/images/${MACHINE}/sdk-${DISTRO}-${DISTRO_ARCH}-${sdk_format}.tar.xz` (being `sdk_format` each one of the formats specified in `CONTAINER_FORMAT`). +The SDK container directory `/isar-apt` contains a copy of isar-apt repo with locally prebuilt target debian packages (for ). +One may get into an SDK container and install required target packages with the help of `apt-get install :` command. +The directory with the source code to develop on should be mounted on the container (with `--volume :`) to be able to edit files in the host with an IDE and build in the container. + +### Example + + - Make the relevant environment variables available to the task + +For one-shot builds (use `local.conf` otherwise): + +``` +export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE IMAGE_TYPE CONTAINER_FORMAT" +export IMAGE_TYPE="container-img" +export CONTAINER_FORMAT="docker-archive" +``` + + - Trigger creation of SDK root filesystem + +``` +bitbake -c do_populate_sdk mc:qemuarm-buster:isar-image-base +``` + + - Load the SDK container image into the Docker Daemon + +``` +xzcat build/tmp/deploy/images/qemuarm/sdk-debian-buster-armhf-docker-archive.tar.xz | docker load +``` + + - Run a container using the SDK container image (following commands starting with `#~:` are to be run in the container) + +``` +docker run --rm -ti --volume "$(pwd):/build" isar-sdk-buster-armhf:latest +``` + + - Check that cross toolchains are installed + +``` +:~# dpkg -l | grep crossbuild-essential-armhf +ii crossbuild-essential-armhf 12.3 all Informational list of cross-build-essential packages +``` + ## Creation of local apt repo caching upstream Debian packages ### Motivation