155 lines
4.6 KiB
Bash
155 lines
4.6 KiB
Bash
#!/bin/bash
|
|
#
|
|
# This is the hook file executed by make-kpkg in the end of creation
|
|
# of the linux-image for a particular flavour. The major task it performs
|
|
# is the creation of the flavour-specific linux-headers package.
|
|
#
|
|
set -e
|
|
|
|
debhelper_pre() {
|
|
dh_clean -k --package="$1"
|
|
dh_installdirs --package="$1"
|
|
}
|
|
|
|
debhelper_post() {
|
|
dh_installdocs --package="$1"
|
|
dh_installchangelogs --package="$1"
|
|
dh_compress --package="$1"
|
|
dh_fixperms --package="$1"
|
|
dh_strip --package="$1"
|
|
dh_installdeb --package="$1"
|
|
dh_gencontrol --package="$1"
|
|
dh_md5sums --package="$1"
|
|
dh_builddeb --package="$1"
|
|
}
|
|
# The version which ends up here is something like
|
|
# $(version)-$(abiname)-$(flavour) and debnum is just
|
|
# -$(abiname), so that the variables get the values:
|
|
# suffix=$(flavour)
|
|
# prefix=$(version)-$(abiname)
|
|
# prefix is then used to form a destination directory
|
|
# to link to. For cases with subarch we need to link
|
|
# to linux-headers-$(subarch)-$(version)-$(abiname),
|
|
# not just linux-headers-$(version)-$(abiname).
|
|
#
|
|
prefix="$DEBIAN_VERSION$DEBIAN_LOCALVERSION_HEADERS"
|
|
pkg="linux-headers-$DEBIAN_VERSION$DEBIAN_LOCALVERSION"
|
|
top="$PWD/debian/$pkg"
|
|
dir="$top/usr/src/$pkg"
|
|
#
|
|
# Here we need to find the kernel architecture which
|
|
# is appropriate for the current flavour. It is available
|
|
# in kernel-package as KERNEL_ARCH. Cleanest way is to get
|
|
# make-kpkg export it to this script.
|
|
#
|
|
# Currently we just use the fact that in the build directory
|
|
# the symlink include/asm must point to include/asm-${arch}
|
|
#
|
|
arch="$(readlink include/asm)"
|
|
arch="$(basename "${arch}")"
|
|
arch="${arch#asm-}"
|
|
|
|
debhelper_pre "$pkg"
|
|
|
|
#
|
|
# Stuff below is ugly as hell, but does the trick so I'm not
|
|
# touching it until we can invent something better.
|
|
#
|
|
mkdir -p "$dir/arch/$arch/kernel"
|
|
mkdir -p "$dir/include/linux"
|
|
cp -a .config "$dir"
|
|
echo "$DEBIAN_LOCALVERSION" > "$dir/localversion"
|
|
|
|
cp -a Module.symvers "$dir"
|
|
|
|
find . -mindepth 1 -maxdepth 1 \
|
|
! -name debian -a ! -name Documentation -a ! -name include -a \
|
|
! -name DEBIAN -a ! -name scripts -a ! -name arch -a ! -name '.*' -a \( \
|
|
-name Makefile -o -type d \) \
|
|
-printf "../linux-headers-$prefix/%f\n" |
|
|
xargs ln -s --target-directory="$dir"
|
|
|
|
find "arch/$arch" -mindepth 1 -maxdepth 1 \( \
|
|
-type d -a ! -name include -a ! -name kernel -o \
|
|
-type f -a \( -name 'Makefile*' -o -name 'Kconfig*' \) \) \
|
|
-printf "../../../linux-headers-$prefix/%p\n" |
|
|
xargs ln -s --target-directory="$dir/arch/$arch"
|
|
if [ -d arch/$arch/include ]; then
|
|
cp -a arch/$arch/include $dir/arch/$arch/include
|
|
fi
|
|
[ -f "arch/$arch/kernel/asm-offsets.s" ] && ln -f "arch/$arch/kernel/asm-offsets.s" "$dir/arch/$arch/kernel"
|
|
ln -s "../../../../linux-headers-$prefix/arch/$arch/kernel/Makefile" "$dir/arch/$arch/kernel"
|
|
find include -mindepth 1 -maxdepth 1 \
|
|
! -name config -a ! -name linux -a ! -name 'asm-*' \
|
|
-printf "../../linux-headers-$prefix/%p\n" |
|
|
xargs ln -s --target-directory="$dir/include"
|
|
cp -a include/config "$dir/include"
|
|
|
|
ln -sf "asm-${arch}" "$dir/include/asm"
|
|
for i in generic $KERNEL_HEADER_DIRS; do
|
|
mkdir "$dir/include/asm-$i"
|
|
find "include/asm-$i" -mindepth 1 -maxdepth 1 \
|
|
\( -type f -a ! -links 2 -o ! -type f \) \
|
|
-printf "../../../linux-headers-$prefix/%p\n" |
|
|
xargs --no-run-if-empty ln -s --target-directory="$dir/include/asm-$i"
|
|
find "include/asm-$i" -mindepth 1 -maxdepth 1 \
|
|
-type f -links 2 |
|
|
xargs --no-run-if-empty ln -f --target-directory="$dir/include/asm-$i"
|
|
done
|
|
|
|
find include/linux -mindepth 1 -maxdepth 1 \
|
|
! -name autoconf.h -a ! -name compile.h -a ! -name version.h \
|
|
-printf "../../../linux-headers-$prefix/%p\n" |
|
|
xargs ln -s --target-directory="$dir/include/linux"
|
|
cp -a include/linux/autoconf.h include/linux/compile.h \
|
|
include/linux/version.h "$dir/include/linux"
|
|
|
|
mkdir -p "$top/lib/modules/$version"
|
|
ln -s "/usr/src/linux-headers-$version" "$top/lib/modules/$version/build"
|
|
|
|
# Populate the scripts directory. The strategy here is to specify what
|
|
# *not* to copy, to make things a little bit more robust. We first create
|
|
# a file with exclude patterns, then copy everything minus excluded files.
|
|
#
|
|
cat > scripts-exclude <<EXCLUDES
|
|
*.c
|
|
*.c_shipped
|
|
*.h
|
|
*.y
|
|
*.l
|
|
*.gperf
|
|
*POTFILES.in
|
|
*.gitignore
|
|
*lxdialog*
|
|
*package*
|
|
EXCLUDES
|
|
tar cfh - -X scripts-exclude scripts | (cd "$dir"; umask 000; tar xsf -)
|
|
rm -f script-exclude
|
|
|
|
debhelper_post "$pkg"
|
|
|
|
#
|
|
# Check whether we should force any modules to be available
|
|
# on the initrd.
|
|
#
|
|
cd "${IMAGE_TOP}/lib/modules/${version}"
|
|
modules='@initrd_modules@'
|
|
if [ -n "${modules}" ]; then
|
|
mkdir initrd
|
|
for i in ${modules}; do
|
|
if [ -f "${i}" ]; then
|
|
ln "${i}" initrd
|
|
fi
|
|
done
|
|
fi
|
|
|
|
#
|
|
# Clean up the build and source symlinks
|
|
#
|
|
if [ -L build ]; then
|
|
rm -f build
|
|
fi
|
|
if [ -L source ]; then
|
|
rm -f source
|
|
fi
|