From patchwork Tue Sep 6 14:58:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Kjellerstedt X-Patchwork-Id: 12376 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 23032C6FA83 for ; Tue, 6 Sep 2022 14:59:08 +0000 (UTC) Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by mx.groups.io with SMTP id smtpd.web12.131.1662476339152728964 for ; Tue, 06 Sep 2022 07:58:59 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@axis.com header.s=axis-central1 header.b=bDfHHC9f; spf=pass (domain: axis.com, ip: 195.60.68.17, mailfrom: peter.kjellerstedt@axis.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1662476339; x=1694012339; h=from:to:subject:date:message-id:mime-version: content-transfer-encoding; bh=7udof6kn7zQFf+JhHXXkRSUFXzQ06PnYrNnQY+nFPwo=; b=bDfHHC9fgup4nvAJgvgjicbMAI+fm7XIsjXjaZQKOoOJDFmXj5WMWuX/ xTftVZtwil9MQBcqXlwhGFFXJvIXiTHjenC3t6tb+c5l3BysJZlbxu3LG AVBauLxm4K7cQpb6+t32ucd3cwUPnioA83j3oF5EbFivgRZJ25NUylUMf 5bbaKnQcrOkR0vyYMuZ2PdD2ppJvOfziGG/j0cXSFMKqwpVen07tifa/T EsF2q7uFx6oDmjVvgfl1m7s9mqu6qJyx7n36b9kUO3FggbcgjgRJ+x8uA /MwVQGW8gChfKFAvOwLAZjThfwftdFPpqjwkJGV6tDUcz0s48Oq8qD1ui w==; From: Peter Kjellerstedt To: Subject: [PATCHv2 1/3] oe-setup-builddir: Correct when validation of the templates dir is run Date: Tue, 6 Sep 2022 16:58:51 +0200 Message-ID: <20220906145853.2617826-1-pkj@axis.com> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 06 Sep 2022 14:59:08 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/170359 The validation of the templates directory is supposed to be run as long as $TEMPLATECONF is defined, but it was only done if the directory did not exist. Signed-off-by: Peter Kjellerstedt --- PATCHv2: Added a commit description. scripts/oe-setup-builddir | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/oe-setup-builddir b/scripts/oe-setup-builddir index d3c7f943e7..70f2245b16 100755 --- a/scripts/oe-setup-builddir +++ b/scripts/oe-setup-builddir @@ -63,11 +63,11 @@ if [ -n "$TEMPLATECONF" ]; then echo >&2 "Error: TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'" exit 1 fi - templatesdir=$(python3 -c "import sys; print(sys.argv[1].strip('/').split('/')[-2])" $TEMPLATECONF) - if [ ! -f "$TEMPLATECONF/../../layer.conf" -o $templatesdir != "templates" ]; then - echo >&2 "Error: TEMPLATECONF value (which is $TEMPLATECONF) must point to meta-some-layer/conf/templates/template-name" - exit 1 - fi + fi + templatesdir=$(python3 -c "import sys; print(sys.argv[1].strip('/').split('/')[-2])" $TEMPLATECONF) + if [ ! -f "$TEMPLATECONF/../../layer.conf" -o $templatesdir != "templates" ]; then + echo >&2 "Error: TEMPLATECONF value (which is $TEMPLATECONF) must point to meta-some-layer/conf/templates/template-name" + exit 1 fi OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample" OECORELOCALCONF="$TEMPLATECONF/local.conf.sample" From patchwork Tue Sep 6 14:58:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Kjellerstedt X-Patchwork-Id: 12377 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 22FE2ECAAD5 for ; Tue, 6 Sep 2022 14:59:08 +0000 (UTC) Received: from smtp1.axis.com (smtp1.axis.com [195.60.68.17]) by mx.groups.io with SMTP id smtpd.web12.131.1662476339152728964 for ; Tue, 06 Sep 2022 07:59:00 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@axis.com header.s=axis-central1 header.b=FKEGgJn6; spf=pass (domain: axis.com, ip: 195.60.68.17, mailfrom: peter.kjellerstedt@axis.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1662476340; x=1694012340; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=pANOZBUY4jdudjTbx1JEoIYnceuYfuZFyu3bdS31QBM=; b=FKEGgJn6m36sFxSjjB0O+HYxvGC3af2Ao4pslPXkDtddySlpQWW7+PqK ugfH2XA4kMyTvXaxVp6uESWAYrG8Y0Pzl5UPH0pExjYcFPgZMALhtS0rG GzGgpkHEwxdUSGaU+U1G+0imq6BN9Xgp1i16ik1PhLj3R5583jzYQ9QpQ GcOeydRpXHvsFOSQvYFbcpv3Vs0L2u/N3eL9iCcup6PreZfBH4A/SDGLS Zgk+9nzHGr2OGoxYMESEkWxHi8yQGyciPhX8sJYqZbZtj1YN50Gmy5w5b LUNjky6R2vQwLZwEdkYv3U9gryao2xT2qiAp9fkoRedVAPXUFhPW4Illa g==; From: Peter Kjellerstedt To: Subject: [PATCHv2 2/3] oe-setup-builddir: Simplify error handling Date: Tue, 6 Sep 2022 16:58:52 +0200 Message-ID: <20220906145853.2617826-2-pkj@axis.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906145853.2617826-1-pkj@axis.com> References: <20220906145853.2617826-1-pkj@axis.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 06 Sep 2022 14:59:08 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/170360 Signed-off-by: Peter Kjellerstedt --- PATCHv2: No changes. scripts/oe-setup-builddir | 29 +++++++++++------------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/scripts/oe-setup-builddir b/scripts/oe-setup-builddir index 70f2245b16..69c33049c7 100755 --- a/scripts/oe-setup-builddir +++ b/scripts/oe-setup-builddir @@ -7,10 +7,12 @@ # SPDX-License-Identifier: GPL-2.0-or-later # -if [ -z "$BUILDDIR" ]; then - echo >&2 "Error: The build directory (BUILDDIR) must be set!" +die() { + echo Error: "$@" >&2 exit 1 -fi +} + +[ -n "$BUILDDIR" ] || die "The build directory (BUILDDIR) must be set!" if [ "$1" = '--help' -o "$1" = '-h' ]; then echo 'Usage: oe-setup-builddir' @@ -22,15 +24,9 @@ fi mkdir -p "$BUILDDIR/conf" -if [ ! -d "$BUILDDIR" ]; then - echo >&2 "Error: The builddir ($BUILDDIR) does not exist!" - exit 1 -fi - -if [ ! -w "$BUILDDIR" ]; then - echo >&2 "Error: Cannot write to $BUILDDIR, perhaps try sourcing with a writable path? i.e. . oe-init-build-env ~/my-build" - exit 1 -fi +[ -d "$BUILDDIR" ] || die "The build directory ($BUILDDIR) does not exist!" +[ -w "$BUILDDIR" ] || + die "Cannot write to $BUILDDIR, perhaps try sourcing with a writable path? i.e. . oe-init-build-env ~/my-build" # Attempting removal of sticky,setuid bits from BUILDDIR, BUILDDIR/conf chmod -st "$BUILDDIR" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR" @@ -59,15 +55,12 @@ if [ -n "$TEMPLATECONF" ]; then if [ -d "$OEROOT/$TEMPLATECONF" ]; then TEMPLATECONF="$OEROOT/$TEMPLATECONF" fi - if [ ! -d "$TEMPLATECONF" ]; then - echo >&2 "Error: TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'" - exit 1 - fi + [ -d "$TEMPLATECONF" ] || + die "TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'" fi templatesdir=$(python3 -c "import sys; print(sys.argv[1].strip('/').split('/')[-2])" $TEMPLATECONF) if [ ! -f "$TEMPLATECONF/../../layer.conf" -o $templatesdir != "templates" ]; then - echo >&2 "Error: TEMPLATECONF value (which is $TEMPLATECONF) must point to meta-some-layer/conf/templates/template-name" - exit 1 + die "TEMPLATECONF value (which is $TEMPLATECONF) must point to meta-some-layer/conf/templates/template-name" fi OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample" OECORELOCALCONF="$TEMPLATECONF/local.conf.sample" From patchwork Tue Sep 6 14:58:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Kjellerstedt X-Patchwork-Id: 12378 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id 24920ECAAA1 for ; Tue, 6 Sep 2022 14:59:08 +0000 (UTC) Received: from smtp2.axis.com (smtp2.axis.com [195.60.68.18]) by mx.groups.io with SMTP id smtpd.web11.149.1662476341042297024 for ; Tue, 06 Sep 2022 07:59:01 -0700 Authentication-Results: mx.groups.io; dkim=pass header.i=@axis.com header.s=axis-central1 header.b=Y/niyuxv; spf=pass (domain: axis.com, ip: 195.60.68.18, mailfrom: peter.kjellerstedt@axis.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=axis.com; q=dns/txt; s=axis-central1; t=1662476342; x=1694012342; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=GhWtpWvFm4JTc2F9U+hJoQ0Fy5MliTLVHWVsKjlUyAU=; b=Y/niyuxvKY7J8rPcaxwZ8fKbJNkm5LqVms/hTqWd9WATBX2Z3FYbR+1G N8HlKeRjo5YmXrojPZ3jjVfmsdb7QyDC7D8Ex7kLe7evMI6IBMY4TRUfD PM/WlVsE7zQ0BzTZMpjUNL1PHBMV8Hg5b//5yho5d+08/PU09Wf542xy+ O73GXpFBJm5VDwvYUcJq4iY3GwJ4jv/LYM0YZasK8TFBQG75jNizHc16z CK3PfIWIeyWDmi7gYz+LBko4mDIkzsrWbz/LyH6hRMdOFL+jDi+rTXJyq +JWf2mgvjpdaXihaQhvX709eCuz0pUDtnmrkImsmaXpaXClsOTLDs0xbm g==; From: Peter Kjellerstedt To: Subject: [PATCHv2 3/3] oe-setup-builddir: Avoid shellcheck warnings Date: Tue, 6 Sep 2022 16:58:53 +0200 Message-ID: <20220906145853.2617826-3-pkj@axis.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220906145853.2617826-1-pkj@axis.com> References: <20220906145853.2617826-1-pkj@axis.com> MIME-Version: 1.0 List-Id: X-Webhook-Received: from li982-79.members.linode.com [45.33.32.79] by aws-us-west-2-korg-lkml-1.web.codeaurora.org with HTTPS for ; Tue, 06 Sep 2022 14:59:08 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/openembedded-core/message/170361 This avoid the following warnings: * SC2086: Double quote to prevent globbing and word splitting. * SC2164: Use 'cd ... || exit' or 'cd ... || return' in case cd fails. * SC2166: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined. * SC2236: Use -n instead of ! -z. Signed-off-by: Peter Kjellerstedt --- PATCHv2: No changes. scripts/oe-setup-builddir | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/oe-setup-builddir b/scripts/oe-setup-builddir index 69c33049c7..b06880c9cb 100755 --- a/scripts/oe-setup-builddir +++ b/scripts/oe-setup-builddir @@ -14,7 +14,7 @@ die() { [ -n "$BUILDDIR" ] || die "The build directory (BUILDDIR) must be set!" -if [ "$1" = '--help' -o "$1" = '-h' ]; then +if [ "$1" = '--help' ] || [ "$1" = '-h' ]; then echo 'Usage: oe-setup-builddir' echo '' echo "OpenEmbedded setup-builddir - setup build directory $BUILDDIR" @@ -32,19 +32,19 @@ mkdir -p "$BUILDDIR/conf" chmod -st "$BUILDDIR" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR" chmod -st "$BUILDDIR/conf" 2>/dev/null || echo "WARNING: unable to chmod $BUILDDIR/conf" -cd "$BUILDDIR" +cd "$BUILDDIR" || die "Failed to change directory to $BUILDDIR!" -if [ -f "$BUILDDIR/conf/templateconf.cfg" -a -z "$TEMPLATECONF" ]; then +if [ -z "$TEMPLATECONF" ] && [ -f "$BUILDDIR/conf/templateconf.cfg" ]; then TEMPLATECONF=$(cat "$BUILDDIR/conf/templateconf.cfg") # The following two are no longer valid; unsetting them will automatically get them replaced # with correct ones. - if [ $TEMPLATECONF = "meta/conf" -o $TEMPLATECONF = "meta-poky/conf" ]; then + if [ "$TEMPLATECONF" = meta/conf ] || [ "$TEMPLATECONF" = meta-poky/conf ]; then unset TEMPLATECONF - rm $BUILDDIR/conf/templateconf.cfg + rm "$BUILDDIR/conf/templateconf.cfg" fi fi -. "$OEROOT"/.templateconf +. "$OEROOT/.templateconf" # # $TEMPLATECONF can point to a directory for the template local.conf & bblayers.conf @@ -58,8 +58,8 @@ if [ -n "$TEMPLATECONF" ]; then [ -d "$TEMPLATECONF" ] || die "TEMPLATECONF value points to nonexistent directory '$TEMPLATECONF'" fi - templatesdir=$(python3 -c "import sys; print(sys.argv[1].strip('/').split('/')[-2])" $TEMPLATECONF) - if [ ! -f "$TEMPLATECONF/../../layer.conf" -o $templatesdir != "templates" ]; then + templatesdir=$(python3 -c "import sys; print(sys.argv[1].strip('/').split('/')[-2])" "$TEMPLATECONF") + if [ "$templatesdir" != templates ] || [ ! -f "$TEMPLATECONF/../../layer.conf" ]; then die "TEMPLATECONF value (which is $TEMPLATECONF) must point to meta-some-layer/conf/templates/template-name" fi OECORELAYERCONF="$TEMPLATECONF/bblayers.conf.sample" @@ -111,7 +111,7 @@ unset OECORELOCALCONF unset OECORELAYERCONF # Ending the first-time run message. Show the YP Documentation banner. -if [ ! -z "$SHOWYPDOC" ]; then +if [ -n "$SHOWYPDOC" ]; then cat <