lin
2025-08-14 dae8bad597b6607a449b32bf76c523423f7720ed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
 
# Utility to build kernel headers tar/zip file
# must be run from the top level of a kernel source directory
# and supplied an output file name
 
MKTEMP=0; if [[ -z ${TDIR+x} ]]  || [[ ! -d "${TDIR}" ]]; then
   TDIR=`mktemp -d`; MKTEMP=1; fi
rm -rf $TDIR/*
TDIR_ABS=$( cd "$TDIR" ; pwd -P )
 
 
if [ $# -ne 1 ]; then
  echo "usage: makeheaders.sh <output file name>"
  exit 0
fi
 
mkdir -p $TDIR_ABS/kernel-headers
 
find arch -name include -type d -print | xargs -n1 -i: find : -type f -exec cp --parents {} $TDIR_ABS/kernel-headers/ \;
find include -exec cp --parents {} $TDIR_ABS/kernel-headers/ 2> /dev/null \;
tar -zcf $1 --directory=$TDIR_ABS kernel-headers
 
zip -r $1.zip $1
rm -rf $TDIR/*; if [ $MKTEMP -eq 1 ]; then rm -rf $TDIR; fi