diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-10-27 00:07:35 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-10-27 00:07:35 -0400 |
commit | 93fd8d3a035f6acb134adff0d6b34e7fba5e72af (patch) | |
tree | c90c8871f6fcf184651c266eff8075085987977e /tools/notsd-fixup | |
parent | 7b997776df38e196b4a779ee4e6be3acd0a363e2 (diff) | |
parent | f0f1df7d0a18ba2db795a610f27c1922cdbf6ed6 (diff) |
Merge branch 'notsystemd/postmove' into notsystemd/master
Diffstat (limited to 'tools/notsd-fixup')
-rwxr-xr-x | tools/notsd-fixup | 57 |
1 files changed, 16 insertions, 41 deletions
diff --git a/tools/notsd-fixup b/tools/notsd-fixup index 99ae0981a3..71b3bf4dfa 100755 --- a/tools/notsd-fixup +++ b/tools/notsd-fixup @@ -1,50 +1,25 @@ #!/usr/bin/env bash - -# The reason we do `find`/`while read`-loops instead of `find -exec` commands -# is that we want errors from the inner loop to bubble up. - -fixup_makefiles() ( - find "$@" -type f -name Makefile | while read -r filename; do - { - <"$filename" sed -r \ - -e "s|(/\.\.)*/config.mk|/$(realpath -ms --relative-to="$(dirname -- "$filename")" config.mk)|" \ - -e '/^nested\.subdirs/d' \ - -e '/^include \$\(topsrcdir\)\/build-aux\/Makefile\.tail\.mk$/d' - echo - find "$(dirname "$filename")" -mindepth 2 -maxdepth 2 -name Makefile -print0 | - xargs -r0 dirname -z -- | - xargs -r0 basename -a -z | - xargs -r0 printf 'nested.subdirs += %s\n' | sort - echo - echo 'include $(topsrcdir)/build-aux/Makefile.tail.mk' - } | cat -s | build-aux/write-ifchanged "$filename" - done -) - -fixup_includes() ( - dirs=($(find "$@" -type d -name include)) - if [[ ${#dirs[@]} -gt 0 ]]; then - find "${dirs[@]}" -type d | while read -r dir; do - printf '=> libdir %q\n' "$dir" - lib="${dir##*/}" - find "$dir" -type f | while read -r filename; do - printf ' => sed -ir %q %q\n' "s|$lib/||" "$filename" - sed -r "s|$lib/||" < "$filename" | build-aux/write-ifchanged "$filename" - done - done - fi - - find "$@" \( -name '*.h' -o -name '*.c' -o -name '*.gperf' \) -type f | while read -r filename; do - "$0"--includes "$filename" - done -) +# Copyright (C) 2015-2016 Luke Shumaker main() { set -e set -o pipefail export LC_COLLATE=C - fixup_makefiles "$@" - fixup_includes "$@" + + # We wrap the programs called by xargs with `sh` because xargs only exits early + # if the status is 255, but we want to exit early for all non-zero statuses. + # We use xargs instead of `find -exec` because `-exec` won't do much of + # anything useful with the exit status. + + # Makefiles + find "$@" -type f -name Makefile -print0 | + xargs -r0 sh -c "$0--makefiles \"\$@\" || exit 255" -- + + # C includes + rm -rf -- "$0"--includes.cache + find "$@" \( -name '*.h' -o -name '*.c' -o -name '*.gperf' -o -name '*.gperf.m4' \) -type f -print0 | + xargs -r0 sh -c "$0--includes \"\$@\" || exit 255" -- + rm -rf -- "$0"--includes.cache } main "$@" |