Magellan Linux

Diff of /trunk/grubby/new-kernel-pkg

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1706 by niro, Sat Feb 18 00:23:51 2012 UTC revision 2259 by niro, Mon Oct 21 14:03:18 2013 UTC
# Line 25  Line 25 
25  # along with this program.  If not, see <http://www.gnu.org/licenses/>.  # along with this program.  If not, see <http://www.gnu.org/licenses/>.
26  #  #
27    
28    read_os_release()
29    {
30     local NAME
31     local ID
32     local Version
33     local Version_ID
34     local PRETTY_NAME
35     local ANSI_COLOR
36     local CPE_NAME
37    
38     if [[ -f /etc/os-release ]]
39     then
40     source /etc/os-release
41    
42     case $1 in
43     name) echo "${NAME}" ;;
44     id) echo "${ID}" ;;
45     version) echo "${Version}" ;;
46     version_id) echo "${Version_ID}" ;;
47     pretty_name) echo "${PRETTY_NAME}" ;;
48     ansi_color) echo "${ANSI_COLOR}" ;;
49     cpe_name) echo "${CPE_NAME}" ;;
50     esac
51     fi
52    }
53    
54  PATH=/sbin:/bin:$PATH  PATH=/sbin:/bin:$PATH
55    
56  lilo=/sbin/lilo  lilo=/sbin/lilo
# Line 46  cfgGrub2="" Line 72  cfgGrub2=""
72  cfgGrub2Efi=""  cfgGrub2Efi=""
73  cfgGrub=""  cfgGrub=""
74  cfgLilo=""  cfgLilo=""
75    cfgExtlinux=""
76  cfguBoot=""  cfguBoot=""
77  runLilo=""  runLilo=""
78  grubConfig=""  grubConfig=""
79  grub2Config=""  grub2Config=""
80  grub2EfiConfig=""  grub2EfiConfig=""
81    extlinuxConfig=""
82    
83  ARCH=$(uname -m)  ARCH=$(uname -m)
84    
# Line 63  then Line 91  then
91  elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]  elif [[ ${ARCH} = ppc64 ]] || [[ ${ARCH} = ppc ]]
92  then  then
93   liloConfig=/etc/yaboot.conf   liloConfig=/etc/yaboot.conf
94     grub2Config=/boot/grub/grub.cfg
95   bootPrefix=/boot   bootPrefix=/boot
96   lilo=/sbin/ybin   lilo=/sbin/ybin
97   liloFlag=yaboot   liloFlag=yaboot
# Line 83  then Line 112  then
112   lilo=/sbin/zipl   lilo=/sbin/zipl
113   runLilo="yes"   runLilo="yes"
114   isx86=""   isx86=""
115  elif [[ ${ARCH} = armv7l ]]  elif [[ ${ARCH} =~ armv[5|7].*l ]]
116  then  then
117   liloConfig=""   liloConfig=""
118   bootPrefix=/boot   bootPrefix=/boot
119   ubootDir=${UBOOT_DIR:-"/boot/uboot"}   extlinuxConfig=$(readlink -f /etc/extlinux.conf 2>/dev/null)
120     ubootDir=${UBOOT_DIR:-"/boot"}
121   ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}   ubootScript=$ubootDir/${UBOOT_SCR:-"boot.scr"}
122   ubootKList=${UBOOT_KLIST:-"klist.txt"}   ubootKList=${UBOOT_KLIST:-"klist.txt"}
123   ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}   ubootDevice=/dev/${UBOOT_DEVICE:-"mmcblk0p1"}
124   ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"}   ubootDefaultImage=${UBOOT_UIMAGE:-"uImage"}
125   ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"}   ubootDefaultInitrd=${UBOOT_UINITRD:-"uInitrd"}
126     ubootAddress=${UBOOT_IMGADDR:-"0x00008000"}
127   mounted=""   mounted=""
128   liloFlag=""   liloFlag=""
129   isx86=""   isx86=""
# Line 102  else Line 133  else
133   grubConfig=/boot/grub/grub.conf   grubConfig=/boot/grub/grub.conf
134   grub2Config=/boot/grub/grub.cfg   grub2Config=/boot/grub/grub.cfg
135   grub2EfiConfig=/boot/grub/grub-efi.cfg   grub2EfiConfig=/boot/grub/grub-efi.cfg
136     extlinuxConfig=/boot/extlinux/extlinux.conf
137   bootPrefix=/boot   bootPrefix=/boot
138   liloFlag=lilo   liloFlag=lilo
139   isx86="yes"   isx86="yes"
# Line 139  usage() Line 171  usage()
171  install()  install()
172  {  {
173   # XXX kernel should be able to be specified also (or work right on ia64)   # XXX kernel should be able to be specified also (or work right on ia64)
174   if [ ! -f ${bootPrefix}/${kernelName}-${version} ]   if [ ! -f ${kernelImage} ]
175   then   then
176   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
177   return   return
# Line 164  install() Line 196  install()
196   if [[ -z ${initrdfile} ]]   if [[ -z ${initrdfile} ]]
197   then   then
198   [[ -n ${verbose} ]] && echo "No initrd, just adding system map"   [[ -n ${verbose} ]] && echo "No initrd, just adding system map"
199   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinitrd-${version}   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinitrd-${version}
200   else   else
201   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${bootPrefix}/${kernelName}-${version} ${bootPrefix}/vmlinux.sm-${version}   /sbin/addSystemMap ${bootPrefix}/System.map-${version} ${kernelImage} ${bootPrefix}/vmlinux.sm-${version}
202   /sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null   /sbin/addRamDisk ${initrdfile} ${bootPrefix}/System.map-${version} ${bootPrefix}/vmlinux.sm-${version} ${bootPrefix}/vmlinitrd-${version} 2>/dev/null
203   rm ${bootPrefix}/vmlinux.sm-${version}   rm ${bootPrefix}/vmlinux.sm-${version}
204   fi   fi
# Line 174  install() Line 206  install()
206   fi   fi
207    
208   # get the root filesystem to use   # get the root filesystem to use
209   rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab)   rootdevice=$(awk '{ if ($1 !~ /^[ \t]*#/ && $2 == "/") { print $1; }}' /etc/fstab  2>/dev/null)
210     if [[ -z $rootdevice ]]
211     then
212     rootdevice=$(grep -o -P "(?<=root=)\S+" /proc/cmdline)
213     fi
214    
215   if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]   if [[ -n ${mbkernel} ]] && [[ -n ${cfgLilo} ]] && [[ ${liloFlag} != elilo ]]
216   then   then
# Line 182  install() Line 218  install()
218   cfgLilo=""   cfgLilo=""
219   fi   fi
220    
221     if [[ -n ${banner} ]]
222     then
223     title="${banner} [ ${version} ]"
224     elif [[ $(read_os_release id) = magellan ]]
225     then
226     title="$(read_os_release name) $(read_os_release version_id) [ ${version} ]"
227     elif [ -f /etc/mageversion ]
228     then
229     title="Magellan Linux $(< /etc/mageversion) [ ${version} ]"
230     else
231     title="Magellan Linux [ ${version} ]"
232     fi
233    
234   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
235   then   then
236   [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grubConfig}"
237    
238   if [[ -n ${banner} ]]   ${grubby} --grub -c ${grubConfig} \
239   then   --add-kernel=${kernelImage} \
  title="${banner} (${version})"  
  elif [ -f /etc/mageversion ]  
  then  
  title="Magellan Linux $(< /etc/mageversion) (${version})"  
  else  
  title="Magellan Linux (${version})"  
  fi  
  ${grubby} --grub --add-kernel=${bootPrefix}/${kernelName}-${version} \  
