aboutsummaryrefslogtreecommitdiffstats
path: root/kernel/gen_kheaders.sh
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.masahiro@socionext.com>2019-06-30 20:58:44 -0400
committerMasahiro Yamada <yamada.masahiro@socionext.com>2019-07-08 21:10:52 -0400
commit7199ff7d74003b5aad1e6328bf6128cd8ceea735 (patch)
tree7a167ba7319986565a82831676b2edbf9e147e2c /kernel/gen_kheaders.sh
parentb60b7c2ea9b7f854d457fefd592c77f621a86580 (diff)
kheaders: include only headers into kheaders_data.tar.xz
Currently, kheaders_data.tar.xz contains some build scripts as well as headers. None of them is needed in the header archive. For ARCH=x86, this commit excludes the following from the archive: arch/x86/include/asm/Kbuild arch/x86/include/uapi/asm/Kbuild include/asm-generic/Kbuild include/config/auto.conf include/config/kernel.release include/config/tristate.conf include/uapi/asm-generic/Kbuild include/uapi/Kbuild kernel/gen_kheaders.sh This change is actually motivated for the planned header compile-testing because it will generate more build artifacts, which should not be included in the archive. Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com> Reviewed-by: Joel Fernandes (Google) <joel@joelfernandes.org>
Diffstat (limited to 'kernel/gen_kheaders.sh')
-rwxr-xr-xkernel/gen_kheaders.sh47
1 files changed, 16 insertions, 31 deletions
diff --git a/kernel/gen_kheaders.sh b/kernel/gen_kheaders.sh
index 86a666f5cb17..9ff449888d9c 100755
--- a/kernel/gen_kheaders.sh
+++ b/kernel/gen_kheaders.sh
@@ -4,24 +4,12 @@
4# This script generates an archive consisting of kernel headers 4# This script generates an archive consisting of kernel headers
5# for CONFIG_IKHEADERS. 5# for CONFIG_IKHEADERS.
6set -e 6set -e
7spath="$(dirname "$(readlink -f "$0")")" 7sfile="$(readlink -f "$0")"
8kroot="$spath/.."
9outdir="$(pwd)" 8outdir="$(pwd)"
10tarfile=$1 9tarfile=$1
11cpio_dir=$outdir/$tarfile.tmp 10cpio_dir=$outdir/$tarfile.tmp
12 11
13# Script filename relative to the kernel source root 12dir_list="
14# We add it to the archive because it is small and any changes
15# to this script will also cause a rebuild of the archive.
16sfile="$(realpath --relative-to $kroot "$(readlink -f "$0")")"
17
18src_file_list="
19include/
20arch/$SRCARCH/include/
21$sfile
22"
23
24obj_file_list="
25include/ 13include/
26arch/$SRCARCH/include/ 14arch/$SRCARCH/include/
27" 15"
@@ -33,33 +21,29 @@ arch/$SRCARCH/include/
33# Uncomment it for debugging. 21# Uncomment it for debugging.
34# if [ ! -f /tmp/iter ]; then iter=1; echo 1 > /tmp/iter; 22# if [ ! -f /tmp/iter ]; then iter=1; echo 1 > /tmp/iter;
35# else iter=$(($(cat /tmp/iter) + 1)); echo $iter > /tmp/iter; fi 23# else iter=$(($(cat /tmp/iter) + 1)); echo $iter > /tmp/iter; fi
36# find $src_file_list -type f | xargs ls -l > /tmp/src-ls-$iter 24# find $src_file_list -name "*.h" | xargs ls -l > /tmp/src-ls-$iter
37# find $obj_file_list -type f | xargs ls -l > /tmp/obj-ls-$iter 25# find $obj_file_list -name "*.h" | xargs ls -l > /tmp/obj-ls-$iter
38 26
39# include/generated/compile.h is ignored because it is touched even when none 27# include/generated/compile.h is ignored because it is touched even when none
40# of the source files changed. This causes pointless regeneration, so let us 28# of the source files changed. This causes pointless regeneration, so let us
41# ignore them for md5 calculation. 29# ignore them for md5 calculation.
42pushd $kroot > /dev/null 30pushd $srctree > /dev/null
43src_files_md5="$(find $src_file_list -type f | 31src_files_md5="$(find $dir_list -name "*.h" |
44 grep -v "include/generated/compile.h" | 32 grep -v "include/generated/compile.h" |
45 grep -v "include/generated/autoconf.h" | 33 grep -v "include/generated/autoconf.h" |
46 grep -v "include/config/auto.conf" |
47 grep -v "include/config/auto.conf.cmd" |
48 grep -v "include/config/tristate.conf" |
49 xargs ls -l | md5sum | cut -d ' ' -f1)" 34 xargs ls -l | md5sum | cut -d ' ' -f1)"
50popd > /dev/null 35popd > /dev/null
51obj_files_md5="$(find $obj_file_list -type f | 36obj_files_md5="$(find $dir_list -name "*.h" |
52 grep -v "include/generated/compile.h" | 37 grep -v "include/generated/compile.h" |
53 grep -v "include/generated/autoconf.h" | 38 grep -v "include/generated/autoconf.h" |
54 grep -v "include/config/auto.conf" |
55 grep -v "include/config/auto.conf.cmd" |
56 grep -v "include/config/tristate.conf" |
57 xargs ls -l | md5sum | cut -d ' ' -f1)" 39 xargs ls -l | md5sum | cut -d ' ' -f1)"
58 40# Any changes to this script will also cause a rebuild of the archive.
41this_file_md5="$(ls -l $sfile | md5sum | cut -d ' ' -f1)"
59if [ -f $tarfile ]; then tarfile_md5="$(md5sum $tarfile | cut -d ' ' -f1)"; fi 42if [ -f $tarfile ]; then tarfile_md5="$(md5sum $tarfile | cut -d ' ' -f1)"; fi
60if [ -f kernel/kheaders.md5 ] && 43if [ -f kernel/kheaders.md5 ] &&
61 [ "$(cat kernel/kheaders.md5|head -1)" == "$src_files_md5" ] && 44 [ "$(cat kernel/kheaders.md5|head -1)" == "$src_files_md5" ] &&
62 [ "$(cat kernel/kheaders.md5|head -2|tail -1)" == "$obj_files_md5" ] && 45 [ "$(cat kernel/kheaders.md5|head -2|tail -1)" == "$obj_files_md5" ] &&
46 [ "$(cat kernel/kheaders.md5|head -3|tail -1)" == "$this_file_md5" ] &&
63 [ "$(cat kernel/kheaders.md5|tail -1)" == "$tarfile_md5" ]; then 47 [ "$(cat kernel/kheaders.md5|tail -1)" == "$tarfile_md5" ]; then
64 exit 48 exit
65fi 49fi
@@ -71,16 +55,16 @@ fi
71rm -rf $cpio_dir 55rm -rf $cpio_dir
72mkdir $cpio_dir 56mkdir $cpio_dir
73 57
74pushd $kroot > /dev/null 58pushd $srctree > /dev/null
75for f in $src_file_list; 59for f in $dir_list;
76 do find "$f" ! -name "*.cmd" ! -name ".*"; 60 do find "$f" -name "*.h";
77done | cpio --quiet -pd $cpio_dir 61done | cpio --quiet -pd $cpio_dir
78popd > /dev/null 62popd > /dev/null
79 63
80# The second CPIO can complain if files already exist which can 64# The second CPIO can complain if files already exist which can
81# happen with out of tree builds. Just silence CPIO for now. 65# happen with out of tree builds. Just silence CPIO for now.
82for f in $obj_file_list; 66for f in $dir_list;
83 do find "$f" ! -name "*.cmd" ! -name ".*"; 67 do find "$f" -name "*.h";
84done | cpio --quiet -pd $cpio_dir >/dev/null 2>&1 68done | cpio --quiet -pd $cpio_dir >/dev/null 2>&1
85 69
86# Remove comments except SDPX lines 70# Remove comments except SDPX lines
@@ -91,6 +75,7 @@ tar -Jcf $tarfile -C $cpio_dir/ . > /dev/null
91 75
92echo "$src_files_md5" > kernel/kheaders.md5 76echo "$src_files_md5" > kernel/kheaders.md5
93echo "$obj_files_md5" >> kernel/kheaders.md5 77echo "$obj_files_md5" >> kernel/kheaders.md5
78echo "$this_file_md5" >> kernel/kheaders.md5
94echo "$(md5sum $tarfile | cut -d ' ' -f1)" >> kernel/kheaders.md5 79echo "$(md5sum $tarfile | cut -d ' ' -f1)" >> kernel/kheaders.md5
95 80
96rm -rf $cpio_dir 81rm -rf $cpio_dir