scripts: Address shellcheck issues
Report issues by shell files with: git ls-files '*.sh' | xargs shellcheck --exclude=SC2162 Address the following: - SC1087: Use braces when expanding arrays - SC1091: Not following - SC2004: `$`/`${}` is unnecessary on arithmetic variables - SC2024: `sudo` doesn't affect redirects - SC2034: foo appears unused. Verify it or export it - SC2086: Double quote to prevent globbing and word splitting - SC2087: Quote `EOF` - SC2115: Use `"${var:?}"` to ensure this never expands to `/*` - SC2148: Add a shebang Addresses (at least partially) some POSIX/dash issues: - SC2113: `function` keyword is non-standard - SC3010: In POSIX sh, `[[` `]]` is undefined - SC3014: In POSIX sh, `==` in place of `=` is undefined - SC3020: In POSIX sh, `&>` is undefined - SC3046: In POSIX sh, `source` in place of `.` is undefined Does not address: - SC2162: `read` without `-r` will mangle backslashes - Any other POSIX/dash-specific issues Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
parent
aa32ba26e1
commit
968a612824
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -z "$1" -o ! -e "$1" -o -z "$2" ]
|
if [ -z "$1" ] || [ ! -e "$1" ] || [ -z "$2" ]
|
||||||
then
|
then
|
||||||
echo "$0 [coreboot.config] [coreboot.rom]" >&2
|
echo "$0 [coreboot.config] [coreboot.rom]" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -10,7 +10,7 @@ fi
|
|||||||
CONFIG="$(realpath "$1")"
|
CONFIG="$(realpath "$1")"
|
||||||
COREBOOT="$(realpath "$2")"
|
COREBOOT="$(realpath "$2")"
|
||||||
|
|
||||||
function check_configs() {
|
check_configs() {
|
||||||
local defconfig="$1"
|
local defconfig="$1"
|
||||||
|
|
||||||
while read -r line; do
|
while read -r line; do
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# shellcheck disable=SC1090
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -z "$1" -o ! -e "$1" -o -z "$2" ]
|
if [ -z "$1" ] || [ ! -e "$1" ] || [ -z "$2" ]
|
||||||
then
|
then
|
||||||
echo "$0 <config> <output>" >&2
|
echo "$0 <config> <output>" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -z "$1" ]
|
if [ -z "$1" ]
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
|
||||||
if [ ! -d "models/${MODEL}" ]
|
if [ ! -d "models/${MODEL}" ]
|
||||||
then
|
then
|
||||||
echo "model '${MODEL}' not found" >&2
|
echo "model '${MODEL}' not found" >&2
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# shellcheck disable=SC2034
|
||||||
|
|
||||||
SPIPI=${SPIPI:-"system76@spipi.local"}
|
SPIPI=${SPIPI:-"system76@spipi.local"}
|
||||||
|
|
||||||
if [ ! -d "models/${MODEL}" ]
|
if [ ! -d "models/${MODEL}" ]
|
||||||
|
@ -46,7 +46,7 @@ EDK2_ARGS+=(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Rebuild gop-policy (used by edk2)
|
# Rebuild gop-policy (used by edk2)
|
||||||
if [ -e "${MODEL_DIR}/IntelGopDriver.inf" -a -e "${MODEL_DIR}/vbt.rom" ]
|
if [ -e "${MODEL_DIR}/IntelGopDriver.inf" ] && [ -e "${MODEL_DIR}/vbt.rom" ]
|
||||||
then
|
then
|
||||||
touch apps/gop-policy/Cargo.toml
|
touch apps/gop-policy/Cargo.toml
|
||||||
FIRMWARE_OPEN_VBT="${MODEL_DIR}/vbt.rom" \
|
FIRMWARE_OPEN_VBT="${MODEL_DIR}/vbt.rom" \
|
||||||
@ -84,7 +84,7 @@ KERNELVERSION="${VERSION}" \
|
|||||||
"${COREBOOT}"
|
"${COREBOOT}"
|
||||||
|
|
||||||
# Rebuild EC firmware for System76 EC models
|
# Rebuild EC firmware for System76 EC models
|
||||||
if [ ! -e "${MODEL_DIR}/ec.rom" -a -e "${MODEL_DIR}/ec.config" ]
|
if [ ! -e "${MODEL_DIR}/ec.rom" ] && [ -e "${MODEL_DIR}/ec.config" ]
|
||||||
then
|
then
|
||||||
env VERSION="${VERSION}" \
|
env VERSION="${VERSION}" \
|
||||||
./scripts/_build/ec.sh \
|
./scripts/_build/ec.sh \
|
||||||
|
@ -9,7 +9,7 @@ then
|
|||||||
fi
|
fi
|
||||||
MODEL="$1"
|
MODEL="$1"
|
||||||
|
|
||||||
source scripts/_ch341a.sh
|
. scripts/_ch341a.sh
|
||||||
|
|
||||||
flashrom -p ch341a_spi -c "${CHIP}" -r build/dump.rom
|
flashrom -p ch341a_spi -c "${CHIP}" -r build/dump.rom
|
||||||
|
|
||||||
|
@ -9,6 +9,6 @@ then
|
|||||||
fi
|
fi
|
||||||
MODEL="$1"
|
MODEL="$1"
|
||||||
|
|
||||||
source scripts/_ch341a.sh
|
. scripts/_ch341a.sh
|
||||||
|
|
||||||
flashrom -p ch341a_spi -c "${CHIP}" -w "build/${MODEL}/firmware.rom"
|
flashrom -p ch341a_spi -c "${CHIP}" -w "build/${MODEL}/firmware.rom"
|
||||||
|
@ -33,8 +33,8 @@ do
|
|||||||
do
|
do
|
||||||
parts+=("$part")
|
parts+=("$part")
|
||||||
done
|
done
|
||||||
parts[1]="$(printf '0x%08x' "$((${parts[1]} & 0xfffffffd))")"
|
parts[1]="$(printf '0x%08x' "$((parts[1] & 0xfffffffd))")"
|
||||||
parts[2]="$(printf '0x%04x' "$((${parts[2]} & 0x00003c00))")"
|
parts[2]="$(printf '0x%04x' "$((parts[2] & 0x00003c00))")"
|
||||||
|
|
||||||
case "${parts[1]}" in
|
case "${parts[1]}" in
|
||||||
0x0???????)
|
0x0???????)
|
||||||
|
@ -14,7 +14,6 @@ then
|
|||||||
echo "model '${MODEL}' not found" >&2
|
echo "model '${MODEL}' not found" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
MODEL_DIR="$(realpath "models/${MODEL}")"
|
|
||||||
|
|
||||||
DMI_MODEL="$(cat /sys/class/dmi/id/product_version)"
|
DMI_MODEL="$(cat /sys/class/dmi/id/product_version)"
|
||||||
if [ "${DMI_MODEL}" != "${MODEL}" ]
|
if [ "${DMI_MODEL}" != "${MODEL}" ]
|
||||||
@ -29,7 +28,7 @@ export BASEDIR="system76-firmware-update"
|
|||||||
# Clean build directory
|
# Clean build directory
|
||||||
mkdir -p build
|
mkdir -p build
|
||||||
BUILD="$(realpath "build/${MODEL}")"
|
BUILD="$(realpath "build/${MODEL}")"
|
||||||
rm -rf "${BUILD}/${BASEDIR}"
|
rm -rf "${BUILD:?}/${BASEDIR}"
|
||||||
mkdir -p "${BUILD}/${BASEDIR}"
|
mkdir -p "${BUILD}/${BASEDIR}"
|
||||||
|
|
||||||
# Rebuild and copy firmware-update
|
# Rebuild and copy firmware-update
|
||||||
@ -50,7 +49,7 @@ fi
|
|||||||
|
|
||||||
# Locate EFI partition mount path
|
# Locate EFI partition mount path
|
||||||
EFI_PATH="$(bootctl --print-esp-path)"
|
EFI_PATH="$(bootctl --print-esp-path)"
|
||||||
if [ -z "${EFI_PATH}" -o ! -d "${EFI_PATH}" ]
|
if [ -z "${EFI_PATH}" ] || [ ! -d "${EFI_PATH}" ]
|
||||||
then
|
then
|
||||||
echo "EFI system partition '${EFI_PATH}' not found" >&2
|
echo "EFI system partition '${EFI_PATH}' not found" >&2
|
||||||
exit 1
|
exit 1
|
||||||
@ -63,7 +62,7 @@ then
|
|||||||
echo "EFI system partition name not found" >&2
|
echo "EFI system partition name not found" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
EFI_PART="$(cat /sys/class/block/${EFI_PART_NAME}/partition)"
|
EFI_PART="$(cat "/sys/class/block/${EFI_PART_NAME}/partition")"
|
||||||
|
|
||||||
# Locate EFI disk
|
# Locate EFI disk
|
||||||
EFI_DISK=""
|
EFI_DISK=""
|
||||||
|
@ -28,9 +28,9 @@ do
|
|||||||
count="$(echo "$line" | cut -d '[' -f2 | cut -d ']' -f1)"
|
count="$(echo "$line" | cut -d '[' -f2 | cut -d ']' -f1)"
|
||||||
for i in $(seq 0 "$count")
|
for i in $(seq 0 "$count")
|
||||||
do
|
do
|
||||||
if [[ "$i" != "$count" ]]
|
if [ "$i" != "$count" ]
|
||||||
then
|
then
|
||||||
echo "DISPLAY_UPD($var[$i]);"
|
echo "DISPLAY_UPD(${var[$i]});"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
|
@ -2,6 +2,8 @@
|
|||||||
#
|
#
|
||||||
# Copyright 2020 System76
|
# Copyright 2020 System76
|
||||||
|
|
||||||
|
# shellcheck disable=SC2024
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
SCRIPT_DIR=$(dirname "$0")
|
SCRIPT_DIR=$(dirname "$0")
|
||||||
@ -54,8 +56,8 @@ cargo build --release
|
|||||||
sudo target/release/coreboot-collector > "${MODEL_DIR}/coreboot-collector.txt"
|
sudo target/release/coreboot-collector > "${MODEL_DIR}/coreboot-collector.txt"
|
||||||
popd
|
popd
|
||||||
|
|
||||||
${SCRIPT_DIR}/coreboot-gpio.sh "${MODEL_DIR}/coreboot-collector.txt" > "${MODEL_DIR}/gpio.h"
|
"${SCRIPT_DIR}/coreboot-gpio.sh" "${MODEL_DIR}/coreboot-collector.txt" > "${MODEL_DIR}/gpio.h"
|
||||||
${SCRIPT_DIR}/coreboot-hda.sh "${MODEL_DIR}/coreboot-collector.txt" > "${MODEL_DIR}/hda_verb.c"
|
"${SCRIPT_DIR}/coreboot-hda.sh" "${MODEL_DIR}/coreboot-collector.txt" > "${MODEL_DIR}/hda_verb.c"
|
||||||
|
|
||||||
if [ -n "${BIOS_IMAGE}" ]
|
if [ -n "${BIOS_IMAGE}" ]
|
||||||
then
|
then
|
||||||
@ -108,4 +110,4 @@ then
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
${SCRIPT_DIR}/readmes.sh
|
"${SCRIPT_DIR}/readmes.sh"
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# SPDX-License-Identifier: GPL-3.0-only
|
# SPDX-License-Identifier: GPL-3.0-only
|
||||||
|
|
||||||
|
# shellcheck disable=SC1091
|
||||||
|
|
||||||
set -eE
|
set -eE
|
||||||
|
|
||||||
function msg {
|
msg() {
|
||||||
echo -e "\x1B[1m$*\x1B[0m" >&2
|
echo -e "\x1B[1m$*\x1B[0m" >&2
|
||||||
}
|
}
|
||||||
|
|
||||||
trap 'msg "\x1B[31mFailed to install dependencies!"' ERR
|
trap 'msg "\x1B[31mFailed to install dependencies!"' ERR
|
||||||
|
|
||||||
source /etc/os-release
|
. /etc/os-release
|
||||||
|
|
||||||
msg "Installing system build dependencies"
|
msg "Installing system build dependencies"
|
||||||
if [[ "${ID}" =~ "debian" ]] || [[ "${ID_LIKE}" =~ "debian" ]]; then
|
if [[ "${ID}" =~ "debian" ]] || [[ "${ID_LIKE}" =~ "debian" ]]; then
|
||||||
|
@ -2,21 +2,8 @@
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# if [ -z "$1" ]
|
|
||||||
# then
|
|
||||||
# echo "$0 [model]" >&2
|
|
||||||
# exit 1
|
|
||||||
# fi
|
|
||||||
# MODEL="$1"
|
|
||||||
MODEL="qemu"
|
MODEL="qemu"
|
||||||
|
|
||||||
if [ ! -d "models/${MODEL}" ]
|
|
||||||
then
|
|
||||||
echo "model '${MODEL}' not found" >&2
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
MODEL_DIR="$(realpath "models/${MODEL}")"
|
|
||||||
|
|
||||||
qemu-system-x86_64 \
|
qemu-system-x86_64 \
|
||||||
-enable-kvm \
|
-enable-kvm \
|
||||||
-M q35 \
|
-M q35 \
|
||||||
|
@ -12,7 +12,7 @@ cargo build --manifest-path "scripts/modeltool/Cargo.toml" --release
|
|||||||
|
|
||||||
MODELTOOL="$(realpath "scripts/modeltool/target/release/modeltool")"
|
MODELTOOL="$(realpath "scripts/modeltool/target/release/modeltool")"
|
||||||
|
|
||||||
function readme_model {
|
readme_model() {
|
||||||
echo -e "\x1B[1m$1\x1B[0m" >&2
|
echo -e "\x1B[1m$1\x1B[0m" >&2
|
||||||
|
|
||||||
pushd "$1" > /dev/null
|
pushd "$1" > /dev/null
|
||||||
@ -28,7 +28,7 @@ do
|
|||||||
readme_model "${dir%/}"
|
readme_model "${dir%/}"
|
||||||
done
|
done
|
||||||
|
|
||||||
function readme_line {
|
readme_line() {
|
||||||
echo -e " \x1B[1m$1\x1B[0m" >&2
|
echo -e " \x1B[1m$1\x1B[0m" >&2
|
||||||
|
|
||||||
name="$(basename "$1")"
|
name="$(basename "$1")"
|
||||||
@ -42,7 +42,7 @@ function readme_line {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
submodule="$(git submodule status "$1" 2> /dev/null | cut -d ' ' -f 3 || true)"
|
submodule="$(git submodule status "$1" 2> /dev/null | cut -d ' ' -f 3 || true)"
|
||||||
if [ "$submodule" == "$1" ]
|
if [ "$submodule" = "$1" ]
|
||||||
then
|
then
|
||||||
# Link to submodule URL
|
# Link to submodule URL
|
||||||
origin="$(git -C "$1" remote get-url origin)"
|
origin="$(git -C "$1" remote get-url origin)"
|
||||||
@ -53,7 +53,7 @@ function readme_line {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function readme_dir {
|
readme_dir() {
|
||||||
echo -e "\x1B[1m$1\x1B[0m" >&2
|
echo -e "\x1B[1m$1\x1B[0m" >&2
|
||||||
|
|
||||||
pushd "$1" > /dev/null
|
pushd "$1" > /dev/null
|
||||||
|
@ -13,7 +13,7 @@ do
|
|||||||
codec_sys="/sys/class/sound/${codec_id}"
|
codec_sys="/sys/class/sound/${codec_id}"
|
||||||
vendor="$(cat "${codec_sys}/vendor_name")"
|
vendor="$(cat "${codec_sys}/vendor_name")"
|
||||||
chip="$(cat "${codec_sys}/chip_name")"
|
chip="$(cat "${codec_sys}/chip_name")"
|
||||||
if [ "${vendor}" == "Realtek" ]
|
if [ "${vendor}" = "Realtek" ]
|
||||||
then
|
then
|
||||||
echo "# ${codec_id}: ${vendor} ${chip}"
|
echo "# ${codec_id}: ${vendor} ${chip}"
|
||||||
|
|
||||||
@ -27,7 +27,7 @@ do
|
|||||||
do
|
do
|
||||||
# Set coefficient index
|
# Set coefficient index
|
||||||
index_hex="$(printf "0x%02x\n" "${index}")"
|
index_hex="$(printf "0x%02x\n" "${index}")"
|
||||||
hda-verb "${codec}" "${nid}" SET_COEF_INDEX "${index_hex}" &>/dev/null
|
hda-verb "${codec}" "${nid}" SET_COEF_INDEX "${index_hex}" >/dev/null 2>&1
|
||||||
|
|
||||||
# Get processing coefficient
|
# Get processing coefficient
|
||||||
value="$(hda-verb "${codec}" "${nid}" GET_PROC_COEF 0 2>/dev/null | cut -d " " -f 3)"
|
value="$(hda-verb "${codec}" "${nid}" GET_PROC_COEF 0 2>/dev/null | cut -d " " -f 3)"
|
||||||
|
@ -8,7 +8,7 @@ REMOTES=(
|
|||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
function git_remote {
|
git_remote() {
|
||||||
echo -e "\x1B[1m$1\x1B[0m"
|
echo -e "\x1B[1m$1\x1B[0m"
|
||||||
pushd "$1" > /dev/null
|
pushd "$1" > /dev/null
|
||||||
if git remote | grep "^$2\$"
|
if git remote | grep "^$2\$"
|
||||||
@ -23,5 +23,5 @@ function git_remote {
|
|||||||
|
|
||||||
for remote in "${REMOTES[@]}"
|
for remote in "${REMOTES[@]}"
|
||||||
do
|
do
|
||||||
git_remote $remote
|
git_remote "$remote"
|
||||||
done
|
done
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# shellcheck disable=SC2087
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -z "$1" ]
|
if [ -z "$1" ]
|
||||||
@ -9,7 +11,7 @@ then
|
|||||||
fi
|
fi
|
||||||
MODEL="$1"
|
MODEL="$1"
|
||||||
|
|
||||||
source scripts/_spipi.sh
|
. scripts/_spipi.sh
|
||||||
|
|
||||||
ssh -T "${SPIPI}" <<EOF
|
ssh -T "${SPIPI}" <<EOF
|
||||||
cd firmware
|
cd firmware
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# shellcheck disable=SC2087
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -z "$1" ]
|
if [ -z "$1" ]
|
||||||
@ -9,7 +11,7 @@ then
|
|||||||
fi
|
fi
|
||||||
MODEL="$1"
|
MODEL="$1"
|
||||||
|
|
||||||
source scripts/_spipi.sh
|
. scripts/_spipi.sh
|
||||||
|
|
||||||
ssh -T "${SPIPI}" <<EOF
|
ssh -T "${SPIPI}" <<EOF
|
||||||
cd firmware
|
cd firmware
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
# shellcheck disable=SC2087
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ -z "$1" ]
|
if [ -z "$1" ]
|
||||||
@ -9,7 +11,7 @@ then
|
|||||||
fi
|
fi
|
||||||
MODEL="$1"
|
MODEL="$1"
|
||||||
|
|
||||||
source scripts/_spipi.sh
|
. scripts/_spipi.sh
|
||||||
|
|
||||||
sftp "${SPIPI}" <<EOF
|
sftp "${SPIPI}" <<EOF
|
||||||
cd firmware
|
cd firmware
|
||||||
|
@ -1 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=24000 "$@"
|
sudo flashrom -p linux_spi:dev=/dev/spidev0.0,spispeed=24000 "$@"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user