summary refs log tree commit diff
path: root/scripts
diff options
context:
space:
mode:
authorHenri Rosten <henri.rosten@unikie.com>2022-11-09 15:27:30 +0200
committerAlyssa Ross <alyssa.ross@unikie.com>2022-11-09 13:34:50 +0000
commit8e28cc80b14b613247d953c35dc76ef0b864eb33 (patch)
tree3a3798d47c730388b6c1417cb8b2ba3bb1457b89 /scripts
parent0a2a5c6d34eb94d18f9cc6a5076ed5d97f7e0715 (diff)
downloadspectrum-8e28cc80b14b613247d953c35dc76ef0b864eb33.tar
spectrum-8e28cc80b14b613247d953c35dc76ef0b864eb33.tar.gz
spectrum-8e28cc80b14b613247d953c35dc76ef0b864eb33.tar.bz2
spectrum-8e28cc80b14b613247d953c35dc76ef0b864eb33.tar.lz
spectrum-8e28cc80b14b613247d953c35dc76ef0b864eb33.tar.xz
spectrum-8e28cc80b14b613247d953c35dc76ef0b864eb33.tar.zst
spectrum-8e28cc80b14b613247d953c35dc76ef0b864eb33.zip
Remove bashisms from spectrum shell scripts
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.

Also updates the path to the UUID reference used in
undocumented-uuids.sh.

Signed-off-by: Henri Rosten <henri.rosten@unikie.com>
Message-Id: <20221109132730.941054-1-henri.rosten@unikie.com>
Fixes: 0a2a5c6 ("Docs: new structure")
Reviewed-by: Alyssa Ross <alyssa.ross@unikie.com>
Tested-by: Alyssa Ross <alyssa.ross@unikie.com>
Signed-off-by: Alyssa Ross <alyssa.ross@unikie.com>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/format-uuid.sh15
-rwxr-xr-xscripts/make-gpt.sh4
2 files changed, 17 insertions, 2 deletions
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 <hi@alyssa.is>
+# 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..3215edb 100755
--- a/scripts/make-gpt.sh
+++ b/scripts/make-gpt.sh
@@ -1,6 +1,7 @@
 #!/bin/sh -eu
 #
 # SPDX-FileCopyrightText: 2021-2022 Alyssa Ross <hi@alyssa.is>
+# SPDX-FileCopyrightText: 2022 Unikie
 # SPDX-License-Identifier: EUPL-1.2+
 #
 # usage: make-gpt.sh GPT_PATH PATH:PARTTYPE[:PARTUUID]...
@@ -38,7 +39,8 @@ scriptsDir="$(dirname "$0")"
 out="$1"
 shift
 
-nl=$'\n'
+nl='
+'
 table="label: gpt"
 
 # Keep 1MiB free at the start, and 1MiB free at the end.