summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xtools/notsd-fixup15
-rwxr-xr-xtools/notsd-fixup--includes57
2 files changed, 49 insertions, 23 deletions
diff --git a/tools/notsd-fixup b/tools/notsd-fixup
index feec1b8921..0bd5c10bd9 100755
--- a/tools/notsd-fixup
+++ b/tools/notsd-fixup
@@ -1,7 +1,10 @@
#!/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
+ find -type f -name Makefile | while read -r filename; do
sed -r -i "s|(/\.\.)*/config.mk|/$(realpath -ms --relative-to="${filename%/*}" config.mk)|" "$filename"
done
)
@@ -9,15 +12,19 @@ fixup_makefiles() (
fixup_includes() (
find $(find . -type d -name include) -type d | while read -r dir; do
lib="${dir##*/}"
- pushd "$dir"
+ pushd "$dir" >/dev/null
find . -type f -exec sed -ri -e "s|$lib/||" -- {} +
- popd
+ popd >/dev/null
done
- find src \( -name '*.h' -o -name '*.c' \) -type f -exec "$0"--includes {} \;
+ find src \( -name '*.h' -o -name '*.c' \) -type f | while read -r filename; do
+ "$0"--includes "$filename"
+ done
)
main() {
+ set -e
+ set -o pipefail
fixup_makefiles
fixup_includes
}
diff --git a/tools/notsd-fixup--includes b/tools/notsd-fixup--includes
index 957733cdc0..cd7638afd4 100755
--- a/tools/notsd-fixup--includes
+++ b/tools/notsd-fixup--includes
@@ -22,11 +22,34 @@ classify() {
out private "$path"
elif [[ "$path" != systemd/* ]] &&
[[ "$path" != libudev.h ]] &&
- cpp -include "$path" <<<'' &>/dev/null;
- then
+ cpp -include "$path" <<<'' &>/dev/null; then
out system "$path"
else
case "$path" in
+ *-to-name.h|*-from-name.h)
+ base="${path##*/}"
+ base="${base%-to-name.h}"
+ base="${base%-from-name.h}"
+ case "$base" in
+ dns_type) d=src/grp-resolve/systemd-resolved;;
+ keyboard-keys) d=src/grp-udev/libudev-core;;
+ af|arphrd|cap|errno) d=src/libbasic/include/basic;;
+ audit_type) d=src/libsystemd/src/sd-journal;;
+ *)
+ >&2 printf 'Unknown gperf base: %q\n' "$base"
+ >&2 printf 'Cannot figure out: %q\n' "$path"
+ exit 2
+ ;;
+ esac
+ file="$d/${path##*/}"
+ if [[ "$current_file" = "$d"/* ]]; then
+ out private "${file##*/}"
+ elif [[ "$file" = */include/* ]]; then
+ out protected "${file##*/include/}"
+ else
+ out protected "${file##*/}"
+ fi
+ ;;
asm/sgidefs.h|dbus/dbus.h|efi.h|efilib.h|gio/gio.h|glib.h|libmount.h)
out system "$path"
;;
@@ -88,13 +111,16 @@ phase0() {
esac
}
-phase1_tail=
-system=()
-linux=()
-public=()
-protected=()
-typedef=(); typedef_last=true
-private=()
+phase1_init() {
+ phase1_tail=
+ system=()
+ linux=()
+ public=()
+ protected=()
+ typedef=(); typedef_last=true
+ private=()
+}
+phase1_init
phase1_flush() {
local b=:
if [[ ${#system[@]} -gt 0 ]]; then
@@ -131,6 +157,7 @@ phase1_flush() {
printf '%s\n' "${typedef[@]}"
fi
printf '%s' "$phase1_tail"
+ phase1_init
}
phase1() {
phase=phase1
@@ -183,22 +210,14 @@ phase1() {
;;
*)
phase1_flush
- phase2 "$line"
+ phase0 "$line"
;;
esac
}
-phase2() {
- phase=phase2
- hook=:
- local line="$1"
- printf '%s\n' "$line"
- cat
-}
-
main() {
current_file="$1"
- printf ' => %s\n' "$current_file"
+ printf ' => %q %q\n' "$0" "$current_file"
set -o pipefail
trap 'rm -f -- "$current_file.tmp"' EXIT
{