240   ${INITRD} --copy-default ${makedefault} --title "${title}" \   ${INITRD} --copy-default ${makedefault} --title "${title}" \
241   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
242   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
# Line 206  install() Line 247  install()
247   then   then
248   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2Config}"
249    
  if [[ -n ${banner} ]]  
  then  
  title="${banner} (${version})"  
  elif [ -f /etc/mageversion ]  
  then  
  title="Magellan Linux $(< /etc/mageversion) (${version})"  
  else  
  title="Magellan Linux (${version})"  
  fi  
250   ${grubby} --grub2 -c ${grub2Config} \   ${grubby} --grub2 -c ${grub2Config} \
251   --add-kernel=${bootPrefix}/${kernelName}-${version} \   --add-kernel=${kernelImage} \
252   ${INITRD} --copy-default ${makedefault} --title "${title}" \   ${INITRD} --copy-default ${makedefault} --title "${title}" \
253   ${mbkernel:+--add-multiboot="${mbkernel}"} \   ${mbkernel:+--add-multiboot="${mbkernel}"} \
254   ${mbargs:+--mbargs="${mbargs}"} \   ${mbargs:+--mbargs="${mbargs}"} \
# Line 228  install() Line 260  install()
260   then   then
261   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${grub2EfiConfig}"
262    
263   if [[ -n ${banner} ]]   ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
264   then   --add-kernel=${kernelImage} \
  title="${banner} (${version})"  
  elif [ -f /etc/mageversion ]  
  then  
  title="Magellan Linux $(< /etc/mageversion) (${version})"  
  else  
  title="Magellan Linux (${version})"  
  fi  
  ${grubby} --grub2 -c ${grub2EfiConfig} \  
  --add-kernel=${bootPrefix}/${kernelName}-${version} \  
