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 96
|
#!/bin/sh
set -e
do_dprint=1
dprint() {
[ -z "$do_dprint" ] || echo "$*"
}
die() {
echo "$*" >&2
exit 1
}
getkpkgvar() {
awk -F " *:= *" "\$1 == \"$1\" { print \$2 }" /etc/kernel-pkg.conf
}
getlinuxvar() {
awk -F " *= *" "\$1 == \"$1\" { print \$2 }" $KSRC/Makefile
}
if [ -f /etc/kernel-pkg.conf ]; then
[ -n "$KMAINT" ] || KMAINT=`getkpkgvar maintainer`
[ -n "$KEMAIL" ] || KEMAIL=`getkpkgvar email`
[ -n "$KDREV" ] || KDREV=`getkpkgvar debian`
[ -n "$ROOTCMD" ] || ROOTCMD=`getkpkgvar root_cmd`
fi
if [ -z "$KMAINT" ]; then
dprint "Inventing maintainer name"
KMAINT="Kernel maintainer"
fi
if [ -z "$KEMAIL" ]; then
dprint "Inventing maintainer email"
if [ -f "/etc/mailname" ]; then
domain=`cat /etc/mailname`
else
domain=`hostname --fqdn`
fi
KEMAIL="${LOGNAME-${USER-root}}"
fi
if [ -z "$KDREV" ]; then
dprint "Inventing debian rev."
KDREV="custom"
fi
if [ -z "$KSRC" ]; then
dprint "Looking for kernel source"
if [ -d "/usr/src/linux" ]; then
KSRC="/usr/src/linux"
elif [ -d "$PWD/linux" ]; then
KSRC="$PWD/linux"
else
die "Unable to find kernel source"
fi
dprint "Found kernel source in $KSRC"
fi
if [ -z "$ROOTCMD" ]; then
dprint "Looking for root cmd"
if [ -f "/usr/bin/fakeroot" ]; then
ROOTCMD=fakeroot
elif [ -f "/usr/bin/sudo" ]; then
ROOTCMD=sudo
fi
dprint "Using $ROOTCMD as root cmd"
fi
KVERS="`getlinuxvar VERSION`.`getlinuxvar PATCHLEVEL`.`getlinuxvar SUBLEVEL``getlinuxvar EXTRAVERSION`"
export KMAINT KEMAIL KDREV KSRC KVERS
# Where are we?
if [ ! -f debian/rules ]; then
# No debian/rules file, try standard place
if [ -f /usr/src/modules/thinkpad/debian/rules ]; then
dprint "Entering directory \"/usr/src/modules/thinkpad\""
cd /usr/src/modules/thinkpad || die "Unable to chdir to /usr/src/modules/thinkpad"
fi
fi
if [ "$1" = "clean" ]; then
dprint "buildpkg: Cleaning up"
$ROOTCMD debian/rules kdist_clean
else
dprint "buildpkg: Making essential files"
debian/rules kdist_configure
# There's no kdist_* target that means "do all the non-root building
# now", unless you count kdist_configure, which I don't.
dprint "buildpkg: Building package"
$ROOTCMD debian/rules kdist_image
fi
|