| 1 | |
| 2 | |
| 3 |
|
| 4 | |
| 5 | |
| 6 | set -e
|
| 7 | spath="$(dirname "$(readlink -f "$0")")"
|
| 8 | kroot="$spath/.."
|
| 9 | outdir="$(pwd)"
|
| 10 | tarfile=$1
|
| 11 | cpio_dir=$outdir/$tarfile.tmp
|
| 12 |
|
| 13 | |
| 14 | |
| 15 | |
| 16 | sfile="$(realpath --relative-to $kroot "$(readlink -f "$0")")"
|
| 17 |
|
| 18 | src_file_list="
|
| 19 | include/
|
| 20 | arch/$SRCARCH/include/
|
| 21 | $sfile
|
| 22 | "
|
| 23 |
|
| 24 | obj_file_list="
|
| 25 | include/
|
| 26 | arch/$SRCARCH/include/
|
| 27 | "
|
| 28 |
|
| 29 | |
| 30 | |
| 31 |
|
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | |
| 38 |
|
| 39 | |
| 40 | |
| 41 | |
| 42 | pushd $kroot > /dev/null
|
| 43 | src_files_md5="$(find $src_file_list -type f |
|
| 44 | grep -v "include/generated/compile.h" |
|
| 45 | 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 -lR | md5sum | cut -d ' ' -f1)"
|
| 50 | popd > /dev/null
|
| 51 | obj_files_md5="$(find $obj_file_list -type f |
|
| 52 | grep -v "include/generated/compile.h" |
|
| 53 | 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 -lR | md5sum | cut -d ' ' -f1)"
|
| 58 |
|
| 59 | if [ -f $tarfile ]; then tarfile_md5="$(md5sum $tarfile | cut -d ' ' -f1)"; fi
|
| 60 | if [ -f kernel/kheaders.md5 ] &&
|
| 61 | [ "$(cat kernel/kheaders.md5|head -1)" == "$src_files_md5" ] &&
|
| 62 | [ "$(cat kernel/kheaders.md5|head -2|tail -1)" == "$obj_files_md5" ] &&
|
| 63 | [ "$(cat kernel/kheaders.md5|tail -1)" == "$tarfile_md5" ]; then
|
| 64 | exit
|
| 65 | fi
|
| 66 |
|
| 67 | if [ "${quiet}" != "silent_" ]; then
|
| 68 | echo " GEN $tarfile"
|
| 69 | fi
|
| 70 |
|
| 71 | rm -rf $cpio_dir
|
| 72 | mkdir $cpio_dir
|
| 73 |
|
| 74 | pushd $kroot > /dev/null
|
| 75 | for f in $src_file_list;
|
| 76 | do find "$f" ! -name "*.cmd" ! -name ".*";
|
| 77 | done | cpio --quiet -pd $cpio_dir
|
| 78 | popd > /dev/null
|
| 79 |
|
| 80 | |
| 81 | |
| 82 | for f in $obj_file_list;
|
| 83 | do find "$f" ! -name "*.cmd" ! -name ".*";
|
| 84 | done | cpio --quiet -pd $cpio_dir >/dev/null 2>&1
|
| 85 |
|
| 86 | |
| 87 | find $cpio_dir -type f -print0 |
|
| 88 | xargs -0 -P8 -n1 perl -pi -e 'BEGIN {undef $/;}; s/\/\*((?!SPDX).)*?\*\///smg;'
|
| 89 |
|
| 90 | tar -Jcf $tarfile -C $cpio_dir/ . > /dev/null
|
| 91 |
|
| 92 | echo "$src_files_md5" > kernel/kheaders.md5
|
| 93 | echo "$obj_files_md5" >> kernel/kheaders.md5
|
| 94 | echo "$(md5sum $tarfile | cut -d ' ' -f1)" >> kernel/kheaders.md5
|
| 95 |
|
| 96 | rm -rf $cpio_dir
|