blob: 10b29308c8f4f210c7826493837340d45938ad73 (
plain)
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
#!/bin/bash -ex
ver=$1
if [[ -z $ver ]]; then
echo "Usage: $0 <kernel ver>"
exit 1
fi
[[ ${ver} == linux-* ]] && ver=${ver#linux-}
ver=${ver%/}
src=linux-${ver}
dst=gentoo-headers-base-${ver}
if [ ! -d ${src} ] ; then
for srcdir in . "$(portageq distdir)" /usr/portage/distfiles ; do
for ext in bz2 xz ; do
srctar=${srcdir}/${src}.tar.${ext}
if [ -e ${srctar} ] ; then
tar xf ${srctar}
break
fi
done
done
fi
if [ ! -d ${src} ] ; then
wget https://www.kernel.org/pub/linux/kernel/v${ver:0:1}.x/linux-${ver}.tar.xz -P /usr/portage/distfiles/
exec "$0" "$@"
fi
rm -rf ${dst}
mkdir ${dst}
cp ${src}/Makefile ${dst}/
mkdir ${dst}/include
[ -f ${src}/include/Kbuild ] && cp ${src}/include/Kbuild ${dst}/include/
directories=$(find ${src}/include -mindepth 2 -maxdepth 2 -name 'Kbuild*' -printf %h' ')
if [ -n "${directories}" ] ; then
cp -r ${directories} ${dst}/include/
else
cp -r ${src}/include/* ${dst}/include
fi
mkdir ${dst}/scripts
cp -r \
${src}/scripts/{Makefile,Kbuild}* \
${src}/scripts/unifdef.c \
${src}/scripts/*.{sh,pl} \
${dst}/scripts/
mkdir -p ${dst}/scripts/basic
printf '#!/bin/sh\nexit 0' > ${dst}/scripts/basic/fixdep
chmod a+rx ${dst}/scripts/basic/fixdep
touch ${dst}/scripts/basic/Makefile
mkdir ${dst}/tools
cp -r \
${src}/tools/include \
${dst}/tools/
mkdir ${dst}/arch
arches=$(cd ${src}/arch ; ls)
for a in ${arches} ; do
if [[ -e ${src}/include/asm-${a}/Kbuild ]] || [[ -e ${src}/arch/${a}/include/asm/Kbuild ]] ; then
mkdir -p ${dst}/arch/${a}
cp ${src}/arch/${a}/Makefile* ${dst}/arch/${a}/
cp ${src}/arch/${a}/Kbuild* ${dst}/arch/${a}/ 2>/dev/null || :
for d in include syscalls tools ; do
if [[ -e ${src}/arch/${a}/${d} ]] ; then
cp -r ${src}/arch/${a}/${d} ${dst}/arch/${a}/
fi
done
fi
done
# handle x86 unique cruft
if [[ -e ${src}/arch/x86/entry/syscalls ]] ; then
mkdir -p ${dst}/arch/x86/entry
cp -r ${src}/arch/x86/entry/syscalls ${dst}/arch/x86/entry/
fi
# mips has some stupid unique bs
if [[ -e ${src}/arch/mips/Kbuild.platforms ]] ; then
for f in "${src}"/arch/mips/*/Platform ; do
f=${f#${src}}
mkdir ${dst}/${f%/*}
cp ${src}/${f} ${dst}/${f}
done
fi
if [[ -d ${src}/arch/mips/boot/tools ]] ; then
mkdir -p ${dst}/arch/mips/boot
cp -r ${src}/arch/mips/boot/tools ${dst}/arch/mips/boot/
fi
find ${dst}/ -name .gitignore -delete
cp README.ripped-headers rip-headers.sh ${dst}/
compress=xz
tar cf - ${dst} | ${compress} > ${dst}.tar.${compress}
rm -rf ${dst}
ls -lh ${dst}.tar.${compress}
|