From cc5549ca12616376a4e4ef04fd4e2fb53d6d098c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 4 Apr 2019 14:10:42 +0200 Subject: [PATCH] scripts: use 4 space indentation We had all kinds of indentation: 2 sp, 3 sp, 4 sp, 8 sp, and mixed. 4 sp was the most common, in particular the majority of scripts under test/ used that. Let's standarize on 4 sp, because many commandlines are long and there's a lot of nesting, and with 8sp indentation less stuff fits. 4 sp also seems to be the default indentation, so this will make it less likely that people will mess up if they don't load the editor config. (I think people often use vi, and vi has no support to load project-wide configuration automatically. We distribute a .vimrc file, but it is not loaded by default, and even the instructions in it seem to discourage its use for security reasons.) Also remove the few vim config lines that were left. We should either have them on all files, or none. Also remove some strange stuff like '#!/bin/env bash', yikes. --- .dir-locals.el | 4 +- .editorconfig | 4 + .vimrc | 1 + coccinelle/run-coccinelle.sh | 26 +- man/50-xdg-data-dirs.sh | 2 +- semaphoreci/gcc-compilation.sh | 8 +- semaphoreci/setup.sh | 1 - src/basic/generate-af-list.sh | 4 +- src/basic/generate-arphrd-list.sh | 4 +- src/basic/generate-cap-list.sh | 4 +- src/basic/generate-errno-list.sh | 2 +- src/boot/efi/no-undefined-symbols.sh | 4 +- src/journal/generate-audit_type-list.sh | 8 +- src/shared/generate-ip-protocol-list.sh | 4 +- src/udev/generate-keyboard-keys-gperf.sh | 18 +- src/udev/generate-keyboard-keys-list.sh | 4 +- test/TEST-01-BASIC/test.sh | 2 - test/TEST-02-CRYPTSETUP/test.sh | 2 - test/TEST-03-JOBS/test.sh | 2 - test/TEST-04-JOURNAL/test-journal.sh | 1 - test/TEST-04-JOURNAL/test.sh | 2 - test/TEST-05-RLIMITS/test-rlimits.sh | 1 - test/TEST-05-RLIMITS/test.sh | 2 - test/TEST-06-SELINUX/test-selinux-checks.sh | 1 - test/TEST-06-SELINUX/test.sh | 2 - test/TEST-07-ISSUE-1981/test-segfault.sh | 1 - test/TEST-07-ISSUE-1981/test.sh | 2 - test/TEST-08-ISSUE-2730/test.sh | 2 - test/TEST-09-ISSUE-2691/test.sh | 2 - test/TEST-10-ISSUE-2467/test.sh | 2 - test/TEST-11-ISSUE-3166/test.sh | 2 - test/TEST-12-ISSUE-3171/test.sh | 2 - test/TEST-13-NSPAWN-SMOKE/test.sh | 2 - test/TEST-14-MACHINE-ID/test.sh | 2 - test/TEST-15-DROPIN/test-dropin.sh | 405 +++++++++---------- test/TEST-15-DROPIN/test.sh | 32 +- test/TEST-16-EXTEND-TIMEOUT/test.sh | 2 - test/TEST-17-UDEV-WANTS/test.sh | 2 - test/TEST-17-UDEV-WANTS/testsuite.sh | 2 - test/TEST-18-FAILUREACTION/test.sh | 2 - test/TEST-18-FAILUREACTION/testsuite.sh | 2 - test/TEST-19-DELEGATE/test.sh | 2 - test/TEST-19-DELEGATE/testsuite.sh | 46 +-- test/TEST-20-MAINPIDGAMES/test.sh | 2 - test/TEST-20-MAINPIDGAMES/testsuite.sh | 2 - test/TEST-21-SYSUSERS/test.sh | 146 ++++--- test/TEST-22-TMPFILES/test.sh | 2 - test/TEST-23-TYPE-EXEC/test.sh | 2 - test/TEST-23-TYPE-EXEC/testsuite.sh | 2 - test/TEST-24-UNIT-TESTS/test.sh | 2 - test/TEST-24-UNIT-TESTS/testsuite.sh | 2 - test/TEST-25-IMPORT/test.sh | 2 - test/TEST-25-IMPORT/testsuite.sh | 2 - test/TEST-26-SETENV/test.sh | 2 - test/TEST-26-SETENV/testsuite.sh | 2 - test/TEST-27-STDOUTFILE/test.sh | 2 - test/TEST-27-STDOUTFILE/testsuite.sh | 20 +- test/TEST-28-PERCENTJ-WANTEDBY/test.sh | 2 - test/TEST-29-UDEV-ID_RENAMING/test.sh | 2 - test/TEST-29-UDEV-ID_RENAMING/testsuite.sh | 2 - test/TEST-30-ONCLOCKCHANGE/test.sh | 2 - test/TEST-30-ONCLOCKCHANGE/testsuite.sh | 2 - test/TEST-31-DEVICE-ENUMERATION/test.sh | 2 - test/TEST-31-DEVICE-ENUMERATION/testsuite.sh | 2 - test/run-integration-tests.sh | 38 +- test/test-efi-create-disk.sh | 14 +- test/test-functions | 18 +- tools/add-git-hook.sh | 2 +- tools/check-directives.sh | 13 +- tools/choose-default-locale.sh | 7 +- tools/coverity.sh | 244 +++++------ tools/find-build-dir.sh | 24 +- tools/find-double-newline.sh | 57 ++- tools/find-tabs.sh | 57 ++- tools/meson-apply-m4.sh | 12 +- tools/meson-check-api-docs.sh | 41 +- tools/meson-check-help.sh | 14 +- tools/meson-git-contrib.sh | 10 +- tools/meson-hwdb-update.sh | 24 +- tools/meson-make-symlink.sh | 4 +- tools/meson-vcs-tag.sh | 4 +- tools/oss-fuzz.sh | 4 +- travis-ci/managers/travis_wait.bash | 82 ++-- travis-ci/managers/xenial.sh | 1 - travis-ci/scripts/build-docker-image.sh | 8 +- travis-ci/tools/get-coverity.sh | 22 +- units/meson-add-wants.sh | 24 +- xorg/50-systemd-user.sh | 2 +- 88 files changed, 740 insertions(+), 815 deletions(-) diff --git a/.dir-locals.el b/.dir-locals.el index 815afe172a..fde58d65bd 100644 --- a/.dir-locals.el +++ b/.dir-locals.el @@ -20,8 +20,8 @@ (nxml-mode . ((nxml-child-indent . 2) (fill-column . 109))) (meson-mode . ((meson-indent-basic . 8))) - (sh-mode . ((sh-basic-offset . 8) - (sh-indentation . 8))) + (sh-mode . ((sh-basic-offset . 4) + (sh-indentation . 4))) (awk-mode . ((c-basic-offset . 8))) (nil . ((indent-tabs-mode . nil) (tab-width . 8) diff --git a/.editorconfig b/.editorconfig index 67d848b68d..63b1d749cb 100644 --- a/.editorconfig +++ b/.editorconfig @@ -19,6 +19,10 @@ charset = utf-8 indent_style = space indent_size = 8 +[*.sh] +indent_style = space +indent_size = 4 + [meson.build] indent_style = space indent_size = 8 diff --git a/.vimrc b/.vimrc index a62546d8e2..d40b57a665 100644 --- a/.vimrc +++ b/.vimrc @@ -17,4 +17,5 @@ set expandtab set makeprg=GCC_COLORS=\ make set tw=79 au BufRead,BufNewFile *.xml set tw=109 shiftwidth=2 smarttab +au FileType sh set tw=80 shiftwidth=4 smarttab au FileType c set tw=109 diff --git a/coccinelle/run-coccinelle.sh b/coccinelle/run-coccinelle.sh index 22ab66d3dd..520de0ac42 100755 --- a/coccinelle/run-coccinelle.sh +++ b/coccinelle/run-coccinelle.sh @@ -5,23 +5,23 @@ files="$(git ls-files ':/*.[ch]')" args= case "$1" in - -i) - args="$args --in-place" - shift - ;; + -i) + args="$args --in-place" + shift + ;; esac if ! parallel -h >/dev/null; then - echo 'Please install GNU parallel (package "parallel")' - exit 1 + echo 'Please install GNU parallel (package "parallel")' + exit 1 fi for SCRIPT in ${@-$top/coccinelle/*.cocci} ; do - echo "--x-- Processing $SCRIPT --x--" - TMPFILE=`mktemp` - echo "+ spatch --sp-file $SCRIPT $args ..." - parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \ - spatch --sp-file $SCRIPT $args ::: $files \ - 2>"$TMPFILE" || cat "$TMPFILE" - echo -e "--x-- Processed $SCRIPT --x--\n" + echo "--x-- Processing $SCRIPT --x--" + TMPFILE=`mktemp` + echo "+ spatch --sp-file $SCRIPT $args ..." + parallel --halt now,fail=1 --keep-order --noswap --max-args=20 \ + spatch --sp-file $SCRIPT $args ::: $files \ + 2>"$TMPFILE" || cat "$TMPFILE" + echo -e "--x-- Processed $SCRIPT --x--\n" done diff --git a/man/50-xdg-data-dirs.sh b/man/50-xdg-data-dirs.sh index 073174cb40..89e9fbb599 100755 --- a/man/50-xdg-data-dirs.sh +++ b/man/50-xdg-data-dirs.sh @@ -5,7 +5,7 @@ XDG_DATA_DIRS="${XDG_DATA_DIRS:-/usr/local/share/:/usr/share}" # add a directory if it exists if [[ -d /opt/foo/share ]]; then - XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS} + XDG_DATA_DIRS=/opt/foo/share:${XDG_DATA_DIRS} fi # write our output diff --git a/semaphoreci/gcc-compilation.sh b/semaphoreci/gcc-compilation.sh index 8755b850b6..ef499b8a35 100755 --- a/semaphoreci/gcc-compilation.sh +++ b/semaphoreci/gcc-compilation.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -ex # keep this in sync with setup.sh @@ -40,4 +39,9 @@ dpkg-buildpackage -S -I -I$(basename "$SEMAPHORE_CACHE_DIR") -d -us -uc -nc # now build the package and run the tests rm -rf "$ARTIFACTS_DIR" # autopkgtest exits with 2 for "some tests skipped", accept that -$AUTOPKGTESTDIR/runner/autopkgtest --apt-upgrade --env DEB_BUILD_OPTIONS=noudeb --env TEST_UPSTREAM=1 ../systemd_*.dsc -o "$ARTIFACTS_DIR" -- lxc -s $CONTAINER || [ $? -eq 2 ] +$AUTOPKGTESTDIR/runner/autopkgtest --apt-upgrade \ + --env DEB_BUILD_OPTIONS=noudeb \ + --env TEST_UPSTREAM=1 ../systemd_*.dsc \ + -o "$ARTIFACTS_DIR" \ + -- lxc -s $CONTAINER \ + || [ $? -eq 2 ] diff --git a/semaphoreci/setup.sh b/semaphoreci/setup.sh index c904a300a1..c39238a4e9 100755 --- a/semaphoreci/setup.sh +++ b/semaphoreci/setup.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -ex # default to Debian testing diff --git a/src/basic/generate-af-list.sh b/src/basic/generate-af-list.sh index 5bf244c49d..6987877ebf 100755 --- a/src/basic/generate-af-list.sh +++ b/src/basic/generate-af-list.sh @@ -2,5 +2,5 @@ set -eu $1 -E -dM -include sys/socket.h -include "$2" -include "$3" - = 7\n\ _Pragma(\"GCC diagnostic ignored \\\"-Wimplicit-fallthrough\\\"\")\n\ #endif\n\ %}" - print "struct key_name { const char* name; unsigned short id; };" - print "%null-strings" - print "%%" - } + print "struct key_name { const char* name; unsigned short id; };" + print "%null-strings" + print "%%" + } - /^KEY_/ { print tolower(substr($1 ,5)) ", " $1 } - { print tolower($1) ", " $1 } + /^KEY_/ { print tolower(substr($1 ,5)) ", " $1 } + { print tolower($1) ", " $1 } ' < "$1" diff --git a/src/udev/generate-keyboard-keys-list.sh b/src/udev/generate-keyboard-keys-list.sh index c055f7c756..aa00c15c16 100755 --- a/src/udev/generate-keyboard-keys-list.sh +++ b/src/udev/generate-keyboard-keys-list.sh @@ -2,6 +2,6 @@ set -eu $1 -dM -include linux/input.h - / { next } - /^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9BK]/ { print $2 } + /\<(KEY_(MAX|MIN_INTERESTING))|(BTN_(MISC|MOUSE|JOYSTICK|GAMEPAD|DIGI|WHEEL|TRIGGER_HAPPY))\>/ { next } + /^#define[ \t]+(KEY|BTN)_[^ ]+[ \t]+[0-9BK]/ { print $2 } ' diff --git a/test/TEST-01-BASIC/test.sh b/test/TEST-01-BASIC/test.sh index 1c64017aaa..2314ec37ce 100755 --- a/test/TEST-01-BASIC/test.sh +++ b/test/TEST-01-BASIC/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Basic systemd setup" RUN_IN_UNPRIVILEGED_CONTAINER=${RUN_IN_UNPRIVILEGED_CONTAINER:-yes} diff --git a/test/TEST-02-CRYPTSETUP/test.sh b/test/TEST-02-CRYPTSETUP/test.sh index 97eb2f409e..aed1c59106 100755 --- a/test/TEST-02-CRYPTSETUP/test.sh +++ b/test/TEST-02-CRYPTSETUP/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="cryptsetup systemd setup" TEST_NO_NSPAWN=1 diff --git a/test/TEST-03-JOBS/test.sh b/test/TEST-03-JOBS/test.sh index 93a387df59..89125109d8 100755 --- a/test/TEST-03-JOBS/test.sh +++ b/test/TEST-03-JOBS/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Job-related tests" TEST_NO_QEMU=1 diff --git a/test/TEST-04-JOURNAL/test-journal.sh b/test/TEST-04-JOURNAL/test-journal.sh index e198cb6ede..4e539aa151 100755 --- a/test/TEST-04-JOURNAL/test-journal.sh +++ b/test/TEST-04-JOURNAL/test-journal.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -x set -e set -o pipefail diff --git a/test/TEST-04-JOURNAL/test.sh b/test/TEST-04-JOURNAL/test.sh index 33bfcbf681..f24a8f6be7 100755 --- a/test/TEST-04-JOURNAL/test.sh +++ b/test/TEST-04-JOURNAL/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Journal-related tests" diff --git a/test/TEST-05-RLIMITS/test-rlimits.sh b/test/TEST-05-RLIMITS/test-rlimits.sh index ba665c5968..b4d79c9655 100755 --- a/test/TEST-05-RLIMITS/test-rlimits.sh +++ b/test/TEST-05-RLIMITS/test-rlimits.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -x set -e set -o pipefail diff --git a/test/TEST-05-RLIMITS/test.sh b/test/TEST-05-RLIMITS/test.sh index 3eb2165796..3c29b2ee3f 100755 --- a/test/TEST-05-RLIMITS/test.sh +++ b/test/TEST-05-RLIMITS/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Resource limits-related tests" diff --git a/test/TEST-06-SELINUX/test-selinux-checks.sh b/test/TEST-06-SELINUX/test-selinux-checks.sh index 153fab3aac..dae48cd4b2 100755 --- a/test/TEST-06-SELINUX/test-selinux-checks.sh +++ b/test/TEST-06-SELINUX/test-selinux-checks.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -x set -e set -o pipefail diff --git a/test/TEST-06-SELINUX/test.sh b/test/TEST-06-SELINUX/test.sh index 0c924ecbbd..2b49b3d5ae 100755 --- a/test/TEST-06-SELINUX/test.sh +++ b/test/TEST-06-SELINUX/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="SELinux tests" TEST_NO_NSPAWN=1 diff --git a/test/TEST-07-ISSUE-1981/test-segfault.sh b/test/TEST-07-ISSUE-1981/test-segfault.sh index 48f05d89fb..82339c23cd 100755 --- a/test/TEST-07-ISSUE-1981/test-segfault.sh +++ b/test/TEST-07-ISSUE-1981/test-segfault.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -x set -e diff --git a/test/TEST-07-ISSUE-1981/test.sh b/test/TEST-07-ISSUE-1981/test.sh index 499a36038c..93ddb6f5fb 100755 --- a/test/TEST-07-ISSUE-1981/test.sh +++ b/test/TEST-07-ISSUE-1981/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/1981" TEST_NO_QEMU=1 diff --git a/test/TEST-08-ISSUE-2730/test.sh b/test/TEST-08-ISSUE-2730/test.sh index b01df3656b..ef2aba0e17 100755 --- a/test/TEST-08-ISSUE-2730/test.sh +++ b/test/TEST-08-ISSUE-2730/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2730" TEST_NO_NSPAWN=1 diff --git a/test/TEST-09-ISSUE-2691/test.sh b/test/TEST-09-ISSUE-2691/test.sh index 01eb4dbac8..8e7402fcd4 100755 --- a/test/TEST-09-ISSUE-2691/test.sh +++ b/test/TEST-09-ISSUE-2691/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2691" TEST_NO_NSPAWN=1 diff --git a/test/TEST-10-ISSUE-2467/test.sh b/test/TEST-10-ISSUE-2467/test.sh index c85433d7d3..dc7a9acaa1 100755 --- a/test/TEST-10-ISSUE-2467/test.sh +++ b/test/TEST-10-ISSUE-2467/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/2467" diff --git a/test/TEST-11-ISSUE-3166/test.sh b/test/TEST-11-ISSUE-3166/test.sh index 38c725fa70..3419b78fe7 100755 --- a/test/TEST-11-ISSUE-3166/test.sh +++ b/test/TEST-11-ISSUE-3166/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3166" TEST_NO_NSPAWN=1 diff --git a/test/TEST-12-ISSUE-3171/test.sh b/test/TEST-12-ISSUE-3171/test.sh index 0c267e11a6..31cf1b471a 100755 --- a/test/TEST-12-ISSUE-3171/test.sh +++ b/test/TEST-12-ISSUE-3171/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="https://github.com/systemd/systemd/issues/3171" TEST_NO_QEMU=1 diff --git a/test/TEST-13-NSPAWN-SMOKE/test.sh b/test/TEST-13-NSPAWN-SMOKE/test.sh index 774b7cbed5..bd85b92caa 100755 --- a/test/TEST-13-NSPAWN-SMOKE/test.sh +++ b/test/TEST-13-NSPAWN-SMOKE/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="systemd-nspawn smoke test" TEST_NO_NSPAWN=1 diff --git a/test/TEST-14-MACHINE-ID/test.sh b/test/TEST-14-MACHINE-ID/test.sh index 9435834204..33e311a1e7 100755 --- a/test/TEST-14-MACHINE-ID/test.sh +++ b/test/TEST-14-MACHINE-ID/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="/etc/machine-id testing" TEST_NO_NSPAWN=1 diff --git a/test/TEST-15-DROPIN/test-dropin.sh b/test/TEST-15-DROPIN/test-dropin.sh index ab0a58caea..02962a8a07 100755 --- a/test/TEST-15-DROPIN/test-dropin.sh +++ b/test/TEST-15-DROPIN/test-dropin.sh @@ -1,279 +1,278 @@ #! /bin/bash - set -e set -x _clear_service () { - systemctl stop $1.service 2>/dev/null || : - rm -f /{etc,run,usr/lib}/systemd/system/$1.service - rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d - rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires} + systemctl stop $1.service 2>/dev/null || : + rm -f /{etc,run,usr/lib}/systemd/system/$1.service + rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.d + rm -fr /{etc,run,usr/lib}/systemd/system/$1.service.{wants,requires} } clear_services () { - for u in $*; do - _clear_service $u - done - systemctl daemon-reload + for u in $*; do + _clear_service $u + done + systemctl daemon-reload } create_service () { - clear_services $1 + clear_services $1 - cat >/etc/systemd/system/$1.service</etc/systemd/system/$1.service</usr/lib/systemd/system/a.service.d/override.conf </usr/lib/systemd/system/a.service.d/override.conf </usr/lib/systemd/system/a.service.d/wants-b.conf</usr/lib/systemd/system/a.service.d/wants-b.conf<&2 + echo "Skipping TEST-19-DELEGATE, as the kernel doesn't actually support cgroup v2" >&2 fi echo OK > /testok diff --git a/test/TEST-20-MAINPIDGAMES/test.sh b/test/TEST-20-MAINPIDGAMES/test.sh index 4ec8081478..bf80e8b584 100755 --- a/test/TEST-20-MAINPIDGAMES/test.sh +++ b/test/TEST-20-MAINPIDGAMES/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="test changing main PID" diff --git a/test/TEST-20-MAINPIDGAMES/testsuite.sh b/test/TEST-20-MAINPIDGAMES/testsuite.sh index b183ec9a6b..9471a5d734 100755 --- a/test/TEST-20-MAINPIDGAMES/testsuite.sh +++ b/test/TEST-20-MAINPIDGAMES/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/TEST-21-SYSUSERS/test.sh b/test/TEST-21-SYSUSERS/test.sh index b1049e720d..9f64e030b5 100755 --- a/test/TEST-21-SYSUSERS/test.sh +++ b/test/TEST-21-SYSUSERS/test.sh @@ -1,21 +1,19 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Sysuser-related tests" . $TEST_BASE_DIR/test-functions test_setup() { - mkdir -p $TESTDIR/etc/sysusers.d $TESTDIR/usr/lib/sysusers.d $TESTDIR/tmp + mkdir -p $TESTDIR/etc/sysusers.d $TESTDIR/usr/lib/sysusers.d $TESTDIR/tmp } prepare_testdir() { - rm -f $TESTDIR/etc/*{passwd,group,shadow} - for i in $1.initial-{passwd,group,shadow}; do - test -f $i && cp $i $TESTDIR/etc/${i#*.initial-} - done - return 0 + rm -f $TESTDIR/etc/*{passwd,group,shadow} + for i in $1.initial-{passwd,group,shadow}; do + test -f $i && cp $i $TESTDIR/etc/${i#*.initial-} + done + return 0 } preprocess() { @@ -30,92 +28,92 @@ preprocess() { compare() { if ! diff -u $TESTDIR/etc/passwd <(preprocess ${1%.*}.expected-passwd); then - echo "**** Unexpected output for $f" - exit 1 + echo "**** Unexpected output for $f" + exit 1 fi if ! diff -u $TESTDIR/etc/group <(preprocess ${1%.*}.expected-group); then - echo "**** Unexpected output for $f $2" - exit 1 + echo "**** Unexpected output for $f $2" + exit 1 fi } test_run() { - # ensure our build of systemd-sysusers is run - PATH=${BUILD_DIR}:$PATH + # ensure our build of systemd-sysusers is run + PATH=${BUILD_DIR}:$PATH - rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/* + rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/* - # happy tests - for f in test-*.input; do - echo "*** Running $f" - prepare_testdir ${f%.input} - cp $f $TESTDIR/usr/lib/sysusers.d/test.conf - systemd-sysusers --root=$TESTDIR + # happy tests + for f in test-*.input; do + echo "*** Running $f" + prepare_testdir ${f%.input} + cp $f $TESTDIR/usr/lib/sysusers.d/test.conf + systemd-sysusers --root=$TESTDIR - compare $f "" - done + compare $f "" + done - for f in test-*.input; do - echo "*** Running $f on stdin" - prepare_testdir ${f%.input} - touch $TESTDIR/etc/sysusers.d/test.conf - cat $f | systemd-sysusers --root=$TESTDIR - + for f in test-*.input; do + echo "*** Running $f on stdin" + prepare_testdir ${f%.input} + touch $TESTDIR/etc/sysusers.d/test.conf + cat $f | systemd-sysusers --root=$TESTDIR - - compare $f "on stdin" - done + compare $f "on stdin" + done - for f in test-*.input; do - echo "*** Running $f on stdin with --replace" - prepare_testdir ${f%.input} - touch $TESTDIR/etc/sysusers.d/test.conf - # this overrides test.conf which is masked on disk - cat $f | systemd-sysusers --root=$TESTDIR --replace=/etc/sysusers.d/test.conf - - # this should be ignored - cat test-1.input | systemd-sysusers --root=$TESTDIR --replace=/usr/lib/sysusers.d/test.conf - + for f in test-*.input; do + echo "*** Running $f on stdin with --replace" + prepare_testdir ${f%.input} + touch $TESTDIR/etc/sysusers.d/test.conf + # this overrides test.conf which is masked on disk + cat $f | systemd-sysusers --root=$TESTDIR --replace=/etc/sysusers.d/test.conf - + # this should be ignored + cat test-1.input | systemd-sysusers --root=$TESTDIR --replace=/usr/lib/sysusers.d/test.conf - - compare $f "on stdin with --replace" - done + compare $f "on stdin with --replace" + done - # test --inline - echo "*** Testing --inline" - prepare_testdir - # copy a random file to make sure it is ignored - cp $f $TESTDIR/etc/sysusers.d/confuse.conf - systemd-sysusers --root=$TESTDIR --inline \ - "u u1 222 - - /bin/zsh" \ - "g g1 111" + # test --inline + echo "*** Testing --inline" + prepare_testdir + # copy a random file to make sure it is ignored + cp $f $TESTDIR/etc/sysusers.d/confuse.conf + systemd-sysusers --root=$TESTDIR --inline \ + "u u1 222 - - /bin/zsh" \ + "g g1 111" - compare inline "(--inline)" + compare inline "(--inline)" - # test --replace - echo "*** Testing --inline with --replace" - prepare_testdir - # copy a random file to make sure it is ignored - cp $f $TESTDIR/etc/sysusers.d/confuse.conf - systemd-sysusers --root=$TESTDIR \ - --inline \ - --replace=/etc/sysusers.d/confuse.conf \ - "u u1 222 - - /bin/zsh" \ - "g g1 111" + # test --replace + echo "*** Testing --inline with --replace" + prepare_testdir + # copy a random file to make sure it is ignored + cp $f $TESTDIR/etc/sysusers.d/confuse.conf + systemd-sysusers --root=$TESTDIR \ + --inline \ + --replace=/etc/sysusers.d/confuse.conf \ + "u u1 222 - - /bin/zsh" \ + "g g1 111" - compare inline "(--inline --replace=…)" + compare inline "(--inline --replace=…)" - rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/* + rm -f $TESTDIR/etc/sysusers.d/* $TESTDIR/usr/lib/sysusers.d/* - # tests for error conditions - for f in unhappy-*.input; do - echo "*** Running test $f" - prepare_testdir ${f%.input} - cp $f $TESTDIR/usr/lib/sysusers.d/test.conf - systemd-sysusers --root=$TESTDIR 2> /dev/null - journalctl -t systemd-sysusers -o cat | tail -n1 > $TESTDIR/tmp/err - if ! diff -u $TESTDIR/tmp/err ${f%.*}.expected-err; then - echo "**** Unexpected error output for $f" - cat $TESTDIR/tmp/err - exit 1 - fi - done + # tests for error conditions + for f in unhappy-*.input; do + echo "*** Running test $f" + prepare_testdir ${f%.input} + cp $f $TESTDIR/usr/lib/sysusers.d/test.conf + systemd-sysusers --root=$TESTDIR 2> /dev/null + journalctl -t systemd-sysusers -o cat | tail -n1 > $TESTDIR/tmp/err + if ! diff -u $TESTDIR/tmp/err ${f%.*}.expected-err; then + echo "**** Unexpected error output for $f" + cat $TESTDIR/tmp/err + exit 1 + fi + done } do_test "$@" diff --git a/test/TEST-22-TMPFILES/test.sh b/test/TEST-22-TMPFILES/test.sh index 13e191bd92..5c509f63fb 100755 --- a/test/TEST-22-TMPFILES/test.sh +++ b/test/TEST-22-TMPFILES/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Tmpfiles related tests" TEST_NO_QEMU=1 diff --git a/test/TEST-23-TYPE-EXEC/test.sh b/test/TEST-23-TYPE-EXEC/test.sh index 2e76451f5b..6ed22be366 100755 --- a/test/TEST-23-TYPE-EXEC/test.sh +++ b/test/TEST-23-TYPE-EXEC/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="test Type=exec" diff --git a/test/TEST-23-TYPE-EXEC/testsuite.sh b/test/TEST-23-TYPE-EXEC/testsuite.sh index 4f7cc44310..b161d97a7c 100755 --- a/test/TEST-23-TYPE-EXEC/testsuite.sh +++ b/test/TEST-23-TYPE-EXEC/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/TEST-24-UNIT-TESTS/test.sh b/test/TEST-24-UNIT-TESTS/test.sh index fc8c89fe0a..038303edf8 100755 --- a/test/TEST-24-UNIT-TESTS/test.sh +++ b/test/TEST-24-UNIT-TESTS/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="Run unit tests under containers" RUN_IN_UNPRIVILEGED_CONTAINER=yes diff --git a/test/TEST-24-UNIT-TESTS/testsuite.sh b/test/TEST-24-UNIT-TESTS/testsuite.sh index 7c7a068556..e33d04d043 100755 --- a/test/TEST-24-UNIT-TESTS/testsuite.sh +++ b/test/TEST-24-UNIT-TESTS/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh #set -ex #set -o pipefail diff --git a/test/TEST-25-IMPORT/test.sh b/test/TEST-25-IMPORT/test.sh index 188e7233bb..7fe367c3be 100755 --- a/test/TEST-25-IMPORT/test.sh +++ b/test/TEST-25-IMPORT/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="test importd" diff --git a/test/TEST-25-IMPORT/testsuite.sh b/test/TEST-25-IMPORT/testsuite.sh index 2bb96f137d..380ba3d82d 100755 --- a/test/TEST-25-IMPORT/testsuite.sh +++ b/test/TEST-25-IMPORT/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/TEST-26-SETENV/test.sh b/test/TEST-26-SETENV/test.sh index fb9c18926f..9a2913d330 100755 --- a/test/TEST-26-SETENV/test.sh +++ b/test/TEST-26-SETENV/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="test setenv" diff --git a/test/TEST-26-SETENV/testsuite.sh b/test/TEST-26-SETENV/testsuite.sh index 2d93cb49c9..0abbf95326 100755 --- a/test/TEST-26-SETENV/testsuite.sh +++ b/test/TEST-26-SETENV/testsuite.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail diff --git a/test/TEST-27-STDOUTFILE/test.sh b/test/TEST-27-STDOUTFILE/test.sh index 724dbef231..fb35f80ec1 100755 --- a/test/TEST-27-STDOUTFILE/test.sh +++ b/test/TEST-27-STDOUTFILE/test.sh @@ -1,6 +1,4 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -e TEST_DESCRIPTION="test StandardOutput=file:" diff --git a/test/TEST-27-STDOUTFILE/testsuite.sh b/test/TEST-27-STDOUTFILE/testsuite.sh index 6975b7966f..2c813da720 100755 --- a/test/TEST-27-STDOUTFILE/testsuite.sh +++ b/test/TEST-27-STDOUTFILE/testsuite.sh @@ -1,13 +1,15 @@ #!/bin/bash -# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*- -# ex: ts=8 sw=4 sts=4 et filetype=sh set -ex set -o pipefail systemd-analyze log-level debug systemd-analyze log-target console -systemd-run --wait --unit=one -p StandardOutput=file:/tmp/stdout -p StandardError=file:/tmp/stderr -p Type=exec sh -c 'echo x ; echo y >&2' +systemd-run --wait --unit=one \ + -p StandardOutput=file:/tmp/stdout \ + -p StandardError=file:/tmp/stderr \ + -p Type=exec \ + sh -c 'echo x ; echo y >&2' cmp /tmp/stdout <&2' +systemd-run --wait --unit=two \ + -p StandardOutput=file:/tmp/stdout \ + -p StandardError=file:/tmp/stderr \ + -p Type=exec \ + sh -c 'echo z ; echo a >&2' cmp /tmp/stdout <&2' +systemd-run --wait --unit=three \ + -p StandardOutput=append:/tmp/stdout \ + -p StandardError=append:/tmp/stderr \ + -p Type=exec \ + sh -c 'echo b ; echo c >&2' cmp /tmp/stdout <mnt/cmdline.txt objcopy \ - --add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \ - --add-section .cmdline=mnt/cmdline.txt --change-section-vma .cmdline=0x30000 \ - --add-section .splash="$splash_bmp" --change-section-vma .splash=0x40000 \ - --add-section .linux=/boot/$(cat /etc/machine-id)/$(uname -r)/linux --change-section-vma .linux=0x2000000 \ - --add-section .initrd=/boot/$(cat /etc/machine-id)/$(uname -r)/initrd --change-section-vma .initrd=0x3000000 \ - "$boot_stub" mnt/EFI/Linux/linux-test.efi + --add-section .osrel=/etc/os-release --change-section-vma .osrel=0x20000 \ + --add-section .cmdline=mnt/cmdline.txt --change-section-vma .cmdline=0x30000 \ + --add-section .splash="$splash_bmp" --change-section-vma .splash=0x40000 \ + --add-section .linux=/boot/$(cat /etc/machine-id)/$(uname -r)/linux --change-section-vma .linux=0x2000000 \ + --add-section .initrd=/boot/$(cat /etc/machine-id)/$(uname -r)/initrd --change-section-vma .initrd=0x3000000 \ + "$boot_stub" mnt/EFI/Linux/linux-test.efi # install entries mkdir -p mnt/loader/entries diff --git a/test/test-functions b/test/test-functions index 6016fd21ac..50c6e96902 100644 --- a/test/test-functions +++ b/test/test-functions @@ -159,15 +159,15 @@ run_qemu() { exit 1 fi -if [[ "$LOOKS_LIKE_SUSE" ]]; then - PARAMS+="rd.hostonly=0" -elif [[ "$LOOKS_LIKE_ARCH" ]]; then - PARAMS+="rw" -else - PARAMS+="ro" -fi + if [[ "$LOOKS_LIKE_SUSE" ]]; then + PARAMS+="rd.hostonly=0" + elif [[ "$LOOKS_LIKE_ARCH" ]]; then + PARAMS+="rw" + else + PARAMS+="ro" + fi -KERNEL_APPEND="$PARAMS \ + KERNEL_APPEND="$PARAMS \ root=/dev/sda1 \ raid=noautodetect \ loglevel=2 \ @@ -1639,7 +1639,7 @@ do_test() { exit 0 fi -# Detect lib paths + # Detect lib paths [[ $libdir ]] || for libdir in /lib64 /lib; do [[ -d $libdir ]] && libdirs+=" $libdir" && break done diff --git a/tools/add-git-hook.sh b/tools/add-git-hook.sh index c1db99b18a..5b1bf17219 100755 --- a/tools/add-git-hook.sh +++ b/tools/add-git-hook.sh @@ -4,7 +4,7 @@ set -eu cd "$MESON_SOURCE_ROOT" if [ ! -f .git/hooks/pre-commit.sample -o -f .git/hooks/pre-commit ]; then - exit 2 # not needed + exit 2 # not needed fi cp -p .git/hooks/pre-commit.sample .git/hooks/pre-commit diff --git a/tools/check-directives.sh b/tools/check-directives.sh index 99f8f9d451..e8c6e60040 100755 --- a/tools/check-directives.sh +++ b/tools/check-directives.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -e function generate_directives() { @@ -12,18 +11,18 @@ function generate_directives() { ret=0 if [[ $(generate_directives src/network/networkd-network-gperf.gperf | wc -l) -ne $(wc -l &2 - exit 2 - fi - found="$c" + if [ -n "$found" ]; then + echo 'Found multiple candidates, specify build directory with $BUILD_DIR' >&2 + exit 2 + fi + found="$c" done if [ -z "$found" ]; then - echo 'Specify build directory with $BUILD_DIR' >&2 - exit 1 + echo 'Specify build directory with $BUILD_DIR' >&2 + exit 1 fi echo "$(realpath $found)" diff --git a/tools/find-double-newline.sh b/tools/find-double-newline.sh index 6a6790b4b2..51204eb7c9 100755 --- a/tools/find-double-newline.sh +++ b/tools/find-double-newline.sh @@ -4,39 +4,38 @@ TOP=`git rev-parse --show-toplevel` case "$1" in + recdiff) + if [ "$2" = "" ] ; then + DIR="$TOP" + else + DIR="$2" + fi - recdiff) - if [ "$2" = "" ] ; then - DIR="$TOP" - else - DIR="$2" - 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) + if [ "$2" = "" ] ; then + DIR="$TOP" + else + DIR="$2" + fi - recpatch) - if [ "$2" = "" ] ; then - DIR="$TOP" - else - DIR="$2" - 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) + T=`mktemp` + sed '/^$/N;/^\n$/D' < "$2" > "$T" + diff -u "$2" "$T" + rm -f "$T" + ;; - diff) - T=`mktemp` - sed '/^$/N;/^\n$/D' < "$2" > "$T" - diff -u "$2" "$T" - rm -f "$T" - ;; + patch) + sed -i '/^$/N;/^\n$/D' "$2" + ;; - patch) - sed -i '/^$/N;/^\n$/D' "$2" - ;; - - *) - echo "Expected recdiff|recpatch|diff|patch as verb." >&2 - ;; + *) + echo "Expected recdiff|recpatch|diff|patch as verb." >&2 + ;; esac diff --git a/tools/find-tabs.sh b/tools/find-tabs.sh index e32eac8f32..95249f9c9c 100755 --- a/tools/find-tabs.sh +++ b/tools/find-tabs.sh @@ -4,39 +4,38 @@ TOP=`git rev-parse --show-toplevel` case "$1" in + recdiff) + if [ "$2" = "" ] ; then + DIR="$TOP" + else + DIR="$2" + fi - recdiff) - if [ "$2" = "" ] ; then - DIR="$TOP" - else - DIR="$2" - 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) + if [ "$2" = "" ] ; then + DIR="$TOP" + else + DIR="$2" + fi - recpatch) - if [ "$2" = "" ] ; then - DIR="$TOP" - else - DIR="$2" - 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) + T=`mktemp` + sed 's/\t/ /g' < "$2" > "$T" + diff -u "$2" "$T" + rm -f "$T" + ;; - diff) - T=`mktemp` - sed 's/\t/ /g' < "$2" > "$T" - diff -u "$2" "$T" - rm -f "$T" - ;; + patch) + sed -i 's/\t/ /g' "$2" + ;; - patch) - sed -i 's/\t/ /g' "$2" - ;; - - *) - echo "Expected recdiff|recpatch|diff|patch as verb." >&2 - ;; + *) + echo "Expected recdiff|recpatch|diff|patch as verb." >&2 + ;; esac diff --git a/tools/meson-apply-m4.sh b/tools/meson-apply-m4.sh index 6abe177ac5..5fad8cd94f 100755 --- a/tools/meson-apply-m4.sh +++ b/tools/meson-apply-m4.sh @@ -5,18 +5,18 @@ CONFIG=$1 TARGET=$2 if [ $# -ne 2 ]; then - echo 'Invalid number of arguments.' - exit 1 + echo 'Invalid number of arguments.' + exit 1 fi if [ ! -f $CONFIG ]; then - echo "$CONFIG not found." - exit 2 + echo "$CONFIG not found." + exit 2 fi if [ ! -f $TARGET ]; then - echo "$TARGET not found." - exit 3 + echo "$TARGET not found." + exit 3 fi DEFINES=$(awk '$1 == "#define" && $3 == "1" { printf "-D%s ", $2 }' $CONFIG) diff --git a/tools/meson-check-api-docs.sh b/tools/meson-check-api-docs.sh index a654368f9e..bd320562ad 100755 --- a/tools/meson-check-api-docs.sh +++ b/tools/meson-check-api-docs.sh @@ -1,5 +1,4 @@ #!/bin/sh - set -eu sd_good=0 @@ -8,27 +7,27 @@ udev_good=0 udev_total=0 for symbol in `nm -g --defined-only "$@" | grep " T " | cut -d" " -f3 | sort -u` ; do - if test -f ${MESON_BUILD_ROOT}/man/$symbol.3 ; then - echo "✓ Symbol $symbol() is documented." - good=1 - else - printf " \x1b[1;31mSymbol $symbol() lacks documentation.\x1b[0m\n" - good=0 - fi + if test -f ${MESON_BUILD_ROOT}/man/$symbol.3 ; then + echo "✓ Symbol $symbol() is documented." + good=1 + else + printf " \x1b[1;31mSymbol $symbol() lacks documentation.\x1b[0m\n" + good=0 + fi - case $symbol in - sd_*) - ((sd_good+=good)) - ((sd_total+=1)) - ;; - udev_*) - ((udev_good+=good)) - ((udev_total+=1)) - ;; - *) - echo 'unknown symbol prefix' - exit 1 - esac + case $symbol in + sd_*) + ((sd_good+=good)) + ((sd_total+=1)) + ;; + udev_*) + ((udev_good+=good)) + ((udev_total+=1)) + ;; + *) + echo 'unknown symbol prefix' + exit 1 + esac done echo "libsystemd: $sd_good/$sd_total libudev: $udev_good/$udev_total" diff --git a/tools/meson-check-help.sh b/tools/meson-check-help.sh index 69157105f2..a0e304ca9c 100755 --- a/tools/meson-check-help.sh +++ b/tools/meson-check-help.sh @@ -5,19 +5,19 @@ export SYSTEMD_LOG_LEVEL=info # output width if "$1" --help | grep -v 'default:' | grep -E -q '.{80}.'; then - echo "$(basename "$1") --help output is too wide:" - "$1" --help | awk 'length > 80' | grep -E --color=yes '.{80}' - exit 1 + echo "$(basename "$1") --help output is too wide:" + "$1" --help | awk 'length > 80' | grep -E --color=yes '.{80}' + exit 1 fi # no --help output to stdout if "$1" --help 2>&1 1>/dev/null | grep .; then - echo "$(basename "$1") --help prints to stderr" - exit 2 + echo "$(basename "$1") --help prints to stderr" + exit 2 fi # error output to stderr if ! "$1" --no-such-parameter 2>&1 1>/dev/null | grep -q .; then - echo "$(basename "$1") with an unknown parameter does not print to stderr" - exit 3 + echo "$(basename "$1") with an unknown parameter does not print to stderr" + exit 3 fi diff --git a/tools/meson-git-contrib.sh b/tools/meson-git-contrib.sh index 514daa0949..b40e97ba62 100755 --- a/tools/meson-git-contrib.sh +++ b/tools/meson-git-contrib.sh @@ -2,8 +2,8 @@ set -eu git shortlog -s `git describe --abbrev=0`.. | \ - cut -c8- | \ - sed 's/ / /g' | \ - awk '{ print $$0 "," }' | \ - sed -e 's/ / /g' | \ - sort -u + cut -c8- | \ + sed 's/ / /g' | \ + awk '{ print $$0 "," }' | \ + sed -e 's/ / /g' | \ + sort -u diff --git a/tools/meson-hwdb-update.sh b/tools/meson-hwdb-update.sh index 8bdc58ac7f..39efd75192 100755 --- a/tools/meson-hwdb-update.sh +++ b/tools/meson-hwdb-update.sh @@ -5,23 +5,23 @@ cd "$1" unset permissive if [ "${2:-}" = "-p" ]; then - permissive=1 - shift + permissive=1 + shift else - permissive=0 + permissive=0 fi if [ "${2:-}" != "-n" ]; then ( - [ -z "$permissive" ] || set +e - set -x + [ -z "$permissive" ] || set +e + set -x - curl -L -o usb.ids 'http://www.linux-usb.org/usb.ids' - curl -L -o pci.ids 'http://pci-ids.ucw.cz/v2.2/pci.ids' - curl -L -o ma-large.txt 'http://standards-oui.ieee.org/oui/oui.txt' - curl -L -o ma-medium.txt 'http://standards-oui.ieee.org/oui28/mam.txt' - curl -L -o ma-small.txt 'http://standards-oui.ieee.org/oui36/oui36.txt' - curl -L -o pnp_id_registry.html 'https://uefi.org/uefi-pnp-export' - curl -L -o acpi_id_registry.html 'https://uefi.org/uefi-acpi-export' + curl -L -o usb.ids 'http://www.linux-usb.org/usb.ids' + curl -L -o pci.ids 'http://pci-ids.ucw.cz/v2.2/pci.ids' + curl -L -o ma-large.txt 'http://standards-oui.ieee.org/oui/oui.txt' + curl -L -o ma-medium.txt 'http://standards-oui.ieee.org/oui28/mam.txt' + curl -L -o ma-small.txt 'http://standards-oui.ieee.org/oui36/oui36.txt' + curl -L -o pnp_id_registry.html 'https://uefi.org/uefi-pnp-export' + curl -L -o acpi_id_registry.html 'https://uefi.org/uefi-acpi-export' ) fi set -x diff --git a/tools/meson-make-symlink.sh b/tools/meson-make-symlink.sh index 501cd43d47..da0d13a341 100755 --- a/tools/meson-make-symlink.sh +++ b/tools/meson-make-symlink.sh @@ -6,7 +6,7 @@ set -eu mkdir -vp "$(dirname "${DESTDIR:-}$2")" if [ "$(dirname $1)" = . ]; then - ln -vfs -T "$1" "${DESTDIR:-}$2" + ln -vfs -T "$1" "${DESTDIR:-}$2" else - ln -vfs -T --relative "${DESTDIR:-}$1" "${DESTDIR:-}$2" + ln -vfs -T --relative "${DESTDIR:-}$1" "${DESTDIR:-}$2" fi diff --git a/tools/meson-vcs-tag.sh b/tools/meson-vcs-tag.sh index c8033d00a1..a8605b6bc9 100755 --- a/tools/meson-vcs-tag.sh +++ b/tools/meson-vcs-tag.sh @@ -8,8 +8,8 @@ tag="$2" fallback="$3" if [ -n "$tag" ]; then - echo "$tag" - exit 0 + echo "$tag" + exit 0 fi # Apparently git describe has a bug where it always considers the work-tree diff --git a/tools/oss-fuzz.sh b/tools/oss-fuzz.sh index 9a116be114..610bb9c235 100755 --- a/tools/oss-fuzz.sh +++ b/tools/oss-fuzz.sh @@ -29,7 +29,7 @@ mkdir -p $build fuzzflag="oss-fuzz=true" if [ -z "$FUZZING_ENGINE" ]; then - fuzzflag="llvm-fuzz=true" + fuzzflag="llvm-fuzz=true" fi meson $build -D$fuzzflag -Db_lundef=false @@ -38,7 +38,7 @@ ninja -C $build fuzzers # The seed corpus is a separate flat archive for each fuzzer, # with a fixed name ${fuzzer}_seed_corpus.zip. 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 # get fuzz-dns-packet corpus diff --git a/travis-ci/managers/travis_wait.bash b/travis-ci/managers/travis_wait.bash index acf6ad15e4..59de6638d6 100644 --- a/travis-ci/managers/travis_wait.bash +++ b/travis-ci/managers/travis_wait.bash @@ -3,59 +3,59 @@ # as soon as Travis CI has started to provide an easy way to export the functions to bash scripts. travis_jigger() { - local cmd_pid="${1}" - shift - local timeout="${1}" - shift - local count=0 + local cmd_pid="${1}" + shift + local timeout="${1}" + shift + local count=0 - echo -e "\\n" + echo -e "\\n" - while [[ "${count}" -lt "${timeout}" ]]; do - count="$((count + 1))" - echo -ne "Still running (${count} of ${timeout}): ${*}\\r" - sleep 60 - done + while [[ "${count}" -lt "${timeout}" ]]; do + count="$((count + 1))" + echo -ne "Still running (${count} of ${timeout}): ${*}\\r" + sleep 60 + done - echo -e "\\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"${*}\"${ANSI_RESET}\\n" - kill -9 "${cmd_pid}" + echo -e "\\n${ANSI_RED}Timeout (${timeout} minutes) reached. Terminating \"${*}\"${ANSI_RESET}\\n" + kill -9 "${cmd_pid}" } travis_wait() { - local timeout="${1}" + local timeout="${1}" - if [[ "${timeout}" =~ ^[0-9]+$ ]]; then - shift - else - timeout=20 - fi + if [[ "${timeout}" =~ ^[0-9]+$ ]]; then + shift + else + timeout=20 + fi - local cmd=("${@}") - local log_file="travis_wait_${$}.log" + local cmd=("${@}") + local log_file="travis_wait_${$}.log" - "${cmd[@]}" &>"${log_file}" & - local cmd_pid="${!}" + "${cmd[@]}" &>"${log_file}" & + local cmd_pid="${!}" - travis_jigger "${!}" "${timeout}" "${cmd[@]}" & - local jigger_pid="${!}" - local result + travis_jigger "${!}" "${timeout}" "${cmd[@]}" & + local jigger_pid="${!}" + local result - { - set +e - wait "${cmd_pid}" 2>/dev/null - result="${?}" - ps -p"${jigger_pid}" &>/dev/null && kill "${jigger_pid}" - set -e - } + { + set +e + wait "${cmd_pid}" 2>/dev/null + result="${?}" + ps -p"${jigger_pid}" &>/dev/null && kill "${jigger_pid}" + set -e + } - if [[ "${result}" -eq 0 ]]; then - echo -e "\\n${ANSI_GREEN}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}" - else - echo -e "\\n${ANSI_RED}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}" - fi + if [[ "${result}" -eq 0 ]]; then + echo -e "\\n${ANSI_GREEN}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}" + else + echo -e "\\n${ANSI_RED}The command ${cmd[*]} exited with ${result}.${ANSI_RESET}" + fi - echo -e "\\n${ANSI_GREEN}Log:${ANSI_RESET}\\n" - cat "${log_file}" + echo -e "\\n${ANSI_GREEN}Log:${ANSI_RESET}\\n" + cat "${log_file}" - return "${result}" + return "${result}" } diff --git a/travis-ci/managers/xenial.sh b/travis-ci/managers/xenial.sh index af60114d34..4822bdd4b7 100755 --- a/travis-ci/managers/xenial.sh +++ b/travis-ci/managers/xenial.sh @@ -1,5 +1,4 @@ #!/bin/bash - set -e set -x diff --git a/travis-ci/scripts/build-docker-image.sh b/travis-ci/scripts/build-docker-image.sh index a18bf5fa85..69f9d69ce7 100755 --- a/travis-ci/scripts/build-docker-image.sh +++ b/travis-ci/scripts/build-docker-image.sh @@ -7,7 +7,7 @@ echo -e "\n\033[33;1mBuilding docker image: coverity-$TRAVIS_COMMIT.\033[0m" docker build \ ---build-arg DOCKER_USER=$USER \ ---build-arg DOCKER_USER_UID=`id -u` \ ---build-arg DOCKER_USER_GID=`id -g` \ ---force-rm -t coverity-${TRAVIS_COMMIT} --pull=true . + --build-arg DOCKER_USER=$USER \ + --build-arg DOCKER_USER_UID=`id -u` \ + --build-arg DOCKER_USER_GID=`id -g` \ + --force-rm -t coverity-${TRAVIS_COMMIT} --pull=true . diff --git a/travis-ci/tools/get-coverity.sh b/travis-ci/tools/get-coverity.sh index d364b541e2..3634e57ad6 100755 --- a/travis-ci/tools/get-coverity.sh +++ b/travis-ci/tools/get-coverity.sh @@ -18,18 +18,18 @@ sudo apt-get update && sudo apt-get -y install wget # Get coverity tool if [ ! -d $TOOL_BASE ]; then - # Download Coverity Scan Analysis Tool - if [ ! -e $TOOL_ARCHIVE ]; then - 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" - fi + # Download Coverity Scan Analysis Tool + if [ ! -e $TOOL_ARCHIVE ]; then + 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" + fi - # Extract Coverity Scan Analysis Tool - echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m" - mkdir -p $TOOL_BASE - pushd $TOOL_BASE - tar xzf $TOOL_ARCHIVE - popd + # Extract Coverity Scan Analysis Tool + echo -e "\033[33;1mExtracting Coverity Scan Analysis Tool...\033[0m" + mkdir -p $TOOL_BASE + pushd $TOOL_BASE + tar xzf $TOOL_ARCHIVE + popd fi echo -e "\033[33;1mCoverity Scan Analysis Tool can be found at $TOOL_BASE ...\033[0m" diff --git a/units/meson-add-wants.sh b/units/meson-add-wants.sh index e2b260398c..a483d75b86 100755 --- a/units/meson-add-wants.sh +++ b/units/meson-add-wants.sh @@ -6,23 +6,23 @@ target="$2" unit="$3" case "$target" in - */?*) # a path, but not just a slash at the end - dir="${DESTDIR:-}${target}" - ;; - *) - dir="${DESTDIR:-}${unitdir}/${target}" - ;; + */?*) # a path, but not just a slash at the end + dir="${DESTDIR:-}${target}" + ;; + *) + dir="${DESTDIR:-}${unitdir}/${target}" + ;; esac unitpath="${DESTDIR:-}${unitdir}/${unit}" case "$target" in - */) - mkdir -vp -m 0755 "$dir" - ;; - *) - mkdir -vp -m 0755 "$(dirname "$dir")" - ;; + */) + mkdir -vp -m 0755 "$dir" + ;; + *) + mkdir -vp -m 0755 "$(dirname "$dir")" + ;; esac ln -vfs --relative "$unitpath" "$dir" diff --git a/xorg/50-systemd-user.sh b/xorg/50-systemd-user.sh index 5588185c50..bfee5f691c 100755 --- a/xorg/50-systemd-user.sh +++ b/xorg/50-systemd-user.sh @@ -3,5 +3,5 @@ systemctl --user import-environment DISPLAY XAUTHORITY if command -v dbus-update-activation-environment >/dev/null 2>&1; then - dbus-update-activation-environment DISPLAY XAUTHORITY + dbus-update-activation-environment DISPLAY XAUTHORITY fi