diff mbox series

[ethtool,2/3] scripts: add all included uapi files on update

Message ID 2a3cf93556d5f458899721aa7e7e5174d527030f.1681858286.git.mkubecek@suse.cz (mailing list archive)
State Accepted, archived
Delegated to: Michal Kubecek
Headers show
Series close uapi header copies w.r.t. include | expand

Checks

Context Check Description
netdev/tree_selection success Not a local patch, async

Commit Message

Michal Kubecek April 18, 2023, 11:02 p.m. UTC
On multiple occasions, we had to add another uapi header copy to fix build
on older system where system <linux/...> headers in /usr/include lacked
recent definitions or changes. To prevent these problems, update the
ethtool-import-uapi script to add all uapi headers included either from
a source file or from already copied uapi header which are not present yet.

Omit <asm/...> headers as those are architecture dependent so that we
cannot pick one random version depending on architecture a developer runs
the script on and having all versions and selecting the right one would be
too complicated.

Signed-off-by: Michal Kubecek <mkubecek@suse.cz>
---
 scripts/ethtool-import-uapi | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)
diff mbox series

Patch

diff --git a/scripts/ethtool-import-uapi b/scripts/ethtool-import-uapi
index 8e48332cfcc8..a04a9c971a01 100755
--- a/scripts/ethtool-import-uapi
+++ b/scripts/ethtool-import-uapi
@@ -29,6 +29,32 @@  popd
 
 pushd uapi
 find . -type f -name '*.h' -exec cp -v "${kobj}/hdr/include/{}" {} \;
+
+go_on=true
+while $go_on; do
+    go_on=false
+    while read f; do
+        if [ "${f#asm/}" != "$f" ]; then
+            # skip architecture dependent asm/ headers
+            continue
+        fi
+        if [ -f "$f" ]; then
+            # already present
+            continue
+        fi
+	if [ ! -f "${kobj}/hdr/include/${f}" ]; then
+            # not a kernel header
+            continue
+        fi
+        echo "+ add $f"
+        go_on=true
+        mkdir -p "${f%/*}"
+        cp "${kobj}/hdr/include/${f}" "${f}"
+    done < <(
+        find . -type f -name '*.[ch]' -exec sed -nre '\_^[[:blank:]]*#include[[:blank:]]<.+>_ { s_^[[:blank:]]*#include[[:blank:]]<([^>]*)>.*$_\1_ ; p }' {} \; \
+            | LC_ALL=C sort -u
+    )
+done
 popd
 rm -rf "$kobj"