From patchwork Mon Sep 23 12:51:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "cedric.hombourger@siemens.com" X-Patchwork-Id: 3828 Return-Path: Received: from shymkent.ilbers.de ([unix socket]) by shymkent (Cyrus 2.5.10-Debian-2.5.10-3+deb9u2) with LMTPA; Mon, 23 Sep 2024 14:51:45 +0200 X-Sieve: CMU Sieve 2.4 Received: from mail-yw1-f185.google.com (mail-yw1-f185.google.com [209.85.128.185]) by shymkent.ilbers.de (8.15.2/8.15.2/Debian-8+deb9u1) with ESMTPS id 48NCphS4002484 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT) for ; Mon, 23 Sep 2024 14:51:44 +0200 Received: by mail-yw1-f185.google.com with SMTP id 00721157ae682-6d683cfa528sf54608797b3.0 for ; Mon, 23 Sep 2024 05:51:44 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1727095898; cv=pass; d=google.com; s=arc-20240605; b=hxGs5gra9o4kTsQ0fjOtCmi7xbpYuk6af/lT02i4vh4osr3pvugazfiEUwVwWppFqu HBptAq4lWf/cTIW7Z5g88bZbhG0LEFLB+eOoPCj/rMmMaypzLysNhUJdCkT1nx7lKcqu 4gQpjAU+a9NjtLKGeMzwac23zPOiHcTkkQFYx4koimX7gBkNk66vMAepqAHGrTzK8S+d +JzdtcmTLhwkA7xKs9hDhFRU/KWcTOT4kTK0P11y9OY3yXoaoERe+TX5Rn1BV8+lG8c4 Hks25nr0XMTcbv+gC6jjbpzIHnJS1CHmPh2usCePrKAVAQXOD6SXDLOOrXmtFhqOyE6x Enmg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to:feedback-id:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=MCdpyypu0CxtTk9GfrjVveY0StLxDdAbQHMT9JU8VS8=; fh=cu4jpHo3WgP3FTGSm592p5mPZdvnTpsYY7ldbBAU1PU=; b=Z1d36Pc200LZSscME+8YU+s2JGbf0flkRMPPLFmvygxDq8VATb9IxFqbScR0YpCdZK 6bNpXuXQCZwjf1fmH1zg8hJWe56PVKsZKcXd3CSDl74F3DNIQixZ9fJcDWEpjDBP5RLH eaLhxPYySQIz7pbujbZzNBdbJcRvDbzQt4xRV+pwhZqbVhY/LMZPqXWQUFyM4faL0wFF 2ov6uT/k93Rw7EBd449TuHe3KV9T9wWTo0D5Rqu6Rv6QCoaIpgZMuj9AupEbqRCsD8oe NtX71qgbaiGrtHMkG3BlovLbWVz3ZioEgPkOwnjge9Y0oQk6ml6tpFi/2xO35nH2DUma jAmw==; darn=isar-build.org ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=XSmVmVkG; spf=pass (google.com: domain of fm-1212295-202409231251359f4593a463fd853e29-n8f3nj@rts-flowmailer.siemens.com designates 185.136.64.227 as permitted sender) smtp.mailfrom=fm-1212295-202409231251359f4593a463fd853e29-n8F3NJ@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20230601; t=1727095898; x=1727700698; darn=isar-build.org; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=MCdpyypu0CxtTk9GfrjVveY0StLxDdAbQHMT9JU8VS8=; b=u3hIuFi+2nJv0gH4CVSt86wVUBN/u+LCIhrEV5Kew9Qd5NHdLFs+cpFSYX8NzIuaDS 5JuYaB1Q4GzQGe1LsNer9IUW2PFLtdVSnMx8BeLi7GXhmDtJIsmFoSp3LFKA98HLWcgZ WGfx+vQhiK3FrURaEn2opXQi9Ie3PmhEBGbxjTI8/BEtD/GouRSRlZtmKFBGMVitwXB9 UFqGDifdj/+ioiRSj750rQ0KiqECyUDvHbsqLneX/c5ifz1AWlRKN+2/J22GSjz2qubl f/HFF30Zdxwo+mrs3JVs/KJRVVGvkRHtRVhxLMHU14ySr3IdtiJtrec8luK3E2w4xSuX Lb0Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1727095898; x=1727700698; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :x-spam-checked-in-group:list-id:mailing-list:precedence:reply-to :x-original-authentication-results:x-original-sender:feedback-id :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-beenthere:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=MCdpyypu0CxtTk9GfrjVveY0StLxDdAbQHMT9JU8VS8=; b=Amcwilss+f8OZKkX6KbOE1PaWOeMyt2uLaMFq5f9PA587iYTjZA1byuC5Vjw+tKJU6 FSvNP6JyjTSYKe2LJ0OGkgZFOAtfQquf+W08XRI+T0sj7x6ykUzXpjMBUGk5avnqNNnv Evvm4OyVRpE0gSW+d7pqwutRPHNuS90cwSfHS0H3J35uw0oK2oPUsbIkT9XAmU/IZDp8 EWVaaay37zmJnghx7NDpNxk/u6YUZV1atCD9CnyO3alYW7Venkt5XyvgskLIe2DvpJnJ GSlH9ZVbWD3O9hcKHqNUgQlTf2fLKPSqUzDRnz7nKjkVqpjuH+WxCK/5FHlFNmZ/CSmx +TWQ== X-Forwarded-Encrypted: i=2; AJvYcCXAF1SYO+60n/9Leh+EXJsrBV5p7erBwd/dpuoI8vYSh/l1hgVL+9TcEuHarkclevBPVwhSWJQ=@isar-build.org X-Gm-Message-State: AOJu0YyumSWJI/NlqQnYlQc0KJbmd8ArzMwT7fu477nAoXSyh9ZsFkHe ITHi5JcIXILNP2uZg1uUPA3L0BV8gXCE3pLZmxNVyiLfiENBrjGM X-Google-Smtp-Source: AGHT+IE3LzUwYsKjC2Ydm3PcIsDRY4ylOyERFTQ8vN/+j7pZFo5M3Y2HgQ9b5Mjzj13CaTvmkaKXJw== X-Received: by 2002:a05:6902:2412:b0:e24:8e92:5cd5 with SMTP id 3f1490d57ef6-e248e925e73mr848552276.57.1727095898041; Mon, 23 Sep 2024 05:51:38 -0700 (PDT) X-BeenThere: isar-users@googlegroups.com Received: by 2002:a05:6902:18c6:b0:e22:6a94:f23d with SMTP id 3f1490d57ef6-e226a94f4ebls1171551276.1.-pod-prod-03-us; Mon, 23 Sep 2024 05:51:37 -0700 (PDT) X-Received: by 2002:a05:6902:2412:b0:e24:8e92:5cd5 with SMTP id 3f1490d57ef6-e248e925e73mr848534276.57.1727095897183; Mon, 23 Sep 2024 05:51:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1727095897; cv=none; d=google.com; s=arc-20240605; b=QS9IUQXRdAJayn+SghsGFOiSofpoe8KastKrZmiF0f9pCsRiEuCUMfBd6edCjkGDJO BZfoaIXZL+n310OuOe5/HGUfaSd6PpHhr++MMnfOO8JpZ5lFW0jUUBr/Jp9COFyxr2sq Kys1F0OhNwqADU+9hVmV46jh2h8Ea/dkiL6PlMXj3pYeva+BBXtV6UcHDvIyAMoEgDGy /MrQ+PCZzqocfNJAMG7YW7KncQrgO3MfXzJc1VO0lg/JbKCQ5xRzromk+OjTqBJVUk75 lrZMVYblm7x3FDfZDrsR7PGPu1ZHKJqH3SAxfChfkZN4JcKA4Zs1S4GZqgz/WydiYymi BZlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=feedback-id:content-transfer-encoding:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:dkim-signature; bh=T4yTXE1VnXOnlMwFdwKzsIpgOUdOBhFgOoILbvO6VRs=; fh=1z37pEVhqwMLlkT4FDzOga7XBsM6Rzv6sXOq0pipxqo=; b=ZgwpB8TaAVCKibvX2ylYEoICI5fRB1a5L/nJooxnWHrghfT21w8tjlzLw8MtMm+tly BU2r68rz1PIKpiy9/jRtN07jyvVuRQJmhcG+KOPOBx92fHUBQVeJNLcQ67YcVXdzRvqQ F/hDz8Wb67htcbkSgqaXlkEen8oGthb/0HEswUCBJQYP4jMaQ13SdjKSPw0rrIr74+l6 JnVE18nGUpgoE3DF0ZjIEa4/Cv2doCj6mofP4DRe+pCA3zPd0b14bUIS+DIj1g3RcWy7 z31tY7SzOqlJN7fDMIjxjLB74C0YDcpQrUJTFeoGhd/SGfZfJ0m9V51sjmCI+tvm6E5j 48dQ==; dara=google.com ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=XSmVmVkG; spf=pass (google.com: domain of fm-1212295-202409231251359f4593a463fd853e29-n8f3nj@rts-flowmailer.siemens.com designates 185.136.64.227 as permitted sender) smtp.mailfrom=fm-1212295-202409231251359f4593a463fd853e29-n8F3NJ@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com Received: from mta-64-227.siemens.flowmailer.net (mta-64-227.siemens.flowmailer.net. [185.136.64.227]) by gmr-mx.google.com with ESMTPS id 3f1490d57ef6-e1dc13c8f59si1168275276.4.2024.09.23.05.51.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 23 Sep 2024 05:51:36 -0700 (PDT) Received-SPF: pass (google.com: domain of fm-1212295-202409231251359f4593a463fd853e29-n8f3nj@rts-flowmailer.siemens.com designates 185.136.64.227 as permitted sender) client-ip=185.136.64.227; Received: by mta-64-227.siemens.flowmailer.net with ESMTPSA id 202409231251359f4593a463fd853e29 for ; Mon, 23 Sep 2024 14:51:35 +0200 X-Patchwork-Original-From: "'Cedric Hombourger' via isar-users" From: "cedric.hombourger@siemens.com" To: isar-users@googlegroups.com Cc: Cedric Hombourger Subject: [PATCH v2 1/2] kas: update kas-container to version 4.5 Date: Mon, 23 Sep 2024 14:51:26 +0200 Message-Id: <20240923125127.150443-2-cedric.hombourger@siemens.com> In-Reply-To: <20240923125127.150443-1-cedric.hombourger@siemens.com> References: <20240923125127.150443-1-cedric.hombourger@siemens.com> MIME-Version: 1.0 X-Flowmailer-Platform: Siemens Feedback-ID: 519:519-1212295:519-21489:flowmailer X-Original-Sender: cedric.hombourger@siemens.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@siemens.com header.s=fm2 header.b=XSmVmVkG; spf=pass (google.com: domain of fm-1212295-202409231251359f4593a463fd853e29-n8f3nj@rts-flowmailer.siemens.com designates 185.136.64.227 as permitted sender) smtp.mailfrom=fm-1212295-202409231251359f4593a463fd853e29-n8F3NJ@rts-flowmailer.siemens.com; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=siemens.com X-Original-From: Cedric Hombourger Reply-To: Cedric Hombourger 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-Spam-Status: No, score=-4.9 required=5.0 tests=DKIMWL_WL_MED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_MSPIKE_H2,RCVD_IN_RP_CERTIFIED,RCVD_IN_RP_RNBL,RCVD_IN_RP_SAFE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on shymkent.ilbers.de X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= Prepare support for newer Ubuntu images and update kas-container to the latest where an adequate version of reprepro is pre-installed into the container. See https://github.com/siemens/kas/commit/ffa795c3458e8a074c5f7e0378095d4d01e42aa2 Signed-off-by: Cedric Hombourger --- kas/kas-container | 159 ++++++++++++++++++++++++++++++---------------- 1 file changed, 103 insertions(+), 56 deletions(-) diff --git a/kas/kas-container b/kas/kas-container index 8fa2d16e..6b2131c3 100755 --- a/kas/kas-container +++ b/kas/kas-container @@ -2,7 +2,7 @@ # # kas - setup tool for bitbake based projects # -# Copyright (c) Siemens AG, 2018-2022 +# Copyright (c) Siemens AG, 2018-2024 # # Authors: # Jan Kiszka @@ -27,13 +27,19 @@ set -e +KAS_IMAGE_VERSION_DEFAULT="4.5" +KAS_CONTAINER_IMAGE_PATH_DEFAULT="ghcr.io/siemens/kas" +KAS_CONTAINER_IMAGE_NAME_DEFAULT="kas" +KAS_CONTAINER_SELF_NAME="$(basename "$0")" + usage() { - printf "%b" "Usage: $0 [OPTIONS] { build | shell } [KASOPTIONS] [KASFILE]\n" - printf "%b" " $0 [OPTIONS] { checkout | dump } [KASOPTIONS] [KASFILE]\n" - printf "%b" " $0 [OPTIONS] for-all-repos [KASOPTIONS] [KASFILE] COMMAND\n" - printf "%b" " $0 [OPTIONS] { clean | cleansstate | cleanall}\n" - printf "%b" " $0 [OPTIONS] menu [KCONFIG]\n" + SELF="${KAS_CONTAINER_SELF_NAME}" + printf "%b" "Usage: ${SELF} [OPTIONS] { build | shell } [KASOPTIONS] [KASFILE]\n" + printf "%b" " ${SELF} [OPTIONS] { checkout | dump } [KASOPTIONS] [KASFILE]\n" + printf "%b" " ${SELF} [OPTIONS] for-all-repos [KASOPTIONS] [KASFILE] COMMAND\n" + printf "%b" " ${SELF} [OPTIONS] { clean | cleansstate | cleanall} [KASFILE]\n" + printf "%b" " ${SELF} [OPTIONS] menu [KCONFIG]\n" printf "%b" "\nPositional arguments:\n" printf "%b" "build\t\t\tCheck out repositories and build target.\n" printf "%b" "checkout\t\tCheck out repositories but do not build.\n" @@ -80,6 +86,15 @@ usage() exit 1 } +fatal_error(){ + echo "${KAS_CONTAINER_SELF_NAME}: Error: $*" >&2 + exit 1 +} + +warning(){ + echo "${KAS_CONTAINER_SELF_NAME}: Warning: $*" >&2 +} + trace() { [ -n "${KAS_VERBOSE}" ] && echo "+ $*" >&2 @@ -113,7 +128,6 @@ enable_oe_mode() { run_clean() { if [ -n "${KAS_ISAR_ARGS}" ]; then - set_container_image_var # SC2086: Double quote to prevent globbing and word splitting. # shellcheck disable=2086 trace ${KAS_CONTAINER_COMMAND} run -v "${KAS_BUILD_DIR}":/build:rw \ @@ -135,10 +149,6 @@ run_clean() { fi } -KAS_IMAGE_VERSION_DEFAULT="4.0" -KAS_CONTAINER_IMAGE_PATH_DEFAULT="ghcr.io/siemens/kas" -KAS_CONTAINER_IMAGE_NAME_DEFAULT="kas" - set_container_image_var() { KAS_IMAGE_VERSION="${KAS_IMAGE_VERSION:-${KAS_IMAGE_VERSION_DEFAULT}}" KAS_CONTAINER_IMAGE_NAME="${KAS_CONTAINER_IMAGE_NAME:-${KAS_CONTAINER_IMAGE_NAME_DEFAULT}}" @@ -168,14 +178,12 @@ if [ -z "${KAS_CONTAINER_ENGINE}" ]; then ;; *) # The docker command is an unknown engine - echo "$0: docker command found, but unknown engine detected" >&2 - exit 1 + fatal_error "docker command found, but unknown engine detected" esac elif command -v podman >/dev/null; then KAS_CONTAINER_ENGINE=podman else - echo "$0: no container engine found, need docker or podman" >&2 - exit 1 + fatal_error "no container engine found, need docker or podman" fi fi @@ -190,8 +198,7 @@ podman) KAS_RUNTIME_ARGS="${KAS_RUNTIME_ARGS} --security-opt label=disable" ;; *) - echo "$0: unknown container engine '${KAS_CONTAINER_ENGINE}'" >&2 - exit 1 + fatal_error "unknown container engine '${KAS_CONTAINER_ENGINE}'" ;; esac @@ -205,8 +212,7 @@ while [ $# -gt 0 ]; do --with-loop-dev) if ! KAS_LOOP_DEV=$(/sbin/losetup -f 2>/dev/null); then if [ "$(id -u)" -eq 0 ]; then - echo "Error: loop device not available!" - exit 1 + fatal_error "loop device not available!" fi sudo_command="/sbin/losetup -f" sudo_message="[sudo] enter password to setup loop" @@ -216,10 +222,9 @@ while [ $# -gt 0 ]; do # shellcheck disable=2086 if ! KAS_LOOP_DEV=$(sudo -p "$sudo_message" $sudo_command \ 2>/dev/null); then - echo "Error: loop device setup unsuccessful!" - echo "try calling '$sudo_command' with root" \ - "permissions manually." - exit 1 + fatal_error "loop device setup unsuccessful!" \ + "try calling '$sudo_command' with root" \ + "permissions manually." fi fi KAS_WITH_LOOP_DEV="--device ${KAS_LOOP_DEV}" @@ -236,6 +241,9 @@ while [ $# -gt 0 ]; do shift 2 ;; --ssh-agent) + if [ -z "${SSH_AUTH_SOCK}" ]; then + fatal_error "no SSH agent running" + fi KAS_SSH_AUTH_SOCK=$(readlink -fv "$SSH_AUTH_SOCK") shift 1 ;; @@ -274,16 +282,16 @@ while [ $# -gt 0 ]; do shift 2 ;; --version) - echo "$(basename "$0") $KAS_IMAGE_VERSION_DEFAULT" + echo "${KAS_CONTAINER_SELF_NAME} $KAS_IMAGE_VERSION_DEFAULT" exit 0 ;; --*) usage ;; clean|cleansstate|cleanall) - [ $# -eq 1 ] || usage - run_clean "$1" - exit 0 + KAS_CMD=$1 + shift 1 + break ;; shell) KAS_REPO_MOUNT_OPT_DEFAULT="rw" @@ -322,15 +330,21 @@ while [ $# -gt 0 ] && [ $KAS_EXTRA_BITBAKE_ARGS -eq 0 ]; do case "$1" in --skip|--target|--task) KAS_OPTIONS="${KAS_OPTIONS} $1 $2" - shift 2 + shift 1 + shift 1 || KAS_OPTIONS="--help" ;; -c|--cmd|--command) KAS_BITBAKE_C_OPTION_ARGS="$2" - shift 2 + shift 1 + shift 1 || KAS_OPTIONS="--help" ;; -E|--preserve-env) - echo "$1 is not supported with kas-container" - exit 1 + fatal_error "$1 is not supported with ${KAS_CONTAINER_SELF_NAME}" + ;; + --provenance) + KAS_OPTIONS="${KAS_OPTIONS} $1 $2" + shift 1 + shift 1 || KAS_OPTIONS="--help" ;; --) KAS_EXTRA_BITBAKE_ARGS=$# @@ -340,13 +354,23 @@ while [ $# -gt 0 ] && [ $KAS_EXTRA_BITBAKE_ARGS -eq 0 ]; do shift 1 ;; *) + ARG="$1" + shift 1 + if [ "$KAS_CMD" = "for-all-repos" ]; then + if [ $# -gt 0 ]; then + KAS_REPO_CMD="$1" + shift 1 + else + KAS_REPO_CMD="$ARG" + unset ARG + fi + fi KAS_FILES= # SC2086: Double quote to prevent globbing and word splitting. # shellcheck disable=2086 - for FILE in $(IFS=':'; echo $1); do + for FILE in $(IFS=':'; echo $ARG); do if ! KAS_REAL_FILE="$(realpath -qe "$FILE")"; then - echo "Error: configuration file '${FILE}' not found" - exit 1 + fatal_error "configuration file '${FILE}' not found" fi if [ -z "${KAS_FILES}" ]; then KAS_FIRST_FILE="${KAS_REAL_FILE}" @@ -355,11 +379,6 @@ while [ $# -gt 0 ] && [ $KAS_EXTRA_BITBAKE_ARGS -eq 0 ]; do KAS_FILES="${KAS_FILES}:${KAS_REAL_FILE}" fi done - shift 1 - if [ "$KAS_CMD" = "for-all-repos" ]; then - KAS_REPO_CMD="$1" - shift 1 - fi ;; esac done @@ -395,7 +414,7 @@ if [ "${KAS_CMD}" = "menu" ]; then set -- "$@" -e _KAS_REPO_DIR_HOST="$(readlink -fv "${KAS_REPO_DIR}")" fi - BUILD_SYSTEM=$(tr '\n' '\f' 2>/dev/null < ${KAS_FIRST_FILE} | \ + BUILD_SYSTEM=$(tr '\n' '\f' 2>/dev/null < "${KAS_FIRST_FILE}" | \ sed -e 's/\(.*\fconfig KAS_BUILD_SYSTEM\f\(.*\)\|.*\)/\2/' \ -e 's/\f\([[:alpha:]].*\|$\)//' \ -e 's/.*default \"\(.*\)\".*/\1/') @@ -416,18 +435,24 @@ fi set_container_image_var +# short circuit for clean* commands. We just need +# the build-system information, but no repo mounts, etc... +if echo "${KAS_CMD}" | grep -qe "^clean"; then + run_clean "${KAS_CMD}" + exit 0 +fi + KAS_REPO_MOUNT_OPT="${KAS_REPO_MOUNT_OPT:-${KAS_REPO_MOUNT_OPT_DEFAULT}}" KAS_FILES="$(echo "${KAS_FILES}" | sed 's|'"${KAS_REPO_DIR}"'/|/repo/|g')" if [ "$(id -u)" -eq 0 ] && [ "${KAS_ALLOW_ROOT}" != "yes" ] ; then - echo "Error: Running as root - may break certain recipes." - echo "Better give a regular user docker access. Set" \ - "KAS_ALLOW_ROOT=yes to override." - exit 1 + fatal_error "Running as root - may break certain recipes." \ + "Better give a regular user docker access. Set" \ + "KAS_ALLOW_ROOT=yes to override." fi -set -- "$@" -v "${KAS_REPO_DIR}":/repo:${KAS_REPO_MOUNT_OPT} \ +set -- "$@" -v "${KAS_REPO_DIR}:/repo:${KAS_REPO_MOUNT_OPT}" \ -v "${KAS_WORK_DIR}":/work:rw -e KAS_WORK_DIR=/work \ -v "${KAS_BUILD_DIR}":/build:rw \ --workdir=/repo \ @@ -436,16 +461,14 @@ set -- "$@" -v "${KAS_REPO_DIR}":/repo:${KAS_REPO_MOUNT_OPT} \ if [ -n "${KAS_SSH_DIR}" ] ; then if [ ! -d "${KAS_SSH_DIR}" ]; then - echo "Passed KAS_SSH_DIR '${KAS_SSH_DIR}' is not a directory" - exit 1 + fatal_error "passed KAS_SSH_DIR '${KAS_SSH_DIR}' is not a directory" fi set -- "$@" -v "$(readlink -fv "${KAS_SSH_DIR}")":/var/kas/userdata/.ssh:ro fi if [ -n "${KAS_SSH_AUTH_SOCK}" ]; then if [ ! -S "${KAS_SSH_AUTH_SOCK}" ]; then - echo "Passed SSH_AUTH_SOCK '${KAS_SSH_AUTH_SOCK}' is not a socket" - exit 1 + fatal_error "passed SSH_AUTH_SOCK '${KAS_SSH_AUTH_SOCK}' is not a socket" fi set -- "$@" -v "${KAS_SSH_AUTH_SOCK}":/ssh-agent/ssh-auth-sock \ -e SSH_AUTH_SOCK=/ssh-agent/ssh-auth-sock @@ -453,20 +476,27 @@ fi if [ -n "${KAS_AWS_DIR}" ] ; then if [ ! -d "${KAS_AWS_DIR}" ]; then - echo "Passed KAS_AWS_DIR '${KAS_AWS_DIR}' is not a directory" - exit 1 + fatal_error "passed KAS_AWS_DIR '${KAS_AWS_DIR}' is not a directory" fi set -- "$@" -v "$(readlink -fv "${KAS_AWS_DIR}")":/var/kas/userdata/.aws:ro \ -e AWS_CONFIG_FILE="${AWS_CONFIG_FILE:-/var/kas/userdata/.aws/config}" \ -e AWS_SHARED_CREDENTIALS_FILE="${AWS_SHARED_CREDENTIALS_FILE:-/var/kas/userdata/.aws/credentials}" fi +if [ -n "${AWS_WEB_IDENTITY_TOKEN_FILE}" ] ; then + if [ ! -f "${AWS_WEB_IDENTITY_TOKEN_FILE}" ]; then + echo "Passed AWS_WEB_IDENTITY_TOKEN_FILE '${AWS_WEB_IDENTITY_TOKEN_FILE}' is not a directory" + exit 1 + fi + set -- "$@" -v "$(readlink -fv "${AWS_WEB_IDENTITY_TOKEN_FILE}")":/var/kas/userdata/.aws/web_identity_token:ro \ + -e AWS_WEB_IDENTITY_TOKEN_FILE="${AWS_CONFIG_FILE:-/var/kas/userdata/.aws/web_identity_token}" \ + -e AWS_ROLE_ARN="${AWS_ROLE_ARN}" +fi KAS_GIT_CREDENTIAL_HELPER_DEFAULT="" if [ -n "${KAS_GIT_CREDENTIAL_STORE}" ] ; then if [ ! -f "${KAS_GIT_CREDENTIAL_STORE}" ]; then - echo "Passed KAS_GIT_CREDENTIAL_STORE '${KAS_GIT_CREDENTIAL_STORE}' is not a file" - exit 1 + fatal_error "passed KAS_GIT_CREDENTIAL_STORE '${KAS_GIT_CREDENTIAL_STORE}' is not a file" fi KAS_GIT_CREDENTIAL_HELPER_DEFAULT="store --file=/var/kas/userdata/.git-credentials" set -- "$@" -v "$(readlink -fv "${KAS_GIT_CREDENTIAL_STORE}")":/var/kas/userdata/.git-credentials:ro @@ -483,6 +513,16 @@ if [ -f "${NETRC_FILE}" ]; then -e NETRC_FILE="/var/kas/userdata/.netrc" fi +if [ -f "${GITCONFIG_FILE}" ]; then + set -- "$@" -v "$(readlink -fv "${GITCONFIG_FILE}")":/var/kas/userdata/.gitconfig:ro \ + -e GITCONFIG_FILE="/var/kas/userdata/.gitconfig" +fi + +if [ -f "${REGISTRY_AUTH_FILE}" ]; then + set -- "$@" -v "$(readlink -fv "${REGISTRY_AUTH_FILE}")":/var/kas/userdata/.docker/config.json:ro \ + -e REGISTRY_AUTH_FILE="/var/kas/userdata/.docker/config.json" +fi + if [ -t 1 ]; then set -- "$@" -t -i fi @@ -500,18 +540,24 @@ if [ -n "${SSTATE_DIR}" ]; then -v "$(readlink -fv "${SSTATE_DIR}")":/sstate:rw \ -e SSTATE_DIR=/sstate fi +if [ -n "${SSTATE_MIRRORS}" ]; then + if echo "${SSTATE_MIRRORS}" | grep -q "file:///"; then + warning "SSTATE_MIRRORS contains a local path." \ + "Make sure to make this path available inside the container." + fi + set -- "$@" -e "SSTATE_MIRRORS=${SSTATE_MIRRORS}" +fi if [ -n "${KAS_REPO_REF_DIR}" ]; then if [ ! -d "${KAS_REPO_REF_DIR}" ]; then - echo "Passed KAS_REPO_REF_DIR '${KAS_REPO_REF_DIR}' is not a directory" - exit 1 + fatal_error "Passed KAS_REPO_REF_DIR '${KAS_REPO_REF_DIR}' is not a directory" fi set -- "$@" \ -v "$(readlink -fv "${KAS_REPO_REF_DIR}")":/repo-ref:rw \ -e KAS_REPO_REF_DIR=/repo-ref fi -for var in TERM KAS_DISTRO KAS_MACHINE KAS_TARGET KAS_TASK \ +for var in TERM KAS_DISTRO KAS_MACHINE KAS_TARGET KAS_TASK KAS_CLONE_DEPTH \ KAS_PREMIRRORS DISTRO_APT_PREMIRRORS BB_NUMBER_THREADS PARALLEL_MAKE \ GIT_CREDENTIAL_USEHTTPPATH; do if [ -n "$(eval echo \$${var})" ]; then @@ -559,4 +605,5 @@ while [ $KAS_EXTRA_BITBAKE_ARGS -gt 0 ]; do KAS_EXTRA_BITBAKE_ARGS=$((KAS_EXTRA_BITBAKE_ARGS - 1)) done +# shellcheck disable=SC2086 trace ${KAS_CONTAINER_COMMAND} run "$@"