mirror of
https://github.com/systemd/systemd.git
synced 2025-01-03 05:18:09 +03:00
tools: shellcheck-ify most of the tool scripts
This commit is contained in:
parent
437e889b18
commit
3b6fd3c1de
@ -2,9 +2,9 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
cd "$MESON_SOURCE_ROOT"
|
cd "${MESON_SOURCE_ROOT:?}"
|
||||||
|
|
||||||
if [ ! -f .git/hooks/pre-commit.sample -o -f .git/hooks/pre-commit ]; then
|
if [ ! -f .git/hooks/pre-commit.sample ] || [ -f .git/hooks/pre-commit ]; then
|
||||||
exit 2 # not needed
|
exit 2 # not needed
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -1,31 +1,32 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
set -eu
|
set -eu
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
sd_good=0
|
sd_good=0
|
||||||
sd_total=0
|
sd_total=0
|
||||||
udev_good=0
|
udev_good=0
|
||||||
udev_total=0
|
udev_total=0
|
||||||
|
|
||||||
deprecated="
|
deprecated=(
|
||||||
-e sd_bus_try_close
|
-e sd_bus_try_close
|
||||||
-e sd_bus_process_priority
|
-e sd_bus_process_priority
|
||||||
-e sd_bus_message_get_priority
|
-e sd_bus_message_get_priority
|
||||||
-e sd_bus_message_set_priority
|
-e sd_bus_message_set_priority
|
||||||
-e sd_seat_can_multi_session
|
-e sd_seat_can_multi_session
|
||||||
-e sd_journal_open_container
|
-e sd_journal_open_container
|
||||||
"
|
)
|
||||||
|
|
||||||
for symbol in `nm -g --defined-only "$@" | grep " T " | cut -d" " -f3 | grep -wv $deprecated | sort -u` ; do
|
for symbol in $(nm -g --defined-only "$@" | grep " T " | cut -d" " -f3 | grep -wv "${deprecated[@]}" | sort -u); do
|
||||||
if test -f ${MESON_BUILD_ROOT}/man/$symbol.3 ; then
|
if test -f "${MESON_BUILD_ROOT:?}/man/$symbol.3"; then
|
||||||
echo "✓ Symbol $symbol() is documented."
|
echo "✓ Symbol $symbol() is documented."
|
||||||
good=1
|
good=1
|
||||||
else
|
else
|
||||||
printf " \x1b[1;31mSymbol $symbol() lacks documentation.\x1b[0m\n"
|
echo -e " \x1b[1;31mSymbol $symbol() lacks documentation.\x1b[0m"
|
||||||
good=0
|
good=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
case $symbol in
|
case "$symbol" in
|
||||||
sd_*)
|
sd_*)
|
||||||
((sd_good+=good))
|
((sd_good+=good))
|
||||||
((sd_total+=1))
|
((sd_total+=1))
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
set -eu
|
set -eu
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
SOURCE_ROOT="${1:?Missing argument: project source root}"
|
SOURCE_ROOT="${1:?Missing argument: project source root}"
|
||||||
BUILD_ROOT="${2:?Missing argument: project build root}"
|
BUILD_ROOT="${2:?Missing argument: project build root}"
|
||||||
|
@ -1,30 +1,41 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
set -eu
|
set -eu
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
# Note: `grep ... >/dev/null` instead of just `grep -q` is used intentionally
|
||||||
|
# here, since `grep -q` exits on the first match causing SIGPIPE being
|
||||||
|
# sent to the sender.
|
||||||
|
|
||||||
|
BINARY="${1:?}"
|
||||||
export SYSTEMD_LOG_LEVEL=info
|
export SYSTEMD_LOG_LEVEL=info
|
||||||
|
|
||||||
|
if [[ ! -x "$BINARY" ]]; then
|
||||||
|
echo "$BINARY is not an executable"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
# output width
|
# output width
|
||||||
if "$1" --help | grep -v 'default:' | grep -E -q '.{80}.'; then
|
if "$BINARY" --help | grep -v 'default:' | grep -E '.{80}.' >/dev/null; then
|
||||||
echo "$(basename "$1") --help output is too wide:"
|
echo "$(basename "$BINARY") --help output is too wide:"
|
||||||
"$1" --help | awk 'length > 80' | grep -E --color=yes '.{80}'
|
"$BINARY" --help | awk 'length > 80' | grep -E --color=yes '.{80}'
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# --help prints something. Also catches case where args are ignored.
|
# --help prints something. Also catches case where args are ignored.
|
||||||
if ! "$1" --help | grep -q .; then
|
if ! "$BINARY" --help | grep . >/dev/null; then
|
||||||
echo "$(basename "$1") --help output is empty."
|
echo "$(basename "$BINARY") --help output is empty."
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# no --help output to stdout
|
# no --help output to stdout
|
||||||
if "$1" --help 2>&1 1>/dev/null | grep .; then
|
if "$BINARY" --help 2>&1 1>/dev/null | grep .; then
|
||||||
echo "$(basename "$1") --help prints to stderr"
|
echo "$(basename "$BINARY") --help prints to stderr"
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# error output to stderr
|
# error output to stderr
|
||||||
if ! "$1" --no-such-parameter 2>&1 1>/dev/null | grep -q .; then
|
if ! ("$BINARY" --no-such-parameter 2>&1 1>/dev/null || :) | grep . >/dev/null; then
|
||||||
echo "$(basename "$1") with an unknown parameter does not print to stderr"
|
echo "$(basename "$BINARY") with an unknown parameter does not print to stderr"
|
||||||
exit 4
|
exit 4
|
||||||
fi
|
fi
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
set -e
|
set -eu
|
||||||
|
|
||||||
# Try to guess the build directory:
|
# Try to guess the build directory:
|
||||||
# we look for subdirectories of the parent directory that look like ninja build dirs.
|
# we look for subdirectories of the parent directory that look like ninja build dirs.
|
||||||
|
|
||||||
if [ -n "$BUILD_DIR" ]; then
|
if [ -n "${BUILD_DIR:=}" ]; then
|
||||||
echo "$(realpath "$BUILD_DIR")"
|
realpath "$BUILD_DIR"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -14,20 +14,20 @@ root="$(dirname "$(realpath "$0")")"
|
|||||||
|
|
||||||
found=
|
found=
|
||||||
for i in "$root"/../*/build.ninja; do
|
for i in "$root"/../*/build.ninja; do
|
||||||
c="$(dirname $i)"
|
c="$(dirname "$i")"
|
||||||
[ -d "$c" ] || continue
|
[ -d "$c" ] || continue
|
||||||
[ "$(basename "$c")" != mkosi.builddir ] || continue
|
[ "$(basename "$c")" != mkosi.builddir ] || continue
|
||||||
|
|
||||||
if [ -n "$found" ]; then
|
if [ -n "$found" ]; then
|
||||||
echo 'Found multiple candidates, specify build directory with $BUILD_DIR' >&2
|
echo "Found multiple candidates, specify build directory with \$BUILD_DIR" >&2
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
found="$c"
|
found="$c"
|
||||||
done
|
done
|
||||||
|
|
||||||
if [ -z "$found" ]; then
|
if [ -z "$found" ]; then
|
||||||
echo 'Specify build directory with $BUILD_DIR' >&2
|
echo "Specify build directory with \$BUILD_DIR" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "$(realpath $found)"
|
realpath "$found"
|
||||||
|
@ -1,38 +1,40 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
TOP=`git rev-parse --show-toplevel`
|
set -eu
|
||||||
|
|
||||||
case "$1" in
|
TOP="$(git rev-parse --show-toplevel)"
|
||||||
|
|
||||||
|
case "${1:-}" in
|
||||||
recdiff)
|
recdiff)
|
||||||
if [ "$2" = "" ] ; then
|
if [ "${2:-}" = "" ] ; then
|
||||||
DIR="$TOP"
|
DIR="$TOP"
|
||||||
else
|
else
|
||||||
DIR="$2"
|
DIR="$2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 diff \{\} \;
|
find "$DIR" -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec "$0" diff \{\} \;
|
||||||
;;
|
;;
|
||||||
|
|
||||||
recpatch)
|
recpatch)
|
||||||
if [ "$2" = "" ] ; then
|
if [ "${2:-}" = "" ] ; then
|
||||||
DIR="$TOP"
|
DIR="$TOP"
|
||||||
else
|
else
|
||||||
DIR="$2"
|
DIR="$2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 patch \{\} \;
|
find "$DIR" -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec "$0" patch \{\} \;
|
||||||
;;
|
;;
|
||||||
|
|
||||||
diff)
|
diff)
|
||||||
T=`mktemp`
|
T="$(mktemp)"
|
||||||
sed '/^$/N;/^\n$/D' < "$2" > "$T"
|
sed '/^$/N;/^\n$/D' <"${2:?}" >"$T"
|
||||||
diff -u "$2" "$T"
|
diff -u "$2" "$T"
|
||||||
rm -f "$T"
|
rm -f "$T"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
patch)
|
patch)
|
||||||
sed -i '/^$/N;/^\n$/D' "$2"
|
sed -i '/^$/N;/^\n$/D' "${2:?}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
|
@ -1,38 +1,40 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
|
|
||||||
TOP=`git rev-parse --show-toplevel`
|
set -eu
|
||||||
|
|
||||||
case "$1" in
|
TOP="$(git rev-parse --show-toplevel)"
|
||||||
|
|
||||||
|
case "${1:-}" in
|
||||||
recdiff)
|
recdiff)
|
||||||
if [ "$2" = "" ] ; then
|
if [ "${2:-}" = "" ] ; then
|
||||||
DIR="$TOP"
|
DIR="$TOP"
|
||||||
else
|
else
|
||||||
DIR="$2"
|
DIR="$2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 diff \{\} \;
|
find "$DIR" -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec "$0" diff \{\} \;
|
||||||
;;
|
;;
|
||||||
|
|
||||||
recpatch)
|
recpatch)
|
||||||
if [ "$2" = "" ] ; then
|
if [ "${2:-}" = "" ] ; then
|
||||||
DIR="$TOP"
|
DIR="$TOP"
|
||||||
else
|
else
|
||||||
DIR="$2"
|
DIR="$2"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
find $DIR -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec $0 patch \{\} \;
|
find "$DIR" -type f \( -name '*.[ch]' -o -name '*.xml' \) -exec "$0" patch \{\} \;
|
||||||
;;
|
;;
|
||||||
|
|
||||||
diff)
|
diff)
|
||||||
T=`mktemp`
|
T="$(mktemp)"
|
||||||
sed 's/\t/ /g' < "$2" > "$T"
|
sed 's/\t/ /g' <"${2:?}" >"$T"
|
||||||
diff -u "$2" "$T"
|
diff -u "$2" "$T"
|
||||||
rm -f "$T"
|
rm -f "$T"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
patch)
|
patch)
|
||||||
sed -i 's/\t/ /g' "$2"
|
sed -i 's/\t/ /g' "${2:?}"
|
||||||
;;
|
;;
|
||||||
|
|
||||||
*)
|
*)
|
||||||
|
@ -1,25 +1,21 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
CONFIG=$1
|
CONFIG="${1:?Missing path to config.h}"
|
||||||
TARGET=$2
|
TARGET="${2:?Missing target m4 file}"
|
||||||
|
|
||||||
if [ $# -ne 2 ]; then
|
if [ ! -f "$CONFIG" ]; then
|
||||||
echo 'Invalid number of arguments.'
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ ! -f $CONFIG ]; then
|
|
||||||
echo "$CONFIG not found."
|
echo "$CONFIG not found."
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ ! -f $TARGET ]; then
|
if [ ! -f "$TARGET" ]; then
|
||||||
echo "$TARGET not found."
|
echo "$TARGET not found."
|
||||||
exit 3
|
exit 3
|
||||||
fi
|
fi
|
||||||
|
|
||||||
DEFINES=$(awk '$1 == "#define" && $3 == "1" { printf "-D%s ", $2 }' $CONFIG)
|
DEFINES=()
|
||||||
|
mapfile -t DEFINES < <(awk '$1 == "#define" && $3 == "1" { printf "-D%s\n", $2 }' "$CONFIG")
|
||||||
|
|
||||||
m4 -P $DEFINES $TARGET
|
m4 -P "${DEFINES[@]}" "$TARGET"
|
||||||
|
@ -2,6 +2,9 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
|
SOURCE="${1:?}"
|
||||||
|
TARGET="${2:?}"
|
||||||
|
|
||||||
if [ "${MESON_INSTALL_QUIET:-0}" = 1 ] ; then
|
if [ "${MESON_INSTALL_QUIET:-0}" = 1 ] ; then
|
||||||
VERBOSE=""
|
VERBOSE=""
|
||||||
else
|
else
|
||||||
@ -11,9 +14,9 @@ fi
|
|||||||
# this is needed mostly because $DESTDIR is provided as a variable,
|
# this is needed mostly because $DESTDIR is provided as a variable,
|
||||||
# and we need to create the target directory...
|
# and we need to create the target directory...
|
||||||
|
|
||||||
mkdir -${VERBOSE}p "$(dirname "${DESTDIR:-}$2")"
|
mkdir -${VERBOSE}p "$(dirname "${DESTDIR:-}$TARGET")"
|
||||||
if [ "$(dirname $1)" = . -o "$(dirname $1)" = .. ]; then
|
if [ "$(dirname "$SOURCE")" = . ] || [ "$(dirname "$SOURCE")" = .. ]; then
|
||||||
ln -${VERBOSE}fs -T -- "$1" "${DESTDIR:-}$2"
|
ln -${VERBOSE}fs -T -- "$SOURCE" "${DESTDIR:-}$TARGET"
|
||||||
else
|
else
|
||||||
ln -${VERBOSE}fs -T --relative -- "${DESTDIR:-}$1" "${DESTDIR:-}$2"
|
ln -${VERBOSE}fs -T --relative -- "${DESTDIR:-}$SOURCE" "${DESTDIR:-}$TARGET"
|
||||||
fi
|
fi
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
set -eu
|
set -eu
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
dir="$1"
|
dir="${1:?}"
|
||||||
fallback="$2"
|
fallback="${2:?}"
|
||||||
|
|
||||||
# Apparently git describe has a bug where it always considers the work-tree
|
# Apparently git describe has a bug where it always considers the work-tree
|
||||||
# dirty when invoked with --git-dir (even though 'git status' is happy). Work
|
# dirty when invoked with --git-dir (even though 'git status' is happy). Work
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
cd "$1"
|
cd "${1:?}"
|
||||||
|
|
||||||
(curl --fail -L 'https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/udev/gen_autosuspend_rules.py?format=TEXT'; echo) \
|
(curl --fail -L 'https://chromium.googlesource.com/chromiumos/platform2/+/master/power_manager/udev/gen_autosuspend_rules.py?format=TEXT'; echo) \
|
||||||
| base64 -d > tools/chromiumos/gen_autosuspend_rules.py
|
| base64 -d > tools/chromiumos/gen_autosuspend_rules.py
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
cd "$1"
|
cd "${1:?}"
|
||||||
|
|
||||||
unset permissive
|
unset permissive
|
||||||
if [ "${2:-}" = "-p" ]; then
|
if [ "${2:-}" = "-p" ]; then
|
||||||
@ -28,6 +28,6 @@ if [ "${2:-}" != "-n" ]; then (
|
|||||||
set -x
|
set -x
|
||||||
./acpi-update.py >20-acpi-vendor.hwdb.base
|
./acpi-update.py >20-acpi-vendor.hwdb.base
|
||||||
patch -p0 -o- 20-acpi-vendor.hwdb.base <20-acpi-vendor.hwdb.patch >20-acpi-vendor.hwdb
|
patch -p0 -o- 20-acpi-vendor.hwdb.base <20-acpi-vendor.hwdb.patch >20-acpi-vendor.hwdb
|
||||||
! diff -u 20-acpi-vendor.hwdb.base 20-acpi-vendor.hwdb >20-acpi-vendor.hwdb.patch
|
diff -u 20-acpi-vendor.hwdb.base 20-acpi-vendor.hwdb >20-acpi-vendor.hwdb.patch && exit 1
|
||||||
|
|
||||||
./ids_parser.py
|
./ids_parser.py
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||||
set -eu
|
set -eu
|
||||||
|
|
||||||
cd "$1" && shift
|
cd "${1:?}" && shift
|
||||||
|
|
||||||
curl --fail -L -o syscall-list.txt 'https://raw.githubusercontent.com/hrw/syscalls-table/master/syscall-names.text'
|
curl --fail -L -o syscall-list.txt 'https://raw.githubusercontent.com/hrw/syscalls-table/master/syscall-names.text'
|
||||||
|
|
||||||
for arch in "$@"; do
|
for arch in "$@"; do
|
||||||
curl --fail -L -o syscalls-$arch.txt "https://raw.githubusercontent.com/hrw/syscalls-table/master/tables/syscalls-$arch"
|
curl --fail -L -o "syscalls-$arch.txt" "https://raw.githubusercontent.com/hrw/syscalls-table/master/tables/syscalls-$arch"
|
||||||
done
|
done
|
||||||
|
Loading…
Reference in New Issue
Block a user