diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:34:36 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 17:34:36 +0000 |
commit | 74ebeae0b4c411df9900224b90a6072b16098458 (patch) | |
tree | fee8f5c9e37f1a9f0842e026876c8af541fa2e86 /scripts/ethtool-import-uapi | |
parent | Initial commit. (diff) | |
download | ethtool-74ebeae0b4c411df9900224b90a6072b16098458.tar.xz ethtool-74ebeae0b4c411df9900224b90a6072b16098458.zip |
Adding upstream version 1:6.7.upstream/1%6.7
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/ethtool-import-uapi')
-rwxr-xr-x | scripts/ethtool-import-uapi | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/scripts/ethtool-import-uapi b/scripts/ethtool-import-uapi new file mode 100755 index 0000000..a04a9c9 --- /dev/null +++ b/scripts/ethtool-import-uapi @@ -0,0 +1,67 @@ +#!/bin/bash -e +# +# ethtool-import-uapi [commit] +# +# Imports sanitized copies of kernel uapi headers from <commit> (can be +# a commit id, a tag or a branch name). If the argument is omitted, +# commit currently checked out in the kernel repository is used. + +sn="${0##*/}" +export ARCH="x86_64" +mkopt="-j$(nproc)" || mkopt='' + +if [ ! -d "$LINUX_GIT" ]; then + echo "${sn}: please set LINUX_GIT to the location of kernel git" >&2 + exit 1 +fi + +pushd "$LINUX_GIT" +if [ -n "$1" ]; then + git checkout "$1" +fi +desc=$(git describe --exact-match 2>/dev/null \ + || git show -s --abbrev=12 --pretty='commit %h') +kobj=$(mktemp -d) +make $mkopt O="$kobj" allmodconfig +make $mkopt O="$kobj" prepare +make $mkopt O="$kobj" INSTALL_HDR_PATH="${kobj}/hdr" headers_install +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" + +git add uapi +git commit -s -F - <<EOT +update UAPI header copies + +Update to kernel ${desc}. + +EOT |