Got an iPhone or iPad? We have a brand new Pastebin App for both devices, and it's totally free! Click here to download the new Pastebin App for iOS.
Guest

ashnazg

By: a guest on Sep 27th, 2007  |  syntax: None  |  size: 3.32 KB  |  hits: 333  |  expires: Never
download  |  raw  |  embed  |  report abuse
Copied
  1. #!/bin/bash
  2.  
  3. ###########################
  4. ##  Instructions by Eric ##
  5. ###########################
  6.  
  7. #####  ATTRIBUTES  ################################
  8. CURRENT_KERNEL=NOT_SET_YET
  9. NEW_KERNEL=NOT_SET_YET
  10.  
  11. #####  METHODS  ################################
  12. setEnv() {
  13.         MAINDIR=/root/sysadmin/kernel
  14.         LOG=$MAINDIR/kernel_build.log
  15. }
  16.  
  17. log() {
  18.         # print a log message to stdout
  19.         echo `date` " -- $1" | tee -a $LOG
  20. }
  21.  
  22. getCurrentVersion() {
  23.         # determine the current kernel version by parsing what /usr/src/linux is linked to
  24.         log "   called getCurrentVersion() (STUB)..."
  25.         CURRENT_KERNEL=2.6.17-gentoo-r4
  26. }
  27.  
  28. getNewestVersion() {
  29.         # determine the newest kernel version by parsing all directory names in /usr/src
  30.         log "   called getNewestVersion() (STUB)..."
  31.         NEW_KERNEL=2.6.17-gentoo-r7
  32. }
  33.  
  34.  
  35. #####  MAIN  ###################################
  36. log "Starting..."
  37. setEnv
  38.  
  39. # ensure we're ready to do this
  40. getCurrentVersion
  41. getNewestVersion
  42. if [ "${CURRENT_KERNEL}" == NOT_SET_YET ]
  43. then
  44.         log "FAILURE:  CURRENT_KERNET is not set ( ${CURRENT_KERNEL} )"
  45.         exit 666
  46. fi
  47. if [ "${NEW_KERNEL}" == NOT_SET_YET ]
  48. then
  49.         log "FAILURE:  NEW_KERNET is not set ( ${NEW_KERNEL} )"
  50.         exit 666
  51. fi
  52. if [ "${NEW_KERNEL}" == "${CURRENT_KERNEL}" ]
  53. then
  54.         log "FAILURE:  NEW_KERNEL $NEW_KERNEL matches CURRENT_KERNEL $CURRENT_KERNEL"
  55.         exit 1
  56. fi
  57.  
  58. # ensure we have most recent updates of linux source
  59. log "   emerge gentoo-sources..."
  60. #emerge gentoo-sources
  61.  
  62. # link to newest source
  63. log "   relink /usr/src/linux..."
  64. cd /usr/src
  65. rm linux
  66. ln -s /usr/src/linux-${NEW_KERNEL} /usr/src/linux
  67.  
  68. cd /usr/src/linux
  69. # The above line will change to whatever version is present in /usr/src
  70.  
  71. # do NOT pull in your existing kernel config to use here UNLESS...
  72. # per Gentoo handbook, it's only safe to use old config when changing gentoo-r?? releases (i.e. r4 to r5), and NOT larger releases (i.e. 2.6.11 to 2.6.12)
  73.         log "   copy existing config..."
  74.         cp /usr/src/linux-$CURRENT_KERNEL/.config /usr/src/linux-$NEW_KERNEL/
  75.  
  76. # run MenuConfig to review/set kernel parameters
  77. log "   launch menuconfig..."
  78. make menuconfig
  79. # Now enable/disable anything that you have decided that you want or no longer need
  80.  
  81. # do the compilation, kernel copy to /boot, and the module installation
  82. log "   build and install the new kernel..."
  83. make && make install && make modules_install
  84.         # here are the manual steps accomplished by "make install"
  85.         # cp System.map /boot/System.map-linux-2.6.10-gentoo-r7
  86.         # cp .config /boot/config-linux-2.6.10-gentoo-r7
  87.         # cp arch/i386/boot/bzImage /boot/kernel-linux-2.6.10-gentoo-r7
  88.  
  89. log "   now add new entry /boot/grub/grub.conf pointing to the new kernel. "
  90. log "      do NOT remove the entry for your old kernel until you are sure that this one works correctly."
  91. GRUB=/boot/grub/grub.conf
  92. mount /boot
  93. echo " " >> $GRUB
  94. echo "title Gentoo Linux ($NEW_KERNEL) - TESTING" >> $GRUB
  95. echo "root (hd0,0)" >> $GRUB
  96. echo "kernel /vmlinuz-$NEW_KERNEL root=/dev/hda3 udev" >> $GRUB
  97. echo " " >> $GRUB
  98.  
  99. log "   Now, ( is reboot necessary???) re-emerge any additional modules that you may have for this new kernel, i.e. wireless, video, etc."
  100. ACCEPT_KEYWORDS="~x86" module-rebuild rebuild
  101.  
  102. log "Finished."