From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from atuin.qyliss.net (localhost [IPv6:::1]) by atuin.qyliss.net (Postfix) with ESMTP id 6EA9420E4B; Wed, 9 Nov 2022 06:23:21 +0000 (UTC) Received: by atuin.qyliss.net (Postfix, from userid 496) id 54E8620E82; Wed, 9 Nov 2022 06:23:19 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on atuin.qyliss.net X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,LOTS_OF_MONEY,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.6 Received: from mail-lj1-x22a.google.com (mail-lj1-x22a.google.com [IPv6:2a00:1450:4864:20::22a]) by atuin.qyliss.net (Postfix) with ESMTPS id 3ABDA20E3A for ; Wed, 9 Nov 2022 06:23:17 +0000 (UTC) Received: by mail-lj1-x22a.google.com with SMTP id u2so24303928ljl.3 for ; Tue, 08 Nov 2022 22:23:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=unikie.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=e+MYkP44WIXTK1aKCcijv+UZcJg78RQxJWM0WCdo+4M=; b=YgyjCFrelOx+YeaXygYOwAL0k9xmfb8J2OGFQ8av3Y1zQJ4KJU/UKmcu5caI3y1yRA +ErBVi/DbLJI9qnGuGrEAkHSCJpv5bA/29K7JtgQGlktl31S8o83Hcua8VfaFDHOPL+I XVQSP0qBuizCi8eCpHCsKxRU3fK8eguak83baKUmk/hTP93JdTwnb/U3uKRadqsU1j5m im2B0e/Rt7fO/C25895zoFz14j2GCwxOdTqoSilZ8W6TQvFhjwDXmgaLyxWhVnM8gmVl NqhSvgw2MH4Oc4N+H8cvVGcpeDeqOvzs4tM5NvfQYEqEspFcleAXciq8YrCNkH7ic+fE dlNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=e+MYkP44WIXTK1aKCcijv+UZcJg78RQxJWM0WCdo+4M=; b=f1xJTu4X/Kch5Yij2FmKHLN9Jm5fi9IPWwdCJrgmwLaa7jxkYW2rXdnm8oIf7x+2ym tZbAn6k4uMaCQwxngXC0Jqhfhn6idAvMdZhAtMGoAnEyA5gzqoVSuAxPPK2UIdIYaWJp Mw8X51UEQmUx9BCOz3rpe3dqfwjsfYTHNOXQHZGA3miSRn1Ep6BfI1eNRUnpNqXSuhP6 Q9nDx35SQbSNUilR0/s/oDv1iBSYCYysjKq/L2XsW6sFUEvYtYG7yd0/ZIAlyeQ6eraA icC91NiyfkaZxMn6V30NzNizs28aYNTbOw5Y64YA0S6WfxSM2NL2OzFMA729MQJa3tLb WFPA== X-Gm-Message-State: ACrzQf11k9o/I4ytZs4p+8m5osPl6qCSJdbBuVuZKcJtZ7k42ZPgDW7A B7F3g79I59BK42AZ5AXcyZapf0DeVcO5iw== X-Google-Smtp-Source: AMsMyM79wrnHbiVuTELgqDBJwFaXl8FM60IRtyr3dSCd8wqtqCr3HkN0WMCzoZhX0c3cx3srfsMA3w== X-Received: by 2002:a2e:86d4:0:b0:277:1d64:f21c with SMTP id n20-20020a2e86d4000000b002771d64f21cmr7636231ljj.373.1667974994479; Tue, 08 Nov 2022 22:23:14 -0800 (PST) Received: from buamix.lan (86-60-162-79.dynamic.lounea.fi. [86.60.162.79]) by smtp.gmail.com with ESMTPSA id s16-20020a056512215000b004a2c447598fsm2091170lfr.159.2022.11.08.22.23.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 08 Nov 2022 22:23:13 -0800 (PST) From: Henri Rosten To: devel@spectrum-os.org Subject: [PATCH v2] Remove bashisms from spectrum shell scripts Date: Wed, 9 Nov 2022 08:22:51 +0200 Message-Id: <20221109062251.850946-1-henri.rosten@unikie.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Message-ID-Hash: SVZGT6A2F5UBCGOPZ6IEBKGAV2ZXB7MP X-Message-ID-Hash: SVZGT6A2F5UBCGOPZ6IEBKGAV2ZXB7MP X-MailFrom: henri.rosten@unikie.com X-Mailman-Rule-Hits: header-match-devel.spectrum-os.org-0 X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1 CC: Henri Rosten X-Mailman-Version: 3.3.5 Precedence: list List-Id: Patches and low-level development discussion Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: X-TUID: 0Ok6v6Ta/epW This commit removes bashisms from spectrum shell scripts. This change is needed to be able to use the scripts from POSIX-compliant shells which are not bash compatible - such as dash. Signed-off-by: Henri Rosten --- Documentation/scripts/undocumented-uuids.sh | 7 ++++++- scripts/format-uuid.sh | 15 ++++++++++++++- scripts/make-gpt.sh | 7 +++---- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/Documentation/scripts/undocumented-uuids.sh b/Documentation/scripts/undocumented-uuids.sh index 34c2d22..fa21366 100755 --- a/Documentation/scripts/undocumented-uuids.sh +++ b/Documentation/scripts/undocumented-uuids.sh @@ -1,14 +1,19 @@ #!/bin/sh -eu # SPDX-FileCopyrightText: 2022 Alyssa Ross +# SPDX-FileCopyrightText: 2022 Unikie # SPDX-License-Identifier: EUPL-1.2+ +trap 'rm -f -- "$documented_uuids"' EXIT + cd "$(dirname "$0")/../.." PATTERN='\b[A-F0-9]{8}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{4}-[A-F0-9]{12}\b' UUID_REFERENCE_PATH=Documentation/uuid-reference.adoc +documented_uuids=$(mktemp) +grep -Eio "$PATTERN" "$UUID_REFERENCE_PATH" | sort -u >$documented_uuids git ls-files -coz --exclude-standard | grep -Fxvz "$UUID_REFERENCE_PATH" | xargs -0 git grep -Ehio --no-index --no-line-number "$PATTERN" -- | sort -u | - comm -23 - <(grep -Eio "$PATTERN" "$UUID_REFERENCE_PATH" | sort -u) + comm -23 - $documented_uuids diff --git a/scripts/format-uuid.sh b/scripts/format-uuid.sh index fa07eb9..6758088 100755 --- a/scripts/format-uuid.sh +++ b/scripts/format-uuid.sh @@ -1,6 +1,19 @@ #!/bin/sh -eu # # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross +# SPDX-FileCopyrightText: 2022 Unikie # SPDX-License-Identifier: EUPL-1.2+ -printf "%s\n" "${1:0:8}-${1:8:4}-${1:12:4}-${1:16:4}-${1:20}" +substr () { + str=$1 + beg=$2 + end=$3 + echo $str | cut -c $beg-$end +} + +u1=$(substr $1 1 8) +u2=$(substr $1 9 12) +u3=$(substr $1 13 16) +u4=$(substr $1 17 20) +u5=$(substr $1 21 32) +printf "%s\n" "$u1-$u2-$u3-$u4-$u5" diff --git a/scripts/make-gpt.sh b/scripts/make-gpt.sh index 56076d3..351aa69 100755 --- a/scripts/make-gpt.sh +++ b/scripts/make-gpt.sh @@ -1,6 +1,7 @@ #!/bin/sh -eu # # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross +# SPDX-FileCopyrightText: 2022 Unikie # SPDX-License-Identifier: EUPL-1.2+ # # usage: make-gpt.sh GPT_PATH PATH:PARTTYPE[:PARTUUID]... @@ -38,7 +39,7 @@ scriptsDir="$(dirname "$0")" out="$1" shift -nl=$'\n' +nl='\n' table="label: gpt" # Keep 1MiB free at the start, and 1MiB free at the end. @@ -51,9 +52,7 @@ done rm -f "$out" truncate -s "$gptBytes" "$out" -sfdisk "$out" <