265   ${INITRD} --copy-default ${makedefault} --title "${title}" \   ${INITRD} --copy-default ${makedefault} --title "${title}" \
266   ${mbkernel:+--add-multiboot="${mbkernel}"} \   ${mbkernel:+--add-multiboot="${mbkernel}"} \
267   ${mbargs:+--mbargs="${mbargs}"} \   ${mbargs:+--mbargs="${mbargs}"} \
# Line 251  install() Line 274  install()
274   then   then
275   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"   [[ -n ${verbose} ]] && echo "adding ${version} to ${liloConfig}"
276    
277   ${grubby} --add-kernel=${bootPrefix}/${kernelName}-${version} ${INITRD} \   ${grubby} --add-kernel=${kernelImage} ${INITRD} \
278   --copy-default ${makedefault} --title ${version} \   --copy-default ${makedefault} --title ${version} \
279   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \   ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
280   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \   --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${version}" \
# Line 270  install() Line 293  install()
293   else   else
294   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "${liloConfig} does not exist, not running grubby"
295   fi   fi
296    
297     if [[ -n ${cfgExtlinux} ]]
298     then
299     [[ -n ${verbose} ]] && echo "adding ${version} to ${extlinuxConfig}"
300    
301     ${grubby} --extlinux -c ${extlinuxConfig} \
302     --add-kernel=${kernelImage} \
303     ${INITRD} --copy-default ${makedefault} --title "${title}" \
304     ${mbkernel:+--add-multiboot="${mbkernel}"} ${mbargs:+--mbargs="${mbargs}"} \
305     --args="root=${rootdevice} ${kernargs}" --remove-kernel="TITLE=${title}"
306     else
307     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
308     fi
309  }  }
310    
311  remove()  remove()
# Line 278  remove() Line 314  remove()
314   if [ -d /proc/iSeries ]   if [ -d /proc/iSeries ]
315   then   then
316   [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"   [[ -n ${verbose} ]] && echo "On an iSeries, remove img file"
317   rm -f ${bootPrefix}/${kernelName}-${version}.img 2>/dev/null   rm -f ${kernelImage}.img 2>/dev/null
318   return   return
319   fi   fi
320    
321   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
322   then   then
323   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${grubConfig}"
324   ${grubby} --grub --remove-kernel=${bootPrefix}/${kernelName}-${version}   ${grubby} --grub -c ${grubConfig} \
325     --remove-kernel=${kernelImage}
326   else   else
327   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"   [[ -n ${verbose} ]] && echo "${grubConfig} does not exist, not running grubby for grub 0.97"
328   fi   fi
# Line 293  remove() Line 330  remove()
330   then   then
331   [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2Config}"
332   ${grubby} --grub2 -c ${grub2Config} \   ${grubby} --grub2 -c ${grub2Config} \
333   --remove-kernel=${bootPrefix}/${kernelName}-${version}   --remove-kernel=${kernelImage}
334   else   else
335   [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"   [[ -n ${verbose} ]] && echo "${grub2Config} does not exist, not running grubby for grub 2"
336   fi   fi
337   if [[ -n ${cfgGrub2Efi} ]]   if [[ -n ${cfgGrub2Efi} ]]
338   then   then
339   [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${grub2EfiConfig}"
340   ${grubby} --grub2 -c ${grub2EfiConfig} \   ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
341   --remove-kernel=${bootPrefix}/${kernelName}-${version}   --remove-kernel=${kernelImage}
342   else   else
343   [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI"   [[ -n ${verbose} ]] && echo "${grub2EfiConfig} does not exist, not running grubby grub 2 with UEFI"
344   fi   fi
# Line 309  remove() Line 346  remove()
346   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
347   then   then
348   [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "removing ${version} from ${liloConfig}"
349   ${grubby} --remove-kernel=${bootPrefix}/${kernelName}-${version} --${liloFlag}   ${grubby} --remove-kernel=${kernelImage} --${liloFlag}
350    
351   if [[ -n ${runLilo} ]]   if [[ -n ${runLilo} ]]
352   then   then
# Line 333  remove() Line 370  remove()
370   then   then
371   tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)   tmpKList=$(mktemp ${ubootDir}/${ubootKList}.XXXX)
372   curversion=$(tail -n1 ${ubootDir}/${ubootKList})   curversion=$(tail -n1 ${ubootDir}/${ubootKList})
373   sed "/${version}/d" ${ubootDir}/${ubootKList} > ${tmpKList}   sed "/$version$/d" ${ubootDir}/${ubootKList} > ${tmpKList}
374   newversion=$(tail -n1 ${tmpKList})   newversion=$(tail -n1 ${tmpKList})
375   if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]   if [ -f ${ubootDir}/uImage-${newversion} ] && [ -f ${ubootDir}/uInitrd-${newversion} ]
376   then   then
# Line 368  remove() Line 405  remove()
405   fi   fi
406    
407   mv ${tmpKList} ${ubootDir}/${ubootKList}   mv ${tmpKList} ${ubootDir}/${ubootKList}
408     [ -x /sbin/a-b-c ] && /sbin/a-b-c
409   else   else
410   [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"   [[ -n ${verbose} ]] && echo "uImage ${newversion} does not exist!"
411   [ -f ${tmpKList} ] && rm -f ${tmpKList}   [ -f ${tmpKList} ] && rm -f ${tmpKList}
412   fi   fi
413   else   else
414   [[ -n ${verbose} ]] && echo "No previous kernel version. uBoot images not removed!"   [[ -n ${verbose} ]] && echo "No previous kernel version.  U-Boot images not removed!"
415   fi   fi
416   else   else
417   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not modifying ${ubootDir}"
418   fi   fi
419    
420     if [[ -n ${cfgExtlinux} ]]
421     then
422     [[ -n ${verbose} ]] && echo "removing ${version} from ${extlinuxConfig}"
423     ${grubby} --extlinux -c ${extlinuxConfig} \
424     --remove-kernel=${kernelImage}
425     else
426     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby for extlinux"
427     fi
428  }  }
429    
430  update()  update()
431  {  {
432   if [ ! -f ${bootPrefix}/${kernelName}-${version} ]   if [ ! -f ${kernelImage} ]
433   then   then
434   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"   [[ -n ${verbose} ]] && echo "kernel for ${version} does not exist, not running grubby"
435   return   return
# Line 403  update() Line 450  update()
450   if [[ -n ${cfgGrub} ]]   if [[ -n ${cfgGrub} ]]
451   then   then
452   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grubConfig}"
453   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \   ${grubby} --grub -c ${grubConfig} \
454     --update-kernel=${kernelImage} \
455   ${INITRD} \   ${INITRD} \
456   ${kernargs:+--args="${kernargs}"} \   ${kernargs:+--args="${kernargs}"} \
457   ${removeargs:+--remove-args="${removeargs}"}   ${removeargs:+--remove-args="${removeargs}"}
# Line 415  update() Line 463  update()
463   then   then
464   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2Config}"
465   ${grubby} --grub2 -c ${grub2Config} \   ${grubby} --grub2 -c ${grub2Config} \
466   --update-kernel=${bootPrefix}/${kernelName}-${version} \   --update-kernel=${kernelImage} \
467   ${INITRD} \   ${INITRD} \
468   ${kernargs:+--args="${kernargs}"} \   ${kernargs:+--args="${kernargs}"} \
469   ${removeargs:+--remove-args="${removeargs}"}   ${removeargs:+--remove-args="${removeargs}"}
# Line 426  update() Line 474  update()
474   if [[ -n ${cfgGrub2Efi} ]]   if [[ -n ${cfgGrub2Efi} ]]
475   then   then
476   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${grub2EfiConfig}"
477   ${grubby} --grub2 -c ${grub2EfiConfig} \   ${grubby} --grub2 -c ${grub2EfiConfig} --efi \
478   --update-kernel=${bootPrefix}/${kernelName}-${version} \   --update-kernel=${kernelImage} \
479   ${INITRD} \   ${INITRD} \
480   ${kernargs:+--args="${kernargs}"} \   ${kernargs:+--args="${kernargs}"} \
481   ${removeargs:+--remove-args="${removeargs}"}   ${removeargs:+--remove-args="${removeargs}"}
# Line 438  update() Line 486  update()
486   if [[ -n ${cfgLilo} ]]   if [[ -n ${cfgLilo} ]]
487   then   then
488   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"   [[ -n ${verbose} ]] && echo "updating ${version} from ${liloConfig}"
489   ${grubby} --update-kernel=${bootPrefix}/${kernelName}-${version} \   ${grubby} --update-kernel=${kernelImage} \
490   ${INITRD} \   ${INITRD} \
491   ${kernargs:+--args="${kernargs}"} \   ${kernargs:+--args="${kernargs}"} \
492   ${removeargs:+--remove-args="${removeargs}"} \   ${removeargs:+--remove-args="${removeargs}"} \
# Line 463  update() Line 511  update()
511   [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."   [[ -n ${verbose} ]] && echo "adding $version to ${ubootDir}..."
512    
513   [[ -n ${verbose} ]] && echo "creating uImage-${version}"   [[ -n ${verbose} ]] && echo "creating uImage-${version}"
514   mkimage -A arm -O linux -T kernel -C none -a 0x80008000 -e 0x80008000 \   mkimage -A arm -O linux -T kernel -C none -a ${ubootAddress} \
515   -n ${version} -d ${bootPrefix}/${kernelName}-${version} ${ubootDir}/uImage-${version}   -e ${ubootAddress} -n ${version} \
516     -d ${kernelImage} ${ubootDir}/uImage-${version}
517    
518   [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"   [[ -n ${verbose} ]] && echo "creating uInitrd-${version}"
519   mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \   mkimage -A arm -O linux -T ramdisk -C none -a 0 -e 0 \
# Line 483  update() Line 532  update()
532   [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit   [[ -n ${verbose} ]] && echo "copy uInitrd-${version} error, kernel not installed!" && exit
533   fi   fi
534   echo ${version} >> ${ubootDir}/${ubootKList}   echo ${version} >> ${ubootDir}/${ubootKList}
535     [ -x /sbin/a-b-c ] && /sbin/a-b-c
536   else   else
537   [[ -n ${verbose} ]] && echo "cannot make ${version} the default"   [[ -n ${verbose} ]] && echo "cannot make ${version} the default"
538   fi   fi
539   else   else
540   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"   [[ -n ${verbose} ]] && echo "${ubootScript} does not exist, not setting up ${ubootDir}"
541   fi   fi
542    
543     if [[ -n ${cfgExtlinux} ]]
544     then
545     [[ -n ${verbose} ]] && echo "updating ${version} from ${extlinuxConfig}"
546     ${grubby} --extlinux -c ${extlinuxConfig} \
547     --update-kernel=${kernelImage} \
548     ${INITRD} \
549     ${kernargs:+--args="${kernargs}"} \
550     ${removeargs:+--remove-args="${removeargs}"}
551     else
552     [[ -n ${verbose} ]] && echo "${extlinuxConfig} does not exist, not running grubby"
553     fi
554  }  }
555    
556  mkinitrd()  makeinitrd()
557  {  {
558   if [[ -n ${dracut} ]]   if [[ -n ${dracut} ]]
559   then   then
560   tool="/sbin/dracut ${dracuthostonly} -f ${initrdfile} ${version}"   tool="dracut ${dracuthostonly} -f ${initrdfile} ${version}"
561   else   else
562   tool="/sbin/mkinitrd --allow-missing -f ${initrdfile} ${version}"   tool="mkinitrd --allow-missing -f ${initrdfile} ${version}"
563   fi   fi
564   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"   [[ -n ${verbose} ]] && echo "creating initrd ${initrdfile} using ${version}"
565   ${tool}   ${tool}
# Line 524  doDepmod() Line 586  doDepmod()
586  doRmmoddep()  doRmmoddep()
587  {  {
588   [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"   [[ -n ${verbose} ]] && echo "removing modules.dep info for ${version}"
589   [ -d /lib/modules/${version} ] && rm -f /lib/modules/${version}/modules.*   if [ -d /lib/modules/${version} ]
590     then
591     rm -f /lib/modules/${version}/modules.*.bin \
592     /lib/modules/${version}/modules.{alias,dep,devname,symbols,softdep}
593     fi
594  }  }
595    
596    
# Line 548  do Line 614  do
614   ;;   ;;
615    
616   --initrdfile*)   --initrdfile*)
617   if echo $1 | grep '=' >/dev/null   if [[ $1 == --initrdfile\=* ]]
618   then   then
619   initrdfile=$(echo $1 | sed 's/^--initrdfile=//')   initrdfile=${1#--initrdfile=}
620   else   else
621   initrdfile=$2   initrdfile=$2
622   shift   shift
# Line 558  do Line 624  do
624   ;;   ;;
625    
626   --kernel-args*)   --kernel-args*)
627   if echo $1 | grep '=' >/dev/null   if [[ $1 == --kernel-args\=* ]]
628   then   then
629   kernargs=$(echo $1 | sed 's/^--kernel-args=//')   kernargs=${1#--kernel-args=}
630   else   else
631   kernargs=$2   kernargs=$2
632   shift   shift
# Line 568  do Line 634  do
634   ;;   ;;
635    
636   --remove-args*)   --remove-args*)
637   if echo $1 | grep '=' >/dev/null   if [[ $1 == --remove-args\=* ]]
638   then   then
639   removeargs=$(echo $1 | sed 's/^--remove-args=//')   removeargs=${1#--remove-args=}
640   else   else
641   removeargs=$2   removeargs=$2
642   shift   shift
# Line 578  do Line 644  do
644   ;;   ;;
645    
646   --banner*)   --banner*)
647   if echo $1 | grep '=' >/dev/null   if [[ $1 == --banner\=* ]]
648   then   then
649   banner=$(echo $1 | sed 's/^--banner=//')   banner=${1#--banner=}
650   else   else
651   banner=$2   banner=$2
652   shift   shift
# Line 588  do Line 654  do
654   ;;   ;;
655    
656   --multiboot*)   --multiboot*)
657   if echo $1 |grep '=' >/dev/null   if [[ $1 == --multiboot\=* ]]
658   then   then
659   mbkernel=$(echo $1 | sed 's/^--multiboot=//')   mbkernel=${1#--multiboot=}
660   else   else
661   # can't really support having an optional second arg here   # can't really support having an optional second arg here
662   # sorry!   # sorry!
# Line 599  do Line 665  do
665   ;;   ;;
666    
667   --mbargs*)   --mbargs*)
668   if echo $1 |grep '=' >/dev/null   if [[ $1 == --mbargs\=* ]]
669   then   then
670   mbargs=$(echo $1 | sed 's/^--mbargs=//')   mbargs=${1#--mbargs=}
671   else   else
672   mbargs="$2"   mbargs="$2"
673   shift   shift
# Line 620  do Line 686  do
686   makedefault="--make-default"   makedefault="--make-default"
687   ;;   ;;
688    
689   --package)   --package*)
690   if echo $1 | grep '=' >/dev/null   if [[ $1 == --package\=* ]]
691   then   then
692   package=$(echo $1 | sed 's/^--package=//')   package=${1#--package=}
693   else   else
694   package=$2   package=$2
695   shift   shift
# Line 638  do Line 704  do
704   addplymouthinitrd=--add-plymouth-initrd   addplymouthinitrd=--add-plymouth-initrd
705   ;;   ;;
706    
707     --kernel-image*)
708     if [[ $1 == --kernel-image\=* ]]
709     then
710     kernelImage=${1#--kernel-image=}
711     else
712     kernelImage="$2"
713     shift
714     fi
715     if ! [[ -f ${kernelImage} ]]
716     then
717     echo "Can't find kernel image '${kernelImage}'" >&2
718     usage
719     exit 1
720     fi
721     ;;
722    
723   -v)   -v)
724   verbose=-v   verbose=-v
725   ;;   ;;
# Line 685  then Line 767  then
767   fi   fi
768  fi  fi
769    
770    [[ ${kernelImage} ]] || kernelImage="${bootPrefix}/${kernelName}-${version}"
771    
772  # set the initrd file based on arch; ia64 is the only currently known oddball  # set the initrd file based on arch; ia64 is the only currently known oddball
773  if [[ -z ${initrdfile} ]]  if [[ -z ${initrdfile} ]]
774  then  then
# Line 706  fi Line 790  fi
790  # add dracut i18n, keyboard and plymouth kernel args if requested  # add dracut i18n, keyboard and plymouth kernel args if requested
791  if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]  if [[ -n ${dracut} ]] || [[ -n ${adddracutargs} ]]
792  then  then
793   [ -r /etc/conf.d/keymap ] && . /etc/conf.d/keymap   if [ -r /etc/vconsole.conf ]
  [ -r /etc/conf.d/consolefont ] && . /etc/conf.d/consolefont  
   
  if [[ -n ${KEYMAP} ]]  
