| 1 |
#!/bin/sh
|
| 2 |
#
|
| 3 |
# This is the hook file executed by make-kpkg in the end of creation
|
| 4 |
# of the kernel-image for a particular flavour. The major task it performs
|
| 5 |
# is the creation of the flavour-specific kernel-headers package.
|
| 6 |
#
|
| 7 |
set -e
|
| 8 |
|
| 9 |
debhelper_pre() {
|
| 10 |
dh_clean -k --package="$1"
|
| 11 |
dh_installdirs --package="$1"
|
| 12 |
}
|
| 13 |
|
| 14 |
debhelper_post() {
|
| 15 |
dh_installdocs --package="$1"
|
| 16 |
dh_installchangelogs --package="$1"
|
| 17 |
dh_compress --package="$1"
|
| 18 |
dh_fixperms --package="$1"
|
| 19 |
dh_installdeb --package="$1"
|
| 20 |
dh_gencontrol --package="$1"
|
| 21 |
dh_md5sums --package="$1"
|
| 22 |
dh_builddeb --package="$1"
|
| 23 |
}
|
| 24 |
# The version which ends up here is something like
|
| 25 |
# $(version)-$(abiname)-$(flavour) and debnum is just
|
| 26 |
# -$(abiname), so that the variables get the values:
|
| 27 |
# suffix=$(flavour)
|
| 28 |
# prefix=$(version)-$(abiname)
|
| 29 |
# prefix is then used to form a destination directory
|
| 30 |
# to link to. For cases with subarch we need to link
|
| 31 |
# to kernel-headers-$(version)-$(abiname)-$(subarch),
|
| 32 |
# not just kernel-headers-$(version)-$(abiname). Note
|
| 33 |
# that the append_subarch substitution must contain a
|
| 34 |
# dash, if it is non-empty.
|
| 35 |
#
|
| 36 |
append='@append_subarch@'
|
| 37 |
suffix=${version#*$debnum-}
|
| 38 |
prefix=${version%%-*}${debnum}${append}
|
| 39 |
pkg=kernel-headers-$version
|
| 40 |
top=$PWD/debian/$pkg
|
| 41 |
dir=$top/usr/src/kernel-headers-$version
|
| 42 |
#
|
| 43 |
# Here we need to find the kernel architecture which
|
| 44 |
# is appropriate for the current flavour. It is available
|
| 45 |
# in kernel-package as KERNEL_ARCH. Cleanest way is to get
|
| 46 |
# make-kpkg export it to this script.
|
| 47 |
#
|
| 48 |
# Currently we'll have to do some fiddling here For
|
| 49 |
# example for sparc we need to map sparc32* to 'sparc'
|
| 50 |
# and sparc64* to 'sparc64'. The default for other
|
| 51 |
# arches is the name of the architecture.
|
| 52 |
#
|
| 53 |
case ${DEB_HOST_ARCH} in
|
| 54 |
sparc*)
|
| 55 |
KERNEL_ARCH=${suffix%-smp}
|
| 56 |
KERNEL_ARCH=${KERNEL_ARCH%32}
|
| 57 |
;;
|
| 58 |
*)
|
| 59 |
KERNEL_ARCH=${DEB_HOST_ARCH}
|
| 60 |
;;
|
| 61 |
esac
|
| 62 |
|
| 63 |
debhelper_pre $pkg
|
| 64 |
|
| 65 |
#
|
| 66 |
# Stuff below is ugly as hell, but does the trick so I'm not
|
| 67 |
# touching it until we can invent something better.
|
| 68 |
#
|
| 69 |
mkdir -p $dir/include/linux
|
| 70 |
cp -a .config $dir
|
| 71 |
echo $debnum-$suffix > $dir/.extraversion
|
| 72 |
cp -a Module.symvers $dir
|
| 73 |
|
| 74 |
find . -mindepth 1 -maxdepth 1 \
|
| 75 |
! -name debian -a ! -name Documentation -a ! -name include -a \
|
| 76 |
! -name '.*' -a \( \
|
| 77 |
-name Makefile -o -type d \) \
|
| 78 |
-printf "../kernel-headers-$prefix/%f\n" |
|
| 79 |
xargs ln -s --target-directory="$dir"
|
| 80 |
|
| 81 |
cd include
|
| 82 |
find . -mindepth 1 -maxdepth 1 \
|
| 83 |
! -name config -a ! -name linux -a \( \
|
| 84 |
! -name 'asm-*' -o -name asm-generic -o -name asm-${KERNEL_ARCH} \) \
|
| 85 |
-printf "../../kernel-headers-$prefix/include/%f\n" |
|
| 86 |
xargs ln -s --target-directory=$dir/include
|
| 87 |
cp -a config $dir/include
|
| 88 |
ln -sf asm-${KERNEL_ARCH} $dir/include/asm
|
| 89 |
find linux -mindepth 1 -maxdepth 1 \
|
| 90 |
! -name autoconf.h -a ! -name compile.h -a ! -name version.h \
|
| 91 |
-printf "../../../kernel-headers-$prefix/include/linux/%f\n" |
|
| 92 |
xargs ln -s --target-directory=$dir/include/linux
|
| 93 |
cp -a linux/autoconf.h linux/compile.h \
|
| 94 |
linux/version.h $dir/include/linux
|
| 95 |
cd ..
|
| 96 |
|
| 97 |
mkdir -p $top/lib/modules/$version
|
| 98 |
ln -s /usr/src/kernel-headers-$version $top/lib/modules/$version/build
|
| 99 |
|
| 100 |
debhelper_post $pkg
|
| 101 |
|
| 102 |
#
|
| 103 |
# Check whether we should force any modules to be available
|
| 104 |
# on the initrd.
|
| 105 |
#
|
| 106 |
cd ${IMAGE_TOP}/lib/modules/${version}
|
| 107 |
modules='@initrd_modules@'
|
| 108 |
if [ -n "${modules}" ]; then
|
| 109 |
mkdir initrd
|
| 110 |
for i in ${modules}; do
|
| 111 |
if [ -f "${i}" ]; then
|
| 112 |
ln "${i}" initrd
|
| 113 |
fi
|
| 114 |
done
|
| 115 |
fi
|