1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-10-26 08:55:18 +03:00

tools: shellcheck-ify tool scripts

This commit is contained in:
Frantisek Sumsal 2021-09-29 21:28:55 +02:00
parent 1c3f490f23
commit f7e0d22d76
5 changed files with 50 additions and 43 deletions

25
configure vendored
View File

@ -2,22 +2,23 @@
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
set -e set -e
cflags=CFLAGS="$CFLAGS" cflags="CFLAGS=${CFLAGS-}"
cxxflags=CXXFLAGS="$CXXFLAGS" cxxflags="CXXFLAGS=${CXXFLAGS-}"
declare -a args args=()
j=0
for i in "$@"; do for arg in "$@"; do
case "$i" in case "$arg" in
CFLAGS=*) CFLAGS=*)
cflags="$i";; cflags="$arg"
;;
CXXFLAGS=*) CXXFLAGS=*)
cxxflags="$i";; cxxflags="$arg"
*) ;;
args[$j]="$i" *)
j=$((j+1)) args+=("$arg")
esac esac
done done
export "$cflags" "$cxxflags" export "${cflags?}" "${cxxflags?}"
set -x set -x
exec meson build "${args[@]}" exec meson build "${args[@]}"

View File

@ -3,33 +3,37 @@
# Download and extract coverity tool # Download and extract coverity tool
set -e
set -o pipefail
# Environment check # Environment check
[ -z "$COVERITY_SCAN_TOKEN" ] && echo 'ERROR: COVERITY_SCAN_TOKEN must be set' && exit 1 if [ -z "$COVERITY_SCAN_TOKEN" ]; then
echo >&2 'ERROR: COVERITY_SCAN_TOKEN must be set'
exit 1
fi
# Use default values if not set # Use default values if not set
PLATFORM=$(uname) PLATFORM="$(uname)"
TOOL_BASE="${TOOL_BASE:-/tmp/coverity-scan-analysis}"
TOOL_BASE=${TOOL_BASE:="/tmp/coverity-scan-analysis"} TOOL_ARCHIVE="${TOOL_ARCHIVE:-/tmp/cov-analysis-${PLATFORM}.tgz}"
TOOL_ARCHIVE=${TOOL_ARCHIVE:="/tmp/cov-analysis-${PLATFORM}.tgz"}
TOOL_URL="https://scan.coverity.com/download/${PLATFORM}" TOOL_URL="https://scan.coverity.com/download/${PLATFORM}"
# Make sure wget is installed # Make sure wget is installed
sudo apt-get update && sudo apt-get -y install wget sudo apt-get update && sudo apt-get -y install wget
# Get coverity tool # Get coverity tool
if [ ! -d $TOOL_BASE ]; then if [ ! -d "$TOOL_BASE" ]; then
# Download Coverity Scan Analysis Tool # Download Coverity Scan Analysis Tool
if [ ! -e $TOOL_ARCHIVE ]; then if [ ! -e "$TOOL_ARCHIVE" ]; then
echo -e "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m" echo -e "\033[33;1mDownloading Coverity Scan Analysis Tool...\033[0m"
wget -nv -O $TOOL_ARCHIVE $TOOL_URL --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN" wget -nv -O "$TOOL_ARCHIVE" "$TOOL_URL" --post-data "project=$COVERITY_SCAN_PROJECT_NAME&token=$COVERITY_SCAN_TOKEN"
fi fi
# Extract Coverity Scan Analysis Tool # Extract Coverity Scan Analysis Tool
echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m" echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m"
mkdir -p $TOOL_BASE mkdir -p "$TOOL_BASE"
pushd $TOOL_BASE pushd "$TOOL_BASE"
tar xzf $TOOL_ARCHIVE tar xzf "$TOOL_ARCHIVE"
popd popd
fi fi

View File

