11da177e4SLinus Torvalds#!/bin/sh 21da177e4SLinus Torvalds# 34964451aSFrans Pop# builddeb 1.3 41da177e4SLinus Torvalds# Copyright 2003 Wichert Akkerman <wichert@wiggy.net> 51da177e4SLinus Torvalds# 61da177e4SLinus Torvalds# Simple script to generate a deb package for a Linux kernel. All the 74f66199bSFrans Pop# complexity of what to do with a kernel after it is installed or removed 81da177e4SLinus Torvalds# is left to other scripts and packages: they can install scripts in the 9fe233cb6SFrans Pop# /etc/kernel/{pre,post}{inst,rm}.d/ directories (or an alternative location 10fe233cb6SFrans Pop# specified in KDEB_HOOKDIR) that will be called on package install and 11fe233cb6SFrans Pop# removal. 121da177e4SLinus Torvalds 131da177e4SLinus Torvaldsset -e 141da177e4SLinus Torvalds 153e2ab256SFrans Popcreate_package() { 163e2ab256SFrans Pop local pname="$1" pdir="$2" 173e2ab256SFrans Pop 18bf7b0055SRiku Voipio mkdir -m 755 -p "$pdir/DEBIAN" 19bf7b0055SRiku Voipio mkdir -p "$pdir/usr/share/doc/$pname" 209461f666SFrans Pop cp debian/copyright "$pdir/usr/share/doc/$pname/" 211ab18486Smaximilian attems cp debian/changelog "$pdir/usr/share/doc/$pname/changelog.Debian" 221ab18486Smaximilian attems gzip -9 "$pdir/usr/share/doc/$pname/changelog.Debian" 23b59a1225SFEJES Jozsef sh -c "cd '$pdir'; find . -type f ! -path './DEBIAN/*' -printf '%P\0' \ 24b59a1225SFEJES Jozsef | xargs -r0 md5sum > DEBIAN/md5sums" 259461f666SFrans Pop 263e2ab256SFrans Pop # Fix ownership and permissions 273e2ab256SFrans Pop chown -R root:root "$pdir" 283e2ab256SFrans Pop chmod -R go-w "$pdir" 293e2ab256SFrans Pop 30dca0c024SRiku Voipio # Create the package 31dca0c024SRiku Voipio dpkg-gencontrol $forcearch -Vkernel:debarch="${debarch}" -p$pname -P"$pdir" 32dca0c024SRiku Voipio dpkg --build "$pdir" .. 33dca0c024SRiku Voipio} 34dca0c024SRiku Voipio 35dca0c024SRiku Voipioset_debarch() { 3610f26fa6SAsbjoern Sloth Toennesen # Attempt to find the correct Debian architecture 3710f26fa6SAsbjoern Sloth Toennesen case "$UTS_MACHINE" in 3810f26fa6SAsbjoern Sloth Toennesen i386|ia64|alpha) 3910f26fa6SAsbjoern Sloth Toennesen debarch="$UTS_MACHINE" ;; 4010f26fa6SAsbjoern Sloth Toennesen x86_64) 4110f26fa6SAsbjoern Sloth Toennesen debarch=amd64 ;; 4210f26fa6SAsbjoern Sloth Toennesen sparc*) 4310f26fa6SAsbjoern Sloth Toennesen debarch=sparc ;; 4410f26fa6SAsbjoern Sloth Toennesen s390*) 45a1323fd1SBen Hutchings debarch=s390$(grep -q CONFIG_64BIT=y $KCONFIG_CONFIG && echo x || true) ;; 4610f26fa6SAsbjoern Sloth Toennesen ppc*) 4722739edfSMichael Neuling debarch=$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo ppc64el || echo powerpc) ;; 4810f26fa6SAsbjoern Sloth Toennesen parisc*) 4910f26fa6SAsbjoern Sloth Toennesen debarch=hppa ;; 5010f26fa6SAsbjoern Sloth Toennesen mips*) 51c5e318f6SBen Hutchings debarch=mips$(grep -q CPU_LITTLE_ENDIAN=y $KCONFIG_CONFIG && echo el || true) ;; 52a8d9c9f1SFathi Boudra arm64) 53a8d9c9f1SFathi Boudra debarch=arm64 ;; 5410f26fa6SAsbjoern Sloth Toennesen arm*) 5563a478fbSBen Hutchings if grep -q CONFIG_AEABI=y $KCONFIG_CONFIG; then 5663a478fbSBen Hutchings if grep -q CONFIG_VFP=y $KCONFIG_CONFIG; then 5763a478fbSBen Hutchings debarch=armhf 5863a478fbSBen Hutchings else 5963a478fbSBen Hutchings debarch=armel 6063a478fbSBen Hutchings fi 6163a478fbSBen Hutchings else 6263a478fbSBen Hutchings debarch=arm 6363a478fbSBen Hutchings fi 6463a478fbSBen Hutchings ;; 6510f26fa6SAsbjoern Sloth Toennesen *) 66dca0c024SRiku Voipio debarch=$(dpkg --print-architecture) 6710f26fa6SAsbjoern Sloth Toennesen echo "" >&2 6810f26fa6SAsbjoern Sloth Toennesen echo "** ** ** WARNING ** ** **" >&2 6910f26fa6SAsbjoern Sloth Toennesen echo "" >&2 7010f26fa6SAsbjoern Sloth Toennesen echo "Your architecture doesn't have it's equivalent" >&2 7110f26fa6SAsbjoern Sloth Toennesen echo "Debian userspace architecture defined!" >&2 7210f26fa6SAsbjoern Sloth Toennesen echo "Falling back to using your current userspace instead!" >&2 7310f26fa6SAsbjoern Sloth Toennesen echo "Please add support for $UTS_MACHINE to ${0} ..." >&2 7410f26fa6SAsbjoern Sloth Toennesen echo "" >&2 7510f26fa6SAsbjoern Sloth Toennesen esac 7655f88eccSAsbjoern Sloth Toennesen if [ -n "$KBUILD_DEBARCH" ] ; then 7755f88eccSAsbjoern Sloth Toennesen debarch="$KBUILD_DEBARCH" 7855f88eccSAsbjoern Sloth Toennesen fi 7910f26fa6SAsbjoern Sloth Toennesen forcearch="-DArchitecture=$debarch" 8010f26fa6SAsbjoern Sloth Toennesen 813e2ab256SFrans Pop} 823e2ab256SFrans Pop 831da177e4SLinus Torvalds# Some variables and settings used throughout the script 841da177e4SLinus Torvaldsversion=$KERNELRELEASE 854f66199bSFrans Poprevision=$(cat .version) 86c72c75dbSFrans Popif [ -n "$KDEB_PKGVERSION" ]; then 87c72c75dbSFrans Pop packageversion=$KDEB_PKGVERSION 88c72c75dbSFrans Popelse 89c72c75dbSFrans Pop packageversion=$version-$revision 90c72c75dbSFrans Popfi 913716001bSRiku Voipiosourcename=$KDEB_SOURCENAME 921da177e4SLinus Torvaldstmpdir="$objtree/debian/tmp" 93bf1b3644SJonathan McDowellfwdir="$objtree/debian/fwtmp" 94ee81b786Smaximilian attemskernel_headers_dir="$objtree/debian/hdrtmp" 95ee81b786Smaximilian attemslibc_headers_dir="$objtree/debian/headertmp" 96810e8437SAnisse Astierdbg_dir="$objtree/debian/dbgtmp" 97f7a2c31fSmaximilian attemspackagename=linux-image-$version 9895e2a7d8SHeinrich Schuchardtfwpackagename=linux-firmware-image-$version 99ee81b786Smaximilian attemskernel_headers_packagename=linux-headers-$version 100ee81b786Smaximilian attemslibc_headers_packagename=linux-libc-dev 101810e8437SAnisse Astierdbg_packagename=$packagename-dbg 102dca0c024SRiku Voipiodebarch= 103dca0c024SRiku Voipioforcearch= 104dca0c024SRiku Voipioset_debarch 105687c3dacSSam Ravnborg 1064f66199bSFrans Popif [ "$ARCH" = "um" ] ; then 107687c3dacSSam Ravnborg packagename=user-mode-linux-$version 108687c3dacSSam Ravnborgfi 1091da177e4SLinus Torvalds 1109de70176SAnisse Astier# Not all arches have the same installed path in debian 1119de70176SAnisse Astier# XXX: have each arch Makefile export a variable of the canonical image install 1129de70176SAnisse Astier# path instead 1139de70176SAnisse Astiercase $ARCH in 1149de70176SAnisse Astierum) 1159de70176SAnisse Astier installed_image_path="usr/bin/linux-$version" 1169de70176SAnisse Astier ;; 1179de70176SAnisse Astierparisc|mips|powerpc) 1189de70176SAnisse Astier installed_image_path="boot/vmlinux-$version" 1199de70176SAnisse Astier ;; 1209de70176SAnisse Astier*) 1219de70176SAnisse Astier installed_image_path="boot/vmlinuz-$version" 1229de70176SAnisse Astieresac 1239de70176SAnisse Astier 124810e8437SAnisse AstierBUILD_DEBUG="$(grep -s '^CONFIG_DEBUG_INFO=y' $KCONFIG_CONFIG || true)" 125810e8437SAnisse Astier 1261da177e4SLinus Torvalds# Setup the directory structure 1278d740a37SRiku Voipiorm -rf "$tmpdir" "$fwdir" "$kernel_headers_dir" "$libc_headers_dir" "$dbg_dir" $objtree/debian/files 128e86c2412Smaximilian attemsmkdir -m 755 -p "$tmpdir/DEBIAN" 129bf7b0055SRiku Voipiomkdir -p "$tmpdir/lib" "$tmpdir/boot" 130bf7b0055SRiku Voipiomkdir -p "$fwdir/lib/firmware/$version/" 131a47b6c61SJoerg Roedelmkdir -p "$kernel_headers_dir/lib/modules/$version/" 1321da177e4SLinus Torvalds 1331da177e4SLinus Torvalds# Build and install the kernel 1344f66199bSFrans Popif [ "$ARCH" = "um" ] ; then 135bf7b0055SRiku Voipio mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/bin" "$tmpdir/usr/share/doc/$packagename" 136687c3dacSSam Ravnborg $MAKE linux 137687c3dacSSam Ravnborg cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map" 138d2091767SAnisse Astier cp $KCONFIG_CONFIG "$tmpdir/usr/share/doc/$packagename/config" 139687c3dacSSam Ravnborg gzip "$tmpdir/usr/share/doc/$packagename/config" 140687c3dacSSam Ravnborgelse 1411da177e4SLinus Torvalds cp System.map "$tmpdir/boot/System.map-$version" 142d2091767SAnisse Astier cp $KCONFIG_CONFIG "$tmpdir/boot/config-$version" 1439de70176SAnisse Astierfi 144a89b433bSFrans Pop# Not all arches include the boot path in KBUILD_IMAGE 145242c5ab0SGuillem Joverif [ -e $KBUILD_IMAGE ]; then 1469de70176SAnisse Astier cp $KBUILD_IMAGE "$tmpdir/$installed_image_path" 147242c5ab0SGuillem Joverelse 1489de70176SAnisse Astier cp arch/$ARCH/boot/$KBUILD_IMAGE "$tmpdir/$installed_image_path" 149687c3dacSSam Ravnborgfi 1501da177e4SLinus Torvalds 151ca2a9d2cSArnaud Patard (Rtp)if grep -q "^CONFIG_OF=y" $KCONFIG_CONFIG ; then 152ca2a9d2cSArnaud Patard (Rtp) # Only some architectures with OF support have this target 153ca2a9d2cSArnaud Patard (Rtp) if grep -q dtbs_install "${srctree}/arch/$SRCARCH/Makefile"; then 154ca2a9d2cSArnaud Patard (Rtp) $MAKE KBUILD_SRC= INSTALL_DTBS_PATH="$tmpdir/usr/lib/$packagename" dtbs_install 155ca2a9d2cSArnaud Patard (Rtp) fi 156ca2a9d2cSArnaud Patard (Rtp)fi 157ca2a9d2cSArnaud Patard (Rtp) 158d2091767SAnisse Astierif grep -q '^CONFIG_MODULES=y' $KCONFIG_CONFIG ; then 159dddcbb7cSJoerg Roedel INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_install 160a47b6c61SJoerg Roedel rm -f "$tmpdir/lib/modules/$version/build" 161a47b6c61SJoerg Roedel rm -f "$tmpdir/lib/modules/$version/source" 1624f66199bSFrans Pop if [ "$ARCH" = "um" ] ; then 163687c3dacSSam Ravnborg mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/" 164687c3dacSSam Ravnborg rmdir "$tmpdir/lib/modules/$version" 165687c3dacSSam Ravnborg fi 166810e8437SAnisse Astier if [ -n "$BUILD_DEBUG" ] ; then 1672d087139SMichal Marek for module in $(find $tmpdir/lib/modules/ -name *.ko -printf '%P\n'); do 1682d087139SMichal Marek module=lib/modules/$module 169810e8437SAnisse Astier mkdir -p $(dirname $dbg_dir/usr/lib/debug/$module) 170810e8437SAnisse Astier # only keep debug symbols in the debug file 1712d087139SMichal Marek $OBJCOPY --only-keep-debug $tmpdir/$module $dbg_dir/usr/lib/debug/$module 172810e8437SAnisse Astier # strip original module from debug symbols 1732d087139SMichal Marek $OBJCOPY --strip-debug $tmpdir/$module 174810e8437SAnisse Astier # then add a link to those 1752d087139SMichal Marek $OBJCOPY --add-gnu-debuglink=$dbg_dir/usr/lib/debug/$module $tmpdir/$module 176810e8437SAnisse Astier done 17764178cb6SAndrey Skvortsov 17864178cb6SAndrey Skvortsov # resign stripped modules 17964178cb6SAndrey Skvortsov MODULE_SIG_ALL="$(grep -s '^CONFIG_MODULE_SIG_ALL=y' $KCONFIG_CONFIG || true)" 18064178cb6SAndrey Skvortsov if [ -n "$MODULE_SIG_ALL" ]; then 18164178cb6SAndrey Skvortsov INSTALL_MOD_PATH="$tmpdir" $MAKE KBUILD_SRC= modules_sign 18264178cb6SAndrey Skvortsov fi 183810e8437SAnisse Astier fi 1841da177e4SLinus Torvaldsfi 1851da177e4SLinus Torvalds 186d7d357bcSJoerg Roedelif [ "$ARCH" != "um" ]; then 187dddcbb7cSJoerg Roedel $MAKE headers_check KBUILD_SRC= 188dddcbb7cSJoerg Roedel $MAKE headers_install KBUILD_SRC= INSTALL_HDR_PATH="$libc_headers_dir/usr" 189d7d357bcSJoerg Roedelfi 190e6807785Smaximilian attems 1911da177e4SLinus Torvalds# Install the maintainer scripts 192fe233cb6SFrans Pop# Note: hook scripts under /etc/kernel are also executed by official Debian 1931c8ddae0SBen Hutchings# kernel packages, as well as kernel packages built using make-kpkg. 1941c8ddae0SBen Hutchings# make-kpkg sets $INITRD to indicate whether an initramfs is wanted, and 1951c8ddae0SBen Hutchings# so do we; recent versions of dracut and initramfs-tools will obey this. 196fe233cb6SFrans Popdebhookdir=${KDEB_HOOKDIR:-/etc/kernel} 1971c8ddae0SBen Hutchingsif grep -q '^CONFIG_BLK_DEV_INITRD=y' $KCONFIG_CONFIG; then 1981c8ddae0SBen Hutchings want_initrd=Yes 1991c8ddae0SBen Hutchingselse 2001c8ddae0SBen Hutchings want_initrd=No 2011c8ddae0SBen Hutchingsfi 2021da177e4SLinus Torvaldsfor script in postinst postrm preinst prerm ; do 203fe233cb6SFrans Pop mkdir -p "$tmpdir$debhookdir/$script.d" 2041da177e4SLinus Torvalds cat <<EOF > "$tmpdir/DEBIAN/$script" 2051da177e4SLinus Torvalds#!/bin/sh 2061da177e4SLinus Torvalds 2071da177e4SLinus Torvaldsset -e 2081da177e4SLinus Torvalds 2094964451aSFrans Pop# Pass maintainer script parameters to hook scripts 210241ad11fSmaximilian attemsexport DEB_MAINT_PARAMS="\$*" 2114964451aSFrans Pop 2121c8ddae0SBen Hutchings# Tell initramfs builder whether it's wanted 2131c8ddae0SBen Hutchingsexport INITRD=$want_initrd 2141c8ddae0SBen Hutchings 215c95182bfSAnisse Astiertest -d $debhookdir/$script.d && run-parts --arg="$version" --arg="/$installed_image_path" $debhookdir/$script.d 2161da177e4SLinus Torvaldsexit 0 2171da177e4SLinus TorvaldsEOF 2181da177e4SLinus Torvalds chmod 755 "$tmpdir/DEBIAN/$script" 2191da177e4SLinus Torvaldsdone 2201da177e4SLinus Torvalds 221edec611dSmaximilian attems# Try to determine maintainer and email values 222edec611dSmaximilian attemsif [ -n "$DEBEMAIL" ]; then 223edec611dSmaximilian attems email=$DEBEMAIL 224edec611dSmaximilian attemselif [ -n "$EMAIL" ]; then 225edec611dSmaximilian attems email=$EMAIL 226edec611dSmaximilian attemselse 227bea107b1SChristian Kujau email=$(id -nu)@$(hostname -f 2>/dev/null || hostname) 228edec611dSmaximilian attemsfi 229edec611dSmaximilian attemsif [ -n "$DEBFULLNAME" ]; then 230edec611dSmaximilian attems name=$DEBFULLNAME 231edec611dSmaximilian attemselif [ -n "$NAME" ]; then 232edec611dSmaximilian attems name=$NAME 233edec611dSmaximilian attemselse 234edec611dSmaximilian attems name="Anonymous" 235edec611dSmaximilian attemsfi 236edec611dSmaximilian attemsmaintainer="$name <$email>" 237edec611dSmaximilian attems 238d9f711dbSSedat Dilek# Try to determine distribution 239d9f711dbSSedat Dilekif [ -n "$KDEB_CHANGELOG_DIST" ]; then 240d9f711dbSSedat Dilek distribution=$KDEB_CHANGELOG_DIST 241d9f711dbSSedat Dilekelif distribution=$(lsb_release -cs 2>/dev/null) && [ -n "$distribution" ]; then 242d9f711dbSSedat Dilek : # nothing to do in this case 243d9f711dbSSedat Dilekelse 244d9f711dbSSedat Dilek distribution="unstable" 245d9f711dbSSedat Dilek echo >&2 "Using default distribution of 'unstable' in the changelog" 246d9f711dbSSedat Dilek echo >&2 "Install lsb-release or set \$KDEB_CHANGELOG_DIST explicitly" 247d9f711dbSSedat Dilekfi 248d9f711dbSSedat Dilek 2491da177e4SLinus Torvalds# Generate a simple changelog template 2501da177e4SLinus Torvaldscat <<EOF > debian/changelog 2513716001bSRiku Voipio$sourcename ($packageversion) $distribution; urgency=low 2521da177e4SLinus Torvalds 253a83ca277SFrans Pop * Custom built Linux kernel. 2541da177e4SLinus Torvalds 255edec611dSmaximilian attems -- $maintainer $(date -R) 2561da177e4SLinus TorvaldsEOF 2571da177e4SLinus Torvalds 2589461f666SFrans Pop# Generate copyright file 2599461f666SFrans Popcat <<EOF > debian/copyright 2609461f666SFrans PopThis is a packacked upstream version of the Linux kernel. 2619461f666SFrans Pop 2629461f666SFrans PopThe sources may be found at most Linux ftp sites, including: 2639461f666SFrans Popftp://ftp.kernel.org/pub/linux/kernel 2649461f666SFrans Pop 265701ca30cSSedat DilekCopyright: 1991 - 2015 Linus Torvalds and others. 2669461f666SFrans Pop 2679461f666SFrans PopThe git repository for mainline kernel development is at: 268701ca30cSSedat Dilekgit://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 2699461f666SFrans Pop 2709461f666SFrans Pop This program is free software; you can redistribute it and/or modify 2719461f666SFrans Pop it under the terms of the GNU General Public License as published by 2729461f666SFrans Pop the Free Software Foundation; version 2 dated June, 1991. 2739461f666SFrans Pop 2749461f666SFrans PopOn Debian GNU/Linux systems, the complete text of the GNU General Public 2759461f666SFrans PopLicense version 2 can be found in \`/usr/share/common-licenses/GPL-2'. 2769461f666SFrans PopEOF 2779461f666SFrans Pop 2783716001bSRiku Voipio 2793716001bSRiku Voipiobuild_depends="bc, kmod, cpio " 2803716001bSRiku Voipio 2811da177e4SLinus Torvalds# Generate a control file 2821da177e4SLinus Torvaldscat <<EOF > debian/control 2833716001bSRiku VoipioSource: $sourcename 284aa42abedSRogério BritoSection: kernel 2851da177e4SLinus TorvaldsPriority: optional 286edec611dSmaximilian attemsMaintainer: $maintainer 2873716001bSRiku VoipioBuild-Depends: $build_depends 2882d7204acSRogério BritoStandards-Version: 3.8.4 289ee6eed80SRogério BritoHomepage: http://www.kernel.org/ 2903e2ab256SFrans PopEOF 2913e2ab256SFrans Pop 2923e2ab256SFrans Popif [ "$ARCH" = "um" ]; then 2933e2ab256SFrans Pop cat <<EOF >> debian/control 2941da177e4SLinus Torvalds 295687c3dacSSam RavnborgPackage: $packagename 2968ebc2fe9Smaximilian attemsProvides: linux-image, linux-image-2.6, linux-modules-$version 2971da177e4SLinus TorvaldsArchitecture: any 298dc5962fdSSam RavnborgDescription: User Mode Linux kernel, version $version 299dc5962fdSSam Ravnborg User-mode Linux is a port of the Linux kernel to its own system call 300dc5962fdSSam Ravnborg interface. It provides a kind of virtual machine, which runs Linux 301dc5962fdSSam Ravnborg as a user process under another Linux kernel. This is useful for 302dc5962fdSSam Ravnborg kernel development, sandboxes, jails, experimentation, and 303dc5962fdSSam Ravnborg many other things. 304dc5962fdSSam Ravnborg . 3051da177e4SLinus Torvalds This package contains the Linux kernel, modules and corresponding other 306a83ca277SFrans Pop files, version: $version. 3071da177e4SLinus TorvaldsEOF 3081da177e4SLinus Torvalds 309dc5962fdSSam Ravnborgelse 3103e2ab256SFrans Pop cat <<EOF >> debian/control 311dc5962fdSSam Ravnborg 312dc5962fdSSam RavnborgPackage: $packagename 3138ebc2fe9Smaximilian attemsProvides: linux-image, linux-image-2.6, linux-modules-$version 314bf1b3644SJonathan McDowellSuggests: $fwpackagename 315dc5962fdSSam RavnborgArchitecture: any 316dc5962fdSSam RavnborgDescription: Linux kernel, version $version 317dc5962fdSSam Ravnborg This package contains the Linux kernel, modules and corresponding other 318a83ca277SFrans Pop files, version: $version. 319dc5962fdSSam RavnborgEOF 3204f66199bSFrans Pop 321dc5962fdSSam Ravnborgfi 322dc5962fdSSam Ravnborg 3238bf13561SFathi Boudra# Build kernel header package 324a765a7ceSMichal Marek(cd $srctree; find . -name Makefile\* -o -name Kconfig\* -o -name \*.pl) > "$objtree/debian/hdrsrcfiles" 325962475acSAzriel Samson(cd $srctree; find arch/*/include include scripts -type f) >> "$objtree/debian/hdrsrcfiles" 3268bf13561SFathi Boudra(cd $srctree; find arch/$SRCARCH -name module.lds -o -name Kbuild.platforms -o -name Platform) >> "$objtree/debian/hdrsrcfiles" 3278bf13561SFathi Boudra(cd $srctree; find $(find arch/$SRCARCH -name include -o -name scripts -type d) -type f) >> "$objtree/debian/hdrsrcfiles" 32815f6d337SWilfried Klaebeif grep -q '^CONFIG_STACK_VALIDATION=y' $KCONFIG_CONFIG ; then 32915f6d337SWilfried Klaebe (cd $objtree; find tools/objtool -type f -executable) >> "$objtree/debian/hdrobjfiles" 33015f6d337SWilfried Klaebefi 331a765a7ceSMichal Marek(cd $objtree; find arch/$SRCARCH/include Module.symvers include scripts -type f) >> "$objtree/debian/hdrobjfiles" 332ee81b786Smaximilian attemsdestdir=$kernel_headers_dir/usr/src/linux-headers-$version 333ee81b786Smaximilian attemsmkdir -p "$destdir" 334a765a7ceSMichal Marek(cd $srctree; tar -c -f - -T -) < "$objtree/debian/hdrsrcfiles" | (cd $destdir; tar -xf -) 335a765a7ceSMichal Marek(cd $objtree; tar -c -f - -T -) < "$objtree/debian/hdrobjfiles" | (cd $destdir; tar -xf -) 336d2091767SAnisse Astier(cd $objtree; cp $KCONFIG_CONFIG $destdir/.config) # copy .config manually to be where it's expected to be 337a47b6c61SJoerg Roedelln -sf "/usr/src/linux-headers-$version" "$kernel_headers_dir/lib/modules/$version/build" 3386c635224SBen Hutchingsrm -f "$objtree/debian/hdrsrcfiles" "$objtree/debian/hdrobjfiles" 339cd8d60a2STheodore Ts'o 340cd8d60a2STheodore Ts'ocat <<EOF >> debian/control 341cd8d60a2STheodore Ts'o 342ee81b786Smaximilian attemsPackage: $kernel_headers_packagename 343cd8d60a2STheodore Ts'oProvides: linux-headers, linux-headers-2.6 344f8ce239dSBen HutchingsArchitecture: any 345f8ce239dSBen HutchingsDescription: Linux kernel headers for $KERNELRELEASE on \${kernel:debarch} 346f8ce239dSBen Hutchings This package provides kernel header files for $KERNELRELEASE on \${kernel:debarch} 347cd8d60a2STheodore Ts'o . 348cd8d60a2STheodore Ts'o This is useful for people who need to build external modules 349cd8d60a2STheodore Ts'oEOF 350cd8d60a2STheodore Ts'o 351bf1b3644SJonathan McDowell# Do we have firmware? Move it out of the way and build it into a package. 352bf1b3644SJonathan McDowellif [ -e "$tmpdir/lib/firmware" ]; then 3536607ddadSmaximilian attems mv "$tmpdir/lib/firmware"/* "$fwdir/lib/firmware/$version/" 3546607ddadSmaximilian attems rmdir "$tmpdir/lib/firmware" 355bf1b3644SJonathan McDowell 356bf1b3644SJonathan McDowell cat <<EOF >> debian/control 357bf1b3644SJonathan McDowell 358bf1b3644SJonathan McDowellPackage: $fwpackagename 359bf1b3644SJonathan McDowellArchitecture: all 360bf1b3644SJonathan McDowellDescription: Linux kernel firmware, version $version 361a83ca277SFrans Pop This package contains firmware from the Linux kernel, version $version. 362bf1b3644SJonathan McDowellEOF 363bf1b3644SJonathan McDowell 3643e2ab256SFrans Pop create_package "$fwpackagename" "$fwdir" 365bf1b3644SJonathan McDowellfi 366bf1b3644SJonathan McDowell 367e6807785Smaximilian attemscat <<EOF >> debian/control 368e6807785Smaximilian attems 369ee81b786Smaximilian attemsPackage: $libc_headers_packagename 370e6807785Smaximilian attemsSection: devel 371e6807785Smaximilian attemsProvides: linux-kernel-headers 372e6807785Smaximilian attemsArchitecture: any 373e6807785Smaximilian attemsDescription: Linux support headers for userspace development 374e6807785Smaximilian attems This package provides userspaces headers from the Linux kernel. These headers 375e6807785Smaximilian attems are used by the installed headers for GNU glibc and other system libraries. 376e6807785Smaximilian attemsEOF 377e6807785Smaximilian attems 378d7d357bcSJoerg Roedelif [ "$ARCH" != "um" ]; then 379d7d357bcSJoerg Roedel create_package "$kernel_headers_packagename" "$kernel_headers_dir" 380ee81b786Smaximilian attems create_package "$libc_headers_packagename" "$libc_headers_dir" 381d7d357bcSJoerg Roedelfi 382d7d357bcSJoerg Roedel 3833e2ab256SFrans Popcreate_package "$packagename" "$tmpdir" 3841da177e4SLinus Torvalds 385810e8437SAnisse Astierif [ -n "$BUILD_DEBUG" ] ; then 386810e8437SAnisse Astier # Build debug package 387810e8437SAnisse Astier # Different tools want the image in different locations 388810e8437SAnisse Astier # perf 389810e8437SAnisse Astier mkdir -p $dbg_dir/usr/lib/debug/lib/modules/$version/ 390810e8437SAnisse Astier cp vmlinux $dbg_dir/usr/lib/debug/lib/modules/$version/ 391810e8437SAnisse Astier # systemtap 392810e8437SAnisse Astier mkdir -p $dbg_dir/usr/lib/debug/boot/ 393810e8437SAnisse Astier ln -s ../lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/boot/vmlinux-$version 394810e8437SAnisse Astier # kdump-tools 395810e8437SAnisse Astier ln -s lib/modules/$version/vmlinux $dbg_dir/usr/lib/debug/vmlinux-$version 396810e8437SAnisse Astier 397810e8437SAnisse Astier cat <<EOF >> debian/control 398810e8437SAnisse Astier 399810e8437SAnisse AstierPackage: $dbg_packagename 400810e8437SAnisse AstierSection: debug 401810e8437SAnisse AstierProvides: linux-debug, linux-debug-$version 402810e8437SAnisse AstierArchitecture: any 403810e8437SAnisse AstierDescription: Linux kernel debugging symbols for $version 404810e8437SAnisse Astier This package will come in handy if you need to debug the kernel. It provides 405810e8437SAnisse Astier all the necessary debug symbols for the kernel and its modules. 406810e8437SAnisse AstierEOF 407810e8437SAnisse Astier 408810e8437SAnisse Astier create_package "$dbg_packagename" "$dbg_dir" 409810e8437SAnisse Astierfi 410810e8437SAnisse Astier 4113716001bSRiku Voipioif [ "x$1" = "xdeb-pkg" ] 4123716001bSRiku Voipiothen 4133716001bSRiku Voipio cat <<EOF > debian/rules 4143716001bSRiku Voipio#!/usr/bin/make -f 4153716001bSRiku Voipio 4163716001bSRiku Voipiobuild: 4173716001bSRiku Voipio \$(MAKE) 4183716001bSRiku Voipio 4193716001bSRiku Voipiobinary-arch: 4203716001bSRiku Voipio \$(MAKE) KDEB_SOURCENAME=${sourcename} KDEB_PKGVERSION=${packageversion} bindeb-pkg 4213716001bSRiku Voipio 4223716001bSRiku Voipioclean: 4238d740a37SRiku Voipio rm -rf debian/*tmp debian/files 4243716001bSRiku Voipio mv debian/ debian.backup # debian/ might be cleaned away 4253716001bSRiku Voipio \$(MAKE) clean 4263716001bSRiku Voipio mv debian.backup debian 4273716001bSRiku Voipio 4283716001bSRiku Voipiobinary: binary-arch 4293716001bSRiku VoipioEOF 4303716001bSRiku Voipio mv ${sourcename}.tar.gz ../${sourcename}_${version}.orig.tar.gz 4313716001bSRiku Voipio tar caf ../${sourcename}_${packageversion}.debian.tar.gz debian/{copyright,rules,changelog,control} 4323716001bSRiku Voipio dpkg-source -cdebian/control -ldebian/changelog --format="3.0 (custom)" --target-format="3.0 (quilt)" \ 4333716001bSRiku Voipio -b / ../${sourcename}_${version}.orig.tar.gz ../${sourcename}_${packageversion}.debian.tar.gz 4343716001bSRiku Voipio mv ${sourcename}_${packageversion}*dsc .. 4353716001bSRiku Voipio dpkg-genchanges > ../${sourcename}_${packageversion}_${debarch}.changes 4363716001bSRiku Voipioelse 4373716001bSRiku Voipio dpkg-genchanges -b > ../${sourcename}_${packageversion}_${debarch}.changes 4383716001bSRiku Voipiofi 4393716001bSRiku Voipio 4401da177e4SLinus Torvaldsexit 0 441