794   then   then
795   kernargs="${kernargs} KEYTABLE=${KEYMAP}"   . /etc/vconsole.conf
796    
797     for i in SYSFONT SYSFONTACM UNIMAP KEYTABLE
798     do
799     val=$(eval echo \$$i)
800     [[ -n ${val} ]] && kernargs="${kernargs} ${i}=${val}"
801     done
802     else
803     if [ -r /etc/conf.d/consolefont ]
804     then
805     . /etc/conf.d/consolefont
806    
807     if [[ -n ${CONSOLEFONT} ]]
808     then
809     kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"
810     fi
811     fi
812    
813     if  [ -r /etc/conf.d/keymap ]
814     then
815     . /etc/conf.d/keymap
816    
817     if [[ -n ${KEYMAP} ]]
818     then
819     kernargs="${kernargs} KEYTABLE=${KEYMAP}"
820     fi
821     fi
822   fi   fi
823    
824   if [[ -n ${CONSOLEFONT} ]]   if [ -r /etc/locale.conf ]
825   then   then
826   kernargs="${kernargs} SYSFONT=${CONSOLEFONT}"   . /etc/locale.conf
827    
828     if [[ -n ${LANG} ]]
829     then
830     kernargs="${kernargs} LANG=${LANG}"
831     fi
832   fi   fi
833  fi  fi
834    
# Line 738  fi Line 850  fi
850    
851  if [[ ${initrd} = make ]]  if [[ ${initrd} = make ]]
852  then  then
853   mkinitrd   makeinitrd
854  elif [[ ${initrd} = remove ]]  elif [[ ${initrd} = remove ]]
855  then  then
856   rminitrd   rminitrd
# Line 754  fi Line 866  fi
866  [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1  [[ -n ${grub2Config} ]] && [ -f ${grub2Config} ] && cfgGrub2=1
867  [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1  [[ -n ${grub2EfiConfig} ]] && [ -f ${grub2EfiConfig} ] && cfgGrub2Efi=1
868  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1  [[ -n ${liloConfig} ]] && [ -f ${liloConfig} ] && cfgLilo=1
869    [[ -n ${extlinuxConfig} ]] && [ -f ${extlinuxConfig} ] && cfgExtlinux=1
870    
871  # if we have a uBoot directory, check if it is mounted.  # if we have a U-Boot directory, but no boot script, check if the directory
872  # if not, mount it. Then check if a boot script exists.  # is mounted.  If not, mount it, and then check if a boot script exists.
873  if [[ -n ${ubootDir} ]]  if [[ -n ${ubootDir} ]]
874  then  then
875   mountEntry=$(mount | grep ${ubootDir})   if [ -f ${ubootScript} ]
  if [[ -z ${mountEntry} ]]  
876   then   then
877   mount ${ubootDevice} ${ubootDir}   cfguBoot=1
878   mounted=1   else
879     mountEntry=$(mount | grep ${ubootDir})
880     if [[ -z ${mountEntry} ]]
881     then
882     mount ${ubootDevice} ${ubootDir}
883     mounted=1
884     fi
885     [ -f ${ubootScript} ] && cfguBoot=1
886     fi
887    fi
888    
889    # if we're using U-Boot, check if the default load address should change
890    if [[ -n ${cfguBoot} ]] && [[ -z ${UBOOT_IMGADDR} ]]
891    then
892     [[ ${version}  =~ .([^.]*)$ ]]
893     platform=${BASH_REMATCH[1]}
894     # A few platforms use an alternate kernel load address
895     if [[ ${platform} = omap ]]
896     then
897     ubootAddress=0x80008000
898     elif [[ ${platform} = imx ]]
899     then
900     ubootAddress=0x90008000
901   fi   fi
  [ -f ${ubootScript} ] && cfguBoot=1  
902  fi  fi
903    
904  # if we have a lilo config on an x86 box, see if the default boot loader  # if we have a lilo config on an x86 box, see if the default boot loader
# Line 786  then Line 919  then
919   update   update
920  fi  fi
921    
922    # if we mounted the U-Boot directory, unmount it.
923    [[ -n ${mounted} ]] && umount ${ubootDir}
924    
925  exit 0  exit 0

Legend:
Removed from v.1706  
changed lines
  Added in v.2259