From 67cd422d20ffbd8be04e2a95803ef073b63237d0 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 21 Oct 2016 19:04:18 -0400 Subject: pull tools/notsd-* changes from notsystemd/master --- tools/notsd-fixup | 17 +++++++++++------ tools/notsd-fixup--includes | 17 ++++++----------- 2 files changed, 17 insertions(+), 17 deletions(-) (limited to 'tools') diff --git a/tools/notsd-fixup b/tools/notsd-fixup index 77df56fff4..99ae0981a3 100755 --- a/tools/notsd-fixup +++ b/tools/notsd-fixup @@ -22,12 +22,17 @@ fixup_makefiles() ( ) fixup_includes() ( - find $(find . -type d -name include) -type d | while read -r dir; do - lib="${dir##*/}" - pushd "$dir" >/dev/null - find . -type f -exec sed -ri -e "s|$lib/||" -- {} + - popd >/dev/null - done + 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" diff --git a/tools/notsd-fixup--includes b/tools/notsd-fixup--includes index 315be32c8d..33218233d5 100755 --- a/tools/notsd-fixup--includes +++ b/tools/notsd-fixup--includes @@ -33,7 +33,7 @@ classify() { 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;; + af|arphrd|cap|errno) d=src/libsystemd-basic/src;; audit_type) d=src/libsystemd/src/sd-journal;; *) >&2 printf 'Unknown gperf base: %q\n' "$base" @@ -57,7 +57,7 @@ classify() { if [[ "$current_file" = */systemd-boot/* ]]; then out private util.h else - out protected basic/util.h + out protected systemd-basic/util.h fi ;; *) @@ -77,6 +77,9 @@ classify() { */include/*) out protected "${file##*/include/}" ;; + */include-staging/*) + out protected "${file##*/include-staging/}" + ;; *) if [[ "${current_file%/*}" = "${file%/*}" ]]; then out private "${file##*/}" @@ -219,7 +222,6 @@ main() { current_file="$1" printf ' => %q %q\n' "$0" "$current_file" set -o pipefail - trap 'rm -f -- "$current_file.tmp"' EXIT { IFS='' while read -r line; do @@ -227,14 +229,7 @@ main() { IFS='' done "$hook" - } < "$current_file" > "$current_file.tmp" - # I specificially don't use write-ifchanged because I don't want the - # temporary file to have the .c suffix. - if cmp -s "$current_file.tmp" "$current_file"; then - rm -f "$current_file.tmp" || : - else - mv -Tf "$current_file.tmp" "$current_file" - fi + } < "$current_file" | build-aux/write-ifchanged "$current_file" } main "$@" -- cgit v1.2.3-54-g00ecf From 7cc82ea6f7682ce35c68fd5c13c1711e6b1eb64b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 21 Oct 2016 19:12:22 -0400 Subject: Add a script for finding renames, so I don't have to reinvent it every time --- tools/notsd-find-renames | 2 ++ 1 file changed, 2 insertions(+) create mode 100755 tools/notsd-find-renames (limited to 'tools') diff --git a/tools/notsd-find-renames b/tools/notsd-find-renames new file mode 100755 index 0000000000..fe90e325f6 --- /dev/null +++ b/tools/notsd-find-renames @@ -0,0 +1,2 @@ +#!/bin/sh +git diff --find-renames -l1000 --stat=300,290 "${1:-notsystemd/postmove}" "${2:-notsystemd/master}" |sed -n '/=>/s/\s*|.*//p' \ No newline at end of file -- cgit v1.2.3-54-g00ecf From 5e0446146dfc11e5653ff895630652733044e068 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 21 Oct 2016 19:25:11 -0400 Subject: more renames --- Makefile.am | 2 +- tools/notsd-move | 35 +++++++++++++++++++++-------------- 2 files changed, 22 insertions(+), 15 deletions(-) (limited to 'tools') diff --git a/Makefile.am b/Makefile.am index 1dabbb0819..f8d6d62a6b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1420,7 +1420,7 @@ CLEANFILES += \ #@src/libbasic/include/Makefile nested.subdirs += basic -#@src/libbasic/include/basic/Makefile +#@src/libbasic/include/systemd-basic/Makefile src/basic/errno-list.txt: $(AM_V_at)$(MKDIR_P) $(dir $@) $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - $@ diff --git a/tools/notsd-move b/tools/notsd-move index 2f6ad3f1b0..21609485a9 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -119,21 +119,22 @@ move_files() ( src/core/umount* mv -T src/{,lib}core - mv -T src/{,lib}basic - mv -T src/{,lib}shared + mv -T src/{,libsystemd-}basic + mv -T src/{,libsystemd-}shared - mv -T src/lib{shared,core}/linux + mv -T src/lib{systemd-shared,core}/linux mkdir src/libfirewall - mv -T src/lib{shared,firewall}/firewall-util.c - mv -T src/lib{shared,firewall}/firewall-util.h + mv -T src/lib{systemd-shared,firewall}/firewall-util.c + mv -T src/lib{systemd-shared,firewall}/firewall-util.h - split_lib src/libbasic + split_lib src/libcore + split_lib src/libsystemd-basic + split_lib src/libsystemd-shared split_lib src/libsystemd-network - split_lib src/libshared - mv src/libshared/{test,include/shared}/test-tables.h - rmdir src/libshared/test + mv src/libsystemd-shared/{test,include/systemd-shared}/test-tables.h + rmdir src/libsystemd-shared/test mkdir src/systemd-hibernate-resume-generator mv -t src/systemd-hibernate-resume-generator \ @@ -441,7 +442,7 @@ move_files() ( units/machine.slice* # muck - mv -t src/libbasic/include/basic src/libbasic/.gitignore + mv -t src/libsystemd-basic/include/systemd-basic src/libsystemd-basic/.gitignore mv -T {test,src/systemd-boot}/test-efi-create-disk.sh mv -t src/systemd-tmpfiles units/systemd-tmpfiles* mv -t src/systemd-tmpfiles \ @@ -698,7 +699,7 @@ breakup_makefile() ( sed -ri \ -e '/^[^# ]*:/ { s|\S+/|$(outdir)/|g }' \ - src/libbasic/include/basic/Makefile \ + src/libsystemd-basic/include/systemd-basic/Makefile \ src/libsystemd/src/Makefile \ src/libsystemd/src/sd-journal/Makefile \ src/grp-udev/libudev-core/Makefile @@ -722,8 +723,8 @@ breakup_makefile() ( ln -sT ../../grp-login/systemd-logind/logind-acl.h src/grp-udev/libudev-core/logind-acl.h ln -sT ../../libsystemd/src/sd-login/sd-login.c src/grp-udev/libudev-core/sd-login.c ln -sT ../../grp-login/systemd-logind/logind-acl.c src/grp-udev/libudev-core/logind-acl.c - ln -sT ../../../libshared/include/shared/gcrypt-util.h src/libsystemd/src/sd-journal/gcrypt-util.h - ln -sT ../../../libshared/src/gcrypt-util.c src/libsystemd/src/sd-journal/gcrypt-util.c + ln -sT ../../../libsystemd-shared/include/systemd-shared/gcrypt-util.h src/libsystemd/src/sd-journal/gcrypt-util.h + ln -sT ../../../libsystemd-shared/src/gcrypt-util.c src/libsystemd/src/sd-journal/gcrypt-util.c ln -sT ../grp-system/libcore/machine-id-setup.h src/systemd-machine-id-setup/machine-id-setup.h ln -sT ../grp-system/libcore/machine-id-setup.c src/systemd-machine-id-setup/machine-id-setup.c @@ -748,7 +749,13 @@ fixup_makefile() { -e '/^[^# ]*:/ { s|^(\s*)\S+/|\1$(outdir)/| }' \ -e 's|^if (.*)|ifneq ($(\1),)|' \ -e '/^\s*\$\(AM_(C|CPP|LD)FLAGS\b/d' \ - -e 's|--version-script=.*/([^/]+)\.sym|--version-script=$(srcdir)/\1.sym|g' + -e 's|--version-script=.*/([^/]+)\.sym|--version-script=$(srcdir)/\1.sym|g' \ + -e '#### Rename helpers ################' \ + -e 's|libbasic_la|libsystemd_basic_la|g' \ + -e 's|libshared_la|libsystemd_shared_la|g' \ + -e 's|libbasic|libsystemd-basic|g' \ + -e 's|libshared|libsystemd-shared|g' \ + -e 's|libsystemd-basic-dns|libbasic-dns|g' } breakup_zshcompletion() ( -- cgit v1.2.3-54-g00ecf From 16c51ffe4f609c238b163e08089fe7e381fec20a Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 21 Oct 2016 20:10:13 -0400 Subject: more --- tools/notsd-move | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/notsd-move b/tools/notsd-move index 21609485a9..3b29039883 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -133,6 +133,10 @@ move_files() ( split_lib src/libsystemd-shared split_lib src/libsystemd-network + mv -t src/libcore/src \ + src/libcore/linux \ + src/libcore/include/core/dbus*.h + mv src/libsystemd-shared/{test,include/systemd-shared}/test-tables.h rmdir src/libsystemd-shared/test @@ -154,6 +158,7 @@ move_files() ( src/resolve/.gitignore \ src/resolve/* rmdir src/resolve + split_lib src/libbasic-dns # src/import => src/{libimport,systemd-{export,importd,import}} mkdir src/libimport @@ -179,7 +184,7 @@ move_files() ( src/import/curl-util* rmdir src/import - # src/journal => src/.. + # src/journal => src/... mkdir src/libjournal-core mv -t src/libjournal-core \ src/journal/.gitignore \ @@ -222,6 +227,7 @@ move_files() ( src/journal/mmap-cache.h \ src/journal/sd-journal.c rmdir src/journal + split_lib src/libjournal-core # src/network => src/... mkdir src/systemd-networkd-wait-online @@ -649,6 +655,12 @@ move_files() ( src/systemd-path \ src/systemd-socket-activate + mv -t src/grp-udev \ + src/grp-udev/rules/* + cat src/grp-udev/rules/.gitignore >> src/grp-udev/.gitignore + rm src/grp-udev/rules/.gitignore + rmdir src/grp-udev/rules + mv -t src/systemd-timesyncd system-preset/??-timesyncd.preset for file in system-preset/??-*.preset; do base="${file##*/??-}" -- cgit v1.2.3-54-g00ecf From 3f1441073d64408c1f937be226369ab6b4072b39 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Fri, 21 Oct 2016 23:51:55 -0400 Subject: more --- tools/notsd-move | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'tools') diff --git a/tools/notsd-move b/tools/notsd-move index 3b29039883..a861d98c99 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -14,7 +14,7 @@ split_lib() { local d=$1 local t=("$d"/test-*) - if [[ -f ${t[0]} ]]; then + if [[ -e ${t[0]} ]]; then mkdir "$d/test" mv "$d"/test-* -t "$d/test" fi @@ -124,14 +124,15 @@ move_files() ( mv -T src/lib{systemd-shared,core}/linux - mkdir src/libfirewall - mv -T src/lib{systemd-shared,firewall}/firewall-util.c - mv -T src/lib{systemd-shared,firewall}/firewall-util.h + mkdir src/libsystemd-firewall + mv -T src/libsystemd-{shared,firewall}/firewall-util.c + mv -T src/libsystemd-{shared,firewall}/firewall-util.h split_lib src/libcore split_lib src/libsystemd-basic split_lib src/libsystemd-shared split_lib src/libsystemd-network + split_lib src/libsystemd-firewall mv -t src/libcore/src \ src/libcore/linux \ @@ -228,6 +229,7 @@ move_files() ( src/journal/sd-journal.c rmdir src/journal split_lib src/libjournal-core + mv -T src/libjournal-core/{,src/}journald-gperf.gperf # src/network => src/... mkdir src/systemd-networkd-wait-online @@ -661,6 +663,11 @@ move_files() ( rm src/grp-udev/rules/.gitignore rmdir src/grp-udev/rules + mv -t src/grp-journal/systemd-journald \ + src/grp-journal/catalog/.gitignore \ + src/grp-journal/catalog/* + rmdir src/grp-journal/catalog + mv -t src/systemd-timesyncd system-preset/??-timesyncd.preset for file in system-preset/??-*.preset; do base="${file##*/??-}" @@ -764,9 +771,11 @@ fixup_makefile() { -e 's|--version-script=.*/([^/]+)\.sym|--version-script=$(srcdir)/\1.sym|g' \ -e '#### Rename helpers ################' \ -e 's|libbasic_la|libsystemd_basic_la|g' \ - -e 's|libshared_la|libsystemd_shared_la|g' \ -e 's|libbasic|libsystemd-basic|g' \ -e 's|libshared|libsystemd-shared|g' \ + -e 's|libshared_la|libsystemd_shared_la|g' \ + -e 's|libfirewall|libsystemd-firewall|g' \ + -e 's|libfirewall_la|libsystemd_firewall_la|g' \ -e 's|libsystemd-basic-dns|libbasic-dns|g' } -- cgit v1.2.3-54-g00ecf From acbe2e3a644cb0fea2e9ead61cae2128f97413bb Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 22 Oct 2016 02:20:35 -0400 Subject: more --- tools/notsd-move | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/tools/notsd-move b/tools/notsd-move index a861d98c99..a62c9d138f 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -137,6 +137,14 @@ move_files() ( mv -t src/libcore/src \ src/libcore/linux \ src/libcore/include/core/dbus*.h + mv -T src/libcore/{src,include/core}/dbus-manager.h + mv -T src/libcore/{include/core,src}/audit-fd.h + mv -T src/libcore/{include/core,src}/load-dropin.h + mv -T src/libcore/{include/core,src}/locale-setup.h + mv -T src/libcore/{include/core,src}/selinux-access.h + mv -T src/libcore/{include/core,src}/transaction.h + mv -T src/libcore/{include/core,src}/unit-printf.h + mv -T src/libcore/{,src}/load-fragment-gperf.gperf.m4 mv src/libsystemd-shared/{test,include/systemd-shared}/test-tables.h rmdir src/libsystemd-shared/test @@ -251,15 +259,17 @@ move_files() ( src/network/test-* rmdir src/network - # src/machine => src/{machinectl,systemd-machined} - mkdir src/machinectl - mv -t src/machinectl \ - src/machine/machinectl* - mkdir src/systemd-machined + # src/machine => src/{machinectl,systemd-machined,libmachine-core} + mkdir src/machinectl src/systemd-machined src/libmachine-core + mv -T src/{machine,machinectl}/machinectl.c + mv -T src/{machine,systemd-machined}/machined.c mv -t src/systemd-machined \ src/machine/.gitignore \ + src/machine/org.* + mv -t src/libmachine-core \ src/machine/* rmdir src/machine + split_lib src/libmachine-core # src/coredump => src/{coredumpctl,systemd-coredump} mkdir src/coredumpctl @@ -469,7 +479,7 @@ move_files() ( mkdir src/libudev/include mv -T src/libudev/{src,include}/libudev.h mv -T src/{systemd-networkd,libnetworkd-core}/networkd.h - mv -T src/{systemd-resolved,libbasic-dns}/resolved-def.h + mv -T src/{systemd-resolved,libbasic-dns/include/basic-dns}/resolved-def.h mv -t src/cdrom_id rules/*cdrom* mv -t src/mtd_probe rules/*mtd* mv -t src/v4l_id rules/*v4l* -- cgit v1.2.3-54-g00ecf From be38937dd1322f1d85eb54226b0f4f33a16e8b53 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 22 Oct 2016 17:59:23 -0400 Subject: more --- tools/notsd-move | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'tools') diff --git a/tools/notsd-move b/tools/notsd-move index a62c9d138f..481bd59523 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -488,9 +488,10 @@ move_files() ( src/libsystemd/include/systemd/sd-ipv4* \ src/libsystemd/include/systemd/sd-lldp* \ src/libsystemd/include/systemd/sd-ndisc* - for l in device hwdb netlink network resolve; do - mv -T src/libsystemd/include/systemd/sd-$l.h src/libsystemd/src/sd-$l/sd-$l.h - done + mkdir src/libsystemd/include-staging{,/systemd-staging} + mv -t src/libsystemd/include-staging/systemd-staging \ + src/libsystemd/include/systemd/sd-{device,hwdb,netlink,network,resolve}.h + mkdir src/grp-journal.d mv -t src/grp-journal.d tmpfiles.d/journal-nocow.* mv -t src/grp-remote.d tmpfiles.d/systemd-remote.* @@ -616,6 +617,7 @@ move_files() ( src/systemd-inhibit \ src/systemd-logind grp src/grp-machine \ + src/libmachine-core \ src/machinectl \ src/nss-mymachines \ src/systemd-machined -- cgit v1.2.3-54-g00ecf From 782296ccf2049ef239130e7f1afe5bdb9bd12068 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sat, 22 Oct 2016 21:13:44 -0400 Subject: more --- tools/notsd-move | 77 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 40 insertions(+), 37 deletions(-) (limited to 'tools') diff --git a/tools/notsd-move b/tools/notsd-move index 481bd59523..a2190bac64 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -10,23 +10,30 @@ in_array() ( return 1 # Not Found ) -split_lib() { +split_lib() ( + shopt -s nullglob local d=$1 + local t - local t=("$d"/test-*) - if [[ -e ${t[0]} ]]; then + if t=("$d"/test-*) && [[ ${#t[@]} -gt 0 ]]; then mkdir "$d/test" - mv "$d"/test-* -t "$d/test" + mv -t "$d/test" -- "${t[@]}" fi - mkdir "$d/src" - mv "$d"/*.c -t "$d/src" + if t=("$d"/*.c) && [[ ${#t[@]} -gt 0 ]]; then + mkdir "$d/src" + mv -t "$d/src" -- "${t[@]}" + fi - local h=${d##*/lib} - mkdir "$d/include" - mkdir "$d/include/$h" - mv "$d"/*.h -t "$d/include/$h" -} + if t=("$d"/*.h) && [[ ${#t[@]} -gt 0 ]]; then + local h=${d##*/lib} + mkdir "$d/include" + mkdir "$d/include/$h" + mv -t "$d/include/$h" -- "${t[@]}" + else + return 1 + fi +) grp() { local grp=$1 @@ -128,11 +135,25 @@ move_files() ( mv -T src/libsystemd-{shared,firewall}/firewall-util.c mv -T src/libsystemd-{shared,firewall}/firewall-util.h + mkdir src/libsystemd-gcrypt + mv -T src/libsystemd-{shared,gcrypt}/gcrypt-util.c + mv -T src/libsystemd-{shared,gcrypt}/gcrypt-util.h + + mkdir src/libsystemd-blkid + mv -T src/libsystemd-{basic,blkid}/blkid-util.h + + mkdir src/libsystemd-microhttpd + mv -t src/libsystemd-microhttpd \ + src/journal-remote/microhttpd* + split_lib src/libcore split_lib src/libsystemd-basic split_lib src/libsystemd-shared split_lib src/libsystemd-network split_lib src/libsystemd-firewall + split_lib src/libsystemd-gcrypt + split_lib src/libsystemd-blkid + split_lib src/libsystemd-microhttpd mv -t src/libcore/src \ src/libcore/linux \ @@ -304,8 +325,7 @@ move_files() ( mv -t src/grp-remote.d \ src/journal-remote/.gitignore \ src/journal-remote/browse.html \ - src/journal-remote/log-generator.py \ - src/journal-remote/microhttpd* + src/journal-remote/log-generator.py rmdir src/journal-remote # src/locale => src/... @@ -460,7 +480,7 @@ move_files() ( units/machine.slice* # muck - mv -t src/libsystemd-basic/include/systemd-basic src/libsystemd-basic/.gitignore + mv -t src/libsystemd-basic/src src/libsystemd-basic/.gitignore mv -T {test,src/systemd-boot}/test-efi-create-disk.sh mv -t src/systemd-tmpfiles units/systemd-tmpfiles* mv -t src/systemd-tmpfiles \ @@ -598,6 +618,7 @@ move_files() ( src/systemd-hibernate-resume-generator \ src/systemd-sleep grp src/grp-remote \ + src/libsystemd-microhttpd \ src/systemd-journal-gatewayd \ src/systemd-journal-remote \ src/systemd-journal-upload @@ -735,29 +756,11 @@ breakup_makefile() ( src/libsystemd/src/sd-journal/Makefile \ src/grp-udev/libudev-core/Makefile - ln -sT ../grp-system/libcore/mount-setup.h src/systemd-remount-fs/mount-setup.h - ln -sT ../grp-system/libcore/mount-setup.c src/systemd-remount-fs/mount-setup.c - ln -sT ../libcore/mount-setup.h src/grp-system/systemd-shutdown/mount-setup.h - ln -sT ../libcore/mount-setup.c src/grp-system/systemd-shutdown/mount-setup.c - ln -sT ../libcore/killall.h src/grp-system/systemd-shutdown/killall.h - ln -sT ../libcore/killall.c src/grp-system/systemd-shutdown/killall.c - ln -sT ../../libcore/mount-setup.h src/grp-system/grp-utils/systemd-fstab-generator/mount-setup.h - ln -sT ../../libcore/mount-setup.c src/grp-system/grp-utils/systemd-fstab-generator/mount-setup.c - ln -sT ../grp-system/libcore/mount-setup.h src/systemd-nspawn/mount-setup.h - ln -sT ../grp-system/libcore/loopback-setup.h src/systemd-nspawn/loopback-setup.h - ln -sT ../grp-system/libcore/loopback-setup.c src/systemd-nspawn/loopback-setup.c - ln -sT ../grp-system/libcore/machine-id-setup.h src/systemd-nspawn/machine-id-setup.h - ln -sT ../grp-system/libcore/machine-id-setup.c src/systemd-nspawn/machine-id-setup.c - ln -sT ../grp-system/libcore/mount-setup.c src/systemd-nspawn/mount-setup.c - ln -sT ../../../libsystemd/include/systemd/_sd-common.h src/libsystemd-network/include/systemd-network/_sd-common.h - ln -sT ../../libsystemd/include/systemd/_sd-common.h src/grp-utils/systemd-path/_sd-common.h - ln -sT ../../grp-login/systemd-logind/logind-acl.h src/grp-udev/libudev-core/logind-acl.h - ln -sT ../../libsystemd/src/sd-login/sd-login.c src/grp-udev/libudev-core/sd-login.c - ln -sT ../../grp-login/systemd-logind/logind-acl.c src/grp-udev/libudev-core/logind-acl.c - ln -sT ../../../libsystemd-shared/include/systemd-shared/gcrypt-util.h src/libsystemd/src/sd-journal/gcrypt-util.h - ln -sT ../../../libsystemd-shared/src/gcrypt-util.c src/libsystemd/src/sd-journal/gcrypt-util.c - ln -sT ../grp-system/libcore/machine-id-setup.h src/systemd-machine-id-setup/machine-id-setup.h - ln -sT ../grp-system/libcore/machine-id-setup.c src/systemd-machine-id-setup/machine-id-setup.c + ln -srT src/libsystemd/include/systemd/_sd-common.h src/libsystemd-network/include/systemd-network/_sd-common.h + ln -srT src/libsystemd/include/systemd/_sd-common.h src/grp-utils/systemd-path/_sd-common.h + ln -srT src/grp-login/systemd-logind/logind-acl.h src/grp-udev/libudev-core/logind-acl.h + ln -srT src/grp-login/systemd-logind/logind-acl.c src/grp-udev/libudev-core/logind-acl.c + ln -srT src/libsystemd/src/sd-login/sd-login.c src/grp-udev/libudev-core/sd-login.c ln -sT ../subdir.mk src/libsystemd/src/sd-network/Makefile ln -sT ../subdir.mk src/libsystemd/src/sd-bus/Makefile -- cgit v1.2.3-54-g00ecf From 434b9800e88bcc9e451b4c4b709e61f5a6992f49 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 23 Oct 2016 12:10:04 -0400 Subject: tools/notsd-fixup--includes: clean up, add caching So now it should cache calls to `cpp` or filesystem checks, which are comparatively expensive. --- tools/.gitignore | 1 + tools/notsd-fixup | 6 +- tools/notsd-fixup--includes | 295 ++++++++++++++++++++++++++++++-------------- 3 files changed, 203 insertions(+), 99 deletions(-) create mode 100644 tools/.gitignore (limited to 'tools') diff --git a/tools/.gitignore b/tools/.gitignore new file mode 100644 index 0000000000..4bba404d19 --- /dev/null +++ b/tools/.gitignore @@ -0,0 +1 @@ +/notsd-fixup--includes.cache diff --git a/tools/notsd-fixup b/tools/notsd-fixup index 99ae0981a3..aa4bf4a10d 100755 --- a/tools/notsd-fixup +++ b/tools/notsd-fixup @@ -25,18 +25,18 @@ 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" + >&2 printf ' => sed -r %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" + "$0"--includes "$filename" | build-aux/write-ifchanged "$filename" done + rm -rf -- "$0"--includes.cache ) main() { diff --git a/tools/notsd-fixup--includes b/tools/notsd-fixup--includes index 33218233d5..9dfa7d0604 100755 --- a/tools/notsd-fixup--includes +++ b/tools/notsd-fixup--includes @@ -1,28 +1,48 @@ #!/usr/bin/env bash -panic() { - >&2 echo panic - exit 2 -} +# Requires Bash 4.2 or higher (for `test -v`). + +# If you are thinking "this file looks gross!", it is. It +# started out as a set of Bash one-liners. Which got turned +# into a script. Which grew somewhat organically. Not huge, +# but given that it started as some one liners, that's not a +# very pretty several hundred lines. So yes, it is gross. +# Rewrites welcome; just don't introduce any behavioral changes +# (easy since `tools/notsd-move` runs it on the entire repo and +# puts the results in git history). + +################################################################ +# Everything else in this program is just fluff and bookkeeping +# around around calling classify(). out() { - printf '%q ' "$@" + _ret_class=$1 + _ret_path=$2 } -# system -# linux -# public -# protected -# private +# Return a tuple of (class/group, path); which is a class that +# the header path belongs to, and a normalized path for it. +# +# There are a fixed number of classes that it may put a header +# in; in order of most-public to most-private: +# +# system +# linux +# public +# protected +# private +# +# This uses the global variable `expensive`. classify() { - local path=$1 + local current_file=$1 + local path=$2 if [[ "$path" = linux/* ]]; then out linux "$path" - elif [[ -f "${current_file%/*}/${path}" ]]; then + elif expensive.exists "${current_file%/*}/${path}"; then out private "$path" elif [[ "$path" != systemd/* ]] && [[ "$path" != libudev.h ]] && - cpp -include "$path" <<<'' &>/dev/null; then + expensive.cpp "$path"; then out system "$path" else case "$path" in @@ -38,7 +58,7 @@ classify() { *) >&2 printf 'Unknown gperf base: %q\n' "$base" >&2 printf 'Cannot figure out: %q\n' "$path" - exit 2 + return 2 ;; esac file="$d/${path##*/}" @@ -61,7 +81,7 @@ classify() { fi ;; *) - file=$(find src -type f -name "${path##*/}") + file=$(expensive.find "${path##*/}") if [[ -f "$file" ]]; then case "$file" in */src/*) @@ -90,146 +110,229 @@ classify() { esac else >&2 printf 'Cannot figure out: %q\n' "$path" - exit 2 + return 2 fi ;; esac fi } -phase=phase0 -hook=: +################################################################ +# Cache expensive things -phase0() { - phase=phase0 - hook=: - local line="$1" - case "$line" in - '#include'*|'typedef '*';') - phase1 "$line" - ;; - *) - printf '%s\n' "$line" - ;; - esac +cache.init_cpp() { + if ! [[ -v _cache_cpp[@] ]]; then + if [[ -f "$0.cache/cpp" ]]; then + . "$0.cache/cpp" + else + declare -gA _cache_cpp=() + fi + fi +} + +cache.save_cpp() { + cache.init_cpp + mkdir -p "$0.cache" + declare -p _cache_cpp | sed 's/-/-g/' > "$0.cache/cpp" +} + + +cache.init_fs() { + if ! [[ -v _cache_fs ]]; then + if ! [[ -f "$0.cache/fs" ]]; then + >&2 echo expensive fs.find + mkdir -p "$0.cache" + find src -name '*.h' \( -type l -printf 'l %p\n' -o -type f -printf 'f %p\n' \) > "$0.cache/fs" + fi + declare -g _cache_fs=true + fi +} + +expensive.cpp() { + local path=$1 + cache.init_cpp + if [[ -z "${_cache_cpp[$path]}" ]]; then + >&2 echo expensive cpp "$path" + local r + r=0; cpp -include "$path" <<<'' &>/dev/null || r=$? + _cache_cpp[$path]=$r + fi + return ${_cache_cpp[$path]} +} + +expensive.exists() { + local path=$1 + cache.init_fs + grep -qFx \ + -e "l $path" \ + -e "f $path" \ + < "$0.cache/fs" } -phase1_init() { - phase1_tail= - system=() - linux=() - public=() - protected=() - typedef=(); typedef_last=true - private=() +expensive.find() { + local name=$1 + cache.init_fs + sed -n "/^f .*\/${name//./\\.}\$/s/^f //p" < "$0.cache/fs" } -phase1_init -phase1_flush() { + +################################################################ +# Data structure for storing a chunk of `#include` lines. + +includes.init() { + _includes_trailing_nl= + _includes_system=() + _includes_linux=() + _includes_public=() + _includes_protected=() + _includes_typedef=() + _includes_typedef_last=true + _includes_private=() +} +includes.print() { local b=: - if [[ ${#system[@]} -gt 0 ]]; then - printf '%s\n' "${system[@]}" | sort -u + if [[ ${#_includes_system[@]} -gt 0 ]]; then + printf '%s\n' "${_includes_system[@]}" | sort -u b=echo fi - if [[ ${#linux[@]} -gt 0 ]]; then + if [[ ${#_includes_linux[@]} -gt 0 ]]; then $b - printf '%s\n' "${linux[@]}" + printf '%s\n' "${_includes_linux[@]}" b=echo fi - if [[ ${#public[@]} -gt 0 ]]; then + if [[ ${#_includes_public[@]} -gt 0 ]]; then $b - printf '%s\n' "${public[@]}" | sort -u + printf '%s\n' "${_includes_public[@]}" | sort -u b=echo fi - if [[ ${#protected[@]} -gt 0 ]]; then + if [[ ${#_includes_protected[@]} -gt 0 ]]; then $b - printf '%s\n' "${protected[@]}" | sort -u + printf '%s\n' "${_includes_protected[@]}" | sort -u b=echo fi - if [[ ${#typedef[@]} -gt 0 ]] && ! $typedef_last; then + if [[ ${#_includes_typedef[@]} -gt 0 ]] && ! $_includes_typedef_last; then $b printf '%s\n' "${typedef[@]}" | sort -u b=echo fi - if [[ ${#private[@]} -gt 0 ]]; then + if [[ ${#_includes_private[@]} -gt 0 ]]; then $b - printf '%s\n' "${private[@]}" | sort -u + printf '%s\n' "${_includes_private[@]}" | sort -u b=echo fi - if [[ ${#typedef[@]} -gt 0 ]] && $typedef_last; then + if [[ ${#_includes_typedef[@]} -gt 0 ]] && $_includes_typedef_last; then $b - printf '%s\n' "${typedef[@]}" + printf '%s\n' "${_includes_typedef[@]}" fi - printf '%s' "$phase1_tail" - phase1_init + printf '%s' "$_includes_trailing_nl" +} +includes.add() { + local class=$1 + local path=$2 + local extra=$3 + local line + case "$class" in + system) + printf -v line '#include <%s>%s' "$path" "$extra" + _includes_system+=("$line") + ;; + linux) + printf -v line '#include <%s>%s' "$path" "$extra" + _includes_linux+=("$line") + ;; + public) + printf -v line '#include <%s>%s' "$path" "$extra" + _includes_public+=("$line") + ;; + protected) + printf -v line '#include "%s"%s' "$path" "$extra" + _includes_protected+=("$line") + ;; + private) + if [[ ${#typedef[@]} -gt 0 ]]; then + _includes_typedef_last=false + fi + printf -v line '#include "%s"%s' "$path" "$extra" + _includes_private+=("$line") + ;; + *) + >&2 printf 'Invalid include class: %q\n' "$class" + return 2 + ;; + esac } + +################################################################ +# The main program loop + +panic() { + >&2 echo panic + exit 2 +} + +phase0() { + phase=phase0 + hook=: + local filename="$1" + local line="$2" + case "$line" in + '#include'*|'typedef '*';') + includes.init + phase1 "$filename" "$line" + ;; + *) + printf '%s\n' "$line" + ;; + esac +} + phase1() { phase=phase1 - hook=phase1_flush - local line="$1" + hook=includes.print + local filename="$1" + local line="$2" case "$line" in '') - phase1_tail+=$'\n' + _includes_trailing_nl+=$'\n' ;; '#include'*) - phase1_tail='' + _includes_trailing_nl='' local re='^#include [<"]([^">]*)[">](.*)' if [[ "$line" =~ $re ]]; then - IFS=' ' - local buf - buf="$(classify "${BASH_REMATCH[1]}")" || panic - read -r class path <<<"$buf" - case "$class" in - system) - printf -v line '#include <%s>%s' "$path" "${BASH_REMATCH[2]}" - system+=("$line") - ;; - linux) - printf -v line '#include <%s>%s' "$path" "${BASH_REMATCH[2]}" - linux+=("$line") - ;; - public) - printf -v line '#include <%s>%s' "$path" "${BASH_REMATCH[2]}" - public+=("$line") - ;; - protected) - printf -v line '#include "%s"%s' "$path" "${BASH_REMATCH[2]}" - protected+=("$line") - ;; - private) - if [[ ${#typedef[@]} -gt 0 ]]; then - typedef_last=false - fi - printf -v line '#include "%s"%s' "$path" "${BASH_REMATCH[2]}" - private+=("$line") - ;; - esac + # OK, this is gross, but we want to avoid creating a subshell + local _ret_class _ret_path + classify "$filename" "${BASH_REMATCH[1]}" || panic + includes.add "$_ret_class" "$_ret_path" "${BASH_REMATCH[2]}" || panic else panic fi ;; 'typedef '*';') - phase1_tail='' - typedef+=("$line") + _includes_trailing_nl='' + _includes_typedef+=("$line") ;; *) - phase1_flush - phase0 "$line" + includes.print + phase0 "$filename" "$line" ;; esac } +phase=phase0 +hook=: + main() { - current_file="$1" - printf ' => %q %q\n' "$0" "$current_file" + local filename="$1" + >&2 printf ' => %q %q\n' "$0" "$filename" set -o pipefail { IFS='' while read -r line; do - "$phase" "$line" + "$phase" "$filename" "$line" IFS='' done "$hook" - } < "$current_file" | build-aux/write-ifchanged "$current_file" + } < "$filename" + cache.save_cpp } main "$@" -- cgit v1.2.3-54-g00ecf From 77501fe72f21618fd6c290013b8151170f73247b Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Sun, 23 Oct 2016 12:11:52 -0400 Subject: tools/notsd-move: avoid invoking the editor for the merge commit --- tools/notsd-move | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/notsd-move b/tools/notsd-move index a2190bac64..fcb9eaff4b 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -852,7 +852,7 @@ main() { git commit -m './tools/notsd-move' git merge -s ours notsystemd/postmove git checkout notsystemd/postmove - git merge tmp/postmove + git merge --no-edit tmp/postmove git branch -d tmp/postmove } -- cgit v1.2.3-54-g00ecf From 9825b6a50a433f15cc0b5baaea2f63eac47fe54e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Mon, 24 Oct 2016 00:17:07 -0400 Subject: tools/notsd-fixup--includes: port from bash to python for speed This shaves off a decent chunk of time because Bash read(1) is slow because it can't buffer and has to read(2) one byte at a time. --- tools/notsd-fixup | 21 +- tools/notsd-fixup--includes | 523 ++++++++++++++++++++------------------------ 2 files changed, 252 insertions(+), 292 deletions(-) (limited to 'tools') diff --git a/tools/notsd-fixup b/tools/notsd-fixup index aa4bf4a10d..1d4287b259 100755 --- a/tools/notsd-fixup +++ b/tools/notsd-fixup @@ -1,4 +1,5 @@ #!/usr/bin/env bash +# Copyright (C) 2015-2016 Luke Shumaker # 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. @@ -34,7 +35,25 @@ fixup_includes() ( fi find "$@" \( -name '*.h' -o -name '*.c' -o -name '*.gperf' \) -type f | while read -r filename; do - "$0"--includes "$filename" | build-aux/write-ifchanged "$filename" + false + # We copy the write-ifchanged logic to here, because we have a + # higher-than usual chance of the main command failing. In a + # Makefile we would handle this by setting .DELETE_ON_ERROR:, + # but we can't do that here, so we have to inter-mingle the + # logics. + local outfile="$filename" + tmpfile="$(dirname "$outfile")/.tmp.${outfile##*/}.tmp" + local r=0 + "$0"--includes "$filename" > "$tmpfile" || r=$? + if [[ $r != 0 ]]; then + rm -f "$tmpfile" || : + (exit $r) + fi + if cmp -s "$tmpfile" "$outfile"; then + rm -f "$tmpfile" || : + else + mv -f "$tmpfile" "$outfile" + fi done rm -rf -- "$0"--includes.cache ) diff --git a/tools/notsd-fixup--includes b/tools/notsd-fixup--includes index 9dfa7d0604..196fd488a3 100755 --- a/tools/notsd-fixup--includes +++ b/tools/notsd-fixup--includes @@ -1,25 +1,26 @@ -#!/usr/bin/env bash - -# Requires Bash 4.2 or higher (for `test -v`). +#!/usr/bin/env python3 # If you are thinking "this file looks gross!", it is. It # started out as a set of Bash one-liners. Which got turned # into a script. Which grew somewhat organically. Not huge, # but given that it started as some one liners, that's not a -# very pretty several hundred lines. So yes, it is gross. +# very pretty several hunderd lines. Then got fairly litterally +# translated into this, for speed. So yes, it is gross. # Rewrites welcome; just don't introduce any behavioral changes # (easy since `tools/notsd-move` runs it on the entire repo and # puts the results in git history). +import json +import os +import re +import shlex +import subprocess +import sys + ################################################################ # Everything else in this program is just fluff and bookkeeping # around around calling classify(). -out() { - _ret_class=$1 - _ret_path=$2 -} - # Return a tuple of (class/group, path); which is a class that # the header path belongs to, and a normalized path for it. # @@ -31,308 +32,248 @@ out() { # public # protected # private -# -# This uses the global variable `expensive`. -classify() { - local current_file=$1 - local path=$2 - if [[ "$path" = linux/* ]]; then - out linux "$path" - elif expensive.exists "${current_file%/*}/${path}"; then - out private "$path" - elif [[ "$path" != systemd/* ]] && - [[ "$path" != libudev.h ]] && - expensive.cpp "$path"; 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/libsystemd-basic/src;; - audit_type) d=src/libsystemd/src/sd-journal;; - *) - >&2 printf 'Unknown gperf base: %q\n' "$base" - >&2 printf 'Cannot figure out: %q\n' "$path" - return 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" - ;; - util.h|*/util.h) - if [[ "$current_file" = */systemd-boot/* ]]; then - out private util.h - else - out protected systemd-basic/util.h - fi - ;; - *) - file=$(expensive.find "${path##*/}") - if [[ -f "$file" ]]; then - case "$file" in - */src/*) - if [[ "${current_file%/*}" = "${file%/*}" ]]; then - out private "${file##*/}" - else - out protected "${file##*/src/}" - fi - ;; - */libsystemd/include/*|*/libudev/include/*) - out public "${file##*/include/}" - ;; - */include/*) - out protected "${file##*/include/}" - ;; - */include-staging/*) - out protected "${file##*/include-staging/}" - ;; - *) - if [[ "${current_file%/*}" = "${file%/*}" ]]; then - out private "${file##*/}" - else - out protected "${file##*/}" - fi - ;; - esac - else - >&2 printf 'Cannot figure out: %q\n' "$path" - return 2 - fi - ;; - esac - fi -} +def classify(expensive, current_file, path): + if path.startswith('linux/'): + return 'linux', path + elif expensive.exists(os.path.join(os.path.dirname(current_file), path)): + return 'private', path + elif not path.startswith('systemd/') and path != 'libudev.h' and expensive.cpp(path): + return 'system', path + else: + if path.endswith('-to-name.h') or path.endswith('-from-name.h'): + base = re.fullmatch('(.*)-(to|from)-name\.h', os.path.basename(path)).group(1) + d={ + 'dns_type' : 'src/grp-resolve/systemd-resolved', + 'keyboard-keys' : 'src/grp-udev/libudev-core', + 'af' : 'src/libsystemd-basic/src', + 'arphrd' : 'src/libsystemd-basic/src', + 'cap' : 'src/libsystemd-basic/src', + 'errno' : 'src/libsystemd-basic/src', + 'audit_type' : 'src/libsystemd/src/sd-journal', + } + file = os.path.join(d[base], os.path.basename(path)) + if current_file.startswith(d[base]): + return 'private', os.path.basename(file) + elif '/include/' in file: + return 'protected', re.sub('.*/include/', '', file) + else: + return 'protected', os.path.basename(file) + elif path in [ 'asm/sgidefs.h', 'dbus/dbus.h', 'efi.h', 'efilib.h', 'gio/gio.h', 'glib.h', 'libmount.h' ]: + return 'system', path + elif os.path.basename(path) == 'util.h': + if '/systemd-boot/' in current_file: + return 'private', 'util.h' + else: + return 'protected', 'systemd-basic/util.h' + else: + find = expensive.find(os.path.basename(path)) + if len(find) == 1: + file = find[0] + if '/src/' in file: + if os.path.dirname(current_file) == os.path.dirname(file): + return 'private', os.path.basename(file) + else: + return 'protected', re.sub('.*/src/', '', file) + elif ('/libsystemd/include/' in file) or ('/libudev/include/' in file): + return 'public', re.sub('.*/include/', '', file) + elif '/include/' in file: + return 'protected', re.sub('.*/include/', '', file) + elif '/include-staging/' in file: + return 'protected', re.sub('.*/include-staging/', '', file) + else: + if os.path.dirname(current_file) == os.path.dirname(file): + return 'private', os.path.basename(file) + else: + return 'protected', os.path.basename(file) + else: + sys.exit('Cannot figure out: {0}'.format(path)) ################################################################ # Cache expensive things -cache.init_cpp() { - if ! [[ -v _cache_cpp[@] ]]; then - if [[ -f "$0.cache/cpp" ]]; then - . "$0.cache/cpp" - else - declare -gA _cache_cpp=() - fi - fi -} +class Cache: + def __init__(self, filename): + self.cache = { + 'find': None, + 'cpp': {} + } + self.dirty = True + + if os.path.isfile(filename): + with open(filename) as file: + self.cache = json.load(file) + self.dirty = False -cache.save_cpp() { - cache.init_cpp - mkdir -p "$0.cache" - declare -p _cache_cpp | sed 's/-/-g/' > "$0.cache/cpp" -} + def save(self, filename): + if self.dirty: + with open(filename, 'w') as file: + json.dump(self.cache, file) + def real_cpp(path): + # `cpp -include "$path" <<<'' &>/dev/null` + print(' -> cpp({0})'.format(path), file=sys.stderr) + with subprocess.Popen(['cpp', '-include', path], + stdin=subprocess.PIPE, + stdout=subprocess.DEVNULL, + stderr=subprocess.DEVNULL) as proc: + proc.stdin.close() + return proc.wait() == 0 -cache.init_fs() { - if ! [[ -v _cache_fs ]]; then - if ! [[ -f "$0.cache/fs" ]]; then - >&2 echo expensive fs.find - mkdir -p "$0.cache" - find src -name '*.h' \( -type l -printf 'l %p\n' -o -type f -printf 'f %p\n' \) > "$0.cache/fs" - fi - declare -g _cache_fs=true - fi -} + def real_find(): + # This can probably be done with os.walk or something, + # but since it is only called once, it isn't a good + # place to start optimizing. + # + # `find src -name '*.h' \( -type l -printf 'l %p\n' -o -type f -printf 'f %p\n' \)` + print(' -> find()', file=sys.stderr) + ret = {} + with subprocess.Popen(['find', 'src', '-name', '*.h', '(', '-type', 'l', '-printf', 'l %p\n', '-o', '-type', 'f', '-printf', 'f %p\n', ')'], + stdin=subprocess.DEVNULL, + stdout=subprocess.PIPE, universal_newlines=True, + stderr=subprocess.DEVNULL) as proc: + for line in proc.stdout: + t, p = line.rstrip('\n').split(' ', 1) + ret[p]=t + return ret -expensive.cpp() { - local path=$1 - cache.init_cpp - if [[ -z "${_cache_cpp[$path]}" ]]; then - >&2 echo expensive cpp "$path" - local r - r=0; cpp -include "$path" <<<'' &>/dev/null || r=$? - _cache_cpp[$path]=$r - fi - return ${_cache_cpp[$path]} -} + def cpp(self, path): + # `cpp -include "$path" <<<'' &>/dev/null` + if path not in self.cache['cpp']: + self.cache['cpp'][path] = Cache.real_cpp(path) + self.dirty = True + return self.cache['cpp'][path] -expensive.exists() { - local path=$1 - cache.init_fs - grep -qFx \ - -e "l $path" \ - -e "f $path" \ - < "$0.cache/fs" -} + def exists(self, path): + # `test -f "$path"` + if not self.cache['find']: + self.cache['find'] = Cache.real_find() + self.dirty = True + return path in self.cache['find'] -expensive.find() { - local name=$1 - cache.init_fs - sed -n "/^f .*\/${name//./\\.}\$/s/^f //p" < "$0.cache/fs" -} + def find(self, name): + # `find src -type f -name "$name"` + if not self.cache['find']: + self.cache['find'] = Cache.real_find() + self.dirty = True + return [p for p in self.cache['find'].keys() if self.cache['find'][p]=='f' and os.path.basename(p) == name] ################################################################ # Data structure for storing a chunk of `#include` lines. -includes.init() { - _includes_trailing_nl= - _includes_system=() - _includes_linux=() - _includes_public=() - _includes_protected=() - _includes_typedef=() - _includes_typedef_last=true - _includes_private=() -} -includes.print() { - local b=: - if [[ ${#_includes_system[@]} -gt 0 ]]; then - printf '%s\n' "${_includes_system[@]}" | sort -u - b=echo - fi - if [[ ${#_includes_linux[@]} -gt 0 ]]; then - $b - printf '%s\n' "${_includes_linux[@]}" - b=echo - fi - if [[ ${#_includes_public[@]} -gt 0 ]]; then - $b - printf '%s\n' "${_includes_public[@]}" | sort -u - b=echo - fi - if [[ ${#_includes_protected[@]} -gt 0 ]]; then - $b - printf '%s\n' "${_includes_protected[@]}" | sort -u - b=echo - fi - if [[ ${#_includes_typedef[@]} -gt 0 ]] && ! $_includes_typedef_last; then - $b - printf '%s\n' "${typedef[@]}" | sort -u - b=echo - fi - if [[ ${#_includes_private[@]} -gt 0 ]]; then - $b - printf '%s\n' "${_includes_private[@]}" | sort -u - b=echo - fi - if [[ ${#_includes_typedef[@]} -gt 0 ]] && $_includes_typedef_last; then - $b - printf '%s\n' "${_includes_typedef[@]}" - fi - printf '%s' "$_includes_trailing_nl" -} -includes.add() { - local class=$1 - local path=$2 - local extra=$3 - local line - case "$class" in - system) - printf -v line '#include <%s>%s' "$path" "$extra" - _includes_system+=("$line") - ;; - linux) - printf -v line '#include <%s>%s' "$path" "$extra" - _includes_linux+=("$line") - ;; - public) - printf -v line '#include <%s>%s' "$path" "$extra" - _includes_public+=("$line") - ;; - protected) - printf -v line '#include "%s"%s' "$path" "$extra" - _includes_protected+=("$line") - ;; - private) - if [[ ${#typedef[@]} -gt 0 ]]; then - _includes_typedef_last=false - fi - printf -v line '#include "%s"%s' "$path" "$extra" - _includes_private+=("$line") - ;; - *) - >&2 printf 'Invalid include class: %q\n' "$class" - return 2 - ;; - esac -} +class IncludeSection: + def __init__(self): + self.trailing_nl = '' + self.system = [] + self.linux = [] + self.public = [] + self.protected = [] + self.typedef = [] + self.typedef_last = True + self.private = [] + def print(self, file=sys.stdout): + b='' + if len(self.system) > 0: + for line in sorted(set(self.system)): + print(line, file=file) + b='\n' + if len(self.linux) > 0: + print(b, end='', file=file) + for line in self.linux: + print(line, file=file) + b='\n' + if len(self.public) > 0: + print(b, end='', file=file) + for line in sorted(set(self.public)): + print(line, file=file) + b='\n' + if len(self.protected) > 0: + print(b, end='', file=file) + for line in sorted(set(self.protected)): + print(line, file=file) + b='\n' + if len(self.typedef) > 0 and not self.typedef_last: + print(b, end='', file=file) + for line in sorted(set(self.typedef)): + print(line, file=file) + b='\n' + if len(self.private) > 0: + print(b, end='', file=file) + for line in sorted(set(self.private)): + print(line, file=file) + b='\n' + if len(self.typedef) > 0 and self.typedef_last: + print(b, end='', file=file) + for line in sorted(set(self.typedef)): + print(line, file=file) + print(self.trailing_nl, end='', file=file) + def add(self, group, path, extra): + if group == 'system': + self.system.append('#include <{0}>{1}'.format(path, extra)) + elif group == 'linux': + self.linux.append('#include <{0}>{1}'.format(path, extra)) + elif group == 'public': + self.public.append('#include <{0}>{1}'.format(path, extra)) + elif group == 'protected': + self.protected.append('#include "{0}"{1}'.format(path, extra)) + elif group == 'private': + if len(self.typedef) > 0: + self.typedef_last = False + self.private.append('#include "{0}"{1}'.format(path, extra)) + else: + sys.exit('panic: unrecognized line class: {0}'.format(group)) ################################################################ # The main program loop -panic() { - >&2 echo panic - exit 2 -} +def phase0(cache, filename, line): + global phase + phase = phase0 + + if re.fullmatch('#include.*|typedef .*;', line): + global includes + includes = IncludeSection() + phase1(cache, filename, line) + else: + print(line) -phase0() { - phase=phase0 - hook=: - local filename="$1" - local line="$2" - case "$line" in - '#include'*|'typedef '*';') - includes.init - phase1 "$filename" "$line" - ;; - *) - printf '%s\n' "$line" - ;; - esac -} +def phase1(cache, filename, line): + global phase, includes + phase = phase1 -phase1() { - phase=phase1 - hook=includes.print - local filename="$1" - local line="$2" - case "$line" in - '') - _includes_trailing_nl+=$'\n' - ;; - '#include'*) - _includes_trailing_nl='' - local re='^#include [<"]([^">]*)[">](.*)' - if [[ "$line" =~ $re ]]; then - # OK, this is gross, but we want to avoid creating a subshell - local _ret_class _ret_path - classify "$filename" "${BASH_REMATCH[1]}" || panic - includes.add "$_ret_class" "$_ret_path" "${BASH_REMATCH[2]}" || panic - else - panic - fi - ;; - 'typedef '*';') - _includes_trailing_nl='' - _includes_typedef+=("$line") - ;; - *) - includes.print - phase0 "$filename" "$line" - ;; - esac -} + if line == '': + includes.trailing_nl += '\n' + elif line.startswith('#include'): + includes.trailing_nl = '' + match = re.fullmatch('^#include [<"]([^">]*)[">](.*)', line) + if match: + group, path = classify(cache, filename, match.group(1)) + includes.add(group, path, match.group(2)) + else: + sys.exit('panic: malformed #include line') + elif re.fullmatch('typedef .*;', line): + includes.trailing_nl = '' + includes.typedef.append(line) + else: + includes.print() + includes = None + phase0(cache, filename, line) -phase=phase0 -hook=: +includes = None +phase = phase0 -main() { - local filename="$1" - >&2 printf ' => %q %q\n' "$0" "$filename" - set -o pipefail - { - IFS='' - while read -r line; do - "$phase" "$filename" "$line" - IFS='' - done - "$hook" - } < "$filename" - cache.save_cpp -} +def main(argv): + filename = argv[1] + print(' => {0} {1}'.format( + shlex.quote(__file__), + shlex.quote(filename), + ), file=sys.stderr) + cache = Cache(__file__+'.cache') + with open(filename) as f: + for line in f: + phase(cache, filename, line.rstrip('\n')) + if includes: + includes.print() + cache.save(__file__+'.cache') -main "$@" +if __name__ == '__main__': + main(sys.argv) -- cgit v1.2.3-54-g00ecf From 52443abf0074a859472a373113a183e0ba518f26 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 25 Oct 2016 01:10:06 -0400 Subject: tools/notsd-fixup--includes: Allow passing multiple arguments. This substantially speeds things up because it doesn't have to set up and tear down the Python runtime for every single C file now. --- tools/notsd-fixup | 32 ++++++++----------------------- tools/notsd-fixup--includes | 46 ++++++++++++++++++++++++++++++--------------- 2 files changed, 39 insertions(+), 39 deletions(-) (limited to 'tools') diff --git a/tools/notsd-fixup b/tools/notsd-fixup index 1d4287b259..4bd4b3f94c 100755 --- a/tools/notsd-fixup +++ b/tools/notsd-fixup @@ -1,11 +1,9 @@ #!/usr/bin/env bash # Copyright (C) 2015-2016 Luke Shumaker -# 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 + >&2 printf ' => fixup %q\n' "$filename" { <"$filename" sed -r \ -e "s|(/\.\.)*/config.mk|/$(realpath -ms --relative-to="$(dirname -- "$filename")" config.mk)|" \ @@ -34,27 +32,13 @@ fixup_includes() ( done fi - find "$@" \( -name '*.h' -o -name '*.c' -o -name '*.gperf' \) -type f | while read -r filename; do - false - # We copy the write-ifchanged logic to here, because we have a - # higher-than usual chance of the main command failing. In a - # Makefile we would handle this by setting .DELETE_ON_ERROR:, - # but we can't do that here, so we have to inter-mingle the - # logics. - local outfile="$filename" - tmpfile="$(dirname "$outfile")/.tmp.${outfile##*/}.tmp" - local r=0 - "$0"--includes "$filename" > "$tmpfile" || r=$? - if [[ $r != 0 ]]; then - rm -f "$tmpfile" || : - (exit $r) - fi - if cmp -s "$tmpfile" "$outfile"; then - rm -f "$tmpfile" || : - else - mv -f "$tmpfile" "$outfile" - fi - done + # We wrap the $0--includes program 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 -exec because -exec won't + # do much of anything useful with the exit status. + 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 ) diff --git a/tools/notsd-fixup--includes b/tools/notsd-fixup--includes index 196fd488a3..d16a3e6500 100755 --- a/tools/notsd-fixup--includes +++ b/tools/notsd-fixup--includes @@ -10,6 +10,8 @@ # (easy since `tools/notsd-move` runs it on the entire repo and # puts the results in git history). +import atexit +import filecmp import json import os import re @@ -225,7 +227,7 @@ class IncludeSection: ################################################################ # The main program loop -def phase0(cache, filename, line): +def phase0(cache, filename, line, file=sys.stdout): global phase phase = phase0 @@ -234,9 +236,9 @@ def phase0(cache, filename, line): includes = IncludeSection() phase1(cache, filename, line) else: - print(line) + print(line, file=file) -def phase1(cache, filename, line): +def phase1(cache, filename, line, file=sys.stdout): global phase, includes phase = phase1 @@ -254,25 +256,39 @@ def phase1(cache, filename, line): includes.trailing_nl = '' includes.typedef.append(line) else: - includes.print() + includes.print(file=file) includes = None - phase0(cache, filename, line) + phase0(cache, filename, line, file=file) includes = None phase = phase0 def main(argv): - filename = argv[1] - print(' => {0} {1}'.format( - shlex.quote(__file__), - shlex.quote(filename), - ), file=sys.stderr) cache = Cache(__file__+'.cache') - with open(filename) as f: - for line in f: - phase(cache, filename, line.rstrip('\n')) - if includes: - includes.print() + tmpfilename = '' + def cleanup(): + if tmpfilename != '': + try: + os.unlink(tmpfilename) + except FileNotFoundError: + pass + atexit.register(cleanup) + for filename in argv[1:]: + tmpfilename = os.path.join(os.path.dirname(filename), '.tmp.'+os.path.basename(filename)+'.tmp') + print(' => {0} {1}'.format( + shlex.quote(__file__), + shlex.quote(filename), + ), file=sys.stderr) + with open(tmpfilename, 'w') as tmpfile: + with open(filename) as f: + for line in f: + phase(cache, filename, line.rstrip('\n'), file=tmpfile) + if includes: + includes.print(file=tmpfile) + if not filecmp.cmp(filename, tmpfilename): + os.rename(tmpfilename, filename) + cleanup() + tmpfilename = '' cache.save(__file__+'.cache') if __name__ == '__main__': -- cgit v1.2.3-54-g00ecf From e4f65c8bb8468e4391c0b38b51e86001cd7e0ed8 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 25 Oct 2016 01:55:19 -0400 Subject: tools/notsd-fixup: Merge the pre-includes pass the includes pass. This shaves off a decent chunk of time, and simplifies the code. --- tools/notsd-fixup | 20 +++++--------------- tools/notsd-fixup--includes | 4 ++++ 2 files changed, 9 insertions(+), 15 deletions(-) (limited to 'tools') diff --git a/tools/notsd-fixup b/tools/notsd-fixup index 4bd4b3f94c..79b30b7c55 100755 --- a/tools/notsd-fixup +++ b/tools/notsd-fixup @@ -1,6 +1,11 @@ #!/usr/bin/env bash # Copyright (C) 2015-2016 Luke Shumaker +# 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. + fixup_makefiles() ( find "$@" -type f -name Makefile | while read -r filename; do >&2 printf ' => fixup %q\n' "$filename" @@ -21,21 +26,6 @@ fixup_makefiles() ( ) fixup_includes() ( - dirs=($(find "$@" -type d -name include)) - if [[ ${#dirs[@]} -gt 0 ]]; then - find "${dirs[@]}" -type d | while read -r dir; do - lib="${dir##*/}" - find "$dir" -type f | while read -r filename; do - >&2 printf ' => sed -r %q < %q\n' "s|$lib/||" "$filename" - sed -r "s|$lib/||" < "$filename" | build-aux/write-ifchanged "$filename" - done - done - fi - - # We wrap the $0--includes program 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 -exec because -exec won't - # do much of anything useful with the exit status. 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" -- diff --git a/tools/notsd-fixup--includes b/tools/notsd-fixup--includes index d16a3e6500..a82247e175 100755 --- a/tools/notsd-fixup--includes +++ b/tools/notsd-fixup--includes @@ -35,6 +35,10 @@ import sys # protected # private def classify(expensive, current_file, path): + if re.fullmatch('.*/include(-staging)?/.*/.*', current_file): + lib = os.path.basename(os.path.dirname(current_file)) + if path.startswith(lib+'/'): + path = re.sub('^'+lib+'/', path) if path.startswith('linux/'): return 'linux', path elif expensive.exists(os.path.join(os.path.dirname(current_file), path)): -- cgit v1.2.3-54-g00ecf From 96a2b322fe384fa624cadd468e7d44396e49c2af Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 25 Oct 2016 02:03:25 -0400 Subject: tools/notsd-fixup: Split the makefile pass into a separate executable. This avoids using bash read(1) to loop over the files, as we've already gotten decent speedups from avoiding bash read(1). This means we've got at least two more fork/exec's because of xargs, but it's probably worth it. But that's kind of premature-optimization; the time improvement here is probably just random noise. But, I think this makes the code more maintainable/manageable too, so I'm committing it. --- tools/notsd-fixup | 44 +++++++++++++------------------------------- tools/notsd-fixup--makefiles | 30 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 31 deletions(-) create mode 100755 tools/notsd-fixup--makefiles (limited to 'tools') diff --git a/tools/notsd-fixup b/tools/notsd-fixup index 79b30b7c55..71b3bf4dfa 100755 --- a/tools/notsd-fixup +++ b/tools/notsd-fixup @@ -1,43 +1,25 @@ #!/usr/bin/env bash # Copyright (C) 2015-2016 Luke Shumaker -# 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. +main() { + set -e + set -o pipefail + export LC_COLLATE=C + + # 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. -fixup_makefiles() ( - find "$@" -type f -name Makefile | while read -r filename; do - >&2 printf ' => fixup %q\n' "$filename" - { - <"$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 -) + # Makefiles + find "$@" -type f -name Makefile -print0 | + xargs -r0 sh -c "$0--makefiles \"\$@\" || exit 255" -- -fixup_includes() ( + # 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() { - set -e - set -o pipefail - export LC_COLLATE=C - fixup_makefiles "$@" - fixup_includes "$@" } main "$@" diff --git a/tools/notsd-fixup--makefiles b/tools/notsd-fixup--makefiles new file mode 100755 index 0000000000..bb18c3be7b --- /dev/null +++ b/tools/notsd-fixup--makefiles @@ -0,0 +1,30 @@ +#!/usr/bin/env bash + +doit() { + local filename=$1 + { + <"$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" +} + +main() { + set -e + set -o pipefail + local filename + for filename in "$@"; do + >&2 printf ' => fixup %q\n' "$filename" + doit "$filename" + done +} + +main "$@" -- cgit v1.2.3-54-g00ecf From 24ca4c3a1d7cc3b2d26d6034124fbb2c31251d90 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Tue, 25 Oct 2016 17:06:47 -0400 Subject: tidy --- tools/notsd-fixup--makefiles | 2 +- tools/notsd-move | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'tools') diff --git a/tools/notsd-fixup--makefiles b/tools/notsd-fixup--makefiles index bb18c3be7b..f89e4b075b 100755 --- a/tools/notsd-fixup--makefiles +++ b/tools/notsd-fixup--makefiles @@ -22,7 +22,7 @@ main() { set -o pipefail local filename for filename in "$@"; do - >&2 printf ' => fixup %q\n' "$filename" + >&2 printf ' => %q %q\n' "$0" "$filename" doit "$filename" done } diff --git a/tools/notsd-move b/tools/notsd-move index fcb9eaff4b..23469ba407 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -709,6 +709,12 @@ move_files() ( mv -t src/grp-"$base" "$file" done rmdir system-preset + + ln -srT src/libsystemd/include/systemd/_sd-common.h src/libsystemd-network/include/systemd-network/_sd-common.h + ln -srT src/libsystemd/include/systemd/_sd-common.h src/grp-utils/systemd-path/_sd-common.h + ln -srT src/grp-login/systemd-logind/logind-acl.h src/grp-udev/libudev-core/logind-acl.h + ln -srT src/grp-login/systemd-logind/logind-acl.c src/grp-udev/libudev-core/logind-acl.c + ln -srT src/libsystemd/src/sd-login/sd-login.c src/grp-udev/libudev-core/sd-login.c ) breakup_makefile() ( @@ -756,12 +762,6 @@ breakup_makefile() ( src/libsystemd/src/sd-journal/Makefile \ src/grp-udev/libudev-core/Makefile - ln -srT src/libsystemd/include/systemd/_sd-common.h src/libsystemd-network/include/systemd-network/_sd-common.h - ln -srT src/libsystemd/include/systemd/_sd-common.h src/grp-utils/systemd-path/_sd-common.h - ln -srT src/grp-login/systemd-logind/logind-acl.h src/grp-udev/libudev-core/logind-acl.h - ln -srT src/grp-login/systemd-logind/logind-acl.c src/grp-udev/libudev-core/logind-acl.c - ln -srT src/libsystemd/src/sd-login/sd-login.c src/grp-udev/libudev-core/sd-login.c - ln -sT ../subdir.mk src/libsystemd/src/sd-network/Makefile ln -sT ../subdir.mk src/libsystemd/src/sd-bus/Makefile ln -sT ../subdir.mk src/libsystemd/src/sd-event/Makefile -- cgit v1.2.3-54-g00ecf From 59ba4944e9764e62154f49e03b278358144a89bf Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 26 Oct 2016 21:30:00 -0400 Subject: tools/notsd-fixup--includes: Fix a variable reuse bug. --- tools/notsd-fixup--includes | 86 ++++++++++++++++++++++++--------------------- 1 file changed, 46 insertions(+), 40 deletions(-) (limited to 'tools') diff --git a/tools/notsd-fixup--includes b/tools/notsd-fixup--includes index a82247e175..afd616534d 100755 --- a/tools/notsd-fixup--includes +++ b/tools/notsd-fixup--includes @@ -231,41 +231,56 @@ class IncludeSection: ################################################################ # The main program loop -def phase0(cache, filename, line, file=sys.stdout): - global phase - phase = phase0 +class Parser: + def __init__(self, cache, ifilename, ofilename): + self.cache = cache + self.ifilename = os.path.normpath(ifilename) + self.ofilename = ofilename - if re.fullmatch('#include.*|typedef .*;', line): - global includes - includes = IncludeSection() - phase1(cache, filename, line) - else: - print(line, file=file) + self.includes = None + self.phase = self.phase0 -def phase1(cache, filename, line, file=sys.stdout): - global phase, includes - phase = phase1 + def phase0(self, line, ofile): + self.phase = self.phase0 - if line == '': - includes.trailing_nl += '\n' - elif line.startswith('#include'): - includes.trailing_nl = '' - match = re.fullmatch('^#include [<"]([^">]*)[">](.*)', line) - if match: - group, path = classify(cache, filename, match.group(1)) - includes.add(group, path, match.group(2)) + if re.fullmatch('#include.*|typedef .*;', line): + self.includes = IncludeSection() + self.phase1(line, ofile) else: - sys.exit('panic: malformed #include line') - elif re.fullmatch('typedef .*;', line): - includes.trailing_nl = '' - includes.typedef.append(line) - else: - includes.print(file=file) - includes = None - phase0(cache, filename, line, file=file) + print(line, file=ofile) + + def phase1(self, line, ofile): + self.phase = self.phase1 + + if line == '': + self.includes.trailing_nl += '\n' + elif line.startswith('#include'): + self.includes.trailing_nl = '' + match = re.fullmatch('^#include [<"]([^">]*)[">](.*)', line) + if match: + group, path = classify(self.cache, self.ifilename, match.group(1)) + self.includes.add(group, path, match.group(2)) + else: + sys.exit('panic: malformed #include line') + elif re.fullmatch('typedef .*;', line): + self.includes.trailing_nl = '' + self.includes.typedef.append(line) + else: + self.includes.print(file=ofile) + self.includes = None + self.phase0(line, ofile) -includes = None -phase = phase0 + def run(self): + print(' => {0} {1}'.format( + shlex.quote(__file__), + shlex.quote(self.ifilename), + ), file=sys.stderr) + with open(self.ofilename, 'w') as ofile: + with open(self.ifilename) as ifile: + for line in ifile: + self.phase(line.rstrip('\n'), ofile) + if self.includes: + self.includes.print(file=ofile) def main(argv): cache = Cache(__file__+'.cache') @@ -279,16 +294,7 @@ def main(argv): atexit.register(cleanup) for filename in argv[1:]: tmpfilename = os.path.join(os.path.dirname(filename), '.tmp.'+os.path.basename(filename)+'.tmp') - print(' => {0} {1}'.format( - shlex.quote(__file__), - shlex.quote(filename), - ), file=sys.stderr) - with open(tmpfilename, 'w') as tmpfile: - with open(filename) as f: - for line in f: - phase(cache, filename, line.rstrip('\n'), file=tmpfile) - if includes: - includes.print(file=tmpfile) + Parser(cache, filename, tmpfilename).run() if not filecmp.cmp(filename, tmpfilename): os.rename(tmpfilename, filename) cleanup() -- cgit v1.2.3-54-g00ecf From 0167e6da4c08602585217269f0a9485d534e77d7 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 26 Oct 2016 21:30:25 -0400 Subject: tools/notsd-fixup--includes: fix mucking with typedefs --- tools/notsd-fixup--includes | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/notsd-fixup--includes b/tools/notsd-fixup--includes index afd616534d..a636c78be6 100755 --- a/tools/notsd-fixup--includes +++ b/tools/notsd-fixup--includes @@ -209,7 +209,7 @@ class IncludeSection: b='\n' if len(self.typedef) > 0 and self.typedef_last: print(b, end='', file=file) - for line in sorted(set(self.typedef)): + for line in self.typedef: print(line, file=file) print(self.trailing_nl, end='', file=file) def add(self, group, path, extra): -- cgit v1.2.3-54-g00ecf From a88538c095c0100e7386e10905f6301716c54815 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 26 Oct 2016 21:57:43 -0400 Subject: tools/notsd-move: bus-util location --- tools/notsd-move | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tools') diff --git a/tools/notsd-move b/tools/notsd-move index 23469ba407..bd4009f518 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -710,6 +710,10 @@ move_files() ( done rmdir system-preset + mv -t src/libsystemd/src/sd-bus \ + src/libsystemd-shared/src/bus-util.c \ + src/libsystemd-shared/include/systemd-shared/bus-util.h + ln -srT src/libsystemd/include/systemd/_sd-common.h src/libsystemd-network/include/systemd-network/_sd-common.h ln -srT src/libsystemd/include/systemd/_sd-common.h src/grp-utils/systemd-path/_sd-common.h ln -srT src/grp-login/systemd-logind/logind-acl.h src/grp-udev/libudev-core/logind-acl.h -- cgit v1.2.3-54-g00ecf From 042468f48fa4b7de28fd51c4416af31f6be2dfde Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 26 Oct 2016 22:01:09 -0400 Subject: tools/notsd-move: avoid dangling empty directories --- tools/notsd-move | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/notsd-move b/tools/notsd-move index bd4009f518..50be86f623 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -48,7 +48,6 @@ grp() { move_files() ( # first focus on getting directories to the right names. - mv -T src/{,systemd-}dbus1-generator mv -T src/{,systemd-}debug-generator mv -T src/{,systemd-}fstab-generator mv -T src/{,systemd-}getty-generator @@ -831,6 +830,7 @@ run() ( move() ( find . \( -name Makefile -o -name '*.mk' \) -delete + find src -type d -empty -exec rmdir -p --ignore-fail-on-non-empty -- {} + >&2 echo ' => breakup_zshcompletion' run breakup_zshcompletion -- cgit v1.2.3-54-g00ecf From 7e3290b73ee989e73e8bdddd3b1c7643077a9c1e Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 26 Oct 2016 22:38:16 -0400 Subject: add missing stub Makefiles --- Makefile.am | 12 ++++++++++++ tools/notsd-move | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/Makefile.am b/Makefile.am index f8d6d62a6b..db99e0b403 100644 --- a/Makefile.am +++ b/Makefile.am @@ -6820,16 +6820,28 @@ sd.CPPFLAGS += $(libsystemd-network.CPPFLAGS) #@src/grp-initprogs/Makefile #@src/grp-initprogs/grp-sleep/Makefile #@src/grp-journal/grp-remote/Makefile +#@src/grp-journal/grp-remote/libsystemd-microhttpd/Makefile +#@src/grp-journal/grp-remote/libsystemd-microhttpd/src/Makefile +#@src/grp-journal/libjournal-core/src/Makefile #@src/grp-locale/Makefile #@src/grp-machine/Makefile #@src/grp-machine/grp-import/Makefile #@src/grp-machine/grp-import/libimport/Makefile +#@src/grp-machine/libmachine-core/src/Makefile #@src/grp-resolve/Makefile #@src/grp-resolve/libbasic-dns/Makefile +#@src/grp-resolve/libbasic-dns/src/Makefile +#@src/grp-resolve/libbasic-dns/test/Makefile #@src/grp-system/Makefile #@src/grp-system/grp-utils/Makefile +#@src/grp-system/libcore/src/Makefile #@src/grp-timedate/Makefile #@src/grp-utils/Makefile +#@src/libsystemd-firewall/src/Makefile +#@src/libsystemd-gcrypt/Makefile +#@src/libsystemd-gcrypt/src/Makefile +#@src/libsystemd/src/sd-bus/Makefile +#@src/libsystemd/src/sd-hwdb/Makefile #@src/libudev/Makefile #@all diff --git a/tools/notsd-move b/tools/notsd-move index 50be86f623..ba021ac5f1 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -766,14 +766,12 @@ breakup_makefile() ( src/grp-udev/libudev-core/Makefile ln -sT ../subdir.mk src/libsystemd/src/sd-network/Makefile - ln -sT ../subdir.mk src/libsystemd/src/sd-bus/Makefile ln -sT ../subdir.mk src/libsystemd/src/sd-event/Makefile ln -sT ../subdir.mk src/libsystemd/src/sd-login/Makefile ln -sT ../subdir.mk src/libsystemd/src/sd-resolve/Makefile ln -sT ../subdir.mk src/libsystemd/src/sd-daemon/Makefile ln -sT ../subdir.mk src/libsystemd/src/sd-netlink/Makefile ln -sT ../subdir.mk src/libsystemd/src/sd-id128/Makefile - ln -sT ../subdir.mk src/libsystemd/src/sd-hwdb/Makefile ln -sT ../subdir.mk src/libsystemd/src/sd-device/Makefile ) -- cgit v1.2.3-54-g00ecf From 62462bb9d7d0866d320d449a77b65c8a011ec813 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 26 Oct 2016 22:48:36 -0400 Subject: have libbasic gperf headers be private --- Makefile.am | 4 +--- tools/notsd-move | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'tools') diff --git a/Makefile.am b/Makefile.am index db99e0b403..5964a99bd5 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1418,9 +1418,7 @@ CLEANFILES += \ $(AM_V_at)$(MKDIR_P) $(dir $@) $(AM_V_GPERF)$(GPERF) -L ANSI-C -t --ignore-case -N lookup_$(notdir $*) -H hash_$(notdir $*)_name -p -C <$< >$@ -#@src/libbasic/include/Makefile -nested.subdirs += basic -#@src/libbasic/include/systemd-basic/Makefile +#@src/libbasic/src/Makefile src/basic/errno-list.txt: $(AM_V_at)$(MKDIR_P) $(dir $@) $(AM_V_GEN)$(CPP) $(CFLAGS) $(AM_CPPFLAGS) $(CPPFLAGS) -dM -include errno.h - $@ diff --git a/tools/notsd-move b/tools/notsd-move index ba021ac5f1..4a5630c777 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -760,7 +760,7 @@ breakup_makefile() ( sed -ri \ -e '/^[^# ]*:/ { s|\S+/|$(outdir)/|g }' \ - src/libsystemd-basic/include/systemd-basic/Makefile \ + src/libsystemd-basic/src/Makefile \ src/libsystemd/src/Makefile \ src/libsystemd/src/sd-journal/Makefile \ src/grp-udev/libudev-core/Makefile -- cgit v1.2.3-54-g00ecf From 2b1abe52835e2f9a85657009b3432cf2c2bdc417 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 26 Oct 2016 22:49:09 -0400 Subject: tools/notsd-move: oops: don't invoke the editor, for real this time --- tools/notsd-move | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/notsd-move b/tools/notsd-move index 4a5630c777..c7a9b99e0b 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -852,9 +852,9 @@ main() { git add . git commit -m './tools/notsd-move' - git merge -s ours notsystemd/postmove + git merge --no-edit -s ours notsystemd/postmove git checkout notsystemd/postmove - git merge --no-edit tmp/postmove + git merge tmp/postmove git branch -d tmp/postmove } -- cgit v1.2.3-54-g00ecf From 7888137c2695828443b5d7488e6e33f7da74e0a5 Mon Sep 17 00:00:00 2001 From: Luke Shumaker Date: Wed, 26 Oct 2016 23:39:19 -0400 Subject: fixity --- Makefile.am | 5 ++--- tools/notsd-move | 10 +++++++--- 2 files changed, 9 insertions(+), 6 deletions(-) (limited to 'tools') diff --git a/Makefile.am b/Makefile.am index 8154394e84..09beac93d3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -5650,7 +5650,7 @@ dist_bashcompletion_data += \ dist_zshcompletion_data += \ shell-completion/zsh/_systemd-resolve -#@src/grp-resolve/libbasic-dns/src/Makefile +#@src/grp-resolve/libbasic-dns/test/Makefile tests += \ test-dns-packet \ test-resolve-tables \ @@ -5728,7 +5728,7 @@ test_dnssec_complex_LDADD = \ #@auto/systemd-resolved/Makefile endif # ENABLE_RESOLVED -#@auto/libbasic-dns/Makefile +#@src/grp-resolve/libbasic-dns/src/Makefile gperf_txt_sources += \ src/resolve/dns_type-list.txt @@ -6829,7 +6829,6 @@ sd.CPPFLAGS += $(libsystemd-network.CPPFLAGS) #@src/grp-machine/libmachine-core/Makefile #@src/grp-resolve/Makefile #@src/grp-resolve/libbasic-dns/Makefile -#@src/grp-resolve/libbasic-dns/test/Makefile #@src/grp-system/Makefile #@src/grp-system/grp-utils/Makefile #@src/grp-system/libcore/Makefile diff --git a/tools/notsd-move b/tools/notsd-move index c7a9b99e0b..36ca546a63 100755 --- a/tools/notsd-move +++ b/tools/notsd-move @@ -780,19 +780,23 @@ fixup_makefile() { -e '#### Specific complete strings #####' \ -e 's|\$\(CPP\) \$\(CFLAGS\) \$\(AM_CPPFLAGS\) \$\(CPPFLAGS\)|$(CPP) $(sd.ALL_CPPFLAGS)|g' \ -e '/^ \$\(AM_V_at\)\$\(MKDIR_P\) \$\(dir \$@\)/d' \ + \ -e '#### General cases #################' \ -e '/^[^# ]*:/ { s|^(\s*)\S+/|\1$(outdir)/| }' \ -e 's|^if (.*)|ifneq ($(\1),)|' \ -e '/^\s*\$\(AM_(C|CPP|LD)FLAGS\b/d' \ -e 's|--version-script=.*/([^/]+)\.sym|--version-script=$(srcdir)/\1.sym|g' \ + \ -e '#### Rename helpers ################' \ -e 's|libbasic_la|libsystemd_basic_la|g' \ -e 's|libbasic|libsystemd-basic|g' \ - -e 's|libshared|libsystemd-shared|g' \ + -e 's|libsystemd-basic-dns|libbasic-dns|g' \ + \ -e 's|libshared_la|libsystemd_shared_la|g' \ - -e 's|libfirewall|libsystemd-firewall|g' \ + -e 's|libshared|libsystemd-shared|g' \ + \ -e 's|libfirewall_la|libsystemd_firewall_la|g' \ - -e 's|libsystemd-basic-dns|libbasic-dns|g' + -e 's|libfirewall|libsystemd-firewall|g' } breakup_zshcompletion() ( -- cgit v1.2.3-54-g00ecf