diff options
author | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-09-11 19:36:48 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@sbcglobal.net> | 2016-09-11 19:47:19 -0400 |
commit | 43f8ba8f90bfd2bae7b779da0aeabfbb50038798 (patch) | |
tree | a1ef92976b9cb3df178bed673b6a9cc956fd50c5 /tools/notsd-fixup--includes | |
parent | 6eb4ef32385e786ec1910f274b1749dcfc623eee (diff) |
sync tools/ from postmove
Diffstat (limited to 'tools/notsd-fixup--includes')
-rwxr-xr-x | tools/notsd-fixup--includes | 63 |
1 files changed, 43 insertions, 20 deletions
diff --git a/tools/notsd-fixup--includes b/tools/notsd-fixup--includes index 957733cdc0..46deaa8e8e 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 { @@ -209,7 +228,11 @@ main() { done "$hook" } < "$current_file" > "$current_file.tmp" - mv -Tf "$current_file.tmp" "$current_file" + if cmp -s "$current_file.tmp" "$current_file"; then + rm -f "$current_file.tmp" || : + else + mv -Tf "$current_file.tmp" "$current_file" + fi } main "$@" |