summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@lukeshu.com>2018-08-16 01:32:59 -0400
committerLuke Shumaker <lukeshu@lukeshu.com>2018-08-16 01:36:18 -0400
commit540db8eef89299b5827bca8a5140ae0c3151181c (patch)
tree88153cb6ab790579cdd2f31273a348bf7b4c5ec7
parent93ba79d3eacfd1ba225d309a226540619f370b05 (diff)
run osi stuff through shellcheck
Disable SC2064 because we use @Q rather than deferred expansion. The only real issue found is adding `-r` to `read` in osi-shell.
-rw-r--r--Makefile2
-rwxr-xr-xosi-extract2
-rwxr-xr-xosi-mk11
-rw-r--r--osi-mk.d/builddeps.sh2
-rw-r--r--osi-mk.d/libretools.sh2
-rw-r--r--osi-mk.d/systemd-autologin-ttyS0.sh2
-rw-r--r--osi-mk.d/systemd-dhcpcd.sh2
-rw-r--r--osi-mk.d/systemd-lukeshu-debug.sh2
-rw-r--r--osi-mk.d/systemd-osi-shell.sh2
-rw-r--r--osi-mk.d/testuser.sh2
-rwxr-xr-xosi-mount4
-rwxr-xr-xosi-shell4
12 files changed, 21 insertions, 16 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..aa3a08d
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,2 @@
+lint:
+ git ls-files '*osi*'|xargs shellcheck --exclude=SC2064 --
diff --git a/osi-extract b/osi-extract
index f09f97d..da7f809 100755
--- a/osi-extract
+++ b/osi-extract
@@ -2,7 +2,7 @@
# 2018 Luke Shumaker
{
set -euE
- source "${BASH_SOURCE[0]%/*}/lib/osi.sh"
+ source ./lib/osi.sh
arg_image=$1
arg_src=$(realpath -ms -- "$2")
diff --git a/osi-mk b/osi-mk
index 1d136b2..662b331 100755
--- a/osi-mk
+++ b/osi-mk
@@ -20,7 +20,7 @@ declare -r VERSION=20180812
# [1]: https://github.com/systemd/mkosi
set -euE -o pipefail
-source "${BASH_SOURCE[0]%/*}/lib/osi.sh"
+source ./lib/osi.sh
loaded_modules=()
load_module() {
@@ -33,6 +33,7 @@ load_module() {
return 0
fi
loaded_modules+=("$module")
+ # shellcheck disable=SC1090
source "$1"
}
@@ -50,7 +51,7 @@ osi-mk:directories() {
# TODO: maybe rsync would be better?
if [[ -d "${arg_mountpoint}/${inside}" ]]; then
print 'Removing existing %q:%q' "$arg_file" "$inside"
- rm -rf -- "${arg_mountpoint}/${inside}"
+ rm -rf -- "${arg_mountpoint:?}/${inside}"
fi
mkdir -p -- "$(dirname -- "${arg_mountpoint}/${inside}")"
print 'Copying %q to %q:%q' "$outside" "$arg_file" "$inside"
@@ -64,6 +65,7 @@ osi-mk:grub-install() {
GRUB_TIMEOUT=0
GRUB_DEFAULT=1 # Use the fallback initramfs, to get all drivers
EOT
+ # shellcheck disable=SC2016
arch-chroot -- "$arg_mountpoint" sh -c \
'grub-install "$(awk '\''$2 == "/" { print $1 }'\'' </proc/mounts)"'
}
@@ -175,6 +177,7 @@ main() {
outside)
if $arg_edit; then
if [[ -n $arg_edit_base ]]; then
+ # shellcheck disable=SC2059
printf -v prefix "$(gettext -- '%s [format]')" "$NAME"
{
cp -T -- "$arg_edit_base" "$arg_file"
@@ -206,6 +209,7 @@ main() {
trap - EXIT
fi
else
+ # shellcheck disable=SC2059
printf -v prefix "$(gettext -- '%s [format]')" "$NAME"
{
truncate --size="$arg_size" -- "$arg_file"
@@ -213,7 +217,6 @@ main() {
} |& sed "s|^|${prefix} |"
fi
arg_mountpoint=$(mktemp -dt -- "${0##*/}.XXXXXXXXXX")
- # shellcheck disable=SC2064
trap "rmdir -- ${arg_mountpoint@Q}" EXIT
sudo -- ./osi-mount --root -- "$arg_file" "$arg_mountpoint" "${BASH_SOURCE[0]}" --inside="$arg_mountpoint" "${arg_orig[@]}"
;;
@@ -240,6 +243,7 @@ main() {
cache_packages+=("${packages[@]}")
#### install ###
+ # shellcheck disable=SC2059
printf -v prefix "$(gettext -- '%s [install]')" "$NAME"
{
# Pre-fill the package cache
@@ -265,6 +269,7 @@ main() {
### post_install ###
while IFS=: read -r n fn; do
+ # shellcheck disable=SC2059
printf -v prefix "$(gettext -- '%s [post_install:%s:%s]')" "$NAME" "$n" "$fn"
{
print Begin
diff --git a/osi-mk.d/builddeps.sh b/osi-mk.d/builddeps.sh
index d4ffee2..74f2bf4 100644
--- a/osi-mk.d/builddeps.sh
+++ b/osi-mk.d/builddeps.sh
@@ -1,4 +1,4 @@
-#!/hint/bash
+#!/hint/bash -euE
packages+=(
git
diff --git a/osi-mk.d/libretools.sh b/osi-mk.d/libretools.sh
index dd49c13..6bb916f 100644
--- a/osi-mk.d/libretools.sh
+++ b/osi-mk.d/libretools.sh
@@ -1,4 +1,4 @@
-#!/hint/bash
+#!/hint/bash -euE
load_module "$(dirname -- "${BASH_SOURCE[0]}")/testuser.sh"
diff --git a/osi-mk.d/systemd-autologin-ttyS0.sh b/osi-mk.d/systemd-autologin-ttyS0.sh
index b73d9ff..623b3e2 100644
--- a/osi-mk.d/systemd-autologin-ttyS0.sh
+++ b/osi-mk.d/systemd-autologin-ttyS0.sh
@@ -1,4 +1,4 @@
-#!/hint/bash
+#!/hint/bash -euE
post_install+=(10:autologin-ttyS0:post_install)
autologin-ttyS0:post_install() {
diff --git a/osi-mk.d/systemd-dhcpcd.sh b/osi-mk.d/systemd-dhcpcd.sh
index 9913d9e..add8352 100644
--- a/osi-mk.d/systemd-dhcpcd.sh
+++ b/osi-mk.d/systemd-dhcpcd.sh
@@ -1,4 +1,4 @@
-#!/hint/bash
+#!/hint/bash -euE
# Also enable haveged. Without it, TLS will be unavailable for a
# while even after network-online.target because getrandom(2) will
diff --git a/osi-mk.d/systemd-lukeshu-debug.sh b/osi-mk.d/systemd-lukeshu-debug.sh
index a6a6895..b9d9702 100644
--- a/osi-mk.d/systemd-lukeshu-debug.sh
+++ b/osi-mk.d/systemd-lukeshu-debug.sh
@@ -1,4 +1,4 @@
-#!/hint/bash
+#!/hint/bash -euE
packages+=(
socat
diff --git a/osi-mk.d/systemd-osi-shell.sh b/osi-mk.d/systemd-osi-shell.sh
index 18ba167..86f6b2e 100644
--- a/osi-mk.d/systemd-osi-shell.sh
+++ b/osi-mk.d/systemd-osi-shell.sh
@@ -1,4 +1,4 @@
-#!/hint/bash
+#!/hint/bash -euE
post_install+=(10:systemd-osi-shell:post_install)
systemd-osi-shell:post_install() {
diff --git a/osi-mk.d/testuser.sh b/osi-mk.d/testuser.sh
index bd1f08a..92aa8e4 100644
--- a/osi-mk.d/testuser.sh
+++ b/osi-mk.d/testuser.sh
@@ -1,4 +1,4 @@
-#!/hint/bash
+#!/hint/bash -euE
post_install+=(01:testuser:early)
testuser:early() {
diff --git a/osi-mount b/osi-mount
index ded5a65..9b539ee 100755
--- a/osi-mount
+++ b/osi-mount
@@ -4,7 +4,7 @@ declare -r NAME=osi-mount
declare -r VERSION=20180812
set -euE
-source "${BASH_SOURCE[0]%/*}/lib/osi.sh"
+source ./lib/osi.sh
main() {
needs_root
@@ -96,11 +96,9 @@ main() {
case "$arg_user" in
user)
mount_opt=ro
- losetup_flags=(--read-only)
;;
root)
mount_opt=rw
- losetup_flags=()
# TODO: make the rest of the system RO
;;
esac
diff --git a/osi-shell b/osi-shell
index 1230f19..0b2df27 100755
--- a/osi-shell
+++ b/osi-shell
@@ -4,7 +4,7 @@ declare -r NAME=osi-run
declare -r VERSION=20180814
set -euE
-source "${BASH_SOURCE[0]%/*}/lib/osi.sh"
+source ./lib/osi.sh
main() {
local arg_mode=main
@@ -65,7 +65,7 @@ main() {
-serial stdio \
-serial file:"$tmp/exit" \
< <(cat <"$tmp/sync" >/dev/null; cat; while sleep 0.1; do printf '\x04'; done) \
- > >(read -N1 c; printf '%s' "$c"; :>"$tmp/sync"; exec cat)
+ > >(read -r -N1 c; printf '%s' "$c"; :>"$tmp/sync"; exec cat)
return "$(sed 's/\r$//' <"$tmp/exit")"
;;