@ -9,13 +9,14 @@ options="$4"
CC="$5" CC="$5"
CXX="$6" CXX="$6"
# shellcheck disable=SC2086
[ -f "$dst/ninja.build" ] || CC="$CC" CXX="$CXX" meson "$src" "$dst" $options [ -f "$dst/ninja.build" ] || CC="$CC" CXX="$CXX" meson "$src" "$dst" $options
# Locate ninja binary, on CentOS 7 it is called ninja-build, so # Locate ninja binary, on CentOS 7 it is called ninja-build, so
# use that name if available. # use that name if available.
ninja=ninja ninja="ninja"
if which ninja-build >/dev/null 2>&1 ; then if which ninja-build >/dev/null 2>&1 ; then
ninja=ninja-build ninja="ninja-build"
fi fi
"$ninja" -C "$dst" "$target" "$ninja" -C "$dst" "$target"

View File

@ -21,11 +21,11 @@ export LDFLAGS=${LDFLAGS:--L${clang_lib}}
export WORK=${WORK:-$(pwd)} export WORK=${WORK:-$(pwd)}
export OUT=${OUT:-$(pwd)/out} export OUT=${OUT:-$(pwd)/out}
mkdir -p $OUT mkdir -p "$OUT"
build=$WORK/build build="$WORK/build"
rm -rf $build rm -rf "$build"
mkdir -p $build mkdir -p "$build"
if [ -z "$FUZZING_ENGINE" ]; then if [ -z "$FUZZING_ENGINE" ]; then
fuzzflag="llvm-fuzz=true" fuzzflag="llvm-fuzz=true"
@ -38,28 +38,28 @@ else
fi fi
fi fi
if ! meson $build -D$fuzzflag -Db_lundef=false; then if ! meson "$build" "-D$fuzzflag" -Db_lundef=false; then
cat $build/meson-logs/meson-log.txt cat "$build/meson-logs/meson-log.txt"
exit 1 exit 1
fi fi
ninja -v -C $build fuzzers ninja -v -C "$build" fuzzers
# The seed corpus is a separate flat archive for each fuzzer, # The seed corpus is a separate flat archive for each fuzzer,
# with a fixed name ${fuzzer}_seed_corpus.zip. # with a fixed name ${fuzzer}_seed_corpus.zip.
for d in "$(dirname "$0")/../test/fuzz/fuzz-"*; do for d in "$(dirname "$0")/../test/fuzz/fuzz-"*; do
zip -jqr $OUT/$(basename "$d")_seed_corpus.zip "$d" zip -jqr "$OUT/$(basename "$d")_seed_corpus.zip" "$d"
done done
# get fuzz-dns-packet corpus # get fuzz-dns-packet corpus
df=$build/dns-fuzzing df="$build/dns-fuzzing"
git clone --depth 1 https://github.com/CZ-NIC/dns-fuzzing $df git clone --depth 1 https://github.com/CZ-NIC/dns-fuzzing "$df"
zip -jqr $OUT/fuzz-dns-packet_seed_corpus.zip $df/packet zip -jqr "$OUT/fuzz-dns-packet_seed_corpus.zip" "$df/packet"
install -Dt $OUT/src/shared/ $build/src/shared/libsystemd-shared-*.so install -Dt "$OUT/src/shared/" "$build"/src/shared/libsystemd-shared-*.so
wget -O $OUT/fuzz-json.dict https://raw.githubusercontent.com/rc0r/afl-fuzz/master/dictionaries/json.dict wget -O "$OUT/fuzz-json.dict" https://raw.githubusercontent.com/rc0r/afl-fuzz/master/dictionaries/json.dict
find $build -maxdepth 1 -type f -executable -name "fuzz-*" -exec mv {} $OUT \; find "$build" -maxdepth 1 -type f -executable -name "fuzz-*" -exec mv {} "$OUT" \;
find src -type f -name "fuzz-*.dict" -exec cp {} $OUT \; find src -type f -name "fuzz-*.dict" -exec cp {} "$OUT" \;
cp src/fuzz/*.options $OUT cp src/fuzz/*.options "$OUT"

View File

@ -1,5 +1,6 @@
#!/bin/sh #!/bin/sh
# SPDX-License-Identifier: LGPL-2.1-or-later # SPDX-License-Identifier: LGPL-2.1-or-later
# shellcheck disable=SC2154,SC2174
set -eu set -eu
i=1 i=1