builddeb 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #!/bin/sh
  2. #
  3. # builddeb 1.2
  4. # Copyright 2003 Wichert Akkerman <wichert@wiggy.net>
  5. #
  6. # Simple script to generate a deb package for a Linux kernel. All the
  7. # complexity of what to do with a kernel after it is installer or removed
  8. # is left to other scripts and packages: they can install scripts in the
  9. # /etc/kernel/{pre,post}{inst,rm}.d/ directories that will be called on
  10. # package install and removal.
  11. set -e
  12. # Some variables and settings used throughout the script
  13. version=$KERNELRELEASE
  14. tmpdir="$objtree/debian/tmp"
  15. # Setup the directory structure
  16. rm -rf "$tmpdir"
  17. mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot"
  18. # Build and install the kernel
  19. cp System.map "$tmpdir/boot/System.map-$version"
  20. cp .config "$tmpdir/boot/config-$version"
  21. cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
  22. if grep -q '^CONFIG_MODULES=y' .config ; then
  23. INSTALL_MOD_PATH="$tmpdir" make modules_install
  24. fi
  25. # Install the maintainer scripts
  26. for script in postinst postrm preinst prerm ; do
  27. mkdir -p "$tmpdir/etc/kernel/$script.d"
  28. cat <<EOF > "$tmpdir/DEBIAN/$script"
  29. #!/bin/sh
  30. set -e
  31. test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d
  32. exit 0
  33. EOF
  34. chmod 755 "$tmpdir/DEBIAN/$script"
  35. done
  36. name="Kernel Compiler <$(id -nu)@$(hostname -f)>"
  37. # Generate a simple changelog template
  38. cat <<EOF > debian/changelog
  39. linux ($version) unstable; urgency=low
  40. * A standard release
  41. -- $name $(date -R)
  42. EOF
  43. # Generate a control file
  44. cat <<EOF > debian/control
  45. Source: linux
  46. Section: base
  47. Priority: optional
  48. Maintainer: $name
  49. Standards-Version: 3.6.1
  50. Package: linux-$version
  51. Architecture: any
  52. Description: Linux kernel, version $version
  53. This package contains the Linux kernel, modules and corresponding other
  54. files version $version.
  55. EOF
  56. # Fix some ownership and permissions
  57. chown -R root:root "$tmpdir"
  58. chmod -R go-w "$tmpdir"
  59. # Perform the final magic
  60. dpkg-gencontrol -isp
  61. dpkg --build "$tmpdir" ..
  62. exit 0