builddeb 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  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. revision=`cat .version`
  15. tmpdir="$objtree/debian/tmp"
  16. packagename=linux-$version
  17. if [ "$ARCH" == "um" ] ; then
  18. packagename=user-mode-linux-$version
  19. fi
  20. # Setup the directory structure
  21. rm -rf "$tmpdir"
  22. mkdir -p "$tmpdir/DEBIAN" "$tmpdir/lib" "$tmpdir/boot"
  23. if [ "$ARCH" == "um" ] ; then
  24. mkdir -p "$tmpdir/usr/lib/uml/modules/$version" "$tmpdir/usr/share/doc/$packagename" "$tmpdir/usr/bin"
  25. fi
  26. # Build and install the kernel
  27. if [ "$ARCH" == "um" ] ; then
  28. $MAKE linux
  29. cp System.map "$tmpdir/usr/lib/uml/modules/$version/System.map"
  30. cp .config "$tmpdir/usr/share/doc/$packagename/config"
  31. gzip "$tmpdir/usr/share/doc/$packagename/config"
  32. cp $KBUILD_IMAGE "$tmpdir/usr/bin/linux-$version"
  33. else
  34. cp System.map "$tmpdir/boot/System.map-$version"
  35. cp .config "$tmpdir/boot/config-$version"
  36. cp $KBUILD_IMAGE "$tmpdir/boot/vmlinuz-$version"
  37. fi
  38. if grep -q '^CONFIG_MODULES=y' .config ; then
  39. INSTALL_MOD_PATH="$tmpdir" make KBUILD_SRC= modules_install
  40. if [ "$ARCH" == "um" ] ; then
  41. mv "$tmpdir/lib/modules/$version"/* "$tmpdir/usr/lib/uml/modules/$version/"
  42. rmdir "$tmpdir/lib/modules/$version"
  43. fi
  44. fi
  45. # Install the maintainer scripts
  46. for script in postinst postrm preinst prerm ; do
  47. mkdir -p "$tmpdir/etc/kernel/$script.d"
  48. cat <<EOF > "$tmpdir/DEBIAN/$script"
  49. #!/bin/sh
  50. set -e
  51. test -d /etc/kernel/$script.d && run-parts --arg="$version" /etc/kernel/$script.d
  52. exit 0
  53. EOF
  54. chmod 755 "$tmpdir/DEBIAN/$script"
  55. done
  56. name="Kernel Compiler <$(id -nu)@$(hostname -f)>"
  57. # Generate a simple changelog template
  58. cat <<EOF > debian/changelog
  59. linux ($version-$revision) unstable; urgency=low
  60. * A standard release
  61. -- $name $(date -R)
  62. EOF
  63. # Generate a control file
  64. if [ "$ARCH" == "um" ]; then
  65. cat <<EOF > debian/control
  66. Source: linux
  67. Section: base
  68. Priority: optional
  69. Maintainer: $name
  70. Standards-Version: 3.6.1
  71. Package: $packagename
  72. Provides: kernel-image-$version, linux-image-$version
  73. Architecture: any
  74. Description: User Mode Linux kernel, version $version
  75. User-mode Linux is a port of the Linux kernel to its own system call
  76. interface. It provides a kind of virtual machine, which runs Linux
  77. as a user process under another Linux kernel. This is useful for
  78. kernel development, sandboxes, jails, experimentation, and
  79. many other things.
  80. .
  81. This package contains the Linux kernel, modules and corresponding other
  82. files version $version
  83. EOF
  84. else
  85. cat <<EOF > debian/control
  86. Source: linux
  87. Section: base
  88. Priority: optional
  89. Maintainer: $name
  90. Standards-Version: 3.6.1
  91. Package: $packagename
  92. Provides: kernel-image-$version, linux-image-$version
  93. Architecture: any
  94. Description: Linux kernel, version $version
  95. This package contains the Linux kernel, modules and corresponding other
  96. files version $version
  97. EOF
  98. fi
  99. # Fix some ownership and permissions
  100. chown -R root:root "$tmpdir"
  101. chmod -R go-w "$tmpdir"
  102. # Perform the final magic
  103. dpkg-gencontrol -isp
  104. dpkg --build "$tmpdir" ..
  105. exit 0