home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Linux / Ubuntu_64-bit / ubuntu-11.04-desktop-amd64.iso / casper / filesystem.squashfs / sbin / installkernel < prev    next >
Text File  |  2011-01-20  |  2KB  |  84 lines

  1. #!/bin/sh
  2. # Copyright (C) 1995 - 1998, Ian A. Murdock <imurdock@debian.org>
  3. # Copyright (C) 1998, 1999, Guy Maor
  4. # Copyright (C) 2002, Matthew Wilcox
  5. # Copyright (C) 2002, 2004, 2005, 2007, 2009  Clint Adams
  6. # Copyright (C) 2009  Manoj Srivasta
  7. #
  8. # Install the kernel on a Debian Linux system.
  9. #
  10. # This script is called from /usr/src/linux/arch/i386/boot/install.sh.
  11. # If you install it as /sbin/installkernel, you can do a "make install"
  12. # from a generic kernel source tree, and the image will be installed to
  13. # the proper place for Debian GNU/Linux.
  14.  
  15. set -e
  16.  
  17. # Parse the command line options.  Of course, powerpc has to be all
  18. # different, and passes in a fifth argument, just because it is
  19. # "special". We ignore the fifth argument, and do not flag is as an
  20. # error, which it would be for any arch apart from powerpc
  21. if [ $# -eq 3 ] || [ $# -eq 4 ] || [ $# -eq 5 ] ; then
  22.   img="$2"
  23.   map="$3"
  24.   ver="$1"
  25.   if [ $# -ge 4 ] && [ -n "$4" ] ; then
  26.       dir="$4"
  27.   else
  28.       dir="/boot"
  29.   fi
  30. else
  31.   echo "Usage: installkernel <version> <image> <System.map> <directory>"
  32.   exit 1
  33. fi
  34.  
  35. # Create backups of older versions before installing
  36. updatever () {
  37.   if [ -f "$dir/$1-$ver" ] ; then
  38.     mv "$dir/$1-$ver" "$dir/$1-$ver.old"
  39.   fi
  40.  
  41.   cat "$2" > "$dir/$1-$ver"
  42.  
  43.   # This section is for backwards compatibility only
  44.   if test -f "$dir/$1" ; then
  45.     # The presence of "$dir/$1" is unusual in modern intallations, and
  46.     # the results are mostly unused.  So only recreate them if they
  47.     # already existed.
  48.     if test -L "$dir/$1" ; then
  49.         # If we were using links, continue to use links, updating if
  50.         # we need to.
  51.         if [ "$(readlink -f ${dir}/${1})" = "${dir}/${1}-${ver}" ]; then
  52.             # Yup, we need to change
  53.             ln -sf "$1-$ver.old" "$dir/$1.old"
  54.         else
  55.             mv "$dir/$1" "$dir/$1.old"
  56.         fi
  57.         ln -sf "$1-$ver" "$dir/$1"
  58.     else                        # No links
  59.         mv "$dir/$1" "$dir/$1.old"
  60.         cat "$2" > "$dir/$1"
  61.     fi
  62.   fi
  63. }
  64.  
  65. if [ "$(basename $img)" = "vmlinux" ] ; then
  66.   img_dest=vmlinux
  67. else
  68.   img_dest=vmlinuz
  69. fi
  70. updatever $img_dest "$img"
  71. updatever System.map "$map"
  72.  
  73. config=$(dirname "$map")
  74. config="${config}/.config"
  75. if [ -f "$config" ] ; then
  76.   updatever config "$config"
  77. fi
  78.  
  79. run-parts --verbose --exit-on-error --arg="$ver" --arg="$dir/$img_dest-$ver" \
  80.   /etc/kernel/postinst.d
  81.  
  82. exit 0
  83.